]> git.ipfire.org Git - thirdparty/postgresql.git/log
thirdparty/postgresql.git
2 hours agodoc: Fix misleading synopsis for CREATE/ALTER PUBLICATION. master github/master
Fujii Masao [Thu, 27 Nov 2025 14:29:57 +0000 (23:29 +0900)] 
doc: Fix misleading synopsis for CREATE/ALTER PUBLICATION.

The documentation for CREATE/ALTER PUBLICATION previously showed:

        [ ONLY ] table_name [ * ] [ ( column_name [, ... ] ) ] [ WHERE ( expression ) ] [, ... ]

to indicate that the table/column specification could be repeated.
However, placing [, ... ] directly after a multi-part construct was
misleading and made it unclear which portion was repeatable.

This commit introduces a new term, table_and_columns, to represent:

        [ ONLY ] table_name [ * ] [ ( column_name [, ... ] ) ] [ WHERE ( expression ) ]

and updates the synopsis to use:

        table_and_columns [, ... ]

which clearly identifies the repeatable element.

Backpatched to v15, where the misleading syntax was introduced.

Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHut+PtsyvYL3KmA6C8f0ZpXQ=7FEqQtETVy-BOF+cm9WPvfMQ@mail.gmail.com
Backpatch-through: 15

4 hours agoFix new test for CATCACHE_FORCE_RELEASE builds
Álvaro Herrera [Thu, 27 Nov 2025 12:10:56 +0000 (13:10 +0100)] 
Fix new test for CATCACHE_FORCE_RELEASE builds

Two of the isolation tests introduce by commit bc32a12e0db2 had a
problem under CATCACHE_FORCE_RELEASE, as evidenced by buildfarm member
prion.  An injection point is hit ahead of what the test spec expects,
so a session goes to sleep and there's no one there to wait it up.  Fix
in the simplest possible way, which is to conditionally wake the process
up if it's waiting.  An alternative output file is necessary to cover
both cases.

This suggests a couple of possible improvements to the injection points
infrastructure: a conditional wakeup (doing nothing if no one is
sleeping, as opposed to throwing an error), as well as a way to attach
to a point in "deactivated" mode, activated later.

Author: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Discussion: https://postgr.es/m/202511261817.fyixgtt3hqdr@alvherre.pgsql

8 hours agodoc: Fix typo in pg_dump documentation
Daniel Gustafsson [Thu, 27 Nov 2025 08:25:56 +0000 (09:25 +0100)] 
doc: Fix typo in pg_dump documentation

Reported-by: Erik Rijkers <er@xs4all.nl>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/7596672c-43e8-a030-0850-2dd09af98cac@xs4all.nl

10 hours agoUse C11 alignas in pg_atomic_uint64 definitions
Peter Eisentraut [Thu, 27 Nov 2025 06:39:25 +0000 (07:39 +0100)] 
Use C11 alignas in pg_atomic_uint64 definitions

They were already using pg_attribute_aligned.  This replaces that with
alignas and moves that into the required syntactic position.  This
ends up making these three atomics implementations appear a bit more
consistent, but shouldn't change anything otherwise.

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/46f05236-d4d4-4b4e-84d4-faa500f14691%40eisentraut.org

13 hours agoFix error reporting for SQL/JSON path type mismatches
Amit Langote [Thu, 27 Nov 2025 01:43:29 +0000 (10:43 +0900)] 
Fix error reporting for SQL/JSON path type mismatches

transformJsonFuncExpr() used exprType()/exprLocation() on the
possibly coerced path expression, which could be NULL when
coercion to jsonpath failed, leading to "cache lookup failed
for type 0" errors.

Preserve the original expression node so that type and location
in the "must be of type jsonpath" error are reported correctly.
Add regression tests to cover these cases.

Reported-by: Jian He <jian.universality@gmail.com>
Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/CACJufxHunVg81JMuNo8Yvv_hJD0DicgaVN2Wteu8aJbVJPBjZA@mail.gmail.com
Backpatch-through: 17

16 hours agoAdd parallelism support for TID Range Scans
David Rowley [Thu, 27 Nov 2025 01:05:04 +0000 (14:05 +1300)] 
Add parallelism support for TID Range Scans

In v14, bb437f995 added support for scanning for ranges of TIDs using a
dedicated executor node for the purpose.  Here, we allow these scans to
be parallelized.  The range of blocks to scan is divvied up similarly to
how a Parallel Seq Scans does that, where 'chunks' of blocks are
allocated to each worker and the size of those chunks is slowly reduced
down to 1 block per worker by the time we're nearing the end of the
scan.  Doing that means workers finish at roughly the same time.

Allowing TID Range Scans to be parallelized removes the dilemma from the
planner as to whether a Parallel Seq Scan will cost less than a
non-parallel TID Range Scan due to the CPU concurrency of the Seq Scan
(disk costs are not divided by the number of workers).  It was possible
the planner could choose the Parallel Seq Scan which would result in
reading additional blocks during execution than the TID Scan would have.
Allowing Parallel TID Range Scans removes the trade-off the planner
makes when choosing between reduced CPU costs due to parallelism vs
additional I/O from the Parallel Seq Scan due to it scanning blocks from
outside of the required TID range.  There is also, of course, the
traditional parallelism performance benefits to be gained as well, which
likely doesn't need to be explained here.

Author: Cary Huang <cary.huang@highgo.ca>
Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Rafia Sabih <rafia.pghackers@gmail.com>
Reviewed-by: Steven Niu <niushiji@gmail.com>
Discussion: https://postgr.es/m/18f2c002a24.11bc2ab825151706.3749144144619388582@highgo.ca

19 hours agoHave the planner replace COUNT(ANY) with COUNT(*), when possible
David Rowley [Wed, 26 Nov 2025 21:43:28 +0000 (10:43 +1300)] 
Have the planner replace COUNT(ANY) with COUNT(*), when possible

This adds SupportRequestSimplifyAggref to allow pg_proc.prosupport
functions to receive an Aggref and allow them to determine if there is a
way that the Aggref call can be optimized.

Also added is a support function to allow transformation of COUNT(ANY)
into COUNT(*).  This is possible to do when the given "ANY" cannot be
NULL and also that there are no ORDER BY / DISTINCT clauses within the
Aggref.  This is a useful transformation to do as it is common that
people write COUNT(1), which until now has added unneeded overhead.
When counting a NOT NULL column.  The overheads can be worse as that
might mean deforming more of the tuple, which for large fact tables may
be many columns in.

It may be possible to add prosupport functions for other aggregates.  We
could consider if ORDER BY could be dropped for some calls, e.g. the
ORDER BY is quite useless in MAX(c ORDER BY c).

There is a little bit of passing fallout from adjusting
expr_is_nonnullable() to handle Const which results in a plan change in
the aggregates.out regression test.  Previously, nothing was able to
determine that "One-Time Filter: (100 IS NOT NULL)" was always true,
therefore useless to include in the plan.

Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/CAApHDvqGcPTagXpKfH=CrmHBqALpziThJEDs_MrPqjKVeDF9wA@mail.gmail.com

19 hours agoTeach DSM registry to retry entry initialization if needed.
Nathan Bossart [Wed, 26 Nov 2025 21:12:25 +0000 (15:12 -0600)] 
Teach DSM registry to retry entry initialization if needed.

If DSM registry entry initialization fails, backends could try to
use an uninitialized DSM segment, DSA, or dshash table (since the
entry is still added to the registry).  To fix, restructure the
code so that the registry retries initialization as needed.  This
commit also modifies pg_get_dsm_registry_allocations() to leave out
partially-initialized entries, as they shouldn't have any allocated
memory.

DSM registry entry initialization shouldn't fail often in practice,
but retrying was deemed better than leaving entries in a
permanently failed state (as was done by commit 1165a933aa, which
has since been reverted).

Suggested-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/E1vJHUk-006I7r-37%40gemulon.postgresql.org
Backpatch-through: 17

20 hours agoAllow pg_locale_t APIs to work when ctype_is_c.
Jeff Davis [Wed, 26 Nov 2025 20:45:06 +0000 (12:45 -0800)] 
Allow pg_locale_t APIs to work when ctype_is_c.

Previously, the caller needed to check ctype_is_c first for some
routines and not others. Now, the APIs consistently work, and the
caller can just check ctype_is_c for optimization purposes.

Discussion: https://postgr.es/m/450ceb6260cad30d7afdf155d991a9caafee7c0d.camel@j-davis.com
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
21 hours agoCheck for correct version of perltidy
Daniel Gustafsson [Wed, 26 Nov 2025 19:43:09 +0000 (20:43 +0100)] 
Check for correct version of perltidy

pgperltidy requires a particular version of perltidy, but the version
wasn't checked like how pgindent checks the underlying indent binary.
Fix by checking the version of perltidy and error out if an incorrect
version is used.

Author: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/1209850.1764092152@sss.pgh.pa.us

23 hours agoAdd #define for UNICODE_CASEMAP_BUFSZ.
Jeff Davis [Wed, 26 Nov 2025 18:05:11 +0000 (10:05 -0800)] 
Add #define for UNICODE_CASEMAP_BUFSZ.

