PostgreSQL 18.0 (upcoming) commit log

Reject non-ASCII locale names.

commit   : adbb27ac89e07cfbd94ea07a53930addfc3895ee    
  
author   : Thomas Munro <[email protected]>    
date     : Sat, 5 Oct 2024 13:48:33 +1300    
  
committer: Thomas Munro <[email protected]>    
date     : Sat, 5 Oct 2024 13:48:33 +1300    

Click here for diff

Commit bf03cfd1 started scanning all available BCP 47 locale names on  
Windows.  This caused an abort/crash in the Windows runtime library if  
the default locale name contained non-ASCII characters, because of our  
use of the setlocale() save/restore pattern with "char" strings.  After  
switching to another locale with a different encoding, the saved name  
could no longer be understood, and setlocale() would abort.  
  
"Turkish_Türkiye.1254" is the example from recent reports, but there are  
other examples of countries and languages with non-ASCII characters in  
their names, and they appear in Windows' (old style) locale names.  
  
To defend against this:  
  
1.  In initdb, reject non-ASCII locale names given explicity on the  
command line, or returned by the operating system environment with  
setlocale(..., ""), or "canonicalized" by the operating system when we  
set it.  
  
2.  In initdb only, perform the save-and-restore with Windows'  
non-standard wchar_t variant of setlocale(), so that it is not subject  
to round trip failures stemming from char string encoding confusion.  
  
3.  In the backend, we don't have to worry about the save-and-restore  
problem because we have already vetted the defaults, so we just have to  
make sure that CREATE DATABASE also rejects non-ASCII names in any new  
databases.  SET lc_XXX doesn't suffer from the problem, but the ban  
applies to it too because it uses check_locale().  CREATE COLLATION  
doesn't suffer from the problem either, but it doesn't use  
check_locale() so it is not included in the new ban for now, to minimize  
the change.  
  
Anyone who encounters the new error message should either create a new  
duplicated locale with an ASCII-only name using Windows Locale Builder,  
or consider using BCP 47 names like "tr-TR".  Users already couldn't  
initialize a cluster with "Turkish_Türkiye.1254" on PostgreSQL 16+, but  
the new failure mode is an error message that explains why, instead of a  
crash.  
  
Back-patch to 16, where bf03cfd1 landed.  Older versions are affected  
in theory too, but only 16 and later are causing crash reports.  
  
Reviewed-by: Andrew Dunstan <[email protected]> (the idea, not the patch)  
Reported-by: Haifang Wang (Centific Technologies Inc) <[email protected]>  
Discussion: https://postgr.es/m/PH8PR21MB3902F334A3174C54058F792CE5182%40PH8PR21MB3902.namprd21.prod.outlook.com  

M src/backend/utils/adt/pg_locale.c
M src/bin/initdb/initdb.c

ecpg: avoid adding whitespace around '&' in connection URLs.

commit   : f22e84df1dea96c8f4b0f7369ea60607fbb9ce10    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 4 Oct 2024 12:01:50 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 4 Oct 2024 12:01:50 -0400    

Click here for diff

The preprocessor really should not have done this to begin with.  
The space after '&' was masked by ECPGconnect's skipping spaces  
before option keywords, and the space before by dint of libpq  
being (mostly) insensitive to trailing space in option values.  
We fixed the one known problem with that in 920d51979.  Hence  
this patch is mostly cosmetic, and we'll just change it in HEAD.  
  
Discussion: https://postgr.es/m/TY2PR01MB36286A7B97B9A15793335D18C1772@TY2PR01MB3628.jpnprd01.prod.outlook.com  

M src/interfaces/ecpg/ecpglib/connect.c
M src/interfaces/ecpg/preproc/ecpg.trailer
M src/interfaces/ecpg/test/expected/connect-test5.c
M src/interfaces/ecpg/test/expected/connect-test5.stderr

Rename PageData to GenericXLogPageData

commit   : ddbba3aac868132137782b02a4e81218cfd3b4b9    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 4 Oct 2024 12:47:35 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 4 Oct 2024 12:47:35 +0200    

Click here for diff

In the PostgreSQL C type naming schema, the type PageData should be  
what the pointer of type Page points to.  But in this case it's  
actually an unrelated type local to generic_xlog.c.  Rename that to a  
more specific name.  This makes room to possible add a PageData type  
with the mentioned meaning, but this is not done here.  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Reviewed-by: Michael Paquier <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/001d457e-c118-4219-8132-e1846c2ae3c9%40eisentraut.org  

M src/backend/access/transam/generic_xlog.c
M src/tools/pgindent/typedefs.list

Speed up numeric division by always using the "fast" algorithm.

commit   : 9428c001f67540e6206b7a76adfc5377d9207777    
  
author   : Dean Rasheed <[email protected]>    
date     : Fri, 4 Oct 2024 09:49:24 +0100    
  
committer: Dean Rasheed <[email protected]>    
date     : Fri, 4 Oct 2024 09:49:24 +0100    

Click here for diff

Formerly there were two internal functions in numeric.c to perform  
numeric division, div_var() and div_var_fast(). div_var() performed  
division exactly to a specified rscale using Knuth's long division  
algorithm, while div_var_fast() used the algorithm from the "FM"  
library, which approximates each quotient digit using floating-point  
arithmetic, and computes a truncated quotient with DIV_GUARD_DIGITS  
extra digits. div_var_fast() could be many times faster than  
div_var(), but did not guarantee correct results in all cases, and was  
therefore only suitable for use in transcendental functions, where  
small errors are acceptable.  
  
This commit merges div_var() and div_var_fast() together into a single  
function with an extra "exact" boolean parameter, which can be set to  
false if the caller is OK with an approximate result. The new function  
uses the faster algorithm from the "FM" library, except that when  
"exact" is true, it does not truncate the computation with  
DIV_GUARD_DIGITS extra digits, but instead performs the full-precision  
computation, subtracting off complete multiples of the divisor for  
each quotient digit. However, it is able to retain most of the  
performance benefits of div_var_fast(), by delaying the propagation of  
carries, allowing the inner loop to be auto-vectorized.  
  
Since this may still lead to an inaccurate result, when "exact" is  
true, it then inspects the remainder and uses that to adjust the  
quotient, if necessary, to make it correct. In practice, the quotient  
rarely needs to be adjusted, and never by more than one in the final  
digit, though it's difficult to prove that, so the code allows for  
larger adjustments, just in case.  
  
In addition, use base-NBASE^2 arithmetic and a 64-bit dividend array,  
similar to mul_var(), so that the number of iterations of the outer  
loop is roughly halved. Together with the faster algorithm, this makes  
div_var() up to around 20 times as fast as the old Knuth algorithm  
when "exact" is true, and up to 2 or 3 times as fast as the old  
div_var_fast() function when "exact" is false.  
  
Dean Rasheed, reviewed by Joel Jacobson.  
  
Discussion: https://postgr.es/m/CAEZATCVHR10BPDJSANh0u2+Sg6atO3mD0G+CjKDNRMD-C8hKzQ@mail.gmail.com  

M src/backend/utils/adt/numeric.c
M src/test/regress/expected/numeric.out
M src/test/regress/sql/numeric.sql

Remove assertion checking query ID in execMain.c

commit   : 4dd308730029f5d90bd188f181c2dd9d7630ea69    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 4 Oct 2024 12:51:17 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 4 Oct 2024 12:51:17 +0900    

Click here for diff

This assertion has been added by 24f520594809, but Alexander Lakhin has  
proved that the ExecutorRun() one can be broken by using a PL function  
that manipulates compute_query_id and track_activities, while the ones  
in ExecutorFinish() and ExecutorEnd() could be triggered when cleaning  
up portals at the beginning of a new query execution.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/execMain.c

Fix wrong varnullingrels error for MERGE WHEN NOT MATCHED BY SOURCE.

commit   : 259a0a99fe3d45dcf624788c1724d9989f3382dc    
  
author   : Dean Rasheed <[email protected]>    
date     : Thu, 3 Oct 2024 13:48:32 +0100    
  
committer: Dean Rasheed <[email protected]>    
date     : Thu, 3 Oct 2024 13:48:32 +0100    

Click here for diff

If a MERGE command contains WHEN NOT MATCHED BY SOURCE actions, the  
source relation appears on the outer side of the join. Thus, any Vars  
referring to the source in the merge join condition, actions, and  
RETURNING list should be marked as nullable by the join, since they  
are used in the ModifyTable node above the join. Note that this only  
applies to the copy of join condition used in the executor to  
distinguish MATCHED from NOT MATCHED BY SOURCE cases. Vars in the  
original join condition, inside the join node itself, should not be  
marked.  
  
Failure to correctly mark these Vars led to a "wrong varnullingrels"  
error in the final stage of query planning, in some circumstances. We  
happened to get away without this in all previous tests, since they  
all involved a ModifyTable node directly on top of the join node, so  
that the top plan targetlist coincided with the output of the join,  
and the varnullingrels check was more lax. However, if another plan  
node, such as a one-time filter Result node, gets inserted between the  
ModifyTable node and the join node, then a stricter check is applied,  
which fails.  
  
Per bug #18634 from Alexander Lakhin. Thanks to Tom Lane and Richard  
Guo for review and analysis.  
  
Back-patch to v17, where WHEN NOT MATCHED BY SOURCE support was added  
to MERGE.  
  
Discussion: https://postgr.es/m/18634-db5299c937877f2b%40postgresql.org  

M src/backend/optimizer/prep/prepjointree.c
M src/test/regress/expected/merge.out
M src/test/regress/sql/merge.sql

Fix incorrect non-strict join recheck in MERGE WHEN NOT MATCHED BY SOURCE.

commit   : dddb5640c6d32f3d48994dac0f4e80d0f4567262    
  
author   : Dean Rasheed <[email protected]>    
date     : Thu, 3 Oct 2024 12:53:03 +0100    
  
committer: Dean Rasheed <[email protected]>    
date     : Thu, 3 Oct 2024 12:53:03 +0100    

Click here for diff

If a MERGE command contains WHEN NOT MATCHED BY SOURCE actions, the  
merge join condition is used by the executor to distinguish MATCHED  
from NOT MATCHED BY SOURCE cases. However, this qual is executed using  
the output from the join subplan node, which nulls the output from the  
source relation in the not matched case, and so the result may be  
incorrect if the join condition is "non-strict" -- for example,  
something like "src.col IS NOT DISTINCT FROM tgt.col".  
  
Fix this by enhancing the join recheck condition with an additional  
"src IS NOT NULL" check, so that it does the right thing when  
evaluated using the output from the join subplan.  
  
Noted by Tom Lane while investigating bug #18634 from Alexander  
Lakhin.  
  
Back-patch to v17, where WHEN NOT MATCHED BY SOURCE support was added  
to MERGE.  
  
Discussion: https://postgr.es/m/18634-db5299c937877f2b%40postgresql.org  

M src/backend/optimizer/prep/prepjointree.c
M src/test/regress/expected/merge.out
M src/test/regress/sql/merge.sql

Replace Unicode apostrophe with ASCII apostrophe

commit   : 19531968e84557693576928b3184ccc549aa44c8    
  
author   : Amit Langote <[email protected]>    
date     : Thu, 3 Oct 2024 19:51:38 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Thu, 3 Oct 2024 19:51:38 +0900    

Click here for diff

In commit babb3993dbe9, I accidentally introduced a Unicode  
apostrophe (U+2019). This commit replaces it with the ASCII  
apostrophe (U+0027) for consistency.  
  
Reported-by: Alexander Korotkov <[email protected]>  
Discussion: https://postgr.es/m/CAPpHfduNWMBjkJFtqXJremk6b6YQYO2s3_VEpnj-T_CaUNUYYQ@mail.gmail.com  

M src/backend/commands/tablecmds.c

Refactor CopyFrom() in copyfrom.c.

commit   : e55f025b059fb02b659f12f3003c160ed4674dc8    
  
author   : Fujii Masao <[email protected]>    
date     : Thu, 3 Oct 2024 15:59:16 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Thu, 3 Oct 2024 15:59:16 +0900    

Click here for diff

This commit simplifies CopyFrom() by removing the unnecessary local variable  
'skipped', which tracked the number of rows skipped due to on_error = 'ignore'.  
That count is already handled by cstate->num_errors, so the 'skipped' variable  
was redundant.  
  
Additionally, the condition on_error != COPY_ON_ERROR_STOP is removed.  
Since on_error == COPY_ON_ERROR_IGNORE is already checked, and on_error  
only has two values (ignore and stop), the additional check was redundant  
and made the logic harder to read. Seemingly this was introduced  
in preparation for a future patch, but the current checks don’t offer  
clear value and have been removed to improve readability.  
  
Author: Atsushi Torikoshi  
Reviewed-by: Masahiko Sawada, Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/copyfrom.c

file_fdw: Add on_error and log_verbosity options to file_fdw.

commit   : a1c4c8a9e1e3a53996dafa1f4ee6d4f7de2c58b2    
  
author   : Fujii Masao <[email protected]>    
date     : Thu, 3 Oct 2024 15:57:32 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Thu, 3 Oct 2024 15:57:32 +0900    

Click here for diff

In v17, the on_error and log_verbosity options were introduced for  
the COPY command. This commit extends support for these options  
to file_fdw.  
  
Setting on_error = 'ignore' for a file_fdw foreign table allows users  
to query it without errors, even when the input file contains  
malformed rows, by skipping the problematic rows.  
  
Both on_error and log_verbosity options apply to SELECT and ANALYZE  
operations on file_fdw foreign tables.  
  
Author: Atsushi Torikoshi  
Reviewed-by: Masahiko Sawada, Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M contrib/file_fdw/expected/file_fdw.out
M contrib/file_fdw/file_fdw.c
M contrib/file_fdw/sql/file_fdw.sql
M doc/src/sgml/file-fdw.sgml

Add log_verbosity = 'silent' support to COPY command.

commit   : e7834a1a251d4a28245377f383ff20a657ba8262    
  
author   : Fujii Masao <[email protected]>    
date     : Thu, 3 Oct 2024 15:55:37 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Thu, 3 Oct 2024 15:55:37 +0900    

Click here for diff

Previously, when the on_error option was set to ignore, the COPY command  
would always log NOTICE messages for input rows discarded due to  
data type incompatibility. Users had no way to suppress these messages.  
  
This commit introduces a new log_verbosity setting, 'silent',  
which prevents the COPY command from emitting NOTICE messages  
when on_error = 'ignore' is used, even if rows are discarded.  
This feature is particularly useful when processing malformed files  
frequently, where a flood of NOTICE messages can be undesirable.  
  
For example, when frequently loading malformed files via the COPY command  
or querying foreign tables using file_fdw (with an upcoming patch to  
add on_error support for file_fdw), users may prefer to suppress  
these messages to reduce log noise and improve clarity.  
  
Author: Atsushi Torikoshi  
Reviewed-by: Masahiko Sawada, Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/copy.sgml
M src/backend/commands/copy.c
M src/backend/commands/copyfrom.c
M src/bin/psql/tab-complete.c
M src/include/commands/copy.h
M src/test/regress/expected/copy2.out
M src/test/regress/sql/copy2.sql

Fix expression list handling in ATExecAttachPartition()

commit   : babb3993dbe9c805c1d29fa275a5e8f4c2b40922    
  
author   : Amit Langote <[email protected]>    
date     : Thu, 3 Oct 2024 11:59:09 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Thu, 3 Oct 2024 11:59:09 +0900    

Click here for diff

This commit addresses two issues related to the manipulation of the  
partition constraint expression list in ATExecAttachPartition().  
  
First, the current use of list_concat() to combine the partition's  
constraint (retrieved via get_qual_from_partbound()) with the parent  
table’s partition constraint can lead to memory safety issues. After  
calling list_concat(), the original constraint (partBoundConstraint)  
might no longer be safe to access, as list_concat() may free or modify  
it.  
  
Second, there's a logical error in constructing the constraint for  
validating against the default partition. The current approach  
incorrectly includes a negated version of the parent table's partition  
constraint, which is redundant, as it always evaluates to false for  
rows in the default partition.  
  
To resolve these issues, list_concat() is replaced with  
list_concat_copy(), ensuring that partBoundConstraint remains unchanged  
and can be safely reused when constructing the validation constraint  
for the default partition.  
  
This fix is not applied to back-branches, as there is no live bug and  
the issue has not caused any reported problems in practice.  
  
Nitin Jadhav posted a patch to address the memory safety issue, but I  
decided to follow Alvaro Herrera's suggestion from the initial  
discussion, as it allows us to fix both the memory safety and logical  
issues.  
  
Reported-by: Andres Freund <[email protected]>  
Reported-by: Nitin Jadhav <[email protected]>  
Reviewed-by: Junwang Zhao <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/CAMm1aWbmYHM3bqtjyMQ-a+4Ub=dgsb_2E3_up2cn=UGdHNrGTg@mail.gmail.com  

M src/backend/commands/tablecmds.c

Remove support for unlogged on partitioned tables

commit   : e2bab2d792044b55dd092bf1c2be0d570ccb9401    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 3 Oct 2024 10:55:02 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 3 Oct 2024 10:55:02 +0900    

Click here for diff

The following commands were allowed on partitioned tables, with  
different effects:  
1) ALTER TABLE SET [UN]LOGGED did not issue an error, and did not update  
pg_class.relpersistence.  
2) CREATE UNLOGGED TABLE was working with pg_class.relpersistence marked  
as initially defined, but partitions did not inherit the UNLOGGED  
property, which was confusing.  
  
This commit causes the commands mentioned above to fail for partitioned  
tables, instead.  
  
pg_dump is tweaked so as partitioned tables marked as UNLOGGED ignore  
the option when dumped from older server versions.  pgbench needs a  
tweak for --unlogged and --partitions=N to ignore the UNLOGGED option on  
the partitioned tables created, its partitions still being unlogged.  
  
Author: Michael Paquier  
Reviewed-by: Nathan Bossart  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/alter_table.sgml
M doc/src/sgml/ref/create_table.sgml
M src/backend/commands/tablecmds.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pgbench/pgbench.c
M src/test/regress/expected/create_table.out
M src/test/regress/sql/create_table.sql

Adjust json_manifest_per_file_callback API in one more place.

commit   : 554d3a18f36264eeb1333655b8ddcd929befa6ec    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 2 Oct 2024 20:27:45 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 2 Oct 2024 20:27:45 -0400    

Click here for diff

Oversight in commit d94cf5ca7 (and in my testing of same).  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/backup/basebackup_incremental.c

Parse libpq's "keepalives" option more like other integer options.

commit   : 920d51979a99df29112396b2c75da7921ba7a7b0    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 2 Oct 2024 17:30:36 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 2 Oct 2024 17:30:36 -0400    

Click here for diff

Use pqParseIntParam (nee parse_int_param) instead of using strtol  
directly.  This allows trailing whitespace, which the previous coding  
didn't, and makes the spelling of the error message consistent with  
other similar cases.  
  
This seems to be an oversight in commit e7a221797, which introduced  
parse_int_param.  That fixed places that were using atoi(), but missed  
this place which was randomly using strtol() instead.  
  
Ordinarily I'd consider this minor cleanup not worth back-patching.  
However, it seems that ecpg assumes it can add trailing whitespace  
to URL parameters, so that use of the keepalives option fails in  
that context.  Perhaps that's worth improving as a separate matter.  
In the meantime, back-patch this to all supported branches.  
  
Yuto Sasaki (some further cleanup by me)  
  
Discussion: https://postgr.es/m/TY2PR01MB36286A7B97B9A15793335D18C1772@TY2PR01MB3628.jpnprd01.prod.outlook.com  

M src/interfaces/libpq/fe-connect.c

File size in a backup manifest should use uint64, not size_t.

commit   : d94cf5ca7fad9cd81af5eac491bfbaf0facb9f6f    
  
author   : Robert Haas <[email protected]>    
date     : Wed, 2 Oct 2024 09:59:04 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Wed, 2 Oct 2024 09:59:04 -0400    

Click here for diff

size_t is the size of an object in memory, not the size of a file on disk.  
  
Thanks to Tom Lane for noting the error.  
  
Discussion: http://postgr.es/m/[email protected]  

M src/bin/pg_combinebackup/load_manifest.c
M src/bin/pg_combinebackup/load_manifest.h
M src/bin/pg_combinebackup/write_manifest.c
M src/bin/pg_combinebackup/write_manifest.h
M src/bin/pg_verifybackup/astreamer_verify.c
M src/bin/pg_verifybackup/pg_verifybackup.c
M src/bin/pg_verifybackup/pg_verifybackup.h
M src/common/parse_manifest.c
M src/include/common/parse_manifest.h

doc: Missing markup, punctuation and wordsmithing

commit   : 7b2822ecf944a6aa429c05cc7f070001c3817934    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Wed, 2 Oct 2024 14:50:56 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Wed, 2 Oct 2024 14:50:56 +0200    

Click here for diff

Various improvements to the documentation like adding missing  
markup, improving punctuation, ensuring consistent spelling of  
words and minor wordsmithing.  
  
Author: Oleg Sibiryakov <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/catalogs.sgml
M doc/src/sgml/charset.sgml
M doc/src/sgml/config.sgml
M doc/src/sgml/func.sgml
M doc/src/sgml/libpq.sgml
M doc/src/sgml/protocol.sgml
M doc/src/sgml/ref/alter_table.sgml
M doc/src/sgml/ref/copy.sgml
M doc/src/sgml/ref/create_subscription.sgml
M doc/src/sgml/ref/pgupgrade.sgml
M doc/src/sgml/sepgsql.sgml
M doc/src/sgml/syntax.sgml
M doc/src/sgml/system-views.sgml
M doc/src/sgml/trigger.sgml
M doc/src/sgml/user-manag.sgml
M doc/src/sgml/wal.sgml

Add fastpaths for when no objects are found

commit   : 9c733951049bf3993c886d7f2c7459e7439a9793    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Wed, 2 Oct 2024 13:08:55 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Wed, 2 Oct 2024 13:08:55 +0200    

Click here for diff

If there are no objects found, there is no reason to inspect the  
result columns and mallocing a zero-sized  (which will be 1 byte  
in reality) heap buffer for it.  Add a fast-path for immediately  
returning like how other object inspection functions are already  
doing it.  
  
Reviewed-by: Ranier Vilela <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_dump/pg_dump.c

Remove superfluous PQExpBuffer resetting

commit   : 1a123e3b136bf38ebf5f7a97b358306998f8a61f    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Wed, 2 Oct 2024 13:07:31 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Wed, 2 Oct 2024 13:07:31 +0200    

Click here for diff

Since the buffer was just created, there is no reason to immediately  
reset it.  
  
Reviewed-by: Ranier Vilela <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_dump/pg_dump.c

commit   : 94902b146fae024c03f80d496a0da5ba9751c9b5    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Wed, 2 Oct 2024 12:24:39 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Wed, 2 Oct 2024 12:24:39 +0200    

Click here for diff

The login event trigger is not listed on the trigger firing matrix  
since it's not fired by a command.  Add a link to the example code  
page similar to how the other event triggers link to the matrix.  
  
Reported-by: Marcos Pegoraro <[email protected]>  
Discussion: https://postgr.es/m/CAB-JLwYS+78rX02BZ3wJ9ykVrd2i3O1K+7jzvZKQ0evquyQiLQ@mail.gmail.com  

M doc/src/sgml/event-trigger.sgml

Fix inconsistent reporting of checkpointer stats.

commit   : 17cc5f666f6aada21eb3237974c50681ba4814ea    
  
author   : Fujii Masao <[email protected]>    
date     : Wed, 2 Oct 2024 11:17:47 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Wed, 2 Oct 2024 11:17:47 +0900    

Click here for diff

Previously, the pg_stat_checkpointer view and the checkpoint completion  
log message could show different numbers for buffers written  
during checkpoints. The view only counted shared buffers,  
while the log message included both shared and SLRU buffers,  
causing inconsistencies.  
  
This commit resolves the issue by updating both the view and the log message  
to separately report shared and SLRU buffers written during checkpoints.  
A new slru_written column is added to the pg_stat_checkpointer view  
to track SLRU buffers, while the existing buffers_written column now  
tracks only shared buffers. This change would help users distinguish  
between the two types of buffers, in the pg_stat_checkpointer view and  
the checkpoint complete log message, respectively.  
  
Bump catalog version.  
  
Author: Nitin Jadhav  
Reviewed-by: Bharath Rupireddy, Michael Paquier, Kyotaro Horiguchi, Robert Haas  
Reviewed-by: Andres Freund, vignesh C, Fujii Masao  
Discussion: https://postgr.es/m/CAMm1aWb18EpT0whJrjG+-nyhNouXET6ZUw0pNYYAe+NezpvsAA@mail.gmail.com  

M doc/src/sgml/monitoring.sgml
M src/backend/access/transam/slru.c
M src/backend/access/transam/xlog.c
M src/backend/catalog/system_views.sql
M src/backend/utils/activity/pgstat_checkpointer.c
M src/backend/utils/adt/pgstatfuncs.c
M src/include/access/xlog.h
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/include/pgstat.h
M src/test/regress/expected/rules.out

doc: Clarify name of files generated by pg_waldump --save-fullpage

commit   : 506eede7111ae7c88bd3c21f653bbb65846bd4a5    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 2 Oct 2024 11:12:40 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 2 Oct 2024 11:12:40 +0900    

Click here for diff

The fork name is always separated with the block number by an underscore  
in the names of the files generated, but the docs stuck them together  
without a separator, which was confusing.  
  
Author: Christoph Berg  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 16  

M doc/src/sgml/ref/pg_waldump.sgml

Reject a copy EOF marker that has data ahead of it on the same line.

commit   : da8a4c1666476648659dc5fb6fc01ba5cd5d16a1    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 1 Oct 2024 16:53:54 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 1 Oct 2024 16:53:54 -0400    

Click here for diff

We have always documented that a copy EOF marker (\.) must appear  
by itself on a line, and that is how psql interprets the rule.  
However, the backend's actual COPY FROM logic only insists that  
there not be data between the \. and the following newline.  
Any data ahead of the \. is parsed as a final line of input.  
It's hard to interpret this as anything but an ancient mistake  
that we've faithfully carried forward.  Continuing to allow it  
is not cost-free, since it could mask client-side bugs that  
unnecessarily backslash-escape periods (and thereby risk  
accidentally creating an EOF marker).  So, let's remove that  
provision and throw error if the EOF marker isn't alone on its  
line, matching what the documentation has said right along.  
Adjust the relevant error messages to be clearer, too.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/copyfromparse.c
M src/test/regress/expected/copy.out
M src/test/regress/sql/copy.sql

initdb: Add new option "--no-data-checksums"

commit   : 983a588e0b864d5c016d5902217ba4b11fc82b4f    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 10:27:39 -0400    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 10:27:39 -0400    

Click here for diff

Right now this does nothing except override any earlier  
--data-checksums option.  But the idea is that --data-checksums could  
become the default, and then this option would allow forcing it off  
instead.  
  
Author: Greg Sabino Mullane <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/CAKAnmmKwiMHik5AHmBEdf5vqzbOBbcwEPHo4-PioWeAbzwcTOQ@mail.gmail.com  

M doc/src/sgml/ref/initdb.sgml
M src/bin/initdb/initdb.c
M src/bin/initdb/t/001_initdb.pl

Tweak docs to reduce possible impact of data checksums

commit   : efd72a3d422b591bfec941d625df6fad820e021b    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 09:58:20 -0400    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 09:58:20 -0400    

Click here for diff

Author: Greg Sabino Mullane <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/CAKAnmmKwiMHik5AHmBEdf5vqzbOBbcwEPHo4-PioWeAbzwcTOQ@mail.gmail.com  

M doc/src/sgml/ref/initdb.sgml

Use macro to define the number of enum values

commit   : 10b721821d6d6e27e594549cf105476dc28514c8    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 09:30:24 -0400    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 09:30:24 -0400    

Click here for diff

Refactoring in the interest of code consistency, a follow-up to 2e068db56e31.  
  
The argument against inserting a special enum value at the end of the enum  
definition is that a switch statement might generate a compiler warning unless  
it has a default clause.  
  
Aleksander Alekseev, reviewed by Michael Paquier, Dean Rasheed, Peter Eisentraut  
  
Discussion: https://postgr.es/m/CAJ7c6TMsiaV5urU_Pq6zJ2tXPDwk69-NKVh4AMN5XrRiM7N%2BGA%40mail.gmail.com  

M contrib/pg_stat_statements/pg_stat_statements.c
M src/backend/postmaster/autovacuum.c
M src/bin/pg_dump/pg_backup.h
M src/include/storage/pmsignal.h
M src/include/storage/procsignal.h

Fix some pg_verifybackup issues reported by Coverity.

commit   : fc1b2ce0ee9c9745c5c562b692e021344a3f719a    
  
author   : Robert Haas <[email protected]>    
date     : Tue, 1 Oct 2024 08:31:33 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Tue, 1 Oct 2024 08:31:33 -0400    

Click here for diff

Commit 8dfd3129027969fdd2d9d294220c867d2efd84aa introduced a few  
problems. verify_tar_file() forgot to free a buffer; the leak can't  
add up to anything material, but might as well fix it.  
precheck_tar_backup_file() intended to return after reporting an  
error but didn't actually do so. member_copy_control_data() could  
try to copy zero bytes (and maybe Coverity thinks it can even be  
trying to copy a negative number of bytes).  
  
Per discussion with Tom Lane.  
  
Discussion: http://postgr.es/m/[email protected]  

M src/bin/pg_verifybackup/astreamer_verify.c
M src/bin/pg_verifybackup/pg_verifybackup.c

Simplify checking for xlocale.h

commit   : 9c2a6c5a5f4b94a93120009e623ae8bd153e6dbb    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 07:16:04 -0400    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 07:16:04 -0400    

Click here for diff

Instead of XXX_IN_XLOCALE_H for several features XXX, let's just  
include <xlocale.h> if HAVE_XLOCALE_H.  The reason for the extra  
complication was apparently that some old glibc systems also had an  
<xlocale.h>, and you weren't supposed to include it directly, but it's  
gone now (as far as I can tell it was harmless to do so anyway).  
  
Author: Thomas Munro <[email protected]>  
Discussion: https://postgr.es/m/CWZBBRR6YA8D.8EHMDRGLCKCD%40neon.tech  

M config/c-library.m4
M configure
M configure.ac
M meson.build
M src/include/c.h
M src/include/pg_config.h.in
M src/include/utils/pg_locale.h
M src/interfaces/ecpg/ecpglib/ecpglib_extern.h
M src/port/chklocale.c

jit: Use opaque pointers in all supported LLVM versions.

commit   : ee4859123e3d47aef8cfe078f7faee2ebcecb613    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 05:05:51 -0400    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 05:05:51 -0400    

Click here for diff

LLVM's opaque pointer change began in LLVM 14, but remained optional  
until LLVM 16.  When commit 37d5babb added opaque pointer support, we  
didn't turn it on for LLVM 14 and 15 yet because we didn't want to risk  
weird bitcode incompatibility problems in released branches of  
PostgreSQL.  (That might have been overly cautious, I don't know.)  
  
Now that PostgreSQL 18 has dropped support for LLVM versions < 14, and  
since it hasn't been released yet and no extensions or bitcode have been  
built against it in the wild yet, we can be more aggressive.  We can rip  
out the support code and build system clutter that made opaque pointer  
use optional.  
  
Author: Thomas Munro <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Discussions: https://postgr.es/m/CA%2BhUKGLhNs5geZaVNj2EJ79Dx9W8fyWUU3HxcpZy55sMGcY%3DiA%40mail.gmail.com  

M configure
M configure.ac
M src/backend/jit/llvm/llvmjit.c
M src/backend/jit/llvm/meson.build
M src/include/jit/llvmjit_emit.h

jit: Require at least LLVM 14, if enabled.

commit   : 972c2cd2882b6dd7a2059d030d03e89dae47ede7    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 04:49:11 -0400    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 1 Oct 2024 04:49:11 -0400    

Click here for diff

Remove support for LLVM versions 10-13.  The default on all non-EOL'd  
OSes represented in our build farm will be at least LLVM 14 when  
PostgreSQL 18 ships.  
  
Author: Thomas Munro <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Discussion: https://postgr.es/m/CA%2BhUKGLhNs5geZaVNj2EJ79Dx9W8fyWUU3HxcpZy55sMGcY%3DiA%40mail.gmail.com  

M config/llvm.m4
M configure
M doc/src/sgml/installation.sgml
M meson.build
M src/backend/jit/llvm/llvmjit.c
M src/backend/jit/llvm/llvmjit_error.cpp
M src/backend/jit/llvm/llvmjit_inline.cpp
M src/backend/jit/llvm/llvmjit_wrap.cpp

doc: Mention the connstring key word for PGSERVICE

commit   : 1b4d52c3556b9abad10165ce7298062cf7eb7005    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Tue, 1 Oct 2024 10:20:14 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Tue, 1 Oct 2024 10:20:14 +0200    

Click here for diff

The documentation for the connection service file was mentioning  
the environment variable early but not the connection string key  
word until the last sentence and only then in an example.  This  
adds the keyword in the first paragraph to make it clearer  
  
Author: Dagfinn Ilmari Mannsåker <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/libpq.sgml

Fix race condition in COMMIT PREPARED causing orphaned 2PC files

commit   : cf4401fe6cf56811343edcad29c96086c2c66481    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 1 Oct 2024 15:44:03 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 1 Oct 2024 15:44:03 +0900    

Click here for diff

COMMIT PREPARED removes on-disk 2PC files near its end, but the state  
checked if a file is on-disk or not gets read from shared memory while  
not holding the two-phase state lock.  
  
Because of that, there was a small window where a second backend doing a  
PREPARE TRANSACTION could reuse the GlobalTransaction put back into the  
2PC free list by the COMMIT PREPARED, overwriting the "ondisk" flag read  
afterwards by the COMMIT PREPARED to decide if its on-disk two-phase  
state file should be removed, preventing the file deletion.  
  
This commit fixes this issue so as the "ondisk" flag in the  
GlobalTransaction is read while holding the two-phase state lock, not  
from shared memory after its entry has been added to the free list.  
  
Orphaned two-phase state files flushed to disk after a checkpoint are  
discarded at the beginning of recovery.  However, a truncation of  
pg_xact/ would make the startup process issue a FATAL when it cannot  
read the SLRU page holding the state of the transaction whose 2PC file  
was orphaned, which is a necessary step to decide if the 2PC file should  
be removed or not.  Removing manually the file would be necessary in  
this case.  
  
Issue introduced by effe7d9552dd, so backpatch all the way down.  
  
Mea culpa.  
  
Author: wuchengwen  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M src/backend/access/transam/twophase.c

Doc: replace unnecessary non-breaking space with ordinal space.

commit   : 3b1a377defcfc01d8a3f964e39aa652766ffc188    
  
author   : Tatsuo Ishii <[email protected]>    
date     : Tue, 1 Oct 2024 11:34:34 +0900    
  
committer: Tatsuo Ishii <[email protected]>    
date     : Tue, 1 Oct 2024 11:34:34 +0900    

Click here for diff

There were unnecessary non-breaking spaces (nbsp, U+00A0, 0xc2a0 in  
UTF-8) in the docs.  This commit replaces them with ASCII spaces  
(0x20).  
  
config.sgml is backpatched through 17.  
ref/drop_extension.sgml is backpatched through 13.  
  
Discussion: https://postgr.es/m/20240930.153404.202479334310259810.ishii%40postgresql.org  
Reviewed-by: Yugo Nagata, Daniel Gustafsson  
Backpatch-through: 17, 13  

M doc/src/sgml/config.sgml
M doc/src/sgml/ref/drop_extension.sgml

Expand assertion check for query ID reporting in executor

commit   : 5deb56387e3a1d08e1e62bed031258db267a0ab5    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 1 Oct 2024 08:56:21 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 1 Oct 2024 08:56:21 +0900    

Click here for diff

As formulated, the assertion added in the executor by 24f520594809 to  
check that a query ID is set had two problems:  
- track_activities may be disabled while compute_query_id is enabled,  
causing the query ID to not be reported to pg_stat_activity.  
- debug_query_string may not be set in some context.  The only path  
where this would matter is visibly autovacuum, should parallel workers  
be enabled there at some point.  This is not the case currently.  
  
There was no test showing the interactions between the query ID and  
track_activities, so let's add one based on a scan of pg_stat_activity.  
This assertion is still an experimentation at this stage, but let's see  
if this shows more paths where query IDs are not properly set while they  
should.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/execMain.c
M src/test/regress/expected/guc.out
M src/test/regress/sql/guc.sql

Add missing command for pg_maintain in comment

commit   : 102de3be73345a8de443355e055c10762b08cc4c    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Tue, 1 Oct 2024 00:01:32 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Tue, 1 Oct 2024 00:01:32 +0200    

Click here for diff

The comment in pg_class_aclmask_ext() which lists the allowed commands  
for the pg_maintain role lacked LOCK TABLE.  
  
Reported-by: Yusuke Sugie <[email protected]>  
Reviewed-by: Yugo Nagata <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/catalog/aclchk.c

Do not treat \. as an EOF marker in CSV mode for COPY IN.

commit   : 7702337489810f645b3501d99215c2b525c5abca    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 30 Sep 2024 17:57:12 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 30 Sep 2024 17:57:12 -0400    

Click here for diff

Since backslash is (typically) not special in CSV data, we should  
not be treating \. as special either.  The server historically did  
this to keep CSV and TEXT modes more alike and to support V2 protocol;  
but V2 protocol is long dead, and the inconsistency with CSV standards  
is annoying.  Remove that behavior in CopyReadLineText, and make some  
minor consequent code simplifications.  
  
On the client side, we need to fix psql so that it does not check  
for \. except when reading data from STDIN (that is, the script  
source).  We must do that regardless of TEXT/CSV mode or there is  
no way to end the COPY short of script EOF.  Also, be careful  
not to send the \. to the server in that case.  
  
This is a small compatibility break in that other applications  
beside psql may need similar adjustment.  Also, using an older  
version of psql with a v18 server may result in misbehavior  
during CSV-mode COPY IN.  
  
Daniel Vérité, reviewed by vignesh C, Robert Haas, and myself  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/libpq.sgml
M doc/src/sgml/protocol.sgml
M doc/src/sgml/ref/copy.sgml
M doc/src/sgml/ref/psql-ref.sgml
M src/backend/commands/copyfromparse.c
M src/backend/commands/copyto.c
M src/bin/psql/copy.c
M src/test/regress/expected/copy.out
M src/test/regress/sql/copy.sql

docs: Enhance the pg_stat_checkpointer view documentation.

commit   : a19f83f87966f763991cc76404f8e42a36e7e842    
  
author   : Fujii Masao <[email protected]>    
date     : Tue, 1 Oct 2024 01:55:45 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Tue, 1 Oct 2024 01:55:45 +0900    

Click here for diff

This commit updates the documentation for the pg_stat_checkpointer view  
to clarify what kind of checkpoints or restartpoints each counter tracks.  
This makes it easier to understand the meaning of each counter.  
  
Previously, the num_requested description included "backend,"  
which could be misleading since requests come from other sources as well.  
This commit also removes "backend" from the description of num_requested,  
to avoid confusion.  
  
Author: Fujii Masao  
Reviewed-by: Anton A. Melnikov  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/monitoring.sgml

Remove incorrect entries in pg_walsummary's getopt_long call.

commit   : 04c64e3fb35af090c249303b9df0a311f2a07593    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 30 Sep 2024 12:06:54 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 30 Sep 2024 12:06:54 -0400    

Click here for diff

For some reason this listed "-f" and "-w" as valid switches, though  
the code doesn't implement any such thing nor do the docs mention  
them.  The effect of this was that if you tried to use one of these  
switches, you'd get an unhelpful error message.  
  
Yusuke Sugie  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_walsummary/pg_walsummary.c

Don't disallow DROP of constraints ONLY on partitioned tables

commit   : 4dea33ce765d65d8807d343ca6535a3d067a63da    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 30 Sep 2024 11:58:13 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 30 Sep 2024 11:58:13 +0200    

Click here for diff

This restriction seems to have come about due to some fuzzy thinking: in  
commit 9139aa19423b we were adding a restriction against ADD constraint  
ONLY on partitioned tables (which is sensible) and apparently we thought  
the DROP case had to be symmetrical.  However, it isn't, and the  
comments about it are mistaken about the effect it would have.  Remove  
this limitation.  
  
There have been no reports of users bothered by this limitation, so I'm  
not backpatching it just yet.  We can revisit this decision later, as needed.  
  
Reviewed-by: Amit Langote <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  
	(about commit 9139aa19423b, previously not registered)  

M doc/src/sgml/ref/alter_table.sgml
M src/backend/commands/tablecmds.c
M src/test/regress/expected/alter_table.out
M src/test/regress/sql/alter_table.sql

Bump catalog version for change in VariableSetStmt

commit   : 4c7cd07aa62abc29e6885e95b5307e5e08bb3bf7    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 30 Sep 2024 14:52:03 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 30 Sep 2024 14:52:03 +0900    

Click here for diff

Oversight in dc68515968e8, as this breaks SQL functions with a SET  
command.  
  
Reported-by: Tom Lane  
Discussion: https://postgr.es/m/[email protected]  

M src/include/catalog/catversion.h

Show values of SET statements as constants in pg_stat_statements

commit   : dc68515968e80d75f8106d0df05da346be537628    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 30 Sep 2024 14:02:00 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 30 Sep 2024 14:02:00 +0900    

Click here for diff

This is a continuation of work like 11c34b342bd7, done to reduce the  
bloat of pg_stat_statements by applying more normalization to query  
entries.  This commit is able to detect and normalize values in  
VariableSetStmt, resulting in:  
SET conf_param = $1  
  
Compared to other parse nodes, VariableSetStmt is embedded in much more  
places in the parser, impacting many query patterns in  
pg_stat_statements.  A custom jumble function is used, with an extra  
field in the node to decide if arguments should be included in the  
jumbling or not, a location field being not enough for this purpose.  
This approach allows for a finer tuning.  
  
Clauses relying on one or more keywords are not normalized, for example:  
* DEFAULT  
* FROM CURRENT  
* List of keywords.  SET SESSION CHARACTERISTICS AS TRANSACTION,  
where it is critical to differentiate different sets of options, is a  
good example of why normalization should not happen.  
  
Some queries use VariableSetStmt for some subclauses with SET, that also  
have their values normalized:  
- ALTER DATABASE  
- ALTER ROLE  
- ALTER SYSTEM  
- CREATE/ALTER FUNCTION  
  
ba90eac7a995 has added test coverage for most of the existing SET  
patterns.  The expected output of these tests shows the difference this  
commit creates.  Normalization could be perhaps applied to more portions  
of the grammar but what is done here is conservative, and good enough as  
a starting point.  
  
Author: Greg Sabino Mullane, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/CAKAnmmJtJY2jzQN91=2QAD2eAJAA-Per61eyO48-TyxEg-q0Rg@mail.gmail.com  

M contrib/pg_stat_statements/expected/dml.out
M contrib/pg_stat_statements/expected/level_tracking.out
M contrib/pg_stat_statements/expected/utility.out
M contrib/pg_stat_statements/expected/wal.out
M src/backend/nodes/queryjumblefuncs.c
M src/backend/parser/gram.y
M src/include/nodes/parsenodes.h

Add num_done counter to the pg_stat_checkpointer view.

commit   : 559efce1d684069acf234a5cb032acba84e70938    
  
author   : Fujii Masao <[email protected]>    
date     : Mon, 30 Sep 2024 11:56:05 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Mon, 30 Sep 2024 11:56:05 +0900    

Click here for diff

Checkpoints can be skipped when the server is idle. The existing num_timed and  
num_requested counters in pg_stat_checkpointer track both completed and  
skipped checkpoints, but there was no way to count only the completed ones.  
  
This commit introduces the num_done counter, which tracks only completed  
checkpoints, making it easier to see how many were actually performed.  
  
Bump catalog version.  
  
Author: Anton A. Melnikov  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/monitoring.sgml
M src/backend/access/transam/xlog.c
M src/backend/catalog/system_views.sql
M src/backend/postmaster/checkpointer.c
M src/backend/utils/activity/pgstat_checkpointer.c
M src/backend/utils/adt/pgstatfuncs.c
M src/include/access/xlog.h
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/include/pgstat.h
M src/test/regress/expected/rules.out

reindexdb: Skip reindexing temporary tables and indexes.

commit   : 20cfec896c6a20ca436f634b0ffa3582d7b9425c    
  
author   : Fujii Masao <[email protected]>    
date     : Mon, 30 Sep 2024 11:13:55 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Mon, 30 Sep 2024 11:13:55 +0900    

Click here for diff

Reindexing temp tables or indexes of other sessions is not allowed.  
However, reindexdb in parallel mode previously listed them as  
the objects to process, leading to failures.  
  
This commit ensures reindexdb in parallel mode skips temporary tables  
and indexes by adding a condition based on the relpersistence column  
in pg_class to the object listing queries, preventing these issues.  
  
Note that this commit does not affect reindexdb when temporary tables  
or indexes are explicitly specified using the -t or -j options;  
reindexdb in that case still does not skip them and can cause an error.  
  
Back-patch to v13 where parallel mode was introduced in reindexdb.  
  
Author: Fujii Masao  
Reviewed-by: Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/scripts/reindexdb.c

Set query ID in parallel workers for vacuum, BRIN and btree

commit   : 6fd5071909a2886c499871e61127f815fd9bb6a2    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 30 Sep 2024 08:43:28 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 30 Sep 2024 08:43:28 +0900    

Click here for diff

All these code paths use their own entry point when starting parallel  
workers, but failed to set a query ID, even if they set a text query.  
Hence, this data would be missed in pg_stat_activity for the worker  
processes.  The main entry point for parallel query processing,  
ParallelQueryMain(), is already doing that by saving its query ID in a  
dummy PlannedStmt, but not the others.  The code is changed so as the  
query ID of these queries is set in their shared state, and reported  
back once the parallel workers start.  
  
Some tests are added to show how the failures can happen for btree and  
BRIN with a parallel build enforced, which are able to trigger a failure  
in an assertion added by 24f520594809 in the recovery TAP test  
027_stream_regress.pl where pg_stat_statements is always loaded.  In  
this case, the executor path was taken because the index expression  
needs to be flattened when building its IndexInfo.  
  
Alexander Lakhin has noticed the problem in btree, and I have noticed  
that the issue was more spread.  This is arguably a bug, but nobody has  
complained about that until now, so no backpatch is done out of caution.  
If folks would like to see a backpatch, well, let me know.  
  
Reported-by: Alexander Lakhin  
Reviewed-by: Sami Imseih  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/brin/brin.c
M src/backend/access/nbtree/nbtsort.c
M src/backend/commands/vacuumparallel.c
M src/test/regress/expected/brin.out
M src/test/regress/expected/btree_index.out
M src/test/regress/sql/brin.sql
M src/test/regress/sql/btree_index.sql

Remove NULL dereference from RenameRelationInternal().

commit   : 0d5a3d7574f8dabcbc229c2a06a9cb2d9a43c7c5    
  
author   : Noah Misch <[email protected]>    
date     : Sun, 29 Sep 2024 15:54:25 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sun, 29 Sep 2024 15:54:25 -0700    

Click here for diff

Defect in last week's commit aac2c9b4fde889d13f859c233c2523345e72d32b,  
per Coverity.  Reaching this would need catalog corruption.  Back-patch  
to v12, like that commit.  

M src/backend/commands/tablecmds.c

In passwordFromFile, don't leak the open file after stat failures.

commit   : e9339782a631eeef01281bc7e1633dd6b970106e    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 29 Sep 2024 13:40:03 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 29 Sep 2024 13:40:03 -0400    

Click here for diff

Oversight in e882bcae0.  Per Coverity.  

M src/interfaces/libpq/fe-connect.c

Avoid 037_invalid_database.pl hang under debug_discard_caches.

commit   : c1ff2d8bc5be55e302731a16aaff563b7f03ed7c    
  
author   : Noah Misch <[email protected]>    
date     : Fri, 27 Sep 2024 15:28:56 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Fri, 27 Sep 2024 15:28:56 -0700    

Click here for diff

Back-patch to v12 (all supported versions).  

M src/test/recovery/t/037_invalid_database.pl

doc: Note that CREATE MATERIALIZED VIEW restricts search_path.

commit   : d8ebcac547d7c25c1378e0fc5810528f343ab8d5    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 27 Sep 2024 16:21:21 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 27 Sep 2024 16:21:21 -0500    

Click here for diff

Since v17, CREATE MATERIALIZED VIEW has set search_path to  
"pg_catalog, pg_temp" while running the query.  The docs for the  
other commands that restrict search_path mention it, but the page  
for CREATE MATERIALIZED VIEW does not.  Fix that.  
  
Oversight in commit 4b74ebf726.  
  
Author: Yugo Nagata  
Reviewed-by: Jeff Davis  
Discussion: https://postgr.es/m/20240805160502.d2a4975802a832b1e04afb80%40sraoss.co.jp  
Backpatch-through: 17  

M doc/src/sgml/ref/create_materialized_view.sgml

Recalculate where-needed data accurately after a join removal.

commit   : a3179ab692be4314d5ee5cd56598976c487d5ef2    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 27 Sep 2024 16:04:04 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 27 Sep 2024 16:04:04 -0400    

Click here for diff

Up to now, remove_rel_from_query() has done a pretty shoddy job  
of updating our where-needed bitmaps (per-Var attr_needed and  
per-PlaceHolderVar ph_needed relid sets).  It removed direct mentions  
of the to-be-removed baserel and outer join, which is the minimum  
amount of effort needed to keep the data structures self-consistent.  
But it didn't account for the fact that the removed join ON clause  
probably mentioned Vars of other relations, and those Vars might now  
not be needed as high up in the join tree as before.  It's easy to  
show cases where this results in failing to remove a lower outer join  
that could also have been removed.  
  
To fix, recalculate the where-needed bitmaps from scratch after  
each successful join removal.  This sounds expensive, but it seems  
to add only negligible planner runtime.  (We cheat a little bit  
by preserving "relation 0" entries in the bitmaps, allowing us to  
skip re-scanning the targetlist and HAVING qual.)  
  
The submitted test case drew attention because we had successfully  
optimized away the lower join prior to v16.  I suspect that that's  
somewhat accidental and there are related cases that were never  
optimized before and now can be.  I've not tried to come up with  
one, though.  
  
Perhaps we should back-patch this into v16 and v17 to repair the  
performance regression.  However, since it took a year for anyone  
to notice the problem, it can't be affecting too many people.  Let's  
let the patch bake awhile in HEAD, and see if we get more complaints.  
  
Per bug #18627 from Mikaël Gourlaouen.  No back-patch for now.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/optimizer/path/equivclass.c
M src/backend/optimizer/plan/analyzejoins.c
M src/backend/optimizer/plan/initsplan.c
M src/backend/optimizer/util/placeholder.c
M src/include/optimizer/paths.h
M src/include/optimizer/placeholder.h
M src/include/optimizer/planmain.h
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Reindent pg_verifybackup.c.

commit   : 7f7474a8e4002ac9fd4979cc7b16b50b70b70c28    
  
author   : Robert Haas <[email protected]>    
date     : Fri, 27 Sep 2024 11:14:31 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Fri, 27 Sep 2024 11:14:31 -0400    

Click here for diff

M src/bin/pg_verifybackup/pg_verifybackup.c

pg_verifybackup: Verify tar-format backups.

commit   : 8dfd3129027969fdd2d9d294220c867d2efd84aa    
  
author   : Robert Haas <[email protected]>    
date     : Fri, 27 Sep 2024 08:40:24 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Fri, 27 Sep 2024 08:40:24 -0400    

Click here for diff

This also works for compressed tar-format backups. However, -n must be  
used, because we use pg_waldump to verify WAL, and it doesn't yet know  
how to verify WAL that is stored inside of a tarfile.  
  
Amul Sul, reviewed by Sravan Kumar and by me, and revised by me.  

M doc/src/sgml/ref/pg_verifybackup.sgml
M src/bin/pg_verifybackup/Makefile
A src/bin/pg_verifybackup/astreamer_verify.c
M src/bin/pg_verifybackup/meson.build
M src/bin/pg_verifybackup/pg_verifybackup.c
M src/bin/pg_verifybackup/pg_verifybackup.h
M src/bin/pg_verifybackup/t/002_algorithm.pl
M src/bin/pg_verifybackup/t/003_corruption.pl
M src/bin/pg_verifybackup/t/004_options.pl
M src/bin/pg_verifybackup/t/008_untar.pl
M src/bin/pg_verifybackup/t/010_client_untar.pl
M src/fe_utils/simple_list.c
M src/include/fe_utils/simple_list.h
M src/tools/pgindent/typedefs.list

Fix typo in pg_walsummary/nls.mk.

commit   : 8410f738ad2fd94fc068ce0189e1ae04ef3c12e3    
  
author   : Fujii Masao <[email protected]>    
date     : Fri, 27 Sep 2024 10:20:22 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Fri, 27 Sep 2024 10:20:22 +0900    

Click here for diff

Author: Koki Nakamura  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_walsummary/nls.mk

Fix incorrect memory access in VACUUM FULL with invalid toast indexes

commit   : 09620ea09121b66e9372e8e9244d8bb6b19b89d7    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 27 Sep 2024 09:40:09 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 27 Sep 2024 09:40:09 +0900    

Click here for diff

An invalid toast index is skipped in reindex_relation().  These would be  
remnants of a failed REINDEX CONCURRENTLY and they should never been  
rebuilt as there can only be one valid toast index at a time.  
  
REINDEX_REL_SUPPRESS_INDEX_USE, used by CLUSTER and VACUUM FULL, needs  
to maintain a list of the indexes being processed.  The list of indexes  
is retrieved from the relation cache, and includes invalid indexes.  The  
code has missed that invalid toast indexes are ignored in  
reindex_relation() as this leads to a hard failure in reindex_index(),  
and they were left in the reindex pending list, making the list  
inconsistent when rechecked.  The incorrect memory access was happening  
when scanning pg_class for the refresh of pg_database.datfrozenxid, when  
doing a scan of pg_class.  
  
This issue exists since REINDEX CONCURRENTLY exists, where invalid toast  
indexes can exist, so backpatch all the way down.  
  
Reported-by: Alexander Lakhin  
Author: Tender Wang  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 12  

M src/backend/catalog/index.c

Fix catalog data of new LO privilege functions

commit   : f762d99c8783f5ca99d5a6ab0f8245e164a954ce    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 27 Sep 2024 07:26:29 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 27 Sep 2024 07:26:29 +0900    

Click here for diff

This commit improves the catalog data in pg_proc for the three functions  
for has_largeobject_privilege(), introduced in 4eada203a5a8:  
- Fix their descriptions (typos and consistency).  
- Reallocate OIDs to be within the 8000-9999 range as required by  
a6417078c414.  
  
Bump catalog version.  
  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat

Ensure we have a snapshot when updating pg_index entries.

commit   : b52adbad46740524cbfbffaeb202b01a2c16202a    
  
author   : Nathan Bossart <[email protected]>    
date     : Thu, 26 Sep 2024 15:51:23 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Thu, 26 Sep 2024 15:51:23 -0500    

Click here for diff

Creating, reindexing, and dropping an index concurrently could  
entail accessing pg_index's TOAST table, which was recently added  
in commit b52c4fc3c0.  These code paths start and commit their own  
transactions, but they do not always set an active snapshot.  This  
rightfully leads to assertion failures and ERRORs when trying to  
access pg_index's TOAST table, such as the following:  
  
	ERROR:  cannot fetch toast data without an active snapshot  
  
To fix, push an active snapshot just before each section of code  
that might require accessing pg_index's TOAST table, and pop it  
shortly afterwards.  
  
Reported-by: Alexander Lakhin  
Reviewed-by: Michael Paquier  
Discussion: https://postgr.es/m/a97d7401-e7c9-f771-6a00-037379f0a8bb%40gmail.com  

M src/backend/catalog/index.c
M src/backend/commands/indexcmds.c
M src/test/regress/expected/indexing.out
M src/test/regress/sql/indexing.sql

Improve style of pg_upgrade task callback functions.

commit   : 9726653185de62f2f8bf42a25e961bc56895a41b    
  
author   : Nathan Bossart <[email protected]>    
date     : Thu, 26 Sep 2024 13:54:37 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Thu, 26 Sep 2024 13:54:37 -0500    

Click here for diff

I wanted to avoid adjusting this code too much when converting  
these tasks to use the new parallelization framework (see commit  
40e2e5e92b), which is why this is being done as a follow-up commit.  
These stylistic adjustments result in fewer lines of code and fewer  
levels of indentation in some places.  
  
While at it, add names to the UpgradeTaskSlotState enum and the  
UpgradeTaskSlot struct.  I'm not aware of any established project  
policy in this area, but let's at least be consistent within the  
same file.  
  
Reviewed-by: Daniel Gustafsson  
Discussion: https://postgr.es/m/ZunW7XHLd2uTts4f%40nathan  

M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/task.c
M src/bin/pg_upgrade/version.c

Modernize to_char's Roman-numeral code, fixing overflow problems.

commit   : 147bbc90f75794e5522dcbadaf2bbe1af3ce574a    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 26 Sep 2024 11:02:31 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 26 Sep 2024 11:02:31 -0400    

Click here for diff

int_to_roman() only accepts plain "int" input, which is fine since  
we're going to produce '###############' for any value above 3999  
anyway.  However, the numeric and int8 variants of to_char() would  
throw an error if the given input exceeded the integer range, while  
the float-input variants invoked undefined-per-C-standard behavior.  
Fix things so that you uniformly get '###############' for out of  
range input.  
  
Also add test cases covering this code, plus the equally-untested  
EEEE, V, and PL format codes.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml
M src/backend/utils/adt/formatting.c
M src/test/regress/expected/int8.out
M src/test/regress/expected/numeric.out
M src/test/regress/sql/int8.sql
M src/test/regress/sql/numeric.sql

Doc: InitPlans aren't parallel-restricted any more.

commit   : e3a92ab0708aa8ac0c8466312cef316ea6d03c63    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 26 Sep 2024 10:37:51 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 26 Sep 2024 10:37:51 -0400    

Click here for diff

Commit e08d74ca1 removed that restriction, but missed updating  
the documentation about it.  Noted by Egor Rogov.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/parallel.sgml

Doc: Add a note in the upgrade of logical replication clusters.

commit   : d66572d9fedb632af5df65ce513d04dc2a1682a3    
  
author   : Amit Kapila <[email protected]>    
date     : Thu, 26 Sep 2024 16:14:07 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Thu, 26 Sep 2024 16:14:07 +0530    

Click here for diff

The steps used to upgrade the cluster first upgraded the publisher node  
but ideally, any node could be upgraded first.  
  
Author: Vignesh C  
Discussion: https://postgr.es/m/CALDaNm1_iDO6srWzntqTr0ZDVkk2whVhNKEWAvtgZBfSmuBeZQ@mail.gmail.com  
Discussion: https://postgr.es/m/CALDaNm3Y-M+kAqr_mf=_C1kNwAB-cS6S5hTHnKMEqDw4sGEh4Q@mail.gmail.com  

M doc/src/sgml/logical-replication.sgml

Update oid for pg_wal_replay_wait() procedure

commit   : e658038772f59588c8be8b016c8a7e28e7705ab4    
  
author   : Alexander Korotkov <[email protected]>    
date     : Thu, 26 Sep 2024 11:48:23 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Thu, 26 Sep 2024 11:48:23 +0300    

Click here for diff

Use an oid from 8000-9999 range, as required by 98eab30b93d5.  
  
Reported-by: Michael Paquier  
Discussion: https://postgr.es/m/ZvUY6bfTwB0GsyzP%40paquier.xyz  

M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat

Remove extra whitespace in pg_upgrade status message.

commit   : 2ceeb638b7b27da156c10cb9d5ea4f81cabda0d1    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 25 Sep 2024 11:18:56 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 25 Sep 2024 11:18:56 -0500    

Click here for diff

There's no need to add another level of indentation to this status  
message.  pg_log() will put it in the right place.  
  
Oversight in commit 347758b120.  
  
Reviewed-by: Daniel Gustafsson  
Discussion: https://postgr.es/m/ZunW7XHLd2uTts4f%40nathan  
Backpatch-through: 17  

M src/bin/pg_upgrade/check.c

Turn 'if' condition around to avoid Svace complaint

commit   : dce507356a4ab7d548dca9d7abf1800a0fc0a18e    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 25 Sep 2024 16:42:02 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 25 Sep 2024 16:42:02 +0200    

Click here for diff

The unwritten assumption of this code is that both events->head and  
events->tail are NULL together (an empty list) or they aren't.  So the  
code was testing events->head for nullness and using that as a cue to  
deference events->tail, which annoys the Svace static code analyzer.  
We can silence it by testing events->tail member instead, and add an  
assertion about events->head to ensure it's all consistent.  
  
This code is very old and as far as we know, there's never been a bug  
report related to this, so there's no need to backpatch.  
  
This was found by the ALT Linux Team using Svace.  
  
Author: Alexander Kuznetsov <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/trigger.c

vacuumdb: Skip temporary tables in query to build list of relations

commit   : 1ab67c9dfaadda86059f405e5746efb6ddb9fe21    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 25 Sep 2024 14:43:16 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 25 Sep 2024 14:43:16 +0900    

Click here for diff

Running vacuumdb with a non-superuser while another user has created a  
temporary table would lead to a mid-flight permission failure,  
interrupting the operation.  vacuum_rel() skips temporary relations of  
other backends, and it makes no sense for vacuumdb to know about these  
relations, so let's switch it to ignore temporary relations entirely.  
  
Adding a qual in the query based on relpersistence simplifies the  
generation of its WHERE clause in vacuum_one_database(), per se the  
removal of "has_where".  
  
Author: VaibhaveS, Michael Paquier  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/CAM_eQjwfAR=y3G1fGyS1U9FTmc+FyJm9amNfY2QCZBnDDbNPZg@mail.gmail.com  
Backpatch-through: 12  

M src/bin/scripts/vacuumdb.c

Doc: Add the steps for upgrading the logical replication cluster.

commit   : 7fdeaf5774d05245e82632e763665ff62db5598e    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 25 Sep 2024 10:06:10 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 25 Sep 2024 10:06:10 +0530    

Click here for diff

Author: Vignesh C  
Reviewed-by: Peter Smith, Amit Kapila, Hayato Kuroda, Bharath Rupireddy  
Discussion: https://postgr.es/m/CALDaNm1_iDO6srWzntqTr0ZDVkk2whVhNKEWAvtgZBfSmuBeZQ@mail.gmail.com  

M doc/src/sgml/glossary.sgml
M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/ref/pgupgrade.sgml

pg_stat_statements: Expand tests for SET statements

commit   : ba90eac7a9953f6f6fa5e0a0cc7441d09778f8b9    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 25 Sep 2024 10:04:44 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 25 Sep 2024 10:04:44 +0900    

Click here for diff

There are many grammar flavors that depend on the parse node  
VariableSetStmt.  This closes the gap in pg_stat_statements by providing  
test coverage for what should be a large majority of them, improving more  
the work begun in de2aca288569.  This will be used to ease the  
evaluation of a path towards more normalization of SET queries with  
query jumbling.  
  
Note that SET NAMES (grammar from the standard, synonym of SET  
client_encoding) is omitted on purpose, this could use UTF8 with a  
conditional script where UTF8 is supported, but that does not seem worth  
the maintenance cost for the sake of these tests.  
  
The author has submitted most of these in a TAP test (filled in any  
holes I could spot), still queries in a SQL file of pg_stat_statements  
is able to achieve the same goal while being easier to look at when  
testing normalization patterns.  
  
Author: Greg Sabino Mullane, Michael Paquier  
Discussion: https://postgr.es/m/CAKAnmmJtJY2jzQN91=2QAD2eAJAA-Per61eyO48-TyxEg-q0Rg@mail.gmail.com  

M contrib/pg_stat_statements/expected/utility.out
M contrib/pg_stat_statements/sql/utility.sql

For inplace update durability, make heap_update() callers wait.

commit   : aac2c9b4fde889d13f859c233c2523345e72d32b    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    

Click here for diff

The previous commit fixed some ways of losing an inplace update.  It  
remained possible to lose one when a backend working toward a  
heap_update() copied a tuple into memory just before inplace update of  
that tuple.  In catalogs eligible for inplace update, use LOCKTAG_TUPLE  
to govern admission to the steps of copying an old tuple, modifying it,  
and issuing heap_update().  This includes MERGE commands.  To avoid  
changing most of the pg_class DDL, don't require LOCKTAG_TUPLE when  
holding a relation lock sufficient to exclude inplace updaters.  
Back-patch to v12 (all supported versions).  In v13 and v12, "UPDATE  
pg_class" or "UPDATE pg_database" can still lose an inplace update.  The  
v14+ UPDATE fix needs commit 86dc90056dfdbd9d1b891718d2e5614e3e432f35,  
and it wasn't worth reimplementing that fix without such infrastructure.  
  
Reviewed by Nitin Motiani and (in earlier versions) Heikki Linnakangas.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/README.tuplock
M src/backend/access/heap/heapam.c
M src/backend/access/index/genam.c
M src/backend/catalog/aclchk.c
M src/backend/catalog/catalog.c
M src/backend/commands/dbcommands.c
M src/backend/commands/event_trigger.c
M src/backend/commands/indexcmds.c
M src/backend/commands/tablecmds.c
M src/backend/executor/execMain.c
M src/backend/executor/execReplication.c
M src/backend/executor/nodeModifyTable.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/cache/syscache.c
M src/include/nodes/execnodes.h
M src/include/storage/lockdefs.h
M src/include/utils/syscache.h
M src/test/isolation/expected/intra-grant-inplace.out
M src/test/isolation/specs/eval-plan-qual.spec
M src/test/isolation/specs/intra-grant-inplace.spec

Fix data loss at inplace update after heap_update().

commit   : a07e03fd8fa7daf4d1356f7cb501ffe784ea6257    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    

Click here for diff

As previously-added tests demonstrated, heap_inplace_update() could  
instead update an unrelated tuple of the same catalog.  It could lose  
the update.  Losing relhasindex=t was a source of index corruption.  
Inplace-updating commands like VACUUM will now wait for heap_update()  
commands like GRANT TABLE and GRANT DATABASE.  That isn't ideal, but a  
long-running GRANT already hurts VACUUM progress more just by keeping an  
XID running.  The VACUUM will behave like a DELETE or UPDATE waiting for  
the uncommitted change.  
  
For implementation details, start at the systable_inplace_update_begin()  
header comment and README.tuplock.  Back-patch to v12 (all supported  
versions).  In back branches, retain a deprecated heap_inplace_update(),  
for extensions.  
  
Reported by Smolkin Grigory.  Reviewed by Nitin Motiani, (in earlier  
versions) Heikki Linnakangas, and (in earlier versions) Alexander  
Lakhin.  
  
Discussion: https://postgr.es/m/CAMp+ueZQz3yDk7qg42hk6-9gxniYbp-=bG2mgqecErqR5gGGOA@mail.gmail.com  

M src/backend/access/heap/README.tuplock
M src/backend/access/heap/heapam.c
M src/backend/access/index/genam.c
M src/backend/catalog/index.c
M src/backend/catalog/toasting.c
M src/backend/commands/dbcommands.c
M src/backend/commands/event_trigger.c
M src/backend/commands/vacuum.c
M src/include/access/genam.h
M src/include/access/heapam.h
M src/test/isolation/expected/intra-grant-inplace-db.out
M src/test/isolation/expected/intra-grant-inplace.out
M src/test/isolation/specs/intra-grant-inplace-db.spec
M src/test/isolation/specs/intra-grant-inplace.spec
M src/test/modules/injection_points/expected/inplace.out
M src/test/modules/injection_points/specs/inplace.spec

Warn if LOCKTAG_TUPLE is held at commit, under debug_assertions.

commit   : dbf3f974ee04d24547690268b1fc2b7eb12b4ebc    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 24 Sep 2024 15:25:18 -0700    

Click here for diff

The current use always releases this locktag.  A planned use will  
continue that intent.  It will involve more areas of code, making unlock  
omissions easier.  Warn under debug_assertions, like we do for various  
resource leaks.  Back-patch to v12 (all supported versions), the plan  
for the commit of the new use.  
  
Reviewed by Heikki Linnakangas.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/storage/lmgr/lock.c

Allow length=-1 for NUL-terminated input to pg_strncoll(), etc.

commit   : ac30021356e7aa05a069741d17c3db3e8d520933    
  
author   : Jeff Davis <[email protected]>    
date     : Tue, 24 Sep 2024 15:15:03 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Tue, 24 Sep 2024 15:15:03 -0700    

Click here for diff

Like ICU, allow a length of -1 to be specified for NUL-terminated  
arguments to pg_strncoll(), pg_strnxfrm(), and pg_strnxfrm_prefix().  
  
Simplifies the code and comments.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/pg_locale.c
M src/include/utils/pg_locale.h

Fix psql describe commands' handling of ACL columns for old servers.

commit   : 1591b38d17c55015403f6e3c9461538ffcf704e7    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 24 Sep 2024 17:21:38 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 24 Sep 2024 17:21:38 -0400    

Click here for diff

Commit d1379ebf4 carelessly broke printACLColumn for pre-9.4 servers,  
by using the cardinality() function which we introduced in 9.4.  
We expect psql's describe-related commands to work back to 9.2, so  
this is bad.  Use the longstanding array_length() function instead.  
  
Per report from Christoph Berg.  Back-patch to v17.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/psql/describe.c

Tighten up make_libc_collator() and make_icu_collator().

commit   : ceeaaed87aa39425f1f2c2409f927c76efb8de89    
  
author   : Jeff Davis <[email protected]>    
date     : Tue, 24 Sep 2024 12:01:45 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Tue, 24 Sep 2024 12:01:45 -0700    

Click here for diff

Ensure that error paths within these functions do not leak a collator,  
and return the result rather than using an out parameter. (Error paths  
in the caller may still result in a leaked collator, which will be  
addressed separately.)  
  
In make_libc_collator(), if the first newlocale() succeeds and the  
second one fails, close the first locale_t object.  
  
The function make_icu_collator() doesn't have any external callers, so  
change it to be static.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/pg_locale.c
M src/include/utils/pg_locale.h

Add further excludes to headerscheck

commit   : 59f0eea7b001e3f5d38fd84a9ee5482a23be56e2    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 24 Sep 2024 20:41:47 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 24 Sep 2024 20:41:47 +0200    

Click here for diff

Some header files under contrib/isn/ are not meant to be included  
independently, and they fail -Wmissing-variable-declarations when  
doing so.  
  
Reported-by: Thomas Munro <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/CA%2BhUKG%2BYVt5MBD-w0HyHpsGb4U8RNge3DvAbDmOFy_epGhZ2Mg%40mail.gmail.com#aba3226c6dd493923bd6ce95d25a2d77  

M src/tools/pginclude/headerscheck

commit   : cd838e200880c6f52c5b5e30887e5ff584876bef    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 24 Sep 2024 12:59:43 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 24 Sep 2024 12:59:43 -0400    

Click here for diff

When our XML-handling modules were first written, the SQL standard  
lacked any error codes that were particularly intended for XML  
error conditions.  Unsurprisingly, this led to some rather random  
choices of errcodes in those modules.  Now the standard has a whole  
SQLSTATE class, "Class 10 - XQuery Error", with a reasonably large  
selection of relevant-looking errcodes.  
  
In this patch I've chosen one fairly generic code defined by the  
standard, 10608 = invalid_argument_for_xquery, and used it where  
it seemed appropriate.  I've also made an effort to replace  
ERRCODE_INTERNAL_ERROR everywhere it was not clearly reporting  
a coding problem; in particular, many of the existing uses look  
like they can fairly be reported as ERRCODE_OUT_OF_MEMORY.  
  
It might be interesting to try to map libxml2's error codes into  
the standard's new collection, but I've not undertaken that here.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/xml2/xpath.c
M contrib/xml2/xslt_proc.c
M src/backend/utils/adt/xml.c
M src/backend/utils/errcodes.txt

Update obsolete nbtree array preprocessing comments.

commit   : 3da436ec09ae2f1a0167d4b74b30449f0292f581    
  
author   : Peter Geoghegan <[email protected]>    
date     : Tue, 24 Sep 2024 12:58:55 -0400    
  
committer: Peter Geoghegan <[email protected]>    
date     : Tue, 24 Sep 2024 12:58:55 -0400    

Click here for diff

The array->scan_key references fixed up at the end of preprocessing  
start out as offsets into the arrayKeyData[] array (the array returned  
by _bt_preprocess_array_keys at the start of preprocessing that involves  
array scan keys).  Offsets into the arrayKeyData[] array are no longer  
guaranteed to be valid offsets into our original scan->keyData[] input  
scan key array, but comments describing the array->scan_key references  
still talked about scan->keyData[].  Update those comments.  
  
Oversight in commit b5249741.  

M src/backend/access/nbtree/nbtutils.c

Add ONLY support for VACUUM and ANALYZE

commit   : 62ddf7ee9a399e0b9624412fc482ed7365e38958    
  
author   : David Rowley <[email protected]>    
date     : Tue, 24 Sep 2024 18:03:40 +1200    
  
committer: David Rowley <[email protected]>    
date     : Tue, 24 Sep 2024 18:03:40 +1200    

Click here for diff

Since autovacuum does not trigger an ANALYZE for partitioned tables,  
users must perform these manually.  However, performing a manual ANALYZE  
on a partitioned table would always result in recursively analyzing each  
partition and that could be undesirable as autovacuum takes care of that.  
For partitioned tables that contain a large number of partitions, having  
to analyze each partition could take an unreasonably long time, especially  
so for tables with a large number of columns.  
  
Here we allow the ONLY keyword to prefix the name of the table to allow  
users to have ANALYZE skip processing partitions.  This option can also  
be used with VACUUM, but there is no work to do if VACUUM ONLY is used on  
a partitioned table.  
  
This commit also changes the behavior of VACUUM	and ANALYZE for  
inheritance parents.  Previously inheritance child tables would not be  
processed when operating on the parent.  Now, by default we *do* operate  
on the child tables.  ONLY can be used to obtain the old behavior.  
The release notes should note this as an incompatibility.  The default  
behavior has not changed for partitioned tables as these always  
recursively processed the partitions.  
  
Author: Michael Harris <[email protected]>  
Discussion: https://postgr.es/m/CADofcAWATx_haD=QkSxHbnTsAe6+e0Aw8Eh4H8cXyogGvn_kOg@mail.gmail.com  
Discussion: https://postgr.es/m/CADofcAXVbD0yGp_EaC9chmzsOoSai3jcfBCnyva3j0RRdRvMVA@mail.gmail.com  
Reviewed-by: Jelte Fennema-Nio <[email protected]>  
Reviewed-by: Melih Mutlu <[email protected]>  
Reviewed-by: Atsushi Torikoshi <[email protected]>  
Reviewed-by: jian he <[email protected]>  
Reviewed-by: David Rowley <[email protected]>  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/monitoring.sgml
M doc/src/sgml/ref/analyze.sgml
M doc/src/sgml/ref/vacuum.sgml
M src/backend/commands/vacuum.c
M src/backend/parser/gram.y
M src/test/regress/expected/vacuum.out
M src/test/regress/sql/vacuum.sql

Remove ATT_TABLE for ALTER TABLE ... ATTACH/DETACH

commit   : bbba59e69a56e1622e270f5e47b402c3a904cefc    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 24 Sep 2024 08:59:08 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 24 Sep 2024 08:59:08 +0900    

Click here for diff

Attempting these commands for a non-partitioned table would result in a  
failure when creating the relation in transformPartitionCmd().  This  
gives the possibility to throw an error earlier with a much better error  
message, thanks to d69a3f4d70b7.  
  
The extra test cases are from me.  Note that FINALIZE uses a different  
subcommand and it had no coverage for its failure path with  
non-partitioned tables.  
  
Author: Álvaro Herrera, Michael Paquier  
Reviewed-by: Nathan Bossart  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/tablecmds.c
M src/test/regress/expected/alter_table.out
M src/test/regress/sql/alter_table.sql

jsonapi: fix memory leakage during OOM error recovery.

commit   : 75240f65e700d7d157be27653c70fe75108f25c1    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 23 Sep 2024 12:30:51 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 23 Sep 2024 12:30:51 -0400    

Click here for diff

Coverity pointed out that inc_lex_level() would leak memory  
(not to mention corrupt the pstack data structure) if some  
but not all of its three REALLOC's failed.  To fix, store  
successfully-updated pointers back into the pstack struct  
immediately.  
  
Oversight in 0785d1b8b, so no need for back-patch.  

M src/common/jsonapi.c

Fix asserts in fast-path locking code

commit   : a7e5237f268ea378c514635d65a55aa47621958a    
  
author   : Tomas Vondra <[email protected]>    
date     : Mon, 23 Sep 2024 11:37:12 +0200    
  
committer: Tomas Vondra <[email protected]>    
date     : Mon, 23 Sep 2024 11:37:12 +0200    

Click here for diff

Commit c4d5cb71d229 introduced a couple asserts in the fast-path locking  
code, upsetting Coverity.  
  
The assert in InitProcGlobal() is clearly wrong, as it assigns instead  
of checking the value. This is harmless, but doesn't check anything.  
  
The asserts in FAST_PATH_ macros are written as if for signed values,  
but the macros are only called for unsigned ones. That makes the check  
for (val >= 0) useless. Checks written as ((uint32) x < max) work for  
both signed and unsigned values. Negative values should wrap to values  
greater than INT32_MAX.  
  
Per Coverity, report by Tom Lane.  
  
Reported-by: Tom Lane  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/storage/lmgr/lock.c
M src/backend/storage/lmgr/proc.c

Add memory/disk usage for more executor nodes.

commit   : 40708acd65c112149493d7159ca5c5a9391c9d35    
  
author   : Tatsuo Ishii <[email protected]>    
date     : Mon, 23 Sep 2024 16:34:24 +0900    
  
committer: Tatsuo Ishii <[email protected]>    
date     : Mon, 23 Sep 2024 16:34:24 +0900    

Click here for diff

This commit is similar to 95d6e9af07, expanding the idea to CTE scan,  
table function scan and recursive union scan nodes so that the maximum  
tuplestore memory or disk usage is shown with EXPLAIN ANALYZE command.  
  
Also adjust show_storage_info() so that it accepts storage type and  
storage size arguments instead of Tuplestorestate. This allows the  
node types to share the formatting code using show_storage_info(). Due  
to this show_material_info() and show_windowagg_info() are also  
modified.  
  
Reviewed-by: David Rowley  
Discussion: https://postgr.es/m/20240918.211246.1127161704188186085.ishii%40postgresql.org  

M src/backend/commands/explain.c

Remove pg_authid's TOAST table.

commit   : 6aa44060a3c94ee10273bb8a89e98a5bb2fbbacb    
  
author   : Nathan Bossart <[email protected]>    
date     : Sat, 21 Sep 2024 15:17:46 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Sat, 21 Sep 2024 15:17:46 -0500    

Click here for diff

pg_authid's only varlena column is rolpassword, which unfortunately  
cannot be de-TOASTed during authentication because we haven't  
selected a database yet and cannot read pg_class.  By removing  
pg_authid's TOAST table, attempts to set password hashes that  
require out-of-line storage will fail with a "row is too big"  
error instead.  We may want to provide a more user-friendly error  
in the future, but for now let's just remove the useless TOAST  
table.  
  
Bumps catversion.  
  
Reported-by: Alexander Lakhin  
Reviewed-by: Tom Lane, Michael Paquier  
Discussion: https://postgr.es/m/89e8649c-eb74-db25-7945-6d6b23992394%40gmail.com  

M src/backend/catalog/catalog.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_authid.h
M src/test/regress/expected/create_index.out
M src/test/regress/expected/misc_sanity.out
M src/test/regress/expected/tablespace.out
M src/test/regress/sql/create_index.sql
M src/test/regress/sql/misc_sanity.sql
M src/test/regress/sql/tablespace.sql

Increase the number of fast-path lock slots

commit   : c4d5cb71d229095a39fda1121a75ee40e6069a2a    
  
author   : Tomas Vondra <[email protected]>    
date     : Sat, 21 Sep 2024 20:06:49 +0200    
  
committer: Tomas Vondra <[email protected]>    
date     : Sat, 21 Sep 2024 20:06:49 +0200    

Click here for diff

Replace the fixed-size array of fast-path locks with arrays, sized on  
startup based on max_locks_per_transaction. This allows using fast-path  
locking for workloads that need more locks.  
  
The fast-path locking introduced in 9.2 allowed each backend to acquire  
a small number (16) of weak relation locks cheaply. If a backend needs  
to hold more locks, it has to insert them into the shared lock table.  
This is considerably more expensive, and may be subject to contention  
(especially on many-core systems).  
  
The limit of 16 fast-path locks was always rather low, because we have  
to lock all relations - not just tables, but also indexes, views, etc.  
For planning we need to lock all relations that might be used in the  
plan, not just those that actually get used in the final plan. So even  
with rather simple queries and schemas, we often need significantly more  
than 16 locks.  
  
As partitioning gets used more widely, and the number of partitions  
increases, this limit is trivial to hit. Complex queries may easily use  
hundreds or even thousands of locks. For workloads doing a lot of I/O  
this is not noticeable, but for workloads accessing only data in RAM,  
the access to the shared lock table may be a serious issue.  
  
This commit removes the hard-coded limit of the number of fast-path  
locks. Instead, the size of the fast-path arrays is calculated at  
startup, and can be set much higher than the original 16-lock limit.  
The overall fast-path locking protocol remains unchanged.  
  
The variable-sized fast-path arrays can no longer be part of PGPROC, but  
are allocated as a separate chunk of shared memory and then references  
from the PGPROC entries.  
  
The fast-path slots are organized as a 16-way set associative cache. You  
can imagine it as a hash table of 16-slot "groups". Each relation is  
mapped to exactly one group using hash(relid), and the group is then  
processed using linear search, just like the original fast-path cache.  
With only 16 entries this is cheap, with good locality.  
  
Treating this as a simple hash table with open addressing would not be  
efficient, especially once the hash table gets almost full. The usual  
remedy is to grow the table, but we can't do that here easily. The  
access would also be more random, with worse locality.  
  
The fast-path arrays are sized using the max_locks_per_transaction GUC.  
We try to have enough capacity for the number of locks specified in the  
GUC, using the traditional 2^n formula, with an upper limit of 1024 lock  
groups (i.e. 16k locks). The default value of max_locks_per_transaction  
is 64, which means those instances will have 64 fast-path slots.  
  
The main purpose of the max_locks_per_transaction GUC is to size the  
shared lock table. It is often set to the "average" number of locks  
needed by backends, with some backends using significantly more locks.  
This should not be a major issue, however. Some backens may have to  
insert locks into the shared lock table, but there can't be too many of  
them, limiting the contention.  
  
The only solution is to increase the GUC, even if the shared lock table  
already has sufficient capacity. That is not free, especially in terms  
of memory usage (the shared lock table entries are fairly large). It  
should only happen on machines with plenty of memory, though.  
  
In the future we may consider a separate GUC for the number of fast-path  
slots, but let's try without one first.  
  
Reviewed-by: Robert Haas, Jakub Wartak  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/bootstrap/bootstrap.c
M src/backend/postmaster/postmaster.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/lmgr/lock.c
M src/backend/storage/lmgr/proc.c
M src/backend/tcop/postgres.c
M src/backend/utils/init/postinit.c
M src/include/miscadmin.h
M src/include/storage/proc.h

Refactor handling of nbtree array redundancies.

commit   : b524974106acb05ae4f9c2178153c3ead72eaf04    
  
author   : Peter Geoghegan <[email protected]>    
date     : Sat, 21 Sep 2024 13:25:49 -0400    
  
committer: Peter Geoghegan <[email protected]>    
date     : Sat, 21 Sep 2024 13:25:49 -0400    

Click here for diff

Teach _bt_preprocess_array_keys to eliminate redundant array equality  
scan keys directly, rather than just marking them as redundant.  Its  
_bt_preprocess_keys caller is no longer required to ignore input scan  
keys that were marked redundant in this way.  Oversights like the one  
fixed by commit f22e17f7 are no longer possible.  
  
The new scheme also makes it easier for _bt_preprocess_keys to output a  
so.keyData[] scan key array with _more_ scan keys than it was passed in  
its scan.keyData[] input scan key array.  An upcoming patch that adds  
skip scan optimizations to nbtree will take advantage of this.  
  
In passing, remove and rename certain _bt_preprocess_keys variables to  
make the difference between our input scan key array and our output scan  
key array clearer.  
  
Author: Peter Geoghegan <[email protected]>  
Reviewed-By: Tomas Vondra <[email protected]>  
Discussion: https://postgr.es/m/CAH2-Wz=9A_UtM7HzUThSkQ+BcrQsQZuNhWOvQWK06PRkEp=SKQ@mail.gmail.com  

M src/backend/access/nbtree/nbtutils.c

Improve Asserts checking relation matching in parallel scans.

commit   : 54562c9cfa2281b6303cdea1aff9596c4a5de4b2    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 20 Sep 2024 16:37:55 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 20 Sep 2024 16:37:55 -0400    

Click here for diff

table_beginscan_parallel and index_beginscan_parallel contain  
Asserts checking that the relation a worker will use in  
a parallel scan is the same one the leader intended.  However,  
they were checking for relation OID match, which was not strong  
enough to detect the mismatch problem fixed in 126ec0bc7.  
What would be strong enough is to compare relfilenodes instead.  
Arguably, that's a saner definition anyway, since a scan surely  
operates on a physical relation not a logical one.  Hence,  
store and compare RelFileLocators not relation OIDs.  Also  
ensure that index_beginscan_parallel checks the index identity  
not just the table identity.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/index/indexam.c
M src/backend/access/table/tableam.c
M src/include/access/relscan.h

Alphabetize #include directives in pg_checksums.c.

commit   : afb03e2ebf595c057db0372f543f9f796effaadf    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 20 Sep 2024 15:18:42 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 20 Sep 2024 15:18:42 -0500    

Click here for diff

Author: Michael Banck  
Discussion: https://postgr.es/m/66edaed0.050a0220.32a9ba.42c8%40mx.google.com  

M src/bin/pg_checksums/pg_checksums.c

Doc: explain how to test ADMIN privilege with pg_has_role().

commit   : a2ebf3274a43acf7ae36d608fc26090b803ab6e1    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 20 Sep 2024 15:56:34 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 20 Sep 2024 15:56:34 -0400    

Click here for diff

This has always been possible, but the syntax is a bit obscure,  
and our user-facing docs were not very helpful.  Spell it out  
more clearly.  
  
Per complaint from Dominique Devienne.  Back-patch to  
all supported branches.  
  
Discussion: https://postgr.es/m/CAFCRh-8JNEy+dV4SXFOrWca50u+d=--TO4cq=+ac1oBtfJy4AA@mail.gmail.com  

M doc/src/sgml/func.sgml

Fix nbtree pgstats accounting with parallel scans.

commit   : c00c54a9ac1e0c52ace8051a30805ca74ae53212    
  
author   : Peter Geoghegan <[email protected]>    
date     : Fri, 20 Sep 2024 14:06:32 -0400    
  
committer: Peter Geoghegan <[email protected]>    
date     : Fri, 20 Sep 2024 14:06:32 -0400    

Click here for diff

Commit 5bf748b8, which enhanced nbtree ScalarArrayOp execution, made  
parallel index scans work with the new design for arrays via explicit  
scheduling of primitive index scans.  Under this scheme a parallel index  
scan with array keys will perform the same number of index descents as  
an equivalent serial index scan (barring corner cases where an  
individual parallel worker discovers that it can advance the scan's  
array keys without anybody needing to perform another descent of the  
index to get to the relevant page on the leaf level).  
  
Despite all this, the pgstats accounting wasn't updated; it continued to  
increment the total number of index scans for the rel once per _bt_first  
call, no matter the details.  As a result, the number of (primitive)  
index scans could be over-counted during parallel scans.  
  
To fix, delay incrementing the count of index scans until after we've  
established that another descent of the index (using either _bt_search  
or _bt_endpoint) is required.  That way pg_stat_user_tables.idx_scan  
always advances in the same way, regardless of whether or not the scan  
makes use of parallelism.  
  
Oversight in commit 5bf748b8, which enhanced nbtree ScalarArrayOp  
execution.  
  
Author: Peter Geoghegan <[email protected]>  
Reviewed-By: Tomas Vondra <[email protected]>  
Discussion: https://postgr.es/m/CAH2-Wz=E7XrkvscBN0U6V81NK3Q-dQOmivvbEsjG-zwEfDdFpg@mail.gmail.com  
Discussion: https://postgr.es/m/CAH2-WzkRqvaqR2CTNqTZP0z6FuL4-3ED6eQB0yx38XBNj1v-4Q@mail.gmail.com  
Backpatch: 17-, where nbtree SAOP execution was enhanced.  

M src/backend/access/nbtree/nbtsearch.c

Add parameter "connstr" to PostgreSQL::Test::Cluster::background_psql

commit   : d35e29387870fecfdb52ffd4c93c651f0c7c1b43    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 20 Sep 2024 09:49:43 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 20 Sep 2024 09:49:43 +0900    

Click here for diff

Like for Cluster::psql, this can be handy to force the use of a  
connection string with some values overriden, like a "host".  
  
Author: Aidar Imamov  
Discussion: https://postgr.es/m/[email protected]  

M src/test/perl/PostgreSQL/Test/Cluster.pm

Restore relmapper state early enough in parallel workers.

commit   : 126ec0bc76d044d3a9eb86538b61242bf7da6db4    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 19 Sep 2024 20:58:17 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 19 Sep 2024 20:58:17 -0400    

Click here for diff

We need to do RestoreRelationMap before loading catalog-derived  
state, else the worker may end up with catalog relcache entries  
containing stale relfilenode data.  Move up RestoreReindexState  
too, on the principle that that should also happen before we  
do much of any catalog access.  
  
I think ideally these things would happen even before InitPostgres,  
but there are various problems standing in the way of that, notably  
that the relmapper thinks "active" mappings should be discarded at  
transaction end.  The implication of this is that InitPostgres and  
RestoreLibraryState will see the same catalog state as an independent  
backend would see, which is probably fine; at least, it's been like  
that all along.  
  
Per report from Justin Pryzby.  There is a case to be made that  
this should be back-patched.  But given the lack of complaints  
before 6e086fa2e and the short amount of time remaining before  
17.0 wraps, I'll just put it in HEAD for now.  
  
Discussion: https://postgr.es/m/ZuoU_8EbSTE14o1U@pryzbyj2023  

M src/backend/access/transam/parallel.c

psql: Add tests for repeated calls of \bind[_named]

commit   : 91287b5f5da324ac24678f556962e1b95e52240c    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 20 Sep 2024 08:59:20 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 20 Sep 2024 08:59:20 +0900    

Click here for diff

The implementation assumes that on multiple calls of these meta-commands  
the last one wins.  Multiple \g calls in-between mean multiple  
executions.  
  
There were no tests to check these properties, hence let's add  
something.  
  
Author: Jelte Fennema-Nio, Michael Paquier  
Discussion: https://postgr.es/m/CAGECzQSTE7CoM=Gst56Xj8pOvjaPr09+7jjtWqTC40pGETyAuA@mail.gmail.com  

M src/test/regress/expected/psql.out
M src/test/regress/sql/psql.sql

commit   : 658fc6c6af4fa209af6ddadc0182cdb69e2b70ae    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 18:05:22 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 18:05:22 -0400    

Click here for diff

Make paragraph empty instead of removing it.  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M doc/src/sgml/stylesheet-fo.xsl

doc PG relnotes: document "Unresolved ID reference found" cause

commit   : c6b1506f71324d0bacfab17c6688e8fc2a79b1dc    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 12:01:59 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 12:01:59 -0400    

Click here for diff

Backpatch-through: 12  

M doc/src/sgml/stylesheet-fo.xsl

commit   : 25f8cf19ab3a0246ef252203410b84169124eaaf    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 09:47:22 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 09:47:22 -0400    

Click here for diff

FYI, during PDF builds, this link type generates a "Unresolved ID  
reference found" warning because it is suppressed from the PDF output.  
  
Backpatch-through: 12  

M doc/src/sgml/release.sgml
M doc/src/sgml/stylesheet-fo.xsl

commit   : f0577816865dc9e6fab1537b2a112545535a5d51    
  
author   : Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 08:45:33 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Thu, 19 Sep 2024 08:45:33 -0400    

Click here for diff

Reported-by: Andrew Dunstan  
  
Discussion: https://postgr.es/m/[email protected]  
  
Author: Andrew Dunstan  
  
Backpatch-through: 12  

M src/tools/add_commit_links.pl

Add UpgradeTaskProcessCB to typedefs.list

commit   : 4c57facbb16ec5f7002f0b87427897f6f9fa49ae    
  
author   : Alexander Korotkov <[email protected]>    
date     : Thu, 19 Sep 2024 14:34:52 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Thu, 19 Sep 2024 14:34:52 +0300    

Click here for diff

While it doesn't directly influence indentation right now, add it for  
uniformity.  

M src/tools/pgindent/typedefs.list

Fix order of includes in src/bin/pg_upgrade/info.c

commit   : a094e8b9e43e350798ea0c95b8967b8caf64bcbd    
  
author   : Alexander Korotkov <[email protected]>    
date     : Thu, 19 Sep 2024 14:34:00 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Thu, 19 Sep 2024 14:34:00 +0300    

Click here for diff

M src/bin/pg_upgrade/info.c

Move pg_wal_replay_wait() to xlogfuncs.c

commit   : 014f9f34d2527c14cdf4150863c053d2a117c1c7    
  
author   : Alexander Korotkov <[email protected]>    
date     : Thu, 19 Sep 2024 14:26:03 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Thu, 19 Sep 2024 14:26:03 +0300    

Click here for diff

This commit moves pg_wal_replay_wait() procedure to be a neighbor of  
WAL-related functions in xlogfuncs.c.  The implementation of LSN waiting  
continues to reside in the same place.  
  
By proposal from Michael Paquier.  
  
Reported-by: Peter Eisentraut  
Discussion: https://postgr.es/m/18c0fa64-0475-415e-a1bd-665d922c5201%40eisentraut.org  

M src/backend/access/transam/xlogfuncs.c
M src/backend/commands/waitlsn.c
M src/include/commands/waitlsn.h

psql: Clean up more aggressively state of \bind[_named], \parse and \close

commit   : 87eeadaea1439693f6108ff599d750842ca6f338    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 19 Sep 2024 15:39:01 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 19 Sep 2024 15:39:01 +0900    

Click here for diff

This fixes a couple of issues with the psql meta-commands mentioned  
above when called repeatedly:  
- The statement name is reset for each call.  If a command errors out,  
its send_mode would still be set, causing an incorrect path to be taken  
when processing a query.  For \bind_named, this could trigger an  
assertion failure as a statement name is always expected for this  
meta-command.  This issue has been introduced by d55322b0da60.  
- The memory allocated for bind parameters can be leaked.  This is a bug  
enlarged by d55322b0da60 that exists since 5b66de3433e2, as it is also  
possible to leak memory with \bind in v16 and v17.  This requires a fix  
that will be done on the affected branches separately.  This issue is  
taken care of here for HEAD.  
  
This patch tightens the cleanup of the state used for the extended  
protocol meta-commands (bind parameters, send mode, statement name) by  
doing it before running each meta-command on top of doing it once a  
query has been processed, avoiding any leaks and the inconsistencies  
when mixing calls, by refactoring the cleanup in a single routine used  
in all the code paths where this step is required.  
  
Reported-by: Alexander Lakhin  
Author: Anthonin Bonnefoy  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/psql/command.c
M src/bin/psql/common.c
M src/bin/psql/common.h
M src/test/regress/expected/psql.out
M src/test/regress/sql/psql.sql

Introduce ATT_PARTITIONED_TABLE in tablecmds.c

commit   : d69a3f4d70b7cab328ba5d0944450d87f39c2eb4    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 19 Sep 2024 12:22:56 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 19 Sep 2024 12:22:56 +0900    

Click here for diff

Partitioned tables and normal tables have been relying on ATT_TABLE in  
ATSimplePermissions() to produce error messages that depend on the  
relation's relkind, because both relkinds currently support the same set  
of ALTER TABLE subcommands.  
  
A patch to restrict SET LOGGED/UNLOGGED for partitioned tables is under  
discussion, and introducing ATT_PARTITIONED_TABLE makes subcommand  
restrictions for partitioned tables easier to deal with, so let's add  
one.  There is no functional change.  
  
Author: Michael Paquier  
Reviewed-by: Nathan Bossart  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/tablecmds.c

Optimize tuplestore usage for WITH RECURSIVE CTEs

commit   : 5d56d07ca343a467ce74a042c22c963ea2690eaf    
  
author   : David Rowley <[email protected]>    
date     : Thu, 19 Sep 2024 15:20:35 +1200    
  
committer: David Rowley <[email protected]>    
date     : Thu, 19 Sep 2024 15:20:35 +1200    

Click here for diff

nodeRecursiveunion.c makes use of two tuplestores and, until now, would  
delete and recreate one of these tuplestores after every recursive  
iteration.  
  
Here we adjust that behavior and instead reuse one of the existing  
tuplestores and just empty it of all tuples using tuplestore_clear().  
  
This saves some free/malloc roundtrips and has shown a 25-30% performance  
improvement for queries that perform very little work between recursive  
iterations.  
  
This also paves the way to add some EXPLAIN ANALYZE telemetry output for  
recursive common table expressions, similar to what was done in 1eff8279d  
and 95d6e9af0.  Previously calling tuplestore_end() would have caused  
the maximum storage space used to be lost.  
  
Reviewed-by: Tatsuo Ishii  
Discussion: https://postgr.es/m/CAApHDvr9yW0YRiK8A2J7nvyT8g17YzbSfOviEWrghazKZbHbig@mail.gmail.com  

M src/backend/executor/nodeRecursiveunion.c

doc PG relnotes: add paragraph explaining the section symbol

commit   : 8a6e85b46e0ff1a49b1b2303149ec010e5e0b30e    
  
author   : Bruce Momjian <[email protected]>    
date     : Wed, 18 Sep 2024 17:13:19 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Wed, 18 Sep 2024 17:13:19 -0400    

Click here for diff

And suppress the symbol in print mode, where the section symbol does not  
appear.  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M doc/src/sgml/release.sgml
M doc/src/sgml/stylesheet-fo.xsl

commit   : f986882ffd67a4a2560b5cbd9056fc70d0c69209    
  
author   : Bruce Momjian <[email protected]>    
date     : Wed, 18 Sep 2024 16:34:52 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Wed, 18 Sep 2024 16:34:52 -0400    

Click here for diff

In print output, there are too many commit links for footnotes in the  
release notes to be useful.  
  
Reported-by: Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M doc/src/sgml/stylesheet-fo.xsl

Add TOAST table to pg_index.

commit   : b52c4fc3c09ec0ec9c1f9aa676f6d74304cc2f6f    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 18 Sep 2024 14:42:57 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 18 Sep 2024 14:42:57 -0500    

Click here for diff

This change allows pg_index rows to use out-of-line storage for the  
"indexprs" and "indpred" columns, which enables use-cases such as  
very large index expressions.  
  
This system catalog was previously not given a TOAST table due to a  
fear of circularity issues (see commit 96cdeae07f).  Testing has  
not revealed any such problems, and it seems unlikely that the  
entries for system indexes could ever need out-of-line storage.  In  
any case, it is still early in the v18 development cycle, so  
committing this now will hopefully increase the chances of finding  
any unexpected problems prior to release.  
  
Bumps catversion.  
  
Reported-by: Jonathan Katz  
Reviewed-by: Tom Lane  
Discussion: https://postgr.es/m/b611015f-b423-458c-aa2d-be0e655cc1b4%40postgresql.org  

M src/include/catalog/catversion.h
M src/include/catalog/pg_index.h
M src/test/regress/expected/misc_sanity.out
M src/test/regress/sql/misc_sanity.sql

docs: Improve the description of num_timed column in pg_stat_checkpointer.

commit   : a7c39db5eb342dd491dacf39546486c6a539ea43    
  
author   : Fujii Masao <[email protected]>    
date     : Thu, 19 Sep 2024 02:14:10 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Thu, 19 Sep 2024 02:14:10 +0900    

Click here for diff

The previous documentation stated that num_timed reflects the number of  
scheduled checkpoints performed. However, checkpoints may be skipped  
if the server has been idle, and num_timed counts both skipped and completed  
checkpoints. This commit clarifies the description to make it clear that  
the counter includes both skipped and completed checkpoints.  
  
Back-patch to v17 where pg_stat_checkpointer was added.  
  
Author: Fujii Masao  
Reviewed-by: Alexander Korotkov  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/monitoring.sgml

Add some sanity checks in executor for query ID reporting

commit   : 24f5205948093a96edf8213294b3d585ac3fe1fb    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 18 Sep 2024 14:43:37 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 18 Sep 2024 14:43:37 +0900    

Click here for diff

This commit adds three sanity checks in code paths of the executor where  
it is possible to use hooks, checking that a query ID is reported in  
pg_stat_activity if compute_query_id is enabled:  
- ExecutorRun()  
- ExecutorFinish()  
- ExecutorEnd()  
  
This causes the test in pg_stat_statements added in 933848d16dc9 to  
complain immediately in ExecutorRun().  The idea behind this commit is  
to help extensions to detect if they are missing query ID reports when a  
query goes through the executor.  Perhaps this will prove to be a bad  
idea, but let's see where this experience goes in v18 and newer  
versions.  
  
Reviewed-by: Sami Imseih  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/execMain.c

postgres_fdw: Extend postgres_fdw_get_connections to return user name.

commit   : 4f08ab55457751308ffd8d33e82155758cd0e304    
  
author   : Fujii Masao <[email protected]>    
date     : Wed, 18 Sep 2024 12:51:48 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Wed, 18 Sep 2024 12:51:48 +0900    

Click here for diff

This commit adds a "user_name" output column to  
the postgres_fdw_get_connections function, returning the name  
of the local user mapped to the foreign server for each connection.  
If a public mapping is used, it returns "public."  
  
This helps identify postgres_fdw connections more easily,  
such as determining which connections are invalid, closed,  
or used within the current transaction.  
  
No extension version bump is needed, as commit c297a47c5f  
already handled it for v18~.  
  
Author: Hayato Kuroda  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M contrib/postgres_fdw/connection.c
M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/postgres_fdw–1.1–1.2.sql
M contrib/postgres_fdw/sql/postgres_fdw.sql
M doc/src/sgml/postgres-fdw.sgml

Extend PgStat_HashKey.objid from 4 to 8 bytes

commit   : b14e9ce7d55c75ffa160b07765eb9dffde70b5fa    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 18 Sep 2024 12:44:15 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 18 Sep 2024 12:44:15 +0900    

Click here for diff

This opens the possibility to define keys for more types of statistics  
kinds in PgStat_HashKey, the first case being 8-byte query IDs for  
statistics like pg_stat_statements.  
  
This increases the size of PgStat_HashKey from 12 to 16 bytes, while  
PgStatShared_HashEntry, entry stored in the dshash for pgstats, keeps  
the same size due to alignment.  
  
xl_xact_stats_item, that tracks the stats items to drop in commit WAL  
records, is increased from 12 to 16 bytes.  Note that individual chunks  
in commit WAL records should be multiples of sizeof(int), hence 8-byte  
object IDs are stored as two uint32, based on a suggestion from Heikki  
Linnakangas.  
  
While on it, the field of PgStat_HashKey is renamed from "objoid" to  
"objid", as for some stats kinds this field does not refer to OIDs but  
just IDs, like for replication slot stats.  
  
This commit bumps the following format variables:  
- PGSTAT_FILE_FORMAT_ID, as PgStat_HashKey is written to the stats file  
for non-serialized stats kinds in the dshash table.  
- XLOG_PAGE_MAGIC for the changes in xl_xact_stats_item.  
- Catalog version, for the SQL function pg_stat_have_stats().  
  
Reviewed-by: Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/rmgrdesc/xactdesc.c
M src/backend/catalog/system_functions.sql
M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_replslot.c
M src/backend/utils/activity/pgstat_shmem.c
M src/backend/utils/activity/pgstat_xact.c
M src/backend/utils/adt/pgstatfuncs.c
M src/include/access/xact.h
M src/include/access/xlog_internal.h
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/include/pgstat.h
M src/include/utils/pgstat_internal.h
M src/test/modules/injection_points/injection_stats.c
M src/test/recovery/t/029_stats_restart.pl
M src/test/regress/expected/stats.out
M src/test/regress/sql/stats.sql

Don't enter parallel mode when holding interrupts.

commit   : ac04aa84a7f06635748278e6ff4bd74751bb3e8e    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 17 Sep 2024 19:53:11 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 17 Sep 2024 19:53:11 -0700    

Click here for diff

Doing so caused the leader to hang in wait_event=ParallelFinish, which  
required an immediate shutdown to resolve.  Back-patch to v12 (all  
supported versions).  
  
Francesco Degrassi  
  
Discussion: https://postgr.es/m/CAC-SaSzHUKT=vZJ8MPxYdC_URPfax+yoA1hKTcF4ROz_Q6z0_Q@mail.gmail.com  

M src/backend/optimizer/plan/planner.c
M src/test/regress/expected/select_parallel.out
M src/test/regress/sql/select_parallel.sql

Add missing query ID reporting in extended query protocol

commit   : 933848d16dc9d9d838c1bc15ed7e48c2f2eed69c    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 18 Sep 2024 09:59:09 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 18 Sep 2024 09:59:09 +0900    

Click here for diff

This commit adds query ID reports for two code paths when processing  
extended query protocol messages:  
- When receiving a bind message, setting it to the first Query retrieved  
from a cached cache.  
- When receiving an execute message, setting it to the first PlannedStmt  
stored in a portal.  
  
An advantage of this method is that this is able to cover all the types  
of portals handled in the extended query protocol, particularly these  
two when the report done in ExecutorStart() is not enough (neither is an  
addition in ExecutorRun(), actually, for the second point):  
- Multiple execute messages, with multiple ExecutorRun().  
- Portal with execute/fetch messages, like a query with a RETURNING  
clause and a fetch size that stores the tuples in a first execute  
message going though ExecutorStart() and ExecuteRun(), followed by one  
or more execute messages doing only fetches from the tuplestore created  
in the first message.  This corresponds to the case where  
execute_is_fetch is set, for example.  
  
Note that the query ID reporting done in ExecutorStart() is still  
necessary, as an EXECUTE requires it.  Query ID reporting is optimistic  
and more calls to pgstat_report_query_id() don't matter as the first  
report takes priority except if the report is forced.  The comment in  
ExecutorStart() is adjusted to reflect better the reality with the  
extended query protocol.  
  
The test added in pg_stat_statements is a courtesy of Robert Haas.  This  
uses psql's \bind metacommand, hence this part is backpatched down to  
v16.  
  
Reported-by:  Kaido Vaikla, Erik Wienhold  
Author: Sami Imseih  
Reviewed-by: Jian He, Andrei Lepikhov, Michael Paquier  
Discussion: https://postgr.es/m/CA+427g8DiW3aZ6pOpVgkPbqK97ouBdf18VLiHFesea2jUk3XoQ@mail.gmail.com  
Discussion: https://postgr.es/m/CA+TgmoZxtnf_jZ=VqBSyaU8hfUkkwoJCJ6ufy4LGpXaunKrjrg@mail.gmail.com  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 14  

M contrib/pg_stat_statements/expected/extended.out
M contrib/pg_stat_statements/sql/extended.sql
M src/backend/executor/execMain.c
M src/backend/tcop/postgres.c

Allow ReadStream to be consumed as raw block numbers.

commit   : 70d38e3d8a2d2cb88e3add2b90a122dacc941aa4    
  
author   : Thomas Munro <[email protected]>    
date     : Wed, 18 Sep 2024 09:20:59 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Wed, 18 Sep 2024 09:20:59 +1200    

Click here for diff

Commits 041b9680 and 6377e12a changed the interface of  
scan_analyze_next_block() to take a ReadStream instead of a BlockNumber  
and a BufferAccessStrategy, and to return a value to indicate when the  
stream has run out of blocks.  
  
This caused integration problems for at least one known extension that  
uses specially encoded BlockNumber values that map to different  
underlying storage, because acquire_sample_rows() sets up the stream so  
that read_stream_next_buffer() reads blocks from the main fork of the  
relation's SMgrRelation.  
  
Provide read_stream_next_block(), as a way for such an extension to  
access the stream of raw BlockNumbers directly and forward them to its  
own ReadBuffer() calls after decoding, as it could in earlier releases.  
The new function returns the BlockNumber and BufferAccessStrategy that  
were previously passed directly to scan_analyze_next_block().  
Alternatively, an extension could wrap the stream of BlockNumbers in  
another ReadStream with a callback that performs any decoding required  
to arrive at real storage manager BlockNumber values, so that it could  
benefit from the I/O combining and concurrency provided by  
read_stream.c.  
  
Another class of table access method that does nothing in  
scan_analyze_next_block() because it is not block-oriented could use  
this function to control the number of block sampling loops.  It could  
match the previous behavior with "return read_stream_next_block(stream,  
&bas) != InvalidBlockNumber".  
  
Ongoing work is expected to provide better ANALYZE support for table  
access methods that don't behave like heapam with respect to storage  
blocks, but that will be for future releases.  
  
Back-patch to 17.  
  
Reported-by: Mats Kindahl <[email protected]>  
Reviewed-by: Mats Kindahl <[email protected]>  
Discussion: https://postgr.es/m/CA%2B14425%2BCcm07ocG97Fp%2BFrD9xUXqmBKFvecp0p%2BgV2YYR258Q%40mail.gmail.com  

M src/backend/storage/aio/read_stream.c
M src/include/storage/read_stream.h

Repair pg_upgrade for identity sequences with non-default persistence.

commit   : 918e21d25178c8ae09808c581a782002f702ed9e    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 17 Sep 2024 15:53:26 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 17 Sep 2024 15:53:26 -0400    

Click here for diff

Since we introduced unlogged sequences in v15, identity sequences  
have defaulted to having the same persistence as their owning table.  
However, it is possible to change that with ALTER SEQUENCE, and  
pg_dump tries to preserve the logged-ness of sequences when it doesn't  
match (as indeed it wouldn't for an unlogged table from before v15).  
  
The fly in the ointment is that ALTER SEQUENCE SET [UN]LOGGED fails  
in binary-upgrade mode, because it needs to assign a new relfilenode  
which we cannot permit in that mode.  Thus, trying to pg_upgrade a  
database containing a mismatching identity sequence failed.  
  
To fix, add syntax to ADD/ALTER COLUMN GENERATED AS IDENTITY to allow  
the sequence's persistence to be set correctly at creation, and use  
that instead of ALTER SEQUENCE SET [UN]LOGGED in pg_dump.  (I tried to  
make SET [UN]LOGGED work without any pg_dump modifications, but that  
seems too fragile to be a desirable answer.  This way should be  
markedly faster anyhow.)  
  
In passing, document the previously-undocumented SEQUENCE NAME option  
that pg_dump also relies on for identity sequences; I see no value  
in trying to pretend it doesn't exist.  
  
Per bug #18618 from Anthony Hsu.  
Back-patch to v15 where we invented this stuff.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/create_table.sgml
M src/backend/commands/sequence.c
M src/backend/parser/gram.y
M src/backend/parser/parse_utilcmd.c
M src/bin/pg_dump/pg_dump.c
M src/test/regress/expected/identity.out
M src/test/regress/sql/identity.sql

Ensure standby promotion point in 043_wal_replay_wait.pl

commit   : 2520226c953c0b443791a185a8d1fb8b71d9fe9e    
  
author   : Alexander Korotkov <[email protected]>    
date     : Tue, 17 Sep 2024 22:51:06 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Tue, 17 Sep 2024 22:51:06 +0300    

Click here for diff

This commit ensures standby will be promoted at least at the primary insert  
LSN we have just observed.  We use pg_switch_wal() to force the insert LSN  
to be written then wait for standby to catchup.  
  
Reported-by: Alexander Lakhin  
Discussion: https://postgr.es/m/1d7b08f2-64a2-77fb-c666-c9a74c68eeda%40gmail.com  

M src/test/recovery/t/043_wal_replay_wait.pl

commit   : 85b98b8d5a48092acd03db76a8bf02d9c38c1d79    
  
author   : Alexander Korotkov <[email protected]>    
date     : Tue, 17 Sep 2024 22:50:43 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Tue, 17 Sep 2024 22:50:43 +0300    

Click here for diff

 * Rename $node_standby1 to $node_standby in 043_wal_replay_wait.pl as there  
   is only one standby.  
 * Remove useless debug printing in 043_wal_replay_wait.pl.  
 * Fix typo in one check description in 043_wal_replay_wait.pl.  
 * Fix some wording in comments and documentation.  
  
Reported-by: Alexander Lakhin  
Discussion: https://postgr.es/m/1d7b08f2-64a2-77fb-c666-c9a74c68eeda%40gmail.com  
Reviewed-by: Alexander Lakhin  

M doc/src/sgml/func.sgml
M src/backend/access/transam/xlog.c
M src/backend/commands/waitlsn.c
M src/test/recovery/t/043_wal_replay_wait.pl

Avoid parallel nbtree index scan hangs with SAOPs.

commit   : d8adfc18bebfb1b69b456a00e67453775a77f594    
  
author   : Peter Geoghegan <[email protected]>    
date     : Tue, 17 Sep 2024 11:10:35 -0400    
  
committer: Peter Geoghegan <[email protected]>    
date     : Tue, 17 Sep 2024 11:10:35 -0400    

Click here for diff

Commit 5bf748b8, which enhanced nbtree ScalarArrayOp execution, made  
parallel index scans work with the new design for arrays via explicit  
scheduling of primitive index scans.  A backend that successfully  
scheduled the scan's next primitive index scan saved its backend local  
array keys in shared memory.  Any backend could pick up the scheduled  
primitive scan within _bt_first.  This scheme decouples scheduling a  
primitive scan from starting the scan (by performing another descent of  
the index via a _bt_search call from _bt_first) to make things robust.  
  
The scheme had a deadlock hazard, at least when the leader process  
participated in the scan.  _bt_parallel_seize had a code path that made  
backends that were not in an immediate position to start a scheduled  
primitive index scan wait for some other backend to do so instead.  
Under the right circumstances, the leader process could wait here  
forever: the leader would wait for any other backend to start the  
primitive scan, while every worker was busy waiting on the leader to  
consume tuples from the scan's tuple queue.  
  
To fix, don't wait for a scheduled primitive index scan to be started by  
some other eligible backend from within _bt_parallel_seize (when the  
calling backend isn't in a position to do so itself).  Return false  
instead, while recording that the scan has a scheduled primitive index  
scan in backend local state.  This leaves the backend in the same state  
as the existing case where a backend schedules (or tries to schedule)  
another primitive index scan from within _bt_advance_array_keys, before  
calling _bt_parallel_seize.  _bt_parallel_seize already handles that  
case by returning false without waiting, and without unsetting the  
backend local state.  Leaving the backend in this state enables it to  
start a previously scheduled primitive index scan once it gets back to  
_bt_first.  
  
Oversight in commit 5bf748b8, which enhanced nbtree ScalarArrayOp  
execution.  
  
Matthias van de Meent, with tweaks by me.  
  
Author: Matthias van de Meent <[email protected]>  
Reported-By: Tomas Vondra <[email protected]>  
Reviewed-By: Peter Geoghegan <[email protected]>  
Discussion: https://postgr.es/m/CAH2-WzmMGaPa32u9x_FvEbPTUkP5e95i=QxR8054nvCRydP-sw@mail.gmail.com  
Backpatch: 17-, where nbtree SAOP execution was enhanced.  

M src/backend/access/nbtree/nbtree.c

Add temporal FOREIGN KEY contraints

commit   : 89f908a6d0ac1337c868625008c9598487d184e7    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 17 Sep 2024 10:41:07 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 17 Sep 2024 10:41:07 +0200    

Click here for diff

Add PERIOD clause to foreign key constraint definitions.  This is  
supported for range and multirange types.  Temporal foreign keys check  
for range containment instead of equality.  
  
This feature matches the behavior of the SQL standard temporal foreign  
keys, but it works on PostgreSQL's native ranges instead of SQL's  
"periods", which don't exist in PostgreSQL (yet).  
  
Reference actions ON {UPDATE,DELETE} {CASCADE,SET NULL,SET DEFAULT}  
are not supported yet.  
  
(previously committed as 34768ee3616, reverted by 8aee330af55; this is  
essentially unchanged from those)  
  
Author: Paul A. Jungwirth <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Reviewed-by: jian he <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/CA+renyUApHgSZF9-nd-a0+OPGharLQLO=mDHcY4_qQ0+noCUVg@mail.gmail.com  

M contrib/btree_gist/expected/without_overlaps.out
M contrib/btree_gist/sql/without_overlaps.sql
M doc/src/sgml/catalogs.sgml
M doc/src/sgml/ref/create_table.sgml
M src/backend/catalog/pg_constraint.c
M src/backend/commands/indexcmds.c
M src/backend/commands/tablecmds.c
M src/backend/parser/gram.y
M src/backend/utils/adt/ri_triggers.c
M src/backend/utils/adt/ruleutils.c
M src/include/catalog/pg_constraint.h
M src/include/commands/defrem.h
M src/include/nodes/parsenodes.h
M src/include/parser/kwlist.h
M src/test/regress/expected/without_overlaps.out
M src/test/regress/sql/without_overlaps.sql

Add temporal PRIMARY KEY and UNIQUE constraints

commit   : fc0438b4e80535419a4e54dba87642cdf84defda    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 17 Sep 2024 10:36:09 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 17 Sep 2024 10:36:09 +0200    

Click here for diff

Add WITHOUT OVERLAPS clause to PRIMARY KEY and UNIQUE constraints.  
These are backed by GiST indexes instead of B-tree indexes, since they  
are essentially exclusion constraints with = for the scalar parts of  
the key and && for the temporal part.  
  
(previously committed as 46a0cd4cefb, reverted by 46a0cd4cefb; the new  
part is this:)  
  
Because 'empty' && 'empty' is false, the temporal PK/UQ constraint  
allowed duplicates, which is confusing to users and breaks internal  
expectations.  For instance, when GROUP BY checks functional  
dependencies on the PK, it allows selecting other columns from the  
table, but in the presence of duplicate keys you could get the value  
from any of their rows.  So we need to forbid empties.  
  
This all means that at the moment we can only support ranges and  
multiranges for temporal PK/UQs, unlike the original patch (above).  
Documentation and tests for this are added.  But this could  
conceivably be extended by introducing some more general support for  
the notion of "empty" for other types.  
  
Author: Paul A. Jungwirth <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Reviewed-by: jian he <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/CA+renyUApHgSZF9-nd-a0+OPGharLQLO=mDHcY4_qQ0+noCUVg@mail.gmail.com  

M contrib/btree_gist/Makefile
A contrib/btree_gist/expected/without_overlaps.out
M contrib/btree_gist/meson.build
A contrib/btree_gist/sql/without_overlaps.sql
M doc/src/sgml/catalogs.sgml
M doc/src/sgml/gist.sgml
M doc/src/sgml/ref/create_table.sgml
M src/backend/access/gist/gistutil.c
M src/backend/catalog/heap.c
M src/backend/catalog/index.c
M src/backend/catalog/pg_constraint.c
M src/backend/commands/indexcmds.c
M src/backend/commands/tablecmds.c
M src/backend/commands/trigger.c
M src/backend/commands/typecmds.c
M src/backend/executor/execIndexing.c
M src/backend/nodes/makefuncs.c
M src/backend/optimizer/util/plancat.c
M src/backend/parser/gram.y
M src/backend/parser/parse_utilcmd.c
M src/backend/utils/adt/ruleutils.c
M src/backend/utils/cache/relcache.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump.h
M src/bin/pg_dump/t/002_pg_dump.pl
M src/bin/psql/describe.c
M src/include/access/gist.h
M src/include/catalog/catversion.h
M src/include/catalog/index.h
M src/include/catalog/pg_constraint.h
M src/include/commands/defrem.h
M src/include/nodes/execnodes.h
M src/include/nodes/makefuncs.h
M src/include/nodes/parsenodes.h
A src/test/regress/expected/without_overlaps.out
M src/test/regress/parallel_schedule
A src/test/regress/sql/without_overlaps.sql

Add stratnum GiST support function

commit   : 7406ab623fee1addcb21c881afecbe638a0d56e9    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 17 Sep 2024 10:19:26 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 17 Sep 2024 10:19:26 +0200    

Click here for diff

This is support function 12 for the GiST AM and translates  
"well-known" RT*StrategyNumber values into whatever strategy number is  
used by the opclass (since no particular numbers are actually  
required).  We will use this to support temporal PRIMARY  
KEY/UNIQUE/FOREIGN KEY/FOR PORTION OF functionality.  
  
This commit adds two implementations, one for internal GiST opclasses  
(just an identity function) and another for btree_gist opclasses.  It  
updates btree_gist from 1.7 to 1.8, adding the support function for  
all its opclasses.  
  
(previously committed as 6db4598fcb8, reverted by 8aee330af55; this is  
essentially unchanged from those)  
  
Author: Paul A. Jungwirth <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Reviewed-by: jian he <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/CA+renyUApHgSZF9-nd-a0+OPGharLQLO=mDHcY4_qQ0+noCUVg@mail.gmail.com  

M contrib/btree_gist/Makefile
A contrib/btree_gist/btree_gist–1.7–1.8.sql
M contrib/btree_gist/btree_gist.c
M contrib/btree_gist/btree_gist.control
A contrib/btree_gist/expected/stratnum.out
M contrib/btree_gist/meson.build
A contrib/btree_gist/sql/stratnum.sql
M doc/src/sgml/gist.sgml
M doc/src/sgml/xindex.sgml
M src/backend/access/gist/gistutil.c
M src/backend/access/gist/gistvalidate.c
M src/include/access/gist.h
M src/include/catalog/catversion.h
M src/include/catalog/pg_amproc.dat
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/misc_functions.out
M src/test/regress/sql/misc_functions.sql

Add memory/disk usage for Window aggregate nodes in EXPLAIN.

commit   : 95d6e9af07d2e5af2fdd272e72b5b552bad3ea0a    
  
author   : Tatsuo Ishii <[email protected]>    
date     : Tue, 17 Sep 2024 14:38:53 +0900    
  
committer: Tatsuo Ishii <[email protected]>    
date     : Tue, 17 Sep 2024 14:38:53 +0900    

Click here for diff

This commit is similar to 1eff8279d and expands the idea to Window  
aggregate nodes so that users can know how much memory or disk the  
tuplestore used.  
  
This commit uses newly introduced tuplestore_get_stats() to inquire this  
information and add some additional output in EXPLAIN ANALYZE to  
display the information for the Window aggregate node.  
  
Reviewed-by: David Rowley, Ashutosh Bapat, Maxim Orlov, Jian He  
Discussion: https://postgr.es/m/20240706.202254.89740021795421286.ishii%40postgresql.org  

M src/backend/commands/explain.c
M src/test/regress/expected/explain.out
M src/test/regress/sql/explain.sql

Fix redefinition of typedef.

commit   : 1bbf1e2f1a077905037272cd4767e952f34c02b3    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:33:50 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:33:50 -0500    

Click here for diff

Per buildfarm members sifaka and longfin, clang with  
-Wtypedef-redefinition warns of a duplicate typedef unless building  
with C11.  
  
Oversight in commit 40e2e5e92b.  

M src/bin/pg_upgrade/task.c

pg_upgrade: Parallelize encoding conversion check.

commit   : c880cf258864cdb355ce28438ec31a2405c20941    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

This commit makes use of the new task framework in pg_upgrade to  
parallelize the check for incompatible user-defined encoding  
conversions, i.e., those defined on servers older than v14.  This  
step will now process multiple databases concurrently when  
pg_upgrade's --jobs option is provided a value greater than 1.  
  
Reviewed-by: Daniel Gustafsson, Ilya Gladyshev  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/check.c

pg_upgrade: Parallelize WITH OIDS check.

commit   : f93f5f7b984edd85f3f515cd454a6160e574b2d0    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

This commit makes use of the new task framework in pg_upgrade to  
parallelize the check for tables declared WITH OIDS.  This step  
will now process multiple databases concurrently when pg_upgrade's  
--jobs option is provided a value greater than 1.  
  
Reviewed-by: Daniel Gustafsson, Ilya Gladyshev  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/check.c

pg_upgrade: Parallelize incompatible polymorphics check.

commit   : cf2f82a37cc35895b67c83dd2b33d2fcf4688a55    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

This commit makes use of the new task framework in pg_upgrade to  
parallelize the check for usage of incompatible polymorphic  
functions, i.e., those with arguments of type anyarray/anyelement  
rather than the newer anycompatible variants.  This step will now  
process multiple databases concurrently when pg_upgrade's --jobs  
option is provided a value greater than 1.  
  
Reviewed-by: Daniel Gustafsson, Ilya Gladyshev  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/check.c

pg_upgrade: Parallelize postfix operator check.

commit   : c34eabfbbfd3d3799bc7bc61f22b1fe730c53fe8    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

This commit makes use of the new task framework in pg_upgrade to  
parallelize the check for user-defined postfix operators.  This  
step will now process multiple databases concurrently when  
pg_upgrade's --jobs option is provided a value greater than 1.  
  
Reviewed-by: Daniel Gustafsson, Ilya Gladyshev  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/check.c

pg_upgrade: Parallelize contrib/isn check.

commit   : 9db3018cf83b4be1dbcdca8274e97ea8645df49c    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

This commit makes use of the new task framework in pg_upgrade to  
parallelize the check for contrib/isn functions that rely on the  
bigint data type.  This step will now process multiple databases  
concurrently when pg_upgrade's --jobs option is provided a value  
greater than 1.  
  
Reviewed-by: Daniel Gustafsson, Ilya Gladyshev  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/check.c

pg_upgrade: Parallelize data type checks.

commit   : bbf83cab98f2c018d6d394decaa9b03212f96983    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

This commit makes use of the new task framework in pg_upgrade to  
parallelize the checks for incompatible data types, i.e., data  
types whose on-disk format has changed, data types that have been  
removed, etc.  This step will now process multiple databases  
concurrently when pg_upgrade's --jobs option is provided a value  
greater than 1.  
  
Reviewed-by: Daniel Gustafsson, Ilya Gladyshev  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/check.c

pg_upgrade: Parallelize retrieving extension updates.

commit   : 6ab8f27bc7163ab534543e32504e47ed924b6737    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

This commit makes use of the new task framework in pg_upgrade to  
parallelize retrieving the set of extensions that should be updated  
with the ALTER EXTENSION command after upgrade.  This step will now  
process multiple databases concurrently when pg_upgrade's --jobs  
option is provided a value greater than 1.  
  
Reviewed-by: Daniel Gustafsson, Ilya Gladyshev  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/version.c

pg_upgrade: Parallelize retrieving loadable libraries.

commit   : 46cad8b31927410a99894279ca9af4e0d5c185b6    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

This commit makes use of the new task framework in pg_upgrade to  
parallelize retrieving the names of all libraries referenced by  
non-built-in C functions.  This step will now process multiple  
databases concurrently when pg_upgrade's --jobs option is provided  
a value greater than 1.  
  
Reviewed-by: Daniel Gustafsson, Ilya Gladyshev  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/function.c

pg_upgrade: Parallelize subscription check.

commit   : 7baa36de58bdaeb4797d592aeb9ef1db08320853    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

This commit makes use of the new task framework in pg_upgrade to  
parallelize the part of check_old_cluster_subscription_state() that  
verifies each of the subscribed tables is in the 'i' (initialize)  
or 'r' (ready) state.  This check will now process multiple  
databases concurrently when pg_upgrade's --jobs option is provided  
a value greater than 1.  
  
Reviewed-by: Daniel Gustafsson, Ilya Gladyshev  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/check.c

pg_upgrade: Parallelize retrieving relation information.

commit   : 6d3d2e8e541f07dafb6a42a105b3ca78b2a09437    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

This commit makes use of the new task framework in pg_upgrade to  
parallelize retrieving relation and logical slot information.  This  
step will now process multiple databases concurrently when  
pg_upgrade's --jobs option is provided a value greater than 1.  
  
Reviewed-by: Daniel Gustafsson, Ilya Gladyshev  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/info.c

Introduce framework for parallelizing various pg_upgrade tasks.

commit   : 40e2e5e92b7da358fb45802b53c735d25a51d23a    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 16 Sep 2024 16:10:33 -0500    

Click here for diff

A number of pg_upgrade steps require connecting to every database  
in the cluster and running the same query in each one.  When there  
are many databases, these steps are particularly time-consuming,  
especially since they are performed sequentially, i.e., we connect  
to a database, run the query, and process the results before moving  
on to the next database.  
  
This commit introduces a new framework that makes it easy to  
parallelize most of these once-in-each-database tasks by processing  
multiple databases concurrently.  This framework manages a set of  
slots that follow a simple state machine, and it uses libpq's  
asynchronous APIs to establish the connections and run the queries.  
The --jobs option is used to determine the number of slots to use.  
To use this new task framework, callers simply need to provide the  
query and a callback function to process its results, and the  
framework takes care of the rest.  A more complete description is  
provided at the top of the new task.c file.  
  
None of the eligible once-in-each-database tasks are converted to  
use this new framework in this commit.  That will be done via  
several follow-up commits.  
  
Reviewed-by: Jeff Davis, Robert Haas, Daniel Gustafsson, Ilya Gladyshev, Corey Huinker  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M doc/src/sgml/ref/pgupgrade.sgml
M src/bin/pg_upgrade/Makefile
M src/bin/pg_upgrade/meson.build
M src/bin/pg_upgrade/pg_upgrade.h
A src/bin/pg_upgrade/task.c
M src/tools/pgindent/typedefs.list

doc PG relnotes: fix SGML markup for new commit links

commit   : d891c49286bb138dcd70df1dff83e22fa757fc84    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 16 Sep 2024 14:23:39 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 16 Sep 2024 14:23:39 -0400    

Click here for diff

Backpatch-through: 12  

M doc/src/sgml/postgres.sgml

commit   : 257210455257aaac30001914886d422cbf34c215    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 16 Sep 2024 13:26:37 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 16 Sep 2024 13:26:37 -0400    

Click here for diff

Reported-by: jian he  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M src/tools/RELEASE_CHANGES
A src/tools/add_commit_links.pl

Perl scripts: revert 43ce181059d

commit   : 4632e5cf4bc5c496f41dfc6a89533e7afa7262dd    
  
author   : Bruce Momjian <[email protected]>    
date     : Sun, 15 Sep 2024 21:25:00 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Sun, 15 Sep 2024 21:25:00 -0400    

Click here for diff

Small improvement not worth the code churn.  
  
Reported-by: Andrew Dunstan  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: master  

M src/tools/copyright.pl
M src/tools/gen_export.pl
M src/tools/gen_keywordlist.pl
M src/tools/msvc_gendef.pl
M src/tools/version_stamp.pl
M src/tools/win32tzlist.pl

Replace usages of xmlXPathCompile() with xmlXPathCtxtCompile().

commit   : d5622acb32b3c11a27b323138fbee9c715742b38    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 15 Sep 2024 13:33:09 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 15 Sep 2024 13:33:09 -0400    

Click here for diff

In existing releases of libxml2, xmlXPathCompile can be driven  
to stack overflow because it fails to protect itself against  
too-deeply-nested input.  While there is an upstream fix as of  
yesterday, it will take years for that to propagate into all  
shipping versions.  In the meantime, we can protect our own  
usages basically for free by calling xmlXPathCtxtCompile instead.  
  
(The actual bug is that libxml2 keeps its nesting counter in the  
xmlXPathContext, and its parsing code was willing to just skip  
counting nesting levels if it didn't have a context.  So if we supply  
a context, all is well.  It seems odd actually that it works at all  
to not supply a context, because this means that XPath parsing does  
not have access to XML namespace info.  Apparently libxml2 never  
checks namespaces until runtime?  Anyway, this seems like good  
future-proofing even if its only immediate effect is to dodge a bug.)  
  
Sadly, this hack only offers protection with libxml2 2.9.11 and newer.  
Before that there are multiple similar problems, so if you are  
processing untrusted XML it behooves you to get a newer version.  
But we have some pretty old libxml2 in the buildfarm, so it seems  
impractical to add a regression test to verify this fix.  
  
Per bug #18617 from Jingzhou Fu.  Back-patch to all supported  
versions.  
  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://gitlab.gnome.org/GNOME/libxml2/-/issues/799  

M contrib/xml2/xpath.c
M src/backend/utils/adt/xml.c

Perl scripts: eliminate "Useless interpolation" warnings

commit   : 43ce181059d4ecbb1b14b75e7f38a7dda9f80225    
  
author   : Bruce Momjian <[email protected]>    
date     : Sun, 15 Sep 2024 10:55:37 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Sun, 15 Sep 2024 10:55:37 -0400    

Click here for diff

Eliminate warnings of Perl Critic from src/tools.  
  
Backpatch-through: master  

M src/tools/copyright.pl
M src/tools/gen_export.pl
M src/tools/gen_keywordlist.pl
M src/tools/msvc_gendef.pl
M src/tools/version_stamp.pl
M src/tools/win32tzlist.pl

Run regression tests with timezone America/Los_Angeles.

commit   : b8ea0f675f35c3f0c2cf62175517ba0dacad4abd    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 14 Sep 2024 17:55:02 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 14 Sep 2024 17:55:02 -0400    

Click here for diff

Historically we've used timezone "PST8PDT", but the recent release  
2024b of tzdb changes the definition of that zone in a way that  
breaks many test cases concerned with dates before 1970.  Although  
we've not yet adopted 2024b into our own tree, this is already  
problematic for people using --with-system-tzdata if their platform  
has already adopted 2024b.  To work with both older and newer  
versions of tzdb, switch to using "America/Los_Angeles", accepting  
the ensuing changes in regression test results.  
  
Back-patch to all supported branches.  
  
Per report and patch from Wolfgang Walther.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/set.sgml
M doc/src/sgml/regress.sgml
M src/test/regress/expected/date.out
M src/test/regress/expected/horology.out
M src/test/regress/expected/timestamptz.out
M src/test/regress/pg_regress.c
M src/test/regress/sql/timestamptz.sql

Add commit 7229ebe011df to .git-blame-ignore-revs.

commit   : f64074c88c067b4733ae439afae46ad61e45474b    
  
author   : Alvaro Herrera <[email protected]>    
date     : Sat, 14 Sep 2024 20:17:30 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Sat, 14 Sep 2024 20:17:30 +0200    

Click here for diff

M .git-blame-ignore-revs

Remove obsolete comment in pg_stat_statements.

commit   : 94537982ec6b4c6b7957d084f0c50eba14924baf    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 14 Sep 2024 11:42:31 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 14 Sep 2024 11:42:31 -0400    

Click here for diff

Commit 76db9cb63 removed the use of multiple nesting counters,  
but missed one comment describing that arrangement.  
  
Back-patch to v17 where 76db9cb63 came in, just to avoid confusion.  
  
Julien Rouhaud  
  
Discussion: https://postgr.es/m/gfcwh3zjxc2vygltapgo7g6yacdor5s4ynr234b6v2ohhuvt7m@gr42joxalenw  

M contrib/pg_stat_statements/pg_stat_statements.c

Improve meson's detection of perl build flags

commit   : 76f2a0e5479618d48161549a148a37251b4b3d4b    
  
author   : Andrew Dunstan <[email protected]>    
date     : Sat, 14 Sep 2024 10:26:25 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Sat, 14 Sep 2024 10:26:25 -0400    

Click here for diff

The current method of detecting perl build flags breaks if the path to  
perl contains a space. This change makes two improvements. First,  
instead of getting a list of ldflags and ccdlflags and then trying to  
filter those out of the reported ldopts, we tell perl to suppress  
reporting those in the first instance. Second, it tells perl to parse  
those and output them, one per line. Thus any space on the option in a  
file name, for example, is preserved.  
  
Issue reported off-list by Muralikrishna Bandaru  
  
Discussion: https://postgr.es/[email protected]  
  
Backpatch to release 16.  

M meson.build

Only define NO_THREAD_SAFE_LOCALE for MSVC plperl when required

commit   : bc46104fc9aa5254f98250cf2756552f92095ae9    
  
author   : Andrew Dunstan <[email protected]>    
date     : Sat, 14 Sep 2024 08:37:08 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Sat, 14 Sep 2024 08:37:08 -0400    

Click here for diff

Latest versions of Strawberry Perl define USE_THREAD_SAFE_LOCALE, and we  
therefore get a handshake error when building against such instances.  
The solution is to perform a test to see if USE_THREAD_SAFE_LOCALE is  
defined and only define NO_THREAD_SAFE_LOCALE if it isn't.  
  
Backpatch the meson.build fix back to release 16 and apply the same  
logic to Mkvcbuild.pm in releases 12 through 16.  
  
Original report of the issue from Muralikrishna Bandaru.  

M meson.build

Allow _h_indexbuild() to be interrupted.

commit   : fae55f0bb38504b3774fa50152d3c14d2f09aa15    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 13 Sep 2024 16:16:47 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 13 Sep 2024 16:16:47 -0400    

Click here for diff

When we are building a hash index that is large enough to need  
pre-sorting (larger than either maintenance_work_mem or NBuffers),  
the initial sorting phase is interruptible, but the insertion  
phase wasn't.  Add the missing CHECK_FOR_INTERRUPTS().  
  
Per bug #18616 from Alexander Lakhin.  Back-patch to all  
supported branches.  
  
Pavel Borisov  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/hash/hashsort.c

Add commit 2b03cfeea4 to .git-blame-ignore-revs.

commit   : 9a23967063b1b36c620a753f72c7cdb56dc0a4c4    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 13 Sep 2024 13:06:06 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 13 Sep 2024 13:06:06 -0500    

Click here for diff

M .git-blame-ignore-revs

Fix contrib/pageinspect's test for sequences.

commit   : 70d1c664f4376fd3499e3b0c6888cf39b65d722b    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 13 Sep 2024 10:16:40 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 13 Sep 2024 10:16:40 -0500    

Click here for diff

I managed to break this test in two different ways in commit  
05036a3155.  
  
First, the output of the new call to tuple_data_split() on the test  
sequence is dependent on endianness.  This is fixed by setting a  
special start value for the test sequence that produces the same  
output regardless of the endianness of the machine.  
  
Second, on versions older than v15, the new test case fails under  
"force_parallel_mode = regress" with the following error:  
  
	ERROR:  cannot access temporary tables during a parallel operation  
  
This is because pageinspect's disk-accessing functions are  
incorrectly marked PARALLEL SAFE on versions older than v15 (see  
commit aeaaf520f4 for details).  This one is fixed by changing the  
test sequence to be permanent.  The only reason it was previously  
marked temporary was to avoid needing a DROP SEQUENCE command at  
the end of the test.  Unlike some other tests in this file, the use  
of a permanent sequence here shouldn't result in any test  
instability like what was fixed by commit e2933a6e11.  
  
Reviewed-by: Tom Lane  
Discussion: https://postgr.es/m/ZuOKOut5hhDlf_bP%40nathan  
Backpatch-through: 12  

M contrib/pageinspect/expected/page.out
M contrib/pageinspect/sql/page.sql

Remove separate locale_is_c arguments

commit   : 433d8f40e957c042d7d224e4561ca033252baf37    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 13 Sep 2024 16:10:52 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 13 Sep 2024 16:10:52 +0200    

Click here for diff

Since e9931bfb751, ctype_is_c is part of pg_locale_t.  Some functions  
passed a pg_locale_t and a bool argument separately.  This can now be  
combined into one argument.  
  
Since some callers call MatchText() with locale 0, it is a bit  
confusing whether this is all correct.  But it is the case that only  
callers that pass a non-zero locale object to MatchText() end up  
checking locale->ctype_is_c.  To make that flow a bit more  
understandable, add the locale argument to MATCH_LOWER() and GETCHAR()  
in like_match.c, instead of implicitly taking it from the outer scope.  
  
Reviewed-by: Jeff Davis <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/utils/adt/like.c
M src/backend/utils/adt/like_match.c

SQL/JSON: Update example in JSON_QUERY() documentation

commit   : 2b67bdca529c6aed4303eb6963d09d1b540137b8    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 13 Sep 2024 16:07:42 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 13 Sep 2024 16:07:42 +0900    

Click here for diff

Commit e6c45d85dc fixed the behavior of JSON_QUERY() when WITH  
CONDITIONAL WRAPPER is used, but the documentation example wasn't  
updated to reflect this change. This commit updates the example to  
show the correct result.  
  
Per off-list report from Andreas Ulbrich.  
  
Backpatch-through: 17  

M doc/src/sgml/func.sgml

Prohibit altering invalidated replication slots.

commit   : 4d8489f4f1fa86a99e6db0ea702911e1cf92fa81    
  
author   : Amit Kapila <[email protected]>    
date     : Fri, 13 Sep 2024 09:29:13 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Fri, 13 Sep 2024 09:29:13 +0530    

Click here for diff

ALTER_REPLICATION_SLOT for invalid replication slots should not be allowed  
because there is no way to get back the invalidated (logical) slot to  
work.  
  
Author: Bharath Rupireddy  
Reviewed-by: Peter Smith, Shveta Malik  
Discussion: https://www.postgresql.org/message-id/CALj2ACW4fSOMiKjQ3=2NVBMTZRTG8Ujg6jsK9z3EvOtvA4vzKQ@mail.gmail.com  

M src/backend/replication/slot.c
M src/test/recovery/t/035_standby_logical_decoding.pl

pg_stat_statements: Add tests with extended query protocol

commit   : 7b1ddbae361b0ed92d5696d666ae85a2cc4dd883    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 13 Sep 2024 09:41:06 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 13 Sep 2024 09:41:06 +0900    

Click here for diff

There are currently no tests in the tree checking that queries using the  
extended query protocol are able to map with their query ID.  
  
This can be achieved for some paths of the extended query protocol with  
the psql meta-commands \bind or \bind_named, so let's add some tests  
based on both.  
  
I have found that to be a useful addition while working on a different  
issue.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pg_stat_statements/Makefile
A contrib/pg_stat_statements/expected/extended.out
M contrib/pg_stat_statements/meson.build
A contrib/pg_stat_statements/sql/extended.sql

Reintroduce support for sequences in pgstattuple and pageinspect.

commit   : 05036a3155c1e8d21500b5ecbbc2f8fbeb4aea66    
  
author   : Nathan Bossart <[email protected]>    
date     : Thu, 12 Sep 2024 16:31:29 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Thu, 12 Sep 2024 16:31:29 -0500    

Click here for diff

Commit 4b82664156 restricted a number of functions provided by  
contrib modules to only relations that use the "heap" table access  
method.  Sequences always use this table access method, but they do  
not advertise as such in the pg_class system catalog, so the  
aforementioned commit also (presumably unintentionally) removed  
support for sequences from some of these functions.  This commit  
reintroduces said support for sequences to these functions and adds  
a couple of relevant tests.  
  
Co-authored-by: Ayush Vatsa  
Reviewed-by: Robert Haas, Michael Paquier, Matthias van de Meent  
Discussion: https://postgr.es/m/CACX%2BKaP3i%2Bi9tdPLjF5JCHVv93xobEdcd_eB%2B638VDvZ3i%3DcQA%40mail.gmail.com  
Backpatch-through: 12  

M contrib/pageinspect/expected/page.out
M contrib/pageinspect/heapfuncs.c
M contrib/pageinspect/sql/page.sql
M contrib/pgstattuple/expected/pgstattuple.out
M contrib/pgstattuple/pgstattuple.c
M contrib/pgstattuple/sql/pgstattuple.sql

Simplify checks for deterministic collations.

commit   : b0c30612c5f6ce519172396527781a0666937363    
  
author   : Jeff Davis <[email protected]>    
date     : Thu, 12 Sep 2024 13:35:56 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Thu, 12 Sep 2024 13:35:56 -0700    

Click here for diff

Remove redundant checks for locale->collate_is_c now that we always  
have a valid pg_locale_t.  
  
Also, remove pg_locale_deterministic() wrapper, which is no longer  
useful after commit e9931bfb75. Just check the field directly,  
consistent with other fields in pg_locale_t.  
  
Author: Andreas Karlsson  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/hash/hashfunc.c
M src/backend/regex/regc_pg_locale.c
M src/backend/utils/adt/like.c
M src/backend/utils/adt/pg_locale.c
M src/backend/utils/adt/varchar.c
M src/backend/utils/adt/varlena.c
M src/include/utils/pg_locale.h

Remove redundant check for default collation.

commit   : 6a9fc11033e61d0dde30d5114887714dbd7612d5    
  
author   : Jeff Davis <[email protected]>    
date     : Thu, 12 Sep 2024 13:35:49 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Thu, 12 Sep 2024 13:35:49 -0700    

Click here for diff

The operative check is for a deterministic collation, so the check for  
DEFAULT_COLLATION is redundant. Furthermore, it will be wrong if we  
ever support a non-deterministic default collation.  
  
Author: Andreas Karlsson  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/varlena.c

Make jsonpath .string() be immutable for datetimes.

commit   : cb599b9ddfccd15e77f4c167c4e5bdf1ddc3af38    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 12 Sep 2024 14:30:29 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 12 Sep 2024 14:30:29 -0400    

Click here for diff

Discussion of commit ed055d249 revealed that we don't actually  
want jsonpath's .string() method to depend on DateStyle, nor  
TimeZone either, because the non-"_tz" jsonpath functions are  
supposed to be immutable.  Potentially we could allow a TimeZone  
dependency in the "_tz" variants, but it seems better to just  
uniformly define this method as returning the same string that  
jsonb text output would do.  That's easier to implement too,  
saving a couple dozen lines.  
  
Patch by me, per complaint from Peter Eisentraut.  Back-patch  
to v17 where this feature came in (in 66ea94e8e).  Also  
back-patch ed055d249 to provide test cases.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml
M src/backend/utils/adt/jsonpath_exec.c
M src/test/regress/expected/jsonb_jsonpath.out
M src/test/regress/sql/jsonb_jsonpath.sql

Add has_largeobject_privilege function.

commit   : 4eada203a5a871f893afe3eb3e07eea5de1aa642    
  
author   : Fujii Masao <[email protected]>    
date     : Thu, 12 Sep 2024 21:48:58 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Thu, 12 Sep 2024 21:48:58 +0900    

Click here for diff

This function checks whether a user has specific privileges on a large object,  
identified by OID. The user can be provided by name, OID,  
or default to the current user. If the specified large object doesn't exist,  
the function returns NULL. It raises an error for a non-existent user name.  
This behavior is basically consistent with other privilege inquiry functions  
like has_table_privilege.  
  
Bump catalog version.  
  
Author: Yugo Nagata  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml
M src/backend/utils/adt/acl.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql

Deduplicate code in LargeObjectExists and myLargeObjectExists.

commit   : 412229d197f894a01c163b9e9fdfec1a1855f7ab    
  
author   : Fujii Masao <[email protected]>    
date     : Thu, 12 Sep 2024 21:45:42 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Thu, 12 Sep 2024 21:45:42 +0900    

Click here for diff

myLargeObjectExists() and LargeObjectExists() had nearly identical code,  
except for handling snapshots. This commit renames myLargeObjectExists()  
to LargeObjectExistsWithSnapshot() and refactors LargeObjectExists()  
to call it internally, reducing duplication.  
  
Author: Yugo Nagata  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/catalog/pg_largeobject.c
M src/backend/storage/large_object/inv_api.c
M src/include/catalog/pg_largeobject.h

Remove hardcoded hash opclass function signature exceptions

commit   : 23d0b48468b8971b35d713754f7d5ecf54e5f78f    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 12 Sep 2024 12:52:37 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 12 Sep 2024 12:52:37 +0200    

Click here for diff

hashvalidate(), which validates the signatures of support functions  
for the hash AM, contained several hardcoded exceptions.  For example,  
hash/date_ops support function 1 was hashint4(), which would  
ordinarily fail validation because the function argument is int4, not  
date.  But this works internally because int4 and date are of the same  
size.  There are several more exceptions like this that happen to work  
and were allowed historically but would now fail the function  
signature validation.  
  
This patch removes those exceptions by providing new support functions  
that have the proper declared signatures.  They internally share most  
of the code with the "wrong" functions they replace, so the behavior  
is still the same.  
  
With the exceptions gone, hashvalidate() is now simplified and relies  
fully on check_amproc_signature().  
  
hashvarlena() and hashvarlenaextended() are kept in pg_proc.dat  
because some extensions currently use them to build hash functions for  
their own types, and we need to keep exposing these functions as  
"LANGUAGE internal" functions for that to continue to work.  
  
Reviewed-by: Tom Lane <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/access/hash/hashfunc.c
M src/backend/access/hash/hashvalidate.c
M src/backend/utils/adt/bool.c
M src/backend/utils/adt/date.c
M src/backend/utils/adt/timestamp.c
M src/backend/utils/adt/xid.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_amproc.dat
M src/include/catalog/pg_proc.dat

Doc: alphabetize aggregate function table

commit   : 5bb9ba2739896d2977e7318658135ba7e356e169    
  
author   : David Rowley <[email protected]>    
date     : Thu, 12 Sep 2024 22:36:39 +1200    
  
committer: David Rowley <[email protected]>    
date     : Thu, 12 Sep 2024 22:36:39 +1200    

Click here for diff

A few recent JSON aggregates have been added without much consideration  
to the existing order.  Put these back in alphabetical order (with the  
exception of the JSONB variant of each JSON aggregate).  
  
Author: Wolfgang Walther <[email protected]>  
Reviewed-by: Marlene Reiterer <[email protected]>  
Discussion: https://postgr.es/m/6a7b910c-3feb-4006-b817-9b4759cb6bb6%40technowledgy.de  
Backpatch-through: 16, where these aggregates were added  

M doc/src/sgml/func.sgml

Remove old RULE privilege completely.

commit   : fefa76f70fdc75c91f80bddce2df7a8825205962    
  
author   : Fujii Masao <[email protected]>    
date     : Thu, 12 Sep 2024 19:33:44 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Thu, 12 Sep 2024 19:33:44 +0900    

Click here for diff

The RULE privilege for tables was removed in v8.2, but for backward  
compatibility, GRANT/REVOKE and privilege functions like  
has_table_privilege continued to accept the RULE keyword without  
any effect.  
  
After discussions on pgsql-hackers, it was agreed that this compatibility  
is no longer needed. Since it's been long enough since the deprecation,  
we've decided to fully remove support for RULE privilege,  
so GRANT/REVOKE and privilege functions will no longer accept it.  
  
Author: Fujii Masao  
Reviewed-by: Nathan Bossart  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/catalog/aclchk.c
M src/backend/utils/adt/acl.c
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql

Don't overwrite scan key in systable_beginscan()

commit   : 811af9786b919d7acb22ea00ecb63f47de7942cd    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 8 Aug 2024 08:27:26 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 8 Aug 2024 08:27:26 +0200    

Click here for diff

When systable_beginscan() and systable_beginscan_ordered() choose an  
index scan, they remap the attribute numbers in the passed-in scan  
keys to the attribute numbers of the index, and then write those  
remapped attribute numbers back into the scan key passed by the  
caller.  This second part is surprising and gratuitous.  It means that  
a scan key cannot safely be used more than once (but it might  
sometimes work, depending on circumstances).  Also, there is no value  
in providing these remapped attribute numbers back to the caller,  
since they can't do anything with that.  
  
Fix that by making a copy of the scan keys passed by the caller and  
make the modifications there.  
  
Also, some code that had to work around the previous situation is  
simplified.  
  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/access/index/genam.c
M src/backend/utils/cache/catcache.c
M src/backend/utils/cache/relfilenumbermap.c

commit   : 00c76cf21c42c17e60e73a87dea0d1b4e234d9da    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 12 Sep 2024 13:32:05 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 12 Sep 2024 13:32:05 +0900    

Click here for diff

This brings more clarity to heapam.c, by cleanly separating all the  
logic related to WAL replay and the rest of Heap and Heap2, similarly  
to other RMGRs like hash, btree, etc.  
  
The header reorganization is also nice in heapam.c, cutting half of the  
headers required.  
  
Author: Li Yong  
Reviewed-by: Sutou Kouhei, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/Makefile
M src/backend/access/heap/heapam.c
A src/backend/access/heap/heapam_xlog.c
M src/backend/access/heap/meson.build
M src/include/access/heapam.h

Adjust tuplestore stats API

commit   : 9fba1ed2947382af213dfbfabfcd8898c89bf4ca    
  
author   : David Rowley <[email protected]>    
date     : Thu, 12 Sep 2024 16:02:01 +1200    
  
committer: David Rowley <[email protected]>    
date     : Thu, 12 Sep 2024 16:02:01 +1200    

Click here for diff

1eff8279d added an API to tuplestore.c to allow callers to obtain  
storage telemetry data.  That API wasn't quite good enough for callers  
that perform tuplestore_clear() as the telemetry functions only  
accounted for the current state of the tuplestore, not the maximums  
before tuplestore_clear() was called.  
  
There's a pending patch that would like to add tuplestore telemetry  
output to EXPLAIN ANALYZE for WindowAgg.  That node type uses  
tuplestore_clear() before moving to the next window partition and we  
want to show the maximum space used, not the space used for the final  
partition.  
  
Reviewed-by: Tatsuo Ishii, Ashutosh Bapat  
Discussion: https://postgres/m/CAApHDvoY8cibGcicLV0fNh=9JVx9PANcWvhkdjBnDCc9Quqytg@mail.gmail.com  

M src/backend/commands/explain.c
M src/backend/utils/sort/tuplestore.c
M src/include/utils/tuplestore.h

SQL/JSON: Fix JSON_QUERY(... WITH CONDITIONAL WRAPPER)

commit   : e6c45d85dc168fb05b5ee5596a4de5167c9fe01f    
  
author   : Amit Langote <[email protected]>    
date     : Thu, 12 Sep 2024 09:36:31 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Thu, 12 Sep 2024 09:36:31 +0900    

Click here for diff

Currently, when WITH CONDITIONAL WRAPPER is specified, array wrappers  
are applied even to a single SQL/JSON item if it is a scalar JSON  
value, but this behavior does not comply with the standard.  
  
To fix, apply wrappers only when there are multiple SQL/JSON items  
in the result.  
  
Reported-by: Peter Eisentraut <[email protected]>  
Author: Peter Eisentraut <[email protected]>  
Author: Amit Langote <[email protected]>  
Reviewed-by: Andrew Dunstan <[email protected]>  
Discussion: https://postgr.es/m/8022e067-818b-45d3-8fab-6e0d94d03626%40eisentraut.org  
Backpatch-through: 17  

M src/backend/utils/adt/jsonpath_exec.c
M src/test/regress/expected/sqljson_queryfuncs.out
M src/test/regress/sql/sqljson_queryfuncs.sql

Remove incorrect Assert.

commit   : 77761ee5dddc0518235a51c533893e81e5f375b9    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 11 Sep 2024 11:41:47 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 11 Sep 2024 11:41:47 -0400    

Click here for diff

check_agglevels_and_constraints() asserted that if we find an  
aggregate function in an EXPR_KIND_FROM_SUBSELECT expression, the  
expression must be in a LATERAL subquery.  Alexander Lakhin found a  
case where that's not so: because of the odd scoping rules for NEW/OLD  
within a rule, a reference to NEW/OLD could cause an aggregate to be  
considered top-level even though it's in an unmarked sub-select.  
The error message that would be thrown seems sufficiently on-point,  
so just remove the Assert.  (Hence, this is not a bug for production  
builds.)  
  
This Assert was added by me in commit eaccfded9 (9.3 era).  It looks  
like I put it in to cross-check that the new logic for detecting  
misplaced aggregates (using agglevelsup) caught the same cases that a  
previous check on p_lateral_active did.  So there might have been some  
related misbehavior before eaccfded9 ... but that's very ancient  
history by now, so I didn't dig any deeper.  
  
Per bug #18608 from Alexander Lakhin.  Back-patch to all supported  
branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/parser/parse_agg.c

pg_createsubscriber: minor documentation fixes

commit   : 280423300b361eb9deff5ea40d4b0e6fab00211b    
  
author   : Magnus Hagander <[email protected]>    
date     : Wed, 11 Sep 2024 16:30:17 +0200    
  
committer: Magnus Hagander <[email protected]>    
date     : Wed, 11 Sep 2024 16:30:17 +0200    

Click here for diff

M doc/src/sgml/ref/pg_createsubscriber.sgml

Replace gratuitous memmove() with memcpy()

commit   : 8b5c6a54c4396bb9daeb9ec5d9cbb0d3deedcbe3    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 11 Sep 2024 15:15:49 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 11 Sep 2024 15:15:49 +0200    

Click here for diff

The index access methods all had similar code that copied the  
passed-in scan keys to local storage.  They all used memmove() for  
that, which is not wrong, but it seems confusing not to use memcpy()  
when that would work.  Presumably, this was all once copied from  
ancient code and never adjusted.  
  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M contrib/bloom/blscan.c
M src/backend/access/brin/brin.c
M src/backend/access/gin/ginscan.c
M src/backend/access/gist/gistscan.c
M src/backend/access/hash/hash.c
M src/backend/access/nbtree/nbtree.c
M src/backend/access/spgist/spgscan.c

Fix unique key checks in JSON object constructors

commit   : 842265631dfd9e5583d934e2ae328b09bc4b2f8b    
  
author   : Tomas Vondra <[email protected]>    
date     : Wed, 11 Sep 2024 13:21:05 +0200    
  
committer: Tomas Vondra <[email protected]>    
date     : Wed, 11 Sep 2024 13:21:05 +0200    

Click here for diff

When building a JSON object, the code builds a hash table of keys, to  
allow checking if the keys are unique. The uniqueness check and adding  
the new key happens in json_unique_check_key(), but this assumes the  
pointer to the key remains valid.  
  
Unfortunately, two places passed pointers to keys in a buffer, while  
also appending more data (additional key/value pairs) to the buffer.  
With enough data the buffer is resized by enlargeStringInfo(), which  
calls repalloc(), invalidating the earlier key pointers.  
  
Due to this the uniqueness check may fail with both false negatives and  
false positives, producing JSON objects with duplicate keys or failing  
to produce a perfectly valid JSON object.  
  
This affects multiple functions that enforce uniqueness of keys, all  
introduced in PG16 with the new SQL/JSON:  
  
- json_object_agg_unique / jsonb_object_agg_unique  
- json_object / jsonb_objectagg  
  
Existing regression tests did not detect the issue, simply because the  
initial buffer size is 1024 and the objects were small enough not to  
require the repalloc.  
  
With a sufficiently large object, AddressSanitizer reported the access  
to invalid memory immediately. So would valgrind, of course.  
  
Fixed by copying the key into the hash table memory context, and adding  
regression tests with enough data to repalloc the buffer. Backpatch to  
16, where the functions were introduced.  
  
Reported by Alexander Lakhin. Investigation and initial fix by Junwang  
Zhao, with various improvements and tests by me.  
  
Reported-by: Alexander Lakhin  
Author: Junwang Zhao, Tomas Vondra  
Backpatch-through: 16  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/CAEG8a3JjH0ReJF2_O7-8LuEbO69BxPhYeXs95_x7+H9AMWF1gw@mail.gmail.com  

M src/backend/utils/adt/json.c
M src/test/regress/expected/json.out
M src/test/regress/expected/sqljson.out
M src/test/regress/sql/json.sql
M src/test/regress/sql/sqljson.sql

Update .gitignore

commit   : 6b25c57a2dd61a44bdb60d5424d4aaa7e0f14334    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 11 Sep 2024 09:26:20 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 11 Sep 2024 09:26:20 +0200    

Click here for diff

for commit 0785d1b8b2  

M src/test/modules/test_json_parser/.gitignore

Remove obsolete unconstify()

commit   : 1fb2308e698ec7aebc1b6676f29e3363a1281479    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 11 Sep 2024 09:18:12 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 11 Sep 2024 09:18:12 +0200    

Click here for diff

This is no longer needed as of OpenSSL 1.1.0 (the current minimum  
version).  LibreSSL made the same change around the same time as well.  
  
Reviewed-by: Daniel Gustafsson <[email protected]>  
Discussion: https://www.postgresql.org/message-id/20463f79-a7b0-4bba-a178-d805f99c02f9%40eisentraut.org  

M src/backend/libpq/be-secure-openssl.c

common/jsonapi: support libpq as a client

commit   : 0785d1b8b2fa27074eeb18a3ac1f2a0e76cb8339    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 11 Sep 2024 08:28:35 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 11 Sep 2024 08:28:35 +0200    

Click here for diff

Based on a patch by Michael Paquier.  
  
For libpq, use PQExpBuffer instead of StringInfo. This requires us to  
track allocation failures so that we can return JSON_OUT_OF_MEMORY as  
needed rather than exit()ing.  
  
Author: Jacob Champion <[email protected]>  
Co-authored-by: Michael Paquier <[email protected]>  
Co-authored-by: Daniel Gustafsson <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/common/Makefile
M src/common/jsonapi.c
M src/common/meson.build
M src/include/common/jsonapi.h
M src/test/modules/test_json_parser/Makefile
M src/test/modules/test_json_parser/meson.build
M src/test/modules/test_json_parser/t/001_test_json_parser_incremental.pl
M src/test/modules/test_json_parser/t/002_inline.pl
M src/test/modules/test_json_parser/t/003_test_semantic.pl

Improve assertion in FindReplTupleInLocalRel().

commit   : 3beb945da9d72a9803180deb1752cf8feeb66883    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 11 Sep 2024 09:18:23 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 11 Sep 2024 09:18:23 +0530    

Click here for diff

The first part of the assertion verifying that the passed index must be PK  
or RI was incorrectly passing index relation instead of heap relation in  
GetRelationIdentityOrPK(). The assertion was not failing because the  
second part of the assertion which needs to be performed only when remote  
relation has REPLICA_IDENTITY_FULL set was also incorrect.  
  
The change is not backpatched because the current coding doesn't lead to  
any failure.  
  
Reported-by: Dilip Kumar  
Author: Amit Kapila  
Reviewed-by: Vignesh C  
Discussion: https://postgr.es/m/CAFiTN-tmguaT1DXbCC+ZomZg-oZLmU6BPhr0po7akQSG6vNJrg@mail.gmail.com  

M src/backend/replication/logical/worker.c

Optimize pg_visibility with read streams.

commit   : 65c310b310a613d86c1ba94891fa9972587e09fd    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 10 Sep 2024 15:21:33 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 10 Sep 2024 15:21:33 -0700    

Click here for diff

We've measured 5% performance improvement, and this arranges to benefit  
automatically from future optimizations to the read_stream subsystem.  
The area lacked test coverage, so close that gap.  
  
Nazir Bilal Yavuz  
  
Discussion: https://postgr.es/m/CAN55FZ1_Ru3XpMgTwsU67FTH2fs_FrRROmb7x6zs+F44QBEiww@mail.gmail.com  
Discussion: https://postgr.es/m/CAEudQAozv3wTY5TV2t29JcwPydbmKbiWQkZD42S2OgzdixPMDQ@mail.gmail.com  

M contrib/pg_visibility/meson.build
M contrib/pg_visibility/pg_visibility.c
A contrib/pg_visibility/t/002_corrupt_vm.pl

Use a hash table to de-duplicate column names in ruleutils.c.

commit   : 52c707483ce4d0161127e4958d981d1b5655865e    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 10 Sep 2024 16:49:09 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 10 Sep 2024 16:49:09 -0400    

Click here for diff

Commit 8004953b5 added a hash table to avoid O(N^2) cost in choosing  
unique relation aliases while deparsing a view or rule.  It did  
nothing about the similar O(N^2) (maybe worse) costs of choosing  
unique column aliases within each RTE.  However, that's now  
demonstrably a bottleneck when deparsing CHECK constraints for wide  
tables, so let's use a similar hash table to handle those.  
  
The extra cost of setting up the hash table will not be repaid unless  
the table has many columns.  I've set this up so that we use the brute  
force method if there are less than 32 columns.  The exact cutoff is  
not too critical, but this value seems good because it results in both  
code paths getting exercised by existing regression-test cases.  
  
Patch by me; thanks to David Rowley for review.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/ruleutils.c

Fix some whitespace issues in XMLSERIALIZE(... INDENT).

commit   : bccca780eef904002512a1a0b5ce617bcb63507b    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 10 Sep 2024 16:20:31 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 10 Sep 2024 16:20:31 -0400    

Click here for diff

We must drop whitespace while parsing the input, else libxml2  
will include "blank" nodes that interfere with the desired  
indentation behavior.  The end result is that we didn't indent  
nodes separated by whitespace.  
  
Also, it seems that libxml2 may add a trailing newline when working  
in DOCUMENT mode.  This is semantically insignificant, so strip it.  
  
This is in the gray area between being a bug fix and a definition  
change.  However, the INDENT option is still pretty new (since v16),  
so I think we can get away with changing this in stable branches.  
Hence, back-patch to v16.  
  
Jim Jones  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/xml.c
M src/test/regress/expected/xml.out
M src/test/regress/expected/xml_1.out
M src/test/regress/expected/xml_2.out
M src/test/regress/sql/xml.sql

Improve documentation and testing of jsonpath string() for datetimes.

commit   : ed055d249df577ab40470f9dc1a30ab18ffdfff4    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 10 Sep 2024 14:48:13 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 10 Sep 2024 14:48:13 -0400    

Click here for diff

Point out that the output format depends on DateStyle, and test that,  
along with testing some cases previously not covered.  
  
In passing, adjust the horology test to verify that the prevailing  
DateStyle is 'Postgres, MDY', much as it has long verified the  
prevailing TimeZone.  We expect pg_regress to have set these up,  
and there are multiple regression tests relying on these settings.  
  
Also make the formatting of entries in table 9.50 more consistent.  
  
David Wheeler (marginal additional hacking by me); review by jian he  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml
M src/test/regress/expected/horology.out
M src/test/regress/expected/jsonb_jsonpath.out
M src/test/regress/sql/horology.sql
M src/test/regress/sql/jsonb_jsonpath.sql

Add PG_TEST_PG_COMBINEBACKUP_MODE to CI tasks

commit   : 861086493faa9ca5468cc50dd20975ee6c042ffe    
  
author   : Tomas Vondra <[email protected]>    
date     : Tue, 10 Sep 2024 16:27:55 +0200    
  
committer: Tomas Vondra <[email protected]>    
date     : Tue, 10 Sep 2024 16:27:55 +0200    

Click here for diff

The environment variable PG_TEST_PG_COMBINEBACKUP_MODE has been  
available since 35a7b288b975, but was not set by any built-in CI tasks.  
This commit modifies two of the CI tasks to use the alternative modes,  
to exercise the pg_combinebackup code.  
  
The Linux task uses --copy-file-range, macOS uses --clone.  
  
This is not an exhaustive test of combinations. The supported modes  
depend on the operating system and filesystem, and it would be nice to  
test all supported combinations. Right now we have just one task for  
each OS, and it doesn't seem worth adding more just for this.  
  
Reported-by: Peter Eisentraut  
Reviewed-by: Peter Eisentraut  
Discussion: https://postgr.es/m/48da4a1f-ccd9-4988-9622-24f37b1de2b4%40eisentraut.org  

M .cirrus.tasks.yml

Protect against small overread in SASLprep validation

commit   : 390b3cbbb2af3c749587b0697c01c94e0e173510    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Tue, 10 Sep 2024 11:02:28 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Tue, 10 Sep 2024 11:02:28 +0200    

Click here for diff

In case of torn UTF8 in the input data we might end up going  
past the end of the string since we don't account for length.  
While validation won't be performed on a sequence with a NULL  
byte it's better to avoid going past the end to beging with.  
Fix by taking the length into consideration.  
  
Author: Jacob Champion <[email protected]>  
Reviewed-by: Daniel Gustafsson <[email protected]>  
Discussion: https://postgr.es/m/CAOYmi+mTnmM172g=_+Yvc47hzzeAsYPy2C4UBY3HK9p-AXNV0g@mail.gmail.com  

M src/common/saslprep.c

Add amgettreeheight index AM API routine

commit   : 56fead44dcc70df9f9188fee08e5aefe3da43ccc    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 10 Sep 2024 09:51:55 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 10 Sep 2024 09:51:55 +0200    

Click here for diff

The only current implementation is for btree where it calls  
_bt_getrootheight().  Other index types can now also use this to pass  
information to their amcostestimate routine.  Previously, btree was  
hardcoded and other index types could not hook into the optimizer at  
this point.  
  
Author: Mark Dilger <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M contrib/bloom/blutils.c
M doc/src/sgml/indexam.sgml
M src/backend/access/brin/brin.c
M src/backend/access/gin/ginutil.c
M src/backend/access/gist/gist.c
M src/backend/access/hash/hash.c
M src/backend/access/nbtree/nbtree.c
M src/backend/access/spgist/spgutils.c
M src/backend/optimizer/util/plancat.c
M src/include/access/amapi.h
M src/include/access/nbtree.h
M src/test/modules/dummy_index_am/dummy_index_am.c

Mark expressions nullable by grouping sets

commit   : f5050f795aea67dfc40bbc429c8934e9439e22e7    
  
author   : Richard Guo <[email protected]>    
date     : Tue, 10 Sep 2024 12:36:48 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Tue, 10 Sep 2024 12:36:48 +0900    

Click here for diff

When generating window_pathkeys, distinct_pathkeys, or sort_pathkeys,  
we failed to realize that the grouping/ordering expressions might be  
nullable by grouping sets.  As a result, we may incorrectly deem that  
the PathKeys are redundant by EquivalenceClass processing and thus  
remove them from the pathkeys list.  That would lead to wrong results  
in some cases.  
  
To fix this issue, we mark the grouping expressions nullable by  
grouping sets if that is the case.  If the grouping expression is a  
Var or PlaceHolderVar or constructed from those, we can just add the  
RT index of the RTE_GROUP RTE to the existing nullingrels field(s);  
otherwise we have to add a PlaceHolderVar to carry on the nullingrel  
bit.  
  
However, we have to manually remove this nullingrel bit from  
expressions in various cases where these expressions are logically  
below the grouping step, such as when we generate groupClause pathkeys  
for grouping sets, or when we generate PathTarget for initial input to  
grouping nodes.  
  
Furthermore, in set_upper_references, the targetlist and quals of an  
Agg node should have nullingrels that include the effects of the  
grouping step, ie they will have nullingrels equal to the input  
Vars/PHVs' nullingrels plus the nullingrel bit that references the  
grouping RTE.  In order to perform exact nullingrels matches, we also  
need to manually remove this nullingrel bit.  
  
Bump catversion because this changes the querytree produced by the  
parser.  
  
Thanks to Tom Lane for the idea to invent a new kind of RTE.  
  
Per reports from Geoff Winkless, Tobias Wendorff, Richard Guo from  
various threads.  
  
Author: Richard Guo  
Reviewed-by: Ashutosh Bapat, Sutou Kouhei  
Discussion: https://postgr.es/m/CAMbWs4_dp7e7oTwaiZeBX8+P1rXw4ThkZxh1QG81rhu9Z47VsQ@mail.gmail.com  

M src/backend/optimizer/path/equivclass.c
M src/backend/optimizer/path/pathkeys.c
M src/backend/optimizer/plan/initsplan.c
M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/plan/setrefs.c
M src/backend/optimizer/util/var.c
M src/backend/parser/parse_agg.c
M src/include/catalog/catversion.h
M src/include/optimizer/paths.h
M src/test/regress/expected/groupingsets.out
M src/test/regress/sql/groupingsets.sql

Introduce an RTE for the grouping step

commit   : 247dea89f7616fdf06b7272b74abafc29e8e5860    
  
author   : Richard Guo <[email protected]>    
date     : Tue, 10 Sep 2024 12:35:34 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Tue, 10 Sep 2024 12:35:34 +0900    

Click here for diff

If there are subqueries in the grouping expressions, each of these  
subqueries in the targetlist and HAVING clause is expanded into  
distinct SubPlan nodes.  As a result, only one of these SubPlan nodes  
would be converted to reference to the grouping key column output by  
the Agg node; others would have to get evaluated afresh.  This is not  
efficient, and with grouping sets this can cause wrong results issues  
in cases where they should go to NULL because they are from the wrong  
grouping set.  Furthermore, during re-evaluation, these SubPlan nodes  
might use nulled column values from grouping sets, which is not  
correct.  
  
This issue is not limited to subqueries.  For other types of  
expressions that are part of grouping items, if they are transformed  
into another form during preprocessing, they may fail to match lower  
target items.  This can also lead to wrong results with grouping sets.  
  
To fix this issue, we introduce a new kind of RTE representing the  
output of the grouping step, with columns that are the Vars or  
expressions being grouped on.  In the parser, we replace the grouping  
expressions in the targetlist and HAVING clause with Vars referencing  
this new RTE, so that the output of the parser directly expresses the  
semantic requirement that the grouping expressions be gotten from the  
grouping output rather than computed some other way.  In the planner,  
we first preprocess all the columns of this new RTE and then replace  
any Vars in the targetlist and HAVING clause that reference this new  
RTE with the underlying grouping expressions, so that we will have  
only one instance of a SubPlan node for each subquery contained in the  
grouping expressions.  
  
Bump catversion because this changes the querytree produced by the  
parser.  
  
Thanks to Tom Lane for the idea to invent a new kind of RTE.  
  
Per reports from Geoff Winkless, Tobias Wendorff, Richard Guo from  
various threads.  
  
Author: Richard Guo  
Reviewed-by: Ashutosh Bapat, Sutou Kouhei  
Discussion: https://postgr.es/m/CAMbWs4_dp7e7oTwaiZeBX8+P1rXw4ThkZxh1QG81rhu9Z47VsQ@mail.gmail.com  

M src/backend/commands/explain.c
M src/backend/nodes/nodeFuncs.c
M src/backend/nodes/outfuncs.c
M src/backend/nodes/print.c
M src/backend/nodes/readfuncs.c
M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/plan/setrefs.c
M src/backend/optimizer/prep/prepjointree.c
M src/backend/optimizer/util/var.c
M src/backend/parser/parse_agg.c
M src/backend/parser/parse_relation.c
M src/backend/parser/parse_target.c
M src/backend/utils/adt/ruleutils.c
M src/include/catalog/catversion.h
M src/include/commands/explain.h
M src/include/nodes/nodeFuncs.h
M src/include/nodes/parsenodes.h
M src/include/nodes/pathnodes.h
M src/include/optimizer/optimizer.h
M src/include/parser/parse_node.h
M src/include/parser/parse_relation.h
M src/test/regress/expected/groupingsets.out
M src/test/regress/sql/groupingsets.sql
M src/tools/pgindent/typedefs.list

Remove emode argument from XLogFileRead() and XLogFileReadAnyTLI()

commit   : fba49d5293b4455b25485450baf02af42bf543d7    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 10 Sep 2024 08:44:31 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 10 Sep 2024 08:44:31 +0900    

Click here for diff

This change makes the code slightly easier to reason about, because  
there is actually no need to know if a specific caller of one of these  
routines should fail hard on a PANIC, or just let it go through with a  
DEBUG2.  
  
The only caller of XLogFileReadAnyTLI() used DEBUG2, and XLogFileRead()  
has never used its emode.  This can be simplified since 1bb2558046cc  
that has introduced XLogFileReadAnyTLI(), splitting both.  
  
Author: Yugo Nagata  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/xlogrecovery.c

Add WAL usage reporting to ANALYZE VERBOSE output.

commit   : bb7775234273268e8852068ee1a2eff9cd2a0020    
  
author   : Masahiko Sawada <[email protected]>    
date     : Mon, 9 Sep 2024 14:56:08 -0700    
  
committer: Masahiko Sawada <[email protected]>    
date     : Mon, 9 Sep 2024 14:56:08 -0700    

Click here for diff

This change adds WAL usage reporting to the output of ANALYZE VERBOSE  
and autoanalyze reports. It aligns the analyze output with VACUUM,  
providing consistency. Additionally, it aids in troubleshooting cases  
where WAL records are generated during analyze operations.  
  
Author: Anthonin Bonnefoy  
Reviewed-by: Masahiko Sawada  
Discussion: https://postgr.es/m/CAO6_Xqr__kTTCLkftqS0qSCm-J7_xbRG3Ge2rWhucxQJMJhcRA%40mail.gmail.com  

M src/backend/commands/analyze.c

Consistently use PageGetExactFreeSpace() in pgstattuple.

commit   : de239d01e7ccf7648e964d7a38c0f1c36bde8346    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 9 Sep 2024 14:34:10 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 9 Sep 2024 14:34:10 -0400    

Click here for diff

Previously this code used PageGetHeapFreeSpace on heap pages,  
and usually used PageGetFreeSpace on index pages (though for some  
reason GetHashPageStats used PageGetExactFreeSpace instead).  
The difference is that those functions subtract off the size of  
a line pointer, and PageGetHeapFreeSpace has some additional  
rules about returning zero if adding another line pointer would  
require exceeding MaxHeapTuplesPerPage.  Those things make sense  
when testing to see if a new tuple can be put on the page, but  
they seem pretty strange for pure statistics collection.  
  
Additionally, statapprox_heap had a special rule about counting  
a "new" page as being fully available space.  This also seems  
strange, because it's not actually usable until VACUUM or some  
such process initializes the page.  Moreover, it's inconsistent  
with what pgstat_heap does, which is to count such a page as  
having zero free space.  So make it work like pgstat_heap, which  
as of this patch unconditionally calls PageGetExactFreeSpace.  
  
This is more of a definitional change than a bug fix, so no  
back-patch.  The module's documentation doesn't define exactly  
what "free space" means either, so we left that as-is.  
  
Frédéric Yhuel, reviewed by Rafia Sabih and Andreas Karlsson.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pgstattuple/pgstatapprox.c
M contrib/pgstattuple/pgstatindex.c
M contrib/pgstattuple/pgstattuple.c

Don't bother checking the result of SPI_connect[_ext] anymore.

commit   : 218527d01456b65decdc7596c6f6d5ac2bdeb78b    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 9 Sep 2024 12:18:32 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 9 Sep 2024 12:18:32 -0400    

Click here for diff

SPI_connect/SPI_connect_ext have not returned any value other than  
SPI_OK_CONNECT since commit 1833f1a1c in v10; any errors are thrown  
via ereport.  (The most likely failure is out-of-memory, which has  
always been thrown that way, so callers had better be prepared for  
such errors.)  This makes it somewhat pointless to check these  
functions' result, and some callers within our code haven't been  
bothering; indeed, the only usage example within spi.sgml doesn't  
bother.  So it's likely that the omission has propagated into  
extensions too.  
  
Hence, let's standardize on not checking, and document the return  
value as historical, while not actually changing these functions'  
behavior.  (The original proposal was to change their return type  
to "void", but that would needlessly break extensions that are  
conforming to the old practice.)  This saves a small amount of  
boilerplate code in a lot of places.  
  
Stepan Neretin  
  
Discussion: https://postgr.es/m/CAMaYL5Z9Uk8cD9qGz9QaZ2UBJFOu7jFx5Mwbznz-1tBbPDQZow@mail.gmail.com  

M contrib/dblink/dblink.c
M contrib/spi/refint.c
M contrib/tablefunc/tablefunc.c
M contrib/xml2/xpath.c
M doc/src/sgml/spi.sgml
M doc/src/sgml/trigger.sgml
M src/backend/commands/matview.c
M src/backend/utils/adt/ri_triggers.c
M src/backend/utils/adt/ruleutils.c
M src/pl/plperl/plperl.c
M src/pl/plpgsql/src/pl_handler.c
M src/pl/plpython/plpy_main.c
M src/pl/tcl/pltcl.c
M src/test/modules/plsample/plsample.c
M src/test/modules/test_predtest/test_predtest.c
M src/test/regress/regress.c

Add PQfullProtocolVersion() to surface the precise protocol version.

commit   : cdb6b0fdb0b2face270406905d31f8f513b015cc    
  
author   : Robert Haas <[email protected]>    
date     : Mon, 9 Sep 2024 11:54:55 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Mon, 9 Sep 2024 11:54:55 -0400    

Click here for diff

The existing function PQprotocolVersion() does not include the minor  
version of the protocol.  In preparation for pending work that will  
bump that number for the first time, add a new function to provide it  
to clients that may care, using the (major * 10000 + minor)  
convention already used by PQserverVersion().  
  
Jacob Champion based on earlier work by Jelte Fennema-Nio  
  
Discussion: http://postgr.es/m/CAOYmi+mM8+6Swt1k7XsLcichJv8xdhPnuNv7-02zJWsezuDL+g@mail.gmail.com  

M doc/src/sgml/libpq.sgml
M src/include/libpq/pqcomm.h
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/libpq-fe.h

Fix waits of REINDEX CONCURRENTLY for indexes with predicates or expressions

commit   : 5bbdfa8a18dc56d3e64aa723a68e02e897cb5ec3    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 9 Sep 2024 13:49:36 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 9 Sep 2024 13:49:36 +0900    

Click here for diff

As introduced by f9900df5f94, a REINDEX CONCURRENTLY job done for an  
index with predicates or expressions would set PROC_IN_SAFE_IC in its  
MyProc->statusFlags, causing it to be ignored by other concurrent  
operations.  
  
Such concurrent index rebuilds should never be ignored, as a predicate  
or an expression could call a user-defined function that accesses a  
different table than the table where the index is rebuilt.  
  
A test that uses injection points is added, backpatched down to 17.  
Michail has proposed a different test, but I have added something  
simpler with more coverage.  
  
Oversight in f9900df5f949.  
  
Author: Michail Nikolaev  
Discussion: https://postgr.es/m/CANtu0oj9A3kZVduFTG0vrmGnKB+DCHgEpzOp0qAyOgmks84j0w@mail.gmail.com  
Backpatch-through: 14  

M src/backend/commands/indexcmds.c
M src/test/modules/injection_points/Makefile
A src/test/modules/injection_points/expected/reindex_conc.out
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/sql/reindex_conc.sql

SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY steps

commit   : dd8bea88abf4794d99270ced884a8bc1e387255d    
  
author   : Amit Langote <[email protected]>    
date     : Mon, 9 Sep 2024 13:46:58 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Mon, 9 Sep 2024 13:46:58 +0900    

Click here for diff

When the ON ERROR / ON EMPTY behavior is to return NULL, returning  
NULL directly from ExecEvalJsonExprPath() suffices. Therefore, there's  
no need to create separate steps to check the error/empty flag or  
those to evaluate the the constant NULL expression.  This speeds up  
common cases because the default ON ERROR / ON EMPTY behavior for  
JSON_QUERY() and JSON_VALUE() is to return NULL.  However, these steps  
are necessary if the RETURNING type is a domain, as constraints on the  
domain may need to be checked.  
  
Reported-by: Jian He <[email protected]>  
Author: Jian He <[email protected]>  
Author: Amit Langote <[email protected]>  
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com  
Backpatch-through: 17  

M src/backend/executor/execExpr.c
M src/backend/executor/execExprInterp.c

Fix order of parameters in a cost_sort call

commit   : 87b6c3c0b703c3a71bc640f456a24937744ff30b    
  
author   : Richard Guo <[email protected]>    
date     : Mon, 9 Sep 2024 12:58:31 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Mon, 9 Sep 2024 12:58:31 +0900    

Click here for diff

In label_sort_with_costsize, the cost_sort function is called with the  
parameters 'input_disabled_nodes' and 'input_cost' in the wrong order.  
This does not cause any plan diffs in the regression tests, because  
label_sort_with_costsize is only used to label the Sort node nicely  
for EXPLAIN, and cost numbers are not displayed in regression tests.  
  
Oversight in e22253467.  Fixed by passing arguments in the right  
order.  
  
Per report from Alexander Lakhin running UBSan.  
  
Author: Alexander Lakhin  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/optimizer/plan/createplan.c

Add callbacks to control flush of fixed-numbered stats

commit   : fc415edf8ca883b38cf8186f0d4b794d4a738cd5    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 9 Sep 2024 11:12:29 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 9 Sep 2024 11:12:29 +0900    

Click here for diff

This commit adds two callbacks in pgstats to have a better control of  
the flush timing of pgstat_report_stat(), whose operation depends on the  
three PGSTAT_*_INTERVAL variables:  
- have_fixed_pending_cb(), to check if a stats kind has any pending  
data waiting for a flush.  This is used as a fast path if there are no  
pending statistics to flush, and this check is done for fixed-numbered  
statistics only if there are no variable-numbered statistics to flush.  
A flush will need to happen if at least one callback reports any pending  
data.  
- flush_fixed_cb(), to do the actual flush.  
  
These callbacks are currently used by the SLRU, WAL and IO statistics,  
generalizing the concept for all stats kinds (builtin and custom).  
  
The SLRU and IO stats relied each on one global variable to determine  
whether a flush should happen; these are now local to pgstat_slru.c and  
pgstat_io.c, cleaning up a bit how the pending flush states are tracked  
in pgstat.c.  
  
pgstat_flush_io() and pgstat_flush_wal() are still required, but we do  
not need to check their return result anymore.  
  
Reviewed-by: Bertrand Drouvot, Kyotaro Horiguchi  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_io.c
M src/backend/utils/activity/pgstat_slru.c
M src/backend/utils/activity/pgstat_wal.c
M src/include/utils/pgstat_internal.h

Avoid core dump after getpwuid_r failure.

commit   : 2e62fa62d6745ba3bcb0a517d002aff1f3cdefb7    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 8 Sep 2024 19:14:40 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 8 Sep 2024 19:14:40 -0400    

Click here for diff

Looking up a nonexistent user ID would lead to a null pointer  
dereference.  That's unlikely to happen here, but perhaps  
not impossible.  
  
Thinko in commit 4d5111b3f, noticed by Coverity.  

M src/interfaces/libpq/fe-auth.c

Update extension lookup routines to use the syscache

commit   : d8df7ac5c04cd17bf13bd3123dcfcaf8007c6280    
  
author   : Michael Paquier <[email protected]>    
date     : Sat, 7 Sep 2024 20:20:46 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Sat, 7 Sep 2024 20:20:46 +0900    

Click here for diff

The following routines are changed to use the syscache entries added for  
pg_extension in 490f869d92e5:  
- get_extension_oid()  
- get_extension_name()  
- get_extension_schema()  
  
A catalog scan is costly and could easily lead to a noticeable  
performance impact when called once or more per query, so this is going  
to be helpful for developers for extension data lookups.  
  
Author: Andrei Lepikhov  
Reviewed-by: Jelte Fennema-Nio  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/extension.c

Remove lc_ctype_is_c().

commit   : 51edc4ca54f826cfac012c7306eee479f07a5dc7    
  
author   : Jeff Davis <[email protected]>    
date     : Fri, 6 Sep 2024 13:23:21 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Fri, 6 Sep 2024 13:23:21 -0700    

Click here for diff

Instead always fetch the locale and look at the ctype_is_c field.  
  
hba.c relies on regexes working for the C locale without needing  
catalog access, which worked before due to a special case for  
C_COLLATION_OID in lc_ctype_is_c(). Move the special case to  
pg_set_regex_collation() now that lc_ctype_is_c() is gone.  
  
Author: Andreas Karlsson  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/regex/regc_pg_locale.c
M src/backend/utils/adt/formatting.c
M src/backend/utils/adt/like.c
M src/backend/utils/adt/like_support.c
M src/backend/utils/adt/pg_locale.c
M src/include/catalog/pg_collation.dat
M src/include/utils/pg_locale.h

Fix incorrect pg_stat_io output on 32-bit machines.

commit   : 129a2f6679fd8891384016b6e2cde6cefda22a7d    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 6 Sep 2024 11:57:57 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 6 Sep 2024 11:57:57 -0400    

Click here for diff

pg_stat_get_io() applied TimestampTzGetDatum twice to the  
stat_reset_timestamp value.  On 64-bit builds that's harmless because  
TimestampTzGetDatum is a no-op, but on 32-bit builds it results in  
displaying garbage in the stats_reset column of the pg_stat_io view.  
  
Bug dates to commit a9c70b46d which introduced pg_stat_io, so  
back-patch to v16 where that came in.  
  
Bertrand Drouvot  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/pgstatfuncs.c

Remove useless unconstify

commit   : 9e43ab3dd79ddb5a6a3f7cdb5b1d6dffc9e7765b    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 6 Sep 2024 11:25:48 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 6 Sep 2024 11:25:48 +0200    

Click here for diff

Digging into the history, this was not necessary even when it was  
added, but might have been some time before that.  In any case, there  
is no use for this now.  

M src/backend/utils/adt/formatting.c

SQL/JSON: Fix default ON ERROR behavior for JSON_TABLE

commit   : bbd4c058a89b1e756eb646af89a4ef90f0df144e    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 13:25:14 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 13:25:14 +0900    

Click here for diff

Use EMPTY ARRAY instead of EMPTY.  
  
This change does not affect the runtime behavior of JSON_TABLE(),  
which continues to return an empty relation ON ERROR. It only alters  
whether the default ON ERROR behavior is shown in the deparsed output.  
  
Reported-by: Jian He <[email protected]>  
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com  
Backpatch-through: 17  

M src/backend/parser/parse_expr.c
M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

SQL/JSON: Fix JSON_TABLE() column deparsing

commit   : ee75a03f37fc27c7f07a21dc22edf4511e31a4a1    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 13:25:02 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 13:25:02 +0900    

Click here for diff

The deparsing code in get_json_expr_options() unnecessarily emitted  
the default column-specific ON ERROR / EMPTY behavior when the  
top-level ON ERROR behavior in JSON_TABLE was set to ERROR. Fix that  
by not overriding the column-specific default, determined based on  
the column's JsonExprOp in get_json_table_columns(), with  
JSON_BEHAVIOR_ERROR when that is the top-level ON ERROR behavior.  
  
Note that this only removes redundancy; the current deparsing output  
is not incorrect, just redundant.  
  
Reviewed-by: Jian He <[email protected]>  
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com  
Backpatch-through: 17  

M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

commit   : 4d7e24e0f4d05b546228488ccdc2848a80245ffb    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 12:53:01 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 12:53:01 +0900    

Click here for diff

Reverts 68222851d5a8, 565caaa79af, and 3a97460970f, because a few  
BF animals didn't like one or all of them.  

M src/backend/executor/execExpr.c
M src/backend/parser/parse_expr.c
M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY steps

commit   : 3a97460970f344660971ee75d7f5a181bf87f633    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 12:05:40 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 12:05:40 +0900    

Click here for diff

When the ON ERROR / ON EMPTY behavior is to return NULL, returning  
NULL directly from ExecEvalJsonExprPath() suffices. Therefore, there's  
no need to create separate steps to check the error/empty flag or  
those to evaluate the the constant NULL expression.  This speeds up  
common cases because the default ON ERROR / ON EMPTY behavior for  
JSON_QUERY() and JSON_VALUE() is to return NULL.  However, these steps  
are necessary if the RETURNING type is a domain, as constraints on the  
domain may need to be checked.  
  
Reported-by: Jian He <[email protected]>  
Author: Jian He <[email protected]>  
Author: Amit Langote <[email protected]>  
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com  
Backpatch-through: 17  

M src/backend/executor/execExpr.c

SQL/JSON: Fix default ON ERROR behavior for JSON_TABLE

commit   : 565caaa79af9a6b3853b161b0652527e716326b8    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 10:13:03 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 10:13:03 +0900    

Click here for diff

Use EMPTY ARRAY instead of EMPTY.  
  
This change does not affect the runtime behavior of JSON_TABLE(),  
which continues to return an empty relation ON ERROR. It only alters  
whether the default ON ERROR behavior is shown in the deparsed output.  
  
Reported-by: Jian He <[email protected]>  
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com  
Backpatch-through: 17  

M src/backend/parser/parse_expr.c
M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

SQL/JSON: Fix JSON_TABLE() column deparsing

commit   : 68222851d5a8d2ca152a97ee69fe18a95970ed20    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 10:12:16 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 10:12:16 +0900    

Click here for diff

The deparsing code in get_json_expr_options() unnecessarily emitted  
the default column-specific ON ERROR / EMPTY behavior when the  
top-level ON ERROR behavior in JSON_TABLE was set to ERROR. Fix that  
by not overriding the column-specific default, determined based on  
the column's JsonExprOp in get_json_table_columns(), with  
JSON_BEHAVIOR_ERROR when that is the top-level ON ERROR behavior.  
  
Note that this only removes redundancy; the current deparsing output  
is not incorrect, just redundant.  
  
Reviewed-by: Jian He <[email protected]>  
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com  
Backpatch-through: 17  

M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

Update comment about ExprState.escontext

commit   : 3422f5f93fcf3a6418e32e4fead20067c1425712    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 10:12:00 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 6 Sep 2024 10:12:00 +0900    

Click here for diff

The updated comment provides more helpful guidance by mentioning that  
escontext should be set when soft error handling is needed.  
  
Reported-by: Jian He <[email protected]>  
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com  
Backpatch-through: 17  

M src/include/nodes/execnodes.h

Be more careful with error paths in pg_set_regex_collation().

commit   : 7829f85a6285b3703a53ba5963a4df2e768014df    
  
author   : Jeff Davis <[email protected]>    
date     : Thu, 5 Sep 2024 12:10:08 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Thu, 5 Sep 2024 12:10:08 -0700    

Click here for diff

Set global variables after error paths so that they don't end up in an  
inconsistent state.  
  
The inconsistent state doesn't lead to an actual problem, because  
after an error, pg_set_regex_collation() will be called again before  
the globals are accessed.  
  
Change extracted from patch by Andreas Karlsson, though not discussed  
explicitly.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/regex/regc_pg_locale.c

Prevent mis-encoding of "trailing junk after numeric literal" errors.

commit   : fadff3fc94598db1d87e4242821964fb2850e19e    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 5 Sep 2024 12:42:33 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 5 Sep 2024 12:42:33 -0400    

Click here for diff

Since commit 2549f0661, we reject an identifier immediately following  
a numeric literal (without separating whitespace), because that risks  
ambiguity with hex/octal/binary integers.  However, that patch used  
token patterns like "{integer}{ident_start}", which is problematic  
because {ident_start} matches only a single byte.  If the first  
character after the integer is a multibyte character, this ends up  
with flex reporting an error message that includes a partial multibyte  
character.  That can cause assorted bad-encoding problems downstream,  
both in the report to the client and in the postmaster log file.  
  
To fix, use {identifier} not {ident_start} in the "junk" token  
patterns, so that they will match complete multibyte characters.  
This seems generally better user experience quite aside from the  
encoding problem: for "123abc" the error message will now say that  
the error appeared at or near "123abc" instead of "123a".  
  
While at it, add some commentary about why these patterns exist  
and how they work.  
  
Report and patch by Karina Litskevich; review by Pavel Borisov.  
Back-patch to v15 where the problem came in.  
  
Discussion: https://postgr.es/m/CACiT8iZ_diop=0zJ7zuY3BXegJpkKK1Av-PU7xh0EDYHsa5+=g@mail.gmail.com  

M src/backend/parser/scan.l
M src/fe_utils/psqlscan.l
M src/interfaces/ecpg/preproc/pgc.l
M src/test/regress/expected/numerology.out

Fix handling of NULL return value in typarray lookup

commit   : 85837b8037ada19d319fa4d3ba99c72205868199    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Thu, 5 Sep 2024 15:32:22 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Thu, 5 Sep 2024 15:32:22 +0200    

Click here for diff

Commit 6ebeeae29 accidentally omitted testing the return value from  
findTypeByOid which can return NULL.  Fix by adding a check to make  
sure that we have a pointer to dereference.  
  
Author: Ranier Vilela <[email protected]>  
Reviewed-by: Nathan Bossart <[email protected]>  
Reviewed-by: Daniel Gustafsson <[email protected]>  
Discussion: https://postgr.es/m/CAEudQAqfMTH8Ya_J6E-NW_y_JyDFDxtQ4V_g6nY_1=0oDbQqdg@mail.gmail.com  

M src/bin/pg_dump/pg_dump.c

Fix misleading error message context

commit   : 4af123ad45bd5e91221983da1152033e6153498c    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 5 Sep 2024 15:19:00 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 5 Sep 2024 15:19:00 +0200    

Click here for diff

Author: Pavel Stehule <[email protected]>  
Reviewed-by: Stepan Neretin <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/CAFj8pRAw+OkVW=FgMKHKyvY3CgtWy3cWdY7XT+S5TJaTttu=oA@mail.gmail.com  

M src/backend/executor/spi.c
M src/pl/plpgsql/src/expected/plpgsql_record.out
M src/pl/plpgsql/src/expected/plpgsql_varprops.out
M src/test/regress/expected/plpgsql.out

Add callback for backend initialization in pgstats

commit   : 1b373aed20e61e4a3033e1e396e4ba7c2a96bc20    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 5 Sep 2024 16:05:21 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 5 Sep 2024 16:05:21 +0900    

Click here for diff

pgstat_initialize() is currently used by the WAL stats as a code path to  
take some custom actions when a backend starts.  A callback is added to  
generalize the concept so as all stats kinds can do the same, for  
builtin and custom kinds, if set.  
  
Reviewed-by: Bertrand Drouvot, Kyotaro Horiguchi  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_wal.c
M src/include/utils/pgstat_internal.h

Fix two NULL pointer dereferences when reading custom pgstats from file

commit   : 341e9a05e7b4c4fb2a1e539a5073dfd0e5b46735    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 5 Sep 2024 14:36:57 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 5 Sep 2024 14:36:57 +0900    

Click here for diff

There were two spots in pgstat_read_statsfile() where is was possible to  
finish with a null-pointer-dereference crash for custom pgstats kinds:  
- When reading stats for a fixed-numbered stats entry.  
- When reading a variable stats entry with name serialization.  
For both cases, these issues were reachable by starting a server after  
changing shared_preload_libraries so as the stats written previously  
could not be loaded.  
  
The code is changed so as the stats are ignored in this case, like the  
other code paths doing similar sanity checks.  Two WARNINGs are added to  
be able to debug these issues.  A test is added for the case of  
fixed-numbered stats with the module injection_points.  
  
Oversights in 7949d9594582, spotted while looking at a different report.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/activity/pgstat.c
M src/test/modules/injection_points/t/001_stats.pl

Check availability of module injection_points in TAP tests

commit   : 5735521ac2d52485bca673039ba43e2b8cc71cd4    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 5 Sep 2024 13:29:43 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 5 Sep 2024 13:29:43 +0900    

Click here for diff

This fixes defects with installcheck for TAP tests that expect the  
module injection_points to exist in an installation, but the contents of  
src/test/modules are not installed by default with installcheck.  This  
would cause, for example, failures under installcheck-world for a build  
with injection points enabled, when the contents of src/test/modules/  
are not installed.  
  
The availability of the module can be done with a scan of  
pg_available_extension.  This has been introduced in 2cdcae9da696, and  
it is refactored here as a new routine in Cluster.pm.  
  
Tests are changed in different ways depending on what they need:  
- The libpq TAP test sets up a node even without injection points, so it  
is enough to check that CREATE EXTENSION can be used.  There is no need  
for the variable enable_injection_points.  
- In test_misc, 006_signal_autovacuum requires a runtime check.  
- 041_checkpoint_at_promote in recovery tests and 005_timeouts in  
test_misc are updated to use the routine introduced in Cluster.pm.  
- test_slru's 001_multixact, injection_points's 001_stats and  
modules/gin/ do not require a check as these modules disable  
installcheck entirely.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/interfaces/libpq/Makefile
M src/interfaces/libpq/meson.build
M src/interfaces/libpq/t/005_negotiate_encryption.pl
M src/test/modules/test_misc/t/005_timeouts.pl
M src/test/modules/test_misc/t/006_signal_autovacuum.pl
M src/test/perl/PostgreSQL/Test/Cluster.pm
M src/test/recovery/t/041_checkpoint_at_promote.pl

Optimize WindowAgg's use of tuplestores

commit   : 908a968612f9ed61911d8ca0a185b262b82f1269    
  
author   : David Rowley <[email protected]>    
date     : Thu, 5 Sep 2024 16:18:30 +1200    
  
committer: David Rowley <[email protected]>    
date     : Thu, 5 Sep 2024 16:18:30 +1200    

Click here for diff

When WindowAgg finished one partition of a PARTITION BY, it previously  
would call tuplestore_end() to purge all the stored tuples before again  
calling tuplestore_begin_heap() and carefully setting up all of the  
tuplestore read pointers exactly as required for the given frameOptions.  
Since the frameOptions don't change between partitions, this part does  
not make much sense.  For queries that had very few rows per partition,  
the overhead of this was very large.  
  
It seems much better to create the tuplestore and the read pointers once  
and simply call tuplestore_clear() at the end of each partition.  
tuplestore_clear() moves all of the read pointers back to the start  
position and deletes all the previously stored tuples.  
  
A simple test query with 1 million partitions and 1 tuple per partition  
has been shown to run around 40% faster than without this change.  The  
additional effort seems to have mostly been spent in malloc/free.  
  
Making this work required adding a new bool field to WindowAggState  
which had the unfortunate effect of being the 9th bool field in a group  
resulting in the struct being enlarged.  Here we shuffle the fields  
around a little so that the two bool fields for runcondition relating  
stuff fit into existing padding.  Also, move the "runcondition" field to  
be near those.  This frees up enough space with the other bool fields so  
that the newly added one fits into the padding bytes.  This was done to  
address a very small but apparent performance regression with queries  
containing a large number of rows per partition.  
  
Reviewed-by: Ashutosh Bapat <[email protected]>  
Reviewed-by: Tatsuo Ishii <[email protected]>  
Discussion: https://postgr.es/m/CAHoyFK9n-QCXKTUWT_xxtXninSMEv%2BgbJN66-y6prM3f4WkEHw%40mail.gmail.com  

M src/backend/executor/nodeWindowAgg.c
M src/include/nodes/execnodes.h

Speedup WindowAgg code by moving uncommon code out-of-line

commit   : 19b861f880166fbdb67d268955e590881376f876    
  
author   : David Rowley <[email protected]>    
date     : Thu, 5 Sep 2024 15:59:47 +1200    
  
committer: David Rowley <[email protected]>    
date     : Thu, 5 Sep 2024 15:59:47 +1200    

Click here for diff

The code to calculate the frame offsets is only performed once per scan.  
Moving this code out of line gives a small (around 4-5%) speedup when testing  
with some CPUs.  Other tested CPUs are indifferent to the change.  
  
Reviewed-by: Ashutosh Bapat <[email protected]>  
Reviewed-by: Tatsuo Ishii <[email protected]>  
Discussion: https://postgr.es/m/CAApHDvqPgFtwme2Zyf75BpMLwYr2mnUstDyPiP%3DEpudYuQTPPQ%40mail.gmail.com  

M src/backend/executor/nodeWindowAgg.c

Remove lc_collate_is_c().

commit   : 06421b08436414b42cd169501005f15adee986f1    
  
author   : Jeff Davis <[email protected]>    
date     : Wed, 4 Sep 2024 12:30:14 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Wed, 4 Sep 2024 12:30:14 -0700    

Click here for diff

Instead just look up the collation and check collate_is_c field.  
  
Author: Andreas Karlsson  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/spgist/spgtextproc.c
M src/backend/commands/collationcmds.c
M src/backend/utils/adt/like_support.c
M src/backend/utils/adt/pg_locale.c
M src/backend/utils/adt/selfuncs.c
M src/backend/utils/adt/varchar.c
M src/backend/utils/adt/varlena.c
M src/include/utils/pg_locale.h

Remove test-case workarounds for ancient libedit versions.

commit   : 83eb481d527b541e2ef2a1b14ab2c56b2ccf362b    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 4 Sep 2024 16:25:28 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 4 Sep 2024 16:25:28 -0400    

Click here for diff

This reverts some hacks added in d33a81203 and cd69ec66c.  
At the time the concern was the already-ancient version of  
libedit shipped in Debian 10 (Buster).  That platform is  
now two years past EOL, so desupporting it for PG 18 seems  
fine.  (Also, if anyone is really hot to keep testing it,  
they can use SKIP_READLINE_TESTS to skip this test.)  
  
We might have to reconsider if any animals still in the  
buildfarm don't like this, but the best way to find out  
is to try it.  
  
Anton Melnikov  
  
Discussion: https://postgr.es/m/CAGRrpzZU48F2oV3d8eDLr=4TU9xFH5Jt9ED+qU1+X91gMH68Sw@mail.gmail.com  

M src/bin/psql/t/010_tab_completion.pl

Revert "Optimize pg_visibility with read streams."

commit   : ddfc556a644404a8942e77651f75f09aa5188782    
  
author   : Noah Misch <[email protected]>    
date     : Wed, 4 Sep 2024 11:36:40 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Wed, 4 Sep 2024 11:36:40 -0700    

Click here for diff

This reverts commit ed1b1ee59fb3792baa32f669333b75024ef01bcc and its  
followup 1c61fd8b527954f0ec522e5e60a11ce82628b681.  They rendered  
collect_corrupt_items() unable to detect corruption.  
  
Discussion: https://postgr.es/m/CAN55FZ1_Ru3XpMgTwsU67FTH2fs_FrRROmb7x6zs+F44QBEiww@mail.gmail.com  
Discussion: https://postgr.es/m/CAEudQAozv3wTY5TV2t29JcwPydbmKbiWQkZD42S2OgzdixPMDQ@mail.gmail.com  

M contrib/pg_visibility/pg_visibility.c

Remove a couple of strerror() calls

commit   : 82b07eba9e8b863cc05adb7e53a86ff02b51d888    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 4 Sep 2024 14:45:31 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 4 Sep 2024 14:45:31 +0200    

Click here for diff

Change to using %m in the error message string.  We need to be a bit  
careful here to preserve errno until we need to print it.  
  
This change avoids the use of not-thread-safe strerror() and unifies  
some error message strings, and maybe makes the code appear more  
consistent.  
  
Reviewed-by: Tom Lane <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/daa87d79-c044-46c4-8458-8d77241ed7b0%40eisentraut.org  

M src/backend/libpq/hba.c

Unify some error messages to ease work of translators

commit   : a68159ff2b32f290b1136e2940470d50b8491301    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 4 Sep 2024 14:53:18 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 4 Sep 2024 14:53:18 +0900    

Click here for diff

This commit updates a couple of error messages around control file data,  
GUCs and server settings, unifying to the same message where possible.  
This reduces the translation burden a bit.  
  
Author: Peter Smith  
Discussion: https://postgr.es/m/CAHut+Pv-kSN8SkxSdoHano_wPubqcg5789ejhCDZAcLFceBR-w@mail.gmail.com  

M src/backend/access/transam/xlog.c
M src/backend/commands/variable.c
M src/backend/storage/file/fd.c
M src/backend/utils/fmgr/dfmgr.c

Apply more quoting to GUC names in messages

commit   : b4db64270e0c18f72c9c7bf214c809949875a85a    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 4 Sep 2024 13:50:44 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 4 Sep 2024 13:50:44 +0900    

Click here for diff

This is a continuation of 17974ec25946.  More quotes are applied to  
GUC names in error messages and hints, taking care of what seems to be  
all the remaining holes currently in the tree for the GUCs.  
  
Author: Peter Smith  
Discussion: https://postgr.es/m/CAHut+Pv-kSN8SkxSdoHano_wPubqcg5789ejhCDZAcLFceBR-w@mail.gmail.com  

M contrib/oid2name/oid2name.c
M contrib/vacuumlo/vacuumlo.c
M src/backend/access/transam/xlog.c
M src/backend/archive/shell_archive.c
M src/backend/postmaster/bgworker.c
M src/backend/postmaster/checkpointer.c
M src/backend/replication/logical/launcher.c
M src/backend/replication/logical/slotsync.c
M src/backend/storage/file/fd.c
M src/backend/utils/misc/guc_tables.c
M src/bin/pg_archivecleanup/pg_archivecleanup.c
M src/bin/pg_basebackup/pg_createsubscriber.c
M src/bin/pg_dump/pg_backup_db.c
M src/bin/pg_rewind/pg_rewind.c
M src/include/libpq/libpq-be-fe-helpers.h

Collect statistics about conflicts in logical replication.

commit   : 6c2b5edecc0d6c936e27775c9451d32bb3141c90    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 4 Sep 2024 08:55:21 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 4 Sep 2024 08:55:21 +0530    

Click here for diff

This commit adds columns in view pg_stat_subscription_stats to show the  
number of times a particular conflict type has occurred during the  
application of logical replication changes. The following columns are  
added:  
  
confl_insert_exists:  
        Number of times a row insertion violated a NOT DEFERRABLE unique  
        constraint.  
confl_update_origin_differs:  
        Number of times an update was performed on a row that was  
        previously modified by another origin.  
confl_update_exists:  
        Number of times that the updated value of a row violates a  
        NOT DEFERRABLE unique constraint.  
confl_update_missing:  
        Number of times that the tuple to be updated is missing.  
confl_delete_origin_differs:  
        Number of times a delete was performed on a row that was  
        previously modified by another origin.  
confl_delete_missing:  
        Number of times that the tuple to be deleted is missing.  
  
The update_origin_differs and delete_origin_differs conflicts can be  
detected only when track_commit_timestamp is enabled.  
  
Author: Hou Zhijie  
Reviewed-by: Shveta Malik, Peter Smith, Anit Kapila  
Discussion: https://postgr.es/m/OS0PR01MB57160A07BD575773045FC214948F2@OS0PR01MB5716.jpnprd01.prod.outlook.com  

M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/monitoring.sgml
M src/backend/catalog/system_views.sql
M src/backend/replication/logical/conflict.c
M src/backend/utils/activity/pgstat_subscription.c
M src/backend/utils/adt/pgstatfuncs.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/include/pgstat.h
M src/include/replication/conflict.h
M src/test/regress/expected/rules.out
M src/test/subscription/t/026_stats.pl

Avoid unnecessary post-sort projection

commit   : 9626068f13338f79ba183b4cf3c975e22c98c575    
  
author   : Richard Guo <[email protected]>    
date     : Wed, 4 Sep 2024 12:19:19 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Wed, 4 Sep 2024 12:19:19 +0900    

Click here for diff

When generating paths for the ORDER BY clause, one thing we need to  
ensure is that the output paths project the correct final_target.  To  
achieve this, in create_ordered_paths, we compare the pathtarget of  
each generated path with the given 'target', and add a post-sort  
projection step if the two targets do not match.  
  
Currently we perform a simple pointer comparison between the two  
targets.  It turns out that this is not sufficient.  Each sorted_path  
generated in create_ordered_paths initially projects the correct  
target required by the preceding steps of sort.  If it is the same  
pointer as sort_input_target, pointer comparison suffices, because  
sort_input_target is always identical to final_target when no  
post-sort projection is needed.  
  
However, sorted_path's initial pathtarget may not be the same pointer  
as sort_input_target, because in apply_scanjoin_target_to_paths, if  
the target to be applied has the same expressions as the existing  
reltarget, we only inject the sortgroupref info into the existing  
pathtargets, rather than create new projection paths.  As a result,  
pointer comparison in create_ordered_paths is not reliable.  
  
Instead, we can compare PathTarget.exprs to determine whether a  
projection step is needed.  If the expressions match, we can be  
confident that a post-sort projection is not required.  
  
It could be argued that this change adds extra check cost each time we  
decide whether a post-sort projection is needed.  However, as  
explained in apply_scanjoin_target_to_paths, by avoiding the creation  
of projection paths, we save effort both immediately and at plan  
creation time.  This, I think, justifies the extra check cost.  
  
There are two ensuing plan changes in the regression tests, but they  
look reasonable and are exactly what we are fixing here.  So no  
additional test cases are added.  
  
No backpatch as this could result in plan changes.  
  
Author: Richard Guo  
Reviewed-by: Peter Eisentraut, David Rowley, Tom Lane  
Discussion: https://postgr.es/m/CAMbWs48TosSvmnz88663_2yg3hfeOFss-J2PtnENDH6J_rLnRQ@mail.gmail.com  

M src/backend/optimizer/plan/planner.c
M src/test/regress/expected/select_distinct_on.out

Check the validity of commutators for merge/hash clauses

commit   : 4f1124548f6f3c7dea639ccd3d3f234cf70faf0a    
  
author   : Richard Guo <[email protected]>    
date     : Wed, 4 Sep 2024 12:17:11 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Wed, 4 Sep 2024 12:17:11 +0900    

Click here for diff

When creating merge or hash join plans in createplan.c, the merge or  
hash clauses may need to get commuted to ensure that the outer var is  
on the left and the inner var is on the right if they are not already  
in the expected form.  This requires that their operators have  
commutators.  Failing to find a commutator at this stage would result  
in 'ERROR: could not find commutator for operator xxx', with no  
opportunity to select an alternative plan.  
  
Typically, this is not an issue because mergejoinable or hashable  
operators are expected to always have valid commutators.  But in some  
artificial cases this assumption may not hold true.  Therefore, here  
in this patch we check the validity of commutators for clauses in the  
form "inner op outer" when selecting mergejoin/hash clauses, and  
consider a clause unusable for the current pair of outer and inner  
relations if it lacks a commutator.  
  
There are not (and should not be) any such operators built into  
Postgres that are mergejoinable or hashable but have no commutators;  
so we leverage the alias type 'int8alias1' created in equivclass.sql  
to build the test case.  This is why the test case is included in  
equivclass.sql rather than in join.sql.  
  
Although this is arguably a bug fix, it cannot be reproduced without  
installing an incomplete opclass, which is unlikely to happen in  
practice, so no back-patch.  
  
Reported-by: Alexander Pyhalov  
Author: Richard Guo  
Reviewed-by: Tom Lane  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/optimizer/path/joinpath.c
M src/test/regress/expected/equivclass.out
M src/test/regress/sql/equivclass.sql

Fix inconsistent LWLock tranche name "CommitTsSLRU"

commit   : 08b9b9e043bb42c12f5cd7439b9c19833fe877d0    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 4 Sep 2024 10:21:17 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 4 Sep 2024 10:21:17 +0900    

Click here for diff

This term was using an inconsistent casing between the code and the  
documentation, using "CommitTsSLRU" in wait_event_names.txt and  
"CommitTSSLRU" in the code.  
  
Let's update the term in the code to reflect what's in the  
documentation, "CommitTs" being more commonly used, so as  
pg_stat_activity shows the same term as the documentation.  
  
Oversight in 53c2a97a9266.  
  
Author: Alexander Lakhin  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 17  

M src/backend/storage/lmgr/lwlock.c

Avoid installcheck failure in TAP tests using injection_points

commit   : 2cdcae9da6968ed1057bfc67442fd9e0dcbbc31d    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 4 Sep 2024 08:56:23 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 4 Sep 2024 08:56:23 +0900    

Click here for diff

These tests depend on the test module injection_points to be installed,  
but it may not be available as the contents of src/test/modules/ are not  
installed by default.  
  
This commit adds a workaround based on a scan of pg_available_extensions  
to check if the extension is available, skipping the test if it is not.  
This allows installcheck to work transparently.  
  
There are more tests impacted by this problem on HEAD, but for now this  
addresses only the tests that exist on HEAD and v17 as the release is  
close by.  
  
Reported-by: Maxim Orlov  
Discussion: https://postgr.es/m/CACG=ezZkoT-pFz6a9XnyToiuR-Wg8fGELqHLoyBodr+2h-77qA@mail.gmail.com  
Backpatch-through: 17  

M src/test/modules/test_misc/t/005_timeouts.pl
M src/test/recovery/t/041_checkpoint_at_promote.pl

Remember last collation to speed up collation cache.

commit   : 12d3345c0d2842a36d0ee2bce06cfe7d3cac84da    
  
author   : Jeff Davis <[email protected]>    
date     : Tue, 3 Sep 2024 16:05:58 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Tue, 3 Sep 2024 16:05:58 -0700    

Click here for diff

This optimization is to avoid a performance regression in an upcoming  
patch that will remove lc_collate_is_c().  
  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/pg_locale.c

Simplify makefiles exporting twice enable_injection_points

commit   : 516ff05539bb70cc378e21e5e67588ec9c959cf7    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 4 Sep 2024 08:05:44 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 4 Sep 2024 08:05:44 +0900    

Click here for diff

This is confusing, as it exports twice the same variable.  Oversight in  
6782709df81f that has spread in more places afterwards.  
  
Reported-by: Alvaro Herrera, Tom Lane  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 17  

M src/test/modules/injection_points/Makefile
M src/test/modules/test_misc/Makefile
M src/test/modules/test_slru/Makefile
M src/test/recovery/Makefile

Standardize "read-ahead advice" terminology.

commit   : 813fde73d4dd4fab1b7bde99ceaa47dd8437c21e    
  
author   : Thomas Munro <[email protected]>    
date     : Wed, 4 Sep 2024 10:12:20 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Wed, 4 Sep 2024 10:12:20 +1200    

Click here for diff

Commit 6654bb920 added macOS's equivalent of POSIX_FADV_WILLNEED, and  
changed some explicit references to posix_fadvise to use this more  
general name for the concept.  Update some remaining references.  
  
Reviewed-by: Peter Eisentraut <[email protected]>  
Discussion: https://postgr.es/m/0827edec-1317-4917-a186-035eb1e3241d%40eisentraut.org  

M src/backend/access/transam/xlogprefetcher.c
M src/backend/storage/aio/read_stream.c

Fix stack variable scope from previous commit.

commit   : 1c61fd8b527954f0ec522e5e60a11ce82628b681    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 3 Sep 2024 12:44:54 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 3 Sep 2024 12:44:54 -0700    

Click here for diff

The defect came from me, not from that commit's credited author.  Per  
buildfarm members olingo and grassquit.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pg_visibility/pg_visibility.c

Optimize pg_visibility with read streams.

commit   : ed1b1ee59fb3792baa32f669333b75024ef01bcc    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 3 Sep 2024 10:46:20 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 3 Sep 2024 10:46:20 -0700    

Click here for diff

We've measured 5% performance improvement, and this arranges to benefit  
automatically from future optimizations to the read_stream subsystem.  
  
Nazir Bilal Yavuz  
  
Discussion: https://postgr.es/m/CAN55FZ1_Ru3XpMgTwsU67FTH2fs_FrRROmb7x6zs+F44QBEiww@mail.gmail.com  

M contrib/pg_visibility/pg_visibility.c

Add block_range_read_stream_cb(), to deduplicate code.

commit   : c582b75851c2d096ce050d753494505a957cee75    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 3 Sep 2024 10:46:20 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 3 Sep 2024 10:46:20 -0700    

Click here for diff

This replaces two functions for iterating over all blocks in a range.  A  
pending patch will use this instead of adding a third.  
  
Nazir Bilal Yavuz  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pg_prewarm/pg_prewarm.c
M src/backend/storage/aio/read_stream.c
M src/backend/storage/buffer/bufmgr.c
M src/include/storage/read_stream.h
M src/tools/pgindent/typedefs.list

Use library functions to edit config in SSL tests

commit   : ba7625a7a51b58c712541d7c0d6667c1f860e33f    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Tue, 3 Sep 2024 18:57:56 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Tue, 3 Sep 2024 18:57:56 +0200    

Click here for diff

The SSL tests were editing the postgres configuration by directly  
reading and writing the files rather than using append_conf() from  
the testcode library.  
  
Reviewed-by: Peter Eisentraut <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/test/ssl/t/SSL/Server.pm

Test for PG_TEST_EXTRA separately in SSL tests

commit   : e5f1f0a4f2ab19d205a520c52530264c19747c0a    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Tue, 3 Sep 2024 18:57:54 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Tue, 3 Sep 2024 18:57:54 +0200    

Click here for diff

PG_TEST_EXTRA is an override and should be tested for separately  
from any other test as there is no dependency on whether OpenSSL  
is available or not.  
  
Reviewed-by: Peter Eisentraut <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/test/ssl/t/001_ssltests.pl
M src/test/ssl/t/002_scram.pl
M src/test/ssl/t/003_sslinfo.pl

Fix typos in code comments and test data

commit   : 31a98934d1699007b50aefaedd68ab4d6b42e3b4    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Tue, 3 Sep 2024 11:33:38 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Tue, 3 Sep 2024 11:33:38 +0200    

Click here for diff

The typos in 005_negotiate_encryption.pl and pg_combinebackup.c  
shall be backported to v17 where they were introduced.  
  
Backpatch-through: v17  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/storage/buffer/bufmgr.c
M src/bin/pg_combinebackup/pg_combinebackup.c
M src/interfaces/libpq/t/005_negotiate_encryption.pl

Add const qualifiers to XLogRegister*() functions

commit   : 2b5f57977f6d16796121d796835c48e4241b4da1    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 3 Sep 2024 08:00:38 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 3 Sep 2024 08:00:38 +0200    

Click here for diff

Add const qualifiers to XLogRegisterData() and XLogRegisterBufData().  
Several unconstify() calls can be removed.  
  
Reviewed-by: Aleksander Alekseev <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/access/brin/brin_pageops.c
M src/backend/access/transam/README
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xloginsert.c
M src/backend/replication/logical/message.c
M src/include/access/xlog_internal.h
M src/include/access/xloginsert.h
M src/include/storage/bufpage.h

Fix typos and grammar in code comments and docs

commit   : 4236825197e8b7f26f8fd2ce0ac287a696e7264e    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 3 Sep 2024 14:49:04 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 3 Sep 2024 14:49:04 +0900    

Click here for diff

Author: Alexander Lakhin  
Discussion: https://postgr.es/m/[email protected]  

M contrib/test_decoding/specs/skip_snapshot_restore.spec
M doc/src/sgml/xfunc.sgml
M src/backend/access/transam/multixact.c
M src/backend/commands/matview.c
M src/backend/commands/waitlsn.c
M src/backend/executor/execExprInterp.c
M src/backend/postmaster/postmaster.c
M src/backend/replication/logical/slotsync.c
M src/backend/storage/aio/read_stream.c
M src/backend/storage/lmgr/lock.c
M src/backend/utils/cache/typcache.c
M src/bin/pg_combinebackup/t/008_promote.pl
M src/bin/psql/common.c
M src/fe_utils/astreamer_gzip.c
M src/include/storage/read_stream.h
M src/include/utils/injection_point.h
M src/interfaces/libpq/fe-connect.c
M src/test/modules/test_misc/t/006_signal_autovacuum.pl
M src/test/subscription/t/021_twophase.pl

Define PG_TBLSPC_DIR for path pg_tblspc/ in data folder

commit   : c7cd2d6ed082a4638172acece33ed6f36da96263    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 3 Sep 2024 09:11:54 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 3 Sep 2024 09:11:54 +0900    

Click here for diff

Similarly to 2065ddf5e34c, this introduces a define for "pg_tblspc".  
This makes the style more consistent with the existing PG_STAT_TMP_DIR,  
for example.  
  
There is a difference with the other cases with the introduction of  
PG_TBLSPC_DIR_SLASH, required in two places for recovery and backups.  
  
Author: Bertrand Drouvot  
Reviewed-by: Ashutosh Bapat, Álvaro Herrera, Yugo Nagata, Michael  
Paquier  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/backup/backup_manifest.c
M src/backend/backup/basebackup.c
M src/backend/commands/dbcommands.c
M src/backend/commands/tablespace.c
M src/backend/storage/file/fd.c
M src/backend/storage/file/reinit.c
M src/backend/utils/adt/dbsize.c
M src/backend/utils/adt/misc.c
M src/backend/utils/cache/relcache.c
M src/bin/pg_checksums/pg_checksums.c
M src/bin/pg_combinebackup/pg_combinebackup.c
M src/bin/pg_rewind/file_ops.c
M src/bin/pg_upgrade/exec.c
M src/common/file_utils.c
M src/common/relpath.c
M src/include/common/relpath.h

doc: Consistently use result set in documentation

commit   : 94eec79633f284488de69e253857e44aad10c730    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Mon, 2 Sep 2024 18:36:57 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Mon, 2 Sep 2024 18:36:57 +0200    

Click here for diff

We use "result set" in all other places so let's be consistent  
across the entire documentation.  
  
Reported-by: [email protected]  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/parallel.sgml

Fix rarely-run test for message wording change

commit   : 2befd22790ef32bbe3cbfc8b4b826e8a1286afbd    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 2 Sep 2024 17:40:32 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 2 Sep 2024 17:40:32 +0200    

Click here for diff

fixup for 2e6a8047f0  
  
Reported-by: Nazir Bilal Yavuz <[email protected]>  

M src/test/modules/xid_wraparound/t/002_limits.pl

Only perform pg_strong_random init when required

commit   : c3333dbc0c0f53452abfccf6c2dd5a86728a19dc    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Mon, 2 Sep 2024 13:52:27 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Mon, 2 Sep 2024 13:52:27 +0200    

Click here for diff

The random number generator in OpenSSL 1.1.1 was redesigned to provide  
fork safety by default, thus removing the need for calling RAND_poll  
after forking to ensure that two processes cannot share the same state.  
Since we now support 1.1.0 as the minumum version, and 1.1.0 is being  
increasingly phased out from production use, only perform the RAND_poll  
initialization for installations running 1.1.0 by checking the OpenSSL  
version number.  
  
LibreSSL changed random number generator when forking OpenSSL and has  
provided fork safety since version 2.0.2.  
  
This removes the overhead of initializing the RNG for strong random  
for the vast majority of users for whom it is no longer required.  
  
Reviewed-by: Jacob Champion <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Reviewed-by: Michael Paquier <[email protected]>  
Discussion: https://postgr.es/m/CA+hUKGKh7QrYzu=8yWEUJvXtMVm_CNWH1L_TLWCbZMwbi1XP2Q@mail.gmail.com  

M src/port/pg_strong_random.c

Remove support for OpenSSL older than 1.1.0

commit   : a70e01d4306fdbcd5fbedb4ca97e5c21c995da60    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Mon, 2 Sep 2024 13:51:48 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Mon, 2 Sep 2024 13:51:48 +0200    

Click here for diff

OpenSSL 1.0.2 has been EOL from the upstream OpenSSL project for  
some time, and is no longer the default OpenSSL version with any  
vendor which package PostgreSQL. By retiring support for OpenSSL  
1.0.2 we can remove a lot of no longer required complexity for  
managing state within libcrypto which is now handled by OpenSSL.  
  
Reviewed-by: Jacob Champion <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Reviewed-by: Michael Paquier <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/CA+hUKGKh7QrYzu=8yWEUJvXtMVm_CNWH1L_TLWCbZMwbi1XP2Q@mail.gmail.com  

M configure
M configure.ac
M contrib/pgcrypto/openssl.c
M doc/src/sgml/installation.sgml
M doc/src/sgml/libpq.sgml
M meson.build
M src/backend/libpq/be-secure-openssl.c
M src/common/Makefile
M src/common/hmac_openssl.c
M src/common/meson.build
D src/common/protocol_openssl.c
M src/include/common/openssl.h
M src/include/pg_config.h.in
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/fe-secure-openssl.c
M src/interfaces/libpq/fe-secure.c
M src/interfaces/libpq/libpq-int.h
M src/test/ssl/t/001_ssltests.pl

Cache typarray for fast lookups in binary upgrade mode

commit   : 6ebeeae29626e742bbe16db3fa6fccf1186c0dfb    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Mon, 2 Sep 2024 10:17:46 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Mon, 2 Sep 2024 10:17:46 +0200    

Click here for diff

When upgrading a large schema it adds significant overhead to perform  
individual catalog lookups per relation in order to retrieve Oid for  
preserving Oid calls. This instead adds the typarray to the TypeInfo  
cache which then allows for fast lookups using the existing API. A  
35% reduction of pg_dump runtime in binary upgrade mode was observed  
with this change.  
  
Reviewed-by: Nathan Bossart <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump.h

More use of getpwuid_r() directly

commit   : 4d5111b3f1a151faf8129e38f8424898588e606d    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 2 Sep 2024 08:16:25 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 2 Sep 2024 08:16:25 +0200    

Click here for diff

Remove src/port/user.c, call getpwuid_r() directly.  This reduces some  
complexity and allows better control of the error behavior.  For  
example, the old code would in some circumstances silently truncate  
the result string, or produce error message strings that the caller  
wouldn't use.  
  
src/port/user.c used to be called src/port/thread.c and contained  
various portability complications to support thread-safety.  These are  
all obsolete, and all but the user-lookup functions have already been  
removed.  This patch completes this by also removing the user-lookup  
functions.  
  
Also convert src/backend/libpq/auth.c to use getpwuid_r() for  
thread-safety.  
  
Originally, I tried to be overly correct by using  
sysconf(_SC_GETPW_R_SIZE_MAX) to get the buffer size for getpwuid_r(),  
but that doesn't work on FreeBSD.  All the OS where I could find the  
source code internally use 1024 as the suggested buffer size, so I  
just ended up hardcoding that.  The previous code used BUFSIZ, which  
is an unrelated constant from stdio.h, so its use seemed  
inappropriate.  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/5f293da9-ceb4-4937-8e52-82c25db8e4d3%40eisentraut.org  

M src/backend/libpq/auth.c
M src/bin/psql/nls.mk
M src/include/port.h
M src/interfaces/libpq/fe-auth.c
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/nls.mk
M src/port/Makefile
M src/port/meson.build
M src/port/path.c
D src/port/user.c

Rename enum labels of PG_Locale_Strategy

commit   : 23138284cde438f65f093156e76683d63b826fff    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 2 Sep 2024 08:18:41 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 2 Sep 2024 08:18:41 +0900    

Click here for diff

PG_REGEX_BUILTIN was added in f69319f2f1fb but it did not follow the  
same pattern as the previous labels, i.e. PG_LOCALE_*.  In addition to  
this, the two libc strategies did not include in the name that they were  
related to this library.  
  
The enum labels are renamed as PG_STRATEGY_type[_subtype] to make the  
code clearer, in accordance to the library and the functions they rely  
on.  
  
Author: Andreas Karlsson  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/regex/regc_pg_locale.c

Fix unfairness in all-cached parallel seq scan.

commit   : 4effd0844daf41a962c05188b719df75ca8ced93    
  
author   : Thomas Munro <[email protected]>    
date     : Sat, 31 Aug 2024 17:27:38 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Sat, 31 Aug 2024 17:27:38 +1200    

Click here for diff

Commit b5a9b18c introduced block streaming infrastructure with a special  
fast path for all-cached scans, and commit b7b0f3f2 connected the  
infrastructure up to sequential scans.  One of the fast path  
micro-optimizations had an unintended consequence: it interfered with  
parallel sequential scan's block range allocator (from commit 56788d21),  
which has its own ramp-up and ramp-down algorithm when handing out  
groups of pages to workers.  A scan of an all-cached table could give  
extra blocks to one worker, when others had finished.  In some plans  
(probably already very bad plans, such as the one reported by  
Alexander), the unfairness could be magnified.  
  
An internal buffer of 16 block numbers is removed, keeping just a single  
block buffer for technical reasons.  
  
Back-patch to 17.  
  
Reported-by: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/63a63690-dd92-c809-0b47-af05459e95d1%40gmail.com  

M src/backend/storage/aio/read_stream.c

Stabilize 039_end_of_wal test.

commit   : ecd56459cfe40d3a494844dffc8cb999364df442    
  
author   : Thomas Munro <[email protected]>    
date     : Sat, 31 Aug 2024 14:32:08 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Sat, 31 Aug 2024 14:32:08 +1200    

Click here for diff

The first test was sensitive to the insert LSN after setting up the  
catalogs, which depended on environmental things like the locales on the  
OS and usernames.  Switch to a new WAL file before the first test, as a  
simple way to put every computer into the same state.  
  
Back-patch to all supported releases.  
  
Reported-by: Anton Voloshin <[email protected]>  
Reported-by: Nathan Bossart <[email protected]>  
Reviewed-by: Tom Lane <[email protected]>  
Reviewed-by: Nathan Bossart <[email protected]>  
Discussion: https://postgr.es/m/b26aeac2-cb6d-4633-a7ea-945baae83dcf%40postgrespro.ru  

M src/test/recovery/t/039_end_of_wal.pl

Clarify restrict_nonsystem_relation_kind description.

commit   : d7613ea72f787f0cc3c1749f7444f17730f4d697    
  
author   : Masahiko Sawada <[email protected]>    
date     : Fri, 30 Aug 2024 15:06:09 -0700    
  
committer: Masahiko Sawada <[email protected]>    
date     : Fri, 30 Aug 2024 15:06:09 -0700    

Click here for diff

This change improves the description of the  
restrict_nonsystem_relation_kind parameter in guc_table.c and the  
documentation for better clarity.  
  
Backpatch to 12, where this GUC parameter was introduced.  
  
Reviewed-by: Peter Eisentraut  
Discussion: https://postgr.es/m/6a96f1af-22b4-4a80-8161-1f26606b9ee2%40eisentraut.org  
Backpatch-through: 12  

M doc/src/sgml/config.sgml
M src/backend/utils/misc/guc_tables.c

Make postgres_fdw's query_cancel test less flaky.

commit   : 0e5c823806a3519a3f6966637cb62755dee659d4    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 30 Aug 2024 16:47:39 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 30 Aug 2024 16:47:39 -0400    

Click here for diff

This test occasionally shows  
  
+WARNING:  could not get result of cancel request due to timeout  
  
which appears to be because the cancel request is sometimes unluckily  
sent to the remote session between queries, and then it's ignored.  
  
This patch tries to make that less probable in three ways:  
  
1. Use a test query that does not involve remote estimates, so that  
no EXPLAINs are sent.  
2. Make sure that the remote session is ready-to-go (transaction  
started, SET commands sent) before we start the timer.  
3. Increase the statement_timeout to 100ms, to give the local  
session enough time to plan and issue the query.  
  
We might have to go higher than 100ms to make this adequately  
stable in the buildfarm, but let's see how it goes.  
  
Back-patch to v17 where this test was introduced.  
  
Jelte Fennema-Nio and Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/postgres_fdw/expected/query_cancel.out
M contrib/postgres_fdw/sql/query_cancel.sql

Avoid inserting PlaceHolderVars in cases where pre-v16 PG did not.

commit   : cb8e50a4a09fe541e32cd54ea90a97f2924121a1    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 30 Aug 2024 12:42:12 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 30 Aug 2024 12:42:12 -0400    

Click here for diff

Commit 2489d76c4 removed some logic from pullup_replace_vars()  
that avoided wrapping a PlaceHolderVar around a pulled-up  
subquery output expression if the expression could be proven  
to go to NULL anyway (because it contained Vars or PHVs of the  
pulled-up relation and did not contain non-strict constructs).  
But removing that logic turns out to cause performance regressions  
in some cases, because the extra PHV blocks subexpression folding,  
and will do so even if outer-join reduction later turns it into a  
no-op with no phnullingrels bits.  This can for example prevent  
an expression from being matched to an index.  
  
The reason for always adding a PHV was to ensure we had someplace  
to put the varnullingrels marker bits of the Var being replaced.  
However, it turns out we can optimize in exactly the same cases that  
the previous code did, because we can instead attach the needed  
varnullingrels bits to the contained Var(s)/PHV(s).  
  
This is not a complete solution --- it would be even better if we  
could remove PHVs after reducing them to no-ops.  It doesn't look  
practical to back-patch such an improvement, but this change seems  
safe and at least gets rid of the performance-regression cases.  
  
Per complaint from Nikhil Raj.  Back-patch to v16 where the  
problem appeared.  
  
Discussion: https://postgr.es/m/CAG1ps1xvnTZceKK24OUfMKLPvDP2vjT-d+F2AOCWbw_v3KeEgg@mail.gmail.com  

M src/backend/optimizer/prep/prepjointree.c
M src/backend/rewrite/rewriteManip.c
M src/test/regress/expected/subselect.out
M src/test/regress/sql/subselect.sql

Remove one memoize test case added by commit 069d0ff02.

commit   : 3409b4db631f5471696127494e57193350b87b41    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 30 Aug 2024 12:22:31 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 30 Aug 2024 12:22:31 -0400    

Click here for diff

This test case turns out to depend on the assumption that a non-Var  
subquery output that's underneath an outer join will always get  
wrapped in a PlaceHolderVar.  But that behavior causes performance  
regressions in some cases compared to what happened before v16.  
The next commit will avoid inserting a PHV in the same cases where  
pre-v16 did, and that causes get_memoized_path to not detect that  
a memoize plan could be used.  
  
Commit this separately, in hopes that we can restore the test after  
making get_memoized_path smarter.  (It's failing to find memoize  
plans in adjacent cases where no PHV was ever inserted, so there  
is definitely room for improvement there.)  
  
Discussion: https://postgr.es/m/CAG1ps1xvnTZceKK24OUfMKLPvDP2vjT-d+F2AOCWbw_v3KeEgg@mail.gmail.com  

M src/test/regress/expected/memoize.out
M src/test/regress/sql/memoize.sql

Define PG_LOGICAL_DIR for path pg_logical/ in data folder

commit   : c39afc38cfec7c34b883095062a89a63b221521a    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 30 Aug 2024 15:25:12 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 30 Aug 2024 15:25:12 +0900    

Click here for diff

This is similar to 2065ddf5e34c, but this time for pg_logical/ itself  
and its contents, like the paths for snapshots, mappings or origin  
checkpoints.  
  
Author: Bertrand Drouvot  
Reviewed-by: Ashutosh Bapat, Yugo Nagata, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/rewriteheap.c
M src/backend/replication/logical/origin.c
M src/backend/replication/logical/reorderbuffer.c
M src/backend/replication/logical/snapbuild.c
M src/backend/utils/adt/genfile.c
M src/include/replication/reorderbuffer.h

Define PG_REPLSLOT_DIR for path pg_replslot/ in data folder

commit   : 2065ddf5e34ce098f549c4279ee3ab33c188a764    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 30 Aug 2024 10:42:21 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 30 Aug 2024 10:42:21 +0900    

Click here for diff

This commit replaces most of the hardcoded values of "pg_replslot" by a  
new PG_REPLSLOT_DIR #define.  This makes the style more consistent with  
the existing PG_STAT_TMP_DIR, for example.  More places will follow a  
similar change.  
  
Author: Bertrand Drouvot  
Reviewed-by: Ashutosh Bapat, Yugo Nagata, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/backup/basebackup.c
M src/backend/replication/logical/reorderbuffer.c
M src/backend/replication/slot.c
M src/backend/utils/adt/genfile.c
M src/bin/pg_rewind/filemap.c
M src/include/replication/slot.h

Rename pg_sequence_read_tuple() to pg_get_sequence_data()

commit   : a83a944e9fdd573802c82d961126ba07bfb65f98    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 30 Aug 2024 08:49:24 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 30 Aug 2024 08:49:24 +0900    

Click here for diff

This commit removes log_cnt from the tuple returned by the SQL function.  
This field is an internal counter that tracks when a WAL record should  
be generated for a sequence, and it is reset each time the sequence is  
restored or recovered.  It is not necessary to rebuild the sequence DDL  
commands for pg_dump and pg_upgrade where this function is used.  The  
field can still be queried with a scan of the "table" created  
under-the-hood for a sequence.  
  
Issue noticed while hacking on a feature that can rely on this new  
function rather than pg_sequence_last_value(), aimed at making sequence  
computation more easily pluggable.  
  
Bump catalog version.  
  
Reviewed-by: Nathan Bossart  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/sequence.c
M src/bin/pg_dump/pg_dump.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/sequence.out
M src/test/regress/sql/sequence.sql

Fix mis-deparsing of ORDER BY lists when there is a name conflict.

commit   : 43f2e7634d838b39fd3fa3aaddb6964392d98312    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 29 Aug 2024 13:24:17 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 29 Aug 2024 13:24:17 -0400    

Click here for diff

If an ORDER BY item in SELECT is a bare identifier, the parser  
first seeks it as an output column name of the SELECT (for SQL92  
compatibility).  However, ruleutils.c is expecting the SQL99  
interpretation where such a name is an input column name.  So it's  
possible to produce an incorrect display of a view in the (admittedly  
pretty ill-advised) case where some other column is renamed in the  
SELECT output list to match an ORDER BY column.  
  
This can be fixed by table-qualifying such names in the dumped  
view text.  To avoid cluttering less-ill-advised queries, we'd  
like to do so only when there's an actual name conflict.  
That requires passing the current get_query_def call's resultDesc  
parameter down to get_variable, so that it can determine what  
the output column names are.  In hopes of reducing rather than  
increasing notational clutter in ruleutils.c, I moved that value  
into the deparse_context struct and removed it from the parameter  
lists of get_query_def's other subroutines.  
  
I made a few other cosmetic changes while at it:  
* Likewise move the colNamesVisible parameter into deparse_context.  
* Rename deparse_context's windowTList field to targetList,  
since it's no longer used only in connection with WINDOW clauses.  
* Replace the special_exprkind field with a bool inGroupBy,  
since that was all it was being used for, and the apparent  
flexibility of storing a ParseExprKind proved to be illusory.  
(We need a separate varInOrderBy field to make this patch work.)  
* Remove useless save/restore logic in get_select_query_def.  
  
In principle, this bug is quite old.  However, it seems unreachable  
before 1b4d280ea, because before that the presence of "new" and "old"  
entries in a view's rangetable caused us to always table-qualify every  
Var reference in dumped views.  Hence, back-patch to v16 where that  
came in.  
  
Per bug #18589 from Quynh Tran.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/create_view.out
M src/test/regress/sql/create_view.sql

Message style improvements

commit   : edee0c621de6f334c94c0ed8649d31ceba7401c8    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 14:43:34 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 14:43:34 +0200    

Click here for diff

M src/backend/access/transam/varsup.c
M src/backend/access/transam/xact.c
M src/backend/backup/basebackup_incremental.c
M src/backend/commands/copyfromparse.c
M src/backend/commands/subscriptioncmds.c
M src/backend/commands/tablecmds.c
M src/backend/postmaster/walsummarizer.c
M src/backend/replication/logical/logical.c
M src/backend/replication/logical/slotsync.c
M src/backend/replication/pgoutput/pgoutput.c
M src/backend/replication/slot.c
M src/backend/rewrite/rewriteHandler.c
M src/backend/utils/adt/jsonpath_exec.c
M src/backend/utils/misc/guc_tables.c
M src/bin/pg_basebackup/t/010_pg_basebackup.pl
M src/common/parse_manifest.c
M src/test/recovery/t/040_standby_failover_slots_sync.pl
M src/test/regress/expected/copy2.out
M src/test/regress/expected/foreign_key.out
M src/test/regress/expected/jsonb_jsonpath.out
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/expected/sqljson_queryfuncs.out
M src/test/regress/expected/updatable_views.out

Put generated_stored test objects in a schema

commit   : 894be11adfa60ad1ce5f74534cf5f04e66d51c30    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 11:49:48 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 11:49:48 +0200    

Click here for diff

This avoids naming conflicts with concurrent tests with similarly  
named objects.  Currently, there are none, but a tests for virtual  
generated columns are planned to be added.  
  
Reviewed-by: Corey Huinker <[email protected]>  
Reviewed-by: Tomasz Rybak <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/test/regress/expected/generated_stored.out
M src/test/regress/sql/generated_stored.sql

Rename regress test generated to generated_stored

commit   : b9ed4969250d1ca8208a8aec91f02ec0d6b28d1c    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 11:49:48 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 11:49:48 +0200    

Click here for diff

This makes naming room to have another test file for virtual generated  
columns.  
  
Reviewed-by: Corey Huinker <[email protected]>  
Reviewed-by: Tomasz Rybak <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

R100 src/test/regress/expected/generated.out src/test/regress/expected/generated_stored.out
M src/test/regress/parallel_schedule
R100 src/test/regress/sql/generated.sql src/test/regress/sql/generated_stored.sql

Disallow USING clause when altering type of generated column

commit   : 4d68a043245a6947d676a216aaac0714bcaf97d5    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 08:38:29 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 08:38:29 +0200    

Click here for diff

This does not make sense.  It would write the output of the USING  
clause into the converted column, which would violate the generation  
expression.  This adds a check to error out if this is specified.  
  
There was a test for this, but that test errored out for a different  
reason, so it was not effective.  
  
Reported-by: Jian He <[email protected]>  
Reviewed-by: Yugo NAGATA <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/c7083982-69f4-4b14-8315-f9ddb20b9834%40eisentraut.org  

M src/backend/commands/tablecmds.c
M src/test/regress/expected/generated.out

Rename some shared memory initialization routines

commit   : 478846e7688c9ab73d2695a66822e9ae0574b551    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Thu, 29 Aug 2024 09:46:21 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Thu, 29 Aug 2024 09:46:21 +0300    

Click here for diff

To make them follow the usual naming convention where  
FoobarShmemSize() calculates the amount of shared memory needed by  
Foobar subsystem, and FoobarShmemInit() performs the initialization.  
  
I didn't rename CreateLWLocks() and InitShmmeIndex(), because they are  
a little special. They need to be called before any of the other  
ShmemInit() functions, because they set up the shared memory  
bookkeeping itself. I also didn't rename InitProcGlobal(), because  
unlike other Shmeminit functions, it's not called by individual  
backends.  
  
Reviewed-by: Andreas Karlsson  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/storage/buffer/buf_init.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/buffer/freelist.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/ipc/procarray.c
M src/backend/storage/ipc/sinvaladt.c
M src/backend/storage/lmgr/predicate.c
M src/backend/utils/activity/backend_status.c
M src/backend/utils/init/postinit.c
M src/include/storage/bufmgr.h
M src/include/storage/predicate.h
M src/include/storage/procarray.h
M src/include/storage/sinvaladt.h
M src/include/utils/backend_status.h

Refactor lock manager initialization to make it a bit less special

commit   : fbce7dfc77eaa0d017dfee78c9d27b142d435e41    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Thu, 29 Aug 2024 09:46:06 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Thu, 29 Aug 2024 09:46:06 +0300    

Click here for diff

Split the shared and local initialization to separate functions, and  
follow the common naming conventions. With this, we no longer create  
the LockMethodLocalHash hash table in the postmaster process, which  
was always pointless.  
  
Reviewed-by: Andreas Karlsson  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/storage/ipc/ipci.c
M src/backend/storage/lmgr/lock.c
M src/backend/utils/init/postinit.c
M src/include/storage/lock.h

Refactor some code for ALTER TABLE SET LOGGED/UNLOGGED in tablecmds.c

commit   : 9f87da1cffda0e07ff3babcfa84abe9e849ccd95    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 29 Aug 2024 15:31:30 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 29 Aug 2024 15:31:30 +0900    

Click here for diff

Both sub-commands use the same routine to switch the relpersistence of a  
relation, duplicated the same checks, and used a style inconsistent with  
access methods and tablespaces.  
  
SET LOGEED/UNLOGGED is refactored to avoid any duplication, setting the  
reason why a relation rewrite happens within ATPrepChangePersistence().  
This shaves some code.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/tablecmds.c

Fixup for prefetching support on macOS

commit   : d7fe02fb9e6eee16b61874bc8964b0e2d4c5b2ad    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 08:22:28 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 29 Aug 2024 08:22:28 +0200    

Click here for diff

The new code path (commit 6654bb92047) should call FileAccess() first,  
like the posix_fadvise() path.  
  
Reported-by: Thomas Munro <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/0827edec-1317-4917-a186-035eb1e3241d%40eisentraut.org  

M src/backend/storage/file/fd.c

Rename the conflict types for the origin differ cases.

commit   : 640178c92e3f6c74d275369b291b507834f1309e    
  
author   : Amit Kapila <[email protected]>    
date     : Thu, 29 Aug 2024 09:12:12 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Thu, 29 Aug 2024 09:12:12 +0530    

Click here for diff

The conflict types 'update_differ' and 'delete_differ' indicate that a row  
to be modified was previously altered by another origin. Rename those to  
'update_origin_differs' and 'delete_origin_differs' to clarify their  
meaning.  
  
Author: Hou Zhijie  
Reviewed-by: Shveta Malik, Peter Smith  
Discussion: https://postgr.es/m/CAA4eK1+HEKwG_UYt4Zvwh5o_HoCKCjEGesRjJX38xAH3OxuuYA@mail.gmail.com  

M doc/src/sgml/logical-replication.sgml
M src/backend/replication/logical/conflict.c
M src/backend/replication/logical/worker.c
M src/include/replication/conflict.h
M src/test/subscription/t/013_partition.pl
M src/test/subscription/t/030_origin.pl

Doc: Fix the ambiguity in the description of failover slots.

commit   : 9d90e2bdafbdeba037aa4fee3febe9f48201bf74    
  
author   : Amit Kapila <[email protected]>    
date     : Thu, 29 Aug 2024 08:56:52 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Thu, 29 Aug 2024 08:56:52 +0530    

Click here for diff

The failover slots ensure a seamless transition of a subscriber after the  
standby is promoted. But the docs for it also explain the behavior of  
asynchronous replication which can confuse the readers.  
  
Reported-by: Masahiro Ikeda  
Backpatch-through: 17  
Discussion: https://postgr.es/m/OS3PR01MB6390B660F4198BB9745E0526B18B2@OS3PR01MB6390.jpnprd01.prod.outlook.com  

M doc/src/sgml/logical-replication.sgml

Add prefetching support on macOS

commit   : 6654bb92047b37cee053cedd6fa1829841b2ad8e    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 28 Aug 2024 07:26:48 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 28 Aug 2024 07:26:48 +0200    

Click here for diff

macOS doesn't have posix_fadvise(), but fcntl() with the F_RDADVISE  
command does the same thing.  
  
Some related documentation has been generalized to not mention  
posix_advise() specifically anymore.  
  
Reviewed-by: Thomas Munro <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/0827edec-1317-4917-a186-035eb1e3241d%40eisentraut.org  

M doc/src/sgml/config.sgml
M doc/src/sgml/wal.sgml
M src/backend/commands/variable.c
M src/backend/storage/file/fd.c
M src/include/pg_config_manual.h
M src/include/port/darwin.h

Message style improvements

commit   : 2e6a8047f0c94b4ac1c3e80faecd628ae552a6c3    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 27 Aug 2024 16:54:10 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 27 Aug 2024 16:54:10 +0200    

Click here for diff

M src/bin/pg_amcheck/pg_amcheck.c
M src/bin/pg_amcheck/t/003_check.pl
M src/bin/pg_combinebackup/pg_combinebackup.c
M src/bin/pg_combinebackup/reconstruct.c
M src/bin/pg_dump/pg_dumpall.c
M src/bin/pg_rewind/pg_rewind.c

Fix misplaced translator comments

commit   : dc26ff2f228174efed9bf285ee8f8065ea295799    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 27 Aug 2024 16:15:28 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 27 Aug 2024 16:15:28 +0200    

Click here for diff

They did not immediately precede the code they were applying to.  

M src/backend/replication/logical/slotsync.c

Fix identation.

commit   : 7229ebe011dff3f418251a4836f6d098923aa1e1    
  
author   : Masahiko Sawada <[email protected]>    
date     : Mon, 26 Aug 2024 16:16:12 -0700    
  
committer: Masahiko Sawada <[email protected]>    
date     : Mon, 26 Aug 2024 16:16:12 -0700    

Click here for diff

M src/backend/replication/logical/reorderbuffer.c

Fix memory counter update in ReorderBuffer.

commit   : 52f1d6730bf7132a175b9b612029812859218927    
  
author   : Masahiko Sawada <[email protected]>    
date     : Mon, 26 Aug 2024 11:00:07 -0700    
  
committer: Masahiko Sawada <[email protected]>    
date     : Mon, 26 Aug 2024 11:00:07 -0700    

Click here for diff

Commit 5bec1d6bc5e changed the memory usage updates of the  
ReorderBufferTXN to zero all at once by subtracting txn->size, rather  
than updating it for each change. However, if TOAST reconstruction  
data remained in the transaction when freeing it, there were cases  
where it further subtracted the memory counter from zero, resulting in  
an assertion failure.  
  
This change calculates the memory size for each change and updates the  
memory usage to precisely the amount that has been freed.  
  
Backpatch to v17, where this was introducd.  
  
Reviewed-by: Amit Kapila, Shlok Kyal  
Discussion: https://postgr.es/m/CAD21AoAqkNUvicgKPT_dXzNoOwpPkVTg0QPPxEcWmzT0moCJ1g%40mail.gmail.com  
Backpatch-through: 17  

M contrib/test_decoding/expected/stream.out
M contrib/test_decoding/sql/stream.sql
M src/backend/replication/logical/reorderbuffer.c

Fix nbtree lookahead overflow bug.

commit   : 09a8407dbfd848301cd2c9801c3b4d75adc6cabc    
  
author   : Peter Geoghegan <[email protected]>    
date     : Mon, 26 Aug 2024 11:29:15 -0400    
  
committer: Peter Geoghegan <[email protected]>    
date     : Mon, 26 Aug 2024 11:29:15 -0400    

Click here for diff

Add bounds checking to nbtree's lookahead/skip-within-a-page mechanism.  
Otherwise it's possible for cases with lots of before-array-keys tuples  
to overflow an int16 variable, causing the mechanism to generate an out  
of bounds page offset number.  
  
Oversight in commit 5bf748b8, which enhanced nbtree ScalarArrayOp  
execution.  
  
Reported-By: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 17-, where nbtree SAOP execution was enhanced.  

M src/backend/access/nbtree/nbtutils.c

pg_upgrade: Message style improvements

commit   : dbe37f1adb9fd10dc273ccf50816895360bcbc15    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 26 Aug 2024 14:38:59 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 26 Aug 2024 14:38:59 +0200    

Click here for diff

M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/info.c
M src/bin/pg_upgrade/t/003_logical_slots.pl

Fix compiler warning in mul_var_short().

commit   : 7cac6307a43c1fcbd050724d3995a489da62e852    
  
author   : Dean Rasheed <[email protected]>    
date     : Mon, 26 Aug 2024 11:00:20 +0100    
  
committer: Dean Rasheed <[email protected]>    
date     : Mon, 26 Aug 2024 11:00:20 +0100    

Click here for diff

Some compilers (e.g., gcc before version 7) mistakenly think "carry"  
might be used uninitialized.  
  
Reported by Tom Lane, per various buildfarm members, e.g. arowana.  

M src/backend/utils/adt/numeric.c

Revert: Avoid looping over all type cache entries in TypeCacheRelCallback()

commit   : 8daa62a10c911c851f7e9ec5ef7b90cfd4b73212    
  
author   : Alexander Korotkov <[email protected]>    
date     : Mon, 26 Aug 2024 00:22:44 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Mon, 26 Aug 2024 00:22:44 +0300    

Click here for diff

This commit reverts c14d4acb8 as the patch design didn't take into account  
that TypeCacheEntry could be invalidated during the lookup_type_cache() call.  
  
Reported-by: Alexander Lakhin  
Discussion: https://postgr.es/m/1927cba4-177e-5c23-cbcc-d444a850304f%40gmail.com  

M src/backend/utils/cache/typcache.c
M src/tools/pgindent/typedefs.list

Avoid looping over all type cache entries in TypeCacheRelCallback()

commit   : c14d4acb81348a34497b53a19dce2924cc4f6551    
  
author   : Alexander Korotkov <[email protected]>    
date     : Sun, 25 Aug 2024 03:21:23 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Sun, 25 Aug 2024 03:21:23 +0300    

Click here for diff

Currently when a single relcache entry gets invalidated,  
TypeCacheRelCallback() has to loop over all type cache entries to find  
appropriate typentry to invalidate.  Unfortunately, using the syscache here  
is impossible, because this callback could be called outside a transaction  
and this makes impossible catalog lookups.  This is why present commit  
introduces RelIdToTypeIdCacheHash to map relation OID to its composite type  
OID.  
  
We are keeping RelIdToTypeIdCacheHash entry while corresponding type cache  
entry have something to clean.  Therefore, RelIdToTypeIdCacheHash shouldn't  
get bloat in the case of temporary tables flood.  
  
Discussion: https://postgr.es/m/5812a6e5-68ae-4d84-9d85-b443176966a1%40sigaev.ru  
Author: Teodor Sigaev  
Reviewed-by: Aleksander Alekseev, Tom Lane, Michael Paquier, Roman Zharkov  
Reviewed-by: Andrei Lepikhov, Pavel Borisov  

M src/backend/utils/cache/typcache.c
M src/tools/pgindent/typedefs.list

Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands

commit   : 3890d90c1508125729ed20038d90513694fc3a7b    
  
author   : Alexander Korotkov <[email protected]>    
date     : Sat, 24 Aug 2024 18:48:48 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Sat, 24 Aug 2024 18:48:48 +0300    

Click here for diff

This commit reverts 1adf16b8fb, 87c21bb941, and subsequent fixes and  
improvements including df64c81ca9, c99ef1811a, 9dfcac8e15, 885742b9f8,  
842c9b2705, fcf80c5d5f, 96c7381c4c, f4fc7cb54b, 60ae37a8bc, 259c96fa8f,  
449cdcd486, 3ca43dbbb6, 2a679ae94e, 3a82c689fd, fbd4321fd5, d53a4286d7,  
c086896625, 4e5d6c4091, 04158e7fa3.  
  
The reason for reverting is security issues related to repeatable name lookups  
(CVE-2014-0062).  Even though 04158e7fa3 solved part of the problem, there  
are still remaining issues, which aren't feasible to even carefully analyze  
before the RC deadline.  
  
Reported-by: Noah Misch, Robert Haas  
Discussion: https://postgr.es/m/20240808171351.a9.nmisch%40google.com  
Backpatch-through: 17  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/ref/alter_table.sgml
M src/backend/commands/tablecmds.c
M src/backend/parser/gram.y
M src/backend/parser/parse_utilcmd.c
M src/backend/partitioning/partbounds.c
M src/backend/tcop/utility.c
M src/backend/utils/adt/ruleutils.c
M src/bin/psql/tab-complete.c
M src/include/nodes/parsenodes.h
M src/include/parser/kwlist.h
M src/include/partitioning/partbounds.h
M src/include/utils/ruleutils.h
D src/test/isolation/expected/partition-merge.out
D src/test/isolation/expected/partition-split.out
M src/test/isolation/isolation_schedule
D src/test/isolation/specs/partition-merge.spec
D src/test/isolation/specs/partition-split.spec
M src/test/modules/test_ddl_deparse/test_ddl_deparse.c
D src/test/regress/expected/partition_merge.out
D src/test/regress/expected/partition_split.out
M src/test/regress/parallel_schedule
D src/test/regress/sql/partition_merge.sql
D src/test/regress/sql/partition_split.sql
M src/tools/pgindent/typedefs.list

pg_createsubscriber: Message style improvements

commit   : 6e8a0317b4c062d4d524b916e10ca7f351ed0793    
  
author   : Peter Eisentraut <[email protected]>    
date     : Sat, 24 Aug 2024 15:56:32 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Sat, 24 Aug 2024 15:56:32 +0200    

Click here for diff

M doc/src/sgml/ref/pg_createsubscriber.sgml
M src/bin/pg_basebackup/pg_createsubscriber.c

Provide feature-test macros for libpq features added in v17.

commit   : ff59d5d2cff32cfe88131f87b6c401970d449c08    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 23 Aug 2024 10:12:56 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 23 Aug 2024 10:12:56 -0400    

Click here for diff

As per the policy established in commit 6991e774e, invent macros  
that can be tested at compile time to detect presence of new libpq  
features.  This should make calling code more readable and less  
error-prone than checking the libpq version would be (especially  
since we don't expose that at compile time; the server version is  
an unreliable substitute).  
  
Discussion: https://postgr.es/m/[email protected]  

M src/interfaces/libpq/libpq-fe.h

thread-safety: gmtime_r(), localtime_r()

commit   : a2bbc58f743489784de797d81be37ea309cb0773    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 23 Aug 2024 07:07:53 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 23 Aug 2024 07:07:53 +0200    

Click here for diff

Use gmtime_r() and localtime_r() instead of gmtime() and localtime(),  
for thread-safety.  
  
There are a few affected calls in libpq and ecpg's libpgtypes, which  
are probably effectively bugs, because those libraries already claim  
to be thread-safe.  
  
There is one affected call in the backend.  Most of the backend  
otherwise uses the custom functions pg_gmtime() and pg_localtime(),  
which are implemented differently.  
  
While we're here, change the call in the backend to gmtime*() instead  
of localtime*(), since for that use time zone behavior is irrelevant,  
and this side-steps any questions about when time zones are  
initialized by localtime_r() vs localtime().  
  
Portability: gmtime_r() and localtime_r() are in POSIX but are not  
available on Windows.  Windows has functions gmtime_s() and  
localtime_s() that can fulfill the same purpose, so we add some small  
wrappers around them.  (Note that these *_s() functions are also  
different from the *_s() functions in the bounds-checking extension of  
C11.  We are not using those here.)  
  
On MinGW, you can get the POSIX-style *_r() functions by defining  
_POSIX_C_SOURCE appropriately before including <time.h>.  This leads  
to a conflict at least in plpython because apparently _POSIX_C_SOURCE  
gets defined in some header there, and then our replacement  
definitions conflict with the system definitions.  To avoid that sort  
of thing, we now always define _POSIX_C_SOURCE on MinGW and use the  
POSIX-style functions here.  
  
Reviewed-by: Stepan Neretin <[email protected]>  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Reviewed-by: Thomas Munro <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M meson.build
M src/backend/utils/adt/pg_locale.c
M src/include/port/win32_port.h
M src/interfaces/ecpg/pgtypeslib/dt_common.c
M src/interfaces/ecpg/pgtypeslib/timestamp.c
M src/interfaces/libpq/fe-trace.c
M src/template/win32

Rework new SLRU test with injection points

commit   : 94a3373ac5c3d2444b2379a3c185b986627c42d4    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 23 Aug 2024 12:11:36 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 23 Aug 2024 12:11:36 +0900    

Click here for diff

Rather than the SQL injection_points_load(), this commit changes the  
injection point test introduced in 768a9fd5535f to rely on the two  
macros INJECTION_POINT_LOAD() and INJECTION_POINT_CACHED(), that have  
been originally introduced for the sake of this test.  
  
This runs the test as a two-step process: load the injection point, then  
run its callback directly from the local cache loaded.  What the test  
did originally was also fine, but the point here is to have an example  
in core of how to use these new macros.  
  
While on it, fix the header ordering in multixact.c, as pointed out by  
Alexander Korotkov.  This was an oversight in 768a9fd5535f.  
  
Per discussion with Álvaro Herrera.  
  
Author: Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/CAPpHfduzaBz7KMhwuVOZMTpG=JniPG4aUosXPZCxZydmzq_oEQ@mail.gmail.com  

M src/backend/access/transam/multixact.c
M src/test/modules/test_slru/t/001_multixact.pl

injection_point: Add injection_points.stats

commit   : 2e35c67f956891b2dd7c30fbac9a14e76377300a    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 23 Aug 2024 11:36:41 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 23 Aug 2024 11:36:41 +0900    

Click here for diff

This GUC controls if cumulative statistics are enabled or not in the  
module.  Custom statistics require the module to be loaded with  
shared_preload_libraries, hence this GUC is made PGC_POSTMASTER.  By  
default, the stats are disabled.  001_stats.pl is updated to enable the  
statistics, as it is the only area where these are required now.  
  
This will be used by an upcoming change for the injection point test  
added by 768a9fd5535f where stats should not be used, as the test runs a  
point callback in a critical section.  And the module injection_points  
will need to be loaded with shared_preload_libraries there.  
  
Per discussion with Álvaro Herrera.  
  
Author: Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  

M src/test/modules/injection_points/injection_points.c
M src/test/modules/injection_points/injection_stats.c
M src/test/modules/injection_points/injection_stats.h
M src/test/modules/injection_points/injection_stats_fixed.c
M src/test/modules/injection_points/t/001_stats.pl

injection_points: Add initialization of shmem state when loading module

commit   : b2b023aa3706ec6b3978708545301f7436205c6d    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 23 Aug 2024 10:12:58 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 23 Aug 2024 10:12:58 +0900    

Click here for diff

This commits adds callbacks to initialize the shared memory state of the  
module when loaded with shared_preload_libraries.  This is necessary to  
be able to update the test introduced in 768a9fd5535f to use the macros  
INJECTION_POINT_{LOAD,CACHED}() rather than a SQL function in the module  
injection_points forcing a load, as this test runs a callback in a  
critical section where no memory allocation should happen.  
  
Initializing the shared memory state of the module while loading  
provides a strict control on the timing of its allocation.  If the  
module is not loaded at startup, it will use a GetNamedDSMSegment()  
instead to initialize its shmem state on-the-fly.  
  
Per discussion with Álvaro Herrera.  
  
Author: Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  

M src/test/modules/injection_points/injection_points.c

Doc: explain the log format of logical replication conflicts.

commit   : edcb71258504ed22abba8cc7181d2bab3762e757    
  
author   : Amit Kapila <[email protected]>    
date     : Thu, 22 Aug 2024 14:11:50 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Thu, 22 Aug 2024 14:11:50 +0530    

Click here for diff

This commit adds a detailed explanation of the log format for logical  
replication conflicts.  
  
Author: Hou Zhijie  
Reviewed-by: Shveta Malik, Peter Smith, Hayato Kuroda  
Discussion: https://postgr.es/m/OS0PR01MB5716352552DFADB8E9AD1D8994C92@OS0PR01MB5716.jpnprd01.prod.outlook.com  
Discussion: https://postgr.es/m/OS0PR01MB57162EDE8BA17F3EE08A24CA948D2@OS0PR01MB5716.jpnprd01.prod.outlook.com  

M doc/src/sgml/logical-replication.sgml

psql: Add more meta-commands able to use the extended protocol

commit   : d55322b0da60a8798ffdb8b78ef90db0fb5be18e    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 22 Aug 2024 16:25:57 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 22 Aug 2024 16:25:57 +0900    

Click here for diff

Currently, only unnamed prepared statement are supported by psql with  
the meta-command \bind.  With only this command, it is not possible to  
test named statement creation, execution or close through the extended  
protocol.  
  
This commit introduces three additional commands:  
* \parse creates a prepared statement using the extended protocol,  
acting as a wrapper of libpq's PQsendPrepare().  
* \bind_named binds and executes an existing prepared statement using  
the extended protocol, for PQsendQueryPrepared().  
* \close closes an existing prepared statement using the extended  
protocol, for PQsendClosePrepared().  
  
This is going to be useful to add regression tests for the extended  
query protocol, and I have some plans for that on separate threads.  
Note that \bind relies on PQsendQueryParams().  
  
The code of psql is refactored so as bind_flag is replaced by an enum in  
_psqlSettings that tracks the type of libpq routine to execute, based on  
the meta-command involved, with the default being PQsendQuery().  This  
refactoring piece has been written by me, while Anthonin has implemented  
the rest.  
  
Author: Anthonin Bonnefoy, Michael Paquier  
Reviewed-by: Aleksander Alekseev, Jelte Fennema-Nio  
Discussion: https://postgr.es/m/CAO6_XqpSq0Q0kQcVLCbtagY94V2GxNP3zCnR6WnOM8WqXPK4nw@mail.gmail.com  

M doc/src/sgml/ref/psql-ref.sgml
M src/bin/psql/command.c
M src/bin/psql/common.c
M src/bin/psql/help.c
M src/bin/psql/settings.h
M src/bin/psql/tab-complete.c
M src/test/regress/expected/psql.out
M src/test/regress/sql/psql.sql
M src/tools/pgindent/typedefs.list

Fix attach of a previously-detached injection point.

commit   : a36aa223ec447276bf7050ab9ec6d974cafdf6c4    
  
author   : Noah Misch <[email protected]>    
date     : Thu, 22 Aug 2024 00:07:04 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Thu, 22 Aug 2024 00:07:04 -0700    

Click here for diff

It's normal for the name in a free slot to match the new name.  The  
max_inuse mechanism kept simple cases from reaching the problem.  The  
problem could appear when index 0 was the previously-detached entry and  
index 1 is in use.  Back-patch to v17, where this code first appeared.  

M src/backend/utils/misc/injection_point.c

Avoid repeated table name lookups in createPartitionTable()

commit   : 04158e7fa37c2dda9c3421ca922d02807b86df19    
  
author   : Alexander Korotkov <[email protected]>    
date     : Thu, 22 Aug 2024 09:50:48 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Thu, 22 Aug 2024 09:50:48 +0300    

Click here for diff

Currently, createPartitionTable() opens newly created table using its name.  
This approach is prone to privilege escalation attack, because we might end  
up opening another table than we just created.  
  
This commit address the issue above by opening newly created table by its  
OID.  It appears to be tricky to get a relation OID out of ProcessUtility().  
We have to extend TableLikeClause with new newRelationOid field, which is  
filled within ProcessUtility() to be further accessed by caller.  
  
Security: CVE-2014-0062  
Reported-by: Noah Misch  
Discussion: https://postgr.es/m/20240808171351.a9.nmisch%40google.com  
Reviewed-by: Pavel Borisov, Dmitry Koval  

M src/backend/commands/tablecmds.c
M src/backend/parser/gram.y
M src/backend/tcop/utility.c
M src/include/nodes/parsenodes.h

Small code simplification

commit   : 9bb842f95ef3384f0822c386a4c569780e613e4e    
  
author   : Richard Guo <[email protected]>    
date     : Thu, 22 Aug 2024 11:41:08 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Thu, 22 Aug 2024 11:41:08 +0900    

Click here for diff

Apply the same code simplification to ATExecAddColumn as was done in  
7ff9afbbd: apply GETSTRUCT() once instead of doing it repeatedly in  
the same function.  
  
Author: Tender Wang  
Discussion: https://postgr.es/m/CAHewXNkO9+U437jvKT14s0MCu6Qpf6G-p2mZK5J9mAi4cHDgpQ@mail.gmail.com  

M src/backend/commands/tablecmds.c

Create syscache entries for pg_extension

commit   : 490f869d92e5db38731b85b9be3cffdc65461808    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 22 Aug 2024 10:48:25 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 22 Aug 2024 10:48:25 +0900    

Click here for diff

Two syscache identifiers are added for extension names and OIDs.  
  
Shared libraries of extensions might want to invalidate or update their  
own caches whenever a CREATE, ALTER or DROP EXTENSION command is run for  
their extension (in any backend).  Right now this is non-trivial to do  
correctly and efficiently, but, if an extension catalog is part of a  
syscache, this could simply be done by registering an callback using  
CacheRegisterSyscacheCallback for the relevant syscache.  
  
Another case where this is useful is a loaded library where some of its  
code paths rely on some objects of the extension to exist; it can be  
simpler and more efficient to do an existence check directly on the  
extension through the syscache.  
  
Author: Jelte Fennema-Nio  
Reviewed-by: Alexander Korotkov, Pavel Stehule  
Discussion: https://postgr.es/m/CAGECzQTWm9sex719Hptbq4j56hBGUti7J9OWjeMobQ1ccRok9w@mail.gmail.com  

M src/include/catalog/pg_extension.h

Fix obsolete comments in varstr_cmp().

commit   : a8395677840c37f6988d7d6420d551d0b744e6bd    
  
author   : Jeff Davis <[email protected]>    
date     : Wed, 21 Aug 2024 09:19:21 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Wed, 21 Aug 2024 09:19:21 -0700    

Click here for diff

M src/backend/utils/adt/varlena.c

Disallow creating binary-coercible casts involving range types.

commit   : 86488cdf1249f86cff75c2446f670be49cb55055    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 21 Aug 2024 12:00:03 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 21 Aug 2024 12:00:03 -0400    

Click here for diff

For a long time we have forbidden binary-coercible casts to or from  
composite and array types, because such a cast cannot work correctly:  
the type OID embedded in the value would need to change, but it won't  
in a binary coercion.  That reasoning applies equally to range types,  
but we overlooked installing a similar restriction here when we  
invented range types.  Do so now.  
  
Given the lack of field complaints, we won't change this in stable  
branches, but it seems not too late for v17.  
  
Per discussion of a problem noted by Peter Eisentraut.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/functioncmds.c

Show number of disabled nodes in EXPLAIN ANALYZE output.

commit   : c01743aa4866e13da2c54e44010abc6d5f986363    
  
author   : Robert Haas <[email protected]>    
date     : Wed, 21 Aug 2024 10:14:35 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Wed, 21 Aug 2024 10:14:35 -0400    

Click here for diff

Now that disable_cost is not included in the cost estimate, there's  
no visible sign in EXPLAIN output of which plan nodes are disabled.  
Fix that by propagating the number of disabled nodes from Path to  
Plan, and then showing it in the EXPLAIN output.  
  
There is some question about whether this is a desirable change.  
While I personally believe that it is, it seems best to make it a  
separate commit, in case we decide to back out just this part, or  
rework it.  
  
Reviewed by Andres Freund, Heikki Linnakangas, and David Rowley.  
  
Discussion: http://postgr.es/m/CA+TgmoZ_+MS+o6NeGK2xyBv-xM+w1AfFVuHE4f_aq6ekHv7YSQ@mail.gmail.com  

M src/backend/commands/explain.c
M src/backend/optimizer/plan/createplan.c
M src/include/nodes/plannodes.h
M src/test/regress/expected/aggregates.out
M src/test/regress/expected/btree_index.out
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/expected/incremental_sort.out
M src/test/regress/expected/inherit.out
M src/test/regress/expected/join.out
M src/test/regress/expected/memoize.out
M src/test/regress/expected/select_parallel.out
M src/test/regress/expected/union.out

Treat number of disabled nodes in a path as a separate cost metric.

commit   : e22253467942fdb100087787c3e1e3a8620c54b2    
  
author   : Robert Haas <[email protected]>    
date     : Wed, 21 Aug 2024 10:12:30 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Wed, 21 Aug 2024 10:12:30 -0400    

Click here for diff

Previously, when a path type was disabled by e.g. enable_seqscan=false,  
we either avoided generating that path type in the first place, or  
more commonly, we added a large constant, called disable_cost, to the  
estimated startup cost of that path. This latter approach can distort  
planning. For instance, an extremely expensive non-disabled path  
could seem to be worse than a disabled path, especially if the full  
cost of that path node need not be paid (e.g. due to a Limit).  
Or, as in the regression test whose expected output changes with this  
commit, the addition of disable_cost can make two paths that would  
normally be distinguishible in cost seem to have fuzzily the same cost.  
  
To fix that, we now count the number of disabled path nodes and  
consider that a high-order component of both the startup cost and the  
total cost. Hence, the path list is now sorted by disabled_nodes and  
then by total_cost, instead of just by the latter, and likewise for  
the partial path list.  It is important that this number is a count  
and not simply a Boolean; else, as soon as we're unable to respect  
disabled path types in all portions of the path, we stop trying to  
avoid them where we can.  
  
Because the path list is now sorted by the number of disabled nodes,  
the join prechecks must compute the count of disabled nodes during  
the initial cost phase instead of postponing it to final cost time.  
  
Counts of disabled nodes do not cross subquery levels; at present,  
there is no reason for them to do so, since the we do not postpone  
path selection across subquery boundaries (see make_subplan).  
  
Reviewed by Andres Freund, Heikki Linnakangas, and David Rowley.  
  
Discussion: http://postgr.es/m/CA+TgmoZ_+MS+o6NeGK2xyBv-xM+w1AfFVuHE4f_aq6ekHv7YSQ@mail.gmail.com  

M contrib/file_fdw/file_fdw.c
M contrib/postgres_fdw/postgres_fdw.c
M contrib/postgres_fdw/postgres_fdw.h
M src/backend/optimizer/path/costsize.c
M src/backend/optimizer/path/joinpath.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/prep/prepunion.c
M src/backend/optimizer/util/pathnode.c
M src/include/nodes/pathnodes.h
M src/include/optimizer/cost.h
M src/include/optimizer/pathnode.h
M src/test/isolation/specs/horizons.spec
M src/test/regress/expected/btree_index.out
M src/test/regress/expected/select_parallel.out

Fix pgindent damage

commit   : 2b03cfeea47834913ff769124f4deba88140f662    
  
author   : Robert Haas <[email protected]>    
date     : Wed, 21 Aug 2024 09:58:11 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Wed, 21 Aug 2024 09:58:11 -0400    

Click here for diff

Oversight in commit a95ff1fe2eb4926b13e0940ad1f37d048704bdb0  

M src/backend/utils/adt/varlena.c

doc: remove llvm-config search from configure documentation

commit   : 4baff5013277a61f6d5e1e3369ae3f878cb48d0a    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 21 Aug 2024 15:11:21 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 21 Aug 2024 15:11:21 +0200    

Click here for diff

As of 4dd29b6833, we no longer attempt to locate any other llvm-config  
variant than plain llvm-config in configure-based builds; update the  
documentation accordingly. (For Meson-based builds, we still use Meson's  
LLVMDependencyConfigTool [0], which runs through a set of possible  
suffixes [1], so no need to update the documentation there.)  
  
[0]: https://github.com/mesonbuild/meson/blob/7d28ff29396f9d7043204de8ddc52226b9903811/mesonbuild/dependencies/dev.py#L184  
[1]: https://github.com/mesonbuild/meson/blob/7d28ff29396f9d7043204de8ddc52226b9903811/mesonbuild/environment.py#L183  
  
Author: Ole Peder Brandtzæg <[email protected]>  
Discussion: https://www.postgresql.org/message-id/20240518224601.gtisttjerylukjr5%40samfundet.no  

M doc/src/sgml/installation.sgml

Fix typos in 9758174e2e.

commit   : d43b8bb6b8f56cda59d14b5040496e266b0d9d25    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 21 Aug 2024 16:45:36 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 21 Aug 2024 16:45:36 +0530    

Click here for diff

Reported off-list by Erik Rijkers  

M doc/src/sgml/logical-replication.sgml

Small code simplification

commit   : 7ff9afbbd1df7c256024edb447eae7269c1bab03    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 21 Aug 2024 09:21:25 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 21 Aug 2024 09:21:25 +0200    

Click here for diff

Apply GETSTRUCT() once instead of doing it repeatedly in the same  
function.  This simplifies the notation and makes the function's  
structure more similar to the surrounding ones.  
  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/commands/tablecmds.c

Don't advance origin during apply failure.

commit   : 3f28b2fcac33fb352d261fac298cfe68c3899d32    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 21 Aug 2024 09:22:32 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 21 Aug 2024 09:22:32 +0530    

Click here for diff

We advance origin progress during abort on successful streaming and  
application of ROLLBACK in parallel streaming mode. But the origin  
shouldn't be advanced during an error or unsuccessful apply due to  
shutdown. Otherwise, it will result in a transaction loss as such a  
transaction won't be sent again by the server.  
  
Reported-by: Hou Zhijie  
Author: Hayato Kuroda and Shveta Malik  
Reviewed-by: Amit Kapila  
Backpatch-through: 16  
Discussion: https://postgr.es/m/TYAPR01MB5692FAC23BE40C69DA8ED4AFF5B92@TYAPR01MB5692.jpnprd01.prod.outlook.com  

M src/backend/replication/logical/worker.c
M src/backend/utils/error/elog.c
M src/include/utils/elog.h
M src/test/subscription/t/021_twophase.pl

Slightly refactor varstr_sortsupport() to improve readability.

commit   : a95ff1fe2eb4926b13e0940ad1f37d048704bdb0    
  
author   : Jeff Davis <[email protected]>    
date     : Tue, 20 Aug 2024 14:29:34 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Tue, 20 Aug 2024 14:29:34 -0700    

Click here for diff

Author: Andreas Karlsson  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/adt/varlena.c

Remove _PG_fini()

commit   : 15c1abd97710d74672e55d53148a0606baa91d18    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 21 Aug 2024 07:24:03 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 21 Aug 2024 07:24:03 +0900    

Click here for diff

ab02d702ef08 has removed from the backend the code able to support the  
unloading of modules, because this has never worked.  This removes the  
last references to _PG_fini(), that could be used as a callback for  
modules to manipulate the stack when unloading a library.  
  
The test module ldap_password_func had the idea to declare it, doing  
nothing.  The function declaration in fmgr.h is gone.  
  
It was left around in 2022 to avoid breaking extension code, but at this  
stage there are also benefits in letting extension developers know that  
keeping the unloading code is pointless and this move leads to less  
maintenance.  
  
Reviewed-by: Tom Lane, Heikki Linnakangas  
Discussion: https://postgr.es/m/[email protected]  

M src/include/fmgr.h
M src/test/modules/ldap_password_func/ldap_password_func.c

Minor wording change in table "JSON Creation Functions"

commit   : 678a8358d18d4079ced9f3655fead13df914cfbb    
  
author   : Alvaro Herrera <[email protected]>    
date     : Tue, 20 Aug 2024 17:53:40 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Tue, 20 Aug 2024 17:53:40 -0400    

Click here for diff

For readability.  Backpatch to 16.  
  
Author: Erik Wienhold <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml

Improve configure error for ICU libraries if pkg-config is absent.

commit   : 0fb0f689331cb0c00348aab752dced30493a6672    
  
author   : Jeff Davis <[email protected]>    
date     : Tue, 20 Aug 2024 11:24:00 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Tue, 20 Aug 2024 11:24:00 -0700    

Click here for diff

If pkg-config is not installed, the ICU libraries cannot be found, but  
the custom configure error message did not mention this. This might  
lead to confusion about the actual problem. To improve this, remove  
the explicit error message and rely on PKG_CHECK_MODULES' generic  
error message.  
  
Author: Michael Banck  
Reported-by: Holger Jakobs  
Discussion: https://postgr.es/m/ccd579ed-4949-d3de-ab13-9e6456fd2caf%40jakobs.com  
Discussion: https://postgr.es/m/[email protected]  

M configure
M configure.ac

Fix a couple of wait event descriptions.

commit   : 5ff9b6b4d981a59236a89d33dea8bc253257ce2a    
  
author   : Nathan Bossart <[email protected]>    
date     : Tue, 20 Aug 2024 13:43:20 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Tue, 20 Aug 2024 13:43:20 -0500    

Click here for diff

The descriptions for ProcArrayGroupUpdate and XactGroupUpdate claim  
that these events mean we are waiting for the group leader "at end  
of a parallel operation," but neither pertains to parallel  
operations.  This commit reverts these descriptions to their  
wording before commit 3048898e73, i.e., "end of a parallel  
operation" is changed to "transaction end."  
  
Author: Sameer Kumar  
Reviewed-by: Amit Kapila  
Discussion: https://postgr.es/m/CAGPeHmh6UMrKQHKCmX%2B5vV5TH9P%3DKw9en3k68qEem6J%3DyrZPUA%40mail.gmail.com  
Backpatch-through: 13  

M src/backend/utils/activity/wait_event_names.txt

Add injection-point test for new multixact CV usage

commit   : 768a9fd5535fddb781088b6f83132b9a1b1f5bd3    
  
author   : Alvaro Herrera <[email protected]>    
date     : Tue, 20 Aug 2024 14:20:48 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Tue, 20 Aug 2024 14:20:48 -0400    

Click here for diff

Before commit a0e0fb1ba56f, multixact.c contained a case in the  
multixact-read path where it would loop sleeping 1ms each time until  
another multixact-create path completed, which was uncovered by any  
tests.  That commit changed the code to rely on a condition variable  
instead.  Add a test now, which relies on injection points and "loading"  
thereof (because of it being in a critical section), per commit  
4b211003ecc2.  
  
Author: Andrey Borodin <[email protected]>  
Reviewed-by: Michaël Paquier <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/multixact.c
M src/test/modules/test_slru/Makefile
M src/test/modules/test_slru/meson.build
A src/test/modules/test_slru/t/001_multixact.pl
A src/test/modules/test_slru/test_multixact.c
M src/test/modules/test_slru/test_slru–1.0.sql

Document limit on the number of out-of-line values per table

commit   : 4d93bbd4e0d414a33521f62d6249ac88486c866f    
  
author   : John Naylor <[email protected]>    
date     : Tue, 20 Aug 2024 10:02:34 +0700    
  
committer: John Naylor <[email protected]>    
date     : Tue, 20 Aug 2024 10:02:34 +0700    

Click here for diff

Document the hard limit stemming from the size of an OID, and also  
mention the perfomance impact that occurs before the hard limit  
is reached.  
  
Jakub Wartak and Robert Haas  
Backpatch to all supported versions  
  
Discussion: https://postgr.es/m/CAKZiRmwWhp2yxjqJLwbBjHdfbJBcUmmKMNAZyBjjtpgM9AMatQ%40mail.gmail.com  

M doc/src/sgml/limits.sgml

Log the conflicts while applying changes in logical replication.

commit   : 9758174e2e5cd278cf37e0980da76b51890e0011    
  
author   : Amit Kapila <[email protected]>    
date     : Tue, 20 Aug 2024 08:35:11 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Tue, 20 Aug 2024 08:35:11 +0530    

Click here for diff

This patch provides the additional logging information in the following  
conflict scenarios while applying changes:  
  
insert_exists: Inserting a row that violates a NOT DEFERRABLE unique constraint.  
update_differ: Updating a row that was previously modified by another origin.  
update_exists: The updated row value violates a NOT DEFERRABLE unique constraint.  
update_missing: The tuple to be updated is missing.  
delete_differ: Deleting a row that was previously modified by another origin.  
delete_missing: The tuple to be deleted is missing.  
  
For insert_exists and update_exists conflicts, the log can include the origin  
and commit timestamp details of the conflicting key with track_commit_timestamp  
enabled.  
  
update_differ and delete_differ conflicts can only be detected when  
track_commit_timestamp is enabled on the subscriber.  
  
We do not offer additional logging for exclusion constraint violations because  
these constraints can specify rules that are more complex than simple equality  
checks. Resolving such conflicts won't be straightforward. This area can be  
further enhanced if required.  
  
Author: Hou Zhijie  
Reviewed-by: Shveta Malik, Amit Kapila, Nisha Moond, Hayato Kuroda, Dilip Kumar  
Discussion: https://postgr.es/m/OS0PR01MB5716352552DFADB8E9AD1D8994C92@OS0PR01MB5716.jpnprd01.prod.outlook.com  

M doc/src/sgml/logical-replication.sgml
M src/backend/access/index/genam.c
M src/backend/catalog/index.c
M src/backend/executor/execIndexing.c
M src/backend/executor/execMain.c
M src/backend/executor/execReplication.c
M src/backend/executor/nodeModifyTable.c
M src/backend/replication/logical/Makefile
A src/backend/replication/logical/conflict.c
M src/backend/replication/logical/meson.build
M src/backend/replication/logical/worker.c
M src/include/executor/executor.h
A src/include/replication/conflict.h
M src/test/subscription/t/001_rep_changes.pl
M src/test/subscription/t/013_partition.pl
M src/test/subscription/t/029_on_error.pl
M src/test/subscription/t/030_origin.pl
M src/tools/pgindent/typedefs.list

Speed up Hash Join by making ExprStates support hashing

commit   : adf97c1562380e02acd60dc859c289ed3a8352ee    
  
author   : David Rowley <[email protected]>    
date     : Tue, 20 Aug 2024 13:38:22 +1200    
  
committer: David Rowley <[email protected]>    
date     : Tue, 20 Aug 2024 13:38:22 +1200    

Click here for diff

Here we add ExprState support for obtaining a 32-bit hash value from a  
list of expressions.  This allows both faster hashing and also JIT  
compilation of these expressions.  This is especially useful when hash  
joins have multiple join keys as the previous code called ExecEvalExpr on  
each hash join key individually and that was inefficient as tuple  
deformation would have only taken into account one key at a time, which  
could lead to walking the tuple once for each join key.  With the new  
code, we'll determine the maximum attribute required and deform the tuple  
to that point only once.  
  
Some performance tests done with this change have shown up to a 20%  
performance increase of a query containing a Hash Join without JIT  
compilation and up to a 26% performance increase when JIT is enabled and  
optimization and inlining were performed by the JIT compiler.  The  
performance increase with 1 join column was less with a 14% increase  
with and without JIT.  This test was done using a fairly small hash  
table and a large number of hash probes.  The increase will likely be  
less with large tables, especially ones larger than L3 cache as memory  
pressure is more likely to be the limiting factor there.  
  
This commit only addresses Hash Joins, but lays expression evaluation  
and JIT compilation infrastructure for other hashing needs such as Hash  
Aggregate.  
  
Author: David Rowley  
Reviewed-by: Alexey Dvoichenkov <[email protected]>  
Reviewed-by: Tels <[email protected]>  
Discussion: https://postgr.es/m/CAApHDvoexAxgQFNQD_GRkr2O_eJUD1-wUGm%3Dm0L%2BGc%3DT%3DkEa4g%40mail.gmail.com  

M src/backend/executor/execExpr.c
M src/backend/executor/execExprInterp.c
M src/backend/executor/nodeHash.c
M src/backend/executor/nodeHashjoin.c
M src/backend/jit/llvm/llvmjit_expr.c
M src/include/executor/execExpr.h
M src/include/executor/executor.h
M src/include/executor/hashjoin.h
M src/include/executor/nodeHash.h
M src/include/nodes/execnodes.h

doc: improve create/alter sequence CYCLE syntax

commit   : 9380e5f129d2a160ecc2444f61bb7cb97fd51fbb    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 19 Aug 2024 20:18:03 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 19 Aug 2024 20:18:03 -0400    

Click here for diff

Reported-by: Peter Smith  
  
Discussion: https://postgr.es/m/CAHut+PtqwZwPfGq62xq2614_ce2ejDmbB9CfP+a1azxpneFRBQ@mail.gmail.com  
  
Author: Peter Smith  
  
Backpatch-through: master  

M doc/src/sgml/ref/alter_sequence.sgml
M doc/src/sgml/ref/create_sequence.sgml

doc: mention of postpostgres_fdw INSERT ON CONFLICT limitation

commit   : e28a2719beeab1e3decfbaa81ebe73335e6282b1    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 19 Aug 2024 19:54:39 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 19 Aug 2024 19:54:39 -0400    

Click here for diff

Reported-by: Fujii Masao  
  
Discussion: https://postgr.es/m/[email protected]  
  
Author: Fujii Masao  
  
Backpatch-through: master  

M doc/src/sgml/postgres-fdw.sgml

doc: clarify create database in start docs uses command line

commit   : cf3bb262044a741a47ff40080b145fe432c54407    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 19 Aug 2024 19:22:10 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 19 Aug 2024 19:22:10 -0400    

Click here for diff

Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: master  

M doc/src/sgml/start.sgml

doc: Improve vague pg_createsubscriber description

commit   : 6467993fb552bda7fc1f615d90a66a16583e9998    
  
author   : Bruce Momjian <[email protected]>    
date     : Mon, 19 Aug 2024 18:27:22 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Mon, 19 Aug 2024 18:27:22 -0400    

Click here for diff

Discussion: https://postgr.es/m/[email protected]  
  
Author: Euler Taveira  
  
Backpatch-through: 17  

M doc/src/sgml/ref/pg_createsubscriber.sgml

Avoid failure to open dropped detached partition

commit   : 52f3de874bbeaf16b3ae2efb505c1117be8355cc    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 19 Aug 2024 16:09:10 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 19 Aug 2024 16:09:10 -0400    

Click here for diff

When a partition is detached and immediately dropped, a prepared  
statement could try to compute a new partition descriptor that includes  
it.  This leads to this kind of error:  
ERROR:  could not open relation with OID 457639  
  
Avoid this by skipping the partition in expand_partitioned_rtentry if it  
doesn't exist.  
  
Noted by me while investigating bug #18559.  Kuntal Gosh helped to  
identify the exact failure.  
  
Backpatch to 14, where DETACH CONCURRENTLY was introduced.  
  
Author: Álvaro Herrera <[email protected]>  
Reviewed-by: Kuntal Ghosh <[email protected]>  
Reviewed-by: Junwang Zhao <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/optimizer/util/inherit.c

Document that search_path is reported by the server

commit   : 0d06a7eac4b23cc7b8fd4568d8623a6023646f63    
  
author   : Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 19:46:05 +0200    
  
committer: Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 19:46:05 +0200    

Click here for diff

Commit 28a1121fd912 marked search_path as GUC_REPORT, but failed to  
update the relevant places in docs. There are two places listing the GUC  
options reported to the client, so update both.  
  
Reported-by: Tom Lane  
Discussion: https://postgr.es/m/CAFh8B=k8s7WrcqhafmYhdN1+E5LVzZi_QaYDq8bKvrGJTAhY2Q@mail.gmail.com  

M doc/src/sgml/libpq.sgml
M doc/src/sgml/protocol.sgml

Mark search_path as GUC_REPORT

commit   : 28a1121fd91235e09793c9ce64cb5539719afa30    
  
author   : Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 17:04:09 +0200    
  
committer: Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 17:04:09 +0200    

Click here for diff

Report search_path changes to the client. Multi-tenant applications  
often map tenants to schemas, and use search_path to pick the tenant a  
given connection works with. This breaks when a connection pool (like  
PgBouncer), because the search_path may change unexpectedly.  
  
There are other GUCs we might want reported (e.g. various timeouts), but  
search_path is by far the biggest foot gun that can lead either to  
puzzling failures during query execution (when objects are missing or  
are defined differently), or even to accessing incorrect data.  
  
Many existing tools modify search_path, pg_dump being a notable example.  
  
Ideally, clients could specify which GUCs are interesting and should be  
subject to this reporting, but we don't support that. GUC_REPORT is what  
connection pools rely on for other interesting GUCs, so just use that.  
  
When this change was initially proposed in 2014, one of the concerns was  
impact on performance. But this was addressed by commit 2432b1a04087,  
which ensures we report each GUC at most once per query, no matter how  
many times it changed during execution.  
  
Eventually, this might be replaced / superseded by allowing doing this  
by making the protocol extensible in this direction, but it's unclear  
when (or if) that happens. Until then, we can leverage GUC_REPORT.  
  
Author: Alexander Kukushkin, Jelte Fennema-Nio  
Discussion: https://postgr.es/m/CAFh8B=k8s7WrcqhafmYhdN1+E5LVzZi_QaYDq8bKvrGJTAhY2Q@mail.gmail.com  

M src/backend/utils/misc/guc_tables.c

Explain dropdb can't use syscache because of TOAST

commit   : 5cb902e9d5a99a0e1a2c9098555447e097102e39    
  
author   : Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 13:31:51 +0200    
  
committer: Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 13:31:51 +0200    

Click here for diff

Add a comment explaining dropdb() can't rely on syscache. The issue with  
flattened rows was fixed by commit 0f92b230f88b, but better to have  
a clear explanation why the systable scan is necessary. The other places  
doing in-place updates on pg_database have the same comment.  
  
Suggestion and patch by Yugo Nagata. Backpatch to 12, same as the fix.  
  
Author: Yugo Nagata  
Backpatch-through: 12  
Discussion: https://postgr.es/m/CAJTYsWWNkCt+-UnMhg=BiCD3Mh8c2JdHLofPxsW3m2dkDFw8RA@mail.gmail.com  

M src/backend/commands/dbcommands.c

Fix regression in TLS session ticket disabling

commit   : 4fdb6558c2709c799643d26f3f956395ae72a8ef    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Mon, 19 Aug 2024 12:55:11 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Mon, 19 Aug 2024 12:55:11 +0200    

Click here for diff

Commit 274bbced disabled session tickets for TLSv1.3 on top of the  
already disabled TLSv1.2 session tickets, but accidentally caused  
a regression where TLSv1.2 session tickets were incorrectly sent.  
Fix by unconditionally disabling TLSv1.2 session tickets and only  
disable TLSv1.3 tickets when the right version of OpenSSL is used.  
  
Backpatch to all supported branches.  
  
Reported-by: Cameron Vogt <[email protected]>  
Reported-by: Fire Emerald <[email protected]>  
Reviewed-by: Jacob Champion <[email protected]>  
Discussion: https://postgr.es/m/DM6PR16MB3145CF62857226F350C710D1AB852@DM6PR16MB3145.namprd16.prod.outlook.com  
Backpatch-through: v12  

M src/backend/libpq/be-secure-openssl.c

Fix harmless LC_COLLATE[_MASK] confusion.

commit   : 2724ff381a161eb030a1fcd2a6346679d74db420    
  
author   : Thomas Munro <[email protected]>    
date     : Mon, 19 Aug 2024 21:21:03 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Mon, 19 Aug 2024 21:21:03 +1200    

Click here for diff

Commit ca051d8b101 called newlocale(LC_COLLATE, ...) instead of  
newlocale(LC_COLLATE_MASK, ...), in code reached only on FreeBSD.  They  
have the same value on that OS, explaining why it worked.  Fix.  
  
Back-patch to 14, where ca051d8b101 landed.  

M src/backend/utils/adt/pg_locale.c

Fix garbled process name on backend crash

commit   : 56d23855c864b7384970724f3ad93fb0fc319e51    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 19 Aug 2024 09:48:25 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 19 Aug 2024 09:48:25 +0300    

Click here for diff

The log message on backend crash used wrong variable, which could be  
uninitialized. Introduced in commit 28a520c0b7.  
  
Reported-by: Alexander Lakhin  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/postmaster/postmaster.c

Fix more holes with SLRU code in need of int64 for segment numbers

commit   : bd06cc338d82fd0c56de6421fe5ef143ec79cf6e    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 19 Aug 2024 12:34:18 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 19 Aug 2024 12:34:18 +0900    

Click here for diff

This is a continuation of c9e24573905b, containing changes included into  
the proposed patch that have been missed in the actual commit.  I have  
managed to miss these diffs while doing a rebase of the original patch.  
  
Thanks to Noah Misch, Peter Eisentraut and Alexander Korotkov for the  
pokes.  
  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 17  

M src/backend/access/transam/multixact.c
M src/backend/access/transam/slru.c

Search for SLRU page only in its own bank

commit   : 7b063ff26a5fa87ee59d2f2907d9aade87fcb803    
  
author   : Alvaro Herrera <[email protected]>    
date     : Sun, 18 Aug 2024 20:49:57 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Sun, 18 Aug 2024 20:49:57 -0400    

Click here for diff

One of the two slot scans in SlruSelectLRUPage was not walking only the  
slots in the specific bank where the buffer could be; change it to do  
that.  
  
Oversight in 53c2a97a9266.  
  
Author: Sergey Sargsyan <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/slru.c

injection_points: Add stats for point caching and loading

commit   : 2793acecee340aa9582e0f3efe9ff6cb4b5bdf5a    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 19 Aug 2024 09:03:52 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 19 Aug 2024 09:03:52 +0900    

Click here for diff

This adds two counters to the fixed-numbered stats of injection points  
to track the number of times injection points have been cached and  
loaded from the cache, as of the additions coming from a0a5869a8598 and  
4b211003ecc2.  
  
These should have been part of f68cd847fa40, but I have lacked time and  
energy back then, and it did not prevent the code to be a useful  
template.  
  
While on it, this commit simplifies the description of a few tests while  
adding coverage for the new stats data.  
  
Author: Yogesh Sharma  
Discussion: https://postgr.es/m/[email protected]  

M src/test/modules/injection_points/injection_points–1.0.sql
M src/test/modules/injection_points/injection_points.c
M src/test/modules/injection_points/injection_stats.h
M src/test/modules/injection_points/injection_stats_fixed.c
M src/test/modules/injection_points/t/001_stats.pl

ci: Upgrade MacPorts version to 2.10.1.

commit   : b10528e6cc677e4714d516d2771e5f84485b3146    
  
author   : Thomas Munro <[email protected]>    
date     : Mon, 19 Aug 2024 11:47:37 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Mon, 19 Aug 2024 11:47:37 +1200    

Click here for diff

MacPorts version 2.9.3 started failing in our ci_macports_packages.sh  
script, for reasons not fully determined, but plausibly linked to the  
release of 2.10.1.  2.10.1 seems to work, so let's switch to it.  
  
Back-patch to 15, where CI began.  
  
Reported-by: Peter Eisentraut <[email protected]>  
Discussion: https://postgr.es/m/81f104e8-f0a9-43c0-85bd-2bbbf590a5b8%40eisentraut.org  

M src/tools/ci/ci_macports_packages.sh

doc: Fix typo in section for custom pgstats

commit   : a5f4ff6c806d359b3d2c28cf902047c830acc132    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 19 Aug 2024 07:53:47 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 19 Aug 2024 07:53:47 +0900    

Click here for diff

Per offline report from Erik Rijkers.  

M doc/src/sgml/xfunc.sgml

Fix DROP DATABASE for databases with many ACLs

commit   : 0f92b230f88b98c34b9804c4b4226e0d1822dc53    
  
author   : Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 00:04:41 +0200    
  
committer: Tomas Vondra <[email protected]>    
date     : Mon, 19 Aug 2024 00:04:41 +0200    

Click here for diff

Commit c66a7d75e652 modified DROP DATABASE so that if interrupted, the  
database is known to be in an invalid state and can only be dropped.  
This is done by setting a flag using an in-place update, so that it's  
not lost in case of rollback.  
  
For databases with many ACLs, this may however fail like this:  
  
  ERROR:  wrong tuple length  
  
This happens because with many ACLs, the pg_database.datacl attribute  
gets TOASTed. The dropdb() code reads the tuple from the syscache, which  
means it's detoasted. But the in-place update expects the tuple length  
to match the on-disk tuple.  
  
Fixed by reading the tuple from the catalog directly, not from syscache.  
  
Report and fix by Ayush Tiwari. Backpatch to 12. The DROP DATABASE fix  
was backpatched to 11, but 11 is EOL at this point.  
  
Reported-by: Ayush Tiwari  
Author: Ayush Tiwari  
Reviewed-by: Tomas Vondra  
Backpatch-through: 12  
Discussion: https://postgr.es/m/CAJTYsWWNkCt+-UnMhg=BiCD3Mh8c2JdHLofPxsW3m2dkDFw8RA@mail.gmail.com  

M src/backend/commands/dbcommands.c

Fix cpluspluscheck for pg_verifybackup.h.

commit   : d426718d8d6f42467ab8888d8e7837dcfa452e20    
  
author   : Thomas Munro <[email protected]>    
date     : Mon, 19 Aug 2024 07:59:16 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Mon, 19 Aug 2024 07:59:16 +1200    

Click here for diff

simplehash.h references pg_fatal(), which cpluspluscheck says is  
undeclared, causing the CI CompilerWarnings task to fail since commit  
aa2d6b15.  Include the header it needs.  
  
Discussion: https://postgr.es/m/CA%2BhUKGJC3d4PXkErpfOWrzQqcq6MLiCv0%2BAH0CMQnB6hdLUFEw%40mail.gmail.com  

M src/bin/pg_verifybackup/pg_verifybackup.h

Fix comments on wal_level=minimal, CREATE TABLESPACE and CREATE DATABASE.

commit   : 64740853f07fd1a8314ad68c38298d7e5afe1acc    
  
author   : Noah Misch <[email protected]>    
date     : Sun, 18 Aug 2024 12:03:59 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sun, 18 Aug 2024 12:03:59 -0700    

Click here for diff

Commit 97ddda8a82ac470ae581d0eb485b6577707678bc removed the rmtree()  
behavior from XLOG_TBLSPC_CREATE, obsoleting that part of the comment.  
The comment's point about XLOG_DBASE_CREATE was wrong when commit  
fa0f466d5329e10b16f3b38c8eaf5306f7e234e8 introduced the point.  (It  
would have been accurate if that commit had predated commit  
fbcbc5d06f53aea412130deb52e216aa3883fb8d introducing the second  
checkpoint of CREATE DATABASE.)  Nothing can skip log_smgrcreate() on  
the basis of wal_level=minimal, so don't comment on that.  
  
Commit c6b92041d38512a4176ed76ad06f713d2e6c01a8 expanded WAL skipping  
from five specific operations to relfilenodes generally, hence the  
CreateDatabaseUsingFileCopy() comment change.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/heap/heapam_handler.c
M src/backend/commands/dbcommands.c

docs: fix incorrect plpgsql error message

commit   : 03e9b958eef44046c0092f1f34da4b2de0f9071d    
  
author   : Bruce Momjian <[email protected]>    
date     : Fri, 16 Aug 2024 22:50:54 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Fri, 16 Aug 2024 22:50:54 -0400    

Click here for diff

Change "$1" to "username".  
  
Reported-by: [email protected]  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch-through: 12  

M doc/src/sgml/plpgsql.sgml

C comment: fix for commit b5a9b18cd0b

commit   : 151da217a37d793020f8daeea45c142571c0fbe4    
  
author   : Bruce Momjian <[email protected]>    
date     : Fri, 16 Aug 2024 21:11:55 -0400    
  
committer: Bruce Momjian <[email protected]>    
date     : Fri, 16 Aug 2024 21:11:55 -0400    

Click here for diff

The commit was "Provide API for streaming relation data.".  
  
Reported-by: Nazir Bilal Yavuz  
  
Discussion: https://postgr.es/m/CAN55FZ3KsZ2faZs1sK5J0W+_8B3myB232CfLYGie4u4BBMwP3g@mail.gmail.com  
  
Backpatch-through: master  

M src/backend/storage/aio/read_stream.c

Relocate a badly placed Assert in COPY FROM code

commit   : bd8fe12ef3f727ed3658daf9b26beaf2b891e9bc    
  
author   : David Rowley <[email protected]>    
date     : Sat, 17 Aug 2024 10:36:23 +1200    
  
committer: David Rowley <[email protected]>    
date     : Sat, 17 Aug 2024 10:36:23 +1200    

Click here for diff

There's not much point in asserting a pointer isn't NULL after some code  
has already dereferenced that pointer.  
  
Adjust the code so that the Assert occurs before the pointer dereference.  
  
The Assert probably has questionable value in the first place, but it  
seems worth keeping around to document the contract between  
CopyMultiInsertInfoNextFreeSlot() and its callers.  
  
Author: Amul Sul <[email protected]>  
Discussion: https://postgr.es/m/CAAJ_b94hXQzXaJxTLShkxQUgezf_SUxhzX9TH2f-g6gP7bne7g@mail.gmail.com  

M src/backend/commands/copyfrom.c

Further reduce dependence on -fwrapv semantics in jsonb.

commit   : 1d80d6b50e6401828fc445151375f9bde3f99ac6    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 16 Aug 2024 15:06:40 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 16 Aug 2024 15:06:40 -0500    

Click here for diff

Commit 108d2adb9e missed updating a few places in the jsonb code  
that rely on signed integer wrapping for correctness.  These can  
also be fixed by using pg_abs_s32() to negate a signed integer  
(that is known to be negative) for comparison with an unsigned  
integer.  
  
Reported-by: Alexander Lakhin  
Discussion: https://postgr.es/m/bfff906f-300d-81ea-83b7-f2c93845e7f2%40gmail.com  

M src/backend/utils/adt/jsonfuncs.c

pg_verifybackup: Move some declarations to new pg_verifybackup.h

commit   : aa2d6b15d6d64564cb5b0d1c1e74fb64b29f41f1    
  
author   : Robert Haas <[email protected]>    
date     : Fri, 16 Aug 2024 15:09:42 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Fri, 16 Aug 2024 15:09:42 -0400    

Click here for diff

This is in preparation for adding a second source file to this  
directory.  
  
Amul Sul, reviewed by Sravan Kumar and revised a bit by me.  
  
Discussion: http://postgr.es/m/CAAJ_b95mcGjkfAf1qduOR97CokW8-_i-dWLm3v6x1w2-OW9M+A@mail.gmail.com  

M src/bin/pg_verifybackup/pg_verifybackup.c
A src/bin/pg_verifybackup/pg_verifybackup.h

pg_verifybackup: Move skip_checksums into verifier_context.

commit   : af99d44a889fb1cc2d0dd7d40e2ed8dcd57367da    
  
author   : Robert Haas <[email protected]>    
date     : Fri, 16 Aug 2024 14:52:52 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Fri, 16 Aug 2024 14:52:52 -0400    

Click here for diff

This is in preparation for adding a second source file to this  
directory. It will need access to this value. Also, fewer global  
variables is usually a good thing.  
  
Amul Sul, reviewed by Sravan Kumar and revised a bit by me.  
  
Discussion: http://postgr.es/m/CAAJ_b95mcGjkfAf1qduOR97CokW8-_i-dWLm3v6x1w2-OW9M+A@mail.gmail.com  

M src/bin/pg_verifybackup/pg_verifybackup.c

Improve more comments in astreamer_gzip.c.

commit   : 76dd015e859845fc5fe60557328e3a6bbf11be31    
  
author   : Robert Haas <[email protected]>    
date     : Fri, 16 Aug 2024 13:34:18 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Fri, 16 Aug 2024 13:34:18 -0400    

Click here for diff

Duplicate the comment from astreamer_plain_writer_new instead of just  
referring to it. Add a further note to mention that there are dangers  
if anything else is written to the same FILE. Also add a comment where  
we dup() the filehandle, referring to the existing comment in  
astreamer_gzip_writer_finalize(), because the dup() looks wrong on  
first glance without that comment to clarify.  
  
Per concerns expressed by Tom Lane on pgsql-security, and using  
some wording suggested by him.  
  
Discussion: http://postgr.es/m/CA+TgmoYTFAD0YTh4HC1Nuhn0YEyoQi0_CENFgVzAY_YReiSksQ@mail.gmail.com  

M src/fe_utils/astreamer_gzip.c

libpq: Trace all messages received from the server

commit   : b8b3f861fbd7ff40055225ec48cec97df925ff04    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 16 Aug 2024 13:23:18 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 16 Aug 2024 13:23:18 -0400    

Click here for diff

Not all messages that libpq received from the server would be sent  
through our message tracing logic.  This commit tries to fix that by  
introducing a new function pqParseDone which make it harder to forget  
about doing so.  
  
The messages that we now newly send through our tracing logic are:  
  
- CopyData (received by COPY TO STDOUT)  
- Authentication requests  
- NegotiateProtocolVersion  
- Some ErrorResponse messages during connection startup  
- ReadyForQuery when received after a FunctionCall message  
  
Author: Jelte Fennema-Nio <[email protected]>  
Discussion: https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com  

M src/interfaces/libpq/fe-auth.c
M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/fe-misc.c
M src/interfaces/libpq/fe-protocol3.c
M src/interfaces/libpq/fe-trace.c
M src/interfaces/libpq/libpq-int.h

Fix extraction of week and quarter fields from intervals.

commit   : 6be39d77a70df52d5a0f2eb414ef9901ccf17e5a    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 16 Aug 2024 12:35:50 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 16 Aug 2024 12:35:50 -0400    

Click here for diff

"EXTRACT(WEEK FROM interval_value)" formerly threw an error.  
Define it as "tm->tm_mday / 7".  (With C99 division semantics,  
this gives consistent results for negative intervals.)  
  
"EXTRACT(QUARTER FROM interval_value)" has been implemented  
all along, but it formerly gave extremely strange results for  
negative intervals.  Fix it so that the output for -N months  
is the negative of the output for N months.  
  
Per bug #18348 from Michael Bondarenko and subsequent discussion.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml
M src/backend/utils/adt/timestamp.c
M src/test/regress/expected/interval.out
M src/test/regress/sql/interval.sql

Remove dependence on -fwrapv semantics in jsonb.

commit   : 108d2adb9e9e084cd57bf514d06ef4b954719ffa    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 16 Aug 2024 11:24:44 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 16 Aug 2024 11:24:44 -0500    

Click here for diff

This commit updates a couple of places in the jsonb code to no  
longer rely on signed integer wrapping for correctness.  Like  
commit 9e9a2b7031, this is intended to move us closer towards  
removing -fwrapv, which may enable some compiler optimizations.  
However, there is presently no plan to actually remove that  
compiler option in the near future.  
  
This commit makes use of the newly introduced pg_abs_s32() routine  
to negate a signed integer (that is known to be negative) for  
comparison with an unsigned integer.  In passing, change one use of  
INT_MIN to the more portable PG_INT32_MIN.  
  
Reported-by: Alexander Lakhin  
Author: Joseph Koshakow  
Reviewed-by: Jian He  
Discussion: https://postgr.es/m/CAAvxfHdBPOyEGS7s%2Bxf4iaW0-cgiq25jpYdWBqQqvLtLe_t6tw%40mail.gmail.com  

M src/backend/utils/adt/jsonfuncs.c
M src/test/regress/expected/jsonb.out
M src/test/regress/sql/jsonb.sql

Remove incidental md5() function use from test

commit   : 95b856de23c72bbb46b7c5430fa6897002d2908e    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 16 Aug 2024 17:14:32 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 16 Aug 2024 17:14:32 +0200    

Click here for diff

To allow test to pass in OpenSSL FIPS mode, similar to 657f5f223e, for  
a new test that has been added since.  
  
Reviewed-by: Tomas Vondra <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M contrib/pageinspect/expected/brin.out
M contrib/pageinspect/sql/brin.sql

Relax fsyncing at end of a bulk load that was not WAL-logged

commit   : 077ad4bd76b12cd4144e40ef5fba3f49528fa5e4    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 16 Aug 2024 14:45:37 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 16 Aug 2024 14:45:37 +0300    

Click here for diff

And improve the comments.  
  
Backpatch to v17 where this was introduced.  
  
Reviewed-by: Noah Misch  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/storage/smgr/bulk_write.c

Refactor CopyOneRowTo

commit   : 3943da46bc54006ec4849bc7541cf4e674b700eb    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 16 Aug 2024 13:48:10 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 16 Aug 2024 13:48:10 +0300    

Click here for diff

The handling of binary and text formats are quite different here, so  
it's more clear to check for the format first and have two separate  
loops.  
  
Author: jian he <[email protected]>  
Reviewed-by: Ilia Evdokimov, Junwang Zhao  
Discussion: https://www.postgresql.org/message-id/CACJufxFzHCeFBQF0M%[email protected]  

M src/backend/commands/copyto.c

Remove unused 'cur_skey' argument from IndexScanOK()

commit   : 1153422edac5d27eeffd61fca2be348fa0714ce9    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 16 Aug 2024 13:13:43 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 16 Aug 2024 13:13:43 +0300    

Click here for diff

Commit a78fcfb51243 removed the last use of it.  
  
Author: Hugo Zhang, Aleksander Alekseev  
Reviewed-by: Daniel Gustafsson  
Discussion: https://www.postgresql.org/message-id/NT0PR01MB129459E243721B954611938F9CDD2%40NT0PR01MB1294.CHNPR01.prod.partner.outlook.cn  

M src/backend/utils/cache/catcache.c

libpq: Fix minor TOCTOU violation

commit   : e882bcae032d5e89777e2a1f3d78dfb77c17c192    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 16 Aug 2024 06:41:17 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 16 Aug 2024 06:41:17 +0200    

Click here for diff

libpq checks the permissions of the password file before opening it.  
The way this is done in two separate operations, a static analyzer  
would flag as a time-of-check-time-of-use violation.  In practice, you  
can't do anything with that, but it still seems better style to fix  
it.  
  
To fix it, open the file first and then check the permissions on the  
opened file handle.  
  
Reviewed-by: Aleksander Alekseev <[email protected]>  
Reviewed-by: Andreas Karlsson <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/a3356054-14ae-4e7a-acc6-249d19dac20b%40eisentraut.org  

M src/interfaces/libpq/fe-connect.c

Add missing wait_for_catchup() to pg_visibility tap test

commit   : e3ec9dc1bf4983fcedb6f43c71ea12ee26aefc7a    
  
author   : Alexander Korotkov <[email protected]>    
date     : Fri, 16 Aug 2024 00:58:32 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Fri, 16 Aug 2024 00:58:32 +0300    

Click here for diff

e2ed7e32271a introduced check of pg_visibility on standby.  This commit adds  
missing wait_for_catchup() to synchronize standby before querying it.  

M contrib/pg_visibility/t/001_concurrent_transaction.pl

Fix GetStrictOldestNonRemovableTransactionId() on standby

commit   : e2ed7e32271a82179c3f8c7c93ce52ff93c6dd3c    
  
author   : Alexander Korotkov <[email protected]>    
date     : Fri, 16 Aug 2024 00:17:59 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Fri, 16 Aug 2024 00:17:59 +0300    

Click here for diff

e85662df44 implemented GetStrictOldestNonRemovableTransactionId() function  
for computation of xid horizon that avoid reporting of false errors.  
However, GetStrictOldestNonRemovableTransactionId() uses  
GetRunningTransactionData() even on standby leading to an assertion failure.  
  
Given that we decided to ignore KnownAssignedXids and standby can't have  
own running xids, we switch to use TransamVariables->nextXid as a xid horizon.  
  
Also, revise the comment regarding ignoring KnownAssignedXids with more  
detailed reasoning provided by Heikki.  
  
Reported-by: Heikki Linnakangas  
Discussion: https://postgr.es/m/42218c4f-2c8d-40a3-8743-4d34dd0e4cce%40iki.fi  
Reviewed-by: Heikki Linnakangas  

M contrib/pg_visibility/pg_visibility.c
M contrib/pg_visibility/t/001_concurrent_transaction.pl

Remove dependence on -fwrapv semantics in a few places.

commit   : 9e9a2b7031f64e49fcaf28f21a4e70eb1212165f    
  
author   : Nathan Bossart <[email protected]>    
date     : Thu, 15 Aug 2024 15:47:31 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Thu, 15 Aug 2024 15:47:31 -0500    

Click here for diff

This commit attempts to update a few places, such as the money,  
numeric, and timestamp types, to no longer rely on signed integer  
wrapping for correctness.  This is intended to move us closer  
towards removing -fwrapv, which may enable some compiler  
optimizations.  However, there is presently no plan to actually  
remove that compiler option in the near future.  
  
Besides using some of the existing overflow-aware routines in  
int.h, this commit introduces and makes use of some new ones.  
Specifically, it adds functions that accept a signed integer and  
return its absolute value as an unsigned integer with the same  
width (e.g., pg_abs_s64()).  It also adds functions that accept an  
unsigned integer, store the result of negating that integer in a  
signed integer with the same width, and return whether the negation  
overflowed (e.g., pg_neg_u64_overflow()).  
  
Finally, this commit adds a couple of tests for timestamps near  
POSTGRES_EPOCH_JDATE.  
  
Author: Joseph Koshakow  
Reviewed-by: Tom Lane, Heikki Linnakangas, Jian He  
Discussion: https://postgr.es/m/CAAvxfHdBPOyEGS7s%2Bxf4iaW0-cgiq25jpYdWBqQqvLtLe_t6tw%40mail.gmail.com  

M src/backend/utils/adt/cash.c
M src/backend/utils/adt/numeric.c
M src/backend/utils/adt/numutils.c
M src/backend/utils/adt/timestamp.c
M src/include/common/int.h
M src/interfaces/ecpg/pgtypeslib/timestamp.c
M src/test/regress/expected/timestamp.out
M src/test/regress/expected/timestamptz.out
M src/test/regress/sql/timestamp.sql
M src/test/regress/sql/timestamptz.sql

Add 97add39c0 to .git-blame-ignore-revs.

commit   : ad89d71978429c61647ae57174a61deb192bd51c    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 15 Aug 2024 11:43:55 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 15 Aug 2024 11:43:55 -0400    

Click here for diff

M .git-blame-ignore-revs

Clean up indentation and whitespace inconsistencies in ecpg.

commit   : 97add39c038bbdb9082b416ddf04cd20b0d20bf5    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 15 Aug 2024 11:41:46 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 15 Aug 2024 11:41:46 -0400    

Click here for diff

ecpg's lexer and parser files aren't normally processed by  
pgindent, and unsurprisingly there's a lot of code in there  
that doesn't really match project style.  I spent some time  
running pgindent over the fragments of these files that are  
C code, and this is the result.  This is in the same spirit  
as commit 30ed71e42, though apparently Peter used a different  
method for that one, since it didn't find these problems.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/interfaces/ecpg/preproc/ecpg.addons
M src/interfaces/ecpg/preproc/ecpg.header
M src/interfaces/ecpg/preproc/ecpg.trailer
M src/interfaces/ecpg/preproc/pgc.l

Do not hardcode PG_PROTOCOL_LATEST in NegotiateProtocolVersion

commit   : 516b87502dc1f99adb5126aa70cc796d53648c92    
  
author   : Robert Haas <[email protected]>    
date     : Thu, 15 Aug 2024 10:44:15 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Thu, 15 Aug 2024 10:44:15 -0400    

Click here for diff

We shouldn't ask the client to use a protocol version later than the  
one that they requested. To avoid that, if the client requests a  
version newer than the latest one we support, set FrontendProtocol  
to the latest version we support, not the requested version. Then,  
use that value when building the NegotiateProtocolVersion message.  
(It seems good on general principle to avoid setting FrontendProtocol  
to a version we don't support, anyway.)  
  
None of this really matters right now, because we only support a  
single protocol version, but if that ever changes, we'll need this.  
  
Jelte Fennema-Nio, reviewed by me and incorporating some of my  
proposed wording  
  
Discussion: https://postgr.es/m/CAGECzQTyXDNtMXdq2L-Wp=OvOCPa07r6+U_MGb==h90MrfT+fQ@mail.gmail.com  

M src/backend/tcop/backend_startup.c

Optimise numeric multiplication using base-NBASE^2 arithmetic.

commit   : 8dc28d7eb868b6ce5a51614628bf46fc63c7e90c    
  
author   : Dean Rasheed <[email protected]>    
date     : Thu, 15 Aug 2024 10:36:17 +0100    
  
committer: Dean Rasheed <[email protected]>    
date     : Thu, 15 Aug 2024 10:36:17 +0100    

Click here for diff

Currently mul_var() uses the schoolbook multiplication algorithm,  
which is O(n^2) in the number of NBASE digits. To improve performance  
for large inputs, convert the inputs to base NBASE^2 before  
multiplying, which effectively halves the number of digits in each  
input, theoretically speeding up the computation by a factor of 4. In  
practice, the actual speedup for large inputs varies between around 3  
and 6 times, depending on the system and compiler used. In turn, this  
significantly reduces the runtime of the numeric_big regression test.  
  
For this to work, 64-bit integers are required for the products of  
base-NBASE^2 digits, so this works best on 64-bit machines, on which  
it is faster whenever the shorter input has more than 4 or 5 NBASE  
digits. On 32-bit machines, the additional overheads, especially  
during carry propagation and the final conversion back to base-NBASE,  
are significantly higher, and it is only faster when the shorter input  
has more than around 50 NBASE digits. When the shorter input has more  
than 6 NBASE digits (so that mul_var_short() cannot be used), but  
fewer than around 50 NBASE digits, there may be a noticeable slowdown  
on 32-bit machines. That seems to be an acceptable tradeoff, given the  
performance gains for other inputs, and the effort that would be  
required to maintain code specifically targeting 32-bit machines.  
  
Joel Jacobson and Dean Rasheed.  
  
Discussion: https://postgr.es/m/9d8a4a42-c354-41f3-bbf3-199e1957db97%40app.fastmail.com  

M src/backend/utils/adt/numeric.c

Extend mul_var_short() to 5 and 6-digit inputs.

commit   : c4e44224cf617c8cd33a734f888c045ac9575226    
  
author   : Dean Rasheed <[email protected]>    
date     : Thu, 15 Aug 2024 10:33:12 +0100    
  
committer: Dean Rasheed <[email protected]>    
date     : Thu, 15 Aug 2024 10:33:12 +0100    

Click here for diff

Commit ca481d3c9a introduced mul_var_short(), which is used by  
mul_var() whenever the shorter input has 1-4 NBASE digits and the  
exact product is requested. As speculated on in that commit, it can be  
extended to work for more digits in the shorter input. This commit  
extends it up to 6 NBASE digits (up to 24 decimal digits), for which  
it also gives a significant speedup. This covers more cases likely to  
occur in real-world queries, for which using base-NBASE^2 arithmetic  
provides little benefit.  
  
To avoid code bloat and duplication, refactor it a bit using macros  
and exploiting the fact that some portions of the code are shared  
between the different cases.  
  
Dean Rasheed, reviewed by Joel Jacobson.  
  
Discussion: https://postgr.es/m/9d8a4a42-c354-41f3-bbf3-199e1957db97%40app.fastmail.com  

M src/backend/utils/adt/numeric.c

Variable renaming in dbcommands.c

commit   : fce7cb6da09b56462fc734e789348376848caf4c    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 15 Aug 2024 07:08:12 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 15 Aug 2024 07:08:12 +0200    

Click here for diff

There were several sets of very similar local variable names, such as  
"downer" and "dbowner", which was very confusing and error-prone.  
Rename the former to "ownerEl" and so on, similar to collationcmds.c  
and typecmds.c.  
  
Reviewed-by: Daniel Gustafsson <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/e5bce225-ee04-40c7-a280-ea7214318048%40eisentraut.org  

M src/backend/commands/dbcommands.c

Fix doc typo: unicode_assigned() return type.

commit   : a3c6aa42ee0d625a55e73e17230db3eaeed3566c    
  
author   : Jeff Davis <[email protected]>    
date     : Wed, 14 Aug 2024 19:05:39 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Wed, 14 Aug 2024 19:05:39 -0700    

Click here for diff

Reported-by: Hironobu SUZUKI  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 17  

M doc/src/sgml/func.sgml

Improve ALTER PUBLICATION validation and error messages

commit   : 80ffcb842748f0b8ccf8b24c5c3b2500755d2dcd    
  
author   : David Rowley <[email protected]>    
date     : Thu, 15 Aug 2024 13:10:25 +1200    
  
committer: David Rowley <[email protected]>    
date     : Thu, 15 Aug 2024 13:10:25 +1200    

Click here for diff

Attempting to add a system column for a table to an existing publication  
would result in the not very intuitive error message of:  
  
ERROR:  negative bitmapset member not allowed  
  
Here we improve that to have it display the same error message as a user  
would see if they tried adding a system column for a table when adding  
it to the publication in the first place.  
  
Doing this requires making the function which validates the list of  
columns an extern function.  The signature of the static function wasn't  
an ideal external API as it made the code more complex than it needed to be.  
Here we adjust the function to have it populate a Bitmapset of attribute  
numbers.  Doing it this way allows code simplification.  
  
There was no particular bug here other than the weird error message, so  
no backpatch.  
  
Bug: #18558  
Reported-by: Alexander Lakhin <[email protected]>  
Author: Peter Smith, David Rowley  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/catalog/pg_publication.c
M src/backend/commands/publicationcmds.c
M src/backend/commands/subscriptioncmds.c
M src/include/catalog/pg_publication.h
M src/test/regress/expected/publication.out
M src/test/regress/sql/publication.sql

Add a couple of recent commits to .git-blame-ignore-revs.

commit   : ef6e028f05b3e4ab23c5edfdfff457e0d2a649f6    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 14 Aug 2024 14:25:54 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 14 Aug 2024 14:25:54 -0500    

Click here for diff

M .git-blame-ignore-revs

libpq: Trace responses to SSLRequest and GSSENCRequest

commit   : a5c6b8f22c206aaa22fc9a826f858a262a023cd5    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 14 Aug 2024 14:53:55 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 14 Aug 2024 14:53:55 -0400    

Click here for diff

Since these are single bytes instead of v2 or v3 messages they need  
custom tracing logic.  These "messages" don't even have official names  
in the protocol specification, so I (Jelte) called them SSLResponse and  
GSSENCResponse here.  
  
Author: Jelte Fennema-Nio <[email protected]>  
Discussion: https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com  

M src/interfaces/libpq/fe-connect.c
M src/interfaces/libpq/fe-trace.c
M src/interfaces/libpq/libpq-int.h

Apply PGDLLIMPORT markings to some GUC variables

commit   : 5304fec4d8a141abe6f8f6f2a6862822ec1f3598    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 14 Aug 2024 11:36:12 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 14 Aug 2024 11:36:12 +0200    

Click here for diff

According to the commit message in 8ec569479, we must have all variables  
in header files marked with PGDLLIMPORT. In commit d3cc5ffe81f6 some  
variables were moved from launch_backend.c file to several header files.  
  
This adds PGDLLIMPORT to moved variables.  
  
Author: Sofia Kopikova <[email protected]>  
Reviewed-by: Robert Haas <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/e0b17014-5319-4dd6-91cd-93d9c8fc9539%40postgrespro.ru  

M src/include/postmaster/syslogger.h
M src/include/storage/pmsignal.h
M src/include/storage/proc.h
M src/include/storage/procsignal.h
M src/include/utils/guc.h

Remove TRACE_SORT macro

commit   : c8e2d422fd556292ab751392bf76f713fe9e9fc1    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 14 Aug 2024 08:02:32 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 14 Aug 2024 08:02:32 +0200    

Click here for diff

The TRACE_SORT macro guarded the availability of the trace_sort GUC  
setting.  But it has been enabled by default ever since it was  
introduced in PostgreSQL 8.1, and there have been no reports that  
someone wanted to disable it.  So just remove the macro to simplify  
things.  (For the avoidance of doubt: The trace_sort GUC is still  
there.  This only removes the rarely-used macro guarding it.)  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/be5f7162-7c1d-44e3-9a78-74dcaa6529f2%40eisentraut.org  

M doc/src/sgml/config.sgml
M src/backend/utils/adt/mac.c
M src/backend/utils/adt/network.c
M src/backend/utils/adt/numeric.c
M src/backend/utils/adt/uuid.c
M src/backend/utils/adt/varlena.c
M src/backend/utils/misc/guc_tables.c
M src/backend/utils/sort/tuplesort.c
M src/backend/utils/sort/tuplesortvariants.c
M src/include/pg_config_manual.h
M src/include/utils/guc.h

Harmonize MinGW CODESET lookup with MSVC.

commit   : bf3401fe813ad3b6b34e5e9daf8fbd03540a2294    
  
author   : Thomas Munro <[email protected]>    
date     : Wed, 14 Aug 2024 15:02:12 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Wed, 14 Aug 2024 15:02:12 +1200    

Click here for diff

Historically, MinGW environments lacked some Windows API calls, so we  
took a different code path in win32_langinfo().  Somehow, the code  
change in commit 35eeea62 (removing setlocale() calls) caused one  
particular 001_initdb.pl test to fail on MinGW + ICU builds, because  
pg_import_system_collations() found no collations.  It might take a  
MinGW user to discover the exact reason.  
  
Updating that function to use the same code as MSVC seems to fix that  
test, so lets do that.  (There are plenty more places that test for MSVC  
unnecessarily, to be investigated later.)  
  
While here, also rename the helper function win32_langinfo() to  
win32_get_codeset(), to explain what it does less confusingly; it's not  
really a general langinfo() substitute.  
  
Noticed by triggering the optional MinGW CI task; no build farm animals  
failed.  
  
Discussion: https://postgr.es/m/CA%2BhUKGKBWfhXQ3J%2B2Lj5PhKvQnGD%3DsywA0XQcb7boTCf%3DerVLg%40mail.gmail.com  

M src/port/chklocale.c

Add resource statistics reporting to ANALYZE VERBOSE.

commit   : 4c1b4cdb86a7a3a97349bb636f34a259abe0187d    
  
author   : Masahiko Sawada <[email protected]>    
date     : Tue, 13 Aug 2024 19:23:56 -0700    
  
committer: Masahiko Sawada <[email protected]>    
date     : Tue, 13 Aug 2024 19:23:56 -0700    

Click here for diff

Previously, log_autovacuum_min_duration utilized dedicated code for  
logging resource statistics, such as system and buffer usage during  
autoanalyze. However, this logging functionality was not utilized by  
ANALYZE VERBOSE.  
  
This commit adds resource statistics reporting to ANALYZE VERBOSE by  
reusing the same logging code as autoanalyze.  
  
Author: Anthonin Bonnefoy  
Reviewed-by: Masahiko Sawada  
Discussion: https://postgr.es/m/CAO6_Xqr__kTTCLkftqS0qSCm-J7_xbRG3Ge2rWhucxQJMJhcRA%40mail.gmail.com  

M src/backend/commands/analyze.c

Use pgBufferUsage for buffer usage tracking in analyze.

commit   : c584781bcc686ebc0b3139e3e166607537336f69    
  
author   : Masahiko Sawada <[email protected]>    
date     : Tue, 13 Aug 2024 18:49:45 -0700    
  
committer: Masahiko Sawada <[email protected]>    
date     : Tue, 13 Aug 2024 18:49:45 -0700    

Click here for diff

Previously, (auto)analyze used global variables VacuumPageHit,  
VacuumPageMiss, and VacuumPageDirty to track buffer usage. However,  
pgBufferUsage provides a more generic way to track buffer usage with  
support functions.  
  
This change replaces those global variables with pgBufferUsage in  
analyze. Since analyze was the sole user of those variables, it  
removes their declarations. Vacuum previously used those variables but  
replaced them with pgBufferUsage as part of a bug fix, commit  
5cd72cc0c.  
  
Additionally, it adjusts the buffer usage message in both vacuum and  
analyze for better consistency.  
  
Author: Anthonin Bonnefoy  
Reviewed-by: Masahiko Sawada, Michael Paquier  
Discussion: https://postgr.es/m/CAO6_Xqr__kTTCLkftqS0qSCm-J7_xbRG3Ge2rWhucxQJMJhcRA%40mail.gmail.com  

M src/backend/access/heap/vacuumlazy.c
M src/backend/commands/analyze.c
M src/backend/commands/vacuum.c
M src/backend/commands/vacuumparallel.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/utils/init/globals.c
M src/include/miscadmin.h

Include <xlocale.h> for macOS, take II.

commit   : 2488058dc356a43455b21a099ea879fff9266634    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 13 Aug 2024 23:42:58 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 13 Aug 2024 23:42:58 +1200    

Click here for diff

Fix typo in macro name.  
  
Discussion: https://postgr.es/m/CA%2BhUKG%2Bk-o3N_SyNJNJpAcdtMo_HheN30miAeXehk9yw%3D9WYzA%40mail.gmail.com  

M src/port/chklocale.c

Include <xlocale.h> for older macOS.

commit   : 52ea7f0e0545e8b7e5f28cceddadbfb184f41a4f    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 13 Aug 2024 23:02:05 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 13 Aug 2024 23:02:05 +1200    

Click here for diff

Commit 35eeea62 forgot to include <xlocale.h> when using locale_t  
(which didn't seem to be required on newer Apple SDK as used by CI,  
hence mistake).  Let's see if this fixes build farm animals longfin and  
sifika.  

M src/port/chklocale.c

Use thread-safe nl_langinfo_l(), not nl_langinfo().

commit   : 35eeea62302260ec07fd11b287e488768d4543e2    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 13 Aug 2024 22:27:16 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 13 Aug 2024 22:27:16 +1200    

Click here for diff

This gets rid of some setlocale() calls.  The remaining call to  
setlocale() in pg_get_encoding_from_locale() is a query of the name  
of the current locale when none was provided (in a multi-threaded future  
that would need more work).  
  
All known non-Windows targets have nl_langinfo_l(), from POSIX 2008, and  
for Windows we already do something thread-safe.  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Discussion: https://postgr.es/m/CA%2BhUKGJqVe0%2BPv9dvC9dSums_PXxGo9SWcxYAMBguWJUGbWz-A%40mail.gmail.com  

M src/port/chklocale.c

All POSIX systems have langinfo.h and CODESET.

commit   : 14c648ff009438830d15de7c8a93c2b29114eb1c    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 13 Aug 2024 22:13:52 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 13 Aug 2024 22:13:52 +1200    

Click here for diff

We don't need configure probes for HAVE_LANGINFO_H (it is implied by  
!WIN32), and we don't need to consider systems that have it but don't  
define CODESET (that was for OpenBSD in commit 81cca218, but it has now  
had it for 19 years).  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Discussion: https://postgr.es/m/CA%2BhUKGJqVe0%2BPv9dvC9dSums_PXxGo9SWcxYAMBguWJUGbWz-A%40mail.gmail.com  

M configure
M configure.ac
M meson.build
M src/bin/pg_upgrade/pg_upgrade.c
M src/include/pg_config.h.in
M src/port/chklocale.c

Use errmsg_internal for debug messages

commit   : 93660d1c27b1b85e84621326c0e2c89e00c3fc6f    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 13 Aug 2024 10:01:49 +0200