- java.lang.Object
-
- org.postgresql.pljava.internal.TriggerData
-
- All Implemented Interfaces:
TriggerData
public class TriggerData extends Object implements TriggerData
TheTriggerData
correspons to the internal PostgreSQLTriggerData
.- Author:
- Thomas Hallgren
-
-
Method Summary
Modifier and Type Method Description String[]
getArguments()
Returns the arguments for this trigger (as declared in theCREATE TRIGGER
statement.String
getName()
Returns the name of the trigger (as declared in theCREATE TRIGGER
statement).ResultSet
getNew()
Returns the ResultSet that represents the new row.Tuple
getNewTuple()
Returns aTuple
reflecting the new version of the row, if the trigger was fired for anUPDATE
, andnull
if it is for anINSERT
or aDELETE
.ResultSet
getOld()
Returns the ResultSet that represents the old row.Relation
getRelation()
Returns a descriptor for the Tuples exposed by this trigger.String
getSchemaName()
String
getTableName()
long
getTriggerReturnTuple()
Commits the changes made on theResultSet
representingnew
and returns the native pointer of new tuple.Tuple
getTriggerTuple()
Returns aTuple
reflecting the row for which the trigger was fired.boolean
isFiredAfter()
Returnstrue
if the trigger was fired after the statement or row action that it is associated with.boolean
isFiredBefore()
Returnstrue
if the trigger was fired before the statement or row action that it is associated with.boolean
isFiredByDelete()
Returnstrue
if this trigger was fired by aDELETE
.boolean
isFiredByInsert()
Returnstrue
if this trigger was fired by anINSERT
.boolean
isFiredByUpdate()
Returnstrue
if this trigger was fired by anUPDATE
.boolean
isFiredForEachRow()
Returnstrue
if this trigger is fired once for each row (as opposed to once for the entire statement).boolean
isFiredForStatement()
Returnstrue
if this trigger is fired once for the entire statement (as opposed to once for each row).void
suppress()
-
-
-
Method Detail
-
suppress
public void suppress() throws SQLException
- Specified by:
suppress
in interfaceTriggerData
- Throws:
SQLException
-
getNew
public ResultSet getNew() throws SQLException
Returns the ResultSet that represents the new row. This ResultSet will be null for delete triggers and for triggers that was fired for statement.
The returned set will be updateable and positioned on a valid row.- Specified by:
getNew
in interfaceTriggerData
- Returns:
- An updateable
ResultSet
containing one row ornull
. - Throws:
SQLException
- if the contained native buffer has gone stale.
-
getOld
public ResultSet getOld() throws SQLException
Returns the ResultSet that represents the old row. This ResultSet will be null for insert triggers and for triggers that was fired for statement.
The returned set will be read-only and positioned on a valid row.- Specified by:
getOld
in interfaceTriggerData
- Returns:
- A read-only
ResultSet
containing one row ornull
. - Throws:
SQLException
- if the contained native buffer has gone stale.
-
getTriggerReturnTuple
public long getTriggerReturnTuple() throws SQLException
Commits the changes made on theResultSet
representingnew
and returns the native pointer of new tuple. This method is called automatically by the trigger handler and should not be called in any other way.Note: starting with PostgreSQL 10, this method can fail if SPI is not connected; it is the caller's responsibility in PG 10 and up to ensure that SPI is connected and that a longer-lived memory context than SPI's has been selected, if the caller wants the result of this call to survive
SPI_finish
.- Returns:
- The modified tuple, or if no modifications have been made, the original tuple.
- Throws:
SQLException
-
getTableName
public String getTableName() throws SQLException
- Specified by:
getTableName
in interfaceTriggerData
- Throws:
SQLException
-
getSchemaName
public String getSchemaName() throws SQLException
- Specified by:
getSchemaName
in interfaceTriggerData
- Throws:
SQLException
-
getRelation
public Relation getRelation() throws SQLException
Returns a descriptor for the Tuples exposed by this trigger.- Throws:
SQLException
- if the contained native buffer has gone stale.
-
getTriggerTuple
public Tuple getTriggerTuple() throws SQLException
Returns aTuple
reflecting the row for which the trigger was fired. This is the row being inserted, updated, or deleted. If this trigger was fired for anINSERT
orDELETE
then this is what you should return to from the method if you don't want to replace the row with a different one (in the case ofINSERT
) or skip the operation.- Throws:
SQLException
- if the contained native buffer has gone stale.
-
getNewTuple
public Tuple getNewTuple() throws SQLException
Returns aTuple
reflecting the new version of the row, if the trigger was fired for anUPDATE
, andnull
if it is for anINSERT
or aDELETE
. This is what you have to return from the function if the event is anUPDATE
and you don't want to replace this row by a different one or skip the operation.- Throws:
SQLException
- if the contained native buffer has gone stale.
-
getArguments
public String[] getArguments() throws SQLException
Returns the arguments for this trigger (as declared in theCREATE TRIGGER
statement. If the trigger has no arguments, this method will return an array with size 0.- Specified by:
getArguments
in interfaceTriggerData
- Throws:
SQLException
- if the contained native buffer has gone stale.
-
getName
public String getName() throws SQLException
Returns the name of the trigger (as declared in theCREATE TRIGGER
statement).- Specified by:
getName
in interfaceTriggerData
- Throws:
SQLException
- if the contained native buffer has gone stale.
-
isFiredAfter
public boolean isFiredAfter() throws SQLException
Returnstrue
if the trigger was fired after the statement or row action that it is associated with.- Specified by:
isFiredAfter
in interfaceTriggerData
- Throws:
SQLException
- if the contained native buffer has gone stale.
-
isFiredBefore
public boolean isFiredBefore() throws SQLException
Returnstrue
if the trigger was fired before the statement or row action that it is associated with.- Specified by:
isFiredBefore
in interfaceTriggerData
- Throws:
SQLException
- if the contained native buffer has gone stale.
-
isFiredForEachRow
public boolean isFiredForEachRow() throws SQLException
Returnstrue
if this trigger is fired once for each row (as opposed to once for the entire statement).- Specified by:
isFiredForEachRow
in interfaceTriggerData
- Throws:
SQLException
- if the contained native buffer has gone stale.
-
isFiredForStatement
public boolean isFiredForStatement() throws SQLException
Returnstrue
if this trigger is fired once for the entire statement (as opposed to once for each row).- Specified by:
isFiredForStatement
in interfaceTriggerData
- Throws:
SQLException
- if the contained native buffer has gone stale.
-
isFiredByDelete
public boolean isFiredByDelete() throws SQLException
Returnstrue
if this trigger was fired by aDELETE
.- Specified by:
isFiredByDelete
in interfaceTriggerData
- Throws:
SQLException
- if the contained native buffer has gone stale.
-
isFiredByInsert
public boolean isFiredByInsert() throws SQLException
Returnstrue
if this trigger was fired by anINSERT
.- Specified by:
isFiredByInsert
in interfaceTriggerData
- Throws:
SQLException
- if the contained native buffer has gone stale.
-
isFiredByUpdate
public boolean isFiredByUpdate() throws SQLException
Returnstrue
if this trigger was fired by anUPDATE
.- Specified by:
isFiredByUpdate
in interfaceTriggerData
- Throws:
SQLException
- if the contained native buffer has gone stale.
-
-