ProvSQL SQL API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
Semiring operations

Functions that build provenance circuit gates for semiring operations. More...

Functions

UUID provsql.provenance_times (UUID[] tokens)
 Create a times (product) gate from multiple provenance tokens.
UUID provsql.provenance_monus (UUID token1, UUID token2)
 Create a monus (difference) gate from two provenance tokens.
UUID provsql.provenance_project (UUID token, INT[] positions)
 Create a project gate for where-provenance tracking.
UUID provsql.provenance_eq (UUID token, INT pos1, INT pos2)
 Create an equijoin gate for where-provenance tracking.
UUID provsql.provenance_plus (UUID[] tokens)
 Create a plus (sum) gate from an array of provenance tokens.
UUID provsql.provenance_cmp (UUID left_token, OID comparison_op, UUID right_token)
 Create a comparison gate for HAVING clause provenance.
UUID provsql.provenance_arith (INTEGER op, UUID[] children)
 Create an arithmetic gate over scalar-valued provenance children.

Detailed Description

Functions that build provenance circuit gates for semiring operations.

These are called internally by the query rewriter.

Function Documentation

◆ provenance_arith()

UUID provsql.provenance_arith ( INTEGER op,
UUID[] children )

Create an arithmetic gate over scalar-valued provenance children.

Builds a deterministic gate_arith from an operator tag and an ordered list of children. The tag is one of the provsql_arith_op ENUM values declared in src/provsql_utils.h (PLUS=0, TIMES=1, MINUS=2, DIV=3, NEG=4) and is stored in the gate's info1 field. Children must be UUIDs of scalar-producing gates (gate_rv, gate_value, or another gate_arith). The token UUID is derived deterministically from op and children so identical sub-expressions share their gate.

Parameters
opOperator tag (provsql_arith_op).
childrenOrdered list of child gate UUIDs.
Returns
UUID of the (possibly pre-existing) gate_arith.
Source code
provsql.sql line 922

◆ provenance_cmp()

UUID provsql.provenance_cmp ( UUID left_token,
OID comparison_op,
UUID right_token )

Create a comparison gate for HAVING clause provenance.

Parameters
left_tokenprovenance token for the left operand
comparison_opOID of the comparison operator
right_tokenprovenance token for the right operand
Source code
provsql.sql line 879

◆ provenance_eq()

UUID provsql.provenance_eq ( UUID token,
INT pos1,
INT pos2 )

Create an equijoin gate for where-provenance tracking.

Parameters
tokenchild provenance token
pos1attribute index in the first relation
pos2attribute index in the second relation
Source code
provsql.sql line 821

◆ provenance_monus()

UUID provsql.provenance_monus ( UUID token1,
UUID token2 )

Create a monus (difference) gate from two provenance tokens.

Implements m-semiring monus. Returns token1 if token2 is NULL (used for LEFT OUTER JOIN semantics in the EXCEPT rewriting).

Source code
provsql.sql line 752

◆ provenance_plus()

UUID provsql.provenance_plus ( UUID[] tokens)

Create a plus (sum) gate from an array of provenance tokens.

Filters out NULL and zero-gates; returns gate_zero() if all tokens are trivial, or a single token if only one remains.

Source code
provsql.sql line 842

◆ provenance_project()

UUID provsql.provenance_project ( UUID token,
INT[] positions )

Create a project gate for where-provenance tracking.

Records the mapping between input and output attribute positions.

Parameters
tokenchild provenance token
positionsarray encoding attribute position mappings
Source code
provsql.sql line 794

◆ provenance_times()

UUID provsql.provenance_times ( UUID[] tokens)

Create a times (product) gate from multiple provenance tokens.

Filters out NULL and one-gates; returns gate_one() if all tokens are trivial, or a single token if only one remains.

Source code
provsql.sql line 717