ProvSQL SQL API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
provsql Schema Reference

provsql schema More...

Types

TYPE  GATE_WITH_DESC
 Row type for sub_circuit_with_desc results. More...
 
TYPE  update_provenance
 Table recording the history of INSERT, UPDATE, DELETE, and UNDO operations. More...
 

Enumerations

ENUM  PROVENANCE_GATE {
  input , plus , times , monus ,
  project , zero , one , eq ,
  agg , semimod , cmp , delta ,
  value , mulinput , update
}
 Provenance circuit gate types. More...
 
ENUM  QUERY_TYPE_ENUM { INSERT , DELETE , UPDATE , UNDO }
 Types of update operations tracked for temporal provenance. More...
 

Functions

VOID create_gate (UUID token, PROVENANCE_GATE type, UUID[] children=NULL)
 Create a new gate in the provenance circuit.
 
PROVENANCE_GATE get_gate_type (UUID token)
 Return the gate type of a provenance token.
 
UUID[] get_children (UUID token)
 Return the children of a provenance gate.
 
VOID set_prob (UUID token, DOUBLE PRECISION p)
 Set the probability of an input gate.
 
DOUBLE PRECISION get_prob (UUID token)
 Get the probability associated with an input gate.
 
VOID set_infos (UUID token, INT info1, INT info2=NULL)
 Set additional INTEGER values on provenance circuit gate.
 
RECORD get_infos (UUID token, OUT INT info1, OUT INT info2)
 Get the INTEGER info values associated with a circuit gate.
 
VOID set_extra (UUID token, TEXT data)
 Set extra TEXT information on provenance circuit gate.
 
TEXT get_extra (UUID token)
 Get the TEXT-encoded extra data associated with a circuit gate.
 
BIGINT get_nb_gates ()
 Return the total number of gates in the provenance circuit.
 
TRIGGER add_gate_trigger ()
 Trigger function that creates an input gate for each newly inserted row.
 
TRIGGER delete_statement_trigger ()
 Trigger function for DELETE statement provenance tracking.
 
VOID add_provenance (REGCLASS _tbl)
 Enable provenance tracking on an existing table.
 
VOID remove_provenance (REGCLASS _tbl)
 Remove provenance tracking from a table.
 
VOID repair_key (REGCLASS _tbl, TEXT key_att)
 Set up provenance for a table with duplicate key values.
 
VOID create_provenance_mapping (TEXT newtbl, REGCLASS oldtbl, TEXT att, BOOL preserve_case='f')
 Create a provenance mapping table from an attribute.
 
UUID uuid_ns_provsql ()
 Return the ProvSQL UUID namespace (used for deterministic gate UUIDs)
 
UUID gate_zero ()
 Return the UUID of the semiring zero gate.
 
UUID gate_one ()
 Return the UUID of the semiring one gate.
 
DOUBLE PRECISION epsilon ()
 Return the epsilon threshold used for probability comparisons.
 
UUID provenance_times (UUID[] tokens)
 Create a times (product) gate from multiple provenance tokens.
 
UUID provenance_monus (UUID token1, UUID token2)
 Create a monus (difference) gate from two provenance tokens.
 
UUID provenance_project (UUID token, INT[] positions)
 Create a project gate for where-provenance tracking.
 
UUID provenance_eq (UUID token, INT pos1, INT pos2)
 Create an equijoin gate for where-provenance tracking.
 
UUID provenance_plus (UUID[] tokens)
 Create a plus (sum) gate from an array of provenance tokens.
 
UUID provenance_cmp (UUID left_token, OID comparison_op, UUID right_token)
 Create a comparison gate for HAVING clause provenance.
 
ANYELEMENT provenance_evaluate_compiled (UUID token, REGCLASS token2value, TEXT semiring, ANYELEMENT element_one)
 Evaluate provenance using a compiled (built-in) semiring.
 
ANYELEMENT provenance_evaluate (UUID token, REGCLASS token2value, ANYELEMENT element_one, REGTYPE value_type, REGPROC plus_function, REGPROC times_function, REGPROC monus_function, REGPROC delta_function)
 Evaluate provenance over a user-defined semiring (PL/pgSQL version)
 
ANYELEMENT aggregation_evaluate (UUID token, REGCLASS token2value, REGPROC agg_function_final, REGPROC agg_function, REGPROC semimod_function, ANYELEMENT element_one, REGTYPE value_type, REGPROC plus_function, REGPROC times_function, REGPROC monus_function, REGPROC delta_function)
 Evaluate aggregate provenance over a user-defined semiring (PL/pgSQL version)
 
ANYELEMENT provenance_evaluate (UUID token, REGCLASS token2value, ANYELEMENT element_one, REGPROC plus_function, REGPROC times_function, REGPROC monus_function=NULL, REGPROC delta_function=NULL)
 Evaluate provenance over a user-defined semiring (C version)
 
ANYELEMENT aggregation_evaluate (UUID token, REGCLASS token2value, REGPROC agg_function_final, REGPROC agg_function, REGPROC semimod_function, ANYELEMENT element_one, REGPROC plus_function, REGPROC times_function, REGPROC monus_function=NULL, REGPROC delta_function=NULL)
 Evaluate aggregate provenance over a user-defined semiring (C version)
 
