Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Rename SetSingleFuncCall() to InitMaterializedSRF()
authorMichael Paquier <michael@paquier.xyz>
Tue, 18 Oct 2022 01:22:40 +0000 (10:22 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 18 Oct 2022 01:22:40 +0000 (10:22 +0900)
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

35 files changed:
contrib/amcheck/verify_heapam.c
contrib/dblink/dblink.c
contrib/pageinspect/brinfuncs.c
contrib/pageinspect/gistfuncs.c
contrib/pg_stat_statements/pg_stat_statements.c
contrib/pg_walinspect/pg_walinspect.c
contrib/pgrowlocks/pgrowlocks.c
contrib/postgres_fdw/connection.c
contrib/xml2/xpath.c
src/backend/access/transam/rmgr.c
src/backend/access/transam/xlogprefetcher.c
src/backend/commands/event_trigger.c
src/backend/commands/extension.c
src/backend/commands/prepare.c
src/backend/foreign/foreign.c
src/backend/replication/logical/launcher.c
src/backend/replication/logical/logicalfuncs.c
src/backend/replication/logical/origin.c
src/backend/replication/slotfuncs.c
src/backend/replication/walsender.c
src/backend/storage/ipc/shmem.c
src/backend/utils/adt/datetime.c
src/backend/utils/adt/genfile.c
src/backend/utils/adt/hbafuncs.c
src/backend/utils/adt/jsonfuncs.c
src/backend/utils/adt/mcxtfuncs.c
src/backend/utils/adt/misc.c
src/backend/utils/adt/pgstatfuncs.c
src/backend/utils/adt/varlena.c
src/backend/utils/fmgr/README
src/backend/utils/fmgr/funcapi.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/pg_config.c
src/backend/utils/mmgr/portalmem.c
src/include/funcapi.h

index e488f5e234b3ff274f19a7beb68e3cc54ec8181b..5919e82b16568196c90a93e7a1e4b324ccc760e3 100644 (file)
@@ -278,7 +278,7 @@ verify_heapam(PG_FUNCTION_ARGS)
    ctx.attnum = -1;
 
    /* Construct the tuplestore and tuple descriptor */
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
    ctx.tupdesc = rsinfo->setDesc;
    ctx.tupstore = rsinfo->setResult;
 
index a561d1d65244c2f8f21fc521ec884b4a02dae05f..0cc339e7d5278878dae877680e133b982116fcf5 100644 (file)
@@ -1934,7 +1934,7 @@ dblink_get_notify(PG_FUNCTION_ARGS)
    else
        conn = pconn->conn;
 
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    PQconsumeInput(conn);
    while ((notify = PQnotifies(conn)) != NULL)
index 879276e6dece94fab01987520735102f0e0afdb8..fbcfa18ac7b7a7706fd00c9bd32a913955d16b13 100644 (file)
@@ -147,7 +147,7 @@ brin_page_items(PG_FUNCTION_ARGS)
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 errmsg("must be superuser to use raw page functions")));
 
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    indexRel = index_open(indexRelid, AccessShareLock);
 
index 4943d6f75bd1905846e2c5d7f1884ae528b3da5e..42d448a8359f684757ad58b648a436fd9740ee76 100644 (file)
@@ -129,7 +129,7 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)
                (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);
 
@@ -213,7 +213,7 @@ gist_page_items(PG_FUNCTION_ARGS)
                (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);
index 14637013fa247058464e9f6ecc2c351eac84384a..2a8c202c14f60772f91e04ec982ed76d1d4d02cb 100644 (file)
@@ -1555,7 +1555,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
                (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
index 68451984300313922a8ad1b795afbfb9d0f9b7f1..6b6c7d46e27daf4a73edb4a8da0d786d36fa924c 100644 (file)
@@ -333,7 +333,7 @@ GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
    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);
 
@@ -554,7 +554,7 @@ GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr 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);
 
index 1d4d4965ac98032afb3a1b6b165a6f7c1e412186..c543277b7c550b772803f51721796be965884889 100644 (file)
@@ -75,7 +75,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
    AclResult   aclresult;
    char      **values;
 
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    /* Access the table */
    relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
