Top Description Inners Fields Constructors Methods
org.hsqldb

public Class TriggerDef

extends Object
implements Runnable, SchemaObject
Class Inheritance
All Implemented Interfaces
org.hsqldb.SchemaObject, java.lang.Runnable
Known Direct Subclasses
org.hsqldb.TriggerDefSQL
Imports
org.hsqldb.HsqlNameManager.HsqlName, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.lib.HsqlDeque, .StringConverter, org.hsqldb.rights.Grantee, org.hsqldb.trigger.Trigger

Represents an HSQLDB Trigger definition.

Provides services regarding HSQLDB Trigger execution and metadata.

Development of the trigger implementation sponsored by Logicscope Realisations Ltd

Author
Peter Hudson (peterhudson@users dot sourceforge.net)
Since
hsqldb 1.61
Version
2.7.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
TriggerDef.TriggerData

Class to store the data used to fire a trigger.

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv static final int
pack-priv static final int
pack-priv long
pack-priv Expression
pack-priv String
pack-priv static final TriggerDef[]
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv static final int
pack-priv boolean
protected volatile boolean
pack-priv int
private HsqlNameManager.HsqlName
pack-priv static final int
pack-priv static final int
pack-priv boolean
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv int
protected HsqlDeque<TriggerDef.TriggerData>
pack-priv static final int
pack-priv RangeVariable[]
pack-priv Routine
protected int
pack-priv Table
pack-priv Thread
pack-priv Table[]
pack-priv Trigger
pack-priv String
pack-priv int
pack-priv int[]
protected boolean

Constructor Summary

AccessConstructor and Description
public
TriggerDef(HsqlNameManager.HsqlName
The trigger object's HsqlName
name
,
int
whether the trigger fires before, after or instead of the triggering event
when
,
int
the triggering operation; currently insert, update, or delete
operation
,
boolean
indicates whether the trigger is fired for each row (true) or statement (false)
forEach
,
Table
the Table object upon which the indicated operation fires the trigger
table
,
Table[] transitions, RangeVariable[] rangeVars, Expression condition, String conditionSQL, int[] updateColumns, String
the fully qualified name of the class implementing the org.hsqldb.Trigger (trigger body) interface
triggerClassName
,
boolean
do not wait for available space on the pending queue; if the pending queue does not have fewer than nQueueSize queued items, then overwrite the current tail instead
noWait
,
int
the length to which the pending queue may grow before further additions are either blocked or overwrite the tail entry, as determined by noWait
queueSize
)

Constructs a new TriggerDef object to represent an HSQLDB trigger declared in an SQL CREATE TRIGGER statement.

public
TriggerDef(HsqlNameManager.HsqlName name, int when, int operation, boolean forEachRow, Table table, Table[] transitions, RangeVariable[] rangeVars, Expression condition, String conditionSQL, int[] updateColumns)

Method Summary

Modifier and TypeMethod and Description
public String
public String
public HsqlNameManager.HsqlName
public long
public String
public String
public String
public HsqlNameManager.HsqlName
public String
public String
public String
public String
pack-priv static int
getOperationType(int token)

Return the type code for operation tokens

public Grantee
public String
public HsqlNameManager.HsqlName
public String

Returns:

the SQL character sequence required to (re)create the trigger
getSQL
()

Implements org.hsqldb.SchemaObject.getSQL.

Retrieves the SQL character sequence required to (re)create the trigger, as a String

public StringBuilder
public int
public Table
pack-priv static int
getTiming(int token)

public int
public int[]
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
pack-priv synchronized TriggerDef.TriggerData

Returns:

Description of the Return Value
popPair
()

pop2 method declaration

The consumer (trigger) thread waits for an event to be queued

Note

This push/pop pairing assumes a single producer thread and a single consumer thread _only_.

pack-priv synchronized void
pushPair(Session
the session
session
,
Object[]
old row
oldData
,
Object[]
new row
newData
)

The main thread tells the trigger thread to fire by this call.

public void
run()

Implements java.lang.Runnable.run.

run method declaration

the trigger JSP is run in its own thread here.

pack-priv void
setUpIndexesAndTypes()

Given the SQL creating the trigger, set up the index to the HsqlArrayList[] and the associated GRANT type

public synchronized void
start()

start the thread if this is threaded

public synchronized void
terminate()