SETOF GATE_WITH_DESC sub_circuit_with_desc (UUID token, REGCLASS token2desc)
 Return the sub-circuit reachable from a token, with descriptions.
 
VOID identify_token (UUID token, OUT REGCLASS table_name, OUT INTEGER nb_columns)
 Identify which table and how many columns a provenance token belongs to.
 
TABLE sub_circuit_for_where (UUID token)
 Return the sub-circuit for where-provenance computation.
 
AGG_TOKEN agg_token_in (CSTRING)
 Input function for the AGG_TOKEN type (parses TEXT representation)
 
CSTRING agg_token_out (AGG_TOKEN)
 Output function for the AGG_TOKEN type (produces TEXT representation)
 
TEXT agg_token_cast (AGG_TOKEN)
 Cast an AGG_TOKEN to its TEXT representation.
 
UUID agg_token_uuid (AGG_TOKEN aggtok)
 Extract the UUID from an AGG_TOKEN (implicit cast to UUID)
 
UUID CAST(AGG_TOKEN AS UUID) (AGG_TOKEN)
 Implicit PostgreSQL cast from AGG_TOKEN to UUID (delegates to agg_token_uuid())
 
BOOLEAN agg_token_comp_numeric (AGG_TOKEN a, NUMERIC b)
 Placeholder comparison of AGG_TOKEN with NUMERIC.
 
BOOLEAN numeric_comp_agg_token (NUMERIC a, AGG_TOKEN b)
 Placeholder comparison of NUMERIC with AGG_TOKEN.
 
