![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
PostgreSQL I/O functions and cast for the agg_token composite type.
More...
#include "postgres.h"#include "fmgr.h"#include "catalog/pg_type.h"#include "utils/uuid.h"#include "utils/numeric.h"#include "utils/fmgrprotos.h"#include "executor/spi.h"#include "access/htup_details.h"#include "provsql_utils.h"#include "agg_token.h"
Go to the source code of this file.
Functions | |
| Datum | agg_token_in (PG_FUNCTION_ARGS) |
Parse an agg_token value from its text representation. | |
| Datum | agg_token_out (PG_FUNCTION_ARGS) |
Produce a display string for an agg_token. | |
| Datum | agg_token_cast (PG_FUNCTION_ARGS) |
Cast an agg_token to text, returning only the UUID part. | |
| Datum | agg_token_to_numeric (PG_FUNCTION_ARGS) |
Cast an agg_token to numeric, extracting only the value. | |
| Datum | agg_token_value (PG_FUNCTION_ARGS) |
Extract the running value of an agg_token as numeric. | |
| Datum | agg_token_to_float8 (PG_FUNCTION_ARGS) |
Cast an agg_token to double precision, extracting only the value. | |
| Datum | agg_token_to_int4 (PG_FUNCTION_ARGS) |
Cast an agg_token to integer, extracting only the value. | |
| Datum | agg_token_to_int8 (PG_FUNCTION_ARGS) |
Cast an agg_token to bigint, extracting only the value. | |
| Datum | agg_token_to_text (PG_FUNCTION_ARGS) |
Cast an agg_token to text, extracting only the value. | |
PostgreSQL I/O functions and cast for the agg_token composite type.
Implements the three SQL-callable C functions that back the agg_token type:
agg_token_in() – text → agg_token (input function)agg_token_out() – agg_token → text (output function)agg_token_cast() – agg_token → text (cast, extracts the UUID part)The on-wire text format is ( UUID , value ) where UUID is the 36-character hyphenated UUID of the provenance gate and value is the aggregate running value.
Definition in file agg_token.c.
| Datum agg_token_cast | ( | PG_FUNCTION_ARGS | ) |
Cast an agg_token to text, returning only the UUID part.
This is used when the caller needs the provenance circuit UUID stored in the token rather than the aggregate value.
Definition at line 109 of file agg_token.c.
| Datum agg_token_in | ( | PG_FUNCTION_ARGS | ) |
Parse an agg_token value from its text representation.
Expected format: "( UUID , value )" with a single space around the comma and at the outer parentheses. Raises ERROR on malformed input.
agg_token. Definition at line 36 of file agg_token.c.
| Datum agg_token_out | ( | PG_FUNCTION_ARGS | ) |
Produce a display string for an agg_token.
Default: returns "value (*)" (the running value followed by " (*)"), matching EXPLAIN and direct CAST to text.
When the provsql.aggtoken_text_as_uuid GUC is on, returns the underlying provenance UUID instead. This is the form ProvSQL Studio enables per session so agg_token cells in a result table expose the circuit root UUID for click-through; the user-facing "value (*)" string is recovered via the provsql.agg_token_value_text(uuid) helper.
Definition at line 87 of file agg_token.c.
| Datum agg_token_to_float8 | ( | PG_FUNCTION_ARGS | ) |
Cast an agg_token to double precision, extracting only the value.
Emits a WARNING that provenance information is lost during the conversion.
Definition at line 181 of file agg_token.c.
| Datum agg_token_to_int4 | ( | PG_FUNCTION_ARGS | ) |
Cast an agg_token to integer, extracting only the value.
Emits a WARNING that provenance information is lost during the conversion.
Definition at line 201 of file agg_token.c.
| Datum agg_token_to_int8 | ( | PG_FUNCTION_ARGS | ) |
Cast an agg_token to bigint, extracting only the value.
Emits a WARNING that provenance information is lost during the conversion.
Definition at line 221 of file agg_token.c.
| Datum agg_token_to_numeric | ( | PG_FUNCTION_ARGS | ) |
Cast an agg_token to numeric, extracting only the value.
Emits a WARNING that provenance information is lost during the conversion.
Definition at line 135 of file agg_token.c.
| Datum agg_token_to_text | ( | PG_FUNCTION_ARGS | ) |
Cast an agg_token to text, extracting only the value.
Unlike agg_token_cast which returns the UUID part, this returns the aggregate value as text. Emits a WARNING that provenance information is lost during the conversion.
Definition at line 243 of file agg_token.c.
| Datum agg_token_value | ( | PG_FUNCTION_ARGS | ) |
Extract the running value of an agg_token as numeric.
Unlike agg_token_to_numeric, this does not emit the "provenance information is lost" warning: it is the internal accessor used by the provenance-preserving agg_token arithmetic operators (which keep the provenance in a gate_arith circuit), where no provenance is dropped.
Definition at line 161 of file agg_token.c.