Remove all traces of tuplestore_donestoring() in the C code
authorMichael Paquier <[email protected]>
Thu, 17 Feb 2022 00:52:02 +0000 (09:52 +0900)
committerMichael Paquier <[email protected]>
Thu, 17 Feb 2022 00:52:02 +0000 (09:52 +0900)
This routine is a no-op since dd04e95 from 2003, with a macro kept
around for compatibility purposes.  This has led to the same code
patterns being copy-pasted around for no effect, sometimes in confusing
ways like in pg_logical_slot_get_changes_guts() from logical.c where the
code was actually incorrect.

This issue has been discussed on two different threads recently, so
rather than living with this legacy, remove any uses of this routine in
the C code to simplify things.  The compatibility macro is kept to avoid
breaking any out-of-core modules that depend on it.

Reported-by: Tatsuhito Kasahara, Justin Pryzby
Author: Tatsuhito Kasahara
Discussion: https://postgr.es/m/20211217200419[email protected]
Discussion: https://postgr.es/m/CAP0=ZVJeeYfAeRfmzqAF2Lumdiv4S4FewyBnZd4DPTrsSQKJKw@mail.gmail.com

24 files changed:
contrib/dblink/dblink.c
contrib/pageinspect/brinfuncs.c
contrib/pg_stat_statements/pg_stat_statements.c
contrib/postgres_fdw/connection.c
contrib/tablefunc/tablefunc.c
contrib/xml2/xpath.c
src/backend/access/transam/xlogfuncs.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/mcxtfuncs.c
src/backend/utils/adt/pgstatfuncs.c
src/backend/utils/adt/varlena.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/pg_config.c
src/backend/utils/mmgr/portalmem.c
src/include/utils/tuplestore.h

index 5a37508c4b301324b3b0e082a5f76e3a46a6b029..efc4c94301845183d8c9779c9bdfb30e0bee0143 100644 (file)
@@ -1005,8 +1005,6 @@ materializeResult(FunctionCallInfo fcinfo, PGconn *conn, PGresult *res)
            /* clean up GUC settings, if we changed any */
            restoreLocalGucs(nestlevel);
 
-           /* clean up and return the tuplestore */
-           tuplestore_donestoring(tupstore);
        }
    }
    PG_FINALLY();
@@ -1988,9 +1986,6 @@ dblink_get_notify(PG_FUNCTION_ARGS)
        PQconsumeInput(conn);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
index f1e64a39ef25b3740821242bd7d9c1f9ee3be6e1..50892b5cc20ad00eb3d0b9bf64de0081b08dc2fc 100644 (file)
@@ -325,9 +325,7 @@ brin_page_items(PG_FUNCTION_ARGS)
            break;
    }
 
-   /* clean up and return the tuplestore */
    brin_free_desc(bdesc);
-   tuplestore_donestoring(tupstore);
    index_close(indexRel, AccessShareLock);
 
    return (Datum) 0;
index 082bfa8f77feef8db9fbd0d552761f45e818b199..9d7d0812ac36b9cec44b72a64ae069b92c1878ef 100644 (file)
@@ -1803,13 +1803,11 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   /* clean up and return the tuplestore */
    LWLockRelease(pgss->lock);
 
    if (qbuffer)
        free(qbuffer);
 
-   tuplestore_donestoring(tupstore);
 }
 
 /* Number of output arguments (columns) for pg_stat_statements_info */
index 29fcb6a76eb3814b751883e08e319e0f9dab4249..f753c6e2324d8724be3d0ea7308c67748d3ce67d 100644 (file)
@@ -1508,12 +1508,7 @@ postgres_fdw_get_connections(PG_FUNCTION_ARGS)
 
    /* If cache doesn't exist, we return no records */
    if (!ConnectionHash)
-   {
-       /* clean up and return the tuplestore */
-       tuplestore_donestoring(tupstore);
-
        PG_RETURN_VOID();
-   }
 
    hash_seq_init(&scan, ConnectionHash);
    while ((entry = (ConnCacheEntry *) hash_seq_search(&scan)))
@@ -1578,8 +1573,6 @@ postgres_fdw_get_connections(PG_FUNCTION_ARGS)
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
 
    PG_RETURN_VOID();
 }