Useful for mapping a single codepoint at a time into a
statically-allocated buffer.

Discussion: https://postgr.es/m/450ceb6260cad30d7afdf155d991a9caafee7c0d.camel@j-davis.com
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
23 hours agoInline pg_ascii_tolower() and pg_ascii_toupper().
Jeff Davis [Wed, 26 Nov 2025 18:04:32 +0000 (10:04 -0800)] 
Inline pg_ascii_tolower() and pg_ascii_toupper().

Discussion: https://postgr.es/m/450ceb6260cad30d7afdf155d991a9caafee7c0d.camel@j-davis.com
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
23 hours agoRevert "Teach DSM registry to ERROR if attaching to an uninitialized entry."
Nathan Bossart [Wed, 26 Nov 2025 17:37:21 +0000 (11:37 -0600)] 
Revert "Teach DSM registry to ERROR if attaching to an uninitialized entry."

This reverts commit 1165a933aa (and the corresponding commits on
the back-branches).  In a follow-up commit, we'll teach the
registry to retry entry initialization instead of leaving it in a
permanently failed state.

Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/E1vJHUk-006I7r-37%40gemulon.postgresql.org
Backpatch-through: 17

25 hours agoSplit heap_page_prune_and_freeze() into helpers
Melanie Plageman [Wed, 26 Nov 2025 15:57:50 +0000 (10:57 -0500)] 
Split heap_page_prune_and_freeze() into helpers

Refactor the setup and planning phases of pruning and freezing into
helpers. This streamlines heap_page_prune_and_freeze() and makes it more
clear when the examination of tuples ends and page modifications begin.

No code change beyond what was required to extract the code into helper
functions.

Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/mhf4vkmh3j57zx7vuxp4jagtdzwhu3573pgfpmnjwqa6i6yj5y%40sy4ymcdtdklo

25 hours agoRemove a few unused struct members.
Nathan Bossart [Wed, 26 Nov 2025 15:50:00 +0000 (09:50 -0600)] 
Remove a few unused struct members.

Oversights in commits ab9e0e718af3049a603a, and 247ce06b88.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/aScUuBSawPWogUxs%40ip-10-97-1-34.eu-west-3.compute.internal

27 hours agossl: Add connection and reload tests for key passphrases
Daniel Gustafsson [Wed, 26 Nov 2025 13:24:34 +0000 (14:24 +0100)] 
ssl: Add connection and reload tests for key passphrases

ssl_passphrase_command_supports_reload was not covered by the SSL
testsuite,  and connection tests after unlocking secrets with the
passphrase was also missing.  This adds test coverage for reloads
of passphrase commands as well as connection attempts which tests
the different codepaths for Windows and non-EXEC_BACKEND builds.

Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/5F301096-921A-427D-8EC1-EBAEC2A35082@yesql.se

27 hours agoAdd GUC to show EXEC_BACKEND state
Daniel Gustafsson [Wed, 26 Nov 2025 13:24:27 +0000 (14:24 +0100)] 
Add GUC to show EXEC_BACKEND state

There is no straightforward way to determine if a cluster is running
in EXEC_BACKEND mode or not, which is useful for tests to know. This
adds a GUC debug_exec_backend similar to debug_assertions which will
be true when the server is running in EXEC_BACKEND mode.

Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/5F301096-921A-427D-8EC1-EBAEC2A35082@yesql.se

27 hours agodoc: Clarify passphrase command reloading on Windows
Daniel Gustafsson [Wed, 26 Nov 2025 13:24:04 +0000 (14:24 +0100)] 
doc: Clarify passphrase command reloading on Windows

When running on Windows (or EXEC_BACKEND) the SSL configuration will
be reloaded on each backend start, so the passphrase command will be
reloaded along with it.  This implies that passphrase command reload
must be enabled on Windows for connections to work at all.  Document
this since it wasn't mentioned explicitly, and will there add markup
for parameter value to match the rest of the docs.

Backpatch to all supported versions.

Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/5F301096-921A-427D-8EC1-EBAEC2A35082@yesql.se
Backpatch-through: 14

34 hours agoReplace internal C function pg_hypot() by standard hypot()
Peter Eisentraut [Wed, 26 Nov 2025 06:46:33 +0000 (07:46 +0100)] 
Replace internal C function pg_hypot() by standard hypot()

The code comment said, "It is expected that this routine will
eventually be replaced with the C99 hypot() function.", so let's do
that now.

This function is tested via the geometry regression test, so if it is
faulty on any platform, it will show up there.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/170308e6-a7a3-4484-87b2-f960bb564afa%40eisentraut.org

36 hours agooauth_validator: Shorten JSON responses in test logs
Jacob Champion [Wed, 26 Nov 2025 04:32:52 +0000 (20:32 -0800)] 
oauth_validator: Shorten JSON responses in test logs

Response padding from the oauth_validator abuse tests was adding a
couple megabytes to the test logs. We don't need the buildfarm to hold
onto that, and we don't need to read it when debugging; truncate it.

Reported-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/202511251218.zfs4nu2qnh2m%40alvherre.pgsql
Backpatch-through: 18

37 hours agoFix test failure caused by commit 76b78721ca.
Amit Kapila [Wed, 26 Nov 2025 03:26:57 +0000 (03:26 +0000)] 
Fix test failure caused by commit 76b78721ca.

The test failed because it assumed that a newly created logical
replication slot could be synced to the standby by the slotsync worker.
However, the presence of an existing physical slot caused the new logical
slot to use a non-latest xmin. On the standby, the DDL had already been
replayed, advancing xmin, which led to the slotsync worker failing to sync
the lagging logical slot.

To resolve this, we moved the slot sync statistics tests to run after the
tests that do not require the newly created slot to be sync-ready.

As per buildfarm.

Author: Hou Zhijie <houzj.fnst@fujitsu.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/OSCPR01MB14966FE0BFB6C212298BFFEDEF5D1A@OSCPR01MB14966.jpnprd01.prod.outlook.com

39 hours agoAdd input function for data type pg_dependencies
Michael Paquier [Wed, 26 Nov 2025 01:53:16 +0000 (10:53 +0900)] 
Add input function for data type pg_dependencies

pg_dependencies is used as data type for the contents of dependencies
extended statistics.  This new input function consumes the format that
has been established by e76defbcf09e for the output function of
pg_dependencies, enforcing some sanity checks for:
- Checks for the input object, which should be a one-dimension array
with correct attributes and values.
- The key names: "attributes", "dependency", "degree".  All are
required, other key names are blocked.
- Value types for each key: "attributes" requires an array of integers,
"dependency" an attribute number, "degree" a float.
- List of attributes.  In this case, it is possible that some
dependencies are not listed in the statistics data, as items with a
degree of 0 are discarded when building the statistics.  This commit
includes checks for simple scenarios, like duplicated attributes, or
overlapping values between the list of "attributes" and the "dependency"
value.  Even if the input function considers the input as valid, a value
still needs to be cross-checked with the attributes defined in a
statistics object at import.
- Based on the discussion, the checks on the values are loose, as there
is also an argument for potentially stats injection.  For example,
"degree" should be defined in [0.0,1.0], but a check is not enforced.

This is required for a follow-up patch that aims to implement the import
of extended statistics.  Some tests are added to check the code paths of
the JSON parser checking the shape of the pg_dependencies inputs, with
91% of code coverage reached.  The tests are located in their own new
test file, for clarity.

Author: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Yuefei Shi <shiyuefei1004@gmail.com>
Discussion: https://postgr.es/m/CADkLM=dpz3KFnqP-dgJ-zvRvtjsa8UZv8wDAQdqho=qN3kX0Zg@mail.gmail.com

39 hours agoAdd input function for data type pg_ndistinct
Michael Paquier [Wed, 26 Nov 2025 01:13:18 +0000 (10:13 +0900)] 
Add input function for data type pg_ndistinct

pg_ndistinct is used as data type for the contents of ndistinct extended
statistics.  This new input function consumes the format that has been
established by 1f927cce4498 for the output function of pg_ndistinct,
enforcing some sanity checks for:
- Checks for the input object, which should be a one-dimension array
with correct attributes and values.
- The key names: "attributes", "ndistinct".  Both are required, other
key names are blocked.
- Value types for each key: "attributes" requires an array of integers,
and "ndistinct" an integer.
- List of attributes.  Note that this enforces a check so as an
attribute list has to be a subset of the longest attribute list found.
This does not enforce that a full group of attribute sets exist, based
on how the groups are generated when the ndistinct objects are
generated, making the list of ndistinct items a bit loose.  Note a check
would still be required at import to see if the attributes listed match
with the attribute numbers set in the definition of a statistics object.
- Based on the discussion, the checks on the values are loose, as there
is also an argument for potentially stats injection.  The relation and
attribute level stats follow the same line of argument for the values.

This is required for a follow-up patch that aims to implement the import
of extended statistics.  Some tests are added to check the code paths of
the JSON parser checking the shape of the pg_ndistinct inputs, with 90%
of code coverage reached.  The tests are located in their own new test
file, for clarity.

