Class InsertNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- org.apache.derby.impl.sql.compile.StatementNode
-
- org.apache.derby.impl.sql.compile.InsertNode
-
- All Implemented Interfaces:
- Visitable
public final class InsertNode extends StatementNode
An InsertNode is the top node in a query tree for an insert statement.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, ...
-
-
Field Summary
Fields Modifier and Type Field and Description ValueNodecheckConstraintsFKInfofkInfobooleanhasDeferrableCheckConstraintslong[]indexConglomerateNumbersjava.lang.String[]indexNamesIndexRowGenerator[]indicesToMaintainjava.util.PropertiestargetProperties
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidbindStatement()Bind this InsertNode.MethodBuildergenerateCheckConstraints(ValueNode checkConstraints, org.apache.derby.impl.sql.compile.ExpressionClassBuilder ecb)Generate a method to evaluate a tree of CHECK CONSTRAINTS.voidgenerateCheckConstraints(ValueNode checkConstraints, org.apache.derby.impl.sql.compile.ExpressionClassBuilder ecb, MethodBuilder mb)Generate the code to evaluate a tree of CHECK CONSTRAINTS.voidgenerateGenerationClauses(org.apache.derby.impl.sql.compile.ResultColumnList rcl, int resultSetNumber, boolean isUpdate, org.apache.derby.impl.sql.compile.ExpressionClassBuilder ecb, MethodBuilder mb)Generate the code to evaluate all of the generation clauses.booleaninMatchingClause()Returns true if this DMLModStatement a [ NOT ] MATCHED action of a MERGE statementbooleanisAtomic()INSERT/UPDATE/DELETE are always atomic.ConstantActionmakeConstantAction()Compile constants that Execution will useResultDescriptionmakeResultDescription()Make a ResultDescription for use in a PreparedStatement.voidoptimizeStatement()Generate an optimized QueryTree from a bound QueryTree.ValueNodeparseCheckConstraint(java.lang.String checkConstraintText, TableDescriptor td)Parse a check constraint and turn it into a query tree.ValueNodeparseGenerationClause(java.lang.String clauseText, TableDescriptor td)Parse the generation clause for a column.booleanreferencesSessionSchema()Return true if the node references SESSION schema tables (temporary or permanent)java.lang.StringtoString()Convert this object to a String.-
Methods inherited from class org.apache.derby.impl.sql.compile.StatementNode
executeSchemaName, executeStatementName, generate, getCursorInfo, getSPSName, needsSavepoint, updateIndexStatisticsFor
-
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, addTag, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, createTypeDependency, getBeginOffset, getDataDictionary, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getUDTDesc, makeTableName, makeTableName, optimizerTracingIsOn, orReliability, setBeginOffset, setEndOffset, taggedWith, treePrint
-
-
-
-
Field Detail
-
checkConstraints
public ValueNode checkConstraints
-
hasDeferrableCheckConstraints
public boolean hasDeferrableCheckConstraints
-
targetProperties
public java.util.Properties targetProperties
-
fkInfo
public FKInfo fkInfo
-
indicesToMaintain
public IndexRowGenerator[] indicesToMaintain
-
indexConglomerateNumbers
public long[] indexConglomerateNumbers
-
indexNames
public java.lang.String[] indexNames
-
-
Method Detail
-
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:
toStringin classStatementNode- Returns:
- This object as a String
-
bindStatement
public void bindStatement() throws StandardExceptionBind 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.
- Overrides:
bindStatementin classStatementNode- Throws:
StandardException- Thrown on error
-
referencesSessionSchema
public boolean referencesSessionSchema() throws StandardExceptionReturn true if the node references SESSION schema tables (temporary or permanent)- Overrides:
referencesSessionSchemain classQueryTreeNode- Returns:
- true if references SESSION schema tables, else false
- Throws:
StandardException- Thrown on error
-
makeConstantAction
public ConstantAction makeConstantAction() throws StandardException
Compile constants that Execution will use- Overrides:
makeConstantActionin classQueryTreeNode- Throws:
StandardException- Thrown on failure
-
optimizeStatement
public void optimizeStatement() throws StandardExceptionGenerate 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.
- Throws:
StandardException- Thrown on failure
-
inMatchingClause
public boolean inMatchingClause()
Returns true if this DMLModStatement a [ NOT ] MATCHED action of a MERGE statement
-
isAtomic
public boolean isAtomic()
INSERT/UPDATE/DELETE are always atomic.- Returns:
- true
-
parseGenerationClause
public ValueNode parseGenerationClause(java.lang.String clauseText, TableDescriptor td) throws StandardException
Parse the generation clause for a column.- Parameters:
clauseText- Text of the generation clause- Returns:
- The parsed expression as a query tree.
- Throws:
StandardException- Thrown on failure
-
parseCheckConstraint
public ValueNode parseCheckConstraint(java.lang.String checkConstraintText, TableDescriptor td) throws StandardException
Parse a check constraint and turn it into a query tree.- Parameters:
checkConstraintText- Text of CHECK CONSTRAINT.td- The TableDescriptor for the table the the constraint is on.- Returns:
- The parsed check constraint as a query tree.
- Throws:
StandardException- Thrown on failure
-
generateCheckConstraints
public void generateCheckConstraints(ValueNode checkConstraints, org.apache.derby.impl.sql.compile.ExpressionClassBuilder ecb, MethodBuilder mb) throws StandardException
Generate the code to evaluate a tree of CHECK CONSTRAINTS.- Parameters:
checkConstraints- Bound query tree of ANDed check constraints.ecb- Expression Class Builder- Throws:
StandardException- Thrown on error
-
generateCheckConstraints
public MethodBuilder generateCheckConstraints(ValueNode checkConstraints, org.apache.derby.impl.sql.compile.ExpressionClassBuilder ecb) throws StandardException
Generate a method to evaluate a tree of CHECK CONSTRAINTS.- Parameters:
checkConstraints- Bound query tree of ANDed check constraints.ecb- Expression Class Builder- Throws:
StandardException- Thrown on error
-
generateGenerationClauses
public void generateGenerationClauses(org.apache.derby.impl.sql.compile.ResultColumnList rcl, int resultSetNumber, boolean isUpdate, org.apache.derby.impl.sql.compile.ExpressionClassBuilder ecb, MethodBuilder mb) throws StandardExceptionGenerate the code to evaluate all of the generation clauses. If there are generation clauses, this routine builds an Activation method which evaluates the generation clauses and fills in the computed columns.- Parameters:
rcl- describes the row of expressions to be put into the bas tableresultSetNumber- index of base table into array of ResultSetsisUpdate- true if this is for an UPDATE statementecb- code generation state variablemb- the method being generated- Throws:
StandardException- Thrown on error
-
makeResultDescription
public ResultDescription makeResultDescription()
Make a ResultDescription for use in a PreparedStatement. ResultDescriptions are visible to JDBC only for cursor statements. For other types of statements, they are only used internally to get descriptions of the base tables being affected. For example, for an INSERT statement, the ResultDescription describes the rows in the table being inserted into, which is useful when the values being inserted are of a different type or length than the columns in the base table.- Overrides:
makeResultDescriptionin classStatementNode- Returns:
- A ResultDescription for this DML statement
-
-
DataMelt 3.0 © DataMelt by jWork.ORG