index afbbdfcf86a0f8f359468250878fabab1564694d..e308228bde5e1595174bb89deaa0740c74fbd150 100644 (file)
@@ -943,8 +943,6 @@ get_crosstab_tuplestore(char *sql,
        /* internal error */
        elog(ERROR, "get_crosstab_tuplestore: SPI_finish() failed");
 
-   tuplestore_donestoring(tupstore);
-
    return tupstore;
 }
 
index 7fdde8eb510b6ad810e2dd408d4412bc292b325d..a2e5fb54e2052ad5a16b93289967ea6898635788 100644 (file)
@@ -783,8 +783,6 @@ xpath_table(PG_FUNCTION_ARGS)
 
    pg_xml_done(xmlerrcxt, false);
 
-   tuplestore_donestoring(tupstore);
-
    SPI_finish();
 
    rsinfo->setResult = tupstore;
index 2f900533cdb3e67853c86cab19e3fa637a815daf..12e2bf4135d52af1bb9c85b225b0ca18649ac181 100644 (file)
@@ -252,7 +252,6 @@ pg_stop_backup_v2(PG_FUNCTION_ARGS)
    values[0] = LSNGetDatum(stoppoint);
 
    tuplestore_putvalues(tupstore, tupdesc, values, nulls);
-   tuplestore_donestoring(tupstore);
 
    return (Datum) 0;
 }
index 93c2099735a464890450d0f3e561c6948da05c88..1e8587502e5878feb7cc370644561503becd6666 100644 (file)
@@ -1401,9 +1401,6 @@ pg_event_trigger_dropped_objects(PG_FUNCTION_ARGS)
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
@@ -2061,9 +2058,6 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    PG_RETURN_VOID();
 }
 
index a2e77c418a429e34f1c5bdf0723b8867e18dad4f..0e04304cb091554128e9eb5d1daeab6ba7e62578 100644 (file)
@@ -2021,9 +2021,6 @@ pg_available_extensions(PG_FUNCTION_ARGS)
        FreeDir(dir);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
@@ -2112,9 +2109,6 @@ pg_available_extension_versions(PG_FUNCTION_ARGS)
        FreeDir(dir);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
@@ -2417,9 +2411,6 @@ pg_extension_update_paths(PG_FUNCTION_ARGS)
        }
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
index 206d2bbbf9f02ecec67611793a204c6af7d2b9bf..e0c985ef8b08b5ee4211e89f5830ff35bb29d2f6 100644 (file)
@@ -778,9 +778,6 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
        }
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    rsinfo->returnMode = SFRM_Materialize;
    rsinfo->setResult = tupstore;
    rsinfo->setDesc = tupdesc;
index 294e22c78c12cbd30604ce34fed0c7e5fc1582fb..d910bc2fbea86763456e2db992d74c8d79a2e7fb 100644 (file)
@@ -555,9 +555,6 @@ deflist_to_tuplestore(ReturnSetInfo *rsinfo, List *options)
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    MemoryContextSwitchTo(oldcontext);
 }
 
index 7b473903a684dc1c40dbc59afb2765c82bd5f980..5a68d6deadc8d8d999dcdeb296dda49de0571532 100644 (file)
@@ -1022,8 +1022,5 @@ pg_stat_get_subscription(PG_FUNCTION_ARGS)
 
    LWLockRelease(LogicalRepWorkerLock);
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
index c29e82307fd7ff7ad06be2ba42cc2307efd7ea59..3609fa7d5bf6cbf90d4e66e701b5336116be9a91 100644 (file)
@@ -296,8 +296,6 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
            CHECK_FOR_INTERRUPTS();
        }
 
