class InternalTriggerExecutionContext extends java.lang.Object implements TriggerExecutionContext, ExecutionStmtValidator
Note that it is crucial that cleanup() is called once the DML has completed, cleanup() makes sure that users can't do something invalid on a tec reference that they were holding from when the trigger fired.
Modifier and Type | Field and Description |
---|---|
protected CursorResultSet |
afterResultSet |
protected ExecRow |
afterRow
used exclusively for InsertResultSets which have autoincrement
columns.
|
private java.util.Vector<AutoincrementCounter> |
aiCounters
aiCounters is a vector of AutoincrementCounters used to keep state which
might be used by the trigger.
|
private java.util.Hashtable<java.lang.String,java.lang.Long> |
aiHT
aiHT is a hash table of auto increment (key, value) pairs.
|
protected CursorResultSet |
beforeResultSet |
protected ConnectionContext |
cc |
protected boolean |
cleanupCalled |
protected int |
dmlType |
protected TriggerEvent |
event |
protected LanguageConnectionContext |
lcc |
private java.util.Vector<java.sql.ResultSet> |
resultSetVector |
protected java.lang.String |
statementText |
protected UUID |
targetTableId |
protected java.lang.String |
targetTableName |
protected TriggerDescriptor |
triggerd |
DELETE_EVENT, INSERT_EVENT, UPDATE_EVENT
Constructor and Description |
---|
InternalTriggerExecutionContext(LanguageConnectionContext lcc,
ConnectionContext cc,
java.lang.String statementText,
int dmlType,
UUID targetTableId,
java.lang.String targetTableName,
java.util.Vector<AutoincrementCounter> aiCounters)
Build a trigger execution context.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanup()
Cleanup the trigger execution context.
|
(package private) void |
clearCurrentTriggerEvent() |
(package private) void |
clearTrigger() |
void |
copyHashtableToAIHT(java.util.Map<java.lang.String,java.lang.Long> from)
Copy a map of auto increment values into the trigger
execution context hash table of auto increment values.
|
private void |
ensureProperContext()
Make sure that the user isn't trying to get a result
set after we have cleaned up.
|
java.lang.Long |
getAutoincrementValue(java.lang.String identity)
Get the last auto-increment value for the specified column.
|
java.lang.String |
getEventStatementText()
Get the text of the statement that caused the
trigger to fire.
|
int |
getEventType()
Get the type for the event that caused the
trigger to fire.
|
java.sql.ResultSet |
getNewRow()
Like getAfterResultSet(), but returns a result set positioned
on the first row of the before result set.
|
java.sql.ResultSet |
getNewRowSet()
Returns a result set row the new images of the changed rows.
|
java.sql.ResultSet |
getOldRow()
Like getBeforeResultSet(), but returns a result set positioned
on the first row of the before result set.
|
java.sql.ResultSet |
getOldRowSet()
Returns a result set row the old images of the changed rows.
|
UUID |
getTargetTableId()
Get the target table UUID upon which the
trigger event is declared.
|
java.lang.String |
getTargetTableName()
Get the target table name upon which the
trigger event is declared.
|
void |
resetAICounters(boolean begin)
Reset Autoincrement counters to the beginning or the end.
|
(package private) void |
setAfterResultSet(CursorResultSet rs) |
(package private) void |
setBeforeResultSet(CursorResultSet rs) |
(package private) void |
setCurrentTriggerEvent(TriggerEvent event) |
(package private) void |
setTrigger(TriggerDescriptor triggerd) |
java.lang.String |
toString() |
void |
updateAICounters()
Update auto increment counters from the last row inserted.
|
void |
validateStatement(ConstantAction constantAction)
Make sure that whatever statement is about to be executed
is ok from the context of this trigger.
|
protected int dmlType
protected java.lang.String statementText
protected ConnectionContext cc
protected UUID targetTableId
protected java.lang.String targetTableName
protected LanguageConnectionContext lcc
protected CursorResultSet beforeResultSet
protected CursorResultSet afterResultSet
protected ExecRow afterRow
protected boolean cleanupCalled
protected TriggerEvent event
protected TriggerDescriptor triggerd
private java.util.Vector<java.sql.ResultSet> resultSetVector
private java.util.Vector<AutoincrementCounter> aiCounters
AutoincrementCounter
private java.util.Hashtable<java.lang.String,java.lang.Long> aiHT
InternalTriggerExecutionContext(LanguageConnectionContext lcc, ConnectionContext cc, java.lang.String statementText, int dmlType, UUID targetTableId, java.lang.String targetTableName, java.util.Vector<AutoincrementCounter> aiCounters) throws StandardException
About the only thing of real interest to outside observers is that it pushes itself as the trigger execution context in the lcc. Be sure to call cleanup() when you are done, or you will be flogged like the reprobate that you are.
lcc
- the lccstatementText
- the text of the statement that caused the
trigger to fire. may be null if we are replicatingtargetTableId
- the UUID of the table upon which the trigger
firedtargetTableName
- the name of the table upon which the trigger
firedaiCounters
- A vector of AutoincrementCounters to keep state
of the ai columns in this insert trigger.aStandardException
- on errorvoid setBeforeResultSet(CursorResultSet rs)
void setAfterResultSet(CursorResultSet rs) throws StandardException
StandardException
void setCurrentTriggerEvent(TriggerEvent event)
void clearCurrentTriggerEvent()
void setTrigger(TriggerDescriptor triggerd)
void clearTrigger() throws StandardException
StandardException
protected void cleanup() throws StandardException
We go to somewhat exaggerated lengths to free up all our resources here because a user may hold on to a TEC after it is valid, so we clean everything up to be on the safe side.
StandardException
- on unexpected errorprivate void ensureProperContext() throws java.sql.SQLException
java.sql.SQLException
public void validateStatement(ConstantAction constantAction) throws StandardException
Note that we are sub classed in replication for checks for replication specific language.
validateStatement
in interface ExecutionStmtValidator
constantAction
- the constant action of the action
that we are to validateStandardException
- on errorConstantAction
public java.lang.String getTargetTableName()
getTargetTableName
in interface TriggerExecutionContext
public UUID getTargetTableId()
getTargetTableId
in interface TriggerExecutionContext
public int getEventType()
getEventType
in interface TriggerExecutionContext
public java.lang.String getEventStatementText()
getEventStatementText
in interface TriggerExecutionContext
public java.sql.ResultSet getOldRowSet() throws java.sql.SQLException
getOldRowSet
in interface TriggerExecutionContext
java.sql.SQLException
- if called after the triggering event has
completedpublic java.sql.ResultSet getNewRowSet() throws java.sql.SQLException
getNewRowSet
in interface TriggerExecutionContext
java.sql.SQLException
- if called after the triggering event has
completedpublic java.sql.ResultSet getOldRow() throws java.sql.SQLException
getOldRow
in interface TriggerExecutionContext
java.sql.SQLException
- if called after the triggering event has
completedpublic java.sql.ResultSet getNewRow() throws java.sql.SQLException
getNewRow
in interface TriggerExecutionContext
java.sql.SQLException
- if called after the triggering event has
completedpublic java.lang.Long getAutoincrementValue(java.lang.String identity)
TriggerExecutionContext
getAutoincrementValue
in interface TriggerExecutionContext
identity
- the fully qualified name of the identity columnnull
if not foundpublic void copyHashtableToAIHT(java.util.Map<java.lang.String,java.lang.Long> from)
public void resetAICounters(boolean begin)
begin
- if True, reset the AutoincremnetCounter to the
beginning-- used to reset the counters for the
next trigger. If false, reset it to the end--
this sets up the counter appropriately for a
AFTER STATEMENT trigger.public void updateAICounters() throws StandardException
StandardException
public java.lang.String toString()
toString
in class java.lang.Object
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.