aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-10-18 10:22:35 +0900
committerMichael Paquier <michael@paquier.xyz>2022-10-18 10:22:35 +0900
commita19e5cee635dc94c9c6e44c8863b4b770920a04b (patch)
tree68204df4e9f1175b5c03ad2fd7bc77772b25fba7 /src/backend/utils
parent77dd153d39663461b32f3d5efce397af678ba083 (diff)
downloadpostgresql-a19e5cee635dc94c9c6e44c8863b4b770920a04b.tar.gz
postgresql-a19e5cee635dc94c9c6e44c8863b4b770920a04b.zip
Rename SetSingleFuncCall() to InitMaterializedSRF()
Per discussion, the existing routine name able to initialize a SRF function with materialize mode is unpopular, so rename it. Equally, the flags of this function are renamed, as of: - SRF_SINGLE_USE_EXPECTED -> MAT_SRF_USE_EXPECTED_DESC - SRF_SINGLE_BLESS -> MAT_SRF_BLESS The previous function and flags introduced in 9e98583 are kept around for compatibility purposes, so as any extension code already compiled with v15 continues to work as-is. The declarations introduced here for compatibility will be removed from HEAD in a follow-up commit. The new names have been suggested by Andres Freund and Melanie Plageman. Discussion: https://postgr.es/m/20221013194820.ciktb2sbbpw7cljm@awork3.anarazel.de Backpatch-through: 15
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/datetime.c2
-rw-r--r--src/backend/utils/adt/genfile.c4
-rw-r--r--src/backend/utils/adt/hbafuncs.c4
-rw-r--r--src/backend/utils/adt/jsonfuncs.c9
-rw-r--r--src/backend/utils/adt/mcxtfuncs.c2
-rw-r--r--src/backend/utils/adt/misc.c2
-rw-r--r--src/backend/utils/adt/pgstatfuncs.c6
-rw-r--r--src/backend/utils/adt/varlena.c2
-rw-r--r--src/backend/utils/fmgr/README2
-rw-r--r--src/backend/utils/fmgr/funcapi.c23
-rw-r--r--src/backend/utils/misc/guc_funcs.c2
-rw-r--r--src/backend/utils/misc/pg_config.c2
-rw-r--r--src/backend/utils/mmgr/portalmem.c2
13 files changed, 35 insertions, 27 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 74b68070984..8cd10ab204a 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -5058,7 +5058,7 @@ pg_timezone_names(PG_FUNCTION_ARGS)
Interval *resInterval;
struct pg_itm_in itm_in;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* initialize timezone scanning code */
tzenum = pg_tzenumerate_start();
diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c
index 2f1e907a10d..ab6f67f8747 100644
--- a/src/backend/utils/adt/genfile.c
+++ b/src/backend/utils/adt/genfile.c
@@ -561,7 +561,7 @@ pg_ls_dir(PG_FUNCTION_ARGS)
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)
@@ -619,7 +619,7 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, const char *dir, bool missing_ok)
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
diff --git a/src/backend/utils/adt/hbafuncs.c b/src/backend/utils/adt/hbafuncs.c
index 9e5794071cd..cbbe44ff133 100644
--- a/src/backend/utils/adt/hbafuncs.c
+++ b/src/backend/utils/adt/hbafuncs.c
@@ -421,7 +421,7 @@ pg_hba_file_rules(PG_FUNCTION_ARGS)
* 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;
@@ -554,7 +554,7 @@ pg_ident_file_mappings(PG_FUNCTION_ARGS)
* 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;
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index fd0d355789c..bfc3f02a863 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -1921,7 +1921,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
funcname)));
rsi = (ReturnSetInfo *) fcinfo->resultinfo;
- SetSingleFuncCall(fcinfo, SRF_SINGLE_BLESS);
+ InitMaterializedSRF(fcinfo, MAT_SRF_BLESS);
tmp_cxt = AllocSetContextCreate(CurrentMemoryContext,
"jsonb_each temporary cxt",
@@ -2001,7 +2001,7 @@ each_worker(FunctionCallInfo fcinfo, bool as_text)
rsi = (ReturnSetInfo *) fcinfo->resultinfo;
- SetSingleFuncCall(fcinfo, SRF_SINGLE_BLESS);
+ InitMaterializedSRF(fcinfo, MAT_SRF_BLESS);
state->tuple_store = rsi->setResult;
state->ret_tdesc = rsi->setDesc;
@@ -2164,8 +2164,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
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",
@@ -2243,7 +2242,7 @@ elements_worker(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
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;
diff --git a/src/backend/utils/adt/mcxtfuncs.c b/src/backend/utils/adt/mcxtfuncs.c
index bb7cc940249..04b7aa2a77b 100644
--- a/src/backend/utils/adt/mcxtfuncs.c
+++ b/src/backend/utils/adt/mcxtfuncs.c
@@ -121,7 +121,7 @@ pg_get_backend_memory_contexts(PG_FUNCTION_ARGS)
{
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
PutMemoryContextsStatsTupleStore(rsinfo->setResult, rsinfo->setDesc,
TopMemoryContext, NULL, 0);
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 6c45fd2007a..9c132512315 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -208,7 +208,7 @@ pg_tablespace_databases(PG_FUNCTION_ARGS)
DIR *dirdesc;
struct dirent *de;
- SetSingleFuncCall(fcinfo, SRF_SINGLE_USE_EXPECTED);
+ InitMaterializedSRF(fcinfo, MAT_SRF_USE_EXPECTED_DESC);
if (tablespaceOid == GLOBALTABLESPACE_OID)
{
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 85ac3e3f04f..96bffc0f2ac 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -502,7 +502,7 @@ pg_stat_get_progress_info(PG_FUNCTION_ARGS)
(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++)
@@ -559,7 +559,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
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++)
@@ -1800,7 +1800,7 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
int i;
PgStat_SLRUStats *stats;
- SetSingleFuncCall(fcinfo, 0);
+ InitMaterializedSRF(fcinfo, 0);
/* request SLRU stats from the cumulative stats system */
stats = pgstat_fetch_slru();
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 1f6e0908216..c5e7ee7ca2d 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -4810,7 +4810,7 @@ text_to_table(PG_FUNCTION_ARGS)
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;
diff --git a/src/backend/utils/fmgr/README b/src/backend/utils/fmgr/README
index 9d8848106df..4b2a5df2852 100644
--- a/src/backend/utils/fmgr/README
+++ b/src/backend/utils/fmgr/README
@@ -305,7 +305,7 @@ If available, the expected tuple descriptor is passed in ReturnSetInfo;
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.
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
index 78eb60c3e85..7ac6f36abe8 100644
--- a/src/backend/utils/fmgr/funcapi.c
+++ b/src/backend/utils/fmgr/funcapi.c
@@ -57,7 +57,16 @@ static TypeFuncClass get_type_func_class(Oid typid, Oid *base_typeid);
/*
- * 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
@@ -65,15 +74,15 @@ static TypeFuncClass get_type_func_class(Oid typid, Oid *base_typeid);
* 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;
@@ -88,7 +97,7 @@ SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags)
(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")));
@@ -101,7 +110,7 @@ SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags)
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
{
@@ -110,7 +119,7 @@ SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags)
}
/* 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;
diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c
index fb763df5fe8..108b3bd1290 100644
--- a/src/backend/utils/misc/guc_funcs.c
+++ b/src/backend/utils/misc/guc_funcs.c
@@ -996,7 +996,7 @@ show_all_file_settings(PG_FUNCTION_ARGS)
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++)
diff --git a/src/backend/utils/misc/pg_config.c b/src/backend/utils/misc/pg_config.c
index d9e18caf448..581965395db 100644
--- a/src/backend/utils/misc/pg_config.c
+++ b/src/backend/utils/misc/pg_config.c
@@ -30,7 +30,7 @@ pg_config(PG_FUNCTION_ARGS)
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++)
diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c
index 3a161bdb88d..c3e95346b60 100644
--- a/src/backend/utils/mmgr/portalmem.c
+++ b/src/backend/utils/mmgr/portalmem.c
@@ -1139,7 +1139,7 @@ pg_cursor(PG_FUNCTION_ARGS)
* 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)