![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Typed aggregation value, operator, and aggregator abstractions. More...
#include "postgres.h"#include <variant>#include <string>#include <vector>#include <cassert>#include <memory>

Go to the source code of this file.
Classes | |
| struct | AggValue |
| A dynamically-typed aggregate value. More... | |
| struct | Aggregator |
| Abstract interface for an incremental aggregate accumulator. More... | |
Enumerations | |
| enum class | ComparisonOperator { EQ , NE , LE , LT , GE , GT } |
SQL comparison operators used in gate_cmp circuit gates. More... | |
| enum class | AggregationOperator { COUNT , SUM , MIN , MAX , AVG , AND , OR , CHOOSE , ARRAY_AGG , NONE } |
| SQL aggregation functions tracked by ProvSQL. More... | |
| enum class | ValueType { INT , FLOAT , BOOLEAN , STRING , ARRAY_INT , ARRAY_FLOAT , ARRAY_BOOLEAN , ARRAY_STRING , NONE } |
| Runtime type tag for aggregate values. More... | |
Functions | |
| AggregationOperator | getAggregationOperator (Oid oid) |
Map a PostgreSQL aggregate function OID to an AggregationOperator. | |
| ComparisonOperator | cmpOpFromOid (Oid op_oid, bool &ok) |
Map a PostgreSQL comparison-operator OID to a ComparisonOperator. | |
| std::unique_ptr< Aggregator > | makeAggregator (AggregationOperator op, ValueType t) |
Create a concrete Aggregator for the given operator and value type. | |
Typed aggregation value, operator, and aggregator abstractions.
This header provides the type system used by ProvSQL's aggregate provenance evaluation:
ComparisonOperator: the six standard SQL comparison operators, used by gate_cmp gates in the circuit.AggregationOperator: the SQL aggregation functions that ProvSQL tracks provenance for (COUNT, SUM, MIN, MAX, AVG, AND, OR, …).ValueType: the runtime type tag for aggregate values.AggValue: a tagged union holding one aggregate value of any supported type, built on std::variant.Aggregator: an abstract interface for stateful incremental accumulators, one per aggregation function/type combination.The free functions getAggregationOperator() and makeAggregator() map PostgreSQL OIDs and operator/type pairs to the corresponding C++ objects.
Definition in file Aggregation.h.
|
strong |
SQL aggregation functions tracked by ProvSQL.
Definition at line 50 of file Aggregation.h.
|
strong |
SQL comparison operators used in gate_cmp circuit gates.
| Enumerator | |
|---|---|
| EQ | Equal (=). |
| NE | Not equal (<>). |
| LE | Less than or equal (<=). |
| LT | Less than (<). |
| GE | Greater than or equal (>=). |
| GT | Greater than (>). |
Definition at line 38 of file Aggregation.h.
|
strong |
Runtime type tag for aggregate values.
Definition at line 66 of file Aggregation.h.
| ComparisonOperator cmpOpFromOid | ( | Oid | op_oid, |
| bool & | ok ) |
Map a PostgreSQL comparison-operator OID to a ComparisonOperator.
The OID is the one stored in gate_cmp's info1 field (the OID of one of the six standard comparators =, <>, <, <=, >, >=). The translation goes via get_opname() so it is operand-type agnostic.
| [in] | op_oid | Comparison-operator OID. |
| [out] | ok | Set to true on a recognised comparator, false when op_oid does not resolve in pg_operator or its name is not one of the six standard ones. |
ComparisonOperator on success; an unspecified value (currently EQ) when ok is false. Definition at line 66 of file Aggregation.cpp.

| AggregationOperator getAggregationOperator | ( | Oid | oid | ) |
Map a PostgreSQL aggregate function OID to an AggregationOperator.
| oid | OID of the aggregate function (e.g. F_COUNT_ANY, F_SUM_INT4). |
AggregationOperator. Definition at line 29 of file Aggregation.cpp.

| std::unique_ptr< Aggregator > makeAggregator | ( | AggregationOperator | op, |
| ValueType | t ) |
Create a concrete Aggregator for the given operator and value type.
| op | The aggregation function to implement. |
| t | The type of input values that will be accumulated. |
Aggregator, or nullptr if the combination is not supported. Definition at line 316 of file Aggregation.cpp.
