ctx.attnum = -1;
/* Construct the tuplestore and tuple descriptor */
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
ctx.tupdesc = rsinfo->setDesc;
ctx.tupstore = rsinfo->setResult;
else
conn = pconn->conn;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
PQconsumeInput(conn);
while ((notify = PQnotifies(conn)) != NULL)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to use raw page functions")));
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
indexRel = index_open(indexRelid, AccessShareLock);
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to use raw page functions")));
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
page = get_page_from_raw(raw_page);
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to use raw page functions")));
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* Open the relation */
indexRel = index_open(indexRelid, AccessShareLock);
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("pg_stat_statements must be loaded via shared_preload_libraries")));
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/*
* Check we have the expected number of output arguments. Aside from
Datum values[PG_GET_WAL_RECORDS_INFO_COLS];
bool nulls[PG_GET_WAL_RECORDS_INFO_COLS];
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
xlogreader = InitXLogReaderState(start_lsn);
Datum values[PG_GET_WAL_STATS_COLS];
bool nulls[PG_GET_WAL_STATS_COLS];
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
xlogreader = InitXLogReaderState(start_lsn);
AclResult aclresult;
char **values;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* Access the table */
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
HASH_SEQ_STATUS scan;
ConnCacheEntry *entry;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* If cache doesn't exist, we return no records */
if (!ConnectionHash)
PgXmlErrorContext *xmlerrcxt;
volatile xmlDocPtr doctree = NULL;
- SetSingleFuncCall(fcinfo, SRF_SINGLE_USE_EXPECTED);
+ InitMaterializedSRF(fcinfo, MAT_SRF_USE_EXPECTED_DESC);
/* must have at least one output column (for the pkey) */
if (rsinfo->setDesc->natts < 1)
Datum values[PG_GET_RESOURCE_MANAGERS_COLS];
bool nulls[PG_GET_RESOURCE_MANAGERS_COLS] = {0};
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
for (int rmid = 0; rmid <= RM_MAX_ID; rmid++)
{
Datum values[PG_STAT_GET_RECOVERY_PREFETCH_COLS];
bool nulls[PG_STAT_GET_RECOVERY_PREFETCH_COLS];
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
for (int i = 0; i < PG_STAT_GET_RECOVERY_PREFETCH_COLS; ++i)
nulls[i] = false;
"pg_event_trigger_dropped_objects()")));
/* Build tuplestore to hold the result rows */
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
slist_foreach(iter, &(currentEventTriggerState->SQLDropList))
{
"pg_event_trigger_ddl_commands()")));
/* Build tuplestore to hold the result rows */
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
foreach(lc, currentEventTriggerState->commandList)
{
struct dirent *de;
/* Build tuplestore to hold the result rows */
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
location = get_extension_control_directory();
dir = AllocateDir(location);
struct dirent *de;
/* Build tuplestore to hold the result rows */
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
location = get_extension_control_directory();
dir = AllocateDir(location);
check_valid_extension_name(NameStr(*extname));
/* Build tuplestore to hold the result rows */
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* Read the extension's control file */
control = read_extension_control_file(NameStr(*extname));
* We put all the tuples into a tuplestore in one scan of the hashtable.
* This avoids any issue of the hashtable possibly changing between calls.
*/
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* hash table might be uninitialized */
if (prepared_queries)
rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
/* prepare the result set */
- SetSingleFuncCall(fcinfo, SRF_SINGLE_USE_EXPECTED);
+ InitMaterializedSRF(fcinfo, MAT_SRF_USE_EXPECTED_DESC);
foreach(cell, options)
{
int i;
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* Make sure we get consistent view of the workers. */
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
}
}
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
p->tupstore = rsinfo->setResult;
p->tupdesc = rsinfo->setDesc;
/* we want to return 0 rows if slot is set to zero */
replorigin_check_prerequisites(false, true);
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* prevent slots from being concurrently dropped */
LWLockAcquire(ReplicationOriginLock, LW_SHARED);
* name, which shouldn't contain anything particularly sensitive.
*/
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
currlsn = GetXLogWriteRecPtr();
int num_standbys;
int i;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/*
* Get the currently active synchronous standbys. This could be out of
Datum values[PG_GET_SHMEM_SIZES_COLS];
bool nulls[PG_GET_SHMEM_SIZES_COLS];
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
LWLockAcquire(ShmemIndexLock, LW_SHARED);
Interval *resInterval;
struct pg_itm_in itm_in;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* initialize timezone scanning code */
tzenum = pg_tzenumerate_start();
include_dot_dirs = PG_GETARG_BOOL(2);
}
- SetSingleFuncCall(fcinfo, SRF_SINGLE_USE_EXPECTED);
+ InitMaterializedSRF(fcinfo, MAT_SRF_USE_EXPECTED_DESC);
dirdesc = AllocateDir(location);
if (!dirdesc)
DIR *dirdesc;
struct dirent *de;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/*
* Now walk the directory. Note that we must do this within a single SRF
* also more efficient than having to look up our current position in the
* parsed list every time.
*/
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* Fill the tuplestore */
rsi = (ReturnSetInfo *) fcinfo->resultinfo;
* also more efficient than having to look up our current position in the
* parsed list every time.
*/
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* Fill the tuplestore */
rsi = (ReturnSetInfo *) fcinfo->resultinfo;
funcname)));
rsi = (ReturnSetInfo *) fcinfo->resultinfo;
- SetSingleFuncCall(fcinfo, SRF_SINGLE_BLESS);
+ InitMaterializedSRF(fcinfo, MAT_SRF_BLESS);
tmp_cxt = AllocSetContextCreate(CurrentMemoryContext,
"jsonb_each temporary cxt",
rsi = (ReturnSetInfo *) fcinfo->resultinfo;
- SetSingleFuncCall(fcinfo, SRF_SINGLE_BLESS);
+ InitMaterializedSRF(fcinfo, MAT_SRF_BLESS);
state->tuple_store = rsi->setResult;
state->ret_tdesc = rsi->setDesc;
rsi = (ReturnSetInfo *) fcinfo->resultinfo;
- SetSingleFuncCall(fcinfo,
- SRF_SINGLE_USE_EXPECTED | SRF_SINGLE_BLESS);
+ InitMaterializedSRF(fcinfo, MAT_SRF_USE_EXPECTED_DESC | MAT_SRF_BLESS);
tmp_cxt = AllocSetContextCreate(CurrentMemoryContext,
"jsonb_array_elements temporary cxt",
state = palloc0(sizeof(ElementsState));
sem = palloc0(sizeof(JsonSemAction));
- SetSingleFuncCall(fcinfo, SRF_SINGLE_USE_EXPECTED | SRF_SINGLE_BLESS);
+ InitMaterializedSRF(fcinfo, MAT_SRF_USE_EXPECTED_DESC | MAT_SRF_BLESS);
rsi = (ReturnSetInfo *) fcinfo->resultinfo;
state->tuple_store = rsi->setResult;
state->ret_tdesc = rsi->setDesc;
{
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
PutMemoryContextsStatsTupleStore(rsinfo->setResult, rsinfo->setDesc,
TopMemoryContext, NULL, 0);
DIR *dirdesc;
struct dirent *de;
- SetSingleFuncCall(fcinfo, SRF_SINGLE_USE_EXPECTED);
+ InitMaterializedSRF(fcinfo, MAT_SRF_USE_EXPECTED_DESC);
if (tablespaceOid == GLOBALTABLESPACE_OID)
{
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid command name: \"%s\"", cmd)));
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* 1-based index */
for (curr_backend = 1; curr_backend <= num_backends; curr_backend++)
int pid = PG_ARGISNULL(0) ? -1 : PG_GETARG_INT32(0);
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* 1-based index */
for (curr_backend = 1; curr_backend <= num_backends; curr_backend++)
int i;
PgStat_SLRUStats *stats;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* request SLRU stats from the cumulative stats system */
stats = pgstat_fetch_slru();
SplitTextOutputData tstate;
tstate.astate = NULL;
- SetSingleFuncCall(fcinfo, SRF_SINGLE_USE_EXPECTED);
+ InitMaterializedSRF(fcinfo, MAT_SRF_USE_EXPECTED_DESC);
tstate.tupstore = rsi->setResult;
tstate.tupdesc = rsi->setDesc;
in other contexts the expectedDesc field will be NULL. The function need
not pay attention to expectedDesc, but it may be useful in special cases.
-SetSingleFuncCall() is a helper function able to setup the function's
+InitMaterializedSRF() is a helper function able to setup the function's
ReturnSetInfo for a single call, filling in the Tuplestore and the
TupleDesc with the proper configuration for Materialize mode.
/*
- * SetSingleFuncCall
+ * Compatibility function for v15.
+ */
+void
+SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags)
+{
+ InitMaterializedSRF(fcinfo, flags);
+}
+
+/*
+ * InitMaterializedSRF
*
* Helper function to build the state of a set-returning function used
* in the context of a single call with materialize mode. This code
* the TupleDesc used with the function and stores them into the
* function's ReturnSetInfo.
*
- * "flags" can be set to SRF_SINGLE_USE_EXPECTED, to use the tuple
+ * "flags" can be set to MAT_SRF_USE_EXPECTED_DESC, to use the tuple
* descriptor coming from expectedDesc, which is the tuple descriptor
- * expected by the caller. SRF_SINGLE_BLESS can be set to complete the
+ * expected by the caller. MAT_SRF_BLESS can be set to complete the
* information associated to the tuple descriptor, which is necessary
* in some cases where the tuple descriptor comes from a transient
* RECORD datatype.
*/
void
-SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags)
+InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
{
bool random_access;
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("set-valued function called in context that cannot accept a set")));
if (!(rsinfo->allowedModes & SFRM_Materialize) ||
- ((flags & SRF_SINGLE_USE_EXPECTED) != 0 && rsinfo->expectedDesc == NULL))
+ ((flags & MAT_SRF_USE_EXPECTED_DESC) != 0 && rsinfo->expectedDesc == NULL))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("materialize mode required, but it is not allowed in this context")));
old_context = MemoryContextSwitchTo(per_query_ctx);
/* build a tuple descriptor for our result type */
- if ((flags & SRF_SINGLE_USE_EXPECTED) != 0)
+ if ((flags & MAT_SRF_USE_EXPECTED_DESC) != 0)
stored_tupdesc = CreateTupleDescCopy(rsinfo->expectedDesc);
else
{
}
/* If requested, bless the tuple descriptor */
- if ((flags & SRF_SINGLE_BLESS) != 0)
+ if ((flags & MAT_SRF_BLESS) != 0)
BlessTupleDesc(stored_tupdesc);
random_access = (rsinfo->allowedModes & SFRM_Materialize_Random) != 0;
conf = ProcessConfigFileInternal(PGC_SIGHUP, false, DEBUG3);
/* Build a tuplestore to return our results in */
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* Process the results and create a tuplestore */
for (seqno = 1; conf != NULL; conf = conf->next, seqno++)
int i = 0;
/* initialize our tuplestore */
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
configdata = get_configdata(my_exec_path, &configdata_len);
for (i = 0; i < configdata_len; i++)
* We put all the tuples into a tuplestore in one scan of the hashtable.
* This avoids any issue of the hashtable possibly changing between calls.
*/
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
hash_seq_init(&hash_seq, PortalHashTable);
while ((hentry = hash_seq_search(&hash_seq)) != NULL)
* memory allocated in multi_call_memory_ctx, but holding file descriptors or
* other non-memory resources open across calls is a bug. SRFs that need
* such resources should not use these macros, but instead populate a
- * tuplestore during a single call, as set up by SetSingleFuncCall() (see
+ * tuplestore during a single call, as set up by InitMaterializedSRF() (see
* fmgr/README). Alternatively, set up a callback to release resources
* at query shutdown, using RegisterExprContextCallback().
*
/* from funcapi.c */
-/* flag bits for SetSingleFuncCall() */
-#define SRF_SINGLE_USE_EXPECTED 0x01 /* use expectedDesc as tupdesc */
-#define SRF_SINGLE_BLESS 0x02 /* validate tuple for SRF */
+/* flag bits for InitMaterializedSRF() */
+#define MAT_SRF_USE_EXPECTED_DESC 0x01 /* use expectedDesc as tupdesc. */
+#define MAT_SRF_BLESS 0x02 /* "Bless" a tuple descriptor with
+ * BlessTupleDesc(). */
+extern void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags);
+
+/* Compatibility declarations, for v15 */
+#define SRF_SINGLE_USE_EXPECTED MAT_SRF_USE_EXPECTED_DESC
+#define SRF_SINGLE_BLESS MAT_SRF_BLESS
extern void SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags);
extern FuncCallContext *init_MultiFuncCall(PG_FUNCTION_ARGS);