pgsql: Introduce frontend API able to retrieve the contents of PG_VERSI

2025-10-14 Thread Michael Paquier
Introduce frontend API able to retrieve the contents of PG_VERSION

get_pg_version() is able to return a version number, that can be used
for comparisons based on PG_VERSION_NUM.  A macro is added to convert
the result to a major version number, to work with PG_MAJORVERSION_NUM.

It is possible to pass to the routine an optional argument, where the
contents retrieved from PG_VERSION are saved.  This requirement matters
for some of the frontend code (one example: pg_upgrade wants that for
tablespace paths with a version number strictly older than v10).

This will be used by a set of follow-up patches, to be consumed in
various frontend tools that duplicate a logic similar to do what this
new routine does, like:
- pg_resetwal
- pg_combinebackup
- pg_createsubscriber
- pg_upgrade

This routine supports both the post-v10 version number and the older
flavor (aka 9.6), as required at least by pg_upgrade.

Author: Michael Paquier 
Reviewed-by: Masahiko Sawada 
Discussion: https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/cd0be131ba6f7e8b1323d188db20d15c2504b021

Modified Files
--
src/fe_utils/Makefile  |  3 +-
src/fe_utils/meson.build   |  1 +
src/fe_utils/version.c | 86 ++
src/include/fe_utils/version.h | 23 +++
4 files changed, 112 insertions(+), 1 deletion(-)



pgsql: pg_upgrade: Use new routine to retrieve data of PG_VERSION

2025-10-14 Thread Michael Paquier
pg_upgrade: Use new routine to retrieve data of PG_VERSION

Unsurprisingly, this shaves code.  get_major_server_version() can be
replaced by the new routine added by cd0be131ba6f, with the contents of
PG_VERSION stored in an allocated buffer instead of a fixed-sized one.

Author: Michael Paquier 
Reviewed-by: Masahiko Sawada 
Discussion: https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/a7d8052910d6254688ef66840554f1bba80a2238

Modified Files
--
src/bin/pg_upgrade/exec.c   |  5 +++--
src/bin/pg_upgrade/pg_upgrade.h |  3 +--
src/bin/pg_upgrade/server.c | 39 ---
3 files changed, 4 insertions(+), 43 deletions(-)



pgsql: Rename apply_at to apply_agg_at for clarity

2025-10-14 Thread Richard Guo
Rename apply_at to apply_agg_at for clarity

The field name "apply_at" in RelAggInfo was a bit ambiguous.  Rename
it to "apply_agg_at" to improve clarity and make its purpose clearer.

Per complaint from David Rowley, Robert Haas.

Suggested-by: Tom Lane 
Discussion: 
https://postgr.es/m/CA+TgmoZ0KR2_XCWHy17=hhcq3p2mamc9c6dnnhf1j6wpyfd...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/1206df04c2001868204f3f79c48173065f3b8231

Modified Files
--
src/backend/optimizer/path/allpaths.c |  2 +-
src/backend/optimizer/path/joinrels.c | 22 +++---
src/backend/optimizer/util/relnode.c  |  6 +++---
src/include/nodes/pathnodes.h |  6 +++---
4 files changed, 18 insertions(+), 18 deletions(-)



pgsql: pg_combinebackup: Use new routine to retrieve data of PG_VERSION

2025-10-14 Thread Michael Paquier
pg_combinebackup: Use new routine to retrieve data of PG_VERSION

pg_combinebackup's custom logic to retrieve the version number of a data
folder's PG_VERSION can be replaced by the facility introduced in
cd0be131ba6f.  This removes some code.

One thing specific to this tool is that backend versions older than v10
are not supported.  The new code does the same checks as the previous
code.

Author: Michael Paquier 
Reviewed-by: Masahiko Sawada 
Discussion: https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/e4775e42cadeaa918bf5e10bf17056c51d5e16e2

Modified Files
--
src/bin/pg_combinebackup/pg_combinebackup.c | 65 -
1 file changed, 9 insertions(+), 56 deletions(-)



pgsql: pg_resetwal: Use new routine to retrieve data of PG_VERSION

2025-10-14 Thread Michael Paquier
pg_resetwal: Use new routine to retrieve data of PG_VERSION

pg_resetwal's custom logic to retrieve the version number of a data
folder's PG_VERSION can be replaced by the facility introduced in
cd0be131ba6f.  This removes some code.

One thing specific to pg_resetwal is that the first line of PG_VERSION
is read and reported in the error report generated when the major
version read does not match with the version pg_resetwal has been
compiled with.  The new logic preserves this property, without changes
to neither the error message nor the data used in the error report.

Note that as a chdir() is done within the data folder before checking the
data of PG_VERSION, get_pg_version() needs to be tweaked to look for
PG_VERSION in the current folder.

Author: Michael Paquier 
Reviewed-by: Masahiko Sawada 
Discussion: https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/c6a6cd53d3ababa667aa224229550b96fb13cf26

Modified Files
--
src/bin/pg_resetwal/pg_resetwal.c | 30 +++---
1 file changed, 7 insertions(+), 23 deletions(-)



pgsql: Make heap_page_is_all_visible independent of LVRelState

2025-10-14 Thread Melanie Plageman
Make heap_page_is_all_visible independent of LVRelState

This function only requires a few fields from LVRelState, so pass them
in individually.

This change allows calling heap_page_is_all_visible() from code such as
pruneheap.c, which does not have access to an LVRelState.

Author: Melanie Plageman 
Reviewed-by: Kirill Reshke 
Reviewed-by: Robert Haas 
Reviewed-by: Andres Freund 
Discussion: 
https://postgr.es/m/2wk7jo4m4qwh5sn33pfgerdjfujebbccsmmlownybddbh6nawl%40mdyyqpqzxjek

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/3e4705484e0c64c7e90d5cc697a9aaf474287d0d

Modified Files
--
src/backend/access/heap/vacuumlazy.c | 60 +++-
1 file changed, 38 insertions(+), 22 deletions(-)



pgsql: Standardize use of REFRESH PUBLICATION in code and messages.

2025-10-14 Thread Amit Kapila
Standardize use of REFRESH PUBLICATION in code and messages.

This patch replaces ALTER SUBSCRIPTION REFRESH with
ALTER SUBSCRIPTION REFRESH PUBLICATION in comments and error messages to
improve clarity and support future extensibility. The change aligns with
upcoming addition REFRESH SEQUENCES for sequence synchronization.

Author: vignesh C 
Author: Hou Zhijie 
Reviewed-by: shveta malik 
Reviewed-by: Dilip Kumar 
Reviewed-by: Peter Smith 
Reviewed-by: Hayato Kuroda 
Reviewed-by: Amit Kapila 
Discussion: 
https://postgr.es/m/caa4ek1lc+kjiaksrpe_nwvndidw9f2os7geruesxskv71gx...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/2436b8c047fff793c9d115dd0acb48c0b6e114d9

Modified Files
--
src/backend/commands/subscriptioncmds.c  | 51 ++--
src/backend/parser/gram.y|  2 +-
src/include/nodes/parsenodes.h   |  2 +-
src/test/regress/expected/object_address.out |  2 +-
src/test/regress/expected/subscription.out   | 28 +++
5 files changed, 43 insertions(+), 42 deletions(-)