BOOLEAN agg_token_lt_numeric (AGG_TOKEN left, NUMERIC right)
 SQL operator AGG_TOKEN < NUMERIC (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN numeric_lt_agg_token (NUMERIC left, AGG_TOKEN right)
 SQL operator NUMERIC < AGG_TOKEN (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN agg_token_le_numeric (AGG_TOKEN left, NUMERIC right)
 SQL operator AGG_TOKEN <= NUMERIC (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN numeric_le_agg_token (NUMERIC left, AGG_TOKEN right)
 SQL operator NUMERIC <= AGG_TOKEN (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN agg_token_eq_numeric (AGG_TOKEN left, NUMERIC right)
 SQL operator AGG_TOKEN = NUMERIC (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN numeric_eq_agg_token (NUMERIC left, AGG_TOKEN right)
 SQL operator NUMERIC = AGG_TOKEN (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN agg_token_ne_numeric (AGG_TOKEN left, NUMERIC right)
 SQL operator AGG_TOKEN <> NUMERIC (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN numeric_ne_agg_token (NUMERIC left, AGG_TOKEN right)
 SQL operator NUMERIC <> AGG_TOKEN (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN agg_token_ge_numeric (AGG_TOKEN left, NUMERIC right)
 SQL operator AGG_TOKEN >= NUMERIC (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN numeric_ge_agg_token (NUMERIC left, AGG_TOKEN right)
 SQL operator NUMERIC >= AGG_TOKEN (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN agg_token_gt_numeric (AGG_TOKEN left, NUMERIC right)
 SQL operator AGG_TOKEN > NUMERIC (placeholder rewritten by ProvSQL at plan time)
 
BOOLEAN numeric_gt_agg_token (NUMERIC left, AGG_TOKEN right)
 SQL operator NUMERIC > AGG_TOKEN (placeholder rewritten by ProvSQL at plan time)
 
UUID provenance_delta (UUID token)
 Create a δ-semiring gate wrapping a provenance token.
 
AGG_TOKEN provenance_aggregate (INTEGER aggfnoid, INTEGER aggtype, ANYELEMENT val, UUID[] tokens)
 Build an aggregate provenance gate from grouped tokens.
 
UUID provenance_semimod (ANYELEMENT val, UUID token)
 Create a semimodule scalar multiplication gate.
 
DOUBLE PRECISION probability_evaluate (UUID token, TEXT method=NULL, TEXT arguments=NULL)
 Compute the probability of a provenance token.
 
DOUBLE PRECISION expected (ANYELEMENT input, UUID prov=gate_one(), TEXT method=NULL, TEXT arguments=NULL)
 Compute the expected value of an aggregate expression.
 
DOUBLE PRECISION shapley (UUID token, UUID variable, TEXT method=NULL, TEXT arguments=NULL, BOOLEAN banzhaf='f')
 Compute the Shapley value of an input variable.
 
SETOF RECORD shapley_all_vars (UUID token, TEXT method=NULL, TEXT arguments=NULL, BOOLEAN banzhaf='f', OUT UUID variable, OUT DOUBLE PRECISIONvalue)
 Compute Shapley values for all input variables at once.
 
DOUBLE PRECISION banzhaf (UUID token, UUID variable, TEXT method=NULL, TEXT arguments=NULL)
 Compute the Banzhaf power index of an input variable.
 
SETOF RECORD banzhaf_all_vars (UUID token, TEXT method=NULL, TEXT arguments=NULL, OUT UUID variable, OUT DOUBLE PRECISIONvalue)
 Compute Banzhaf power indices for all input variables at once.
 
TEXT view_circuit (UUID token, REGCLASS token2desc, INT dbg=0)
 Return a DOT or TEXT visualization of the provenance circuit.
 
TEXT to_provxml (UUID token, REGCLASS token2desc=NULL)
 Return an XML representation of the provenance circuit.
 
UUID provenance ()
 Return the provenance token of the current query result tuple.
 
TEXT where_provenance (UUID token)
 Compute where-provenance for a result tuple.
 
VOID reset_constants_cache ()
 Reset the internal cache of OID constants used by the query rewriter.
 
VARCHAR sr_formula (ANYELEMENT token, REGCLASS token2value)
 Evaluate provenance as a symbolic formula (e.g., "a ⊗ b ⊕ c")
 
INT sr_counting (ANYELEMENT token, REGCLASS token2value)
 Evaluate provenance over the counting semiring (ℕ)
 
VARCHAR sr_why (ANYELEMENT token, REGCLASS token2value)
 Evaluate provenance as why-provenance (set of witness sets)
 
VARCHAR sr_boolexpr (ANYELEMENT token)
 Evaluate provenance as a Boolean expression.
 
BOOLEAN sr_boolean (ANYELEMENT token, REGCLASS token2value)
 Evaluate provenance over the Boolean semiring (true/false)
 
ANYELEMENT choose_function (ANYELEMENT state, ANYELEMENT data)
 Transition function for the choose aggregate (keeps first non-NULL value)
 
VOID choose (ANYELEMENT)
 Aggregate that returns an arbitrary non-NULL value from a group.
 
TRIGGER insert_statement_trigger ()
 Trigger function for INSERT statement provenance tracking.
 
TRIGGER update_statement_trigger ()
 Trigger function for UPDATE statement provenance tracking.
 
TSTZMULTIRANGE union_tstzintervals_plus_state (TSTZMULTIRANGE state, TSTZMULTIRANGE value)
 Transition function for temporal union (plus): merge multiranges.
 
TSTZMULTIRANGE union_tstzintervals_times_state (TSTZMULTIRANGE state, TSTZMULTIRANGE value)
 Transition function for temporal intersection (times): intersect multiranges.
 
VOID union_tstzintervals_plus (TSTZMULTIRANGE)
 Aggregate: union of TIMESTAMP multiranges (semiring plus)
 
VOID union_tstzintervals_times (TSTZMULTIRANGE)
 Aggregate: intersection of TIMESTAMP multiranges (semiring times)
 
TSTZMULTIRANGE union_tstzintervals_monus (TSTZMULTIRANGE state, TSTZMULTIRANGE value)
 Temporal monus: subtract one multirange from another.
 
TSTZMULTIRANGE union_tstzintervals (UUID token, REGCLASS token2value)
 Evaluate temporal provenance as a TIMESTAMP multirange.
 
VOID 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 timetravel (TEXT tablename, TIMESTAMPTZ at_time)
 Query a table as it was at a specific point in time.
 
SETOF RECORD timeslice (TEXT tablename, TIMESTAMPTZ from_time, TIMESTAMPTZ to_time)
 Query a table for rows valid during a time interval.
 
SETOF RECORD history (TEXT tablename, TEXT[] col_names, TEXT[] col_values)
 Query the full temporal history of specific rows.
 
TSTZMULTIRANGE get_valid_time (UUID token, TEXT tablename)
 Get the valid time range for a specific tuple.
 
UUID undo (UUID c)
 Undo a previously recorded update operation.
 
UUID replace_the_circuit (UUID x, UUID c, UUID u)
 Recursively rewrite a circuit to undo a specific operation.
 

Detailed Description

provsql schema

All types and functions introduced by ProvSQL are defined in the provsql schema, requiring prefixing them by provsql. or using PostgreSQL's search_path variable with a command such as

SET search_path TO public, provsql;

Enumeration Type Documentation

◆ PROVENANCE_GATE

Provenance circuit gate types.

Each gate in the provenance circuit has a type that determines its semantics during semiring evaluation.

Enumerator
input 

Input (variable) gate of the circuit.

plus 

Semiring plus.

times 

Semiring times.

monus 

M-Semiring monus.

project 

Project gate (for where provenance)

zero 

Semiring zero.

one 

Semiring one.

eq 

Equijoin gate (for where provenance)

agg 

Aggregation operator (for aggregate provenance)

semimod 

Semimodule scalar multiplication (for aggregate provenance)

cmp 

Currently unused, meant for comparison of aggregate values.

delta 

δ-semiring operator (see Amsterdamer, Deutch, Tannen, PODS 2011)

value 

Scalar value (for aggregate provenance)

mulinput 

Multivalued input (for Boolean provenance)

update 

Update operation.

◆ QUERY_TYPE_ENUM

Types of update operations tracked for temporal provenance.

Enumerator
INSERT 

Row was inserted.

DELETE 

Row was deleted.

UPDATE 

Row was updated.

UNDO 

Previous operation was undone.