Author: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Yuefei Shi <shiyuefei1004@gmail.com>
Discussion: https://postgr.es/m/CADkLM=dpz3KFnqP-dgJ-zvRvtjsa8UZv8wDAQdqho=qN3kX0Zg@mail.gmail.com

43 hours agoAssert that cutoffs are provided if freezing will be attempted
Melanie Plageman [Tue, 25 Nov 2025 21:39:56 +0000 (16:39 -0500)] 
Assert that cutoffs are provided if freezing will be attempted

heap_page_prune_and_freeze() requires the caller to initialize
PruneFreezeParams->cutoffs so that the function can correctly evaluate
whether tuples should be frozen. This requirement previously existed
only in comments and was easy to miss, especially after “cutoffs” was
converted from a direct function parameter to a field of the newly
introduced PruneFreezeParams struct (added in 1937ed70621). Adding an
assert makes this requirement explicit and harder to violate.

Also, fix a minor typo while we're at it.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/0AC177F5-5E26-45EE-B273-357C51212AC5%40gmail.com

45 hours agoRemove a useless length check.
Jeff Davis [Tue, 25 Nov 2025 19:38:45 +0000 (11:38 -0800)] 
Remove a useless length check.

Author: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/CAEoWx2mW0P8CByavV58zm3=eb2MQHaKOcDEF5B2UJYRyC2c3ig@mail.gmail.com

46 hours agopg_dump tests: don't put dumps in stdout
Álvaro Herrera [Tue, 25 Nov 2025 18:08:36 +0000 (19:08 +0100)] 
pg_dump tests: don't put dumps in stdout

This bloats the regression log files for no reason.

Backpatch to 18; no further only because it fails to apply cleanly.
(It's just whitespace change that conflicts, but I don't think this
warrants more effort than this.)

Discussion: https://postgr.es/m/202511251218.zfs4nu2qnh2m@alvherre.pgsql

47 hours agoImprove test case stability
Álvaro Herrera [Tue, 25 Nov 2025 17:20:06 +0000 (18:20 +0100)] 
Improve test case stability

Given unlucky timing, some of the new tests added by commit bc32a12e0db2
can fail spuriously.  We haven't seen such failures yet in buildfarm,
but allegedly we can prevent them with this tweak.

While at it, remove an unused injection point I (Álvaro) added.

Author: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Discussion: https://postgr.es/m/CADzfLwUc=jtSUEaQCtyt8zTeOJ-gHZ8=w_KJsVjDOYSLqaY9Lg@mail.gmail.com
Discussion: https://postgr.es/m/CADzfLwV5oQq-Vg_VmG_o4SdL6yHjDoNO4T4pMtgJLzYGmYf74g@mail.gmail.com

2 days agogen_guc_tables.pl: Validate required GUC fields before code generation
Peter Eisentraut [Tue, 25 Nov 2025 15:50:34 +0000 (16:50 +0100)] 
gen_guc_tables.pl: Validate required GUC fields before code generation

Previously, gen_guc_tables.pl would emit "Use of uninitialized value"
warnings if required fields were missing in guc_parameters.dat (for
example, when an integer or real GUC omitted the 'max' value).  The
resulting error messages were unclear and did not identify which GUC
entry was problematic.

Add explicit validation of required fields depending on the parameter
type, and fail with a clear and specific message such as:

    guc_parameters.dat:1909: error: entry "max_index_keys" of type "int" is missing required field "max"

No changes to generated guc_tables.c.

Author: Chao Li <lic@highgo.com>
Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/CAEoWx2%3DoP4LgHi771_OKhPPUS7B-CTqCs%3D%3DuQcNXWrwBoAm5Vg%40mail.gmail.com

2 days agobackend/nodes cleanup: Move loop variables definitions into for statement
Peter Eisentraut [Tue, 25 Nov 2025 14:38:23 +0000 (15:38 +0100)] 
backend/nodes cleanup: Move loop variables definitions into for statement

Author: Chao Li (Evan) <lic@highgo.com>
Discussion: https://www.postgresql.org/message-id/flat/CAEoWx2nP12qwAaiJutbn1Kw50atN6FbMJNQ4bh4%2BfP_Ay_u7Eg%40mail.gmail.com

2 days agoFix a BF failure caused by commit 76b78721ca.
Amit Kapila [Tue, 25 Nov 2025 08:49:46 +0000 (08:49 +0000)] 
Fix a BF failure caused by commit 76b78721ca.

The issue occurred because the replication slot was not released in the
slotsync worker when a slot synchronization cycle was skipped. This skip
happened because the required WAL was not received and flushed on the
standby server. As a result, in the next cycle, when attempting to acquire
the slot, an assertion failure was triggered.

Author: Hou Zhijie <houzj.fnst@fujitsu.com>
Discussion: https://postgr.es/m/CAA4eK1KMwYUYy=oAVHu9mam+vX50ixxfhO4_C=kgQC8VCQHEfw@mail.gmail.com

2 days agoAdd slotsync skip statistics.
Amit Kapila [Tue, 25 Nov 2025 06:47:49 +0000 (06:47 +0000)] 
Add slotsync skip statistics.

This patch adds two new columns to the pg_stat_replication_slots view:
slotsync_skip_count - the total number of times a slotsync operation was
skipped.
slotsync_skip_at - the timestamp of the most recent skip.

These additions provide better visibility into replication slot
synchronization behavior.

A future patch will introduce the slotsync_skip_reason column in
pg_replication_slots to capture the reason for skip.

Author: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CAE9k0PkhfKrTEAsGz4DjOhEj1nQ+hbQVfvWUxNacD38ibW3a1g@mail.gmail.com

2 days agoRemove obsolete comment
Peter Eisentraut [Tue, 25 Nov 2025 05:26:49 +0000 (06:26 +0100)] 
Remove obsolete comment

This comment should probably have been moved to pg_locale_libc.c in
commit 66ac94cdc79 (2024), but upon closer examination it was already
completely obsolete then.

The first part of the comment has been obsolete since commit
85feb77aa09 (2017), which required that the system provides the
required wide-character functions.

The second part has been obsolete since commit e9931bfb751 (2024),
which eliminated code paths depending on the global LC_CTYPE setting.

Discussion: https://www.postgresql.org/message-id/flat/170308e6-a7a3-4484-87b2-f960bb564afa%40eisentraut.org

2 days agoRename routines for write/read of pgstats file
Michael Paquier [Tue, 25 Nov 2025 01:55:40 +0000 (10:55 +0900)] 
Rename routines for write/read of pgstats file

This commit renames write_chunk and read_chunk to respectively
pgstat_write_chunk() and pgstat_read_chunk(), along with the *_s
convenience macros.

These are made available for plug-ins, so as any code that decides to
write and/or read stats data can rely on a single code path for this
work.

Extracted from a larger patch by the same author.

Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0s9SDOu+Z6veoJCHWk+kDeTktAtC-KY9fQ9Z6BJdDUirQ@mail.gmail.com

2 days agolwlock: Fix, currently harmless, bug in LWLockWakeup()
Andres Freund [Mon, 24 Nov 2025 22:37:09 +0000 (17:37 -0500)] 
lwlock: Fix, currently harmless, bug in LWLockWakeup()

Accidentally the code in LWLockWakeup() checked the list of to-be-woken up
processes to see if LW_FLAG_HAS_WAITERS should be unset. That means that
HAS_WAITERS would not get unset immediately, but only during the next,
unnecessary, call to LWLockWakeup().

Luckily, as the code stands, this is just a small efficiency issue.

However, if there were (as in a patch of mine) a case in which LWLockWakeup()
would not find any backend to wake, despite the wait list not being empty,
we'd wrongly unset LW_FLAG_HAS_WAITERS, leading to potentially hanging.

While the consequences in the backbranches are limited, the code as-is
confusing, and it is possible that there are workloads where the additional
wait list lock acquisitions hurt, therefore backpatch.

Discussion: https://postgr.es/m/fvfmkr5kk4nyex56ejgxj3uzi63isfxovp2biecb4bspbjrze7@az2pljabhnff
Backpatch-through: 14

2 days agoAvoid global LC_CTYPE dependency in pg_locale_libc.c.
Jeff Davis [Mon, 24 Nov 2025 22:55:09 +0000 (14:55 -0800)] 
Avoid global LC_CTYPE dependency in pg_locale_libc.c.

Call tolower_l() directly instead of through pg_tolower(), because the
latter depends on the global LC_CTYPE.

Discussion: https://postgr.es/m/8186b28a1a39e61a0d833a4c25a8909ebbbabd48.camel@j-davis.com

2 days agoImprove detection of implicitly-temporary views.
Tom Lane [Mon, 24 Nov 2025 22:00:16 +0000 (17:00 -0500)] 
Improve detection of implicitly-temporary views.

