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

provsql schema More...

Enumerations

ENUM  PROVENANCE_GATE {
  input , plus , times , monus ,
  project , zero , one , eq ,
  agg , semimod , cmp , delta ,
  value , mulinput , update , rv ,
  arith , mixture , assumed , annotation ,
  conditioned , name =() , kind , executable ,
  operations , input_formats , output_format , parser ,
  preference , enabled , argtpl , argtpl_circuit ,
  endpoint , setup_search_path =()
}
 Provenance circuit gate types. More...

Functions

TRIGGER insert_statement_trigger ()
 Trigger function for INSERT statement provenance tracking.
TRIGGER update_statement_trigger ()
 Trigger function for UPDATE statement provenance tracking.
TSTZMULTIRANGE sr_temporal (ANYELEMENT token, REGCLASS token2value)
 Evaluate provenance over the temporal (interval-union) m-semiring.
nummultirange sr_interval_num (ANYELEMENT token, REGCLASS token2value)
 Evaluate provenance over the interval-union m-semiring with a NUMERIC multirange carrier.
int4multirange sr_interval_int (ANYELEMENT token, REGCLASS token2value)
 Evaluate provenance over the interval-union m-semiring with an int4 multirange carrier.
TSTZMULTIRANGE union_tstzintervals (UUID token, REGCLASS token2value)
 Evaluate temporal provenance as a TIMESTAMP multirange.
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.

Variables

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

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 

Comparison of aggregate values (HAVING-clause provenance).

delta 

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

value 

Scalar value (for aggregate provenance).

mulinput 

Multivalued input (for Boolean provenance).

update 

Update operation.

rv 

Continuous random-variable leaf.

arith 

n-ary arithmetic gate over scalar-valued children

mixture 

Probabilistic mixture of two scalar RV roots with a Bernoulli weight.

assumed 

Structural assumption marker over a single child: the.

annotation 

wrapped sub-circuit was computed under the assumption named by the gate's extra label 'BOOLEAN' (e.g.

the safe-query rewrite; the default when the label is absent) or 'absorptive' (cyclic recursion truncated at the absorptive value fixpoint). Transparent for evaluation semirings satisfying the assumption, fatal error for the rest, rendered as an explicit element in PROV-XML export. Transparent single-child wrapper carrying a query-level annotation string in extra (e.g. the inversion-free tractability certificate / per-input order key). Identity for EVERY evaluator; its UUID folds in extra so distinct annotations over the same child are distinct gates.

conditioned 

Conditioning marker: two children [target, evidence].

Evaluated only in the measure interpretation: probability_evaluate returns P(target ∧ evidence) / P(evidence };

name 

Return a DOT or TEXT visualization of the provenance circuit.

Parameters
tokenroot provenance token
token2descmapping table for gate descriptions
dbgdebug level (0 = normal)
Source code
provsql.sql line 6612

Return a DOT visualisation of the d-DNNF compiled from the provenance circuit

Runs the requested external knowledge compiler and renders the resulting d-DNNF as a GraphViz digraph.

Parameters
tokenroot provenance token
compilerexternal compiler or in-process meta-route to invoke; empty (the default) picks the highest-preference available compiler
Source code
provsql.sql line 6630

Return the compiled d-DNNF of a provenance circuit in the c2d / d4 ".nnf" TEXT interchange format.

Companion to compile_to_ddnnf_dot (DOT, for viewing): this is the machine-readable form, suitable for feeding to an external d-DNNF reasoner / verifier or saving next to tseytin_cnf (same variable numbering). Accepts the same compiler / meta-route names.

Parameters
tokenroot provenance token
compilercompiler or in-process meta-route to use; empty (the default) picks the highest-preference available compiler
Source code
provsql.sql line 6649

Structural statistics of the d-DNNF a compiler produces for a provenance circuit.

Compiles the circuit with the given compiler / meta-route (same names as compile_to_ddnnf_dot: d4, d4v2, c2d, minic2d, dsharp, panini-*, tree-decomposition, interpret-as-dd, default) and returns a jsonb object: nodes, edges, and / or / not / inputs counts, smooth, depth (longest path), treewidth (null when not computable), and compile_ms. Lets clients compare what each compiler produces on the same circuit.

Parameters
tokenroot provenance token
compilercompiler or in-process meta-route to use; empty (the default) picks the highest-preference available compiler
Source code
provsql.sql line 6670

