pgsql: Remove unnecessary GetTransactionSnapshot() calls

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove unnecessary GetTransactionSnapshot() calls
Date: 2024-12-23 10:44:34
Message-ID: E1tPfvO-000v3U-F6@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Remove unnecessary GetTransactionSnapshot() calls

In get_database_list() and get_subscription_list(), the
GetTransactionSnapshot() call is not required because the catalog
table scans use the catalog snapshot, which is held until the end of
the scan. See table_beginscan_catalog(), which calls
RegisterSnapshot(GetCatalogSnapshot(relid)).

In InitPostgres, it's a little less obvious that it's not required,
but still true I believe. All the catalog lookups in InitPostgres()
also use the catalog snapshot, and the looked up values are copied
while still holding the snapshot.

Furthermore, as the removed FIXME comments said, calling
GetTransactionSnapshot() didn't really prevent MyProc->xmin from being
reset anyway.

Discussion: https://www.postgresql.org/message-id/7c56f180-b9e1-481e-8c1d-efa63de3ecbb@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/952365cded635e54c4177399c0280cb7a5e34c11

Modified Files
--------------
src/backend/postmaster/autovacuum.c | 11 +----------
src/backend/replication/logical/launcher.c | 11 +----------
src/backend/utils/init/postinit.c | 13 +------------
3 files changed, 3 insertions(+), 32 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2024-12-23 20:14:41 pgsql: postgres_fdw: re-issue cancel requests a few times if necessary.
Previous Message David Rowley 2024-12-23 06:43:28 pgsql: Fix incorrect source filename references