We've long had a practice of making views temporary by default if they
reference any temporary tables.  However the implementation was pretty
incomplete, in that it only searched for RangeTblEntry references to
temp relations.  Uses of temporary types, regclass constants, etc
were not detected even though the dependency mechanism considers them
grounds for dropping the view.  Thus a view not believed to be temp
could silently go away at session exit anyhow.

To improve matters, replace the ad-hoc isQueryUsingTempRelation()
logic with use of the dependency-based infrastructure introduced by
commit 572c40ba9.  This is complete by definition, and it's less code
overall.

While we're at it, we can also extend the warning NOTICE (or ERROR
in the case of a materialized view) to mention one of the temp
objects motivating the classification of the view as temp, as was
done for functions in 572c40ba9.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Discussion: https://postgr.es/m/19cf6ae1-04cd-422c-a760-d7e75fe6cba9@uni-muenster.de

2 days agoReorganize pqcomm.h a bit
Jacob Champion [Mon, 24 Nov 2025 18:01:30 +0000 (10:01 -0800)] 
Reorganize pqcomm.h a bit

Group the PG_PROTOCOL() codes, add a comment to AuthRequest now that the
AUTH_REQ codes live in a different header, and make some small
adjustments to spacing and comment style for the sake of scannability.

Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/CAOYmi%2B%3D6zg4oXXOQtifrVao_YKiujTDa3u6bxnU08r0FsSig4g%40mail.gmail.com

2 days agopostgres: Use pg_{add,mul}_size_overflow()
Jacob Champion [Mon, 24 Nov 2025 17:59:54 +0000 (09:59 -0800)] 
postgres: Use pg_{add,mul}_size_overflow()

The backend implementations of add_size() and mul_size() can now make
use of the APIs provided in common/int.h.

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAOYmi%2B%3D%2BpqUd2MUitvgW1pAJuXgG_TKCVc3_Ek7pe8z9nkf%2BAg%40mail.gmail.com

2 days agoAdd pg_add_size_overflow() and friends
Jacob Champion [Mon, 24 Nov 2025 17:59:38 +0000 (09:59 -0800)] 
Add pg_add_size_overflow() and friends

Commit 600086f47 added (several bespoke copies of) size_t addition with
overflow checks to libpq. Move this to common/int.h, along with
its subtraction and multiplication counterparts.

pg_neg_size_overflow() is intentionally omitted; I'm not sure we should
add SSIZE_MAX to win32_port.h for the sake of a function with no
callers.

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAOYmi%2B%3D%2BpqUd2MUitvgW1pAJuXgG_TKCVc3_Ek7pe8z9nkf%2BAg%40mail.gmail.com

2 days agoMake some use of anonymous unions [libpq-oauth]
Jacob Champion [Mon, 24 Nov 2025 17:55:16 +0000 (09:55 -0800)] 
Make some use of anonymous unions [libpq-oauth]

Make some use of anonymous unions, which are allowed as of C11, as
examples and encouragement for future code, and to test compilers.

This commit changes the json_field struct.

Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/CAOYmi%2BnV25oC5uXFgWodydGrHkfWMDCLUcjbAreM3mNX%3DF2JWw%40mail.gmail.com

3 days agoFix infer_arbiter_index during concurrent index operations
Álvaro Herrera [Mon, 24 Nov 2025 16:03:10 +0000 (17:03 +0100)] 
Fix infer_arbiter_index during concurrent index operations

Previously, we would only consider indexes marked indisvalid as usable
for INSERT ON CONFLICT.  But that's problematic during CREATE INDEX
CONCURRENTLY and REINDEX CONCURRENTLY, because concurrent transactions
would end up with inconsistents lists of inferred indexes, leading to
deadlocks and spurious errors about unique key violations (because two
transactions are operating on different indexes for the speculative
insertion tokens).  Change this function to return indexes even if
invalid.  This fixes the spurious errors and deadlocks.

Because such indexes might not be complete, we still need uniqueness to
be verified in a different way.  We do that by requiring that at least
one index marked valid is part of the set of indexes returned.  It is
that index that is going to help ensure that the inserted tuple is
indeed unique.

This does not fix similar problems occurring with partitioned tables or
with named constraints.  These problems will be fixed in follow-up
commits.

We have no user report of this problem, even though it exists in all
branches.  Because of that and given that the fix is somewhat tricky, I
decided not to backpatch for now.

Author: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CANtu0ogv+6wqRzPK241jik4U95s1pW3MCZ3rX5ZqbFdUysz7Qw@mail.gmail.com

3 days agoMove isolation test index-killtuples to src/test/modules/index/
Michael Paquier [Mon, 24 Nov 2025 10:33:51 +0000 (19:33 +0900)] 
Move isolation test index-killtuples to src/test/modules/index/

index-killtuples test depends on the contrib modules btree_gin and
btree_gist, which would not be installed in a temporary installation
with an execution of the main isolation test suite like this one:
make -C src/test/isolation/ check

src/test/isolation/ should not depend on contrib/, and EXTRA_INSTALL has
no effect in this case as this test suite uses its own Makefile rules.

This commit moves index-killtuples into its new module, called "index",
whose name looks like the best fit there can be as it depends on more
than one index AM.  btree_gin and btree_gist are now pulled in the
temporary installation with EXTRA_INSTALL.  The test is renamed to
"killtuples", for simplicity.

Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Suggested-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/aKJsWedftW7UX1WM@paquier.xyz

3 days agoC11 alignas instead of unions -- extended alignments
Peter Eisentraut [Mon, 24 Nov 2025 06:36:49 +0000 (07:36 +0100)] 
C11 alignas instead of unions -- extended alignments

This replaces some uses of pg_attribute_aligned() with the standard
alignas() for cases where extended alignment (larger than max_align_t)
is required.

This patch stipulates that all supported compilers must support
alignments up to PG_IO_ALIGN_SIZE, but that seems pretty likely.

We can then also desupport the case where direct I/O is disabled
because pg_attribute_aligned is not supported.

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/46f05236-d4d4-4b4e-84d4-faa500f14691%40eisentraut.org

3 days agopg_buffercache: Add pg_buffercache_os_pages
Michael Paquier [Mon, 24 Nov 2025 05:29:15 +0000 (14:29 +0900)] 
pg_buffercache: Add pg_buffercache_os_pages

ba2a3c2302f has added a way to check if a buffer is spread across
multiple pages with some NUMA information, via a new view
pg_buffercache_numa that depends on pg_buffercache_numa_pages(), a SQL
function.  These can only be queried when support for libnuma exists,
generating an error if not.

However, it can be useful to know how shared buffers and OS pages map
when NUMA is not supported or not available.  This commit expands the
capabilities around pg_buffercache_numa:
- pg_buffercache_numa_pages() is refactored as an internal function,
able to optionally process NUMA.  Its SQL definition prior to this
commit is still around to ensure backward-compatibility with v1.6.
- A SQL function called pg_buffercache_os_pages() is added, able to work
with or without NUMA.
- The view pg_buffercache_numa is redefined to use
pg_buffercache_os_pages().
- A new view is added, called pg_buffercache_os_pages.  This ignores
NUMA for its result processing, for a better efficiency.

The implementation is done so as there is no code duplication between
the NUMA and non-NUMA views/functions, relying on one internal function
that does the job for all of them.  The module is bumped to v1.7.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Mircea Cadariu <cadariu.mircea@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/Z/fFA2heH6lpSLlt@ip-10-97-1-34.eu-west-3.compute.internal

3 days agoFix incorrect IndexOptInfo header comment
David Rowley [Mon, 24 Nov 2025 04:00:01 +0000 (17:00 +1300)] 
Fix incorrect IndexOptInfo header comment

The comment incorrectly indicated that indexcollations[] stored
collations for both key columns and INCLUDE columns, but in reality it
only has elements for the key columns.  canreturn[] didn't get a mention,
so add that while we're here.

Author: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAEG8a3LwbZgMKOQ9CmZarX5DEipKivdHp5PZMOO-riL0w%3DL%3D4A%40mail.gmail.com
Backpatch-through: 14

3 days agoIssue a NOTICE if a created function depends on any temp objects.
Tom Lane [Sun, 23 Nov 2025 20:02:55 +0000 (15:02 -0500)] 
Issue a NOTICE if a created function depends on any temp objects.

We don't have an official concept of temporary functions.  (You can
make one explicitly in pg_temp, but then you have to explicitly
schema-qualify it on every call.)  However, until now we were quite
laissez-faire about whether a non-temporary function could depend on
a temporary object, such as a temp table or view.  If one does,
it will silently go away at end of session, due to the automatic
DROP ... CASCADE on the session's temporary objects.  People have
complained that that's surprising; however, we can't really forbid
it because other people (including our own regression tests) rely
on being able to do it.  Let's compromise by emitting a NOTICE
at CREATE FUNCTION time.  This is somewhat comparable to our
ancient practice of emitting a NOTICE when forcing a view to
become temp because it depends on temp tables.

Along the way, refactor recordDependencyOnExpr() so that the
dependencies of an expression can be combined with other
dependencies, instead of being emitted separately and perhaps
duplicatively.

