After parsing, the node contains targetTableName: the target table for the insert collist: a list of column names, if specified queryexpr: the expression being inserted, either a values clause or a select form; both of these are represented via the SelectNode, potentially with a TableOperatorNode such as UnionNode above it.
After binding, the node has had the target table's descriptor located and inserted, and the queryexpr and collist have been massaged so that they are identical to the table layout. This involves adding any default values for missing columns, and reordering the columns to match the table's ordering of them.
After optimizing, ...
| Modifier and Type | Field and Description |
|---|---|
| public boolean | |
| protected boolean | |
| private boolean | |
| public ValueNode | |
| private boolean | |
| private ValueNode | |
| public FKInfo | |
| public boolean | |
| private boolean | |
| private ValueNode | |
| private OrderByList | |
| private ResultColumnList | |
| public Properties |
| Access | Constructor and Description |
|---|---|
| pack-priv | InsertNode(QueryTreeNode
The name of the table/VTI to insert into targetName, ResultColumnList A ResultColumnList with the names of the
columns to insert into. May be null if the
user did not specify the columns - in this
case, the binding phase will have to figure
it out. insertColumns, ResultSetNode The query expression that will generate
the rows to insert into the given table queryExpression, MatchingClauseNode Non-null if this DML is part of a MATCHED clause of a MERGE statement. matchingClause, Properties The properties specified on the target table targetProperties, OrderByList The order by list for the source result set,
null if no order by list orderByList, ValueNode The value of a offset, ValueNode The value of a fetchFirst, boolean True if the offset/fetchFirst clauses come
from JDBC limit/offset escape syntax hasJDBClimitClause, ContextManager The context manager cm)Constructor for an InsertNode. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | acceptChildren(Visitor
the visitor v)Overrides org. Accept the visitor for all visitable children of this node. |
| public void | bindStatement()
Overrides org. Bind this InsertNode. |
| pack-priv ResultSetNode | Returns: a node representing the source for the insertcurrent node in the result set tree resultSet, boolean FALSE if the column list needs reordering inOrder, int[] correspondence between RCLs colMap, boolean true if DEFAULT clauses were replaced with generated expressions defaultsWereReplaced)Process ResultSet column lists for projection and autoincrement. |
| pack-priv void | generate(ActivationClassBuilder
The ActivationClassBuilder for the class being built acb, MethodBuilder the method for the execute() method to be built mb)Overrides org. Code generation for insert creates an expression for: ResultSetFactory.getInsertResultSet(resultSet.generate(ps), generationClausesResult, checkConstrainResult, this ) |
| private void | getAffectedIndexes(TableDescriptor
TableDescriptor for the table being inserted into
or deleted from td)Get the list of indexes on the table being inserted into. |
| pack-priv boolean[] | Returns: A boolean[] to track the (0-based) columns which are indexed.Create a boolean[] to track the (0-based) columns which are indexed. |
| pack-priv int | getPrivType()
Overrides org. Return default privilege needed for this node. |
| protected final int | Returns: the type of statementOverrides org. Return the type of statement, something from StatementType. |
| pack-priv static int | Returns: the type of statementReturn the statement type, where it is dependent on the targetProperties. |
| public ConstantAction | makeConstantAction()
Overrides org. Compile constants that Execution will use |
| public void | optimizeStatement()
Overrides org. Generate an optimized QueryTree from a bound QueryTree. |
| pack-priv void | printSubNodes(int
The depth of this node in the tree depth)Overrides org. Prints the sub-nodes of this object. |
| public boolean | Returns: true if references SESSION schema tables, else falseOverrides org. Return true if the node references SESSION schema tables (temporary or permanent) |
| private void | |
| pack-priv String | |
| public String | Returns: This object as a StringOverrides org. Convert this object to a String. |
| private boolean | Returns: Whether or not bulkInsert is allowed.The DataDictionary dd, String The insert mode mode)Do the bind time checks to see if bulkInsert is allowed on this table. |
| private void | verifyTargetProperties(DataDictionary
The DataDictionary dd)Verify that the target properties that we are interested in all hold valid values. |
| autoincrementColumnSetToDEFAULT | back to summary |
|---|---|
| public boolean autoincrementColumnSetToDEFAULT | |
| bulkInsert | back to summary |
|---|---|
| protected boolean bulkInsert | |
| bulkInsertReplace | back to summary |
|---|---|
| private boolean bulkInsertReplace | |
| checkConstraints | back to summary |
|---|---|
| public ValueNode checkConstraints Hides org. | |
| deferred | back to summary |
|---|---|
| private boolean deferred | |
| fetchFirst | back to summary |
|---|---|
| private ValueNode fetchFirst | |
| fkInfo | back to summary |
|---|---|
| public FKInfo fkInfo Hides org. | |
| hasDeferrableCheckConstraints | back to summary |
|---|---|
| public boolean hasDeferrableCheckConstraints | |
| hasJDBClimitClause | back to summary |
|---|---|
| private boolean hasJDBClimitClause | |
| offset | back to summary |
|---|---|
| private ValueNode offset | |
| orderByList | back to summary |
|---|---|
| private OrderByList orderByList | |
| targetColumnList | back to summary |
|---|---|
| private ResultColumnList targetColumnList | |
| targetProperties | back to summary |
|---|---|
| public Properties targetProperties | |
| InsertNode | back to summary |
|---|---|
| pack-priv InsertNode(QueryTreeNode targetName, ResultColumnList insertColumns, ResultSetNode queryExpression, MatchingClauseNode matchingClause, Properties targetProperties, OrderByList orderByList, ValueNode offset, ValueNode fetchFirst, boolean hasJDBClimitClause, ContextManager cm) Constructor for an InsertNode.
| |
| acceptChildren | back to summary |
|---|---|
| pack-priv void acceptChildren(Visitor v) throws StandardException Overrides org. Accept the visitor for all visitable children of this node.
| |
| bindStatement | back to summary |
|---|---|
| public void bindStatement() throws StandardException Overrides org. Bind this InsertNode. This means looking up tables and columns and getting their types, and figuring out the result types of all expressions, as well as doing view resolution, permissions checking, etc. Binding an insert will also massage the tree so that the collist and select column order/number are the same as the layout of the table in the store.
| |
| enhanceAndCheckForAutoincrement | back to summary |
|---|---|
| pack-priv ResultSetNode enhanceAndCheckForAutoincrement(ResultSetNode resultSet, boolean inOrder, int[] colMap, boolean defaultsWereReplaced) throws StandardException Process ResultSet column lists for projection and autoincrement. This method recursively descends the result set node tree. When it finds a simple result set, it processes any autoincrement columns in that rs by calling checkAutoIncrement. When it finds a compound result set, like a Union or a PRN, it recursively descends to the child(ren) nodes. Union nodes can arise due to multi-rows in VALUES clause), PRN nodes can arise when the set of columns being inserted is a subset of the set of columns in the table. In addition to checking for autoincrement columns in the result set, we may need to enhance and re-order the column list to match the column list of the table we are inserting into. This work is handled by ResultsetNode.enhanceRCLForInsert. Note that, at the leaf level, we need to enhance the RCL first, then check for autoincrement columns. At the non-leaf levels, we have to enhance the RCL, but we don't have to check for autoincrement columns, since they only occur at the leaf level. This way, all ColumnDescriptor of all rows will be set properly.
| |
| generate | back to summary |
|---|---|
| pack-priv void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException Overrides org. Code generation for insert creates an expression for: ResultSetFactory.getInsertResultSet(resultSet.generate(ps), generationClausesResult, checkConstrainResult, this )
| |
| getAffectedIndexes | back to summary |
|---|---|
| private void getAffectedIndexes(TableDescriptor td) throws StandardException Get the list of indexes on the table being inserted into. This is used by INSERT. This is an optimized version of what UPDATE and DELETE use.
| |
| getIndexedCols | back to summary |
|---|---|
| pack-priv boolean[] getIndexedCols() throws StandardException Create a boolean[] to track the (0-based) columns which are indexed.
| |
| getPrivType | back to summary |
|---|---|
| pack-priv int getPrivType() Overrides org. Doc from org. Return default privilege needed for this node. Other DML nodes can override this method to set their own default privilege.
| |
| getStatementType | back to summary |
|---|---|
| protected final int getStatementType() Overrides org. Return the type of statement, something from StatementType.
| |
| getStatementType | back to summary |
|---|---|
| pack-priv static int getStatementType(Properties targetProperties) Return the statement type, where it is dependent on the targetProperties. (insertMode = replace causes statement type to be BULK_INSERT_REPLACE.
| |
| makeConstantAction | back to summary |
|---|---|
| public ConstantAction makeConstantAction() throws StandardException Overrides org. Compile constants that Execution will use
| |
| optimizeStatement | back to summary |
|---|---|
| public void optimizeStatement() throws StandardException Overrides org. Doc from org. Generate an optimized QueryTree from a bound QueryTree. Actually, it can annotate the tree in place rather than generate a new tree, but this interface allows the root node of the optimized QueryTree to be different from the root node of the bound QueryTree. For non-optimizable statements, this method is a no-op. Throws an exception if the tree is not bound, or if the binding is out of date. Remove any duplicate ORDER BY columns and push an ORDER BY if present down to the source result set, before calling super.optimizeStatement.
| |
| printSubNodes | back to summary |
|---|---|
| pack-priv void printSubNodes(int depth) Overrides org. Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.
| |
| referencesSessionSchema | back to summary |
|---|---|
| public boolean referencesSessionSchema() throws StandardException Overrides org. Return true if the node references SESSION schema tables (temporary or permanent)
| |
| requestBulkInsert | back to summary |
|---|---|
| private void requestBulkInsert() Request bulk insert optimization at run time. | |
| statementToString | back to summary |
|---|---|
| pack-priv String statementToString() Overrides org.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing. | |
| verifyBulkInsert | back to summary |
|---|---|
| private boolean verifyBulkInsert(DataDictionary dd, String mode) throws StandardException Do the bind time checks to see if bulkInsert is allowed on this table. bulkInsert is disallowed at bind time for: o target databases o (tables with triggers?) (It is disallowed at execution time if the table has at least 1 row in it or if it is a deferred mode insert.)
| |
| verifyTargetProperties | back to summary |
|---|---|
| private void verifyTargetProperties(DataDictionary dd) throws StandardException Verify that the target properties that we are interested in all hold valid values. Note Any target property which is valid but cannot be supported due to a target database, etc. will be turned off quietly.
| |