Visitable
public final class InsertNode extends DMLModGeneratedColumnsStatementNode
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 | Description |
---|---|---|
protected boolean |
bulkInsert |
|
private boolean |
bulkInsertReplace |
|
ValueNode |
checkConstraints |
|
private boolean |
deferred |
|
private ValueNode |
fetchFirst |
|
FKInfo |
fkInfo |
|
boolean |
hasDeferrableCheckConstraints |
|
private boolean |
hasJDBClimitClause |
|
private ValueNode |
offset |
|
private OrderByList |
orderByList |
|
private ResultColumnList |
targetColumnList |
|
java.util.Properties |
targetProperties |
autoincRowLocation, identitySequenceUUIDString
dependentTables, fkColArrays, fkColDescriptors, fkIndexConglomNumbers, fkRefActions, fkSchemaNames, fkTableNames, indexConglomerateNumbers, indexNames, indicesToMaintain, isDependentTable, lockMode, matchingClause, relevantCdl, relevantTriggers, resultColumnList, synonymTableName, targetTableDescriptor, targetTableName, targetVTI, triggerInfo
resultSet
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
EMPTY_TD_LIST, NEED_CURSOR_ACTIVATION, NEED_DDL_ACTIVATION, NEED_NOTHING_ACTIVATION, NEED_PARAM_ACTIVATION, NEED_ROW_ACTIVATION
Constructor | Description |
---|---|
InsertNode(QueryTreeNode targetName,
ResultColumnList insertColumns,
ResultSetNode queryExpression,
MatchingClauseNode matchingClause,
java.util.Properties targetProperties,
OrderByList orderByList,
ValueNode offset,
ValueNode fetchFirst,
boolean hasJDBClimitClause,
ContextManager cm) |
Constructor for an InsertNode.
|
Modifier and Type | Method | Description |
---|---|---|
(package private) void |
acceptChildren(Visitor v) |
Accept the visitor for all visitable children of this node.
|
void |
bindStatement() |
Bind this InsertNode.
|
(package private) ResultSetNode |
enhanceAndCheckForAutoincrement(ResultSetNode resultSet,
boolean inOrder,
int[] colMap,
boolean defaultsWereReplaced) |
Process ResultSet column lists for projection and autoincrement.
|
(package private) void |
generate(ActivationClassBuilder acb,
MethodBuilder mb) |
Code generation for insert
creates an expression for:
ResultSetFactory.getInsertResultSet(resultSet.generate(ps), generationClausesResult, checkConstrainResult, this )
|
private void |
getAffectedIndexes(TableDescriptor td) |
Get the list of indexes on the table being inserted into.
|
(package private) boolean[] |
getIndexedCols() |
Create a boolean[] to track the (0-based) columns which are indexed.
|
(package private) int |
getPrivType() |
Return default privilege needed for this node.
|
protected int |
getStatementType() |
Return the type of statement, something from
StatementType.
|
(package private) static int |
getStatementType(java.util.Properties targetProperties) |
Return the statement type, where it is dependent on
the targetProperties.
|
ConstantAction |
makeConstantAction() |
Compile constants that Execution will use
|
void |
optimizeStatement() |
Generate an optimized QueryTree from a bound QueryTree.
|
(package private) void |
printSubNodes(int depth) |
Prints the sub-nodes of this object.
|
boolean |
referencesSessionSchema() |
Return true if the node references SESSION schema tables (temporary or permanent)
|
private void |
requestBulkInsert() |
Request bulk insert optimization at run time.
|
(package private) java.lang.String |
statementToString() |
|
java.lang.String |
toString() |
Convert this object to a String.
|
private boolean |
verifyBulkInsert(DataDictionary dd,
java.lang.String mode) |
Do the bind time checks to see if bulkInsert is allowed on
this table.
|
private void |
verifyTargetProperties(DataDictionary dd) |
Verify that the target properties that we are interested in
all hold valid values.
|
getUUIDofSequenceGenerator
adjustDeferredFlag, bindConstraints, bindRowScopedExpression, generateCheckConstraints, generateCheckConstraints, generateCodeForTemporaryTable, generateGenerationClauses, getAffectedIndexes, getAllRelevantConstraints, getAllRelevantTriggers, getCheckConstraints, getFKInfo, getReadColMap, getResultColumnList, getResultColumnList, getSchemaDescriptor, getTriggerInfo, getXAffectedIndexes, hasCheckConstraints, hasGenerationClauses, inMatchingClause, isAtomic, markAffectedIndexes, normalizeSynonymColumns, parseAndBindGenerationClauses, parseCheckConstraint, parseGenerationClause, requiresDeferredProcessing, setRefActionInfo, setTarget, verifyTargetTable
activationKind, bind, bindExpressions, bindExpressionsWithTables, bindResultSetsWithTables, bindTables, generateParameterValueSet, getResultSetNode, makeResultDescription
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getTableDescriptor, getTypeCompiler, getUDTDesc, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, resolveTableToSynonym, setBeginOffset, setEndOffset, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
executeSchemaName, executeStatementName, generate, getCursorInfo, getSPSName, lockTableForCompilation, needsSavepoint, updateIndexStatisticsFor
private ResultColumnList targetColumnList
private boolean deferred
public ValueNode checkConstraints
public boolean hasDeferrableCheckConstraints
public java.util.Properties targetProperties
public FKInfo fkInfo
protected boolean bulkInsert
private boolean bulkInsertReplace
private OrderByList orderByList
private ValueNode offset
private ValueNode fetchFirst
private boolean hasJDBClimitClause
InsertNode(QueryTreeNode targetName, ResultColumnList insertColumns, ResultSetNode queryExpression, MatchingClauseNode matchingClause, java.util.Properties targetProperties, OrderByList orderByList, ValueNode offset, ValueNode fetchFirst, boolean hasJDBClimitClause, ContextManager cm)
targetName
- The name of the table/VTI to insert intoinsertColumns
- 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.queryExpression
- The query expression that will generate
the rows to insert into the given tablematchingClause
- Non-null if this DML is part of a MATCHED clause of a MERGE statement.targetProperties
- The properties specified on the target tableorderByList
- The order by list for the source result set,
null if no order by listoffset
- The value of a fetchFirst
- The value of a hasJDBClimitClause
- True if the offset/fetchFirst clauses come
from JDBC limit/offset escape syntaxcm
- The context managerpublic java.lang.String toString()
toString
in class StatementNode
java.lang.String statementToString()
statementToString
in class DMLModStatementNode
void printSubNodes(int depth)
printSubNodes
in class DMLModStatementNode
depth
- The depth of this node in the treepublic void bindStatement() throws StandardException
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.
bindStatement
in class StatementNode
StandardException
- Thrown on errorResultSetNode enhanceAndCheckForAutoincrement(ResultSetNode resultSet, boolean inOrder, int[] colMap, boolean defaultsWereReplaced) throws StandardException
resultSet
- current node in the result set treeinOrder
- FALSE if the column list needs reorderingcolMap
- correspondence between RCLsdefaultsWereReplaced
- true if DEFAULT clauses were replaced with generated expressionsStandardException
- Thrown on errorint getPrivType()
DMLStatementNode
getPrivType
in class DMLStatementNode
public boolean referencesSessionSchema() throws StandardException
referencesSessionSchema
in class QueryTreeNode
StandardException
- Thrown on errorprivate void verifyTargetProperties(DataDictionary dd) throws StandardException
dd
- The DataDictionaryStandardException
- Thrown on errorprivate boolean verifyBulkInsert(DataDictionary dd, java.lang.String mode) throws StandardException
dd
- The DataDictionarymode
- The insert modeStandardException
- Thrown on errorpublic ConstantAction makeConstantAction() throws StandardException
makeConstantAction
in class QueryTreeNode
StandardException
- Thrown on failureboolean[] getIndexedCols() throws StandardException
StandardException
- Thrown on failurepublic void optimizeStatement() throws StandardException
Remove any duplicate ORDER BY columns and push an ORDER BY if present down to the source result set, before calling super.optimizeStatement.
optimizeStatement
in class DMLModStatementNode
StandardException
- Thrown on failureprivate void requestBulkInsert()
void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
generate
in class QueryTreeNode
acb
- The ActivationClassBuilder for the class being builtmb
- the method for the execute() method to be builtStandardException
- Thrown on errorprotected final int getStatementType()
getStatementType
in class QueryTreeNode
static int getStatementType(java.util.Properties targetProperties)
private void getAffectedIndexes(TableDescriptor td) throws StandardException
td
- TableDescriptor for the table being inserted into
or deleted fromStandardException
- Thrown on errorvoid acceptChildren(Visitor v) throws StandardException
acceptChildren
in class DMLModStatementNode
v
- the visitorStandardException
- on errorApache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.