![]() |
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/builtins.h"#include "utils/lsyscache.h"#include "provsql_utils.h"#include <string>#include <vector>#include <unordered_map>#include <algorithm>#include "Expectation.h"#include "having_semantics.hpp"#include "provenance_evaluate_compiled.hpp"#include "semiring/Boolean.h"#include "semiring/Counting.h"#include "semiring/Formula.h"#include "semiring/How.h"#include "semiring/Why.h"#include "semiring/Which.h"#include "semiring/BoolExpr.h"#include "semiring/Tropical.h"#include "semiring/Viterbi.h"#include "semiring/Lukasiewicz.h"#include "semiring/IntervalUnion.h"#include "semiring/MinMax.h"
Go to the source code of this file.
Functions | |
| 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 representation as a formula)"how" → semiring::How (canonical polynomial provenance ℕ[X])"why" → semiring::Why (witness sets)"which" → semiring::Which (lineage)"boolexpr" → semiring::BoolExpr (Boolean circuit for probability)"tropical" → semiring::Tropical (min-plus, shortest-cost)"viterbi" → semiring::Viterbi (max-times, most-likely derivation)"lukasiewicz" → semiring::Lukasiewicz (Łukasiewicz fuzzy t-norm)"interval_union" → semiring::IntervalUnion (multirange union, PG14+) for any of tstzmultirange, nummultirange, int4multirange; selected by the result type of the call"minmax" / "maxmin" → semiring::MinMax over any user-defined PostgreSQL enum type, selected by get_typtype() == TYPTYPE_ENUM Each compiled semiring exposes parse_leaf() and (for text-valued carriers) to_text() member functions, so this file is purely a dispatcher: it picks the right semiring instance from the (result-type, semiring-name) pair, then calls the pec() template which runs the same four-step pipeline for every semiring (build leaf mapping, evaluate HAVING sub-circuits, evaluate the main circuit, encode the result as a Datum).
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 155 of file provenance_evaluate_compiled.cpp.

| Datum provenance_evaluate_compiled | ( | PG_FUNCTION_ARGS | ) |
PostgreSQL-callable wrapper for provenance_evaluate_compiled().
Definition at line 359 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 249 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 69 of file provenance_evaluate_compiled.cpp.