We should probably make the implementation of temp-by-default
views use the same infrastructure used here, but that's for
another patch.  It's unclear whether there are any other object
classes that deserve similar treatment.

Author: Jim Jones <jim.jones@uni-muenster.de>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19cf6ae1-04cd-422c-a760-d7e75fe6cba9@uni-muenster.de

4 days agopsql: Improve tab-completion for PREPARE.
Fujii Masao [Sun, 23 Nov 2025 14:03:53 +0000 (23:03 +0900)] 
psql: Improve tab-completion for PREPARE.

This commit enhances tab-completion for PREPARE xx AS to also suggest
MERGE INTO, VALUES, WITH, and TABLE.

Author: Haruna Miwa <miwa@sraoss.co.jp>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/TY7P286MB5466B859BD6C5BE64E961878F1CEA@TY7P286MB5466.JPNP286.PROD.OUTLOOK.COM

4 days agopg_buffercache: Remove unused fields from BufferCacheNumaRec
Michael Paquier [Sun, 23 Nov 2025 04:37:42 +0000 (13:37 +0900)] 
pg_buffercache: Remove unused fields from BufferCacheNumaRec

These fields have been added in commit ba2a3c2302f, and have never been
used.  While on it, this commit moves a comment that was out of place,
improving it.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/aSBOKX6pLJzumbmF@ip-10-97-1-34.eu-west-3.compute.internal

4 days agoAdd SupportRequestInlineInFrom planner support request.
Tom Lane [Sun, 23 Nov 2025 00:33:34 +0000 (19:33 -0500)] 
Add SupportRequestInlineInFrom planner support request.

This request allows a support function to replace a function call
appearing in FROM (typically a set-returning function) with an
equivalent SELECT subquery.  The subquery will then be subject
to the planner's usual optimizations, potentially allowing a much
better plan to be generated.  While the planner has long done this
automatically for simple SQL-language functions, it's now possible
for extensions to do it for functions outside that group.
Notably, this could be useful for functions that are presently
implemented in PL/pgSQL and work by generating and then EXECUTE'ing
a SQL query.

Author: Paul A Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/09de6afa-c33d-4d94-a5cb-afc6cea0d2bb@illuminatedcomputing.com

5 days agotools: remove src/tools/codelines
Bruce Momjian [Sat, 22 Nov 2025 17:01:56 +0000 (12:01 -0500)] 
tools:  remove src/tools/codelines

This is a one-line script never gained general usage since being added
in 2005.

Backpatch-through: master

5 days agoAdd range_minus_multi and multirange_minus_multi functions
Peter Eisentraut [Sat, 22 Nov 2025 08:40:00 +0000 (09:40 +0100)] 
Add range_minus_multi and multirange_minus_multi functions

The existing range_minus function raises an exception when the range is
"split", because then the result can't be represented by a single range.
For example '[0,10)'::int4range - '[4,5)' would be '[0,4)' and '[5,10)'.

This commit adds new set-returning functions so that callers can get
results even in the case of splits. There is no risk of an exception for
multiranges, but a set-returning function lets us handle them the same
way we handle ranges.

Both functions return zero results if the subtraction would give an
empty range/multirange.

The main use-case for these functions is to implement UPDATE/DELETE FOR
PORTION OF, which must compute the application-time of "temporal
leftovers": the part of history in an updated/deleted row that was not
changed. To preserve the untouched history, we will implicitly insert
one record for each result returned by range/multirange_minus_multi.
Using a set-returning function will also let us support user-defined
types for application-time update/delete in the future.

Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/ec498c3d-5f2b-48ec-b989-5561c8aa2024%40illuminatedcomputing.com

5 days agojit: Adjust AArch64-only code for LLVM 21.
Thomas Munro [Sat, 22 Nov 2025 07:51:16 +0000 (20:51 +1300)] 
jit: Adjust AArch64-only code for LLVM 21.

LLVM 21 changed the arguments of RTDyldObjectLinkingLayer's
constructor, breaking compilation with the backported
SectionMemoryManager from commit 9044fc1d.

https://github.com/llvm/llvm-project/commit/cd585864c0bbbd74ed2a2b1ccc191eed4d1c8f90

Backpatch-through: 14
Author: Holger Hoffstätte <holger@applied-asynchrony.com>
Reviewed-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Discussion: https://postgr.es/m/d25e6e4a-d1b4-84d3-2f8a-6c45b975f53d%40applied-asynchrony.com

5 days agoAdd 'make check-tests' behavior to the meson based builds
Andrew Dunstan [Fri, 21 Nov 2025 22:08:46 +0000 (17:08 -0500)] 
Add 'make check-tests' behavior to the meson based builds

There was no easy way to run specific tests in the meson based builds.

Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Discussion: postgr.es/m/CAExHW5tK-QqayUN0%2BN3MF5bjV6vLKDCkRuGwoDJwc7vGjwCygQ%40mail.gmail.com

6 days agoFix typo in documentation about application time
Peter Eisentraut [Fri, 21 Nov 2025 16:36:25 +0000 (17:36 +0100)] 
Fix typo in documentation about application time

Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>

6 days agoRemove useless casts to (void *)
Peter Eisentraut [Fri, 21 Nov 2025 15:49:40 +0000 (16:49 +0100)] 
Remove useless casts to (void *)

Their presence causes (small) risks of hiding actual type mismatches
or silently discarding qualifiers.  Some have been missed in
7f798aca1d5 and some are new ones along the same lines.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/aR8Yv%2BuATLKbJCgI%40ip-10-97-1-34.eu-west-3.compute.internal

6 days agoUse strtoi64() in pgbench, replacing its open-coded implementation
Heikki Linnakangas [Fri, 21 Nov 2025 13:03:11 +0000 (15:03 +0200)] 
Use strtoi64() in pgbench, replacing its open-coded implementation

Makes the code a little simpler.

The old implementation accepted trailing whitespace, but that was
unnecessary. Firstly, its sibling function for parsing decimals,
strtodouble(), does not accept trailing whitespace. Secondly, none of
the callers can pass a string with trailing whitespace to it.

In the passing, check specifically for ERANGE before printing the "out
of range" error. On some systems, strtoul() and strtod() return EINVAL
on an empty or all-spaces string, and "invalid input syntax" is more
appropriate for that than "out of range". For the existing
strtodouble() function this is purely academical because it's never
called with errorOK==false, but let's be tidy. (Perhaps we should
remove the dead codepaths altogether, but I'll leave that for another
day.)

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Yuefei Shi <shiyuefei1004@gmail.com>
Reviewed-by: Neil Chen <carpenter.nail.cz@gmail.com>
Discussion: https://www.postgresql.org/message-id/861dd5bd-f2c9-4ff5-8aa0-f82bdb75ec1f@iki.fi

6 days agoUpdate timezone to C99
Peter Eisentraut [Fri, 21 Nov 2025 12:01:30 +0000 (13:01 +0100)] 
Update timezone to C99

This reverts changes done in PostgreSQL over the upstream code to
avoid relying on C99 <stdint.h> and <inttypes.h>.

In passing, there were a few other minor and cosmetic changes that I
left in to improve alignment with upstream, including some C11 feature
use (_Noreturn).

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/9ad2749f-77ab-4ecb-a321-1ca915480b05%40eisentraut.org

6 days agoC11 alignas instead of unions
Peter Eisentraut [Fri, 21 Nov 2025 08:57:06 +0000 (09:57 +0100)] 
C11 alignas instead of unions

This changes a few union members that only existed to ensure
alignments and replaces them with the C11 alignas specifier.

This change only uses fundamental alignments (meaning approximately
alignments of basic types), which all C11 compilers must support.
There are opportunities for similar changes using extended alignments,
for example in PGIOAlignedBlock, but these are not necessarily
supported by all compilers, so they are kept as a separate change.

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/46f05236-d4d4-4b4e-84d4-faa500f14691%40eisentraut.org

6 days agoUse "COPY table TO" for partitioned tables in initial table synchronization.
Masahiko Sawada [Thu, 20 Nov 2025 22:50:27 +0000 (14:50 -0800)] 
Use "COPY table TO" for partitioned tables in initial table synchronization.

Commit 4bea91f added support for "COPY table TO" with partitioned
tables. This commit enhances initial table synchronization in logical
replication to use "COPY table TO" for partitioned tables if possible,
instead of "COPY (SELECT ...) TO" variant, improving performance.

Author: Ajin Cherian <itsajin@gmail.com>
Discussion: https://postgr.es/m/CAFPTHDY=w+xmEof=yyjhbDzaLxhBkoBzKcksEofXcT6EcjMbtQ@mail.gmail.com

6 days agoSplit PruneFreezeParams initializers to one field per line
Melanie Plageman [Thu, 20 Nov 2025 22:36:40 +0000 (17:36 -0500)] 
Split PruneFreezeParams initializers to one field per line

This conforms more closely with the style of other struct initializers
in the code base. Initializing multiple fields on a single line is
unpopular in part because pgindent won't permit a space after the comma
before the next field's period.

Author: Melanie Plageman <melanieplageman@gmail.com>
Reported-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Discussion: https://postgr.es/m/87see87fnq.fsf%40wibble.ilmari.org

