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...

Functions

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

Variables

 provsql.provsql
 Table recording the history of INSERT, UPDATE, DELETE, and UNDO operations.
TEXT provsql.query
QUERY_TYPE_ENUM provsql.query_type
TEXT provsql.username
TIMESTAMP provsql.ts
TSTZMULTIRANGE provsql.valid_time

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 provsql.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 7482

◆ update_statement_trigger()

TRIGGER provsql.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 7529

Variable Documentation

◆ provsql

provsql.provsql

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

Each row records one provenance-tracked modification, linking the operation's provenance token to metadata (query TEXT, type, user, TIMESTAMP) and the temporal validity range of the affected rows.

Source code
provsql.sql line 7378

◆ query

TEXT provsql.query

◆ query_type

QUERY_TYPE_ENUM provsql.query_type

◆ ts

TIMESTAMP provsql.ts

◆ username

TEXT provsql.username

◆ valid_time

TSTZMULTIRANGE provsql.valid_time