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.union_tstzintervals_plus_state (TSTZMULTIRANGE state, TSTZMULTIRANGE value)
 Transition function for temporal union (plus): merge multiranges.
 
TSTZMULTIRANGE provsql.union_tstzintervals_times_state (TSTZMULTIRANGE state, TSTZMULTIRANGE value)
 Transition function for temporal intersection (times): intersect multiranges.
 
VOID provsql.union_tstzintervals_plus (TSTZMULTIRANGE)
 Aggregate: union of TIMESTAMP multiranges (semiring plus)
 
VOID provsql.union_tstzintervals_times (TSTZMULTIRANGE)
 Aggregate: intersection of TIMESTAMP multiranges (semiring times)
 
TSTZMULTIRANGE provsql.union_tstzintervals_monus (TSTZMULTIRANGE state, TSTZMULTIRANGE value)
 Temporal monus: subtract one multirange from another.
 
TSTZMULTIRANGE provsql.union_tstzintervals (UUID token, REGCLASS token2value)
 Evaluate temporal provenance as a TIMESTAMP multirange.
 
VOID provsql.create_provenance_mapping_view (TEXT newview, REGCLASS oldtbl, TEXT att, BOOL preserve_case=false)
 Create a view mapping provenance tokens to attribute values.
 
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

◆ create_provenance_mapping_view()

VOID provsql.create_provenance_mapping_view ( TEXT  newview,
REGCLASS  oldtbl,
TEXT  att,
BOOL  preserve_case = false 
)

Create a view mapping provenance tokens to attribute values.

Like create_provenance_mapping but creates a view instead of a table, so it always reflects the current state of the source table.

Parameters
newviewname of the view to create
oldtblsource table with provenance tracking
attattribute whose values populate the mapping
preserve_caseif true, quote the view name to preserve case
Source code
provsql.sql line 1852

◆ 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 2015

◆ 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 2141

◆ 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 2053

◆ union_tstzintervals()

TSTZMULTIRANGE provsql.union_tstzintervals ( UUID  token,
REGCLASS  token2value 
)

Evaluate temporal provenance as a TIMESTAMP multirange.

Evaluates provenance over the multirange semiring to compute the valid time intervals of a tuple.

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

◆ union_tstzintervals_monus()

TSTZMULTIRANGE provsql.union_tstzintervals_monus ( TSTZMULTIRANGE  state,
TSTZMULTIRANGE  value 
)

Temporal monus: subtract one multirange from another.

Source code
provsql.sql line 1805

◆ union_tstzintervals_plus()

VOID provsql.union_tstzintervals_plus ( TSTZMULTIRANGE  )

Aggregate: union of TIMESTAMP multiranges (semiring plus)

Source code
provsql.sql line 1789

◆ union_tstzintervals_plus_state()

TSTZMULTIRANGE provsql.union_tstzintervals_plus_state ( TSTZMULTIRANGE  state,
TSTZMULTIRANGE  value 
)

Transition function for temporal union (plus): merge multiranges.

Source code
provsql.sql line 1769

◆ union_tstzintervals_times()

VOID provsql.union_tstzintervals_times ( TSTZMULTIRANGE  )

Aggregate: intersection of TIMESTAMP multiranges (semiring times)

Source code
provsql.sql line 1797

◆ union_tstzintervals_times_state()

TSTZMULTIRANGE provsql.union_tstzintervals_times_state ( TSTZMULTIRANGE  state,
TSTZMULTIRANGE  value 
)

Transition function for temporal intersection (times): intersect multiranges.

Source code
provsql.sql line 1779