6 days agotools: update tools/codelines to use "git ls-files"
Bruce Momjian [Thu, 20 Nov 2025 20:23:39 +0000 (15:23 -0500)] 
tools:  update tools/codelines to use "git ls-files"

This generates a more accurate code count because 'make distclean'
doesn't always remove build files.

Author: idea from David Rowley

Discussion: https://postgr.es/m/aR4hoOotVHB7TXo5@momjian.us

Backpatch-through: master

7 days agoUpdate PruneState.all_[visible|frozen] earlier in pruning
Melanie Plageman [Thu, 20 Nov 2025 16:40:36 +0000 (11:40 -0500)] 
Update PruneState.all_[visible|frozen] earlier in pruning

During pruning and freezing in phase I of vacuum, we delay clearing
all_visible and all_frozen in the presence of dead items. This allows
opportunistic freezing if the page would otherwise be fully frozen,
since those dead items are later removed in vacuum phase III.

To move the VM update into the same WAL record that
prunes and freezes tuples, we must know whether the page will
be marked all-visible/all-frozen before emitting WAL. Previously we
waited until after emitting WAL to update all_visible/all_frozen to
their correct values.

The only barrier to updating these flags immediately after deciding
whether to opportunistically freeze was that while emitting WAL for a
record freezing tuples, we use the pre-corrected value of all_frozen to
compute the snapshot conflict horizon. By determining the conflict
horizon earlier, we can update the flags immediately after making the
opportunistic freeze decision.

This is required to set the VM in the XLOG_HEAP2_PRUNE_VACUUM_SCAN
record emitted by pruning and freezing.

Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/flat/CAAKRu_ZMw6Npd_qm2KM%2BFwQ3cMOMx1Dh3VMhp8-V7SOLxdK9-g%40mail.gmail.com

7 days agoKeep all_frozen updated in heap_page_prune_and_freeze
Melanie Plageman [Thu, 20 Nov 2025 15:58:34 +0000 (10:58 -0500)] 
Keep all_frozen updated in heap_page_prune_and_freeze

Previously, we relied on all_visible and all_frozen being used together
to ensure that all_frozen was correct, but it is better to keep both
fields updated.

Future changes will separate their usage, so we should not depend on
all_visible for the validity of all_frozen.

Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/flat/CAAKRu_ZMw6Npd_qm2KM%2BFwQ3cMOMx1Dh3VMhp8-V7SOLxdK9-g%40mail.gmail.com

7 days agoRefactor heap_page_prune_and_freeze() parameters into a struct
Melanie Plageman [Thu, 20 Nov 2025 15:30:43 +0000 (10:30 -0500)] 
Refactor heap_page_prune_and_freeze() parameters into a struct

heap_page_prune_and_freeze() had accumulated an unwieldy number of input
parameters and upcoming work to handle VM updates in this function will
add even more.

Introduce a new PruneFreezeParams struct to group the function’s input
parameters, improving readability and maintainability.

Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/yn4zp35kkdsjx6wf47zcfmxgexxt4h2og47pvnw2x5ifyrs3qc%407uw6jyyxuyf7

7 days agodoc: Assorted documentation improvements
Daniel Gustafsson [Thu, 20 Nov 2025 14:04:41 +0000 (15:04 +0100)] 
doc: Assorted documentation improvements

A set of wording improvements and spelling fixes.

Author: Oleg Sibiryakov <o.sibiryakov@postgrespro.ru>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/e62bedb5-c26f-4d37-b4ed-ce9b55f1e980@postgrespro.ru

7 days agodoc: Document how to run a subset of regress tests
Daniel Gustafsson [Thu, 20 Nov 2025 13:49:33 +0000 (14:49 +0100)] 
doc: Document how to run a subset of regress tests

This patch was originally submitted a year ago, but never
ended up getting committed. It was later brought up again
on a recent thread on the same subject.

Original patch by Paul A Jungwirth with some wordsmithing
by me based on the review from the original thread.

Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Viktor Holmberg <v@viktorh.net>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CA+renyXB5jYG9r5-CaDc4g607EB398QwTk_efEXTzarrO8bPzw@mail.gmail.com
Discussion: https://postgr.es/m/CACJufxHOcmeTkoh2CxFHKv9GRnp9sLVzN=LZhqTgvqT++PXZNQ@mail.gmail.com

7 days agoHandle EPERM in pg_numa_init
Tomas Vondra [Thu, 20 Nov 2025 11:51:58 +0000 (12:51 +0100)] 
Handle EPERM in pg_numa_init

When running in Docker, the container may not have privileges needed by
get_mempolicy(). This is called by numa_available() in libnuma, but
versions prior to 2.0.19 did not expect that. The numa_available() call
seemingly succeeds, but then we get unexpected failures when trying to
query status of pages:

  postgres =# select * from pg_shmem_allocations_numa;
  ERROR:  XX000: failed NUMA pages inquiry status: Operation not
          permitted
  LOCATION:  pg_get_shmem_allocations_numa, shmem.c:691

The best solution is to call get_mempolicy() first, and proceed to
numa_available() only when it does not fail with EPERM. Otherwise we'd
need to treat older libnuma versions as insufficient, which seems a bit
too harsh, as this only affects containerized systems.

Fix by me, based on suggestions by Christoph. Backpatch to 18, where the
NUMA functions were introduced.

Reported-by: Christoph Berg <myon@debian.org>
Reviewed-by: Christoph Berg <myon@debian.org>
Discussion: https://postgr.es/m/aPDZOxjrmEo_1JRG@msg.df7cb.de
Backpatch-through: 18

7 days agoRemove obsolete cast
Peter Eisentraut [Thu, 20 Nov 2025 06:47:48 +0000 (07:47 +0100)] 
Remove obsolete cast

The upstream timezone code uses a bool variable as an array subscript.
Back when PostgreSQL's bool was char, this would have caused a warning
from gcc -Wchar-subscripts, which is included in -Wall.  But this has
been obsolete since probably commit d26a810ebf9, but certainly since
bool is now the C standard bool.  So we can remove this deviation from
the upstream code, to make future code merges simpler.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/9ad2749f-77ab-4ecb-a321-1ca915480b05%40eisentraut.org

7 days agodoc: Update pg_upgrade documentation to match recent description changes.
Fujii Masao [Thu, 20 Nov 2025 00:18:51 +0000 (09:18 +0900)] 
doc: Update pg_upgrade documentation to match recent description changes.

Commit 792353f7d52 updated the pg_dump and pg_dumpall documentation to
clarify which statistics are not included in their output. The pg_upgrade
documentation contained a nearly identical description, but it was not updated
at the same time.

This commit updates the pg_upgrade documentation to match those changes.

Backpatch to v18, where commit 792353f7d52 was backpatched to.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Bruce Momjian <bruce@momjian.us>
Discussion: https://postgr.es/m/CAHGQGwFnfgdGz8aGWVzgFCFwoWQU7KnFFjmxinf4RkQAkzmR+w@mail.gmail.com
Backpatch-through: 18

7 days agoAdd HINT listing valid encodings to encode() and decode() errors.
Fujii Masao [Thu, 20 Nov 2025 00:14:02 +0000 (09:14 +0900)] 
Add HINT listing valid encodings to encode() and decode() errors.

This commit updates encode() and decode() so that when an invalid encoding
is specified, their error message includes a HINT listing all valid encodings.
This helps users quickly see which encodings are supported without needing
to consult the documentation.

Author: Shinya Sugamoto <shinya34892@gmail.com>
Reviewed-by: Chao Li <lic@highgo.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAAe3y+99sfPv8UDF1VM-rC1i5HBdqxUh=2HrbJJFm2+i=1OwOw@mail.gmail.com

7 days agoDrop support for MSVCRT's float formatting quirk.
Thomas Munro [Wed, 19 Nov 2025 21:23:44 +0000 (10:23 +1300)] 
Drop support for MSVCRT's float formatting quirk.

Commit f1885386 added code to remove an unnecessary leading zero from
the exponent in a float formatted by the system snprintf().  The C
standard doesn't allow unnecessary digits beyond two, and the tests pass
without this on Windows' modern UCRT (required since commit 1758d424).

Discussion: https://postgr.es/m/CA%2BhUKGJnmzTqiODmTjf-23yZ%3DE3HXqFTtKoyp3TF-MpB93hTMQ%40mail.gmail.com

7 days agoDrop support for MSVCRT's %I64 format strings.
Thomas Munro [Wed, 19 Nov 2025 21:04:11 +0000 (10:04 +1300)] 
Drop support for MSVCRT's %I64 format strings.

MSVCRT predated C99 and invented non-standard placeholders for 64-bit
numbers, and then later used them in standard macros when C99
<inttypes.h> arrived.  The macros just use %lld etc when building with
UCRT, so there should be no way for our interposed sprintf.c code to
receive the pre-standard kind these days.  Time to drop the code that
parses them.

