Search in sources :

Example 1 with QueryTreeNode

use of org.apache.derby.impl.sql.compile.QueryTreeNode in project derby by apache.

the class DataDictionaryImpl method getTransitionVariables.

/**
 * Get all columns that reference transition variables in triggers.
 * The columns should be returned in the same order as in the SQL text.
 *
 * @param node the node in which to look for transition variables
 * @param oldReferencingName the name of the old transition variable
 * @param newReferencingName the name of the new transition variable
 * @return all references to transition variables
 */
private static SortedSet<ColumnReference> getTransitionVariables(Visitable node, String oldReferencingName, String newReferencingName) throws StandardException {
    // First get all column references.
    SortedSet<ColumnReference> refs = ((QueryTreeNode) node).getOffsetOrderedNodes(ColumnReference.class);
    // Then remove all that are not referencing a transition variable.
    Iterator<ColumnReference> it = refs.iterator();
    while (it.hasNext()) {
        TableName tableName = it.next().getQualifiedTableName();
        if (!isTransitionVariable(tableName, oldReferencingName, newReferencingName)) {
            it.remove();
        }
    }
    // variables.
    return refs;
}
Also used : TableName(org.apache.derby.impl.sql.compile.TableName) QueryTreeNode(org.apache.derby.impl.sql.compile.QueryTreeNode) ColumnReference(org.apache.derby.impl.sql.compile.ColumnReference)

Aggregations

ColumnReference (org.apache.derby.impl.sql.compile.ColumnReference)1 QueryTreeNode (org.apache.derby.impl.sql.compile.QueryTreeNode)1 TableName (org.apache.derby.impl.sql.compile.TableName)1