-       tuplestore_donestoring(tupstore);
-
        /*
         * Logical decoding could have clobbered CurrentResourceOwner during
         * transaction management, so restore the executor's value.  (This is
index e91fa93d03abc39b23dc5f090a11525fe573bdd6..76055a8a036bb4f853cf26dc6c69710a8817c1be 100644 (file)
@@ -1568,8 +1568,6 @@ pg_show_replication_origin_status(PG_FUNCTION_ARGS)
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   tuplestore_donestoring(tupstore);
-
    LWLockRelease(ReplicationOriginLock);
 
 #undef REPLICATION_ORIGIN_PROGRESS_COLS
index 5149ebccb030b9f40281691a2030d37d7168ffa0..886899afd22a7151d238d6503fc9f7f5a6300c89 100644 (file)
@@ -436,8 +436,6 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
 
    LWLockRelease(ReplicationSlotControlLock);
 
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
index a1dadd4c6ad7dca7eadd385121a6b540309f50d2..5a718b1fe9b595019106595c95e2b04a1395e6be 100644 (file)
@@ -3580,9 +3580,6 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
index c682775db4405f75d0be782bc14c9f4515fdb604..1f023a34604249c8169702e278f175a7ef077790 100644 (file)
@@ -605,7 +605,5 @@ pg_get_shmem_allocations(PG_FUNCTION_ARGS)
 
    LWLockRelease(ShmemIndexLock);
 
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
index 28cb9d3ff10b5d4ec8645b75380ef6c853923dff..c7c95adf97d453c762c5a7b9f705f62d9b28c5c4 100644 (file)
@@ -152,9 +152,6 @@ pg_get_backend_memory_contexts(PG_FUNCTION_ARGS)
    PutMemoryContextsStatsTupleStore(tupstore, tupdesc,
                                     TopMemoryContext, NULL, 0);
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
index 15cb17ace4f108fcb2529226dfb5342247091268..30e8dfa7c12acc166fcbdf92bd25dd48823c3379 100644 (file)
@@ -555,9 +555,6 @@ pg_stat_get_progress_info(PG_FUNCTION_ARGS)
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
@@ -953,9 +950,6 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
            break;
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
@@ -1936,9 +1930,6 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
index b73cebfdb5d0cac9281c9af43486d96b7a482cc7..eda9c1e42c0476390c0075c00d8266882244619a 100644 (file)
@@ -4855,8 +4855,6 @@ text_to_table(PG_FUNCTION_ARGS)
 
    (void) split_text(fcinfo, &tstate);
 
-   tuplestore_donestoring(tstate.tupstore);
-
    rsi->returnMode = SFRM_Materialize;
    rsi->setResult = tstate.tupstore;
    rsi->setDesc = tstate.tupdesc;
index 568ac62c2ab68f89065df3a058480a5efe5ceb33..9d0208ec98a43647dc86658a774e3bdeae5da2a1 100644 (file)
@@ -10206,8 +10206,6 @@ show_all_file_settings(PG_FUNCTION_ARGS)
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   tuplestore_donestoring(tupstore);
-
    return (Datum) 0;
 }
 
index 7a13212f9916f108d31da57e5da0be0b9e7a8f06..d916d7b2c47f89bcf607ba99e6eb256fdae58353 100644 (file)
@@ -85,7 +85,6 @@ pg_config(PG_FUNCTION_ARGS)
     */
    ReleaseTupleDesc(tupdesc);
 
-   tuplestore_donestoring(tupstore);
    rsinfo->setResult = tupstore;
 
    /*
index 236f450a2be41e1c767b8603c240e4b29c3378fc..7885344164f8867a26dbcfa59ce18813f3efd998 100644 (file)
@@ -1204,9 +1204,6 @@ pg_cursor(PG_FUNCTION_ARGS)
        tuplestore_putvalues(tupstore, tupdesc, values, nulls);
    }
 
-   /* clean up and return the tuplestore */
-   tuplestore_donestoring(tupstore);
-
    rsinfo->returnMode = SFRM_Materialize;
    rsinfo->setResult = tupstore;
    rsinfo->setDesc = tupdesc;
index 399a8493cf534af4a03f6d8141c5d4ec8cc0b0f3..01716fb44eee8a681abbe8765db2b27bc3eb015d 100644 (file)
@@ -56,7 +56,7 @@ extern void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple);
 extern void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc,
                                 Datum *values, bool *isnull);
 
-/* tuplestore_donestoring() used to be required, but is no longer used */
+/* Backwards compatibility macro */
 #define tuplestore_donestoring(state)  ((void) 0)
 
 extern int tuplestore_alloc_read_pointer(Tuplestorestate *state, int eflags);