index cffb6f83107288ed58bea0fd6dfaf71b9b1f1af8..5187ea8e009125a4dd963ed0a441925c04d68176 100644 (file)
@@ -1668,7 +1668,7 @@ postgres_fdw_get_connections(PG_FUNCTION_ARGS)
    HASH_SEQ_STATUS scan;
    ConnCacheEntry *entry;
 
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    /* If cache doesn't exist, we return no records */
    if (!ConnectionHash)
index b8ee757674d48a999dc45d6520d9bfeb55920bbf..a692dc6be86dfd6a56d34b8d28d1b8d5e34861b9 100644 (file)
@@ -511,7 +511,7 @@ xpath_table(PG_FUNCTION_ARGS)
    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)
index 3b6de3aa04e4d2d14dacba87bd9971d60f7ad394..6bb4de387f3512c01e05409815a8c380dc497696 100644 (file)
@@ -145,7 +145,7 @@ pg_get_wal_resource_managers(PG_FUNCTION_ARGS)
    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++)
    {
index 995c5e83bc881f5f05561e441f1f7d662f55c67a..b98b3192cf59005960ae35fd9011d2e85cef6afb 100644 (file)
@@ -833,7 +833,7 @@ pg_stat_get_recovery_prefetch(PG_FUNCTION_ARGS)
    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;
index 46425278811b8f5e919eacb498aac3ba13f477a6..356aac4afc02de41aaa76225fdebf5757e59cc19 100644 (file)
@@ -1305,7 +1305,7 @@ pg_event_trigger_dropped_objects(PG_FUNCTION_ARGS)
                        "pg_event_trigger_dropped_objects()")));
 
    /* Build tuplestore to hold the result rows */
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    slist_foreach(iter, &(currentEventTriggerState->SQLDropList))
    {
@@ -1835,7 +1835,7 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
                        "pg_event_trigger_ddl_commands()")));
 
    /* Build tuplestore to hold the result rows */
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    foreach(lc, currentEventTriggerState->commandList)
    {
index eb4878701a1e5bb5a491a8d7546381ed394c7264..3f750d34b363e8a6f7444a40cd7536607d6bf6a8 100644 (file)
@@ -1941,7 +1941,7 @@ pg_available_extensions(PG_FUNCTION_ARGS)
    struct dirent *de;
 
    /* Build tuplestore to hold the result rows */
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    location = get_extension_control_directory();
    dir = AllocateDir(location);
@@ -2021,7 +2021,7 @@ pg_available_extension_versions(PG_FUNCTION_ARGS)
    struct dirent *de;
 
    /* Build tuplestore to hold the result rows */
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    location = get_extension_control_directory();
    dir = AllocateDir(location);
@@ -2278,7 +2278,7 @@ pg_extension_update_paths(PG_FUNCTION_ARGS)
    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));
index 80738547ed80a8cdd259c785ae49cfc49db93104..fc5c7f9d4d2bf5b89c12e3726fd1d8ff4fb34435 100644 (file)
@@ -672,7 +672,7 @@ pg_prepared_statement(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 table might be uninitialized */
    if (prepared_queries)
index cf222fc3e998fcf5293bf72f64771f7e6d97f945..e60394c7f90901c94caa11b281be8db7feaabbdd 100644 (file)
@@ -516,7 +516,7 @@ pg_options_to_table(PG_FUNCTION_ARGS)
    rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
 
    /* prepare the result set */
-   SetSingleFuncCall(fcinfo, SRF_SINGLE_USE_EXPECTED);
+   InitMaterializedSRF(fcinfo, MAT_SRF_USE_EXPECTED_DESC);
 
    foreach(cell, options)
    {
index 2bdab53e19b032a3fdfae76e77f7ae115978894e..e88e30d467c3b2d82db9741ea56c1bc339335b33 100644 (file)
@@ -930,7 +930,7 @@ pg_stat_get_subscription(PG_FUNCTION_ARGS)
    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);
index 6058d36e0d5ed5a9e8457f6f09535cb11be008d7..dc29b6c67404b9448e1659baa9e93610e2e609a5 100644 (file)
@@ -189,7 +189,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
        }
    }
 
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
    p->tupstore = rsinfo->setResult;
    p->tupdesc = rsinfo->setDesc;
 
