ProvSQL SQL API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
Update provenance (PostgreSQL 14+)

Installation-time advisory: if provsql is not in the database's default search_path, point the user at setup_search_path(). More...

Types

TYPE  update_provenance
 Table recording the history of INSERT, UPDATE, DELETE, and UNDO operations. More...

Functions

TRIGGER insert_statement_trigger ()
 Trigger function for INSERT statement provenance tracking.
TRIGGER update_statement_trigger ()
 Trigger function for UPDATE statement provenance tracking.

Detailed Description

Installation-time advisory: if provsql is not in the database's default search_path, point the user at setup_search_path().

reset_val reflects the configured session default (postgresql.conf / ALTER DATABASE / ALTER ROLE), unaffected by the SET search_path statements this script ran. CREATE EXTENSION raises client_min_messages to WARNING for the duration of the script, so we lower it around the RAISE NOTICE. SET LOCAL only: it unwinds by itself when CREATE EXTENSION's transaction ends. An explicit save/restore here would capture the WARNING clamp (already in force when this block runs) and restore that at session level, leaving the whole installing session with NOTICEs suppressed. Final constants-cache refresh. The planned SELECT statements earlier in this script (reset_constants_cache itself, the zero/one create_gate calls) make the installing session memoize the OID constants mid-script, while objects defined later (notably the choose aggregate, used by the scalar-subquery decorrelation) do not exist yet. Their optional lookups then stay InvalidOid for the rest of the session, silently disabling the corresponding rewrites (e.g. IN/NOT IN over a tracked relation would raise "Subqueries ... not supported") until a new connection. Refreshing here, after every object exists, repairs the installing session's cache.

Extended provenance tracking for INSERT, UPDATE, DELETE, and UNDO operations, including temporal validity ranges.

Function Documentation

◆ insert_statement_trigger()

TRIGGER insert_statement_trigger ( )

Trigger function for INSERT statement provenance tracking.

Records the insertion in update_provenance and multiplies provenance tokens of inserted rows with the insert token.

Source code
provsql.sql line 10740

◆ update_statement_trigger()

TRIGGER update_statement_trigger ( )

Trigger function for UPDATE statement provenance tracking.

Records the update in update_provenance. Multiplies new-row tokens with the update token and applies monus to old-row tokens.

Source code
provsql.sql line 10787