From: Michael Paquier Date: Thu, 17 Feb 2022 00:52:02 +0000 (+0900) Subject: Remove all traces of tuplestore_donestoring() in the C code X-Git-Tag: REL_15_BETA1~680 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=d61a361d1aef1231db61162d99b635b89c73169d;p=postgresql.git Remove all traces of tuplestore_donestoring() in the C code 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.GQ17618@telsasoft.com Discussion: https://postgr.es/m/CAP0=ZVJeeYfAeRfmzqAF2Lumdiv4S4FewyBnZd4DPTrsSQKJKw@mail.gmail.com --- diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 5a37508c4b3..efc4c943018 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -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; } diff --git a/contrib/pageinspect/brinfuncs.c b/contrib/pageinspect/brinfuncs.c index f1e64a39ef2..50892b5cc20 100644 --- a/contrib/pageinspect/brinfuncs.c +++ b/contrib/pageinspect/brinfuncs.c @@ -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; diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index 082bfa8f77f..9d7d0812ac3 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -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 */ diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c index 29fcb6a76eb..f753c6e2324 100644 --- a/contrib/postgres_fdw/connection.c +++ b/contrib/postgres_fdw/connection.c @@ -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(); } diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index afbbdfcf86a..e308228bde5 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -943,8 +943,6 @@ get_crosstab_tuplestore(char *sql, /* internal error */ elog(ERROR, "get_crosstab_tuplestore: SPI_finish() failed"); - tuplestore_donestoring(tupstore); - return tupstore; } diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c index 7fdde8eb510..a2e5fb54e20 100644 --- a/contrib/xml2/xpath.c +++ b/contrib/xml2/xpath.c @@ -783,8 +783,6 @@ xpath_table(PG_FUNCTION_ARGS) pg_xml_done(xmlerrcxt, false); - tuplestore_donestoring(tupstore); - SPI_finish(); rsinfo->setResult = tupstore; diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c index 2f900533cdb..12e2bf4135d 100644 --- a/src/backend/access/transam/xlogfuncs.c +++ b/src/backend/access/transam/xlogfuncs.c @@ -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; } diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index 93c2099735a..1e8587502e5 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -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(); } diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c index a2e77c418a4..0e04304cb09 100644 --- a/src/backend/commands/extension.c +++ b/src/backend/commands/extension.c @@ -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; } diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 206d2bbbf9f..e0c985ef8b0 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -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; diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c index 294e22c78c1..d910bc2fbea 100644 --- a/src/backend/foreign/foreign.c +++ b/src/backend/foreign/foreign.c @@ -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); } diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 7b473903a68..5a68d6deadc 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -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; } diff --git a/src/backend/replication/logical/logicalfuncs.c b/src/backend/replication/logical/logicalfuncs.c index c29e82307fd..3609fa7d5bf 100644 --- a/src/backend/replication/logical/logicalfuncs.c +++ b/src/backend/replication/logical/logicalfuncs.c @@ -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 diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c index e91fa93d03a..76055a8a036 100644 --- a/src/backend/replication/logical/origin.c +++ b/src/backend/replication/logical/origin.c @@ -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 diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c index 5149ebccb03..886899afd22 100644 --- a/src/backend/replication/slotfuncs.c +++ b/src/backend/replication/slotfuncs.c @@ -436,8 +436,6 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) LWLockRelease(ReplicationSlotControlLock); - tuplestore_donestoring(tupstore); - return (Datum) 0; } diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index a1dadd4c6ad..5a718b1fe9b 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -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; } diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index c682775db44..1f023a34604 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -605,7 +605,5 @@ pg_get_shmem_allocations(PG_FUNCTION_ARGS) LWLockRelease(ShmemIndexLock); - tuplestore_donestoring(tupstore); - return (Datum) 0; } diff --git a/src/backend/utils/adt/mcxtfuncs.c b/src/backend/utils/adt/mcxtfuncs.c index 28cb9d3ff10..c7c95adf97d 100644 --- a/src/backend/utils/adt/mcxtfuncs.c +++ b/src/backend/utils/adt/mcxtfuncs.c @@ -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; } diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 15cb17ace4f..30e8dfa7c12 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -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; } diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index b73cebfdb5d..eda9c1e42c0 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -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; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 568ac62c2ab..9d0208ec98a 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10206,8 +10206,6 @@ show_all_file_settings(PG_FUNCTION_ARGS) tuplestore_putvalues(tupstore, tupdesc, values, nulls); } - tuplestore_donestoring(tupstore); - return (Datum) 0; } diff --git a/src/backend/utils/misc/pg_config.c b/src/backend/utils/misc/pg_config.c index 7a13212f991..d916d7b2c47 100644 --- a/src/backend/utils/misc/pg_config.c +++ b/src/backend/utils/misc/pg_config.c @@ -85,7 +85,6 @@ pg_config(PG_FUNCTION_ARGS) */ ReleaseTupleDesc(tupdesc); - tuplestore_donestoring(tupstore); rsinfo->setResult = tupstore; /* diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 236f450a2be..7885344164f 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -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; diff --git a/src/include/utils/tuplestore.h b/src/include/utils/tuplestore.h index 399a8493cf5..01716fb44ee 100644 --- a/src/include/utils/tuplestore.h +++ b/src/include/utils/tuplestore.h @@ -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);