index 9b0774ee3e617021aab6cab264f533677c40a03d..cd8600760167a72993b957f4954f08277c7f6b09 100644 (file)
@@ -1487,7 +1487,7 @@ pg_show_replication_origin_status(PG_FUNCTION_ARGS)
    /* 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);
index ca945994ef018f5a32511b3479703613fc768bde..16a35279037657bada54d27d4a3ab2e38d1b2de7 100644 (file)
@@ -242,7 +242,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
     * name, which shouldn't contain anything particularly sensitive.
     */
 
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    currlsn = GetXLogWriteRecPtr();
 
index 66f44d25dcb3fa9b9d6982b212ddadcc5363026f..269914bce2892ad61d9ce8cff2c39ca9e1aa8606 100644 (file)
@@ -3476,7 +3476,7 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
    int         num_standbys;
    int         i;
 
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    /*
     * Get the currently active synchronous standbys.  This could be out of
index c1279960cd0bc0cd20c70623718aa7a5553e07a4..10be765fb7b173947f5875cdf1d7b6e84b6b63de 100644 (file)
@@ -543,7 +543,7 @@ pg_get_shmem_allocations(PG_FUNCTION_ARGS)
    Datum       values[PG_GET_SHMEM_SIZES_COLS];
    bool        nulls[PG_GET_SHMEM_SIZES_COLS];
 
-   SetSingleFuncCall(fcinfo, 0);
+   InitMaterializedSRF(fcinfo, 0);
 
    LWLockAcquire(ShmemIndexLock, LW_SHARED);
 
index 4c12c4d66302d21a1a143ef28822402792f47612..a3cfd54409b77805812716ab8e125009da7bd7a7 100644 (file)
@@ -5059,7 +5059,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();
index 2bf52192567a37625fd613070d540e38c3750a69..5d2679dd40b9e3e945a7d66b13842233d40cffbe 100644 (file)
@@ -491,7 +491,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)
@@ -549,7 +549,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
index 57c4c4e8462d8f45a4e34a65e180ba46d0ae03b7..c33659978688364dce4b506b0fcfb185da4da70d 100644 (file)
@@ -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;
index ccc327957581cfdfa7f9c1adc31cc614ad344d1f..6c5886eb056f5be994543b79b3dfdc5e81951f06 100644 (file)
@@ -1923,7 +1923,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",
@@ -2003,7 +2003,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;
 
@@ -2166,8 +2166,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",
@@ -2245,7 +2244,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;
index bb7cc940249b90a362928ea2da85cad5eff0c2aa..04b7aa2a77bcea9fdebd43aecd202db72d1dc7d5 100644 (file)
@@ -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);
 
index 89690be2ed1fef9f3817a2d50755e51e4cbbcdfd..6d8fa920cdb25b9afa5d2ce38b65b1b64458aae0 100644 (file)
@@ -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)
    {
index 893690dad52049db1fde02ddeaf634793bcc8981..83d2cdb57c80453320f33205b3b872b37030fe99 100644 (file)
@@ -481,7 +481,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++)
@@ -545,7 +545,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++)
@@ -1818,7 +1818,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();
index 8539cef024616e6a23a941073b85d30a7cbdbec3..3732b79c21e303d0298d4e98f58faa6277268344 100644 (file)
@@ -4809,7 +4809,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;
 
index 9d8848106dfe0613d1c90941c7fec4d7709e8288..4b2a5df285253aa83f322dcb5901e0c438b1969a 100644 (file)
@@ -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.
 
index e82a6d50654a84fbb13ab6d0d8e0b2fdd6160301..31f6662768ea9699c08c6be3593cce159124855e 100644 (file)
@@ -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;
index 328aab07714159fd7a121c594127f954c57df358..75ac077a9d112082f69f667f97ab25b79be70162 100644 (file)
@@ -10476,7 +10476,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++)
index d9e18caf448c9a0943f64a86f21c2c07e846d12c..581965395dbed0f93e878fc652e1ec77e5ff5d3a 100644 (file)
@@ -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++)
index d549f66d4afd1466d1b5114723846480d5c62dfd..7409593c968d472e2cdd58c4f680c139c8162265 100644 (file)
@@ -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)
index dc3d819a1c7eca066511205ed94f4aa845010b42..8c47054ed527c2e48c15d322d49470843c19ecf1 100644 (file)
@@ -278,7 +278,7 @@ extern Datum HeapTupleHeaderGetDatum(HeapTupleHeader tuple);
  * 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().
  *
@@ -287,9 +287,15 @@ extern Datum HeapTupleHeaderGetDatum(HeapTupleHeader tuple);
 
 /* 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);