signal the thread to stop

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actionTimingback to summary
pack-priv int actionTiming
AFTERback to summary
pack-priv static final int AFTER
BEFOREback to summary
pack-priv static final int BEFORE
changeTimestampback to summary
pack-priv long changeTimestamp
conditionback to summary
pack-priv Expression condition
conditionSQLback to summary
pack-priv String conditionSQL
emptyArrayback to summary
pack-priv static final TriggerDef[] emptyArray

Hides org.hsqldb.SchemaObject.emptyArray.

forEachRowback to summary
pack-priv boolean forEachRow
hasTransitionRangesback to summary
pack-priv boolean hasTransitionRanges
hasTransitionTablesback to summary
pack-priv boolean hasTransitionTables
INSTEADback to summary
pack-priv static final int INSTEAD
isSystemback to summary
pack-priv boolean isSystem
keepGoingback to summary
protected volatile boolean keepGoing
maxRowsQueuedback to summary
pack-priv int maxRowsQueued
nameback to summary
private HsqlNameManager.HsqlName name
NEW_ROWback to summary
pack-priv static final int NEW_ROW
NEW_TABLEback to summary
pack-priv static final int NEW_TABLE
nowaitback to summary
pack-priv boolean nowait
NUM_TRIGGER_OPSback to summary
pack-priv static final int NUM_TRIGGER_OPS
NUM_TRIGSback to summary
pack-priv static final int NUM_TRIGS
OLD_ROWback to summary
pack-priv static final int OLD_ROW
OLD_TABLEback to summary
pack-priv static final int OLD_TABLE
operationTypeback to summary
pack-priv int operationType
pendingQueueback to summary
protected HsqlDeque<TriggerDef.TriggerData> pendingQueue
RANGE_COUNTback to summary
pack-priv static final int RANGE_COUNT
rangeVarsback to summary
pack-priv RangeVariable[] rangeVars
routineback to summary
pack-priv Routine routine
rowsQueuedback to summary
protected int rowsQueued
tableback to summary
pack-priv Table table
threadback to summary
pack-priv Thread thread
transitionsback to summary
pack-priv Table[] transitions
triggerback to summary
pack-priv Trigger trigger
triggerClassNameback to summary
pack-priv String triggerClassName
triggerTypeback to summary
pack-priv int triggerType
updateColumnsback to summary
pack-priv int[] updateColumns
validback to summary
protected boolean valid

Constructor Detail

TriggerDefback to summary
public TriggerDef(HsqlNameManager.HsqlName name, int when, int operation, boolean forEach, Table table, Table[] transitions, RangeVariable[] rangeVars, Expression condition, String conditionSQL, int[] updateColumns, String triggerClassName, boolean noWait, int queueSize)

Constructs a new TriggerDef object to represent an HSQLDB trigger declared in an SQL CREATE TRIGGER statement. Changes in 1.7.2 allow the queue size to be specified as 0. A zero queue size causes the Trigger.fire() code to run in the main thread of execution (fully inside the enclosing transaction). Otherwise, the code is run in the Trigger's own thread. (fredt@users)

Parameters
name:HsqlNameManager.HsqlName

The trigger object's HsqlName

when:int

whether the trigger fires before, after or instead of the triggering event

operation:int

the triggering operation; currently insert, update, or delete

forEach:boolean

indicates whether the trigger is fired for each row (true) or statement (false)

table:Table

the Table object upon which the indicated operation fires the trigger

triggerClassName:String

the fully qualified name of the class implementing the org.hsqldb.Trigger (trigger body) interface

noWait:boolean

do not wait for available space on the pending queue; if the pending queue does not have fewer than nQueueSize queued items, then overwrite the current tail instead

queueSize:int

the length to which the pending queue may grow before further additions are either blocked or overwrite the tail entry, as determined by noWait

TriggerDefback to summary
public TriggerDef(HsqlNameManager.HsqlName name, int when, int operation, boolean forEachRow, Table table, Table[] transitions, RangeVariable[] rangeVars, Expression condition, String conditionSQL, int[] updateColumns)

Method Detail

getActionOrientationStringback to summary
public String getActionOrientationString()
getActionTimingStringback to summary
public String getActionTimingString()
getCatalogNameback to summary
public HsqlNameManager.HsqlName getCatalogName()

Implements org.hsqldb.SchemaObject.getCatalogName.

getChangeTimestampback to summary
public long getChangeTimestamp()

Implements org.hsqldb.SchemaObject.getChangeTimestamp.

getClassNameback to summary
public String getClassName()
getConditionSQLback to summary
public String getConditionSQL()
getEventTypeStringback to summary
public String getEventTypeString()
getNameback to summary
public HsqlNameManager.HsqlName getName()

