Class CurrentOfNode

  • All Implemented Interfaces:
    Optimizable, Visitable

    public final class CurrentOfNode
    extends FromTable
    The CurrentOf operator is used by positioned DELETE and UPDATE to get the current row and location for the target cursor. The bind() operations for positioned DELETE and UPDATE add a column to the select list under the statement for the row location accessible from this node. This node is placed in the from clause of the select generated for the delete or update operation. It acts much like a FromBaseTable, using the information about the target table of the cursor to provide information.
    • Constructor Detail

      • CurrentOfNode

        CurrentOfNode​(java.lang.String correlationName,
                      java.lang.String cursor,
                      java.util.Properties tableProperties,
                      ContextManager cm)
    • Method Detail

      • makeForMerge

        static CurrentOfNode makeForMerge​(java.lang.String cursorName,
                                          FromBaseTable dummyTargetTable,
                                          ContextManager cm)

        Construct a dummy CurrentOfNode just for compiling the DELETE action of a MERGE statement.

      • bindNonVTITables

        ResultSetNode bindNonVTITables​(DataDictionary dataDictionary,
                                       FromList fromListParam)
                                throws StandardException
        Binding this FromTable means finding the prepared statement for the cursor and creating the result columns (the columns updatable on that cursor). We expect someone else to verify that the target table of the positioned update or delete is the table under this cursor.
        Overrides:
        bindNonVTITables in class ResultSetNode
        Parameters:
        dataDictionary - The DataDictionary to use for binding
        fromListParam - FromList to use/append to.
        Returns:
        ResultSetNode Returns this.
        Throws:
        StandardException - Thrown on error
      • bindExpressions

        void bindExpressions​(FromList fromListParam)
        Bind the expressions in this ResultSetNode. This means binding the sub-expressions, as well as figuring out what the return type is for each expression.
        Overrides:
        bindExpressions in class ResultSetNode
        Parameters:
        fromListParam - FromList to use/append to.
      • getMatchingColumn

        ResultColumn getMatchingColumn​(ColumnReference columnReference)
                                throws StandardException
        Try to find a ResultColumn in the table represented by this CurrentOfNode that matches the name in the given ColumnReference.
        Overrides:
        getMatchingColumn in class ResultSetNode
        Parameters:
        columnReference - The columnReference whose name we're looking for in the given table.
        Returns:
        A ResultColumn whose expression is the ColumnNode that matches the ColumnReference. Returns null if there is no match.
        Throws:
        StandardException - Thrown on error
      • preprocess

        ResultSetNode preprocess​(int numTables,
                                 GroupByList gbl,
                                 FromList fromList)
                          throws StandardException
        Preprocess a CurrentOfNode. For a CurrentOfNode, this simply means allocating a referenced table map to avoid downstream NullPointerExceptions. NOTE: There are no bits set in the referenced table map.
        Overrides:
        preprocess in class ResultSetNode
        Parameters:
        numTables - The number of tables in the DML Statement
        gbl - The group by list, if any
        fromList - The from list, if any
        Returns:
        ResultSetNode at top of preprocessed tree.
        Throws:
        StandardException - Thrown on error
      • optimize

        ResultSetNode optimize​(DataDictionary dataDictionary,
                               PredicateList predicateList,
                               double outerRows)
                        throws StandardException
        Optimize this CurrentOfNode. Nothing to do.
        Overrides:
        optimize in class ResultSetNode
        Parameters:
        dataDictionary - The DataDictionary to use for optimization
        predicateList - The PredicateList to optimize. This should be a single-table predicate with the table the same as the table in this FromTable.
        outerRows - The number of outer joining rows
        Returns:
        ResultSetNode The top of the optimized subtree.
        Throws:
        StandardException - Thrown on error
      • generate

        void generate​(ActivationClassBuilder acb,
                      MethodBuilder mb)
               throws StandardException
        Generation on a CurrentOfNode creates a scan on the cursor, CurrentOfResultSet.

        This routine will generate and return a call of the form:

        
                        ResultSetFactory.getCurrentOfResultSet(cursorName)
                   
        Overrides:
        generate in class QueryTreeNode
        Parameters:
        acb - The ActivationClassBuilder for the class being built
        mb - The execute() method to be built
        Throws:
        StandardException - Thrown on error
      • printSubNodes

        void printSubNodes​(int depth)
        Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.
        Overrides:
        printSubNodes in class ResultSetNode
        Parameters:
        depth - The depth of this node in the tree
      • toString

        public java.lang.String toString()
        Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.
        Overrides:
        toString in class FromTable
        Returns:
        This object as a String
      • getExposedName

        java.lang.String getExposedName()
        Description copied from class: FromTable
        Get the exposed name for this table, which is the name that can be used to refer to it in the rest of the query.
        Overrides:
        getExposedName in class FromTable
        Returns:
        The exposed name of this table.
      • updateTargetLockMode

        public int updateTargetLockMode()
        Get the lock mode for this table as the target of an update statement (a delete or update). This is implemented only for base tables and CurrentOfNodes.
        Overrides:
        updateTargetLockMode in class ResultSetNode
        Returns:
        The lock mode
        See Also:
        TransactionController
      • getExposedTableName

        TableName getExposedTableName()
      • getBaseCursorTargetTableName

        TableName getBaseCursorTargetTableName()
      • getCursorName

        java.lang.String getCursorName()
      • getCursorStatement

        ExecPreparedStatement getCursorStatement()
        Return the CursorNode associated with a positioned update/delete.
        Returns:
        CursorNode The associated CursorNode.