Action hints provide a powerful mechanism to customize the behavior of the vrsn.trigger_handler() function on a per-operation basis. These hints are passed as a jsonb object within the NEW record of the view being manipulated (e.g., NEW.action_hints). The vrsn.trigger_handler() will then interpret these hints via the vrsn.__tar_h__config_func_update function, overriding default behaviors.
Here are the primary parameterizations available within the action_hints JSONB object and their effects:
-
onDupKey(text): Controls behavior when anINSERToperation encounters an existing record with a conflicting unique key."update": If a duplicate key is found, theINSERToperation will be converted into anUPDATEoperation on the existing record."do nothing": If a duplicate key is found, theINSERToperation will be ignored, and no action will be performed.- (Default if not specified or unrecognized: Raises a
unique_violationerror)
-
versioning(text): Controls whether versioning is active for the current operation."off": Disables versioning for the currentINSERTorUPDATEoperation, meaning no new history record will be created, and thedb_ts_rangeof the_currentrecord will not be closed.- (Default if not specified or unrecognized: Versioning remains active as per entity configuration)
-
onUnchangedValue(text): Dictates behavior if anUPDATEoperation detects no actual changes in the record's data (excludingbt_info)."update": Forces an update, even if no values have changed."touch": Updates only thetouchTs(touch timestamp) within theaudit_recordof the existing record, without creating a new historical version."discard": Discards the operation entirely if no changes are detected.- (Default if not specified or unrecognized: Behaves as if
"touch"is specified)
-
onUpdate(text): Influences howNULLvalues in theNEWrecord are handled during anUPDATE."ignore nulls":NULLvalues in theNEWrecord for fields that are not part of the primary key will be ignored, meaning they will not overwrite existing non-NULL values in the database. Only non-NULL values in theNEWrecord will be applied.- (Default if not specified or unrecognized:
NULLvalues inNEWrecord will overwrite existing values)
-
allowFullDeactivationByPastCloseTs(boolean): Used in conjunction with past-dated logical deletions.true: Allows an operation (typically a logical deletion or a retroactive correction) to fully deactivate a record even if itsuser_ts_rangeextends far into the past, affecting all prior history.false: Strict behavior, preventing deactivation if it would fully invalidate records far in the past without explicit range definition.- (Default:
false)
-
dbTs(timestamptz): Allows explicit control over thedb_ts_range(transaction time) of the record.- By providing a timestamp here, you can override the system's
clock_timestamp()for thedb_ts_rangefor the current operation. This is an advanced feature primarily for data migration or specific synchronization scenarios. - (Default:
clock_timestamp())
- By providing a timestamp here, you can override the system's
-
modify_ts(timestamptz): Similar tomodify_user_id, this field in theNEWrecord is used to set theuser_ts_range(valid time) of the record. If provided and it's a past date, it triggers the complex temporal deactivation logic described in the main overview. -
modify_user_id(text): While not explicitly part ofaction_hintsas an override, thevrsn.trigger_handler()explicitly checks for this field in theNEWrecord as the source for theuser_idin theaudit_record. If not found, an exception is raised. It's the mandatory field for user tracking. -
Other Parameters (
extraInfo): Any other key-value pairs present in theaction_hintsJSONB that are not recognized by the specific parameters listed above will be collected and stored in theaudit_recordunder theextraInfokey. This allows for passing custom, application-specific metadata alongside the bitemporal operation without needing to modify the core trigger logic.ac -
Audit record: take a look to this section to deeply understand usage of
modify_user_idandextraInfo.