Stream triggers row functions v5

bdr.trigger_get_row

This function returns the contents of a trigger row specified by an identifier as a RECORD. This function returns NULL if called inappropriately, that is, called with SOURCE_NEW when the operation type (TG_OP) is DELETE.

Synopsis

bdr.trigger_get_row(row_id text)

Parameters

  • row_id Identifier of the row. Can be any of SOURCE_NEW, SOURCE_OLD, and TARGET, depending on the trigger type and operation. (See the descriptions of the individual trigger types.)

bdr.trigger_get_committs

This function returns the commit timestamp of a trigger row specified by an identifier. If not available because a row is frozen or isn't available, returns NULL. Always returns NULL for row identifier SOURCE_OLD.

Synopsis

bdr.trigger_get_committs(row_id text)

Parameters

  • row_id Identifier of the row. Can be any of SOURCE_NEW, SOURCE_OLD, and TARGET, depending on trigger type and operation. (See the descriptions of the individual trigger types.)

bdr.trigger_get_xid

This function returns the local transaction id of a TARGET row specified by an identifier. If not available because a row is frozen or isn't available, returns NULL. Always returns NULL for SOURCE_OLD and SOURCE_NEW row identifiers.

Available only for conflict triggers.

Synopsis

bdr.trigger_get_xid(row_id text)

Parameters

  • row_id Identifier of the row. Can be any of SOURCE_NEW, SOURCE_OLD, and TARGET, depending on trigger type and operation. (See the descriptions of the individual trigger types.)

bdr.trigger_get_type

This function returns the current trigger type, which can be CONFLICT or TRANSFORM. Returns null if called outside a stream trigger.

Synopsis

bdr.trigger_get_type()

bdr.trigger_get_conflict_type

This function returns the current conflict type if called inside a conflict trigger. Otherwise, returns NULL.

See Conflict types for possible return values of this function.

Synopsis

bdr.trigger_get_conflict_type()

bdr.trigger_get_origin_node_id

This function returns the node id corresponding to the origin for the trigger row_id passed in as argument. If the origin isn't valid (which means the row originated locally), returns the node id of the source or target node, depending on the trigger row argument. Always returns NULL for row identifier SOURCE_OLD. You can use this function to define conflict triggers to always favor a trusted source node.

Synopsis

bdr.trigger_get_origin_node_id(row_id text)

Parameters

  • row_id Identifier of the row. Can be any of SOURCE_NEW, SOURCE_OLD, and TARGET, depending on trigger type and operation. (See the descriptions of the individual trigger types.)

bdr.ri_fkey_on_del_trigger

When called as a BEFORE trigger, this function uses FOREIGN KEY information to avoid FK anomalies.

Synopsis

bdr.ri_fkey_on_del_trigger()