Skip to content

Instantly share code, notes, and snippets.

@anarazel anarazel/i-am-a-monster.h
Last active Oct 5, 2018

Embed
What would you like to do?
typedef struct NullableDatum
{
Datum datum;
bool isnull;
/* FIXME: space for flags? */
} NullableDatum;
typedef struct FunctionCallInfoDataVar
{
FmgrInfo *flinfo; /* ptr to lookup info used for this call */
fmNodePtr context; /* pass info about context of call */
fmNodePtr resultinfo; /* pass or return extra info about result */
Oid fncollation; /* collation for function to use */
bool isnull; /* function must set true if result is NULL */
short nargs; /* # arguments actually passed */
NullableDatum args[FLEXIBLE_ARRAY_MEMBER];
} FunctionCallInfoDataVar;
#define SizeForFunctionCallInfoData(nargs) (offsetof(FunctionCallInfoDataVar, args) + sizeof(NullableDatum) * (nargs))
#define DirectFunctionCallVarColl(func, collation, ...) \
DirectFunctionCallVarExec(func, collation, VA_ARGS_NARGS(__VA_ARGS__), \
(&(\
union { \
struct FunctionCallInfoDataVar fcinfo; \
char *fcinfo_data[SizeForFunctionCallInfoData(VA_ARGS_NARGS(__VA_ARGS__))]; \
} \
){.fcinfo = {\
.flinfo = NULL, \
.context = NULL, \
.resultinfo = NULL, \
.nargs = VA_ARGS_NARGS(__VA_ARGS__)}\
}.fcinfo ), \
(Datum[]){__VA_ARGS__})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.