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

Functions for temporal database support. More...

Functions

TSTZMULTIRANGE provsql.sr_temporal (ANYELEMENT token, REGCLASS token2value)
 Evaluate provenance over the temporal (interval-union) m-semiring.
nummultirange provsql.sr_interval_num (ANYELEMENT token, REGCLASS token2value)
 Evaluate provenance over the interval-union m-semiring with a NUMERIC multirange carrier.
int4multirange provsql.sr_interval_int (ANYELEMENT token, REGCLASS token2value)
 Evaluate provenance over the interval-union m-semiring with an int4 multirange carrier.
TSTZMULTIRANGE provsql.union_tstzintervals (UUID token, REGCLASS token2value)
 Evaluate temporal provenance as a TIMESTAMP multirange.
SETOF RECORD provsql.timetravel (TEXT tablename, TIMESTAMPTZ at_time)
 Query a table as it was at a specific point in time.
SETOF RECORD provsql.timeslice (TEXT tablename, TIMESTAMPTZ from_time, TIMESTAMPTZ to_time)
 Query a table for rows valid during a time interval.
SETOF RECORD provsql.history (TEXT tablename, TEXT[] col_names, TEXT[] col_values)
 Query the full temporal history of specific rows.
TSTZMULTIRANGE provsql.get_valid_time (UUID token, TEXT tablename)
 Get the valid time range for a specific tuple.
UUID provsql.undo (UUID c)
 Undo a previously recorded update operation.
UUID provsql.replace_the_circuit (UUID x, UUID c, UUID u)
 Recursively rewrite a circuit to undo a specific operation.

Detailed Description

Functions for temporal database support.

These use provenance evaluation over the multirange semiring to track temporal validity of tuples.

Function Documentation

◆ get_valid_time()

TSTZMULTIRANGE provsql.get_valid_time ( UUID token,
TEXT tablename )

Get the valid time range for a specific tuple.

Parameters
tokenprovenance token of the tuple
tablenamename of the table containing the tuple
Source code
provsql.sql line 4492

◆ history()

SETOF RECORD provsql.history ( TEXT tablename,
TEXT[] col_names,
TEXT[] col_values )

Query the full temporal history of specific rows.

Returns all versions of rows matching the given column values, with their temporal validity ranges.

Parameters
tablenamename of the provenance-tracked table
col_namesarray of column names to filter on
col_valuesarray of corresponding values to match

◆ replace_the_circuit()

UUID provsql.replace_the_circuit ( UUID x,
UUID c,
UUID u )

Recursively rewrite a circuit to undo a specific operation.

Helper for undo(). Walks the circuit and replaces occurrences of the target update gate with its monus.

Parameters
xprovenance token to rewrite
cUUID of the update operation to undo
uUUID of the undo operation
Source code
provsql.sql line 4618

◆ sr_interval_int()

int4multirange provsql.sr_interval_int ( ANYELEMENT token,
REGCLASS token2value )

Evaluate provenance over the interval-union m-semiring with an int4 multirange carrier.

Inputs are read as int4multirange validity ranges over the integers (e.g. page or line ranges of supporting documents). Addition is multirange union, multiplication is intersection, monus is set difference; the additive identity is '{}'::int4multirange and the multiplicative identity is '{(,)}'::int4multirange.

Parameters
tokenProvenance token to evaluate.
token2valueMapping from input gates to int4 multiranges.
Source code
provsql.sql line 4327

◆ sr_interval_num()

nummultirange provsql.sr_interval_num ( ANYELEMENT token,
REGCLASS token2value )

Evaluate provenance over the interval-union m-semiring with a NUMERIC multirange carrier.

Inputs are read as nummultirange validity ranges over a NUMERIC domain (e.g. sensor measurement-validity ranges). Addition is multirange union, multiplication is intersection, monus is set difference; the additive identity is '{}'::nummultirange and the multiplicative identity is '{(,)}'::nummultirange (universal range).

Parameters
tokenProvenance token to evaluate.
token2valueMapping from input gates to NUMERIC multiranges.
Source code
provsql.sql line 4300

◆ sr_temporal()

TSTZMULTIRANGE provsql.sr_temporal ( ANYELEMENT token,
REGCLASS token2value )

Evaluate provenance over the temporal (interval-union) m-semiring.

Inputs are read as TSTZMULTIRANGE validity intervals; the additive identity is '{}'::TSTZMULTIRANGE (empty), the multiplicative identity is '{(,)}'::TSTZMULTIRANGE (universal). Returns the union of intervals supporting the result, computed via the compiled circuit traversal.

Parameters
tokenProvenance token to evaluate.
token2valueMapping from input gates to validity multiranges.
Source code
provsql.sql line 4273

◆ timeslice()

SETOF RECORD provsql.timeslice ( TEXT tablename,
TIMESTAMPTZ from_time,
TIMESTAMPTZ to_time )

Query a table for rows valid during a time interval.

Returns all rows whose temporal validity overlaps the given range.

Parameters
tablenamename of the provenance-tracked table
from_timestart of the time interval
to_timeend of the time interval

◆ timetravel()

SETOF RECORD provsql.timetravel ( TEXT tablename,
TIMESTAMPTZ at_time )

Query a table as it was at a specific point in time.

Returns all rows whose temporal validity includes the given TIMESTAMP.

Parameters
tablenamename of the provenance-tracked table
at_timethe point in time to query

◆ undo()

UUID provsql.undo ( UUID c)

Undo a previously recorded update operation.

Traverses all provenance-tracked tables and rewrites their circuits to apply monus with respect to the given update token, effectively undoing the operation.

Parameters
cUUID of the update operation to undo (from update_provenance)
Source code
provsql.sql line 4530

◆ union_tstzintervals()

TSTZMULTIRANGE provsql.union_tstzintervals ( UUID token,
REGCLASS token2value )

Evaluate temporal provenance as a TIMESTAMP multirange.

Thin wrapper around :sqlfunc:sr_temporal retained for backward compatibility; both compute the same union of validity intervals.

Parameters
tokenprovenance token to evaluate
token2valuemapping table from tokens to temporal validity ranges
Source code
provsql.sql line 4349