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

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 "executor/spi.h"
#include "access/htup_details.h"
#include "provsql_utils.h"
#include "agg_token.h"
Include dependency graph for agg_token.c:

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 human-readable display string for an agg_token.
 
Datum agg_token_cast (PG_FUNCTION_ARGS)
 Cast an agg_token to text, returning only the UUID part.
 

Detailed Description

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:

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.

Function Documentation

◆ agg_token_cast()

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.

Returns
Text datum containing the UUID string of the token.

Definition at line 96 of file agg_token.c.

◆ agg_token_in()

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.

Returns
Pointer to the newly allocated agg_token.

Definition at line 34 of file agg_token.c.

◆ agg_token_out()

Datum agg_token_out ( PG_FUNCTION_ARGS  )

Produce a human-readable display string for an agg_token.

Returns "value (*)", i.e. the running value followed by " (*)". This is the output used by EXPLAIN and direct CAST to text.

Returns
C-string representation of the agg_token value.

Definition at line 77 of file agg_token.c.