Implements org.hsqldb.SchemaObject.getName.

getNewTransitionRowNameback to summary
public String getNewTransitionRowName()
getNewTransitionTableNameback to summary
public String getNewTransitionTableName()
getOldTransitionRowNameback to summary
public String getOldTransitionRowName()
getOldTransitionTableNameback to summary
public String getOldTransitionTableName()
getOperationTypeback to summary
pack-priv static int getOperationType(int token)

Return the type code for operation tokens

getOwnerback to summary
public Grantee getOwner()

Implements org.hsqldb.SchemaObject.getOwner.

getProcedureSQLback to summary
public String getProcedureSQL()
getSchemaNameback to summary
public HsqlNameManager.HsqlName getSchemaName()

Implements org.hsqldb.SchemaObject.getSchemaName.

getSQLback to summary
public String getSQL()

Implements org.hsqldb.SchemaObject.getSQL.

Retrieves the SQL character sequence required to (re)create the trigger, as a String

Returns:String

the SQL character sequence required to (re)create the trigger

getSQLMainback to summary
public StringBuilder getSQLMain()
getStatementTypeback to summary
public int getStatementType()
getTableback to summary
public Table getTable()
getTimingback to summary
pack-priv static int getTiming(int token)
getTypeback to summary
public int getType()

Implements org.hsqldb.SchemaObject.getType.

getUpdateColumnIndexesback to summary
public int[] getUpdateColumnIndexes()
hasNewRowback to summary
public boolean hasNewRow()
hasNewTableback to summary
public boolean hasNewTable()
hasOldRowback to summary
public boolean hasOldRow()
hasOldTableback to summary
public boolean hasOldTable()
isBusyback to summary
public boolean isBusy()
isForEachRowback to summary
public boolean isForEachRow()
isSystemback to summary
public boolean isSystem()
isValidback to summary
public boolean isValid()
popPairback to summary
pack-priv synchronized TriggerDef.TriggerData popPair()

pop2 method declaration

The consumer (trigger) thread waits for an event to be queued

Note

This push/pop pairing assumes a single producer thread and a single consumer thread _only_.

Returns:TriggerDef.TriggerData

Description of the Return Value

pushPairback to summary
pack-priv synchronized void pushPair(Session session, Object[] oldData, Object[] newData)

The main thread tells the trigger thread to fire by this call. If this Trigger is not threaded then the fire method is called immediately and executed by the main thread. Otherwise, the row data objects are added to the queue to be used by the Trigger thread.

Parameters
session:Session

the session

oldData:Object[]

old row

newData:Object[]

new row

runback to summary
public void run()

Implements java.lang.Runnable.run.

run method declaration

the trigger JSP is run in its own thread here. Its job is simply to wait until it is told by the main thread that it should fire the trigger.

setUpIndexesAndTypesback to summary
pack-priv void setUpIndexesAndTypes()

Given the SQL creating the trigger, set up the index to the HsqlArrayList[] and the associated GRANT type

startback to summary
public synchronized void start()

start the thread if this is threaded

terminateback to summary
public synchronized void terminate()

signal the thread to stop

org.hsqldb back to summary

pack-priv Class TriggerDef.DefaultTrigger

extends Object
implements Trigger
Class Inheritance
All Implemented Interfaces
org.hsqldb.trigger.Trigger

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
fire(int i, String name, String table, Object[] row1, Object[] row2)

Overrides default org.hsqldb.trigger.Trigger.fire.

Old fire method.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DefaultTriggerback to summary
pack-priv DefaultTrigger()

Method Detail

fireback to summary
public void fire(int i, String name, String table, Object[] row1, Object[] row2)

Overrides default org.hsqldb.trigger.Trigger.fire.

Doc from org.hsqldb.trigger.Trigger.fire.

Old fire method.

org.hsqldb back to summary

pack-priv Class TriggerDef.TriggerData

extends Object
Class Inheritance

Class to store the data used to fire a trigger. The username attribute is not used but it allows developers to change the signature of the fire method of the Trigger class and pass the user name to the Trigger.

Field Summary

Modifier and TypeField and Description
public Object[]
public Object[]
public String

Constructor Summary

AccessConstructor and Description
public
TriggerData(Session session, Object[] oldRow, Object[] newRow)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

newRowback to summary
public Object[] newRow
oldRowback to summary
public Object[] oldRow
usernameback to summary
public String username

Constructor Detail

TriggerDataback to summary
public TriggerData(Session session, Object[] oldRow, Object[] newRow)