That code was in fact already dead when commit 962da900 landed, as we'd
disclaimed MSVCRT support a couple of weeks earlier in commit 1758d424,
but patch development overlapped and the history of these macros hadn't
been investigated.

Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/4d8b1a67-aab2-4429-b44b-f03988095939%40eisentraut.org

7 days agoSpeed up eqjoinsel() with lots of MCV entries.
Tom Lane [Wed, 19 Nov 2025 18:22:12 +0000 (13:22 -0500)] 
Speed up eqjoinsel() with lots of MCV entries.

If both sides of the operator have most-common-value statistics,
eqjoinsel wants to check which MCVs have matches on the other side.
Formerly it did this with a dumb compare-all-the-entries loop,
which had O(N^2) behavior for long MCV lists.  When that code was
written, twenty-plus years ago, that seemed tolerable; but nowadays
people frequently use much larger statistics targets, so that the
O(N^2) behavior can hurt quite a bit.

To add insult to injury, when asked for semijoin semantics, the
entire comparison loop was done over, even though we frequently
know that it will yield exactly the same results.

To improve matters, switch to using a hash table to perform the
matching.  Testing suggests that depending on the data type, we may
need up to about 100 MCVs on each side to amortize the extra costs
of setting up the hash table and performing hash-value computations;
so continue to use the old looping method when there are fewer MCVs
than that.

Also, refactor so that we don't repeat the matching work unless
we really need to, which occurs only in the uncommon case where
eqjoinsel_semi decides to truncate the set of inner MCVs it
considers.  The refactoring also got rid of the need to use the
presented operator's commutator.  Real-world operators that are
using eqjoinsel should pretty much always have commutators, but
at the very least this saves a few syscache lookups.

Author: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
Co-authored-by: David Geier <geidav.pg@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20ea8bf5-3569-4e46-92ef-ebb2666debf6@tantorlabs.com

8 days agoPrint new OldestXID value in pg_resetwal when it's being changed
Heikki Linnakangas [Wed, 19 Nov 2025 16:05:42 +0000 (18:05 +0200)] 
Print new OldestXID value in pg_resetwal when it's being changed

Commit 74cf7d46a91d added the --oldest-transaction-id option to
pg_resetwal, but forgot to update the code that prints all the new
values that are being set. Fix that.

Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/5461bc85-e684-4531-b4d2-d2e57ad18cba@iki.fi
Backpatch-through: 14

8 days agodoc: Update formula for vacuum insert threshold.
Nathan Bossart [Wed, 19 Nov 2025 16:01:37 +0000 (10:01 -0600)] 
doc: Update formula for vacuum insert threshold.

Oversight in commit 06eae9e621.

Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/aRODeqFUVkGDJSPP%40nathan
Backpatch-through: 18

8 days agoFix indentation
Peter Eisentraut [Wed, 19 Nov 2025 09:41:28 +0000 (10:41 +0100)] 
Fix indentation

for commit 0fc33b00536

8 days agoFix NLS for incorrect GUC enum value hint message
Peter Eisentraut [Wed, 19 Nov 2025 07:46:31 +0000 (08:46 +0100)] 
Fix NLS for incorrect GUC enum value hint message

The translation markers were applied at the wrong place, so no string
was extracted for translation.

Also add translator comments here and in a similar place.

Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://www.postgresql.org/message-id/2c961fa1-14f6-44a2-985c-e30b95654e8d%40eisentraut.org

8 days agoAdd <stdalign.h> to c.h
Peter Eisentraut [Wed, 19 Nov 2025 07:02:05 +0000 (08:02 +0100)] 
Add <stdalign.h> to c.h

This allows using the C11 constructs alignas and alignof (not done in
this patch).

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/46f05236-d4d4-4b4e-84d4-faa500f14691%40eisentraut.org

8 days agoFix typo in nodeHash.c
Richard Guo [Wed, 19 Nov 2025 02:04:03 +0000 (11:04 +0900)] 
Fix typo in nodeHash.c

Replace "overlow" with "overflow".

Author: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/CAHewXNnzFjAjYLTkP78HE2PQ17MjBqFdQQg+0X6Wo7YMUb68xA@mail.gmail.com

8 days agoFix pg_popcount_aarch64.c to build with ancient glibc releases.
Tom Lane [Tue, 18 Nov 2025 21:16:46 +0000 (16:16 -0500)] 
Fix pg_popcount_aarch64.c to build with ancient glibc releases.

Like commit 6d969ca68, except here we are mopping up after 519338ace.
(There are no other uses of <sys/auxv.h> in the tree, so we should
be done now.)

Reported-by: GaoZengqi <pgf00a@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAFmBtr3Av62-jBzdhFkDHXJF9vQmNtSnH2upwODjnRcsgdTytw@mail.gmail.com
Backpatch-through: 18

8 days agoFix typo
Álvaro Herrera [Tue, 18 Nov 2025 18:31:23 +0000 (19:31 +0100)] 
Fix typo

8 days agoDon't allow CTEs to determine semantic levels of aggregates.
Tom Lane [Tue, 18 Nov 2025 17:56:55 +0000 (12:56 -0500)] 
Don't allow CTEs to determine semantic levels of aggregates.

The fix for bug #19055 (commit b0cc0a71e) allowed CTE references in
sub-selects within aggregate functions to affect the semantic levels
assigned to such aggregates.  It turns out this broke some related
cases, leading to assertion failures or strange planner errors such
as "unexpected outer reference in CTE query".  After experimenting
with some alternative rules for assigning the semantic level in
such cases, we've come to the conclusion that changing the level
is more likely to break things than be helpful.

Therefore, this patch undoes what b0cc0a71e changed, and instead
installs logic to throw an error if there is any reference to a
CTE that's below the semantic level that standard SQL rules would
assign to the aggregate based on its contained Var and Aggref nodes.
(The SQL standard disallows sub-selects within aggregate functions,
so it can't reach the troublesome case and hence has no rule for
what to do.)

Perhaps someone will come along with a legitimate query that this
logic rejects, and if so probably the example will help us craft
a level-adjustment rule that works better than what b0cc0a71e did.
I'm not holding my breath for that though, because the previous
logic had been there for a very long time before bug #19055 without
complaints, and that bug report sure looks to have originated from
fuzzing not from real usage.

Like b0cc0a71e, back-patch to all supported branches, though
sadly that no longer includes v13.

Bug: #19106
Reported-by: Kamil Monicz <kamil@monicz.dev>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19106-9dd3668a0734cd72@postgresql.org
Backpatch-through: 14

9 days agoAdd commit f63ae72bbc to .git-blame-ignore-revs.
Nathan Bossart [Tue, 18 Nov 2025 16:32:22 +0000 (10:32 -0600)] 
Add commit f63ae72bbc to .git-blame-ignore-revs.

9 days agoCheck for tabs in postgresql.conf.sample.
Nathan Bossart [Tue, 18 Nov 2025 16:28:36 +0000 (10:28 -0600)] 
Check for tabs in postgresql.conf.sample.

The previous commit updated this file to use spaces instead of
tabs.  This commit adds a test to ensure that no new tabs are
added.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/aReNUKdMgKxLqmq7%40nathan

9 days agoSwitch from tabs to spaces in postgresql.conf.sample.
Nathan Bossart [Tue, 18 Nov 2025 16:28:36 +0000 (10:28 -0600)] 
Switch from tabs to spaces in postgresql.conf.sample.

This file is written for 8-space tabs, since we expect that most
users who edit their configuration files use 8-space tabs.
However, most of PostgreSQL is written for 4-space tabs, and at
least one popular web interface defaults to 4-space tabs.  Rather
than trying to standardize on a particular tab width for this file,
let's just switch to spaces.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/aReNUKdMgKxLqmq7%40nathan

9 days agoUpdate .editorconfig and .gitattributes for postgresql.conf.sample.
Nathan Bossart [Tue, 18 Nov 2025 16:28:36 +0000 (10:28 -0600)] 
Update .editorconfig and .gitattributes for postgresql.conf.sample.

This commit updates .editorconfig and .gitattributes in preparation
for a follow-up commit that will modify this file to use spaces
instead of tabs.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/aReNUKdMgKxLqmq7%40nathan

9 days agoLog a note at program start when running in dry-run mode
Álvaro Herrera [Tue, 18 Nov 2025 15:13:29 +0000 (16:13 +0100)] 
Log a note at program start when running in dry-run mode

Users might get some peace of mind knowing their data is not being
destroyed or whatever.

Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAHut+PsvQJQnQO0KT0S2oegenkvJ8FUuY-QS5syyqmT24R2xFQ@mail.gmail.com

9 days agoOptimize shared memory usage for WaitLSNProcInfo
Alexander Korotkov [Tue, 18 Nov 2025 07:50:12 +0000 (09:50 +0200)] 
Optimize shared memory usage for WaitLSNProcInfo

We need separate pairing heaps for different WaitLSNType's, because there
might be waiters for different LSN's at the same time.  However, one process
can wait only for one type of LSN at a time.  So, no need for inHeap
and heapNode fields to be arrays.