Return the DIMACS CNF (Tseytin transformation) of the provenance circuit

Returns the same encoding the extension writes to a temp file before invoking d4 / c2d / minic2d / dsharp. With weighted true (the default), per-input probability weights are appended as w lines.

Parameters
tokenroot provenance token
weightedinclude probability weights when true
mappingprepend "c input <var> <UUID> <prob>" comment lines documenting which provenance input each variable stands for
Source code
provsql.sql line 6688

Map each DIMACS variable of tseytin_cnf back to its provenance input.

Returns one row per input gate: the variable index (matching tseytin_cnf and compile_to_ddnnf's NNF), the original-circuit UUID of that input, and its probability. Lets a satisfying assignment or weighted model count obtained from an external tool be read against the provenance circuit.

Parameters
tokenroot provenance token
Source code
provsql.sql line 6707

Return a DOT visualisation of the tree decomposition of the provenance circuit

Computes the min-fill decomposition used by the in-process knowledge compiler. The first line of the output is a comment of the form "// treewidth=<n>".

Parameters
tokenroot provenance token
Source code
provsql.sql line 6729

Report whether an external tool is on the backend's resolved PATH

Uses the same find_external_tool() helper that the compilers (d4 / c2d / minic2d / dsharp / panini), model counters (ganak / sharpsat-td / dpmc via htb+dmc / weightmc), and visualisation wrappers (graph-easy, dot) themselves consult, so the result reflects exactly what a subsequent probability_evaluate or view_circuit call would see, including the provsql.tool_search_path GUC prepended to $PATH.

Names with a slash are treated as paths and tested directly via access(X_OK); bare names are resolved through /bin/sh's command -v under the backend's PATH.

Parameters
namebare executable (e.g. 'd4') or an absolute path
Returns
true iff the tool resolves to an executable file
Source code
provsql.sql line 6752

Persistent overrides overlaid on the compiled-in tool seed.

Each row is the complete desired RECORD for a tool (added or modified) keyed by logical name, or a tombstone (removed = true) hiding a seeded default. The effective registry is the compiled seed with tombstoned names removed and the remaining rows upserted over it. Written only by the superuser-only register_tool / unregister_tool / set_tool_* functions; read back into each backend's in-memory registry on demand. Marked as a configuration table so pg_dump carries an operator's registrations.

Set-returning listing backing the provsql.tools view.

operations / input_formats / output_format use the KCMCP shared-registry names (see the KCMCP server protocol), so a CLI RECORD and a future kcmcp-server RECORD are comparable; parser is the CLI-only tag for how to decode the tool's raw output. argtpl is the command template ({in}/{out}/... placeholders). available is true iff executable (when set) and every dependency currently resolve on the backend's PATH.

Source code
provsql.sql line 6812

Read-only view of the registered tools.

kind 
executable 
operations 
input_formats 
output_format 
parser 
preference 
enabled 
argtpl 
argtpl_circuit 
endpoint 
setup_search_path 

Transition function for the choose aggregate (keeps first non-NULL value).

Source code
provsql.sql line 7190

Aggregate that returns an arbitrary non-NULL value from a group

Source code
provsql.sql line 7203

Explodes a table column containing aggregated provenance into multiple rows.

For each row in the input table, this function unnests the children of the specified aggregate token column and produces one output row per child. It reconstructs the corresponding value and provenance (provsql) for each resulting row.

The original table is replaced by the transformed table.

Parameters
_tblName of the table to transform.
AGG_TOKENName of the column containing the aggregate to explode.
Source code
provsql.sql line 7220

Append provsql to this database's default search_path, if missing.

ProvSQL's operators and functions live in the provsql schema and are resolved through search_path. When provsql is absent from the path some surfaces fail with a clear error (RV/AGG_TOKEN arithmetic), but others can be silently misrouted by an implicit cross-domain cast. This helper makes the common case painless: it reads the current database-level search_path setting from pg_db_role_setting, appends provsql if not already present (never replacing or reordering the existing entries), and applies the result with ALTER DATABASE. It is idempotent and emits a NOTICE describing what it did.

Only new sessions pick up the change; the calling session keeps its current path. Role-level settings (if any) take precedence over the database-level setting and are left untouched. The caller must be the database owner or a superuser (the privilege model of ALTER DATABASE). Returns the resulting search_path value.

Source code
provsql.sql line 7273