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

SQL function provsql.where_provenance() – column-level provenance. More...

#include "postgres.h"
#include "fmgr.h"
#include "catalog/pg_type.h"
#include "utils/uuid.h"
#include "executor/spi.h"
#include "utils/builtins.h"
#include "provsql_shmem.h"
#include "provsql_utils.h"
#include <algorithm>
#include <utility>
#include <sstream>
#include "WhereCircuit.h"
#include "provsql_utils_cpp.h"
Include dependency graph for where_provenance.cpp:

Go to the source code of this file.

Functions

static vector< pair< int, int > > parse_array (string s)
 Parse a PostgreSQL text representation of an array of integer pairs.
 
static string where_provenance_internal (Datum token)
 Build a JSON where-provenance description for the circuit rooted at token.
 
Datum where_provenance (PG_FUNCTION_ARGS)
 PostgreSQL-callable wrapper for where_provenance().
 

Detailed Description

SQL function provsql.where_provenance() – column-level provenance.

Implements provsql.where_provenance(), which evaluates the where-provenance of a query result tuple. Where-provenance identifies the base-relation cells (table, row, column) from which each output value was copied.

The function builds a WhereCircuit from the mmap-backed circuit store (using SPI to obtain gate information), evaluates it via WhereCircuit::evaluate(), and returns the result as a PostgreSQL text-array value containing "table.tid.position" locator strings.

Definition in file where_provenance.cpp.

Function Documentation

◆ parse_array()

static vector< pair< int, int > > parse_array ( string  s)
static

Parse a PostgreSQL text representation of an array of integer pairs.

Parameters
sString in the form {{a,b},{c,d},...}.
Returns
Vector of (first, second) integer pairs.

Definition at line 44 of file where_provenance.cpp.

Here is the caller graph for this function:

◆ where_provenance()

Datum where_provenance ( PG_FUNCTION_ARGS  )

PostgreSQL-callable wrapper for where_provenance().

Definition at line 169 of file where_provenance.cpp.

Here is the call graph for this function:

◆ where_provenance_internal()

static string where_provenance_internal ( Datum  token)
static

Build a JSON where-provenance description for the circuit rooted at token.

Parameters
tokenDatum containing the root provenance gate UUID.
Returns
JSON string describing the where-provenance.

Definition at line 76 of file where_provenance.cpp.

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