class CreateTriggerNode extends DDLStatementNode
Modifier and Type | Field and Description |
---|---|
private StatementNode |
actionNode |
private java.lang.String |
actionText |
private java.util.ArrayList<int[]> |
actionTransformations
A list that describes how the original SQL text of the trigger action
statement was modified when transition tables and transition variables
were replaced by VTI calls.
|
private SchemaDescriptor |
compSchemaDescriptor |
private boolean |
isBefore |
private boolean |
isEnabled |
private boolean |
isRow |
private boolean |
newTableInReferencingClause |
private java.lang.String |
newTableName |
private static java.util.Comparator<FromBaseTable> |
OFFSET_COMPARATOR
Comparator that can be used for sorting lists of FromBaseTables
on the position they have in the SQL query string.
|
private boolean |
oldTableInReferencingClause |
private java.lang.String |
oldTableName |
private java.lang.String |
originalActionText |
private java.lang.String |
originalWhenText |
private ProviderInfo[] |
providerInfo |
private java.util.List<TriggerReferencingStruct> |
refClause |
private int[] |
referencedColInts |
private int[] |
referencedColsInTriggerAction |
private TableName |
tableName |
private ResultColumnList |
triggerCols |
private int |
triggerEventMask |
private TableName |
triggerName |
private SchemaDescriptor |
triggerSchemaDescriptor |
private TableDescriptor |
triggerTableDescriptor |
private ValueNode |
whenClause |
private java.util.ArrayList<int[]> |
whenClauseTransformations
Structure that has the same shape as
actionTransformations ,
except that it describes the transformations in the WHEN clause. |
private java.lang.String |
whenText |
ADD_TYPE, DROP_STATISTICS, DROP_TYPE, implicitCreateSchema, LOCKING_TYPE, MODIFY_TYPE, UNKNOWN_TYPE, UPDATE_STATISTICS
EMPTY_TD_LIST, NEED_CURSOR_ACTIVATION, NEED_DDL_ACTIVATION, NEED_NOTHING_ACTIVATION, NEED_PARAM_ACTIVATION, NEED_ROW_ACTIVATION
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
Constructor and Description |
---|
CreateTriggerNode(TableName triggerName,
TableName tableName,
int triggerEventMask,
ResultColumnList triggerCols,
boolean isBefore,
boolean isRow,
boolean isEnabled,
java.util.List<TriggerReferencingStruct> refClause,
ValueNode whenClause,
java.lang.String whenText,
StatementNode actionNode,
java.lang.String actionText,
ContextManager cm)
Constructor for a CreateTriggerNode
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
acceptChildren(Visitor v)
Accept a visitor on all child nodes.
|
private boolean |
bindReferencesClause(DataDictionary dd) |
void |
bindStatement()
Bind this CreateTriggerNode.
|
private void |
checkInvalidTriggerReference(java.lang.String tableName) |
private boolean |
equals(java.lang.String left,
java.lang.String right) |
private void |
forbidActionsOnGenCols() |
private static java.lang.Integer |
getOriginalPosition(java.util.List<int[]> replacements,
int transformedPosition)
Translate a position from the transformed trigger text
(
actionText or whenText ) to the corresponding
position in the original trigger text (originalActionText
or originalWhenText ). |
private java.util.SortedSet<FromBaseTable> |
getTransitionTables(Visitable node)
Get all transition tables referenced by a given node, sorted in the
order in which they appear in the SQL text.
|
private boolean |
isTransitionTable(FromBaseTable fbt)
Check if a table represents one of the transition tables.
|
private int[] |
justTheRequiredColumns(int[] columnsArrary) |
ConstantAction |
makeConstantAction()
Create the Constant information that will drive the guts of Execution.
|
(package private) void |
printSubNodes(int depth)
Prints the sub-nodes of this object.
|
private void |
qualifyNames(QueryTreeNode node,
java.util.SortedSet<TableName> tableNames,
java.lang.String originalText,
java.lang.String transformedText,
java.util.List<int[]> replacements,
java.lang.StringBuilder newOriginal,
java.lang.StringBuilder newTransformed)
Qualify all names SQL object names in original and transformed SQL
text for an action or a WHEN clause.
|
private void |
qualifyNames(java.util.SortedSet<TableName> actionNames,
java.util.SortedSet<TableName> whenNames)
Make sure all references to SQL schema objects (such as tables and
functions) in the SQL fragments that will be stored in the SPS and
in the trigger descriptor, are fully qualified with a schema name.
|
boolean |
referencesSessionSchema()
Return true if the node references SESSION schema tables (temporary or permanent)
|
(package private) java.lang.String |
statementToString() |
java.lang.String |
toString()
Convert this object to a String.
|
private java.lang.String |
transformStatementTriggerText(QueryTreeNode node,
java.lang.String originalText,
java.util.List<int[]> replacements)
Transform the WHEN clause or the triggered SQL statement of a
statement trigger from its original shape to internal syntax where
references to transition tables are replaced with VTIs that return
the before or after image of the changed rows.
|
private void |
validateReferencesClause(DataDictionary dd) |
activationKind, generate, getFullName, getObjectName, getRelativeName, getSchemaDescriptor, getSchemaDescriptor, getTableDescriptor, getTableDescriptor, getTableDescriptor, getTableDescriptor, initAndCheck, isAtomic, makeFromList
executeSchemaName, executeStatementName, generate, getCursorInfo, getSPSName, lockTableForCompilation, makeResultDescription, needsSavepoint, optimizeStatement, updateIndexStatisticsFor
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, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
private TableName triggerName
private TableName tableName
private int triggerEventMask
private ResultColumnList triggerCols
private boolean isBefore
private boolean isRow
private boolean isEnabled
private java.util.List<TriggerReferencingStruct> refClause
private ValueNode whenClause
private java.lang.String whenText
private StatementNode actionNode
private java.lang.String actionText
private java.lang.String originalWhenText
private java.lang.String originalActionText
private ProviderInfo[] providerInfo
private SchemaDescriptor triggerSchemaDescriptor
private SchemaDescriptor compSchemaDescriptor
private int[] referencedColInts
private int[] referencedColsInTriggerAction
private TableDescriptor triggerTableDescriptor
private java.lang.String oldTableName
private java.lang.String newTableName
private boolean oldTableInReferencingClause
private boolean newTableInReferencingClause
private final java.util.ArrayList<int[]> actionTransformations
A list that describes how the original SQL text of the trigger action
statement was modified when transition tables and transition variables
were replaced by VTI calls. Each element in the list contains four
integers describing positions where modifications have happened. The
first two integers are begin and end positions of a transition table
or transition variable in the original SQL
text
. The last two integers are begin and end positions of the
corresponding replacement in the transformed SQL
text
.
Begin positions are inclusive and end positions are exclusive.
private final java.util.ArrayList<int[]> whenClauseTransformations
actionTransformations
,
except that it describes the transformations in the WHEN clause.private static final java.util.Comparator<FromBaseTable> OFFSET_COMPARATOR
CreateTriggerNode(TableName triggerName, TableName tableName, int triggerEventMask, ResultColumnList triggerCols, boolean isBefore, boolean isRow, boolean isEnabled, java.util.List<TriggerReferencingStruct> refClause, ValueNode whenClause, java.lang.String whenText, StatementNode actionNode, java.lang.String actionText, ContextManager cm) throws StandardException
triggerName
- name of the triggertableName
- name of the table which the trigger is declared upontriggerEventMask
- TriggerDescriptor.TRIGGER_EVENT_XXXtriggerCols
- columns trigger is to fire upon. Valid
for UPDATE case only.isBefore
- is before trigger (false for after)isRow
- true for row trigger, false for statementisEnabled
- true if enabledrefClause
- the referencing clausewhenClause
- the WHEN clause treewhenText
- the text of the WHEN clauseactionNode
- the trigger action treeactionText
- the text of the trigger actioncm
- context managerStandardException
- Thrown on errorjava.lang.String statementToString()
statementToString
in class StatementNode
void printSubNodes(int depth)
printSubNodes
in class QueryTreeNode
depth
- The depth of this node in the treepublic void bindStatement() throws StandardException
bindStatement
in class StatementNode
StandardException
- Thrown on errorpublic boolean referencesSessionSchema() throws StandardException
referencesSessionSchema
in class QueryTreeNode
StandardException
- Thrown on errorprivate boolean bindReferencesClause(DataDictionary dd) throws StandardException
StandardException
private void qualifyNames(java.util.SortedSet<TableName> actionNames, java.util.SortedSet<TableName> whenNames) throws StandardException
actionNames
- all the TableName nodes found in the triggered
SQL statementwhenNames
- all the Table Name nodes found in the WHEN clauseStandardException
private void qualifyNames(QueryTreeNode node, java.util.SortedSet<TableName> tableNames, java.lang.String originalText, java.lang.String transformedText, java.util.List<int[]> replacements, java.lang.StringBuilder newOriginal, java.lang.StringBuilder newTransformed) throws StandardException
node
- the query tree node for the transformed version of the
SQL text, in a bound statetableNames
- all the TableName nodes in the transformed text,
in the order in which they appear in the SQL textoriginalText
- the original SQL texttransformedText
- the transformed SQL text (with VTI calls for
transition tables or transition variables)replacements
- a data structure that describes how originalText
was transformed into transformedText
newOriginal
- where to store the normalized version of the
original textnewTransformed
- where to store the normalized version of the
transformed textStandardException
private static java.lang.Integer getOriginalPosition(java.util.List<int[]> replacements, int transformedPosition)
actionText
or whenText
) to the corresponding
position in the original trigger text (originalActionText
or originalWhenText
).replacements
- a data structure that describes the relationship
between positions in the original and the transformed texttransformedPosition
- the position to translatenull
if there
is no corresponding position in the original text (for example if
it points to a token that was added to the transformed text and
does not exist in the original text)private int[] justTheRequiredColumns(int[] columnsArrary)
private java.lang.String transformStatementTriggerText(QueryTreeNode node, java.lang.String originalText, java.util.List<int[]> replacements) throws StandardException
node
- the syntax tree of the WHEN clause or the triggered
SQL statementoriginalText
- the original text of the WHEN clause or the
triggered SQL statementreplacements
- list that will be populated with int arrays that
describe how the original text was transformed. The int arrays
contain the begin (inclusive) and end (exclusive) positions of the
original text that got replaced and of the replacement text, so that
positions in the transformed text can be mapped to positions in the
original text.StandardException
- if an error happens while performing the
transformationprivate java.util.SortedSet<FromBaseTable> getTransitionTables(Visitable node) throws StandardException
node
- the node in which to search for transition tablesFromBaseTable
s that represent
transition tablesStandardException
- if an error occursprivate boolean isTransitionTable(FromBaseTable fbt)
fbt
- the table to checktrue
if fbt
represents either the old or
the new transition table, false
otherwiseprivate void forbidActionsOnGenCols() throws StandardException
StandardException
private boolean equals(java.lang.String left, java.lang.String right)
private void checkInvalidTriggerReference(java.lang.String tableName) throws StandardException
StandardException
private void validateReferencesClause(DataDictionary dd) throws StandardException
StandardException
public ConstantAction makeConstantAction() throws StandardException
makeConstantAction
in class QueryTreeNode
StandardException
- Thrown on failurepublic java.lang.String toString()
toString
in class DDLStatementNode
void acceptChildren(Visitor v) throws StandardException
QueryTreeNode
accept(v)
on all visitable fields, as well as
super.acceptChildren(v)
to make sure all visitable fields
defined by the super-class are accepted too.acceptChildren
in class DDLStatementNode
v
- the visitorStandardException
- on errors raised by the visitorApache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.