summaryrefslogtreecommitdiff
path: root/src/backend/utils/fmgr/funcapi.c
diff options
context:
space:
mode:
authorMichael Paquier2022-10-18 01:22:35 +0000
committerMichael Paquier2022-10-18 01:22:35 +0000
commita19e5cee635dc94c9c6e44c8863b4b770920a04b (patch)
tree68204df4e9f1175b5c03ad2fd7bc77772b25fba7 /src/backend/utils/fmgr/funcapi.c
parent77dd153d39663461b32f3d5efce397af678ba083 (diff)
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/[email protected] Backpatch-through: 15
Diffstat (limited to 'src/backend/utils/fmgr/funcapi.c')
-rw-r--r--src/backend/utils/fmgr/funcapi.c23
1 files changed, 16 insertions, 7 deletions
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;