java.io.Externalizable
, java.io.Serializable
, Dependable
, Formatable
, TypedFormat
, Dependent
, Provider
public class TriggerDescriptor extends UniqueSQLObjectDescriptor implements Provider, Dependent, Formatable
We are dependent on TableDescriptors, SPSDescriptors (for our WHEN clause and our action). Note that we don't strictly need to be dependent on out SPSes because we could just disallow anyone from dropping an sps of type 'T', but to keep dependencies uniform, we'll do be dependent.
We are a provider for DML (PreparedStatements or SPSes) The public methods for this class are:
Modifier and Type | Field | Description |
---|---|---|
private SPSDescriptor |
actionSPS |
|
private UUID |
actionSPSId |
|
private java.sql.Timestamp |
creationTimestamp |
|
private int |
eventMask |
|
private UUID |
id |
|
private boolean |
isBefore |
|
private boolean |
isEnabled |
|
private boolean |
isRow |
|
private java.lang.String |
name |
|
private java.lang.String |
newReferencingName |
|
private java.lang.String |
oldReferencingName |
|
private int[] |
referencedCols |
|
private int[] |
referencedColsInTriggerAction |
|
private boolean |
referencingNew |
|
private boolean |
referencingOld |
|
private SchemaDescriptor |
sd |
|
static int |
SYSTRIGGERS_STATE_FIELD |
|
private TableDescriptor |
td |
|
static int |
TRIGGER_EVENT_DELETE |
|
static int |
TRIGGER_EVENT_INSERT |
|
static int |
TRIGGER_EVENT_UPDATE |
|
private java.lang.String |
triggerDefinition |
|
private UUID |
triggerSchemaId |
|
private UUID |
triggerTableId |
|
private java.lang.String |
whenClauseText |
|
private SPSDescriptor |
whenSPS |
|
private UUID |
whenSPSId |
ACTIVATION, ALIAS, COLUMNS_IN_TABLE, COLUMNS_PERMISSION, CONGLOMERATE, CONSTRAINT, DEFAULT, FILE, HEAP, INDEX, PERM, PREPARED_STATEMENT, ROLE_GRANT, ROUTINE_PERMISSION, SCHEMA, SEQUENCE, STORED_PREPARED_STATEMENT, TABLE, TABLE_PERMISSION, TRIGGER, VIEW
Constructor | Description |
---|---|
TriggerDescriptor() |
Niladic constructor, for formatable
|
TriggerDescriptor(DataDictionary dataDictionary,
SchemaDescriptor sd,
UUID id,
java.lang.String name,
int eventMask,
boolean isBefore,
boolean isRow,
boolean isEnabled,
TableDescriptor td,
UUID whenSPSId,
UUID actionSPSId,
java.sql.Timestamp creationTimestamp,
int[] referencedCols,
int[] referencedColsInTriggerAction,
java.lang.String triggerDefinition,
boolean referencingOld,
boolean referencingNew,
java.lang.String oldReferencingName,
java.lang.String newReferencingName,
java.lang.String whenClauseText) |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
void |
drop(LanguageConnectionContext lcc) |
|
UUID |
getActionId() |
Get the trigger action sps UUID
|
SPSDescriptor |
getActionSPS(LanguageConnectionContext lcc) |
Get the trigger action sps from SYSSTATEMENTS.
|
java.lang.String |
getClassType() |
Get the provider's type.
|
private static Context |
getContext(java.lang.String contextID) |
Privileged lookup of a Context.
|
java.sql.Timestamp |
getCreationTimestamp() |
Get the time that this trigger was created.
|
protected DataDictionary |
getDataDictionary() |
|
DependableFinder |
getDependableFinder() |
Get an object which can be written to disk and which,
when read from disk, will find or reconstruct this in-memory
Dependable.
|
java.lang.String |
getDescriptorName() |
|
java.lang.String |
getDescriptorType() |
Each descriptor must identify itself with its type; i.e index, check
constraint whatever.
|
java.lang.String |
getName() |
Get the trigger name
|
java.lang.String |
getNewReferencingName() |
Get the new Referencing name, if any,
from the REFERENCING clause.
|
UUID |
getObjectID() |
Get the provider's UUID
|
java.lang.String |
getObjectName() |
Return the name of this Provider.
|
java.lang.String |
getOldReferencingName() |
Get the old Referencing name, if any,
from the REFERENCING clause.
|
int[] |
getReferencedCols() |
Get the referenced column array for this trigger, used in "alter table
drop column", we get the handle and change it
|
int[] |
getReferencedColsInTriggerAction() |
Get the referenced column array for the trigger action columns.
|
boolean |
getReferencingNew() |
Get whether or not NEW was replaced
in the REFERENCING clause.
|
boolean |
getReferencingOld() |
Get whether or not OLD was replaced
in the REFERENCING clause.
|
SchemaDescriptor |
getSchemaDescriptor() |
Get the triggers schema descriptor
|
private SPSDescriptor |
getSPS(LanguageConnectionContext lcc,
boolean isWhenClause) |
Get the SPS for the triggered SQL statement or the WHEN clause.
|
TableDescriptor |
getTableDescriptor() |
Get the trigger table descriptor
|
UUID |
getTableId() |
|
java.lang.String |
getTriggerDefinition() |
Get the original trigger definition.
|
int |
getTriggerEventMask() |
Get the trigger event mask.
|
int |
getTypeFormatId() |
Get the formatID which corresponds to this class.
|
UUID |
getUUID() |
Get the trigger UUID
|
UUID |
getWhenClauseId() |
Get the trigger when clause sps UUID
|
SPSDescriptor |
getWhenClauseSPS(LanguageConnectionContext lcc) |
Get the trigger when clause sps
|
java.lang.String |
getWhenClauseText() |
Get the SQL text of the WHEN clause.
|
boolean |
isBeforeTrigger() |
Is this a before trigger
|
boolean |
isEnabled() |
Is this trigger enforced
|
boolean |
isRowTrigger() |
Is this a row trigger
|
boolean |
isValid() |
Check that all of the dependent's dependencies are valid.
|
boolean |
listensForEvent(int event) |
Indicate whether this trigger listens for this
type of event.
|
void |
makeInvalid(int action,
LanguageConnectionContext lcc) |
Mark the dependent as invalid (due to at least one of
its dependencies being invalid).
|
boolean |
needsToFire(int stmtType,
int[] modifiedCols) |
Does this trigger need to fire on this type of
DML?
|
void |
prepareToInvalidate(Provider p,
int action,
LanguageConnectionContext lcc) |
Prepare to mark the dependent as invalid (due to at least one of
its dependencies being invalid).
|
void |
readExternal(java.io.ObjectInput in) |
Read this object from a stream of stored objects.
|
void |
setDisabled() |
Mark this trigger as disabled
|
void |
setEnabled() |
Mark this trigger as enforced
|
void |
setReferencedCols(int[] newCols) |
Update the array of referenced columns
|
void |
setReferencedColsInTriggerAction(int[] referencedColsInTriggerAction) |
Set the referenced column array for trigger actions
|
java.lang.String |
toString() |
|
void |
writeExternal(java.io.ObjectOutput out) |
Write this object to a stream of stored objects.
|
isPersistent
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getColumnDependableFinder, getDependableFinder, isPersistent, setDataDictionary
public static final int SYSTRIGGERS_STATE_FIELD
public static final int TRIGGER_EVENT_UPDATE
public static final int TRIGGER_EVENT_DELETE
public static final int TRIGGER_EVENT_INSERT
private UUID id
private java.lang.String name
private java.lang.String oldReferencingName
private java.lang.String newReferencingName
private java.lang.String triggerDefinition
private SchemaDescriptor sd
private int eventMask
private boolean isBefore
private boolean isRow
private boolean referencingOld
private boolean referencingNew
private TableDescriptor td
private UUID actionSPSId
private SPSDescriptor actionSPS
private UUID whenSPSId
private SPSDescriptor whenSPS
private boolean isEnabled
private int[] referencedCols
private int[] referencedColsInTriggerAction
private java.sql.Timestamp creationTimestamp
private UUID triggerSchemaId
private UUID triggerTableId
private java.lang.String whenClauseText
public TriggerDescriptor()
TriggerDescriptor(DataDictionary dataDictionary, SchemaDescriptor sd, UUID id, java.lang.String name, int eventMask, boolean isBefore, boolean isRow, boolean isEnabled, TableDescriptor td, UUID whenSPSId, UUID actionSPSId, java.sql.Timestamp creationTimestamp, int[] referencedCols, int[] referencedColsInTriggerAction, java.lang.String triggerDefinition, boolean referencingOld, boolean referencingNew, java.lang.String oldReferencingName, java.lang.String newReferencingName, java.lang.String whenClauseText)
dataDictionary
- the data dictionarysd
- the schema descriptor for this triggerid
- the trigger idname
- the trigger nameeventMask
- TriggerDescriptor.TRIGGER_EVENT_XXXXisBefore
- is this a before (as opposed to after) triggerisRow
- is this a row trigger or statement triggerisEnabled
- is this trigger enabled or disabledtd
- the table upon which this trigger is definedwhenSPSId
- the sps id for the when clause (may be null)actionSPSId
- the spsid for the trigger action (may be null)creationTimestamp
- when was this trigger created?referencedCols
- what columns does this trigger reference (may be null)referencedColsInTriggerAction
- what columns does the trigger
action reference through old/new transition variables
(may be null)triggerDefinition
- The original user text of the trigger actionreferencingOld
- whether or not OLD appears in REFERENCING clausereferencingNew
- whether or not NEW appears in REFERENCING clauseoldReferencingName
- old referencing table name, if any, that appears in REFERCING clausenewReferencingName
- new referencing table name, if any, that appears in REFERCING clausewhenClauseText
- the SQL text of the WHEN clause, or null
if there is no WHEN clausepublic UUID getUUID()
getUUID
in class UniqueTupleDescriptor
public java.lang.String getName()
getName
in class UniqueSQLObjectDescriptor
public UUID getTableId()
public SchemaDescriptor getSchemaDescriptor() throws StandardException
getSchemaDescriptor
in class UniqueSQLObjectDescriptor
StandardException
- on errorpublic boolean listensForEvent(int event)
event
- TRIGGER_EVENT_XXXXpublic int getTriggerEventMask()
public java.sql.Timestamp getCreationTimestamp()
public boolean isBeforeTrigger()
public boolean isRowTrigger()
public UUID getActionId()
public SPSDescriptor getActionSPS(LanguageConnectionContext lcc) throws StandardException
lcc
- The LanguageConnectionContext to use.StandardException
- on errorprivate SPSDescriptor getSPS(LanguageConnectionContext lcc, boolean isWhenClause) throws StandardException
lcc
- the LanguageConnectionContext to useisWhenClause
- true
if the SPS for the WHEN clause is
requested, false
if it is the triggered SQL statementStandardException
- if an error occurspublic UUID getWhenClauseId()
public java.lang.String getWhenClauseText()
null
if there is
no WHEN clausepublic SPSDescriptor getWhenClauseSPS(LanguageConnectionContext lcc) throws StandardException
lcc
- the LanguageConnectionContext to useStandardException
- on errorpublic TableDescriptor getTableDescriptor() throws StandardException
StandardException
- on errorpublic int[] getReferencedCols()
public void setReferencedCols(int[] newCols)
public int[] getReferencedColsInTriggerAction()
public void setReferencedColsInTriggerAction(int[] referencedColsInTriggerAction)
public boolean isEnabled()
public void setEnabled()
public void setDisabled()
public boolean needsToFire(int stmtType, int[] modifiedCols) throws StandardException
stmtType
- the type of DML
(StatementType.INSERT|StatementType.UPDATE|StatementType.DELETE)modifiedCols
- the columns modified, or null for allStandardException
- on errorpublic java.lang.String getTriggerDefinition()
public boolean getReferencingOld()
public boolean getReferencingNew()
public java.lang.String getOldReferencingName()
public java.lang.String getNewReferencingName()
public java.lang.String toString()
toString
in class java.lang.Object
public DependableFinder getDependableFinder()
Dependable
getDependableFinder
in interface Dependable
Dependable.getDependableFinder()
public java.lang.String getObjectName()
getObjectName
in interface Dependable
public UUID getObjectID()
getObjectID
in interface Dependable
public java.lang.String getClassType()
getClassType
in interface Dependable
public boolean isValid()
public void prepareToInvalidate(Provider p, int action, LanguageConnectionContext lcc) throws StandardException
prepareToInvalidate
in interface Dependent
action
- The action causing the invalidationp
- the providerlcc
- the language connection contextStandardException
- thrown if unable to make it invalidpublic void makeInvalid(int action, LanguageConnectionContext lcc) throws StandardException
makeInvalid
in interface Dependent
lcc
- the language connection contextaction
- The action causing the invalidationStandardException
- thrown if called in sanity modepublic void drop(LanguageConnectionContext lcc) throws StandardException
StandardException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- read this.java.io.IOException
- thrown on errorjava.lang.ClassNotFoundException
- thrown on errorprotected DataDictionary getDataDictionary()
getDataDictionary
in class TupleDescriptor
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- write bytes here.java.io.IOException
- thrown on errorpublic int getTypeFormatId()
getTypeFormatId
in interface TypedFormat
public java.lang.String getDescriptorType()
TupleDescriptor
getDescriptorType
in class TupleDescriptor
TupleDescriptor.getDescriptorType()
public java.lang.String getDescriptorName()
getDescriptorName
in class TupleDescriptor
TupleDescriptor.getDescriptorName()
private static Context getContext(java.lang.String contextID)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.