![]() |
ProvSQL SQL API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Low-level functions for creating and querying provenance circuit gates. More...
Functions | |
| VOID | provsql.create_gate (UUID token, PROVENANCE_GATE type, UUID[] children=NULL) |
| Create a new gate in the provenance circuit. | |
| PROVENANCE_GATE | provsql.get_gate_type (UUID token) |
| Return the gate type of a provenance token. | |
| UUID[] | provsql.get_children (UUID token) |
| Return the children of a provenance gate. | |
| VOID | provsql.set_prob (UUID token, DOUBLE PRECISION p) |
| Set the probability of an input gate. | |
| DOUBLE PRECISION | provsql.get_prob (UUID token) |
| Get the probability associated with an input gate. | |
| VOID | provsql.set_infos (UUID token, INT info1, INT info2=NULL) |
| Set additional INTEGER values on provenance circuit gate. | |
| RECORD | provsql.get_infos (UUID token, OUT INT info1, OUT INT info2) |
| Get the INTEGER info values associated with a circuit gate. | |
| UUID | provsql.assume_boolean (UUID token) |
Wrap token in a fresh gate_assumed_boolean and return the wrapper's UUID. | |
| UUID | provsql.annotate (UUID token, TEXT extra) |
Wrap token in a fresh transparent gate_annotation carrying extra, and return the wrapper's UUID. | |
| TEXT | provsql.inversion_free_key (TEXT root, TEXT sec, INT factor) |
| Build a per-input order-key string for the inversion-free path. | |
| VOID | provsql.set_extra (UUID token, TEXT data) |
| Set extra TEXT information on provenance circuit gate. | |
| TEXT | provsql.get_extra (UUID token) |
| Get the TEXT-encoded extra data associated with a circuit gate. | |
| BIGINT | provsql.get_nb_gates () |
| Return the total number of materialized gates in the provenance circuit. | |
Low-level functions for creating and querying provenance circuit gates.
| UUID provsql.annotate | ( | UUID | token, |
| TEXT | extra ) |
Wrap token in a fresh transparent gate_annotation carrying extra, and return the wrapper's UUID.
Unlike every other gate, the annotation wrapper's UUID folds in extra (not just the child): uuid_generate_v5 over concat('annotation', token, extra). This is deliberate – two annotations over the same child with different extra must be distinct gates (e.g. the same input tuple carrying different per-occurrence order keys, or two queries attaching different certificates to a shared root). The wrapper is transparent (identity) for EVERY evaluator; extra is inert metadata read only by the code that placed it. No-op (returns NULL) on a NULL input.
| UUID provsql.assume_boolean | ( | UUID | token | ) |
Wrap token in a fresh gate_assumed_boolean and return the wrapper's UUID.
Public primitive callable from any rewrite that needs to flag a sub-circuit as having been computed under a Boolean-provenance assumption (the safe-query rewriter is the first caller; future Boolean-only simplifications should reuse this). The wrapper is transparent for Boolean-compatible evaluators (probability, the sr_boolean / sr_boolexpr / sr_formula / sr_interval_* family, where-provenance) and raises a CircuitException for the rest. Always kept as an explicit node in PROV-XML export.
The wrapper UUID is content-derived via uuid_generate_v5 on the child, so identical children always wrap to the same outer UUID (and distinct children always wrap to distinct outer UUIDs). No-op (returns NULL) on a NULL input.
| VOID provsql.create_gate | ( | UUID | token, |
| PROVENANCE_GATE | type, | ||
| UUID[] | children = NULL ) |
Create a new gate in the provenance circuit.
| token | UUID identifying the new gate |
| type | gate type (see PROVENANCE_GATE) |
| children | optional array of child gate UUIDs |
| UUID[] provsql.get_children | ( | UUID | token | ) |
Return the children of a provenance gate.
| TEXT provsql.get_extra | ( | UUID | token | ) |
Get the TEXT-encoded extra data associated with a circuit gate.
| PROVENANCE_GATE provsql.get_gate_type | ( | UUID | token | ) |
Return the gate type of a provenance token.
Returns 'input' for any token not yet materialized in the circuit, since input is the default semantics of an unmaterialized provenance token.
| RECORD provsql.get_infos | ( | UUID | token, |
| OUT INT | info1, | ||
| OUT INT | info2 ) |
Get the INTEGER info values associated with a circuit gate.
| BIGINT provsql.get_nb_gates | ( | ) |
Return the total number of materialized gates in the provenance circuit.
Input gates for provenance-tracked table rows are created lazily on first reference; rows that have never appeared in a query result are not counted.
| DOUBLE PRECISION provsql.get_prob | ( | UUID | token | ) |
Get the probability associated with an input gate.
| TEXT provsql.inversion_free_key | ( | TEXT | root, |
| TEXT | sec, | ||
| INT | factor ) |
Build a per-input order-key string for the inversion-free path.
Emitted by the planner per certified atom: K-prefixed, length-prefixed "K<factor> <octet_length(root)>:<root><octet_length(sec)>:<sec>", parsed back at evaluation by safe_cert_key_parse. root / sec are the tuple's root- and secondary-class column values (TEXT-cast by the caller); the byte-length prefixes keep the values unambiguous for any column type, including TEXT containing spaces, colons or digits. factor is the atom's factor id (or -1 for the shared self-join guard). IMMUTABLE so the planner can fold it and the marker dedups by content-addressing.
| VOID provsql.set_extra | ( | UUID | token, |
| TEXT | data ) |
Set extra TEXT information on provenance circuit gate.
This function sets TEXT-encoded data associated to a circuit gate, used in different ways by different gate types:
| token | UUID of the circuit gate |
| data | TEXT-encoded information |
| VOID provsql.set_infos | ( | UUID | token, |
| INT | info1, | ||
| INT | info2 = NULL ) |
Set additional INTEGER values on provenance circuit gate.
This function sets two INTEGER values associated to a circuit gate, used in different ways by different gate types:
| token | UUID of the circuit gate |
| info1 | first INTEGER value |
| info2 | second INTEGER value |
| VOID provsql.set_prob | ( | UUID | token, |
| DOUBLE PRECISION | p ) |
Set the probability of an input gate.
| token | UUID of the input gate |
| p | probability value in [0,1] |