![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
SQL function provsql.provenance_evaluate_compiled() – C++ semiring evaluation.
More...
#include "postgres.h"#include "fmgr.h"#include "catalog/pg_type.h"#include "utils/uuid.h"#include "utils/lsyscache.h"#include "provsql_shmem.h"#include "provsql_utils.h"#include <string>#include <sstream>#include <vector>#include <unordered_map>#include <algorithm>#include "having_semantics.hpp"#include "provenance_evaluate_compiled.hpp"#include "semiring/Boolean.h"#include "semiring/Counting.h"#include "semiring/Formula.h"#include "semiring/Why.h"#include "semiring/BoolExpr.h"
Go to the source code of this file.
Functions | |
| static Datum | pec_bool (const constants_t &constants, GenericCircuit &c, gate_t g, const std::set< gate_t > &inputs, const std::string &semiring, bool drop_table) |
| Evaluate the Boolean semiring provenance for a circuit. | |
| static Datum | pec_boolexpr (const constants_t &constants, BooleanCircuit &bc, gate_t root) |
| Evaluate the Boolean-expression semiring provenance for a circuit. | |
| static Datum | pec_why (const constants_t &constants, GenericCircuit &c, gate_t g, const std::set< gate_t > &inputs, bool drop_table) |
| Evaluate the Why-provenance semiring for a circuit. | |
| static Datum | pec_varchar (const constants_t &constants, GenericCircuit &c, gate_t g, const std::set< gate_t > &inputs, const std::string &semiring, bool drop_table) |
| Evaluate a varchar semiring provenance for a circuit. | |
| static Datum | pec_int (const constants_t &constants, GenericCircuit &c, gate_t g, const std::set< gate_t > &inputs, const std::string &semiring, bool drop_table) |
| Evaluate an integer semiring provenance for a circuit. | |
| bool | join_with_temp_uuids (Oid table, const std::vector< std::string > &uuids) |
| Join a provenance mapping table with a set of UUIDs using SPI. | |
| static Datum | provenance_evaluate_compiled_internal (pg_uuid_t token, Oid table, const std::string &semiring, Oid type) |
| Core implementation of compiled provenance evaluation. | |
| Datum | provenance_evaluate_compiled (PG_FUNCTION_ARGS) |
| PostgreSQL-callable wrapper for provenance_evaluate_compiled(). | |
Variables | |
| const char * | drop_temp_table = "DROP TABLE IF EXISTS tmp_uuids;" |
| DROP TABLE statement for the per-query temporary provenance mapping table. | |
SQL function provsql.provenance_evaluate_compiled() – C++ semiring evaluation.
Implements the compiled (C++ generic) variant of provenance circuit evaluation. Unlike provenance_evaluate() (which calls user-supplied PostgreSQL functions for each semiring operation), this function evaluates the circuit using one of the built-in C++ semiring implementations from the semiring/ directory.
Supported semirings (selected by the semiring argument):
"boolean" → semiring::Boolean "counting" → semiring::Counting "formula" → semiring::Formula (symbolic expression)"why" → semiring::Why (witness sets)"boolexpr" → semiring::BoolExpr (Boolean circuit for probability)The function first builds a provenance mapping (input-gate UUID → semiring value) by querying the tmp_uuids table via SPI (using initialize_provenance_mapping()), then evaluates the GenericCircuit with GenericCircuit::evaluate() and returns the result as text.
Definition in file provenance_evaluate_compiled.cpp.
| bool join_with_temp_uuids | ( | Oid | table, |
| const std::vector< std::string > & | uuids | ||
| ) |
Join a provenance mapping table with a set of UUIDs using SPI.
| table | OID of the provenance mapping relation. |
| uuids | List of UUID strings to join against. |
true if a temporary table was created (caller must drop it). Definition at line 245 of file provenance_evaluate_compiled.cpp.

|
static |
Evaluate the Boolean semiring provenance for a circuit.
| constants | Extension OID cache. |
| c | Generic circuit to evaluate. |
| g | Root gate of the sub-circuit. |
| inputs | Set of input gate IDs. |
| semiring | Semiring name (must be "boolean"). |
| drop_table | Whether the temporary UUID table should be dropped. |
Definition at line 63 of file provenance_evaluate_compiled.cpp.


|
static |
Evaluate the Boolean-expression semiring provenance for a circuit.
| constants | Extension OID cache. |
| bc | Boolean circuit to render as a formula. |
| root | Root gate of the circuit. |
Definition at line 92 of file provenance_evaluate_compiled.cpp.


|
static |
Evaluate an integer semiring provenance for a circuit.
| constants | Extension OID cache. |
| c | Generic circuit to evaluate. |
| g | Root gate. |
| inputs | Set of input gate IDs. |
| semiring | Semiring name (e.g. "counting"). |
| drop_table | Whether the temporary UUID table should be dropped. |
Definition at line 216 of file provenance_evaluate_compiled.cpp.


|
static |
Evaluate a varchar semiring provenance for a circuit.
| constants | Extension OID cache. |
| c | Generic circuit to evaluate. |
| g | Root gate. |
| inputs | Set of input gate IDs. |
| semiring | Semiring name (e.g. "formula"). |
| drop_table | Whether the temporary UUID table should be dropped. |
Definition at line 177 of file provenance_evaluate_compiled.cpp.


|
static |
Evaluate the Why-provenance semiring for a circuit.
| constants | Extension OID cache. |
| c | Generic circuit to evaluate. |
| g | Root gate. |
| inputs | Set of input gate IDs. |
| drop_table | Whether the temporary UUID table should be dropped. |
Definition at line 114 of file provenance_evaluate_compiled.cpp.


| Datum provenance_evaluate_compiled | ( | PG_FUNCTION_ARGS | ) |
PostgreSQL-callable wrapper for provenance_evaluate_compiled().
Definition at line 369 of file provenance_evaluate_compiled.cpp.

|
static |
Core implementation of compiled provenance evaluation.
| token | UUID of the root provenance gate. |
| table | OID of the provenance mapping relation. |
| semiring | Name of the semiring to evaluate over. |
| type | OID of the result element type. |
Definition at line 332 of file provenance_evaluate_compiled.cpp.


| const char* drop_temp_table = "DROP TABLE IF EXISTS tmp_uuids;" |
DROP TABLE statement for the per-query temporary provenance mapping table.
Definition at line 51 of file provenance_evaluate_compiled.cpp.