17#include "catalog/pg_type.h"
18#include "utils/uuid.h"
19#include "executor/spi.h"
20#include "access/htup_details.h"
36 char *str = PG_GETARG_CSTRING(0);
38 const unsigned toklen=
sizeof(result->
tok)-1;
47 if(strlen(str)<toklen+7 ||
48 str[0]!=
'(' || str[1]!=
' ' || str[2+toklen] !=
' ' || str[2+toklen+1] !=
','
49 || str[2+toklen+2] !=
' ' || str[strlen(str)-2] !=
' '
50 || str[strlen(str)-1] !=
')')
52 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
53 errmsg(
"invalid input syntax for agg_token: \"%s\"",
56 strncpy(result->
tok, str+2, toklen);
57 result->
tok[toklen]=
'\0';
59 vallen=strlen(str)-toklen-2-3-2;
60 if(vallen>=
sizeof(result->
val))
61 vallen=
sizeof(result->
val)-1;
62 strncpy(result->
val, str+2+toklen+3, vallen);
63 result->
val[vallen]=
'\0';
65 PG_RETURN_POINTER(result);
82 result = psprintf(
"%s (*)", aggtok->
val);
84 PG_RETURN_CSTRING(result);
103 result = psprintf(
"%s", aggtok->
tok);
104 len = strlen(result);
106 txt_result = (text *) palloc(len + ((int32)
sizeof(int32)));
108 SET_VARSIZE(txt_result, len + ((int32)
sizeof(int32)));
109 memcpy(VARDATA(txt_result), result, len);
111 PG_RETURN_TEXT_P(txt_result);
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.
Datum agg_token_in(PG_FUNCTION_ARGS)
Parse an agg_token value from its text representation.
Aggregate-provenance token type used in SQL aggregate functions.
Core types, constants, and utilities shared across ProvSQL.
Aggregate token bundling a provenance UUID with a running value.
char val[80]
Aggregate running value as a text string.
char tok[2 *UUID_LEN+5]
Provenance UUID as a text string.