ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
provenance_evaluate_compiled.cpp File Reference

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"
Include dependency graph for provenance_evaluate_compiled.cpp:

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.

Detailed Description

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):

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.

Function Documentation

◆ join_with_temp_uuids()

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.

Parameters
tableOID of the provenance mapping relation.
uuidsList of UUID strings to join against.
Returns
true if a temporary table was created (caller must drop it).

Definition at line 155 of file provenance_evaluate_compiled.cpp.

Here is the caller graph for this function:

◆ provenance_evaluate_compiled()

Datum provenance_evaluate_compiled ( PG_FUNCTION_ARGS )

PostgreSQL-callable wrapper for provenance_evaluate_compiled().

Definition at line 359 of file provenance_evaluate_compiled.cpp.

Here is the call graph for this function:

◆ provenance_evaluate_compiled_internal()

Datum provenance_evaluate_compiled_internal ( pg_uuid_t token,
Oid table,
const std::string & semiring,
Oid type )
static

Core implementation of compiled provenance evaluation.

Parameters
tokenUUID of the root provenance gate.
tableOID of the provenance mapping relation.
semiringName of the semiring to evaluate over.
typeOID of the result element type.
Returns
Datum containing the semiring evaluation result.

Definition at line 249 of file provenance_evaluate_compiled.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ drop_temp_table

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.