Discussion: https://postgr.es/m/CAPpHfdsBR-7sDtXFJ1qpJtKiohfGoj%3DvqzKVjWxtWsWidx7G_A%40mail.gmail.com
Author: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
9 days agopg_buffercache: Fix incorrect result cast for relforknumber
Michael Paquier [Tue, 18 Nov 2025 06:46:43 +0000 (15:46 +0900)] 
pg_buffercache: Fix incorrect result cast for relforknumber

pg_buffercache_pages.relforknumber is defined as an int2, but its value
was stored with ObjectIdGetDatum() rather than Int16GetDatum() in the
result record.

Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://postgr.es/m/CAExHW5s2_qwSdhKpVnUzjRMf0cf1PvmhUHQDLaFM3QzKbP1OyQ@mail.gmail.com

9 days agodoc: Fix style of description for pg_buffercache_numa.os_page_num
Michael Paquier [Tue, 18 Nov 2025 05:17:54 +0000 (14:17 +0900)] 
doc: Fix style of description for pg_buffercache_numa.os_page_num

Extracted from a larger patch by the same author.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/Z/fFA2heH6lpSLlt@ip-10-97-1-34.eu-west-3.compute.internal

9 days agoRename two columns in pg_stat_subscription_stats.
Amit Kapila [Tue, 18 Nov 2025 03:58:55 +0000 (03:58 +0000)] 
Rename two columns in pg_stat_subscription_stats.

This patch renames the sync_error_count column to sync_table_error_count
in the pg_stat_subscription_stats view. The new name makes the purpose
explicit now that a separate column exists to track sequence
synchronization errors.

Additionally, the column seq_sync_error_count is renamed to
sync_seq_error_count to maintain a consistent naming pattern, making it
easier for users to group, and query synchronization related counters.

Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CALDaNm3WwJmz=-4ybTkhniB-Nf3qmFG9Zx1uKjyLLoPF5NYYXA@mail.gmail.com

9 days agoDoc: Use <structfield> markup for sequence fields.
Amit Kapila [Tue, 18 Nov 2025 03:48:00 +0000 (03:48 +0000)] 
Doc: Use <structfield> markup for sequence fields.

Following commit 980a855c5c, update documentation to use <structfield> for
sequence columns. Previously, these were incorrectly marked up as <literal>.

Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHut+PtpDMUE3Kd1p=1ff9pw2HMbgQCpowE_0Hd6gs5v2pKfQg@mail.gmail.com

9 days agodoc: clarify that pg_upgrade preserves "optimizer" stats.
Bruce Momjian [Mon, 17 Nov 2025 23:55:41 +0000 (18:55 -0500)] 
doc:  clarify that pg_upgrade preserves "optimizer" stats.

Reported-by: Rambabu V
Author: Robert Treat

Discussion: https://postgr.es/m/CADtiZxrUzRRX6edyN2y-7U5HA8KSXttee7K=EFTLXjwG1SCE4A@mail.gmail.com

Backpatch-through: 18

9 days agoUse streaming read I/O in BRIN vacuum scan.
Masahiko Sawada [Mon, 17 Nov 2025 21:22:20 +0000 (13:22 -0800)] 
Use streaming read I/O in BRIN vacuum scan.

This commit implements streaming read I/O for BRIN vacuum
scans. Although BRIN indexes tend to be relatively small by design,
performance tests have shown performance improvements.

Author: Arseniy Mukhin <arseniy.mukhin.dev@gmail.com>
Discussion: https://postgr.es/m/CAE7r3ML01aiq9Th_1OSz7U7Aq2pWbhMLoz5T%2BPXcg8J9ZAPFFA%40mail.gmail.com

9 days agoFix pg_crc32c_armv8_choose.c to build with ancient glibc releases.
Tom Lane [Mon, 17 Nov 2025 20:24:34 +0000 (15:24 -0500)] 
Fix pg_crc32c_armv8_choose.c to build with ancient glibc releases.

If you go back as far as the RHEL7 era, <sys/auxv.h> does not provide
the HWCAPxxx macros needed with elf_aux_info or getauxval, so you need
to get those from the kernel header <asm/hwcap.h> instead.  We knew
that for the 32-bit case but failed to extrapolate to the 64-bit case.
Oversight in commit aac831caf.

Reported-by: GaoZengqi <pgf00a@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAFmBtr3Av62-jBzdhFkDHXJF9vQmNtSnH2upwODjnRcsgdTytw@mail.gmail.com
Backpatch-through: 18

9 days agoClean up match_orclause_to_indexcol().
Tom Lane [Mon, 17 Nov 2025 18:54:52 +0000 (13:54 -0500)] 
Clean up match_orclause_to_indexcol().

Remove bogus stripping of RelabelTypes: that can result in building
an output SAOP tree with incorrect exposed exprType for the operands,
which might confuse polymorphic operators.  Moreover it demonstrably
prevents folding some OR-trees to SAOPs when the RHS expressions
have different base types that were coerced to the same type by
RelabelTypes.

Reduce prohibition on type_is_rowtype to just disallow type RECORD.
We need that because otherwise we would happily fold multiple RECORD
Consts into a RECORDARRAY Const even if they aren't the same record
type.  (We could allow that perhaps, if we checked that they all have
the same typmod, but the case doesn't seem worth that much effort.)
However, there is no reason at all to disallow the transformation
for named composite types, nor domains over them: as long as we can
find a suitable array type we're good.

Remove some assertions that seem rather out of place (it's not
this code's duty to verify that the RestrictInfo structure is
sane).  Rewrite some comments.

The issues with RelabelType stripping seem severe enough to
back-patch this into v18 where the code was introduced.

Author: Tender Wang <tndrwang@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAHewXN=aH7GQBk4fXU-WaEeVmQWUmBAeNyBfJ3VKzPphyPKUkQ@mail.gmail.com
Backpatch-through: 18

10 days agodoc: Document default values for some pg_recvlogical options.
Fujii Masao [Mon, 17 Nov 2025 14:24:39 +0000 (23:24 +0900)] 
doc: Document default values for some pg_recvlogical options.

The documentation did not previously mention the default values for
the --fsync-interval and --plugin options, even though pg_recvlogical --help
shows them. This omission made it harder for users to understand
the tool's behavior from the documentation alone.

This commit adds the missing default value descriptions for both options
to the pg_recvlogical documentation.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Discussion: https://postgr.es/m/CAHGQGwFqssPBjkWMFofGq32e_tANOeWN-cM=6biAP3nnFUXMRw@mail.gmail.com

10 days agoFix typos in logical replication code comments
Daniel Gustafsson [Mon, 17 Nov 2025 12:37:25 +0000 (13:37 +0100)] 
Fix typos in logical replication code comments

Author: Chao Li <lic@highgo.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAEoWx2kt8m7wV39_zOBds5SNXx9EAkDqb5cPshk7Bxw6Js4Zpg@mail.gmail.com

10 days agoMention md5 deprecation in postgresql.conf.sample
Daniel Gustafsson [Mon, 17 Nov 2025 11:18:18 +0000 (12:18 +0100)] 
Mention md5 deprecation in postgresql.conf.sample

PostgreSQL 18 deprecated password_encryption='md5', but the
comments for this GUC in the sample configuration file did
not mention the deprecation.  Update comments with a notice
to make as many users as possible aware of it.  Also add a
comment to the related md5_password_warnings GUC while there.

Author: Michael Banck <mbanck@gmx.net>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Robert Treat <rob@xzilla.net>
Backpatch-through: 18

10 days agoRework output format of pg_dependencies
Michael Paquier [Mon, 17 Nov 2025 01:44:26 +0000 (10:44 +0900)] 
Rework output format of pg_dependencies

The existing format of pg_dependencies uses a single-object JSON
structure, with each key value embedding all the knowledge about the
set attributes tracked, like:
{"1 => 5": 1.000000, "5 => 1": 0.423130}

While this is a very compact format, it is confusing to read and it is
difficult to manipulate the values within the object, particularly when
tracking multiple attributes.

The new output format introduced in this commit is a JSON array of
objects, with:
- A key named "degree", with a float value.
- A key named "attributes", with an array of attribute numbers.
- A key named "dependency", with an attribute number.

The values use the same underlying type as previously when printed, with
a new output format that shows now as follows:
[{"degree": 1.000000, "attributes": [1], "dependency": 5},
 {"degree": 0.423130, "attributes": [5], "dependency": 1}]

This new format will become handy for a follow-up set of changes, so as
it becomes possible to inject extended statistics rather than require an
ANALYZE, like in a dump/restore sequence or after pg_upgrade on a new
cluster.

This format has been suggested by Tomas Vondra.  The key names are
defined in the header introduced by 1f927cce4498, to ease the
integration of frontend-specific changes that are still under
discussion.  (Again a personal note: if anybody comes up with better
name for the keys, of course feel free.)

The bulk of the changes come from the regression tests, where
jsonb_pretty() is now used to make the outputs generated easier to
parse.

Author: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CADkLM=dpz3KFnqP-dgJ-zvRvtjsa8UZv8wDAQdqho=qN3kX0Zg@mail.gmail.com