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    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 13 Aug 2024 10:01:49 +0200    

Click here for diff

Some newer code was applying this inconsistently.  

M src/backend/postmaster/walsummarizer.c

Rename C23 keyword

commit   : a67a49648d98162e3fca7e502408def0755e487f    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 13 Aug 2024 06:15:28 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 13 Aug 2024 06:15:28 +0200    

Click here for diff

constexpr is a keyword in C23.  Rename a conflicting identifier for  
future-proofing.  
  
Reviewed-by: Robert Haas <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/08abc832-1384-4aca-a535-1a79765b565e%40eisentraut.org  

M src/backend/optimizer/util/predtest.c

libpq: Trace frontend authentication challenges

commit   : ea92f3a0a5ad756600d94078a5d629c072ff61dd    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 12 Aug 2024 19:12:54 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 12 Aug 2024 19:12:54 -0400    

Click here for diff

If tracing was enabled during connection startup, these messages would  
previously be listed in the trace output as something like this:  
  
F	54	Unknown message: 70  
mismatched message length: consumed 4, expected 54  
  
With this commit their type and contents are now correctly listed:  
  
F	36	StartupMessage	 3 0 "user" "foo" "database" "alvherre"  
F	54	SASLInitialResponse	 "SCRAM-SHA-256" 32 'n,,n=,r=nq5zEPR/VREHEpOAZzH8Rujm'  
F	108	SASLResponse	 'c=biws,r=nq5zEPR/VREHEpOAZzH8RujmVtWZDQ8glcrvy9OMNw7ZqFUn,p=BBwAKe0WjSvigB6RsmmArAC+hwucLeuwJrR5C/HQD5M='  
  
Author: Jelte Fennema-Nio <[email protected]>  
Reviewed-by: Michael Paquier <[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-trace.c
M src/interfaces/libpq/libpq-int.h

Fix nls.mk to reflect astreamer files relocation

commit   : 12d6c727ca6988462651c525e197601c4c0f8745    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 12 Aug 2024 18:42:18 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 12 Aug 2024 18:42:18 -0400    

Click here for diff

In the recent commit f80b09bac8, astreamer files were moved to another  
directory, but this change was not reflected in nls.mk.  This commit  
corrects that oversight.  
  
Author: Kyotaro Horiguchi <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_basebackup/nls.mk

Fix creation of partition descriptor during concurrent detach+drop

commit   : c899c6839f5de596a316da7fb94e4f917a242b04    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 12 Aug 2024 18:17:56 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 12 Aug 2024 18:17:56 -0400    

Click here for diff

If a partition undergoes DETACH CONCURRENTLY immediately followed by  
DROP, this could cause a problem for a concurrent transaction  
recomputing the partition descriptor when running a prepared statement,  
because it tries to dereference a pointer to a tuple that's not found in  
a catalog scan.  
  
The existing retry logic added in commit dbca3469ebf8 is sufficient to  
cope with the overall problem, provided we don't try to dereference a  
non-existant heap tuple.  
  
Arguably, the code in RelationBuildPartitionDesc() has been wrong all  
along, since no check was added in commit 898e5e3290a7 against receiving  
a NULL tuple from the catalog scan; that bug has only become  
user-visible with DETACH CONCURRENTLY which was added in branch 14.  
Therefore, even though there's no known mechanism to cause a crash  
because of this, backpatch the addition of such a check to all supported  
branches.  In branches prior to 14, this would cause the code to fail  
with a "missing relpartbound for relation XYZ" error instead of  
crashing; that's okay, because there are no reports of such behavior  
anyway.  
  
Author: Kuntal Ghosh <[email protected]>  
Reviewed-by: Junwang Zhao <[email protected]>  
Reviewed-by: Tender Wang <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/partitioning/partdesc.c

Remove unnecessary check for NULL locale, per Coverity.

commit   : a459ac504cc62421c08c9ee1ddc3e6f9be61f384    
  
author   : Jeff Davis <[email protected]>    
date     : Mon, 12 Aug 2024 12:26:23 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Mon, 12 Aug 2024 12:26:23 -0700    

Click here for diff

Discussion: https://postgr.es/m/[email protected]  
Reported-by: Tom Lane  

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

Give nbtree move right function internal linkage.

commit   : 1343ae954ceaf591d6b4271f2b0a93390d56501d    
  
author   : Peter Geoghegan <[email protected]>    
date     : Mon, 12 Aug 2024 14:36:55 -0400    
  
committer: Peter Geoghegan <[email protected]>    
date     : Mon, 12 Aug 2024 14:36:55 -0400    

Click here for diff

Declare _bt_moveright() static.  This is a minor modularity win; the  
routine was already private to nbtsearch.c for all practical purposes.  
  
Author: Matthias van de Meent <[email protected]>  
Discussion: https://postgr.es/m/CAEze2WgWVzCNEXQB_op5MMZMDgJ3fg3AhVm6bq2iZPpJNXGhWw@mail.gmail.com  

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

Log more info when wait-for-catchup tests time out.

commit   : 2aecbd752616aa664f32b3c1804732e475def7cc    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 12 Aug 2024 13:18:36 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 12 Aug 2024 13:18:36 -0400    

Click here for diff

Cluster.pm's wait_for_catchup and allied subroutines don't provide  
enough information to diagnose the problem when a wait times out.  
In hopes of debugging some intermittent buildfarm failures, let's  
dump the ending state of the relevant system view when that happens.  
  
Add this to v17 too, but not stable branches.  
  
Discussion: https://postgr.es/m/[email protected]  

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

Add user-callable CRC functions.

commit   : 760162fedb4f7ee6f0167cc6acfadee6ccb6be66    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 12 Aug 2024 10:35:06 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 12 Aug 2024 10:35:06 -0500    

Click here for diff

We've had code for CRC-32 and CRC-32C for some time (for WAL  
records, etc.), but there was no way for users to call it, despite  
apparent popular demand.  The new crc32() and crc32c() functions  
accept bytea input and return bigint (to avoid returning negative  
values).  
  
Bumps catversion.  
  
Author: Aleksander Alekseev  
Reviewed-by: Peter Eisentraut, Tom Lane  
Discussion: https://postgr.es/m/CAJ7c6TNMTGnqnG%3DyXXUQh9E88JDckmR45H2Q%2B%3DucaCLMOW1QQw%40mail.gmail.com  

M doc/src/sgml/func.sgml
M src/backend/utils/hash/pg_crc.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/opr_sanity.out
M src/test/regress/expected/strings.out
M src/test/regress/sql/strings.sql

Fix outdated comments

commit   : 313df8f5adde186b0052d7d634a6d0ae41852de0    
  
author   : David Rowley <[email protected]>    
date     : Mon, 12 Aug 2024 23:41:13 +1200    
  
committer: David Rowley <[email protected]>    
date     : Mon, 12 Aug 2024 23:41:13 +1200    

Click here for diff

A few fields in ResultRelInfo are now also used for MERGE.  Update the  
comments to mention that.  
  
Reported-by: jian he <[email protected]>  
Discussion: https://postgr.es/m/CACJufxH8-NvFhLcSZZTTW+1M9AfS4+SOTKmyPG7ZhzNvN=+NkA@mail.gmail.com:wq  

M src/include/nodes/execnodes.h

Fix a series of typos and outdated references

commit   : ffabb56c9460b8e2a3fffeea6263a61590ba006d    
  
author   : David Rowley <[email protected]>    
date     : Mon, 12 Aug 2024 23:27:09 +1200    
  
committer: David Rowley <[email protected]>    
date     : Mon, 12 Aug 2024 23:27:09 +1200    

Click here for diff

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

M src/backend/access/transam/xlogreader.c
M src/backend/executor/execCurrent.c
M src/backend/utils/activity/pgstat_shmem.c
M src/include/access/sdir.h
M src/include/access/xlogreader.h
M src/test/modules/worker_spi/worker_spi.c

Fix bad indentation introduced in commit f011e82c2c

commit   : 8de5ca1dc9fa809102acd1983ee19159d0bc469f    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 12 Aug 2024 10:57:03 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 12 Aug 2024 10:57:03 +0300    

Click here for diff

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

Consolidate postmaster code to launch background processes

commit   : 3354f85284dc5439c25b57e002e62a88490aca1e    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 12 Aug 2024 10:04:26 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 12 Aug 2024 10:04:26 +0300    

Click here for diff

Much of the code in process_pm_child_exit() to launch replacement  
processes when one exits or when progressing to next postmaster state  
was unnecessary, because the ServerLoop will launch any missing  
background processes anyway. Remove the redundant code and let  
ServerLoop handle it.  
  
In ServerLoop, move the code to launch all the processes to a new  
subroutine, to group it all together.  
  
Reviewed-by: Thomas Munro <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/postmaster/postmaster.c

Remove dead code

commit   : 4eb5089e26848ecb71f9e15086e4064597108564    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 12 Aug 2024 08:43:47 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 12 Aug 2024 08:43:47 +0200    

Click here for diff

After e9931bfb751, the locale argument of SB_lower_char() is never  
NULL, so the branch that deals with NULL can be removed (similar to  
how e9931bfb751 for example removed those branches in str_tolower()).  
  
Reviewed-by: Jeff Davis <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

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

Remove fe_memutils from libpgcommon_shlib

commit   : f1976df5eaf277f6f761306ce06ae32141438096    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 12 Aug 2024 08:30:39 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 12 Aug 2024 08:30:39 +0200    

Click here for diff

libpq must not use palloc/pfree. It's not allowed to exit on allocation  
failure, and mixing the frontend pfree with malloc is architecturally  
unsound.  
  
Remove fe_memutils from the shlib build entirely, to keep devs from  
accidentally depending on it in the future.  
  
Author: Jacob Champion <[email protected]>  
Discussion: https://www.postgresql.org/message-id/CAOYmi+=pg=W5L1h=3MEP_EB24jaBu2FyATrLXqQHGe7cpuvwyg@mail.gmail.com  

M src/common/Makefile
M src/common/meson.build

Remove support for old realpath() API

commit   : 94980c45674fc2d1125f3ba7ce0bb5d34f770e00    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 12 Aug 2024 07:59:40 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 12 Aug 2024 07:59:40 +0200    

Click here for diff

The now preferred way to call realpath() is by passing NULL as the  
second argument and get a malloc'ed result.  We still supported the  
old way of providing our own buffer as a second argument, for some  
platforms that didn't support the new way yet.  Those were only  
Solaris less than version 11 and some older AIX versions (7.1 and  
newer appear to support the new variant).  We don't support those  
platforms versions anymore, so we can remove this extra code.  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/9e638b49-5c3f-470f-a392-2cbedb2f7855%40eisentraut.org  

M src/common/exec.c

Remove "parent" column from pg_backend_memory_contexts

commit   : f0d11275954719fd5d0281d4135e5c78de46e099    
  
author   : David Rowley <[email protected]>    
date     : Mon, 12 Aug 2024 15:42:16 +1200    
  
committer: David Rowley <[email protected]>    
date     : Mon, 12 Aug 2024 15:42:16 +1200    

Click here for diff

32d3ed816 added the "path" column to pg_backend_memory_contexts to allow  
a stable method of obtaining the parent MemoryContext of a given row in  
the view.  Using the "path" column is now the preferred method of  
obtaining the parent row.  
  
Previously, any queries which were self-joining to this view using the  
"name" and "parent" columns could get incorrect results due to the fact  
that names are not unique.  Here we aim to explicitly break such queries  
so that they can be corrected and use the "path" column instead.  
  
It is possible that there are more innocent users of the parent column  
that just need an indication of the parent and having to write out a  
self-joining CTE may be an unnecessary hassle for those cases.  Let's  
remove the column for now and see if anyone comes back with any  
complaints.  This does seem like a good time to attempt to get rid of  
the column as we still have around 1 year to revert this if someone comes  
back with a valid complaint.  Plus this view is new to v14 and is quite  
niche, so perhaps not many people will be affected.  
  
Author: Melih Mutlu <[email protected]>  
Discussion: https://postgr.es/m/CAGPVpCT7NOe4fZXRL8XaoxHpSXYTu6GTpULT_3E-HT9hzjoFRA@mail.gmail.com  

M doc/src/sgml/system-views.sgml
M src/backend/utils/adt/mcxtfuncs.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/rules.out
M src/test/regress/expected/sysviews.out
M src/test/regress/sql/sysviews.sql

Avoid unneeded nbtree backwards scan buffer locks.

commit   : 3f44959f47460fb350d25d760cf2384f9aa14e9a    
  
author   : Peter Geoghegan <[email protected]>    
date     : Sun, 11 Aug 2024 15:42:52 -0400    
  
committer: Peter Geoghegan <[email protected]>    
date     : Sun, 11 Aug 2024 15:42:52 -0400    

Click here for diff

Teach nbtree backwards scans to avoid relocking a just-read leaf page to  
read its current left sibling link when it isn't truly necessary.  This  
happened inside _bt_readnextpage whenever _bt_readpage had already  
determined that there'll be no further matches to the left (or at least  
none for the current primitive index scan, for a scan with array keys).  
  
A new precheck inside _bt_readnextpage is all that we need to avoid  
these useless lock acquisitions.  Arguably, using a precheck like this  
was a missed opportunity for commit 2ed5b87f96, which taught nbtree to  
drop leaf page pins early to avoid blocking cleanup by VACUUM.  Forwards  
scans already managed to avoid relocking the page like this.  
  
The optimization added by this commit is particularly helpful with  
backwards scans that use array keys where the scan must perform multiple  
primitive index scans.  Such backwards scans will now avoid a useless  
leaf page re-lock at the end of each primitive index scan.  
  
Note that this commit does not attempt to avoid needlessly re-locking a  
leaf page that was just read when the scan must follow the leaf page's  
left link.  That more ambitious optimization could work by stashing the  
left link when the page is first read by a backwards scan, allowing the  
subsequent _bt_readnextpage call to optimistically skip re-reading the  
original page just to get a new copy of its left link.  For now we only  
address cases where we don't care about our original page's left link.  
  
Author: Peter Geoghegan <[email protected]>  
Reviewed-By: Matthias van de Meent <[email protected]>  
Discussion: https://postgr.es/m/CAH2-Wz=xgs7PojG=EUvhgadwENzu_mY_riNh-w9wFPsaS717ew@mail.gmail.com  

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

Initialize HASHCTL differently, to suppress Coverity warning

commit   : f011e82c2c886329245f821146c560a3607f7aba    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Sun, 11 Aug 2024 20:21:16 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Sun, 11 Aug 2024 20:21:16 +0300    

Click here for diff

Coverity complained that the hash_create() call might access  
hash_table_ctl->hctl. That's a false alarm, hash_create() only  
accesses that field when passed the HASH_SHARED_MEM flag. Try to  
silence it by using a plain local variable instead of a const. That's  
how the HASHCTL is initialized in all the other hash_create() calls.  

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

Suppress Coverity warnings about Asserts in get_name_for_var_field.

commit   : b2be5cb2ab671073ec0fc69357c3c11e25bb41cc    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 11 Aug 2024 12:24:56 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 11 Aug 2024 12:24:56 -0400    

Click here for diff

Coverity thinks dpns->plan could be null at these points.  That  
shouldn't really be possible, but it's easy enough to modify the  
Asserts so they'd not core-dump if it were true.  
  
These are new in b919a97a6.  Back-patch to v13; the v12 version  
of the patch didn't have these Asserts.  

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

Allow adjusting session_authorization and role in parallel workers.

commit   : 364de74cff281e7363c7ca8de4fbf04c6e16f8ed    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 10 Aug 2024 15:51:28 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 10 Aug 2024 15:51:28 -0400    

Click here for diff

The code intends to allow GUCs to be set within parallel workers  
via function SET clauses, but not otherwise.  However, doing so fails  
for "session_authorization" and "role", because the assign hooks for  
those attempt to set the subsidiary "is_superuser" GUC, and that call  
falls foul of the "not otherwise" prohibition.  We can't switch to  
using GUC_ACTION_SAVE for this, so instead add a new GUC variable  
flag GUC_ALLOW_IN_PARALLEL to mark is_superuser as being safe to set  
anyway.  (This is okay because is_superuser has context PGC_INTERNAL  
and thus only hard-wired calls can change it.  We'd need more thought  
before applying the flag to other GUCs; but maybe there are other  
use-cases.)  This isn't the prettiest fix perhaps, but other  
alternatives we thought of would be much more invasive.  
  
While here, correct a thinko in commit 059de3ca4: when rejecting  
a GUC setting within a parallel worker, we should return 0 not -1  
if the ereport doesn't longjmp.  (This seems to have no consequences  
right now because no caller cares, but it's inconsistent.)  Improve  
the comments to try to forestall future confusion of the same kind.  
  
Despite the lack of field complaints, this seems worth back-patching.  
Thanks to Nathan Bossart for the idea to invent a new flag,  
and for review.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/misc/guc.c
M src/backend/utils/misc/guc_tables.c
M src/include/utils/guc.h
M src/test/regress/expected/select_parallel.out
M src/test/regress/sql/select_parallel.sql

Add tests for pg_wal_replay_wait() errors

commit   : 0868d7ae70e57f4eeba43792db92ce2d9fe4340d    
  
author   : Alexander Korotkov <[email protected]>    
date     : Sat, 10 Aug 2024 21:43:14 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Sat, 10 Aug 2024 21:43:14 +0300    

Click here for diff

Improve test coverage for pg_wal_replay_wait() procedure by adding test  
cases when it errors out.  

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

Improve header comment for WaitLSNSetLatches()

commit   : 3ac3ec580c6f4f991d32252814e4b04c0e903a41    
  
author   : Alexander Korotkov <[email protected]>    
date     : Sat, 10 Aug 2024 21:43:09 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Sat, 10 Aug 2024 21:43:09 +0300    

Click here for diff

Reflect the fact that we remove waiters from the heap, not just set their  
latches.  

M src/backend/commands/waitlsn.c

Adjust pg_wal_replay_wait() procedure behavior on promoted standby

commit   : 867d396ccd2a7f0ce55e1fa7ebda00bc8c81147b    
  
author   : Alexander Korotkov <[email protected]>    
date     : Sat, 10 Aug 2024 21:43:02 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Sat, 10 Aug 2024 21:43:02 +0300    

Click here for diff

pg_wal_replay_wait() is intended to be called on standby.  However, standby  
can be promoted to primary at any moment, even concurrently with the  
pg_wal_replay_wait() call.  If recovery is not currently in progress  
that doesn't mean the wait was unsuccessful.  Thus, we always need to recheck  
if the target LSN is replayed.  
  
Reported-by: Kevin Hale Boyes  
Discussion: https://postgr.es/m/CAPpHfdu5QN%2BZGACS%2B7foxmr8_nekgA2PA%2B-G3BuOUrdBLBFb6Q%40mail.gmail.com  
Author: Alexander Korotkov  

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

Lower minimum maintenance_work_mem to 64kB

commit   : bbf668d66fbf61d45f1c187b08a5f51537bfb7c7    
  
author   : John Naylor <[email protected]>    
date     : Tue, 6 Aug 2024 20:38:33 +0700    
  
committer: John Naylor <[email protected]>    
date     : Tue, 6 Aug 2024 20:38:33 +0700    

Click here for diff

Since the introduction of TID store, vacuum uses far less memory in  
the common case than in versions 16 and earlier. Invoking multiple  
rounds of index vacuuming in turn requires a much larger table. It'd  
be a good idea anyway to cover this case in regression testing, and a  
lower limit is less painful for slow buildfarm animals. The reason to  
do it now is to re-enable coverage of the bugfix in commit 83c39a1f7f.  
  
For consistency, give autovacuum_work_mem the same treatment.  
  
Suggested by Andres Freund  
Tested by Melanie Plageman  
Backpatch to v17, where TID store was introduced  
  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/20240722164745.fvaoh6g6zprisqgp%40awork3.anarazel.de  

M src/backend/postmaster/autovacuum.c
M src/backend/utils/misc/guc_tables.c
M src/backend/utils/misc/postgresql.conf.sample

Fix inappropriate uses of atol()

commit   : f5a1311fccd2ed24a9fb42aa47a17d1df7126039    
  
author   : Peter Eisentraut <[email protected]>    
date     : Sat, 10 Aug 2024 08:12:44 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Sat, 10 Aug 2024 08:12:44 +0200    

Click here for diff

Some code using atol() would not work correctly if sizeof(long)==4:  
  
- src/bin/pg_basebackup/pg_basebackup.c: Would miscount size of a  
  tablespace over 2 TB.  
  
- src/bin/pg_basebackup/streamutil.c: Would truncate a timeline ID  
  beyond INT32_MAX.  
  
- src/bin/pg_rewind/libpq_source.c: Would miscount size of files  
  larger than 2 GB (but this currently cannot happen).  
  
Replace these with atoll().  
  
In one case, the use of atol() did not result in incorrect behavior  
but seems inconsistent with related code:  
  
- src/interfaces/ecpg/ecpglib/execute.c: Gratuitous, since it  
  processes a value from pg_type.typlen, which is int16.  
  
Replace this with atoi().  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/a52738ad-06bc-4d45-b59f-b38a8a89de49%40eisentraut.org  

M src/bin/pg_basebackup/pg_basebackup.c
M src/bin/pg_basebackup/streamutil.c
M src/bin/pg_rewind/libpq_source.c
M src/interfaces/ecpg/ecpglib/execute.c

libpq: Trace StartupMessage/SSLRequest/GSSENCRequest correctly

commit   : 7adec2d5fc29036a6ce78c4f4e95f85466cb5d9a    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 9 Aug 2024 17:55:01 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 9 Aug 2024 17:55:01 -0400    

Click here for diff

libpq tracing via PQtrace would uselessly print the wrong thing for  
these types of messages.  With this commit, their type and contents  
would be correctly listed.  (This can be verified with PQconnectStart(),  
but we don't use that in libpq_pipeline, so I (Álvaro) haven't bothered  
to add any tests.)  
  
Author: Jelte Fennema-Nio <[email protected]>  
Discussion: https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com  

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

Fix comment on processes being kept over a restart

commit   : a79ed10e6c6b43cc43a51a5f5bcc29252b4bb6dc    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Sat, 10 Aug 2024 00:06:19 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Sat, 10 Aug 2024 00:06:19 +0300    

Click here for diff

All child processes except the syslogger are killed on a restart. The  
archiver might be already running though, if it was started during  
recovery.  
  
The split in the comments between "other special children" and the  
first group of "background tasks" seemed really arbitrary, so I just  
merged them all into one group.  
  
Reviewed-by: Thomas Munro <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/postmaster/postmaster.c

Refactor code to handle death of a backend or bgworker in postmaster

commit   : 28a520c0b77325a97bafd0f57cc7bd0dd523b71e    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Sat, 10 Aug 2024 00:04:43 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Sat, 10 Aug 2024 00:04:43 +0300    

Click here for diff

Currently, when a child process exits, the postmaster first scans  
through BackgroundWorkerList, to see if it the child process was a  
background worker. If not found, then it scans through BackendList to  
see if it was a regular backend. That leads to some duplication  
between the bgworker and regular backend cleanup code, as both have an  
entry in the BackendList that needs to be cleaned up in the same way.  
Refactor that so that we scan just the BackendList to find the child  
process, and if it was a background worker, do the additional  
bgworker-specific cleanup in addition to the normal Backend cleanup.  
  
Change HandleChildCrash so that it doesn't try to handle the cleanup  
of the process that already exited, only the signaling of all the  
other processes. When called for any of the aux processes, the caller  
had already cleared the *PID global variable, so the code in  
HandleChildCrash() to do that was unused.  
  
On Windows, if a child process exits with ERROR_WAIT_NO_CHILDREN, it's  
now logged with that exit code, instead of 0. Also, if a bgworker  
exits with ERROR_WAIT_NO_CHILDREN, it's now treated as crashed and is  
restarted. Previously it was treated as a normal exit.  
  
If a child process is not found in the BackendList, the log message  
now calls it "untracked child process" rather than "server process".  
Arguably that should be a PANIC, because we do track all the child  
processes in the list, so failing to find a child process is highly  
unexpected. But if we want to change that, let's discuss and do that  
as a separate commit.  
  
Reviewed-by: Thomas Munro <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/postmaster/bgworker.c
M src/backend/postmaster/postmaster.c
M src/include/postmaster/bgworker_internals.h

Make BackgroundWorkerList doubly-linked

commit   : b43100fa71d7f21751b0b1b9b84833be95336386    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 9 Aug 2024 22:44:20 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 9 Aug 2024 22:44:20 +0300    

Click here for diff

This allows ForgetBackgroundWorker() and ReportBackgroundWorkerExit()  
to take a RegisteredBgWorker pointer as argument, rather than a list  
iterator. That feels a little more natural. But more importantly, this  
paves the way for more refactoring in the next commit.  
  
Reviewed-by: Thomas Munro <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/postmaster/bgworker.c
M src/backend/postmaster/postmaster.c
M src/include/postmaster/bgworker_internals.h

doc: Standardize use of dashes in references to CRC and SHA.

commit   : 7fceb5725b05768e9c76b1c3af447dfea8f8da53    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 9 Aug 2024 13:16:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 9 Aug 2024 13:16:33 -0500    

Click here for diff

Presently, we inconsistently use dashes in references to these  
algorithms (e.g., CRC32C versus CRC-32C).  Some popular web sources  
appear to prefer dashes, and with this commit, we will, too.  
  
Reviewed-by: Robert Haas  
Discussion: https://postgr.es/m/ZrUFpLP-w2zTAHqq%40nathan  

M doc/src/sgml/backup-manifest.sgml
M doc/src/sgml/pgcrypto.sgml
M doc/src/sgml/ref/pg_basebackup.sgml

doc: Fix name of CRC algorithm in "Reliability" section.

commit   : 8c3548613d7e2a7c010360e6f55fa6db849eeef9    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 9 Aug 2024 10:52:37 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 9 Aug 2024 10:52:37 -0500    

Click here for diff

This section claims we use CRC-32 for WAL records and two-phase  
state files, but we've actually used CRC-32C since v9.5 (commit  
5028f22f6e).  Fix that.  
  
Reviewed-by: Robert Haas  
Discussion: https://postgr.es/m/ZrUFpLP-w2zTAHqq%40nathan  
Backpatch-through: 12  

M doc/src/sgml/wal.sgml

Fix "failed to find plan for subquery/CTE" errors in EXPLAIN.

commit   : b919a97a6cd204cbd9b77d12c9e60ad59eea04a4    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 9 Aug 2024 11:21:39 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 9 Aug 2024 11:21:39 -0400    

Click here for diff

To deparse a reference to a field of a RECORD-type output of a  
subquery, EXPLAIN normally digs down into the subquery's plan to try  
to discover exactly which anonymous RECORD type is meant.  However,  
this can fail if the subquery has been optimized out of the plan  
altogether on the grounds that no rows could pass the WHERE quals,  
which has been possible at least since 3fc6e2d7f.  There isn't  
anything remaining in the plan tree that would help us, so fall back  
to printing the field name as "fN" for the N'th column of the record.  
(This will actually be the right thing some of the time, since it  
matches the column names we assign to RowExprs.)  
  
In passing, fix a comment typo in create_projection_plan, which  
I noticed while experimenting with an alternative fix for this.  
  
Per bug #18576 from Vasya B.  Back-patch to all supported branches.  
  
Richard Guo and Tom Lane  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/optimizer/plan/createplan.c
M src/backend/utils/adt/ruleutils.c
M src/test/regress/expected/rowtypes.out
M src/test/regress/sql/rowtypes.sql

Remove obsolete RECHECK keyword completely

commit   : 7da1bdc2c2f17038f2ae1900be90a0d7b5e361e0    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 9 Aug 2024 07:17:15 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 9 Aug 2024 07:17:15 +0200    

Click here for diff

This used to be part of CREATE OPERATOR CLASS and ALTER OPERATOR  
FAMILY, but it has done nothing (except issue a NOTICE) since  
PostgreSQL 8.4.  Commit 30e7c175b81 removed support for dumping from  
pre-9.2 servers, so this no longer serves any need.  
  
This now removes it completely, and you'd get a normal parse error if  
you used it.  
  
Reviewed-by: Aleksander Alekseev <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/113ef2d2-3657-4353-be97-f28fceddbca1%40eisentraut.org  

M doc/src/sgml/ref/alter_opfamily.sgml
M doc/src/sgml/ref/create_opclass.sgml
M src/backend/parser/gram.y
M src/include/parser/kwlist.h
M src/test/isolation/specs/merge-match-recheck.spec

Change the misleading local end_lsn for prepared transactions.

commit   : 701cf1e3174d560a19c019f1085c73ef667acf2d    
  
author   : Amit Kapila <[email protected]>    
date     : Fri, 9 Aug 2024 10:23:57 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Fri, 9 Aug 2024 10:23:57 +0530    

Click here for diff

The apply worker was using XactLastCommitEnd as local end_lsn for applying  
prepare and rollback_prepare. The XactLastCommitEnd value is the end lsn  
of the last commit applied before the prepare transaction which makes no  
sense. This LSN is used to decide whether we can send the acknowledgment  
of the corresponding remote LSN to the server.  
  
It is okay not to set the local_end LSN with the actual WAL position for  
the prepare because we always flush the prepare record. So, we can send  
the acknowledgment of the remote_end LSN as soon as prepare is finished.  
  
The current code is misleading but as such doesn't create any problem, so  
decided not to backpatch.  
  
Author: Hayato Kuroda  
Reviewed-by: Shveta Malik, Amit Kapila  
Discussion: https://postgr.es/m/TYAPR01MB5692FA4926754B91E9D7B5F0F5AA2@TYAPR01MB5692.jpnprd01.prod.outlook.com  

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

libpq: Add suppress argument to pqTraceOutputNchar

commit   : 4eb179e5bf7a5551ce3963d1563d6c9968c1a257    
  
author   : Alvaro Herrera <[email protected]>    
date     : Thu, 8 Aug 2024 20:35:12 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Thu, 8 Aug 2024 20:35:12 -0400    

Click here for diff

In future commits we're going to trace authentication related messages.  
Some of these messages contain challenge bytes as part of a  
challenge-response flow.  Since these bytes are different for every  
connection, we want to normalize them when the PQTRACE_REGRESS_MODE  
trace flag is set.  This commit modifies pqTraceOutputNchar to take a  
suppress argument, which makes it possible to do so.  
  
Author: Jelte Fennema-Nio <[email protected]>  
Discussion: https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com  

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

Refuse ATTACH of a table referenced by a foreign key

commit   : a90bdd7a44d088a10b2faf5d7cdb85b8e4f0c662    
  
author   : Alvaro Herrera <[email protected]>    
date     : Thu, 8 Aug 2024 19:35:13 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Thu, 8 Aug 2024 19:35:13 -0400    

Click here for diff

Trying to attach a table as a partition which is already on the  
referenced side of a foreign key on the partitioned table that it is  
being attached to, leads to strange behavior: we try to clone the  
foreign key from the parent to the partition, but this new FK points to  
the partition itself, and the mix of pg_constraint rows and triggers  
doesn't behave well.  
  
Rather than trying to untangle the mess (which might be possible given  
sufficient time), I opted to forbid the ATTACH.  This doesn't seem a  
problematic restriction, given that we already fail to create the  
foreign key if you do it the other way around, that is, having the  
partition first and the FK second.  
  
Backpatch to all supported branches.  
  
Reported-by: Alexander Lakhin <[email protected]>  
Reviewed-by: Tender Wang <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

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

Refactor error messages to reduce duplication

commit   : 498ee9ee2f4bc7d79f2d91cdd817b2a8f14a664f    
  
author   : Alvaro Herrera <[email protected]>    
date     : Thu, 8 Aug 2024 15:17:11 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Thu, 8 Aug 2024 15:17:11 -0400    

Click here for diff

I also took the liberty of changing  
  
	errmsg("COPY DEFAULT only available using COPY FROM")  
to  
	errmsg("COPY %s cannot be used with %s", "DEFAULT", "COPY TO")  
  
because the original wording is unlike all other messages that indicate  
option incompatibility.  This message was added by commit 9f8377f7a279  
(16-era), in whose development thread there was no discussion on this  
point.  
  
Backpatch to 17.  

M src/backend/commands/copy.c
M src/backend/commands/copyfrom.c
M src/backend/commands/copyto.c
M src/test/regress/expected/copy2.out

Add a caveat to hash_seq_init_with_hash_value() header comment

commit   : d0c8cf2a56fadb08705433bffb301559d97b0712    
  
author   : Alexander Korotkov <[email protected]>    
date     : Thu, 8 Aug 2024 11:48:57 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Thu, 8 Aug 2024 11:48:57 +0300    

Click here for diff

The typical use-case for hash_seq_init_with_hash_value() is syscache  
callback.  Add a caveat that the default hash function doesn't match syscache  
hash function.  So, one needs to define a custom hash function.  
  
Reported-by: Pavel Stehule  
Discussion: https://postgr.es/m/CAFj8pRAXmv6eyYx%3DE_BTfyK%3DO_%2ByOF8sXB%3D0bn9eOBt90EgWRA%40mail.gmail.com  
Reviewed-by: Pavel Stehule  

M src/backend/utils/hash/dynahash.c

Fix pg_rewind debug output to print the source timeline history

commit   : 49dc191bd1ae30180597c33e7f75a9950b896ccc    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Thu, 8 Aug 2024 10:20:25 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Thu, 8 Aug 2024 10:20:25 +0300    

Click here for diff

getTimelineHistory() is called twice, to read the source and the  
target timeline history files. However, the loop to print the file  
with the --debug option used the wrong variable when dealing with the  
source. As a result, the source's history was always printed as empty.  
  
Spotted while debugging bug #18575, but this does not fix that bug,  
just the debugging output. Backpatch to all supported versions.  
  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/bin/pg_rewind/pg_rewind.c

Fix names of "Visual Studio" and Meson in a documentation sentence.

commit   : e56ccc8e4204d9faf86f3bd2e435a0788b3d0429    
  
author   : Noah Misch <[email protected]>    
date     : Wed, 7 Aug 2024 11:43:08 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Wed, 7 Aug 2024 11:43:08 -0700    

Click here for diff

Commit 3cffe7946c268be91a340ec9a27081cb93d67d35 missed this.  Back-patch  
to v17, which introduced this.  
  
Discussion: https://postgr.es/m/CAJ7c6TM7ct0EjoCQaLSVYoxxnEw4xCUFebWj77GktWsqEdyCtQ@mail.gmail.com  

M doc/src/sgml/installation.sgml

Fix edge case in plpgsql's make_callstmt_target().

commit   : 8d148bb8b8529ed8edeee4332e8eb41bac0fc193    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 7 Aug 2024 12:54:39 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 7 Aug 2024 12:54:39 -0400    

Click here for diff

If the plancache entry for the CALL statement is already stale,  
it's possible for us to fetch an old procedure OID out of it,  
and then fail with "cache lookup failed for function NNN".  
In ordinary usage this never happens because make_callstmt_target  
is called just once immediately after building the plancache  
entry.  It can be forced however by setting up an erroneous CALL  
(that causes make_callstmt_target itself to report an error),  
then dropping/recreating the target procedure, then repeating  
the erroneous CALL.  
  
To fix, use SPI_plan_get_cached_plan() to fetch the plancache's  
plan, rather than assuming we can use SPI_plan_get_plan_sources().  
This shouldn't add any noticeable overhead in the normal case,  
and in the stale-plan case we'd have had to replan anyway a little  
further down.  
  
The other callers of SPI_plan_get_plan_sources() seem OK, because  
either they don't need up-to-date plans or they know that the  
query was just (re) planned.  But add some commentary in hopes  
of not falling into this trap again.  
  
Per bug #18574 from Song Hongyu.  Back-patch to v14 where this coding  
was introduced.  (Older branches have comparable code, but it's run  
after any required replanning, so there's no issue.)  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/spi.c
M src/pl/plpgsql/src/pl_exec.c

Refactor/reword some error messages to avoid duplicates

commit   : 2bb969f3998489e5dc4fe9f2a61185b43581975d    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 7 Aug 2024 11:30:36 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 7 Aug 2024 11:30:36 -0400    

Click here for diff

Also, remove brackets around "EMPTY [ ARRAY ]".  An error message is  
not the place to state that a keyword is optional.  
  
Backpatch to 17.  

M src/backend/executor/execExprInterp.c
M src/backend/parser/parse_expr.c
M src/backend/parser/parse_jsontable.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/expected/sqljson_queryfuncs.out

Improve file header comments for astramer code.

commit   : 22b4a1b561f830f2af80c21450a4c05f6efbb698    
  
author   : Robert Haas <[email protected]>    
date     : Wed, 7 Aug 2024 08:49:41 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Wed, 7 Aug 2024 08:49:41 -0400    

Click here for diff

Make it clear that "astreamer" stands for "archive streamer".  
Generalize comments that still believe this code can only be used  
by pg_basebackup. Add some comments explaining the asymmetry  
between the gzip, lz4, and zstd astreamers, in the hopes of making  
life easier for anyone who hacks on this code in the future.  
  
Robert Haas, reviewed by Amul Sul.  
  
Discussion: http://postgr.es/m/CAAJ_b97O2kkKVTWxt8MxDN1o-cDfbgokqtiN2yqFf48=gXpcxQ@mail.gmail.com  

M src/fe_utils/astreamer_file.c
M src/fe_utils/astreamer_gzip.c
M src/fe_utils/astreamer_lz4.c
M src/fe_utils/astreamer_zstd.c
M src/include/fe_utils/astreamer.h

Make fallback MD5 implementation thread-safe on big-endian systems

commit   : 2676040df0b2ebbcf8af759dbe5d34f393c3d5b5    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Wed, 7 Aug 2024 10:43:52 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Wed, 7 Aug 2024 10:43:52 +0300    

Click here for diff

Replace a static scratch buffer with a local variable, because a  
static buffer makes the function not thread-safe. This function is  
used in client-code in libpq, so it needs to be thread-safe. It was  
until commit b67b57a966, which replaced the implementation with the  
one from pgcrypto.  
  
Backpatch to v14, where we switched to the new implementation.  
  
Reviewed-by: Robert Haas, Michael Paquier  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/common/md5.c

Revert ECPG's use of pnstrdup()

commit   : 5388216f6adc7eac20f32db33cc5ce54ef0cc930    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 7 Aug 2024 09:21:07 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 7 Aug 2024 09:21:07 +0200    

Click here for diff

Commit 0b9466fce added a dependency on fe_memutils' pnstrdup() inside  
informix.c.  This adds an exit() path in a library, which we don't  
want.  (Unlike libpq, the ecpg libraries don't have an automated check  
for that, but it makes sense to keep them to a similar standard.)  The  
ecpg code can already handle failure results from the *strdup() call  
by itself.  
  
Author: Jacob Champion <[email protected]>  
Discussion: https://www.postgresql.org/message-id/CAOYmi+=pg=W5L1h=3MEP_EB24jaBu2FyATrLXqQHGe7cpuvwyg@mail.gmail.com  

M src/interfaces/ecpg/compatlib/informix.c

Optimize InvalidateAttoptCacheCallback() and TypeCacheTypCallback()

commit   : 40064a8ee1b34d8a128d6007416acd89077a2c11    
  
author   : Alexander Korotkov <[email protected]>    
date     : Wed, 7 Aug 2024 06:51:29 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Wed, 7 Aug 2024 06:51:29 +0300    

Click here for diff

These callbacks are receiving hash values as arguments, which doesn't allow  
direct lookups for AttoptCacheHash and TypeCacheHash.  This is why subject  
callbacks currently use full iteration over corresponding hashes.  
  
This commit avoids full hash iteration in InvalidateAttoptCacheCallback(),  
and TypeCacheTypCallback().  At first, we switch AttoptCacheHash and  
TypeCacheHash to use same hash function as syscache.  As second, we  
use hash_seq_init_with_hash_value() to iterate only hash entries with matching  
hash value.  
  
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  

M src/backend/utils/cache/attoptcache.c
M src/backend/utils/cache/typcache.c

Introduce hash_search_with_hash_value() function

commit   : d0f020037e19c33c74d683eb7e0c7cc5725294b4    
  
author   : Alexander Korotkov <[email protected]>    
date     : Wed, 7 Aug 2024 06:51:16 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Wed, 7 Aug 2024 06:51:16 +0300    

Click here for diff

This new function iterates hash entries with given hash values.  This function  
is designed to avoid full sequential hash search in the syscache invalidation  
callbacks.  
  
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  

M src/backend/utils/hash/dynahash.c
M src/include/utils/hsearch.h

Use psprintf to simplify gtsvectorout()

commit   : 3ab2668d48476e31d8809fbb36c9ee739cc444e1    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 23:05:25 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 23:05:25 +0300    

Click here for diff

The buffer allocation was correct, but looked archaic and scary:  
  
- It was weird to calculate the buffer size before determining which  
  format string was used. With the same effort, we could've used the  
  right-sized buffer for each branch.  
  
- Commit aa0d3504560 added one more possible return string ("all true  
  bits"), but didn't adjust the code at the top of the function to  
  calculate the returned string's max size. It was not a live bug,  
  because the new string was smaller than the existing ones, but  
  seemed wrong in principle.  
  
- Use of sprintf() is generally eyebrow-raising these days  
  
Switch to psprintf(). psprintf() allocates a larger buffer than what  
was allocated before, 128 bytes vs 80 bytes, which is acceptable as  
this code is not performance or space critical.  
  
Reviewed-by: Andres Freund  
Discussion: https://www.postgresql.org/message-id/[email protected]  

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

Constify fields and parameters in spell.c

commit   : d5f139cb6814f0af2d2e1106899361e45c305630    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 23:04:51 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 23:04:51 +0300    

Click here for diff

I started by marking VoidString as const, and fixing the fallout by  
marking more fields and function arguments as const. It proliferated  
quite a lot, but all within spell.c and spell.h.  
  
A more narrow patch to get rid of the static VoidString buffer would  
be to replace it with '#define VoidString ""', as C99 allows assigning  
"" to a non-const pointer, even though you're not allowed to modify  
it. But it seems like good hygiene to mark all these as const. In the  
structs, the pointers can point to the constant VoidString, or a  
buffer allocated with palloc(), or with compact_palloc(), so you  
should not modify them.  
  
Reviewed-by: Andres Freund  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/tsearch/spell.c
M src/include/tsearch/dicts/spell.h

Mark misc static global variables as const

commit   : fe8dd65bf28db1a6ad690ffcd5124d1863b5a4c6    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 23:04:48 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 23:04:48 +0300    

Click here for diff

Reviewed-by: Andres Freund  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M contrib/btree_gist/btree_interval.c
M contrib/oid2name/oid2name.c
M src/backend/access/transam/xlogprefetcher.c
M src/common/sha1.c
M src/pl/plpython/plpy_cursorobject.c

commit   : 85829c973cb33592dbc0b0f3aaf9132f5dea6953    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 23:04:22 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 23:04:22 +0300    

Click here for diff

To make it more clear that these should never be modified.  
  
Reviewed-by: Andres Freund  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/utils/adt/jsonfuncs.c
M src/common/jsonapi.c
M src/include/common/jsonapi.h
M src/include/utils/jsonfuncs.h
M src/test/modules/test_json_parser/test_json_parser_incremental.c

Turn a few 'validnsps' static variables into locals

commit   : 1e35951e71d37ab6716fa55ba399fbe6df4a7417    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 23:03:43 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 23:03:43 +0300    

Click here for diff

There was no need for these to be static buffers, local variables work  
just as well. I think they were marked as 'static' to imply that they  
are read-only, but 'const' is more appropriate for that, so change  
them to const.  
  
To make it possible to mark the variables as 'const', also add 'const'  
decorations to the transformRelOptions() signature.  
  
Reviewed-by: Andres Freund  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/access/common/reloptions.c
M src/backend/commands/createas.c
M src/backend/commands/tablecmds.c
M src/backend/tcop/utility.c
M src/include/access/reloptions.h

selfuncs.c: use pg_strxfrm() instead of strxfrm().

commit   : a890ad214942c9eab1b2f0c6997e7dc114f99e71    
  
author   : Jeff Davis <[email protected]>    
date     : Tue, 6 Aug 2024 11:55:21 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Tue, 6 Aug 2024 11:55:21 -0700    

Click here for diff

pg_strxfrm() takes a pg_locale_t, so it works properly with all  
providers. This improves estimates for ICU when performing linear  
interpolation within a histogram bin.  
  
Previously, convert_string_datum() always used strxfrm() and relied on  
setlocale(). That did not produce good estimates for non-default or  
non-libc collations.  
  
Discussion: https://postgr.es/m/[email protected]  

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

Fix datatypes in comments in instr_time.h

commit   : a54d4ed183927f15e1853b83106acebeeeee11c8    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 22:15:55 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 22:15:55 +0300    

Click here for diff

The INSTR_TIME_GET_NANOSEC(t) and INSTR_TIME_GET_MICROSEC(t) macros  
return a signed int64.  
  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/include/portability/instr_time.h

Revert "Fix comments in instr_time.h and remove an unneeded cast to int64"

commit   : 39a138fbef87803ab7fe494243c1ba36a093a0e8    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 22:15:46 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 22:15:46 +0300    

Click here for diff

This reverts commit 3dcb09de7b. Tom Lane pointed out that it broke the  
abstraction provided by the macros. The callers should not need to  
know what the internal type is.  
  
This commit is an exact revert, the next commit will fix the comments  
on the macros that incorrectly claim that they return uint64.  
  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/include/portability/instr_time.h

Allow parallel workers to cope with a newly-created session user ID.

commit   : 6e086fa2e771ad4c0b2d3cca4e2de209a92c719b    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 6 Aug 2024 12:36:42 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 6 Aug 2024 12:36:42 -0400    

Click here for diff

Parallel workers failed after a sequence like  
BEGIN;  
CREATE USER foo;  
SET SESSION AUTHORIZATION foo;  
because check_session_authorization could not see the uncommitted  
pg_authid row for "foo".  This is because we ran RestoreGUCState()  
in a separate transaction using an ordinary just-created snapshot.  
The same disease afflicts any other GUC that requires catalog lookups  
and isn't forgiving about the lookups failing.  
  
To fix, postpone RestoreGUCState() into the worker's main transaction  
after we've set up a snapshot duplicating the leader's.  This affects  
check_transaction_isolation and check_transaction_deferrable, which  
think they should only run during transaction start.  Make them  
act like check_transaction_read_only, which already knows it should  
silently accept the value when InitializingParallelWorker.  
  
This un-reverts commit f5f30c22e.  The original plan was to back-patch  
that, but the fact that 0ae5b763e proved to be a pre-requisite shows  
that the subtle API change for GUC hooks might actually break some of  
them.  The problem we're trying to fix seems not worth taking such a  
risk for in stable branches.  
  
Per bug #18545 from Andrey Rachitskiy.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/parallel.c
M src/backend/commands/variable.c
M src/test/regress/expected/select_parallel.out
M src/test/regress/sql/select_parallel.sql

Clean up handling of client_encoding GUC in parallel workers.

commit   : 0ae5b763ea0e9dcd85521ebdc9285bbdc7470331    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 6 Aug 2024 12:21:23 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 6 Aug 2024 12:21:23 -0400    

Click here for diff

The previous coding here threw an error from assign_client_encoding  
if it was invoked in a parallel worker.  That's a very fundamental  
violation of the GUC hook API: assign hooks must not throw errors.  
The place to complain is in the check hook, so move the test to  
there, and use the regular check-hook API (ie return false) to  
report it.  
  
The reason this coding is a problem is that it breaks GUC rollback,  
which may occur after we leave InitializingParallelWorker state.  
That case seems not actually reachable before now, but commit  
f5f30c22e made it reachable, so we need to fix this before that  
can be un-reverted.  
  
In passing, improve the commentary in ParallelWorkerMain, and  
add a check for failure of SetClientEncoding.  That's another  
case that can't happen now but might become possible after  
foreseeable code rearrangements (notably, if the shortcut of  
skipping PrepareClientEncoding stops being OK).  
  
Discussion: https://postgr.es/m/[email protected]  

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

Remove volatile qualifiers from pg_stat_statements.c.

commit   : 8928817769de0d81758bc760333d3056c67b63c1    
  
author   : Nathan Bossart <[email protected]>    
date     : Tue, 6 Aug 2024 10:56:37 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Tue, 6 Aug 2024 10:56:37 -0500    

Click here for diff

Prior to commit 0709b7ee72, which changed the spinlock primitives  
to function as compiler barriers, access to variables within a  
spinlock-protected section required using a volatile pointer, but  
that is no longer necessary.  
  
Reviewed-by: Bertrand Drouvot, Michael Paquier  
Discussion: https://postgr.es/m/Zqkv9iK7MkNS0KaN%40nathan  

M contrib/pg_stat_statements/pg_stat_statements.c

Fix comments in instr_time.h and remove an unneeded cast to int64

commit   : 3dcb09de7bb21c75d4df48263561af324fd099a4    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 14:28:02 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 6 Aug 2024 14:28:02 +0300    

Click here for diff

03023a2664 represented time as an int64 on all platforms but forgot to  
update the comment related to INSTR_TIME_GET_MICROSEC() and provided  
an incorrect comment for INSTR_TIME_GET_NANOSEC().  
  
In passing remove an unneeded cast to int64.  
  
Author: Bertrand Drouvot  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/include/portability/instr_time.h

Remove unnecessary declaration of heapam_methods

commit   : 8771298605a6d81861634ed387a6fc7ed496fa61    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 6 Aug 2024 16:27:38 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 6 Aug 2024 16:27:38 +0900    

Click here for diff

This overlaps with the declaration at the end of heapam_handler.c that  
lists all the callback routines for the heap table AM.  
  
Author: Japin Li  
Discussion: https://postgr.es/m/ME0P300MB04459456D5C4E70D48116896B6B12@ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM  

M src/backend/access/heap/heapam_handler.c

Remove support for null pg_locale_t most places.

commit   : e9931bfb7515b253cc26ff495ee917acff8995d0    
  
author   : Jeff Davis <[email protected]>    
date     : Mon, 5 Aug 2024 18:15:57 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Mon, 5 Aug 2024 18:15:57 -0700    

Click here for diff

Previously, passing NULL for pg_locale_t meant "use the libc provider  
and the server environment". Now that the database collation is  
represented as a proper pg_locale_t (not dependent on setlocale()),  
remove special cases for NULL.  
  
Leave wchar2char() and char2wchar() unchanged for now, because the  
callers don't always have a libc-based pg_locale_t available.  
  
Discussion: https://postgr.es/m/[email protected]  
Reviewed-by: Peter Eisentraut, Andreas Karlsson  

M src/backend/access/hash/hashfunc.c
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/pg_locale.c
M src/backend/utils/adt/varchar.c
M src/backend/utils/adt/varlena.c

Move astreamer (except astreamer_inject) to fe_utils.

commit   : f80b09bac87d6b49f5dbb6131da5fbd9b9773c5c    
  
author   : Robert Haas <[email protected]>    
date     : Mon, 5 Aug 2024 11:40:29 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Mon, 5 Aug 2024 11:40:29 -0400    

Click here for diff

This allows the code to be used by other frontend applications.  
  
Amul Sul, reviewed by Sravan Kumar, Andres Freund (whose input  
I specifically solicited regarding the meson.build changes),  
and me.  
  
Discussion: http://postgr.es/m/CAAJ_b94StvLWrc_p4q-f7n3OPfr6GhL8_XuAg2aAaYZp1tF-nw@mail.gmail.com  

M meson.build
M src/bin/pg_basebackup/Makefile
M src/bin/pg_basebackup/astreamer_inject.h
M src/bin/pg_basebackup/meson.build
M src/fe_utils/Makefile
R099 src/bin/pg_basebackup/astreamer_file.c src/fe_utils/astreamer_file.c
R099 src/bin/pg_basebackup/astreamer_gzip.c src/fe_utils/astreamer_gzip.c
R099 src/bin/pg_basebackup/astreamer_lz4.c src/fe_utils/astreamer_lz4.c
R099 src/bin/pg_basebackup/astreamer_tar.c src/fe_utils/astreamer_tar.c
R099 src/bin/pg_basebackup/astreamer_zstd.c src/fe_utils/astreamer_zstd.c
M src/fe_utils/meson.build
R100 src/bin/pg_basebackup/astreamer.h src/include/fe_utils/astreamer.h

Move recovery injector astreamer to a separate header file.

commit   : 53b2c921a0f9b56465ab65165c1909f9616ffa98    
  
author   : Robert Haas <[email protected]>    
date     : Mon, 5 Aug 2024 10:40:23 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Mon, 5 Aug 2024 10:40:23 -0400    

Click here for diff

Unlike the rest of the astreamer (formerly bbstreamer) infrastructure  
which is reusable by other tools, astreamer_inject.c seems extremely  
specific to pg_basebackup. Hence, move the corresponding declarations  
to a separate header file, so that we can move the rest of the code  
without moving this.  
  
Amul Sul, reviewed by Sravan Kumar and by me.  
  
Discussion: http://postgr.es/m/CAAJ_b94StvLWrc_p4q-f7n3OPfr6GhL8_XuAg2aAaYZp1tF-nw@mail.gmail.com  

M src/bin/pg_basebackup/astreamer.h
M src/bin/pg_basebackup/astreamer_inject.c
A src/bin/pg_basebackup/astreamer_inject.h
M src/bin/pg_basebackup/pg_basebackup.c

Rename bbstreamer to astreamer.

commit   : 3c905698114d6c4de4dc607c110c27e0723ae70c    
  
author   : Robert Haas <[email protected]>    
date     : Mon, 5 Aug 2024 09:35:42 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Mon, 5 Aug 2024 09:35:42 -0400    

Click here for diff

I (rhaas) intended "bbstreamer" to stand for "base backup streamer,"  
but that implies that this infrastructure can only ever be used by  
pg_basebackup.  In fact, it is a generally useful way of streaming  
data from a tar or compressed tar file, and it could be extended to  
work with other archive formats as well if we ever wanted to do that.  
Hence, rename it to "astreamer" (archive streamer) in preparation for  
reusing the infrastructure from pg_verifybackup (and perhaps  
eventually also other utilities, such as pg_combinebackup or  
pg_waldump).  
  
This is purely a renaming commit. Comment adjustments and relocation  
of the actual code to someplace from which it can be reused are left  
to future commits.  
  
Amul Sul, reviewed by Sravan Kumar and by me.  
  
Discussion: http://postgr.es/m/CAAJ_b94StvLWrc_p4q-f7n3OPfr6GhL8_XuAg2aAaYZp1tF-nw@mail.gmail.com  

M src/bin/pg_basebackup/Makefile
A src/bin/pg_basebackup/astreamer.h
R069 src/bin/pg_basebackup/bbstreamer_file.c src/bin/pg_basebackup/astreamer_file.c
R062 src/bin/pg_basebackup/bbstreamer_gzip.c src/bin/pg_basebackup/astreamer_gzip.c
R053 src/bin/pg_basebackup/bbstreamer_inject.c src/bin/pg_basebackup/astreamer_inject.c
R069 src/bin/pg_basebackup/bbstreamer_lz4.c src/bin/pg_basebackup/astreamer_lz4.c
R050 src/bin/pg_basebackup/bbstreamer_tar.c src/bin/pg_basebackup/astreamer_tar.c
R064 src/bin/pg_basebackup/bbstreamer_zstd.c src/bin/pg_basebackup/astreamer_zstd.c
D src/bin/pg_basebackup/bbstreamer.h
M src/bin/pg_basebackup/meson.build
M src/bin/pg_basebackup/nls.mk
M src/bin/pg_basebackup/pg_basebackup.c
M src/tools/pgindent/typedefs.list

Restrict accesses to non-system views and foreign tables during pg_dump.

commit   : 66e94448abec3aad04faf0a79cab4881ae08e08a    
  
author   : Masahiko Sawada <[email protected]>    
date     : Mon, 5 Aug 2024 06:05:33 -0700    
  
committer: Masahiko Sawada <[email protected]>    
date     : Mon, 5 Aug 2024 06:05:33 -0700    

Click here for diff

When pg_dump retrieves the list of database objects and performs the  
data dump, there was possibility that objects are replaced with others  
of the same name, such as views, and access them. This vulnerability  
could result in code execution with superuser privileges during the  
pg_dump process.  
  
This issue can arise when dumping data of sequences, foreign  
tables (only 13 or later), or tables registered with a WHERE clause in  
the extension configuration table.  
  
To address this, pg_dump now utilizes the newly introduced  
restrict_nonsystem_relation_kind GUC parameter to restrict the  
accesses to non-system views and foreign tables during the dump  
process. This new GUC parameter is added to back branches too, but  
these changes do not require cluster recreation.  
  
Back-patch to all supported branches.  
  
Reviewed-by: Noah Misch  
Security: CVE-2024-7348  
Backpatch-through: 12  

M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/sql/postgres_fdw.sql
M doc/src/sgml/config.sgml
M doc/src/sgml/ref/pg_dump.sgml
M src/backend/foreign/foreign.c
M src/backend/optimizer/plan/createplan.c
M src/backend/optimizer/util/plancat.c
M src/backend/rewrite/rewriteHandler.c
M src/backend/tcop/postgres.c
M src/backend/utils/misc/guc_tables.c
M src/bin/pg_dump/pg_dump.c
M src/include/tcop/tcopprot.h
M src/include/utils/guc_hooks.h
M src/test/regress/expected/create_view.out
M src/test/regress/sql/create_view.sql

Optimize JSON escaping using SIMD

commit   : ca6fde92258a328a98c1d9e41da5462b73da8529    
  
author   : David Rowley <[email protected]>    
date     : Mon, 5 Aug 2024 23:16:44 +1200    
  
committer: David Rowley <[email protected]>    
date     : Mon, 5 Aug 2024 23:16:44 +1200    

Click here for diff

Here we adjust escape_json_with_len() to make use of SIMD to allow  
processing of up to 16-bytes at a time rather than processing a single  
byte at a time.  This has been shown to speed up escaping of JSON  
strings significantly.  
  
Escaping is required for both JSON string properties and also the  
property names themselves, so this should also help improve the speed of  
the conversion from JSON into text for JSON objects that have property  
names 16 or more bytes long.  
  
Escaping JSON strings was often a significant bottleneck for longer  
strings.  With these changes, some benchmarking has shown a query  
performing nearly 4 times faster when escaping a JSON object with a 1MB  
text property.  Tests with shorter text properties saw smaller but still  
significant performance improvements.  For example, a test outputting 1024  
JSON strings with a text property length ranging from 1 char to 1024 chars  
became around 2 times faster.  
  
Author: David Rowley  
Reviewed-by: Melih Mutlu  
Discussion: https://postgr.es/m/CAApHDvpLXwMZvbCKcdGfU9XQjGCDm7tFpRdTXuB9PVgpNUYfEQ@mail.gmail.com  

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

Fix typo in bufpage.h.

commit   : b5df24e52044abfa6fe20a568ed8bfcb9761a090    
  
author   : Amit Kapila <[email protected]>    
date     : Mon, 5 Aug 2024 14:38:00 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Mon, 5 Aug 2024 14:38:00 +0530    

Click here for diff

Author: Senglee Choi  
Reviewed-by: Tender Wang  
Discussion: https://postgr.es/m/CACUsy79U0=S5zWEf6D57F=vB7rOEa86xFY6oovDZ58jRcROCxQ@mail.gmail.com  

M src/include/storage/bufpage.h

injection_points: Add some fixed-numbered statistics

commit   : f68cd847fa40ead44a786b9c34aff9ccc048004b    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 5 Aug 2024 12:29:22 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 5 Aug 2024 12:29:22 +0900    

Click here for diff

Like 75534436a477, this acts mainly as a template to show what can be  
achieved with fixed-numbered stats (like WAL, bgwriter, etc.) with the  
pluggable cumulative statistics APIs introduced in 7949d9594582.  
  
Fixed-numbered stats are defined in their own file, named  
injection_stats_fixed.c, separated entirely from the variable-numbered  
case in injection_stats.c.  This is mainly for clarity as having both  
examples in the same file would be confusing.  
  
Note that this commit uses the helper routines added in 2eff9e678d35.  
The stats stored track globally the number of times injection points  
have been attached, detached or run.  Two more fields should be added  
later for the number of times a point has been cached or loaded, but  
what's here is enough as a template.  
  
More TAP tests are added, providing coverage for fixed-numbered custom  
stats.  
  
Author: Michael Paquier  
Reviewed-by: Dmitry Dolgov, Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M src/test/modules/injection_points/Makefile
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
A src/test/modules/injection_points/injection_stats_fixed.c
M src/test/modules/injection_points/meson.build
M src/test/modules/injection_points/t/001_stats.pl
M src/tools/pgindent/typedefs.list

injection_points: Add some cumulative stats for injection points

commit   : 75534436a477474ea05004b7fbed21e20cea774a    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 5 Aug 2024 12:06:54 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 5 Aug 2024 12:06:54 +0900    

Click here for diff

This acts as a template of what can be achieved with the pluggable  
cumulative stats APIs introduced in 7949d9594582 for the  
variable-numbered case where stats entries are stored in the pgstats  
dshash, while being potentially useful on its own for injection points,  
say to add starting and/or stopping conditions based on the statistics  
(want to trigger a callback after N calls, for example?).  
  
Currently, the only data gathered is the number of times an injection  
point is run.  More fields can always be added as required.  All the  
routines related to the stats are located in their own file, called  
injection_stats.c in the test module injection_points, for clarity.  
  
The stats can be used only if the test module is loaded through  
shared_preload_libraries.  The key of the dshash uses InvalidOid for the  
database, and an int4 hash of the injection point name as object ID.  
  
A TAP test is added to provide coverage for the new custom cumulative  
stats APIs, showing the persistency of the data across restarts, for  
example.  
  
Author: Michael Paquier  
Reviewed-by: Dmitry Dolgov, Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/xfunc.sgml
M src/test/modules/injection_points/Makefile
M src/test/modules/injection_points/injection_points–1.0.sql
M src/test/modules/injection_points/injection_points.c
A src/test/modules/injection_points/injection_stats.c
A src/test/modules/injection_points/injection_stats.h
M src/test/modules/injection_points/meson.build
A src/test/modules/injection_points/t/001_stats.pl
M src/tools/pgindent/typedefs.list

Add helper routines to retrieve data for custom fixed-numbered pgstats

commit   : 2eff9e678d350882f7a4b6ec6361927c9093051c    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 5 Aug 2024 11:43:33 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 5 Aug 2024 11:43:33 +0900    

Click here for diff

This is useful for extensions to get snapshot and shmem data for custom  
cumulative statistics when these have a fixed number of objects, so as  
these do not need to know about the snapshot internals, aka pgStatLocal.  
  
An upcoming commit introducing an example template for custom cumulative  
stats with fixed-numbered objects will make use of these.  I have  
noticed that this is useful for extension developers while hacking my  
own example, actually.  
  
Author: Michael Paquier  
Reviewed-by: Dmitry Dolgov, Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M src/include/utils/pgstat_internal.h

pg_wal_replay_wait(): Fix typo in the doc

commit   : 8036d73ae3d4014a9dde21b0746dc1ac139d4dc1    
  
author   : Alexander Korotkov <[email protected]>    
date     : Sun, 4 Aug 2024 20:26:48 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Sun, 4 Aug 2024 20:26:48 +0300    

Click here for diff

Reported-by: Kevin Hale Boyes  
Discussion: https://postgr.es/m/CADAecHWKpaPuPGXAMOH%3DwmhTpydHWGPOk9KWX97UYhp5GdqCWw%40mail.gmail.com  

M doc/src/sgml/func.sgml

Introduce pluggable APIs for Cumulative Statistics

commit   : 7949d9594582ab49dee221e1db1aa5401ace49d4    
  
author   : Michael Paquier <[email protected]>    
date     : Sun, 4 Aug 2024 19:41:24 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Sun, 4 Aug 2024 19:41:24 +0900    

Click here for diff

This commit adds support in the backend for $subject, allowing  
out-of-core extensions to plug their own custom kinds of cumulative  
statistics.  This feature has come up a few times into the lists, and  
the first, original, suggestion came from Andres Freund, about  
pg_stat_statements to use the cumulative statistics APIs in shared  
memory rather than its own less efficient internals.  The advantage of  
this implementation is that this can be extended to any kind of  
statistics.  
  
The stats kinds are divided into two parts:  
- The in-core "builtin" stats kinds, with designated initializers, able  
to use IDs up to 128.  
- The "custom" stats kinds, able to use a range of IDs from 128 to 256  
(128 slots available as of this patch), with information saved in  
TopMemoryContext.  This can be made larger, if necessary.  
  
There are two types of cumulative statistics in the backend:  
- For fixed-numbered objects (like WAL, archiver, etc.).  These are  
attached to the snapshot and pgstats shmem control structures for  
efficiency, and built-in stats kinds still do that to avoid any  
redirection penalty.  The data of custom kinds is stored in a first  
array in snapshot structure and a second array in the shmem control  
structure, both indexed by their ID, acting as an equivalent of the  
builtin stats.  
- For variable-numbered objects (like tables, functions, etc.).  These  
are stored in a dshash using the stats kind ID in the hash lookup key.  
  
Internally, the handling of the builtin stats is unchanged, and both  
fixed and variabled-numbered objects are supported.  Structure  
definitions for builtin stats kinds are renamed to reflect better the  
differences with custom kinds.  
  
Like custom RMGRs, custom cumulative statistics can only be loaded with  
shared_preload_libraries at startup, and must allocate a unique ID  
shared across all the PostgreSQL extension ecosystem with the following  
wiki page to avoid conflicts:  
https://wiki.postgresql.org/wiki/CustomCumulativeStats  
  
This makes the detection of the stats kinds and their handling when  
reading and writing stats much easier than, say, allocating IDs for  
stats kinds from a shared memory counter, that may change the ID used by  
a stats kind across restarts.  When under development, extensions can  
use PGSTAT_KIND_EXPERIMENTAL.  
  
Two examples that can be used as templates for fixed-numbered and  
variable-numbered stats kinds will be added in some follow-up commits,  
with tests to provide coverage.  
  
Some documentation is added to explain how to use this plugin facility.  
  
Author: Michael Paquier  
Reviewed-by: Dmitry Dolgov, Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/xfunc.sgml
M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_shmem.c
M src/backend/utils/adt/pgstatfuncs.c
M src/include/pgstat.h
M src/include/utils/pgstat_internal.h

Use CXXFLAGS instead of CFLAGS for linking C++ code

commit   : 365b5a345b2680615527b23ee6befa09a2f784f2    
  
author   : Peter Eisentraut <[email protected]>    
date     : Sun, 4 Aug 2024 11:17:46 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Sun, 4 Aug 2024 11:17:46 +0200    

Click here for diff

Otherwise, this would break if using C and C++ compilers from  
different families and they understand different options.  It already  
used the right flags for compiling, this is only for linking.  Also,  
the meson setup already did this correctly.  
  
Reported-by: Tom Lane <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/jit/llvm/Makefile

Fix incorrect format placeholders in pgstat.c

commit   : 028b4b21df26fee67b3ce75c6f14fcfd3c7cf2ee    
  
author   : Michael Paquier <[email protected]>    
date     : Sun, 4 Aug 2024 03:07:20 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Sun, 4 Aug 2024 03:07:20 +0900    

Click here for diff

These should have been switched from %d to %u in 3188a4582a8c in the  
debugging elogs added in ca1ba50fcb6f.  PgStat_Kind should never be  
higher than INT32_MAX, but let's be clean.  
  
Issue noticed while hacking more on this area.  

M src/backend/utils/activity/pgstat.c

Add -Wmissing-variable-declarations to the standard compilation flags

commit   : 66188912566b5614dff095ae86f4b1e06d58e875    
  
author   : Peter Eisentraut <[email protected]>    
date     : Sat, 3 Aug 2024 11:42:37 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Sat, 3 Aug 2024 11:42:37 +0200    

Click here for diff

This warning flag detects global variables not declared in header  
files.  This is similar to what -Wmissing-prototypes does for  
functions.  (More correctly, it is similar to what  
-Wmissing-declarations does for functions, but -Wmissing-prototypes is  
a superset of that in C.)  
  
This flag is new in GCC 14.  Clang has supported it for a while.  
  
Several recent commits have cleaned up warnings triggered by this, so  
it should now be clean.  
  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M configure
M configure.ac
M meson.build
M src/Makefile.global.in
M src/interfaces/ecpg/test/Makefile.regress
M src/interfaces/ecpg/test/meson.build
M src/makefiles/meson.build
M src/tools/pg_bsd_indent/Makefile
M src/tools/pg_bsd_indent/meson.build

Small refactoring around ExecCreateTableAs().

commit   : 7926a9a80f6daf0fcc1feb1bee5c51fd001bc173    
  
author   : Jeff Davis <[email protected]>    
date     : Fri, 2 Aug 2024 11:49:03 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Fri, 2 Aug 2024 11:49:03 -0700    

Click here for diff

Since commit 4b74ebf726, the refresh logic is used to populate  
materialized views, so we can simplify the error message in  
ExecCreateTableAs().  
  
Also, RefreshMatViewByOid() is moved to just after  
create_ctas_nodata() call to improve code readability.  
  
Author: Yugo Nagata  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/createas.c

Fix name of "Visual Studio" in documentation.

commit   : 3cffe7946c268be91a340ec9a27081cb93d67d35    
  
author   : Noah Misch <[email protected]>    
date     : Fri, 2 Aug 2024 12:49:56 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Fri, 2 Aug 2024 12:49:56 -0700    

Click here for diff

Back-patch to v17, which introduced this.  
  
Aleksander Alekseev  
  
Discussion: https://postgr.es/m/CAJ7c6TM7ct0EjoCQaLSVYoxxnEw4xCUFebWj77GktWsqEdyCtQ@mail.gmail.com  

M doc/src/sgml/installation.sgml

Implement pg_wal_replay_wait() stored procedure

commit   : 3c5db1d6b01642bcd8dbf5e34b68f034365747bb    
  
author   : Alexander Korotkov <[email protected]>    
date     : Fri, 2 Aug 2024 21:13:05 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Fri, 2 Aug 2024 21:13:05 +0300    

Click here for diff

pg_wal_replay_wait() is to be used on standby and specifies waiting for  
the specific WAL location to be replayed.  This option is useful when  
the user makes some data changes on primary and needs a guarantee to see  
these changes are on standby.  
  
The queue of waiters is stored in the shared memory as an LSN-ordered pairing  
heap, where the waiter with the nearest LSN stays on the top.  During  
the replay of WAL, waiters whose LSNs have already been replayed are deleted  
from the shared memory pairing heap and woken up by setting their latches.  
  
pg_wal_replay_wait() needs to wait without any snapshot held.  Otherwise,  
the snapshot could prevent the replay of WAL records, implying a kind of  
self-deadlock.  This is why it is only possible to implement  
pg_wal_replay_wait() as a procedure working without an active snapshot,  
not a function.  
  
Catversion is bumped.  
  
Discussion: https://postgr.es/m/eb12f9b03851bb2583adab5df9579b4b%40postgrespro.ru  
Author: Kartyshov Ivan, Alexander Korotkov  
Reviewed-by: Michael Paquier, Peter Eisentraut, Dilip Kumar, Amit Kapila  
Reviewed-by: Alexander Lakhin, Bharath Rupireddy, Euler Taveira  
Reviewed-by: Heikki Linnakangas, Kyotaro Horiguchi  

M doc/src/sgml/func.sgml
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/catalog/system_functions.sql
M src/backend/commands/Makefile
M src/backend/commands/meson.build
A src/backend/commands/waitlsn.c
M src/backend/lib/pairingheap.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/lmgr/proc.c
M src/backend/tcop/pquery.c
M src/backend/utils/activity/wait_event_names.txt
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
A src/include/commands/waitlsn.h
M src/include/lib/pairingheap.h
M src/include/storage/lwlocklist.h
M src/test/recovery/meson.build
A src/test/recovery/t/043_wal_replay_wait.pl
M src/tools/pgindent/typedefs.list

Fix NLS file reference in pg_createsubscriber

commit   : a83f3088b8f409aaee7a939c2847157d97006193    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 2 Aug 2024 12:05:38 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 2 Aug 2024 12:05:38 -0400    

Click here for diff

pg_createsubscriber is referring to a non-existent message translation  
file, causing NLS to not work correctly. This command should use the  
same file as pg_basebackup.  
  
Author: Kyotaro Horiguchi <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_basebackup/pg_createsubscriber.c

pg_createsubscriber: Fix bogus error message

commit   : 3b2f668b785c9b7970d86e7f72a717751d1ddfc2    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 2 Aug 2024 12:01:10 -0400    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 2 Aug 2024 12:01:10 -0400    

Click here for diff

Also some desultory style improvement  

M src/bin/pg_basebackup/pg_createsubscriber.c

Include bison header files into implementation files

commit   : 9fb855fe1ae04a147bd4cdaa571a1c9de5f03682    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 2 Aug 2024 09:59:35 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 2 Aug 2024 09:59:35 +0200    

Click here for diff

Before Bison 3.4, the generated parser implementation files run afoul  
of -Wmissing-variable-declarations (in spite of commit ab61c40bfa2)  
because declarations for yylval and possibly yylloc are missing.  The  
generated header files contain an extern declaration, but the  
implementation files don't include the header files.  Since Bison 3.4,  
the generated implementation files automatically include the generated  
header files, so then it works.  
  
To make this work with older Bison versions as well, include the  
generated header file from the .y file.  
  
(With older Bison versions, the generated implementation file contains  
effectively a copy of the header file pasted in, so including the  
header file is redundant.  But we know this works anyway because the  
core grammar uses this arrangement already.)  
  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M contrib/cube/cubeparse.y
M contrib/seg/segparse.y
M src/backend/bootstrap/bootparse.y
M src/backend/replication/repl_gram.y
M src/backend/replication/syncrep_gram.y
M src/interfaces/ecpg/preproc/ecpg.header
M src/pl/plpgsql/src/pl_gram.y
M src/test/isolation/specparse.y

Minor refactoring of assign_backendlist_entry()

commit   : 63bef4df975cd8b0a3fee1384a80c569043a6d72    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Thu, 1 Aug 2024 23:23:55 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Thu, 1 Aug 2024 23:23:55 +0300    

Click here for diff

Make assign_backendlist_entry() responsible just for allocating the  
Backend struct. Linking it to the RegisteredBgWorker is the caller's  
responsibility now. Seems more clear that way.  
  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/postmaster/postmaster.c

Fix outdated comment; all running bgworkers are in BackendList

commit   : ef4c35b4166e3c99558eba1bc324b2fde61d6ed5    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Thu, 1 Aug 2024 23:23:47 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Thu, 1 Aug 2024 23:23:47 +0300    

Click here for diff

Before commit 8a02b3d732, only bgworkers that connected to a database  
had an entry in the Backendlist. Commit 8a02b3d732 changed that, but  
forgot to update this comment.  
  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/include/postmaster/bgworker_internals.h

Switch PgStat_Kind from an enum to a uint32 type

commit   : 3188a4582a8ce8223fba6e08636d8aaa4cbfd29f    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 2 Aug 2024 04:49:34 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 2 Aug 2024 04:49:34 +0900    

Click here for diff

A follow-up patch is planned to make cumulative statistics pluggable,  
and using a type is useful in the internal routines used by pgstats as  
PgStat_Kind may have a value that was not originally in the enum removed  
here, once made pluggable.  
  
While on it, this commit switches pgstat_is_kind_valid() to use  
PgStat_Kind rather than an int, to be more consistent with its existing  
callers.  Some loops based on the stats kind IDs are switched to use  
PgStat_Kind rather than int, for consistency with the new time.  
  
Author: Michael Paquier  
Reviewed-by: Dmitry Dolgov, Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_shmem.c
M src/include/pgstat.h

Add redo LSN to pgstats files

commit   : b860848232aab440c9ac4c5de3563565e3d2934b    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 2 Aug 2024 01:57:28 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 2 Aug 2024 01:57:28 +0900    

Click here for diff

This is used in the startup process to check that the pgstats file we  
are reading includes the redo LSN referring to the shutdown checkpoint  
where it has been written.  The redo LSN in the pgstats file needs to  
match with what the control file has.  
  
This is intended to be used for an upcoming change that will extend the  
write of the stats file to happen during checkpoints, rather than only  
shutdown sequences.  
  
Bump PGSTAT_FILE_FORMAT_ID.  
  
Reviewed-by: Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/xlog.c
M src/backend/utils/activity/pgstat.c
M src/include/pgstat.h

Convert some extern variables to static, Windows code

commit   : c27090bd605a54d00c808ce1656a097fddd118f7    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 1 Aug 2024 12:41:26 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 1 Aug 2024 12:41:26 +0200    

Click here for diff

Similar to 720b0eaae9b, discovered by MinGW.  

M src/bin/pg_upgrade/parallel.c
M src/bin/pgevent/pgevent.c
M src/common/restricted_token.c
M src/interfaces/libpq/win32.c

Convert an extern variable to static

commit   : 6bbbd7f65f44256a6aea6cb4fd2432a954d37f9e    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 1 Aug 2024 11:59:29 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 1 Aug 2024 11:59:29 +0200    

Click here for diff

Similar to 720b0eaae9b, fixes new code from bd15b7db489.  

M src/bin/pg_dump/pg_dump.c

pg_createsubscriber: Rename option --socket-directory to --socketdir

commit   : c671e142bf4b568434eb8559baff34d32eed5b29    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 1 Aug 2024 12:09:56 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 1 Aug 2024 12:09:56 +0200    

Click here for diff

For consistency with the equivalent option in pg_upgrade.  
  
Reviewed-by: Hayato Kuroda <[email protected]>  
Reviewed-by: Euler Taveira <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/1ed82b9b-8e20-497d-a2f8-aebdd793d595%40eisentraut.org  

M doc/src/sgml/ref/pg_createsubscriber.sgml
M src/bin/pg_basebackup/pg_createsubscriber.c
M src/bin/pg_basebackup/t/040_pg_createsubscriber.pl

Update comment in portal.h.

commit   : e66b32e43b222692feed8015f320b9894a987346    
  
author   : Etsuro Fujita <[email protected]>    
date     : Thu, 1 Aug 2024 17:45:00 +0900    
  
committer: Etsuro Fujita <[email protected]>    
date     : Thu, 1 Aug 2024 17:45:00 +0900    

Click here for diff

We store tuples into the portal's tuple store for a PORTAL_ONE_MOD_WITH  
query as well.  
  
Back-patch to all supported branches.  
  
Reviewed by Andy Fan.  
  
Discussion: https://postgr.es/m/CAPmGK14HVYBZYZtHabjeCd-e31VT%3Dwx6rQNq8QfehywLcpZ2Hw%40mail.gmail.com  

M src/include/utils/portal.h

Convert node test compile-time settings into run-time parameters

commit   : a292c98d62ddc0ad681f772ab91bf68ee399cb4b    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 1 Aug 2024 09:37:44 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 1 Aug 2024 09:37:44 +0200    

Click here for diff

This converts  
  
    COPY_PARSE_PLAN_TREES  
    WRITE_READ_PARSE_PLAN_TREES  
    RAW_EXPRESSION_COVERAGE_TEST  
  
into run-time parameters  
  
    debug_copy_parse_plan_trees  
    debug_write_read_parse_plan_trees  
    debug_raw_expression_coverage_test  
  
They can be activated for tests using PG_TEST_INITDB_EXTRA_OPTS.  
  
The compile-time symbols are kept for build farm compatibility, but  
they now just determine the default value of the run-time settings.  
  
Furthermore, support for these settings is not compiled in at all  
unless assertions are enabled, or the new symbol  
DEBUG_NODE_TESTS_ENABLED is defined at compile time, or any of the  
legacy compile-time setting symbols are defined.  So there is no  
run-time overhead in production builds.  (This is similar to the  
handling of DISCARD_CACHES_ENABLED.)  
  
Discussion: https://www.postgresql.org/message-id/flat/30747bd8-f51e-4e0c-a310-a6e2c37ec8aa%40eisentraut.org  

M .cirrus.tasks.yml
M doc/src/sgml/config.sgml
M src/backend/nodes/README
M src/backend/nodes/read.c
M src/backend/nodes/readfuncs.c
M src/backend/parser/analyze.c
M src/backend/tcop/postgres.c
M src/backend/utils/misc/guc_tables.c
M src/include/nodes/nodes.h
M src/include/nodes/readfuncs.h
M src/include/pg_config_manual.h
M src/include/utils/guc.h

Avoid duplicate table scans for cross-partition updates during logical replication.

commit   : a67da49e1d983fc7662f7854e9eec5debbd14446    
  
author   : Amit Kapila <[email protected]>    
date     : Thu, 1 Aug 2024 10:11:06 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Thu, 1 Aug 2024 10:11:06 +0530    

Click here for diff

When performing a cross-partition update in the apply worker, it  
needlessly scans the old partition twice, resulting in noticeable  
overhead.  
  
This commit optimizes it by removing the redundant table scan.  
  
Author: Hou Zhijie  
Reviewed-by: Hayato Kuroda, Amit Kapila  
Discussion: https://postgr.es/m/OS0PR01MB571623E39984D94CBB5341D994AB2@OS0PR01MB5716.jpnprd01.prod.outlook.com  

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

Evaluate arguments of correlated SubPlans in the referencing ExprState

commit   : a7f107df2b700c859e4d9ad2ca66b07a465d6223    
  
author   : Andres Freund <[email protected]>    
date     : Wed, 31 Jul 2024 18:11:49 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Wed, 31 Jul 2024 18:11:49 -0700    

Click here for diff

Until now we generated an ExprState for each parameter to a SubPlan and  
evaluated them one-by-one ExecScanSubPlan. That's sub-optimal as creating lots  
of small ExprStates  
a) makes JIT compilation more expensive  
b) wastes memory  
c) is a bit slower to execute  
  
This commit arranges to evaluate parameters to a SubPlan as part of the  
ExprState referencing a SubPlan, using the new EEOP_PARAM_SET expression  
step. We emit one EEOP_PARAM_SET for each argument to a subplan, just before  
the EEOP_SUBPLAN step.  
  
It likely is worth using EEOP_PARAM_SET in other places as well, e.g. for  
SubPlan outputs, nestloop parameters and - more ambitiously - to get rid of  
ExprContext->domainValue/caseValue/ecxt_agg*.  But that's for later.  
  
Author: Andres Freund <[email protected]>  
Reviewed-by: Tom Lane <[email protected]>  
Reviewed-by: Alena Rybakina <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/execExpr.c
M src/backend/executor/execExprInterp.c
M src/backend/executor/execProcnode.c
M src/backend/executor/nodeSubplan.c
M src/backend/jit/llvm/llvmjit_expr.c
M src/backend/jit/llvm/llvmjit_types.c
M src/include/executor/execExpr.h
M src/include/nodes/execnodes.h

Revert "Allow parallel workers to cope with a newly-created session user ID."

commit   : e6a9637488e2673efb87f8ead657789e9889fb17    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 31 Jul 2024 20:53:33 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 31 Jul 2024 20:53:33 -0400    

Click here for diff

This reverts commit f5f30c22ed69fb37b896c4d4546b2ab823c3fd61.  
  
Some buildfarm animals are failing with "cannot change  
"client_encoding" during a parallel operation".  It looks like  
assign_client_encoding is unhappy at being asked to roll back a  
client_encoding setting after a parallel worker encounters a  
failure.  There must be more to it though: why didn't I see this  
during local testing?  In any case, it's clear that moving the  
RestoreGUCState() call is not as side-effect-free as I thought.  
Given that the bug f5f30c22e intended to fix has gone unreported  
for years, it's not something that's urgent to fix; I'm not  
willing to risk messing with it further with only days to our  
next release wrap.  

M src/backend/access/transam/parallel.c
M src/backend/commands/variable.c
M src/test/regress/expected/select_parallel.out
M src/test/regress/sql/select_parallel.sql

Add is_create parameter to RefreshMatviewByOid().

commit   : ca2eea3ac89a4ea16ab069cb681510d05de5285f    
  
author   : Jeff Davis <[email protected]>    
date     : Wed, 31 Jul 2024 16:42:19 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Wed, 31 Jul 2024 16:42:19 -0700    

Click here for diff

RefreshMatviewByOid is used for both REFRESH and CREATE MATERIALIZED  
VIEW.  This flag is currently just used for handling internal error  
messages, but also aimed to improve code-readability.  
  
Author: Yugo Nagata  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/createas.c
M src/backend/commands/matview.c
M src/include/commands/matview.h

Remove unused ParamListInfo argument from ExecRefreshMatView.

commit   : f683d3a4ca6dc441a86ed90070f126c20ea46b45    
  
author   : Jeff Davis <[email protected]>    
date     : Wed, 31 Jul 2024 16:15:26 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Wed, 31 Jul 2024 16:15:26 -0700    

Click here for diff

Author: Yugo Nagata  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/createas.c
M src/backend/commands/matview.c
M src/backend/tcop/utility.c
M src/include/commands/matview.h

Allow parallel workers to cope with a newly-created session user ID.

commit   : f5f30c22ed69fb37b896c4d4546b2ab823c3fd61    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 31 Jul 2024 18:54:10 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 31 Jul 2024 18:54:10 -0400    

Click here for diff

Parallel workers failed after a sequence like  
	BEGIN;  
	CREATE USER foo;  
	SET SESSION AUTHORIZATION foo;  
because check_session_authorization could not see the uncommitted  
pg_authid row for "foo".  This is because we ran RestoreGUCState()  
in a separate transaction using an ordinary just-created snapshot.  
The same disease afflicts any other GUC that requires catalog lookups  
and isn't forgiving about the lookups failing.  
  
To fix, postpone RestoreGUCState() into the worker's main transaction  
after we've set up a snapshot duplicating the leader's.  This affects  
check_transaction_isolation and check_transaction_deferrable, which  
think they should only run during transaction start.  Make them  
act like check_transaction_read_only, which already knows it should  
silently accept the value when InitializingParallelWorker.  
  
Per bug #18545 from Andrey Rachitskiy.  Back-patch to all  
supported branches, because this has been wrong for awhile.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/parallel.c
M src/backend/commands/variable.c
M src/test/regress/expected/select_parallel.out
M src/test/regress/sql/select_parallel.sql

Improve performance of dumpSequenceData().

commit   : bd15b7db489deadb2d9af7f21d16a6ed4a09465b    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 31 Jul 2024 10:12:42 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 31 Jul 2024 10:12:42 -0500    

Click here for diff

As one might guess, this function dumps the sequence data.  It is  
called once per sequence, and each such call executes a query to  
retrieve the relevant data for a single sequence.  This can cause  
pg_dump to take significantly longer, especially when there are  
many sequences.  
  
This commit improves the performance of this function by gathering  
all the sequence data with a single query at the beginning of  
pg_dump.  This information is stored in a sorted array that  
dumpSequenceData() can bsearch() for what it needs.  This follows a  
similar approach as previous commits that introduced sorted arrays  
for role information, pg_class information, and sequence metadata.  
As with those commits, this patch will cause pg_dump to use more  
memory, but that isn't expected to be too egregious.  
  
Note that we use the brand new function pg_sequence_read_tuple() in  
the query that gathers all sequence data, so we must continue to  
use the preexisting query-per-sequence approach for versions older  
than 18.  
  
Reviewed-by: Euler Taveira, Michael Paquier, Tom Lane  
Discussion: https://postgr.es/m/20240503025140.GA1227404%40nathanxps13  

M src/bin/pg_dump/pg_dump.c

Introduce pg_sequence_read_tuple().

commit   : c8b06bb969bf26c01f10b835e59d0aff39b7f516    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 31 Jul 2024 10:12:42 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 31 Jul 2024 10:12:42 -0500    

Click here for diff

This new function returns the data for the given sequence, i.e.,  
the values within the sequence tuple.  Since this function is a  
substitute for SELECT from the sequence, the SELECT privilege is  
required on the sequence in question.  It returns all NULLs for  
sequences for which we lack privileges, other sessions' temporary  
sequences, and unlogged sequences on standbys.  
  
This function is primarily intended for use by pg_dump in a  
follow-up commit that will use it to optimize dumpSequenceData().  
Like pg_sequence_last_value(), which is a support function for the  
pg_sequences system view, pg_sequence_read_tuple() is left  
undocumented.  
  
Bumps catversion.  
  
Reviewed-by: Michael Paquier, Tom Lane  
Discussion: https://postgr.es/m/20240503025140.GA1227404%40nathanxps13  

M src/backend/commands/sequence.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

Improve performance of dumpSequence().

commit   : 68e9629985981ce8f8f04b5a9f8b3781eacaafd6    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 31 Jul 2024 10:12:42 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 31 Jul 2024 10:12:42 -0500    

Click here for diff

This function dumps the sequence definitions.  It is called once  
per sequence, and each such call executes a query to retrieve the  
metadata for a single sequence.  This can cause pg_dump to take  
significantly longer, especially when there are many sequences.  
  
This commit improves the performance of this function by gathering  
all the sequence metadata with a single query at the beginning of  
pg_dump.  This information is stored in a sorted array that  
dumpSequence() can bsearch() for what it needs.  This follows a  
similar approach as commits d5e8930f50 and 2329cad1b9, which  
introduced sorted arrays for role information and pg_class  
information, respectively.  As with those commits, this patch will  
cause pg_dump to use more memory, but that isn't expected to be too  
egregious.  
  
Note that before version 10, the sequence metadata was stored in  
the sequence relation itself, which makes it difficult to gather  
all the sequence metadata with a single query.  For those older  
versions, we continue to use the preexisting query-per-sequence  
approach.  
  
Reviewed-by: Euler Taveira  
Discussion: https://postgr.es/m/20240503025140.GA1227404%40nathanxps13  

M src/bin/pg_dump/pg_dump.c
M src/tools/pgindent/typedefs.list

Parse sequence type and integer metadata in dumpSequence().

commit   : 23687e925f94e36d2d3172faa053f4540bfbb8d2    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 31 Jul 2024 10:12:41 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 31 Jul 2024 10:12:41 -0500    

Click here for diff

This commit modifies dumpSequence() to parse all the sequence  
metadata into the appropriate types instead of carting around  
string pointers to the PGresult data.  Besides allowing us to free  
the PGresult storage earlier in the function, this eliminates the  
need to compare min_value and max_value to their respective  
defaults as strings.  
  
This is preparatory work for a follow-up commit that will improve  
the performance of dumpSequence() in a similar manner to how commit  
2329cad1b9 optimized binary_upgrade_set_pg_class_oids().  
  
Reviewed-by: Euler Taveira  
Discussion: https://postgr.es/m/20240503025140.GA1227404%40nathanxps13  

M src/bin/pg_dump/pg_dump.c
M src/tools/pgindent/typedefs.list

Doc: mention executor memory usage for enable_partitionwise* GUCs

commit   : 057ee9183c2142f6ecd9035aa6b96c5509c18a27    
  
author   : David Rowley <[email protected]>    
date     : Thu, 1 Aug 2024 01:25:25 +1200    
  
committer: David Rowley <[email protected]>    
date     : Thu, 1 Aug 2024 01:25:25 +1200    

Click here for diff

Prior to this commit, the docs for enable_partitionwise_aggregate and  
enable_partitionwise_join mentioned the additional overheads enabling  
these causes for the query planner, but they mentioned nothing about the  
possible surge in work_mem-consuming executor nodes that could end up in  
the final plan.  Dimitrios reported the OOM killer intervened on his  
query as a result of using enable_partitionwise_aggregate=on.  
  
Here we adjust the docs to mention the possible increase in the number of  
work_mem-consuming executor nodes that can appear in the final plan as a  
result of enabling these GUCs.  
  
Reported-by: Dimitrios Apostolou  
Reviewed-by: Ashutosh Bapat  
Discussion: https://postgr.es/m/3603c380-d094-136e-e333-610914fb3e80%40gmx.net  
Discussion: https://postgr.es/m/CAApHDvoZ0_yqwPFEpb6h261L76BUpmh5GxBQq0LeRzQ5Jh3zzg@mail.gmail.com  
Backpatch-through: 12, oldest supported version  

M doc/src/sgml/config.sgml

Add API and ABI stability guidance to the C language docs

commit   : e54a42ac9d49ef9cd660d1bf55f09c88bb841ee9    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 31 Jul 2024 11:08:28 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 31 Jul 2024 11:08:28 +0200    

Click here for diff

Includes guidance for major and minor version releases, and sets  
reasonable expectations for extension developers to follow.  
  
Author: David Wheeler, Peter Eisentraut  
  
Discussion: https://www.postgresql.org/message-id/flat/5DA9F9D2-B8B2-43DE-BD4D-53A4160F6E8D%40justatheory.com  

M doc/src/sgml/xfunc.sgml

doc: Avoid too prominent use of "backup" on pg_dump man page

commit   : 4f29394ea941f688fd4faf7260d2c198931ca797    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 31 Jul 2024 07:57:47 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 31 Jul 2024 07:57:47 +0200    

Click here for diff

Some users inadvertently rely on pg_dump as their primary backup tool,  
when better solutions exist.  The pg_dump man page is arguably  
misleading in that it starts with  
  
"pg_dump is a utility for backing up a PostgreSQL database."  
  
This tones this down a little bit, by replacing most uses of "backup"  
with "export" and adding a short note that pg_dump is not a  
general-purpose backup tool.  
  
Discussion: https://www.postgresql.org/message-id/flat/70b48475-7706-4268-990d-fd522b038d96%40eisentraut.org  

M doc/src/sgml/ref/pg_dump.sgml
M doc/src/sgml/ref/pg_restore.sgml

Make building with LTO work on macOS

commit   : 73275f093f8969f4d2353fcc803377350aa650f6    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 31 Jul 2024 06:22:02 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 31 Jul 2024 06:22:02 +0200    

Click here for diff

When building with -flto, the backend binary must keep many otherwise  
unused symbols to make them available to dynamically loaded modules /  
extensions.  This has been done via -Wl,--export-dynamic on many  
platforms for years.  This flag is not supported by the macOS linker,  
though.  Here it's called -Wl,-export_dynamic instead.  
  
Thus, make configure pick up on this variant of the flag as well.  
Meson has the logic upstream as of version 1.5.0.  
  
Without this fix, building with -flto fails with errors similar to [1]  
and [2].  
  
[1]: https://postgr.es/m/1581936537572-0.post%40n3.nabble.com  
[2]: https://postgr.es/m/21800.1499270547%40sss.pgh.pa.us  
  
Author: Wolfgang Walther <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M configure
M configure.ac

Fix random failure in 021_twophase.

commit   : 0dcea330babd46402f6ca3ea3a552829c99bbe5e    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 31 Jul 2024 08:53:55 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 31 Jul 2024 08:53:55 +0530    

Click here for diff

After disabling the subscription, the failed test was changing the  
two_phase option for the subscription. We can't change the two_phase  
option for a subscription till the corresponding apply worker is active.  
The check to ensure that the replication apply worker has exited was  
incorrect.  
  
Author: Vignesh C  
Discussion: https://postgr.es/m/CALDaNm3YY+bzj+JWJbY+DsUgJ2mPk8OR1ttjVX2cywKr4BUgxw@mail.gmail.com  

M src/test/subscription/t/021_twophase.pl

Relax check for return value from second call of pg_strnxfrm().

commit   : 679c5084cf210c6e958276b657039e8ba0c077c0    
  
author   : Jeff Davis <[email protected]>    
date     : Tue, 30 Jul 2024 16:23:20 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Tue, 30 Jul 2024 16:23:20 -0700    

Click here for diff

strxfrm() is not guaranteed to return the exact number of bytes needed  
to store the result; it may return a higher value.  
  
Discussion: https://postgr.es/m/[email protected]  
Reviewed-by: Heikki Linnakangas  
Backpatch-through: 16  

M src/backend/access/hash/hashfunc.c
M src/backend/utils/adt/pg_locale.c
M src/backend/utils/adt/varchar.c

Refactor getWeights to write to caller-supplied buffer

commit   : f822be39629cd24a8ad1f8f6aa444e0c9ae1eaad    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 22:06:07 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 22:06:07 +0300    

Click here for diff

This gets rid of the static result buffer.  
  
Reviewed-by: Robert Haas  
Discussion: https://www.postgresql.org/message-id/[email protected]  

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

Replace static buf with a stack-allocated one in 'seg' extension

commit   : 01e51ed78070703c7e078f1519ad59af38e2888a    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 22:06:03 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 22:06:03 +0300    

Click here for diff

The buffer is used only locally within the function. Also, the  
initialization to '0' characters was unnecessary, the initial content  
were always overwritten with sprintf(). I don't understand why it was  
done that way, but it's been like that since forever.  
  
In the passing, change from sprintf() to snprintf(). The buffer was  
long enough so sprintf() was fine, but this makes it more obvious that  
there's no risk of a buffer overflow.  
  
Reviewed-by: Robert Haas  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M contrib/seg/segparse.y

Replace static buf with a stack-allocated one in ReadControlFile

commit   : da8a587e2e225be1ccf838a330e342bda6848874    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 22:05:59 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 22:05:59 +0300    

Click here for diff

It's only used very locally within the function.  
  
Reviewed-by: Robert Haas  
Discussion: https://www.postgresql.org/message-id/[email protected]  

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

Replace static buf with palloc in str_time()

commit   : 6151cb7876136ad23748f4f724309166bbfad3e0    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 22:05:51 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 22:05:51 +0300    

Click here for diff

The function is used only once in the startup process, so the leak  
into current memory context is harmless.  
  
This is a tiny step in making the server thread-safe.  
  
Reviewed-by: Robert Haas  
Discussion: https://www.postgresql.org/message-id/[email protected]  

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

Replace static bufs with a StringInfo in cash_words()

commit   : 5bf948d564e36553d2a1cda3244a52d054238af4    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 22:02:58 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 22:02:58 +0300    

Click here for diff

For clarity. The code was correct, and the buffer was large enough,  
but string manipulation with no bounds checking is scary.  
  
This incurs an extra palloc+pfree to every call, but in quick  
performance testing, it doesn't seem to be significant.  
  
Reviewed-by: Robert Haas  
Discussion: https://www.postgresql.org/message-id/[email protected]  

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

Remove leftover function declaration

commit   : 47c98035c6fbff01724b9a646196c92b99faa6bf    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 15:19:46 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 30 Jul 2024 15:19:46 +0300    

Click here for diff

Commit 9d9b9d46f3 removed the function (or rather, moved it to a  
different source file and renamed it to SendCancelRequest), but forgot  
the declaration in the header file.  

M src/include/postmaster/postmaster.h

Preserve tz when converting to jsonb timestamptz

commit   : 524d490a9f4ab81d86bbedc6e429fbc27776351c    
  
author   : Andrew Dunstan <[email protected]>    
date     : Tue, 30 Jul 2024 07:57:38 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Tue, 30 Jul 2024 07:57:38 -0400    

Click here for diff

This removes an inconsistency in the treatment of different datatypes by  
the jsonpath timestamp_tz() function. Conversions from data types that  
are not timestamp-aware, such as date and timestamp, are now treated  
consistently with conversion from those that are such as timestamptz.  
  
Author: David Wheeler  
Reviewed-by: Junwang Zhao and Jeevan Chalke  
  
Discussion: https://postgr.es/m/7DE080CE-6D8C-4794-9BD1-7D9699172FAB%40justatheory.com  
  
Backpatch to release 17.  

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

Remove spinlocks and atomics from meson_options.txt.

commit   : 06ffce4559d0f7d29e0d92d18b72b4b96772ad1c    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 23:31:56 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 23:31:56 +1200    

Click here for diff

Commits e2562667 and 81385261 removed the configure equivalents, but  
forgot to remove these options from meson_options.txt.  
  
Revealed by the fact that build farm animals rorqual and francolin  
didn't fail, despite being configured to set those options to off.  They  
should now fail with unknown option, until they are adjusted.  

M meson_options.txt

Remove useless member of BackendParameters.

commit   : 71d6c4b966ae8699103548107312275fc8029fc2    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 23:15:09 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 23:15:09 +1200    

Click here for diff

Oversight in e2562667, which stopped using SpinlockSemaArray but forgot  
to remove it from the array.  
  
Reported-by: Heikki Linnakangas <[email protected]>  
Discussion: https://postgr.es/m/310f4005-91d7-42b2-ac70-92624260dd28%40iki.fi  

M src/backend/postmaster/launch_backend.c

Require memory barrier support.

commit   : 83aadbeb96f019fff88e6a06615fe0a86c6956ca    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 22:16:50 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 22:16:50 +1200    

Click here for diff

Previously we had a fallback implementation that made a harmless system  
call, based on the assumption that system calls must contain a memory  
barrier.  That shouldn't be reached on any current system, and it seems  
highly likely that we can easily find out how to request explicit memory  
barriers, if we've already had to find out how to do atomics on a  
hypothetical new system.  
  
Removed comments and a function name referred to a spinlock used for  
fallback memory barriers, but that changed in 1b468a13, which left some  
misleading words behind in a few places.  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Suggested-by: Andres Freund <[email protected]>  
Discussion: https://postgr.es/m/721bf39a-ed8a-44b0-8b8e-be3bd81db748%40technowledgy.de  
Discussion: https://postgr.es/m/3351991.1697728588%40sss.pgh.pa.us  

M src/backend/port/atomics.c
M src/include/port/atomics.h
M src/include/port/atomics/fallback.h
M src/include/port/atomics/generic.h

Require compiler barrier support.

commit   : a011dc399cc82be07326c89c926bd5880160b1ba    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 22:12:42 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 22:12:42 +1200    

Click here for diff

Previously we had a fallback implementation of pg_compiler_barrier()  
that called an empty function across a translation unit boundary so the  
compiler couldn't see what it did.  That shouldn't be needed on any  
current systems, and might not even work with a link time optimizer.  
Since we now require compiler-specific knowledge of how to implement  
atomics, we should also know how to implement compiler barriers on a  
hypothetical new system.  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Suggested-by: Andres Freund <[email protected]>  
Discussion: https://postgr.es/m/721bf39a-ed8a-44b0-8b8e-be3bd81db748%40technowledgy.de  
Discussion: https://postgr.es/m/3351991.1697728588%40sss.pgh.pa.us  

M src/backend/port/atomics.c
M src/include/port/atomics.h
M src/include/port/atomics/fallback.h

Remove --disable-atomics, require 32 bit atomics.

commit   : 81385261362962deb9861b39b509aeffe213721d    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 21:52:46 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 21:52:46 +1200    

Click here for diff

Modern versions of all relevant architectures and tool chains have  
atomics support.  Since edadeb07, there is no remaining reason to carry  
code that simulates atomic flags and uint32 imperfectly with spinlocks.  
64 bit atomics are still emulated with spinlocks, if needed, for now.  
  
Any modern compiler capable of implementing C11 <stdatomic.h> must have  
the underlying operations we need, though we don't require C11 yet.  We  
detect certain compilers and architectures, so hypothetical new systems  
might need adjustments here.  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Reviewed-by: Tom Lane <[email protected]> (concept, not the patch)  
Reviewed-by: Andres Freund <[email protected]> (concept, not the patch)  
Discussion: https://postgr.es/m/3351991.1697728588%40sss.pgh.pa.us  

M configure
M configure.ac
M doc/src/sgml/installation.sgml
M meson.build
M src/backend/port/atomics.c
M src/include/pg_config.h.in
M src/include/port/atomics.h
M src/include/port/atomics/arch-x86.h
M src/include/port/atomics/fallback.h
M src/include/port/atomics/generic-gcc.h
M src/include/port/atomics/generic-msvc.h
M src/include/port/atomics/generic-sunpro.h

Remove --disable-spinlocks.

commit   : e25626677f8076eb3ce94586136c5464ee154381    
  
author   : Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 21:45:01 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Tue, 30 Jul 2024 21:45:01 +1200    

Click here for diff

A later change will require atomic support, so it wouldn't make sense  
for a hypothetical new system not to be able to implement spinlocks.  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Reviewed-by: Tom Lane <[email protected]> (concept, not the patch)  
Reviewed-by: Andres Freund <[email protected]> (concept, not the patch)  
Discussion: https://postgr.es/m/3351991.1697728588%40sss.pgh.pa.us  

M configure
M configure.ac
M doc/src/sgml/installation.sgml
M meson.build
M src/backend/port/atomics.c
M src/backend/port/posix_sema.c
M src/backend/port/sysv_sema.c
M src/backend/postmaster/launch_backend.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/lmgr/Makefile
M src/backend/storage/lmgr/meson.build
M src/backend/storage/lmgr/s_lock.c
D src/backend/storage/lmgr/spin.c
M src/include/pg_config.h.in
M src/include/pg_config_manual.h
M src/include/port/atomics.h
M src/include/port/atomics/fallback.h
M src/include/storage/s_lock.h
M src/include/storage/spin.h
M src/test/regress/regress.c

pg_createsubscriber: Remove obsolete comment

commit   : 1330843bb78e9d2422af2f2b9909b80732bd6fc0    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 30 Jul 2024 12:21:20 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 30 Jul 2024 12:21:20 +0200    

Click here for diff

This comment should have been removed by commit b9639138262.  There is  
no replication slot check on the primary anymore.  
  
Author: Euler Taveira <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/bin/pg_basebackup/pg_createsubscriber.c

Stabilize xid_wraparound tests

commit   : 800cd3e923597172a29aba49da45753f52996ee8    
  
author   : Andrew Dunstan <[email protected]>    
date     : Tue, 30 Jul 2024 06:17:48 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Tue, 30 Jul 2024 06:17:48 -0400    

Click here for diff

The tests had a race condition if autovacuum was set to off. Instead we  
create all the tables we are interested in with autovacuum disabled, so  
they are only ever touched when in danger of wraparound.  
  
Discussion: https://postgr.es/m/[email protected]  
  
Masahiko Sawada (slightly tweaked by me)  
  
Backpatch to release 17 where these tests were introduced.  

M src/test/modules/xid_wraparound/t/001_emergency_vacuum.pl
M src/test/modules/xid_wraparound/t/002_limits.pl
M src/test/modules/xid_wraparound/t/003_wraparounds.pl

pg_createsubscriber: Fix an unpredictable recovery wait time.

commit   : 03b08c8f5f3e30c97e5908f3d3d76872dab8a9dc    
  
author   : Amit Kapila <[email protected]>    
date     : Tue, 30 Jul 2024 14:01:01 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Tue, 30 Jul 2024 14:01:01 +0530    

Click here for diff

The problem is that the tool is using the LSN returned by  
pg_create_logical_replication_slot() as recovery_target_lsn. This LSN is  
ahead of the current WAL position and the recovery waits until the  
publisher writes a WAL record to reach the target and ends the recovery.  
On idle systems, this wait time is unpredictable and could lead to failure  
in promoting the subscriber. To avoid that, insert a harmless WAL record.  
  
Reported-by: Alexander Lakhin and Tom Lane  
Diagnosed-by: Hayato Kuroda  
Author: Euler Taveira  
Reviewed-by: Hayato Kuroda, Amit Kapila  
Backpatch-through: 17  
Discussion: https://postgr.es/m/2377319.1719766794%40sss.pgh.pa.us  
Discussion: https://postgr.es/m/CA+TgmoYcY+Wb67NAwaHT7MvxCSeV86oSc+va9hHKaasE42ukyw@mail.gmail.com  

M src/bin/pg_basebackup/pg_createsubscriber.c

Disallow setting MAX_PARTITION_BUFFERS to less than 2

commit   : c19615fe391c9577e2129fed4429736f6b5295da    
  
author   : David Rowley <[email protected]>    
date     : Tue, 30 Jul 2024 20:19:59 +1200    
  
committer: David Rowley <[email protected]>    
date     : Tue, 30 Jul 2024 20:19:59 +1200    

Click here for diff

Add some comments to mention that this value must be at least 2 and also  
add a StaticAssertDecl to cause compilation failure if anyone tries to  
build with an invalid value.  
  
The multiInsertBuffers list must have at least two elements due to how the  
code in CopyMultiInsertInfoFlush() pushes the current ResultRelInfo's  
CopyMultiInsertBuffer to the end of the list.  If the first element is  
also the last element, bad things will happen.  
  
Author: Zhang Mingli <[email protected]>  
Discussion: https://postgr.es/m/CAApHDvpQ6t9ROcqbD-OgqR04Kfq4vQKw79Vo6r5j%2BciHwsSfkA%40mail.gmail.com  

M src/backend/commands/copyfrom.c

Make collation not depend on setlocale().

commit   : 72fe6d24a38c88e112d5e63a8e907c3e96ae46ad    
  
author   : Jeff Davis <[email protected]>    
date     : Tue, 30 Jul 2024 00:58:06 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Tue, 30 Jul 2024 00:58:06 -0700    

Click here for diff

Now that the result of pg_newlocale_from_collation() is always  
non-NULL, then we can move the collate_is_c and ctype_is_c flags into  
pg_locale_t. That simplifies the logic in lc_collate_is_c() and  
lc_ctype_is_c(), removing the dependence on setlocale().  
  
This commit also eliminates the multi-stage initialization of the  
collation cache.  
  
As long as we have catalog access, then it's now safe to call  
pg_newlocale_from_collation() without checking lc_collate_is_c()  
first.  
  
Discussion: https://postgr.es/m/[email protected]  
Reviewed-by: Peter Eisentraut, Andreas Karlsson  

M src/backend/utils/adt/pg_locale.c
M src/include/utils/pg_locale.h
M src/test/regress/expected/collate.utf8.out
M src/test/regress/sql/collate.utf8.sql

Fix partitionwise join with partially-redundant join clauses

commit   : 9b282a9359a12831c087eba7f0f5f0b1dba7b7eb    
  
author   : Richard Guo <[email protected]>    
date     : Tue, 30 Jul 2024 15:51:54 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Tue, 30 Jul 2024 15:51:54 +0900    

Click here for diff

To determine if the two relations being joined can use partitionwise  
join, we need to verify the existence of equi-join conditions  
involving pairs of matching partition keys for all partition keys.  
Currently we do that by looking through the join's restriction  
clauses.  However, it has been discovered that this approach is  
insufficient, because there might be partition keys known equal by a  
specific EC, but they do not form a join clause because it happens  
that other members of the EC than the partition keys are constrained  
to become a join clause.  
  
To address this issue, in addition to examining the join's restriction  
clauses, we also check if any partition keys are known equal by ECs,  
by leveraging function exprs_known_equal().  To accomplish this, we  
enhance exprs_known_equal() to check equality per the semantics of the  
opfamily, if provided.  
  
It could be argued that exprs_known_equal() could be called O(N^2)  
times, where N is the number of partition key expressions, resulting  
in noticeable performance costs if there are a lot of partition key  
expressions.  But I think this is not a problem.  The number of a  
joinrel's partition key expressions would only be equal to the join  
degree, since each base relation within the join contributes only one  
partition key expression.  That is to say, it does not scale with the  
number of partitions.  A benchmark with a query involving 5-way joins  
of partitioned tables, each with 3 partition keys and 1000 partitions,  
shows that the planning time is not significantly affected by this  
patch (within the margin of error), particularly when compared to the  
impact caused by partitionwise join.  
  
Thanks to Tom Lane for the idea of leveraging exprs_known_equal() to  
check if partition keys are known equal by ECs.  
  
Author: Richard Guo, Tom Lane  
Reviewed-by: Tom Lane, Ashutosh Bapat, Robert Haas  
Discussion: https://postgr.es/m/CAN_9JTzo_2F5dKLqXVtDX5V6dwqB0Xk+ihstpKEt3a1LT6X78A@mail.gmail.com  

M src/backend/optimizer/path/equivclass.c
M src/backend/optimizer/util/relnode.c
M src/backend/utils/adt/selfuncs.c
M src/include/optimizer/paths.h
M src/test/regress/expected/partition_join.out
M src/test/regress/sql/partition_join.sql

Refactor the checks for parameterized partial paths

commit   : 2309eff62b463fb3f19e6dd229243902b3b44501    
  
author   : Richard Guo <[email protected]>    
date     : Tue, 30 Jul 2024 15:49:44 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Tue, 30 Jul 2024 15:49:44 +0900    

Click here for diff

Parameterized partial paths are not supported, and we have several  
checks in try_partial_xxx_path functions to enforce this.  For a  
partial nestloop join path, we need to ensure that if the inner path  
is parameterized, the parameterization is fully satisfied by the  
proposed outer path.  For a partial merge/hashjoin join path, we need  
to ensure that the inner path is not parameterized.  In all cases, we  
need to ensure that the outer path is not parameterized.  
  
However, the comment in try_partial_hashjoin_path does not describe  
this correctly.  This patch fixes that.  
  
In addtion, this patch simplifies the checks peformed in  
try_partial_hashjoin_path and try_partial_mergejoin_path with the help  
of macro PATH_REQ_OUTER, and also adds asserts that the outer path is  
not parameterized in try_partial_xxx_path functions.  
  
Author: Richard Guo  
Discussion: https://postgr.es/m/CAMbWs48mKJ6g_GnYNa7dnw04MHaMK-jnAEBrMVhTp2uUg3Ut4A@mail.gmail.com  

M src/backend/optimizer/path/joinpath.c

Short-circuit sort_inner_and_outer if there are no mergejoin clauses

commit   : cc9daa09eee927c17b9409ff42fc7a0b7d6fbd9a    
  
author   : Richard Guo <[email protected]>    
date     : Tue, 30 Jul 2024 15:46:39 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Tue, 30 Jul 2024 15:46:39 +0900    

Click here for diff

In sort_inner_and_outer, we create mergejoin join paths by explicitly  
sorting both relations on each possible ordering of the available  
mergejoin clauses.  However, if there are no available mergejoin  
clauses, we can skip this process entirely.  
  
This patch introduces a check for mergeclause_list at the beginning of  
sort_inner_and_outer and exits the function if it is found to be  
empty.  This might help skip all the statements that come before the  
call to select_outer_pathkeys_for_merge, including the build of  
UniquePaths in the case of JOIN_UNIQUE_OUTER or JOIN_UNIQUE_INNER.  
  
I doubt there's any measurable performance improvement, but throughout  
the run of the regression tests, sort_inner_and_outer is called a  
total of 44,424 times.  Among these calls, there are 11,064 instances  
where mergeclause_list is found to be empty, which accounts for  
approximately one-fourth.  I think this suggests that implementing  
this shortcut is worthwhile.  
  
Author: Richard Guo  
Reviewed-by: Ashutosh Bapat  
Discussion: https://postgr.es/m/CAMbWs48RKiZGFEd5A0JtztRY5ZdvVvNiHh0AKeuoz21F+0dVjQ@mail.gmail.com  

M src/backend/optimizer/path/joinpath.c

Add more debugging information when failing to read pgstats files

commit   : ca1ba50fcb6f85ac603aecbc184c7c59886c2a7c    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 30 Jul 2024 15:08:21 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 30 Jul 2024 15:08:21 +0900    

Click here for diff

This is useful to know which part of a stats file is corrupted when  
reading it, adding to the server logs a WARNING with details about what  
could not be read before giving up with the remaining data in the file.  
  
Author: Michael Paquier  
Reviewed-by: Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/activity/pgstat.c

SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE

commit   : 7f56eaff2fb0f3541c5c6ef8c1099e7f0618b461    
  
author   : Amit Langote <[email protected]>    
date     : Tue, 30 Jul 2024 10:12:23 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Tue, 30 Jul 2024 10:12:23 +0900    

Click here for diff

The current method of coercing the boolean result value of  
JsonPathExists() to the target type specified for an EXISTS column,  
which is to call the type's input function via json_populate_type(),  
leads to an error when the target type is integer, because the  
integer input function doesn't recognize boolean literal values as  
valid.  
  
Instead use the boolean-to-integer cast function for coercion in that  
case so that using integer or domains thereof as type for EXISTS  
columns works. Note that coercion for ON ERROR values TRUE and FALSE  
already works like that because the parser creates a cast expression  
including the cast function, but the coercion of the actual result  
value is not handled by the parser.  
  
Tests by Jian He.  
  
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
M src/include/executor/execExpr.h
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/sql/sqljson_jsontable.sql

SQL/JSON: Some fixes to JsonBehavior expression casting

commit   : 74c96699be3f53c058c8794c07952221b9625b4f    
  
author   : Amit Langote <[email protected]>    
date     : Tue, 30 Jul 2024 10:11:23 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Tue, 30 Jul 2024 10:11:23 +0900    

Click here for diff

1. Remove the special case handling when casting the JsonBehavior  
   expressions to types with typmod, like 86d33987 did for the casting  
   of SQL/JSON constructor functions.  
  
2. Fix casting for fixed-length character and bit string types by  
   using assignment-level casts.  This is again similar to what  
   86d33987 did, but for ON ERROR / EMPTY expressions.  
  
3. Use runtime coercion for the boolean ON ERROR constants so that  
   using fixed-length character string types, for example, for an  
   EXISTS column doesn't cause a "value too long for type  
   character(n)" when the parser tries to coerce the default ON ERROR  
   value "false" to that type, that is, even when clause is not  
   specified.  
  
4. Simplify the conditions of when to use runtime coercion vs  
   creating the cast expression in the parser itself.  jsonb-valued  
   expressions are now always coerced at runtime and boolean  
   expressions too if the target type is a string type for the  
   reasons mentioned above.  
  
Tests are taken from a patch that Jian He posted.  
  
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/parser/parse_expr.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/expected/sqljson_queryfuncs.out
M src/test/regress/sql/sqljson_jsontable.sql
M src/test/regress/sql/sqljson_queryfuncs.sql

Do not return NULL from pg_newlocale_from_collation().

commit   : 8240401437c8e261b4ae95fcc4183db98339cc9e    
  
author   : Jeff Davis <[email protected]>    
date     : Mon, 29 Jul 2024 15:15:11 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Mon, 29 Jul 2024 15:15:11 -0700    

Click here for diff

Previously, pg_newlocale_from_collation() returned NULL as a special  
case for the DEFAULT_COLLATION_OID if the provider was libc. In that  
case the behavior would depend on the last call to setlocale().  
  
Now, consistent with the other providers, it will return a pointer to  
default_locale, which is not dependent on setlocale().  
  
Note: for the C and POSIX locales, the locale_t structure within the  
pg_locale_t will still be zero, because those locales are implemented  
with internal logic and do not use libc at all.  
  
lc_collate_is_c() and lc_ctype_is_c() still depend on setlocale() to  
determine the current locale, which will be removed in a subsequent  
commit.  
  
Discussion: https://postgr.es/m/[email protected]  
Reviewed-by: Peter Eisentraut, Andreas Karlsson  

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

Detach syslogger from shared memory

commit   : 6a1d8cef46e654bdc645e9c32412f707471aff2a    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 22:21:34 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 22:21:34 +0300    

Click here for diff

Commit aafc05de1b removed the calls to detach from shared memory from  
syslogger startup. That was not intentional, so put them back.  
  
Author: Rui Zhao  
Reviewed-by: Aleksander Alekseev  
Backpatch-through: 17  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/postmaster/launch_backend.c

Remove dead generators for cyrillic encoding conversion tables

commit   : 679f940740f42f2401f72a6b95dc02b9c0ab3f30    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 20:38:19 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 20:38:19 +0300    

Click here for diff

These tools were used to read the koi-iso.tab, koi-win.tab, and  
koi-alt.tab files, which contained the mappings between the  
single-byte cyrillic encodings. However, those data files were removed  
in commit 4c3c8c048d, back in 2003. These code generators have been  
unused and unusable ever since.  
  
The generated tables live in cyrillic_and_mic.c. There has been one  
change to the tables since they were generated in 1999, in commit  
f4b7624eb07a. So if we resurrected the original data tables, that  
change would need to be taken into account.  
  
So this code is very dead. The tables in cyrillic_and_mic.c, which  
were originally generated by these tools, are now the authoritative  
source for these mappings.  
  
Reviewed-by: Tom Lane, Aleksander Alekseev  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/utils/mb/README
D src/backend/utils/mb/iso.c
D src/backend/utils/mb/win1251.c
D src/backend/utils/mb/win866.c

Remove tab completion for CREATE UNLOGGED MATERIALIZED VIEW.

commit   : 5c1ce1bbbe5fb8ac2fb1725a980caeed64d7a33e    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 29 Jul 2024 11:34:12 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 29 Jul 2024 11:34:12 -0500    

Click here for diff

Commit 3bf3ab8c56 added support for unlogged materialized views,  
but commit 3223b25ff7 reverted that feature before it made it into  
a release.  However, the latter commit left the grammar and  
tab-completion support intact.  This commit removes the  
tab-completion support to prevent psql from recommending bogus  
commands.  I've opted to keep the grammar support so that the  
server continues to emit a descriptive error when users try to  
create unlogged matviews.  
  
Reported-by: Daniel Westermann, px shi  
Author: Dagfinn Ilmari Mannsåker  
Discussion: https://postgr.es/m/ZR0P278MB092093E92263DE16734208A5D2C59%40ZR0P278MB0920.CHEP278.PROD.OUTLOOK.COM  
Discussion: https://postgr.es/m/CAAccyY%2BWg1Z-9tNfSwLmuZVgGOwqU5u1OP-RWcoAr2UZGuvN_w%40mail.gmail.com  

M src/bin/psql/tab-complete.c

Count individual SQL commands in pg_restore's --transaction-size mode.

commit   : 0f129052150487afab9fe64889c5bf7534f7bbc3    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 29 Jul 2024 12:17:24 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 29 Jul 2024 12:17:24 -0400    

Click here for diff

The initial implementation in commit 959b38d77 counted one action  
per TOC entry (except for some special cases for multi-blob BLOBS  
entries).  This assumes that TOC entries are all about equally  
complex, but it turns out that that assumption doesn't hold up very  
well in binary-upgrade mode.  For example, even after the previous  
commit I was able to cause backend bloat with tables having many  
inherited constraints.  There may be other cases too.  (Since no  
serious problems have been reported with --single-transaction mode,  
we can conclude that the backend copes well with psql's regular  
restore scripts; but before 959b38d77 we never ran binary-upgrade  
restores with multi-command transactions.)  
  
To fix, count multi-command TOC entries as N actions, allowing the  
transaction size to be scaled down when we hit a complex TOC entry.  
Rather than add a SQL parser to pg_restore, approximate "multi  
command" by counting semicolons in the TOC entry's defn string.  
This will be fooled by semicolons appearing in string literals ---  
but the error is in the conservative direction, so it doesn't seem  
worth working harder.  The biggest risk is with function/procedure  
TOC entries, but we can just explicitly skip those.  
  
(This is undoubtedly a hack, and maybe someday we'll be able to  
revert it after fixing the backend's bloat issues or rethinking  
what pg_dump emits in binary upgrade mode.  But that surely isn't  
a project for v17.)  
  
Thanks to Alexander Korotkov for the let's-count-semicolons idea.  
  
Per report from Justin Pryzby.  Back-patch to v17 where txn_size mode  
was introduced.  
  
Discussion: https://postgr.es/m/ZqEND4ZcTDBmcv31@pryzbyj2023  

M src/bin/pg_dump/pg_backup_archiver.c

Reduce number of commands dumpTableSchema emits for binary upgrade.

commit   : b3f0e0503f333938df638a8f499909ce4901b40c    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 29 Jul 2024 11:53:49 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 29 Jul 2024 11:53:49 -0400    

Click here for diff

Avoid issuing a separate SQL UPDATE command for each column when  
directly manipulating pg_attribute contents in binary upgrade mode.  
With the separate updates, we triggered a relcache invalidation with  
each update.  For a table with N columns, that causes O(N^2) relcache  
bloat in txn_size mode because the table's newly-created relcache  
entry can't be flushed till end of transaction.  Reducing the number  
of commands should make it marginally faster as well as avoiding that  
problem.  
  
While at it, likewise avoid issuing a separate UPDATE on pg_constraint  
for each inherited constraint.  This is less exciting, first because  
inherited (non-partitioned) constraints are relatively rare, and  
second because the backend has a good deal of trouble anyway with  
restoring tables containing many such constraints, due to  
MergeConstraintsIntoExisting being horribly inefficient.  But it seems  
more consistent to do it this way here too, and it surely can't hurt.  
  
In passing, fix one place in dumpTableSchema that failed to use ONLY  
in ALTER TABLE.  That's not a live bug, but it's inconsistent.  
Also avoid silently casting away const from string literals.  
  
Per report from Justin Pryzby.  Back-patch to v17 where txn_size mode  
was introduced.  
  
Discussion: https://postgr.es/m/ZqEND4ZcTDBmcv31@pryzbyj2023  

M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/t/002_pg_dump.pl

Fix double-release of spinlock

commit   : 0393f542d72c6182271c392d9a83d0fc775113c7    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 18:17:33 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 18:17:33 +0300    

Click here for diff

Commit 9d9b9d46f3 added spinlocks to protect the fields in ProcSignal  
flags, but in EmitProcSignalBarrier(), the spinlock was released  
twice. With most spinlock implementations, releasing a lock that's not  
held is not easy to notice, because most of the time it does nothing,  
but if the spinlock was concurrently acquired by another process, it  
could lead to more serious issues. Fortunately, with the  
--disable-spinlocks emulation implementation, it caused more visible  
failures.  
  
In the passing, fix a type in comment and add an assertion that the  
procNumber passed to SendProcSignal looks valid.  
  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/storage/ipc/procsignal.c

Fix compiler warning/error about typedef redefinitions

commit   : 8bda213ec1628737b500b6b04ec164aec354eb04    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 16:23:30 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 16:23:30 +0300    

Click here for diff

Per buildfarm member 'sifaka':  
  
    procsignal.c:87:3: error: redefinition of typedef 'ProcSignalHeader' is a C11 feature [-Werror,-Wtypedef-redefinition]  

M src/backend/storage/ipc/procsignal.c

Move cancel key generation to after forking the backend

commit   : 9d9b9d46f3c509c722ebbf2a1e7dc6296a6c711d    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 15:37:48 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 15:37:48 +0300    

Click here for diff

Move responsibility of generating the cancel key to the backend  
process. The cancel key is now generated after forking, and the  
backend advertises it in the ProcSignal array. When a cancel request  
arrives, the backend handling it scans the ProcSignal array to find  
the target pid and cancel key. This is similar to how this previously  
worked in the EXEC_BACKEND case with the ShmemBackendArray, just  
reusing the ProcSignal array.  
  
One notable change is that we no longer generate cancellation keys for  
non-backend processes. We generated them before just to prevent a  
malicious user from canceling them; the keys for non-backend processes  
were never actually given to anyone. There is now an explicit flag  
indicating whether a process has a valid key or not.  
  
I wrote this originally in preparation for supporting longer cancel  
keys, but it's a nice cleanup on its own.  
  
Reviewed-by: Jelte Fennema-Nio  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/postmaster/auxprocess.c
M src/backend/postmaster/launch_backend.c
M src/backend/postmaster/postmaster.c
M src/backend/storage/ipc/ipci.c
M src/backend/storage/ipc/procsignal.c
M src/backend/tcop/backend_startup.c
M src/backend/tcop/postgres.c
M src/backend/utils/init/globals.c
M src/backend/utils/init/postinit.c
M src/include/miscadmin.h
M src/include/postmaster/postmaster.h
M src/include/storage/procsignal.h

Fix outdated comment in smgrtruncate()

commit   : 19de089cdc23373e2f36916017a1e23e8ff4c2f8    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 14:23:23 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 29 Jul 2024 14:23:23 +0300    

Click here for diff

Commit c5315f4f44 replaced smgr_fsm_nblocks and smgr_vm_nblocks with  
smgr_cached_nblocks, but forgot to update this comment.  
  
Author: Kirill Reshke  
Discussion: https://www.postgresql.org/message-id/CALdSSPh9VA6SDSVjrcmSPEYramf%[email protected]  

M src/backend/storage/smgr/smgr.c

Reduce memory used by partitionwise joins

commit   : 513f4472a4a0d294ca64123627ce7b48ce0ee7c1    
  
author   : Richard Guo <[email protected]>    
date     : Mon, 29 Jul 2024 11:35:51 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Mon, 29 Jul 2024 11:35:51 +0900    

Click here for diff

In try_partitionwise_join, we aim to break down the join between two  
partitioned relations into joins between matching partitions.  To  
achieve this, we iterate through each pair of partitions from the two  
joining relations and create child-join relations for them.  With  
potentially thousands of partitions, the local objects allocated in  
each iteration can accumulate significant memory usage.  Therefore, we  
opt to eagerly free these local objects at the end of each iteration.  
  
In line with this approach, this patch frees the bitmap set that  
represents the relids of child-join relations at the end of each  
iteration.  Additionally, it modifies build_child_join_rel() to reuse  
the AppendRelInfo structures generated within each iteration.  
  
Author: Ashutosh Bapat  
Reviewed-by: David Christensen, Richard Guo  
Discussion: https://postgr.es/m/CAExHW5s4EqY43oB=ne6B2=-xLgrs9ZGeTr1NXwkGFt2j-OmaQQ@mail.gmail.com  

M src/backend/optimizer/path/joinrels.c
M src/backend/optimizer/util/relnode.c
M src/include/optimizer/pathnode.h

Simplify create_merge_append_path for clarity

commit   : f47b33a19115f432ad80777db0d1350d23bb6cf5    
  
author   : Richard Guo <[email protected]>    
date     : Mon, 29 Jul 2024 11:33:18 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Mon, 29 Jul 2024 11:33:18 +0900    

Click here for diff

We don't currently support parameterized MergeAppend paths: there's  
little use for an ordered path on the inside of a nestloop.  Given  
this, we can simplify create_merge_append_path by directly setting  
param_info to NULL instead of calling get_appendrel_parampathinfo.  We  
can also simplify the Assert for child paths a little bit.  
  
This change won't make any measurable difference in performance; it's  
just for clarity's sake.  
  
Author: Richard Guo  
Reviewed-by: Alena Rybakina, Paul A Jungwirth  
Discussion: https://postgr.es/m/CAMbWs4_n1bgH2nACMuGsXZct3KH6PBFS0tPdQsXdstRfyxTunQ@mail.gmail.com  

M src/backend/optimizer/util/pathnode.c

Refactor pg_set_regex_collation() for clarity.

commit   : 2e68077b07cc597ef6bdfacffb5acbd17e179237    
  
author   : Jeff Davis <[email protected]>    
date     : Sun, 28 Jul 2024 16:55:17 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Sun, 28 Jul 2024 16:55:17 -0700    

Click here for diff

Discussion: https://postgr.es/m/[email protected]  
Reviewed-by: Andreas Karlsson  

M src/backend/regex/regc_pg_locale.c

Add missing pointer dereference in pg_backend_memory_contexts view

commit   : da87dc07f16e7435edc601661a6ec71b38bccd25    
  
author   : David Rowley <[email protected]>    
date     : Mon, 29 Jul 2024 09:53:10 +1200    
  
committer: David Rowley <[email protected]>    
date     : Mon, 29 Jul 2024 09:53:10 +1200    

Click here for diff

32d3ed816 moved the logic for setting the context's name and ident into  
a reusable function.  I missed adding a pointer dereference after  
copying and pasting the code into that function.  The ident parameter is  
a pointer to the ident variable in the calling function, so the  
dereference is required to correctly determine if the contents of that  
variable is NULL or not.  
  
In passing, adjust the if condition to include an == NULL to make it  
more clear that it's not checking for == '\0'.  
  
Reported-by: Tom Lane, Coverity  
Discussion: https://postgr.es/m/[email protected]  

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

Fix whitespace in commit 005c6b833f.

commit   : c0ef1234dfb68bb0b5c926c0eafd82881ad78374    
  
author   : Jeff Davis <[email protected]>    
date     : Sun, 28 Jul 2024 13:34:52 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Sun, 28 Jul 2024 13:34:52 -0700    

Click here for diff

M src/backend/utils/adt/pg_locale.c
M src/tools/pgindent/typedefs.list

Refactor: make default_locale internal to pg_locale.c.

commit   : 1c461a8d8d3c7a4655fdb944ffca94b1e49e5b3d    
  
author   : Jeff Davis <[email protected]>    
date     : Sun, 28 Jul 2024 13:07:25 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Sun, 28 Jul 2024 13:07:25 -0700    

Click here for diff

Discussion: https://postgr.es/m/[email protected]  
Reviewed-by: Peter Eisentraut, Andreas Karlsson  

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

Change collation cache to use simplehash.h.

commit   : 005c6b833f7866b71b50a5382e30d6c3f695306e    
  
author   : Jeff Davis <[email protected]>    
date     : Sun, 28 Jul 2024 12:39:57 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Sun, 28 Jul 2024 12:39:57 -0700    

Click here for diff

Speeds up text comparison expressions when using a collation other  
than the database default collation. Does not affect larger operations  
such as ORDER BY, because the lookup is only done once.  
  
Discussion: https://postgr.es/m/[email protected]  
Reviewed-by: John Naylor, Andreas Karlsson  

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

amcheck: Optimize speed of checking for unique constraint violation

commit   : cdd6ab9d1f5396ec1097d51c21a224aa41118c9c    
  
author   : Alexander Korotkov <[email protected]>    
date     : Sun, 28 Jul 2024 13:50:57 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Sun, 28 Jul 2024 13:50:57 +0300    

Click here for diff

Currently, when amcheck validates a unique constraint, it visits the heap for  
each index tuple.  This commit implements skipping keys, which have only one  
non-dedeuplicated index tuple (quite common case for unique indexes). That  
gives substantial economy on index checking time.  
  
Reported-by: Noah Misch  
Discussion: https://postgr.es/m/20240325020323.fd.nmisch%40google.com  
Author: Alexander Korotkov, Pavel Borisov  

M contrib/amcheck/verify_nbtree.c

Fix incorrect return value for pg_size_pretty(bigint)

commit   : b181062aa5727a013c96b64476f884c992b5068d    
  
author   : David Rowley <[email protected]>    
date     : Sun, 28 Jul 2024 22:22:52 +1200    
  
committer: David Rowley <[email protected]>    
date     : Sun, 28 Jul 2024 22:22:52 +1200    

Click here for diff

pg_size_pretty(bigint) would return the value in bytes rather than PB  
for the smallest-most bigint value.  This happened due to an incorrect  
assumption that the absolute value of -9223372036854775808 could be  
stored inside a signed 64-bit type.  
  
Here we fix that by instead storing that value in an unsigned 64-bit type.  
  
This bug does exist in versions prior to 15 but the code there is  
sufficiently different and the bug seems sufficiently non-critical that  
it does not seem worth risking backpatching further.  
  
Author: Joseph Koshakow <[email protected]>  
Discussion: https://postgr.es/m/CAAvxfHdTsMZPWEHUrZ=h3cky9Ccc3Mtx2whUHygY+ABP-mCmUw@mail.gmail.com  
Backpatch-through: 15  

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

libpq: Use strerror_r instead of strerror

commit   : 1e666fd7c6d3bff658cdbad02b4e7bb77dde391d    
  
author   : Peter Eisentraut <[email protected]>    
date     : Sun, 28 Jul 2024 09:12:00 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Sun, 28 Jul 2024 09:12:00 +0200    

Click here for diff

Commit 453c4687377 introduced a use of strerror() into libpq, but that  
is not thread-safe.  Fix by using strerror_r() instead.  
  
In passing, update some of the code comments added by 453c4687377, as  
we have learned more about the reason for the change in OpenSSL that  
started this.  
  
Reviewed-by: Daniel Gustafsson <[email protected]>  
Discussion: Discussion: https://postgr.es/m/[email protected]  

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

Doc: fix text's description of regexp_replace's arguments.

commit   : da4017a694de0610bd5b3a54adda311e46e26300    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 27 Jul 2024 15:38:54 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 27 Jul 2024 15:38:54 -0400    

Click here for diff

Section 9.7.3 had a syntax synopsis for regexp_replace()  
that was different from Table 9.10's, but still wrong.  
Update that one too.  Oversight in 580f8727c.  
  
Jian He  
  
Discussion: https://postgr.es/m/CACJufxG3NFKKsh6x4fRLv8h3V-HvN4W5dA=zNKMxsNcDwOKang@mail.gmail.com  

M doc/src/sgml/func.sgml

Optimize escaping of JSON strings

commit   : 17a5871d9d58ea639b6d1ba4f0ce58462d55a33c    
  
author   : David Rowley <[email protected]>    
date     : Sat, 27 Jul 2024 23:46:07 +1200    
  
committer: David Rowley <[email protected]>    
date     : Sat, 27 Jul 2024 23:46:07 +1200    

Click here for diff

There were quite a few places where we either had a non-NUL-terminated  
string or a text Datum which we needed to call escape_json() on.  Many of  
these places required that a temporary string was created due to the fact  
that escape_json() needs a NUL-terminated cstring.  For text types, those  
first had to be converted to cstring before calling escape_json() on them.  
  
Here we introduce two new functions to make escaping JSON more optimal:  
  
escape_json_text() can be given a text Datum to append onto the given  
buffer.  This is more optimal as it foregoes the need to convert the text  
Datum into a cstring.  A temporary allocation is only required if the text  
Datum needs to be detoasted.  
  
escape_json_with_len() can be used when the length of the cstring is  
already known or the given string isn't NUL-terminated.  Having this  
allows various places which were creating a temporary NUL-terminated  
string to just call escape_json_with_len() without any temporary memory  
allocations.  
  
Discussion: https://postgr.es/m/CAApHDvpLXwMZvbCKcdGfU9XQjGCDm7tFpRdTXuB9PVgpNUYfEQ@mail.gmail.com  
Reviewed-by: Melih Mutlu, Heikki Linnakangas  

M contrib/hstore/hstore_io.c
M src/backend/backup/backup_manifest.c
M src/backend/utils/adt/json.c
M src/backend/utils/adt/jsonb.c
M src/backend/utils/adt/jsonfuncs.c
M src/backend/utils/adt/jsonpath.c
M src/include/utils/json.h

Support falling back to non-preferred readline implementation with meson

commit   : 67427f10093a9c50c79e1dbfdcd1698433e8a88f    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Sat, 27 Jul 2024 13:53:16 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Sat, 27 Jul 2024 13:53:16 +0300    

Click here for diff

To build with -Dreadline=enabled one can use either readline or  
libedit. The -Dlibedit_preferred flag is supposed to control the order  
of names to lookup.  This works fine when either both libraries are  
present or -Dreadline is set to auto. However, explicitly enabling  
readline with only libedit present, but not setting libedit_preferred,  
or alternatively enabling readline with only readline present, but  
setting libedit_preferred, too, are both broken. This is because  
cc.find_library will throw an error for a not found dependency as soon  
as the first required dependency is checked, thus it's impossible to  
fallback to the alternative.  
  
Here we only check the second of the two dependencies for  
requiredness, thus we only fail when none of the two can be found.  
  
Author: Wolfgang Walther  
Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut  
Reviewed-by: Tristan Partin  
Discussion: https://www.postgresql.org/message-id/[email protected]  
Backpatch: 16-, where meson support was added  

M meson.build

Support absolute bindir/libdir in regression tests with meson

commit   : ff34ae368bdb11f9f66e22a4d79e2a179b3a6f0e    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Sat, 27 Jul 2024 13:53:14 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Sat, 27 Jul 2024 13:53:14 +0300    

Click here for diff

Passing an absolute bindir/libdir will install the binaries and  
libraries to <build>/tmp_install/<bindir> and  
<build>/tmp_install/<libdir> respectively.  
  
This path is correctly passed to the regression test suite via  
configure/make, but not via meson, yet. This is because the "/"  
operator in the following expression throws away the whole left side  
when the right side is an absolute path:  
  
    test_install_location / get_option('libdir')  
  
This was already correctly handled for dir_prefix, which is likely  
absolute as well. This patch handles both bindir and libdir in the  
same way - prefixing absolute paths with the tmp_install path  
correctly.  
  
Author: Wolfgang Walther  
Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut  
Reviewed-by: Tristan Partin  
Discussion: https://www.postgresql.org/message-id/[email protected]  
Backpatch: 16-, where meson support was added  

M meson.build

Fallback to clang in PATH with meson

commit   : 4d8de281b5834c8f5e0be6ae21e884e69dffd4ce    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Sat, 27 Jul 2024 13:53:11 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Sat, 27 Jul 2024 13:53:11 +0300    

Click here for diff

Some distributions put clang into a different path than the llvm  
binary path.  
  
For example, this is the case on NixOS / nixpkgs, which failed to find  
clang with meson before this patch.  
  
Author: Wolfgang Walther  
Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut  
Reviewed-by: Tristan Partin  
Discussion: https://www.postgresql.org/message-id/[email protected]  
Backpatch: 16-, where meson support was added  

M meson.build

Fallback to uuid for ossp-uuid with meson

commit   : a00fae9d43e5adabc56e64a4df6d332062666501    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Sat, 27 Jul 2024 13:53:08 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Sat, 27 Jul 2024 13:53:08 +0300    

Click here for diff

The upstream name for the ossp-uuid package / pkg-config file is  
"uuid". Many distributions change this to be "ossp-uuid" to not  
conflict with e2fsprogs.  
  
This lookup fails on distributions which don't change this name, for  
example NixOS / nixpkgs. Both "ossp-uuid" and "uuid" are also checked  
in configure.ac.  
  
Author: Wolfgang Walther  
Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut  
Reviewed-by: Tristan Partin  
Discussion: https://www.postgresql.org/message-id/[email protected]  
Backpatch: 16-, where meson support was added  

M meson.build

Fix more holes with SLRU code in need of int64 for segment numbers

commit   : c9e24573905bef7fc3e4efb02bdb4d0cc8e43c51    
  
author   : Michael Paquier <[email protected]>    
date     : Sat, 27 Jul 2024 07:16:52 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Sat, 27 Jul 2024 07:16:52 +0900    

Click here for diff

This is a continuation of 3937cadfd438, taking care of more areas I have  
managed to miss previously.  
  
Reported-by: Noah Misch  
Reviewed-by: Noah Misch  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 17  

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

Introduce num_os_semaphores GUC.

commit   : 0dcaea56903489e8abedf231f286272495c3beb4    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 26 Jul 2024 15:28:55 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 26 Jul 2024 15:28:55 -0500    

Click here for diff

The documentation for System V IPC parameters provides complicated  
formulas to determine the appropriate values for SEMMNI and SEMMNS.  
Furthermore, these formulas have often been wrong because folks  
forget to update them (e.g., when adding a new auxiliary process).  
  
This commit introduces a new runtime-computed GUC named  
num_os_semaphores that reports the number of semaphores needed for  
the configured number of allowed connections, worker processes,  
etc.  This new GUC allows us to simplify the formulas in the  
documentation, and it should help prevent future inaccuracies.  
Like the other runtime-computed GUCs, users can view it with  
"postgres -C" before starting the server, which is useful for  
preconfiguring the necessary operating system resources.  
  
Reviewed-by: Tom Lane, Sami Imseih, Andres Freund, Robert Haas  
Discussion: https://postgr.es/m/20240517164452.GA1914161%40nathanxps13  

M doc/src/sgml/config.sgml
M doc/src/sgml/runtime.sgml
M src/backend/storage/ipc/ipci.c
M src/backend/utils/misc/guc_tables.c

Wait for WAL summarization to catch up before creating .partial file.

commit   : 8a53539bd603e5fe8fa52bdbb7277f6f49724522    
  
author   : Robert Haas <[email protected]>    
date     : Fri, 26 Jul 2024 14:50:21 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Fri, 26 Jul 2024 14:50:21 -0400    

Click here for diff

When a standby is promoted, CleanupAfterArchiveRecovery() may decide  
to rename the final WAL file from the old timeline by adding ".partial"  
to the name. If WAL summarization is enabled and this file is renamed  
before its partial contents are summarized, WAL summarization breaks:  
the summarizer gets stuck at that point in the WAL stream and just  
errors out.  
  
To fix that, first make the startup process wait for WAL summarization  
to catch up before renaming the file. Generally, this should be quick,  
and if it's not, the user can shut off summarize_wal and try again.  
To make this fix work, also teach the WAL summarizer that after a  
promotion has occurred, no more WAL can appear on the previous  
timeline: previously, the WAL summarizer wouldn't switch to the new  
timeline until we actually started writing WAL there, but that meant  
that when the startup process was waiting for the WAL summarizer, it  
was waiting for an action that the summarizer wasn't yet prepared to  
take.  
  
In the process of fixing these bugs, I realized that the logic to wait  
for WAL summarization to catch up was spread out in a way that made  
it difficult to reuse properly, so this code refactors things to make  
it easier.  
  
Finally, add a test case that would have caught this bug and the  
previously-fixed bug that WAL summarization sometimes needs to back up  
when the timeline changes.  
  
Discussion: https://postgr.es/m/CA+TgmoZGEsZodXC4f=XZNkAeyuDmWTSkpkjCEOcF19Am0mt_OA@mail.gmail.com  

M src/backend/access/transam/xlog.c
M src/backend/backup/basebackup_incremental.c
M src/backend/postmaster/walsummarizer.c
M src/bin/pg_combinebackup/meson.build
A src/bin/pg_combinebackup/t/008_promote.pl
M src/include/access/xlog.h
M src/include/postmaster/walsummarizer.h

postgres_fdw: Fix bug in connection status check.

commit   : 454aab4b738e53a5dbfca9251a7807a2ad21f87e    
  
author   : Fujii Masao <[email protected]>    
date     : Sat, 27 Jul 2024 03:05:47 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Sat, 27 Jul 2024 03:05:47 +0900    

Click here for diff

The buildfarm member "hake" reported a failure in the regression test  
added by commit 857df3cef7, where postgres_fdw_get_connections(true)  
returned unexpected results.  
  
The function postgres_fdw_get_connections(true) checks  
if a connection is closed by using POLLRDHUP in the requested events  
and calling poll(). Previously, the function only considered  
POLLRDHUP or 0 as valid returned events. However, poll() can also  
return POLLHUP, POLLERR, and/or POLLNVAL. So if any of these events  
were returned, postgres_fdw_get_connections(true) would report  
incorrect results. postgres_fdw_get_connections(true) failed to  
account for these return events.  
  
This commit updates postgres_fdw_get_connections(true) to correctly  
report a closed connection when poll() returns not only POLLRDHUP  
but also POLLHUP, POLLERR, or POLLNVAL.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/postgres_fdw/connection.c

pg_upgrade: Move live_check variable to user_opts.

commit   : 4b56bb4ab4856070d5ea4aeafdd663d8bf96b874    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 26 Jul 2024 13:37:32 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 26 Jul 2024 13:37:32 -0500    

Click here for diff

At the moment, pg_upgrade stores whether it is doing a "live check"  
(i.e., the user specified --check and the old server is still  
running) in a local variable scoped to main().  This live_check  
variable is passed to several functions.  To further complicate  
matters, a few call sites provide a hard-coded "false" as the  
live_check argument.  Specifically, this is done when calling these  
functions for the new cluster, for which any live-check-only paths  
won't apply.  
  
This commit moves the live_check variable to the global user_opts  
variable, which stores information about the options the user  
specified on the command line.  This allows us to remove the  
live_check parameter from several functions.  For the functions  
with callers that provide a hard-coded "false" as the live_check  
argument (e.g., get_control_data()), we verify the given cluster is  
the old cluster before taking any live-check-only paths.  
  
This small refactoring effort helps simplify some proposed changes  
that would parallelize many of pg_upgrade's once-in-each-database  
tasks using libpq's asynchronous APIs.  By removing the live_check  
parameter, we can more easily convert the functions to callbacks  
for the new parallel system.  
  
Reviewed-by: Daniel Gustafsson  
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13  

M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/controldata.c
M src/bin/pg_upgrade/info.c
M src/bin/pg_upgrade/option.c
M src/bin/pg_upgrade/pg_upgrade.c
M src/bin/pg_upgrade/pg_upgrade.h

commit   : 5d1d8b3c82c2a796bf7d89f2a5785ce9424acab1    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 26 Jul 2024 12:39:45 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 26 Jul 2024 12:39:45 -0400    

Click here for diff

We restrict typed tables (those declared as "OF composite_type")  
to be based on stand-alone composite types, not composite types  
that are the implicitly-created rowtypes of other tables.  
But if you tried to do that, you got the very confusing error  
message "type foo is not a composite type".  Provide a more specific  
message for that case.  Also clarify related documentation in the  
CREATE TABLE man page.  
  
Erik Wienhold and David G. Johnston, per complaint from Hannu Krosing.  
  
Discussion: https://postgr.es/m/CAMT0RQRysCb_Amy5CTENSc5GfsvXL1a4qX3mv_hx31_v74P==g@mail.gmail.com  

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

Fix indentation.

commit   : c883453cb29cb40c1e59c3c54d159c5e744da8a9    
  
author   : Robert Haas <[email protected]>    
date     : Fri, 26 Jul 2024 11:59:34 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Fri, 26 Jul 2024 11:59:34 -0400    

Click here for diff

M src/backend/postmaster/walsummarizer.c

Fix macro placement in pg_config.h.in

commit   : 161c73462bf2b9845371d785eac21e32f8fdcae0    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Fri, 26 Jul 2024 16:25:28 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Fri, 26 Jul 2024 16:25:28 +0200    

Click here for diff

Commit 274bbced85383e831dde accidentally placed the pg_config.h.in  
for SSL_CTX_set_num_tickets on the wrong line wrt where autoheader  
places it.  Fix by re-arranging and backpatch to the same level as  
the original commit.  
  
Reported-by: Marina Polyakova <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: v12  

M src/include/pg_config.h.in

Allow WAL summarization to back up when timeline changes.

commit   : cf8a4898360bbb70a0f9eec7bac8bcb4fcb7aa42    
  
author   : Robert Haas <[email protected]>    
date     : Fri, 26 Jul 2024 09:50:31 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Fri, 26 Jul 2024 09:50:31 -0400    

Click here for diff

The old code believed that it was not possible to switch timelines  
without first replaying all of the WAL from the old timeline, but  
that turns out to be false, as demonstrated by an example from Fujii  
Masao. As a result, it assumed that summarization would always  
continue from the LSN where summarization previously ended. But in  
fact, when a timeline switch occurs without replaying all the WAL  
from the previous timeline, we can need to back up to an earlier  
LSN. Adjust accordingly.  
  
Discussion: https://postgr.es/m/CA+TgmoZGEsZodXC4f=XZNkAeyuDmWTSkpkjCEOcF19Am0mt_OA@mail.gmail.com  

M src/backend/postmaster/walsummarizer.c

postgres_fdw: Add connection status check to postgres_fdw_get_connections().

commit   : 857df3cef7be93f7b9214c926e7af6f06a8cf23e    
  
author   : Fujii Masao <[email protected]>    
date     : Fri, 26 Jul 2024 22:16:39 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Fri, 26 Jul 2024 22:16:39 +0900    

Click here for diff

This commit extends the postgres_fdw_get_connections() function  
to check if connections are closed. This is useful for detecting closed  
postgres_fdw connections that could prevent successful transaction  
commits. Users can roll back transactions immediately upon detecting  
closed connections, avoiding unnecessary processing of failed  
transactions.  
  
This feature is available only on systems supporting the non-standard  
POLLRDHUP extension to the poll system call, including Linux.  
  
Author: Hayato Kuroda  
Reviewed-by: Shinya Kato, Zhihong Yu, Kyotaro Horiguchi, Andres Freund  
Reviewed-by: Onder Kalaci, Takamichi Osumi, Vignesh C, Tom Lane, Ted Yu  
Reviewed-by: Katsuragi Yuta, Peter Smith, Shubham Khanna, Fujii Masao  
Discussion: https://postgr.es/m/TYAPR01MB58662809E678253B90E82CE5F5889@TYAPR01MB5866.jpnprd01.prod.outlook.com  

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

postgres_fdw: Add "used_in_xact" column to postgres_fdw_get_connections().

commit   : c297a47c5f8da78d976e8c3f790dbeeb6a21a853    
  
author   : Fujii Masao <[email protected]>    
date     : Fri, 26 Jul 2024 22:15:51 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Fri, 26 Jul 2024 22:15:51 +0900    

Click here for diff

This commit extends the postgres_fdw_get_connections() function to  
include a new used_in_xact column, indicating whether each connection  
is used in the current transaction.  
  
This addition is particularly useful for the upcoming feature that  
will check if connections are closed. By using those information,  
users can verify if postgres_fdw connections used in a transaction  
remain open. If any connection is closed, the transaction cannot  
be committed successfully. In this case users can roll back it  
immediately without waiting for transaction end.  
  
The SQL API for postgres_fdw_get_connections() is updated by  
this commit and may change in the future. To handle compatibility  
with older SQL declarations, an API versioning system is introduced,  
allowing the function to behave differently based on the API version.  
  
Author: Hayato Kuroda  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M contrib/postgres_fdw/Makefile
M contrib/postgres_fdw/connection.c
M contrib/postgres_fdw/expected/postgres_fdw.out
M contrib/postgres_fdw/meson.build
A contrib/postgres_fdw/postgres_fdw–1.1–1.2.sql
M contrib/postgres_fdw/postgres_fdw.control
M doc/src/sgml/postgres-fdw.sgml

pg_createsubscriber: Message style improvements

commit   : 5687f8c0dd766acb15587a0af8b5208aa3841b21    
  
author   : Peter Eisentraut <[email protected]>    
date     : Fri, 26 Jul 2024 14:45:13 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Fri, 26 Jul 2024 14:45:13 +0200    

Click here for diff

Refactor some messages, improve quoting.  

M src/bin/pg_basebackup/pg_createsubscriber.c

Add tests for errors during SSL or GSSAPI handshake

commit   : ef7fa900fb587cbaac9f3e943f789155b97aa02b    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 26 Jul 2024 15:12:23 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 26 Jul 2024 15:12:23 +0300    

Click here for diff

These test that libpq correctly falls back to a plaintext connection  
on handshake error, in the "prefer" modes.  
  
Reviewed-by: Michael Paquier  
Discussion: https://www.postgresql.org/message-id/CAOYmi%2Bnwvu21mJ4DYKUa98HdfM_KZJi7B1MhyXtnsyOO-PB6Ww%40mail.gmail.com  

M src/backend/libpq/be-secure-gssapi.c
M src/backend/libpq/be-secure.c
M src/interfaces/libpq/t/005_negotiate_encryption.pl

Add test for early backend startup errors

commit   : 20e0e7da9bc0089433c70b2b53ddf6a340ab5df3    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 26 Jul 2024 15:12:21 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 26 Jul 2024 15:12:21 +0300    

Click here for diff

The new test tests the libpq fallback behavior on an early error,  
which was fixed in the previous commit.  
  
This adds an IS_INJECTION_POINT_ATTACHED() macro, to allow writing  
injected test code alongside the normal source code. In principle, the  
new test could've been implemented by an extra test module with a  
callback that sets the FrontendProtocol global variable, but I think  
it's more clear to have the test code right where the injection point  
is, because it has pretty intimate knowledge of the surrounding  
context it runs in.  
  
Reviewed-by: Michael Paquier  
Discussion: https://www.postgresql.org/message-id/CAOYmi%2Bnwvu21mJ4DYKUa98HdfM_KZJi7B1MhyXtnsyOO-PB6Ww%40mail.gmail.com  

M doc/src/sgml/xfunc.sgml
M src/backend/tcop/backend_startup.c
M src/backend/utils/misc/injection_point.c
M src/include/utils/injection_point.h
M src/interfaces/libpq/Makefile
M src/interfaces/libpq/meson.build
M src/interfaces/libpq/t/005_negotiate_encryption.pl

Fix using injection points at backend startup in EXEC_BACKEND mode

commit   : b9e5249c29354186576d8fc00609fe7eaf7c8d25    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 26 Jul 2024 14:55:04 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 26 Jul 2024 14:55:04 +0300    

Click here for diff

Commit 86db52a506 changed the locking of injection points to use only  
atomic ops and spinlocks, to make it possible to define injection  
points in processes that don't have a PGPROC entry (yet). However, it  
didn't work in EXEC_BACKEND mode, because the pointer to shared memory  
area was not initialized until the process "attaches" to all the  
shared memory structs. To fix, pass the pointer to the child process  
along with other global variables that need to be set up early.  
  
Backpatch-through: 17  

M src/backend/postmaster/launch_backend.c
M src/backend/utils/misc/injection_point.c
M src/include/utils/injection_point.h

Fix fallback behavior when server sends an ERROR early at startup

commit   : c95d2159c1dd3f269383a9bd830e1c804dba34c8    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 26 Jul 2024 14:52:08 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 26 Jul 2024 14:52:08 +0300    

Click here for diff

With sslmode=prefer, the desired behavior is to completely fail the  
connection attempt, *not* fall back to a plaintext connection, if the  
server responds to the SSLRequest with an error ('E') response instead  
of rejecting SSL with an 'N' response. This was broken in commit  
05fd30c0e7.  
  
Reported-by: Jacob Champion  
Reviewed-by: Michael Paquier  
Discussion: https://www.postgresql.org/message-id/CAOYmi%2Bnwvu21mJ4DYKUa98HdfM_KZJi7B1MhyXtnsyOO-PB6Ww%40mail.gmail.com  
Backpatch-through: 17  

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

doc: Enhance documentation for postgres_fdw_get_connections() output columns.

commit   : 284c030a10b838bb016e8c2de56ae9b845a6b30e    
  
author   : Fujii Masao <[email protected]>    
date     : Fri, 26 Jul 2024 20:47:05 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Fri, 26 Jul 2024 20:47:05 +0900    

Click here for diff

The documentation previously described the output columns of  
postgres_fdw_get_connections() in text format, which was manageable  
for the original two columns. However, upcoming patches will add  
new columns, making text descriptions less readable.  
  
This commit updates the documentation to use a table format,  
making it easier for users to understand each output column.  
  
Author: Fujii Masao, Hayato Kuroda  
Reviewed-by: Hayato Kuroda  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/postgres-fdw.sgml

Disable all TLS session tickets

commit   : 274bbced85383e831ddeb9d83a8af74c4992e7a1    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Fri, 26 Jul 2024 11:09:45 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Fri, 26 Jul 2024 11:09:45 +0200    

Click here for diff

OpenSSL supports two types of session tickets for TLSv1.3, stateless  
and stateful. The option we've used only turns off stateless tickets  
leaving stateful tickets active. Use the new API introduced in 1.1.1  
to disable all types of tickets.  
  
Backpatch to all supported versions.  
  
Reviewed-by: Heikki Linnakangas <[email protected]>  
Reported-by: Andres Freund <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: v12  

M configure
M configure.ac
M meson.build
M src/backend/libpq/be-secure-openssl.c
M src/include/pg_config.h.in

SQL/JSON: Remove useless code in ExecInitJsonExpr()

commit   : 6f9a62b454e8d36f57d54efa141c464f69ce9206    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 26 Jul 2024 16:38:46 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 26 Jul 2024 16:38:46 +0900    

Click here for diff

The code was for adding an unconditional JUMP to the next step,  
which is unnecessary processing.  
  
Reported-by: Jian He <[email protected]>  
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com  
Backpatch-through: 17  

M src/backend/executor/execExpr.c

SQL/JSON: Respect OMIT QUOTES when RETURNING domains over jsonb

commit   : 4fc6a555606de003690d46e900339e78214ee363    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 26 Jul 2024 16:08:13 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 26 Jul 2024 16:08:13 +0900    

Click here for diff

populate_domain() didn't take into account the omit_quotes flag passed  
down to json_populate_type() by ExecEvalJsonCoercion() and that led  
to incorrect behavior when the RETURNING type is a domain over  
jsonb.  Fix that by passing the flag by adding a new function  
parameter to populate_domain().  
  
Reported-by: Jian He <[email protected]>  
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com  
Backpatch-through: 17  

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

SQL/JSON: Improve error-handling of JsonBehavior expressions

commit   : 231b7d670b218d6a5cde0574cf160c8157ab91fb    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 26 Jul 2024 16:00:16 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 26 Jul 2024 16:00:16 +0900    

Click here for diff

Instead of returning a NULL when the JsonBehavior expression value  
could not be coerced to the RETURNING type, throw the error message  
informing the user that it is the JsonBehavior expression that caused  
the error with the actual coercion error message shown in its DETAIL  
line.  
  
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com  
Backpatch-through: 17  

M src/backend/executor/execExprInterp.c
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/expected/sqljson_queryfuncs.out

SQL/JSON: Fix error-handling of some JsonBehavior expressions

commit   : 63e6c5f4a2eeb22e0dd446a62c2b4b417d2b51f0    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 26 Jul 2024 15:59:27 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 26 Jul 2024 15:59:27 +0900    

Click here for diff

To ensure that the errors of executing a JsonBehavior expression that  
is coerced in the parser are caught instead of being thrown directly,  
pass ErrorSaveContext to ExecInitExprRec() when initializing it.  
Also, add a EEOP_JSONEXPR_COERCION_FINISH step to handle the errors  
that are caught that way.  
  
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
M src/test/regress/expected/sqljson_jsontable.out
M src/test/regress/expected/sqljson_queryfuncs.out

Doc: fix misleading syntax synopses for targetlists.

commit   : c7301c3b6fe2feaf96d52cbf35a85ac6b95374dc    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 25 Jul 2024 19:52:08 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 25 Jul 2024 19:52:08 -0400    

Click here for diff

In the syntax synopses for SELECT, INSERT, UPDATE, etc,  
SELECT ... and RETURNING ... targetlists were missing { ... }  
braces around an OR (|) operator.  That allows misinterpretation  
which could lead to confusion.  
  
David G. Johnston, per gripe from [email protected].  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ref/delete.sgml
M doc/src/sgml/ref/insert.sgml
M doc/src/sgml/ref/merge.sgml
M doc/src/sgml/ref/select.sgml
M doc/src/sgml/ref/select_into.sgml
M doc/src/sgml/ref/update.sgml

commit   : e458dc1ac8388b33e3ce6b971d8de2721dd73870    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 25 Jul 2024 16:38:19 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 25 Jul 2024 16:38:19 -0400    

Click here for diff

These aren't actually broken at present, but we might as well  
avoid redirects.  
  
Joel Jacobson  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/acronyms.sgml
M doc/src/sgml/isn.sgml
M doc/src/sgml/sepgsql.sgml

Document restrictions regarding incremental backups and standbys.

commit   : 744ddc6c6a0fa5d4d6d0e187cadcc632daaefc0e    
  
author   : Robert Haas <[email protected]>    
date     : Thu, 25 Jul 2024 15:45:06 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Thu, 25 Jul 2024 15:45:06 -0400    

Click here for diff

If you try to take an incremental backup on a standby and there hasn't  
been much system activity, it might fail. Document why this happens.  
Also add a hint to the error message you get, to make it more likely  
that users will understand what has gone wrong.  
  
Laurenz Albe and Robert Haas  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/backup.sgml
M src/backend/backup/basebackup_incremental.c

Add argument names to the regexp_XXX functions.

commit   : 580f8727ca93b7b9a2ce49746b9cdbcb0a2b4a7e    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 25 Jul 2024 14:51:46 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 25 Jul 2024 14:51:46 -0400    

Click here for diff

This change allows these functions to be called using named-argument  
notation, which can be helpful for readability, particularly for  
the ones with many arguments.  
  
There was considerable debate about exactly which names to use,  
but in the end we settled on the names already shown in our  
documentation table 9.10.  
  
The citext extension provides citext-aware versions of some of  
these functions, so add argument names to those too.  
  
In passing, fix table 9.10's syntax synopses for regexp_match,  
which were slightly wrong about which combinations of arguments  
are allowed.  
  
Jian He, reviewed by Dian Fay and others  
  
Discussion: https://postgr.es/m/CACJufxG3NFKKsh6x4fRLv8h3V-HvN4W5dA=zNKMxsNcDwOKang@mail.gmail.com  

M contrib/citext/Makefile
A contrib/citext/citext–1.6–1.7.sql
M contrib/citext/citext.control
M contrib/citext/meson.build
M doc/src/sgml/func.sgml
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat

pg_createsubscriber: Message improvements

commit   : 05faf06e9c21f012355e7095435a5bfb013f5eec    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 25 Jul 2024 15:25:42 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 25 Jul 2024 15:25:42 +0200    

Click here for diff

Objects are typically "in" a database, not "on".  

M src/bin/pg_basebackup/pg_createsubscriber.c
M src/bin/pg_basebackup/t/040_pg_createsubscriber.pl

pg_upgrade: Remove unused macro

commit   : 88e3da5658c55d49522f01694dc43ad177987f43    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Thu, 25 Jul 2024 15:03:50 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Thu, 25 Jul 2024 15:03:50 +0200    

Click here for diff

Commit f06b1c598 removed validate_exec from pg_upgrade and instead  
exported it from src/common, but the macro for checking executable  
suffix on Windows was accidentally left.  Fix by removing.  
  
Author: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_upgrade/pg_upgrade.h

pgcrypto: Remove unused binary from clean target

commit   : cc59f9d0ff27bc63b41992e04afc67f7efe44019    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Thu, 25 Jul 2024 14:27:01 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Thu, 25 Jul 2024 14:27:01 +0200    

Click here for diff

Generation of the gen-rtab binary was removed in db7d1a7b0 but it  
was accidentally left in the cleaning target.  Remove since it is  
no longer built.  
  
Author: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pgcrypto/Makefile

Remove useless unconstify() call

commit   : c5c71830267b42098add2862df4b15bc25ae0103    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 25 Jul 2024 11:38:05 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 25 Jul 2024 11:38:05 +0200    

Click here for diff

This should have been part of 67c0ef9752 but was apparently forgotten  
there.  

M src/bin/pg_dump/compress_gzip.c

Fix -Wmissing-variable-declarations warnings for float.c special case

commit   : 37c6923cf3d8ec1bd44924aab6f58f72754a0e7b    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 24 Jul 2024 06:21:40 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 24 Jul 2024 06:21:40 +0200    

Click here for diff

This adds extern declarations for the global variables defined in  
float.c but not meant for external use.  This is a workaround to be  
able to add -Wmissing-variable-declarations to the global set of  
warning options in the near future.  
  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

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

Add extern declarations for Bison global variables

commit   : ab61c40bfa2ba1887fee304b2ef5306a14a7248c    
  
author   : Peter Eisentraut <[email protected]>    
date     : Thu, 25 Jul 2024 09:26:08 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Thu, 25 Jul 2024 09:26:08 +0200    

Click here for diff

This adds extern declarations for some global variables produced by  
Bison that are not already declared in its generated header file.  
This is a workaround to be able to add -Wmissing-variable-declarations  
to the global set of warning options in the near future.  
  
Another longer-term solution would be to convert these grammars to  
"pure" parsers in Bison, to avoid global variables altogether.  Note  
that the core grammar is already pure, so this patch did not need to  
touch it.  
  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M contrib/cube/cubeparse.y
M contrib/seg/segparse.y
M src/backend/bootstrap/bootparse.y
M src/backend/replication/repl_gram.y
M src/backend/replication/syncrep_gram.y
M src/interfaces/ecpg/preproc/ecpg.header
M src/pl/plpgsql/src/pl_gram.y
M src/test/isolation/specparse.y

Add path column to pg_backend_memory_contexts view

commit   : 32d3ed8165f821f6994c95230a9a4b2ff0ce9f12    
  
author   : David Rowley <[email protected]>    
date     : Thu, 25 Jul 2024 15:03:28 +1200    
  
committer: David Rowley <[email protected]>    
date     : Thu, 25 Jul 2024 15:03:28 +1200    

Click here for diff

"path" provides a reliable method of determining the parent/child  
relationships between memory contexts.  Previously this could be done in  
a non-reliable way by writing a recursive query and joining the "parent"  
and "name" columns.  This wasn't reliable as the names were not unique,  
which could result in joining to the wrong parent.  
  
To make this reliable, "path" stores an array of numerical identifiers  
starting with the identifier for TopLevelMemoryContext.  It contains an  
element for each intermediate parent between that and the current context.  
  
Incompatibility: Here we also adjust the "level" column to make it  
1-based rather than 0-based.  A 1-based level provides a convenient way  
to access elements in the "path" array. e.g. path[level] gives the  
identifier for the current context.  
  
Identifiers are not stable across multiple evaluations of the view.  In  
an attempt to make these more stable for ad-hoc queries, the identifiers  
are assigned breadth-first.  Contexts closer to TopLevelMemoryContext  
are less likely to change between queries and during queries.  
  
Author: Melih Mutlu <[email protected]>  
Discussion: https://postgr.es/m/CAGPVpCThLyOsj3e_gYEvLoHkr5w=tadDiN_=z2OwsK3VJppeBA@mail.gmail.com  
Reviewed-by: Andres Freund, Stephen Frost, Atsushi Torikoshi,  
Reviewed-by: Michael Paquier, Robert Haas, David Rowley  

M doc/src/sgml/system-views.sgml
M src/backend/utils/adt/mcxtfuncs.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/include/nodes/memnodes.h
M src/test/regress/expected/rules.out
M src/test/regress/expected/sysviews.out
M src/test/regress/sql/sysviews.sql

ci: Pin MacPorts version to 2.9.3.

commit   : 64c39bd5047e6ee045bbc80ea1399feb59cd2b53    
  
author   : Thomas Munro <[email protected]>    
date     : Thu, 25 Jul 2024 14:46:01 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Thu, 25 Jul 2024 14:46:01 +1200    

Click here for diff

Commit d01ce180 invented a new way to find the latest MacPorts version.  
By bad luck, a new beta release has just been published, and it seems  
to lack some packages we need.  Go back to searching for this specific  
version for now.  We still search with a pattern so that we can find the  
package for the running version of macOS, but for now we always look for  
2.9.3.  The code to do that had been anticipated already in a commented  
out line, I just didn't expect to have to use it so soon...  
  
Also include the whole MacPorts installation script in the cache key, so  
that changes to the script cause a fresh installation.  This should make  
it a bit easier to reason about the effect of changes on cached state in  
github accounts using CI, when we make adjustments.  
  
Back-patch to 15, like d01ce180.  
  
Discussion: https://postgr.es/m/CA%2BhUKGLqJdv6RcwyZ_0H7khxtLTNJyuK%2BvDFzv3uwYbn8hKH6A%40mail.gmail.com  

M .cirrus.tasks.yml
M src/tools/ci/ci_macports_packages.sh

doc: Decorate psql page with application markup tags

commit   : b8aa44fd4f86ed1ba5798ad360423555865c437c    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 25 Jul 2024 10:59:49 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 25 Jul 2024 10:59:49 +0900    

Click here for diff

Noticed while looking at this area of the documentation for a separate  
patch.  

M doc/src/sgml/ref/psql-ref.sgml

ci: Upgrade macOS version from 13 to 14.

commit   : d01ce180d9b5f0656d499840e138ab9ae9f8bf76    
  
author   : Thomas Munro <[email protected]>    
date     : Thu, 25 Jul 2024 11:26:48 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Thu, 25 Jul 2024 11:26:48 +1200    

Click here for diff

1.  Previously we were using ghcr.io/cirruslabs/macos-XXX-base:latest  
images, but Cirrus has started ignoring that and using a particular  
image, currently ghcr.io/cirruslabs/macos-runner:sonoma, for github  
accounts using free CI resources (as opposed to dedicated runner  
machines, as cfbot uses).  Let's just ask for that image anyway, to stay  
in sync.  
  
2.  Instead of hard-coding a MacPorts installation URL, deduce it from  
the running macOS version and the available releases.  This removes the  
need to keep the ci_macports_packages.sh in sync with .cirrus.task.yml,  
and to advance the MacPorts version from time to time.  
  
3.  Change the cache key we use to cache the whole macports installation  
across builds to include the OS major version, to trigger a fresh  
installation when appropriate.  
  
Back-patch to 15 where CI began.  
  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://postgr.es/m/CA%2BhUKGLqJdv6RcwyZ_0H7khxtLTNJyuK%2BvDFzv3uwYbn8hKH6A%40mail.gmail.com  

M .cirrus.tasks.yml
M src/tools/ci/ci_macports_packages.sh

pg_upgrade: Retrieve subscription count more efficiently.

commit   : 364509a2e7f92785407348ec702e39729fda6cf8    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 24 Jul 2024 11:30:33 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 24 Jul 2024 11:30:33 -0500    

Click here for diff

Presently, pg_upgrade obtains the number of subscriptions in the  
to-be-upgraded cluster by first querying pg_subscription in every  
database for the number of subscriptions in only that database.  
Then, in count_old_cluster_subscriptions(), it adds all the values  
collected in the first step.  This is expensive, especially when  
there are many databases.  
  
Fortunately, there is a better way to retrieve the subscription  
count.  Since pg_subscription is a shared catalog, we only need to  
connect to a single database and query it once.  This commit  
modifies pg_upgrade to use that approach, which also allows us to  
trim several lines of code.  In passing, move the call to  
get_db_subscription_count(), which has been renamed to  
get_subscription_count(), from get_db_rel_and_slot_infos() to the  
dedicated >= v17 section in check_and_dump_old_cluster().  
  
We may be able to make similar improvements to  
get_old_cluster_logical_slot_infos(), but that is left as a future  
exercise.  
  
Reviewed-by: Michael Paquier, Amit Kapila  
Discussion: https://postgr.es/m/ZprQJv_TxccN3tkr%40nathan  
Backpatch-through: 17  

M src/bin/pg_upgrade/check.c
M src/bin/pg_upgrade/info.c
M src/bin/pg_upgrade/pg_upgrade.h

Fix a missing article in the documentation

commit   : 9f21482fe189c3b6193e9a7c3c50518a8a805165    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 24 Jul 2024 14:13:55 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 24 Jul 2024 14:13:55 +0200    

Click here for diff

Per complaint from Grant Gryczan.  
  
It's a very old typo; backpatch all the way back.  
  
Author: Laurenz Albe <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/parallel.sgml

pg_stat_statements: Add regression test for privilege handling.

commit   : 97f2bc5aa531e32e91c7f27aeaeb87a07e13e822    
  
author   : Fujii Masao <[email protected]>    
date     : Wed, 24 Jul 2024 20:54:51 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Wed, 24 Jul 2024 20:54:51 +0900    

Click here for diff

This commit adds a regression test to verify that pg_stat_statements  
correctly handles privileges, improving its test coverage.  
  
Author: Keisuke Kuroda  
Reviewed-by: Michael Paquier, Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

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

Reset relhassubclass upon attaching table as a partition

commit   : 3dd637f3d5997eb5ef3ccf8787e6fa091d93cd0c    
  
author   : Alvaro Herrera <[email protected]>    
date     : Wed, 24 Jul 2024 12:38:18 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Wed, 24 Jul 2024 12:38:18 +0200    

Click here for diff

We don't allow inheritance parents as partitions, and have checks to  
prevent this; but if a table _was_ in the past an inheritance parents  
and all their children are removed, the pg_class.relhassubclass flag  
may remain set, which confuses the partition pruning code (most  
obviously, it results in an assertion failure; in production builds it  
may be worse.)  
  
Fix by resetting relhassubclass on attach.  
  
Backpatch to all supported versions.  
  
Reported-by: Alexander Lakhin <[email protected]>  
Reviewed-by: Tom Lane <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/catalog/heap.c
M src/test/regress/expected/alter_table.out
M src/test/regress/sql/alter_table.sql

Doc: Fix the mistakes in the subscription's failover option.

commit   : 07fbecb87b16bd52b5bfe6e0ab8a1960734eb04d    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 24 Jul 2024 14:24:45 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 24 Jul 2024 14:24:45 +0530    

Click here for diff

The documentation incorrectly stated that users could not alter the  
subscription's failover option when the two-phase commit is enabled.  
  
The steps to confirm that the standby server is ready for failover were  
incorrect.  
  
Author: Shveta Malik, Hou Zhijie  
Reviewed-by: Amit Kapila  
Discussion: https://postgr.es/m/OS0PR01MB571657B72F8D75BD858DCCE394AD2@OS0PR01MB5716.jpnprd01.prod.outlook.com  
Discussion: https://postgr.es/m/CAJpy0uBBk+OZXXqQ00Gai09XR+mDi2=9sMBYY0F+BedoFivaMA@mail.gmail.com  

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

Refactor tidstore.c iterator buffering.

commit   : f6bef362cac8c47137f9786171eaee5a95fb538b    
  
author   : Thomas Munro <[email protected]>    
date     : Wed, 24 Jul 2024 17:24:59 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Wed, 24 Jul 2024 17:24:59 +1200    

Click here for diff

Previously, TidStoreIterateNext() would expand the set of offsets for  
each block into an internal buffer that it overwrote each time.  In  
order to be able to collect the offsets for multiple blocks before  
working with them, change the contract.  Now, the offsets are obtained  
by a separate call to TidStoreGetBlockOffsets(), which can be called at  
a later time.  TidStoreIteratorResult objects are safe to copy and store  
in a queue.  
  
Reviewed-by: Noah Misch <[email protected]>  
Discussion: https://postgr.es/m/CAAKRu_bbkmwAzSBgnezancgJeXrQZXy4G4kBTd+5=cr86H5yew@mail.gmail.com  

M src/backend/access/common/tidstore.c
M src/backend/access/heap/vacuumlazy.c
M src/include/access/tidstore.h
M src/test/modules/test_tidstore/test_tidstore.c

Allow altering of two_phase option of a SUBSCRIPTION.

commit   : 1462aad2e4474ab61174f8ab00992cd3d6d57c7b    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 24 Jul 2024 10:13:36 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 24 Jul 2024 10:13:36 +0530    

Click here for diff

The two_phase option is controlled by both the publisher (as a slot  
option) and the subscriber (as a subscription option), so the slot option  
must also be modified.  
  
Changing the 'two_phase' option for a subscription from 'true' to 'false'  
is permitted only when there are no pending prepared transactions  
corresponding to that subscription. Otherwise, the changes of already  
prepared transactions can be replicated again along with their corresponding  
commit leading to duplicate data or errors.  
  
To avoid data loss, the 'two_phase' option for a subscription can only be  
changed from 'false' to 'true' once the initial data synchronization is  
completed. Therefore this is performed later by the logical replication worker.  
  
Author: Hayato Kuroda, Ajin Cherian, Amit Kapila  
Reviewed-by: Peter Smith, Hou Zhijie, Amit Kapila, Vitaly Davydov, Vignesh C  
Discussion: https://postgr.es/m/8fab8-65d74c80-1-2f28e880@39088166  

M doc/src/sgml/protocol.sgml
M doc/src/sgml/ref/alter_subscription.sgml
M src/backend/access/transam/twophase.c
M src/backend/commands/subscriptioncmds.c
M src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
M src/backend/replication/logical/launcher.c
M src/backend/replication/logical/worker.c
M src/backend/replication/slot.c
M src/backend/replication/walsender.c
M src/bin/psql/tab-complete.c
M src/include/access/twophase.h
M src/include/replication/slot.h
M src/include/replication/walreceiver.h
M src/include/replication/worker_internal.h
M src/test/regress/expected/subscription.out
M src/test/regress/sql/subscription.sql
M src/test/subscription/t/021_twophase.pl

Move all extern declarations for GUC variables to header files

commit   : 774d47b6c01a8b8111ae390b97343f25ebdf9267    
  
author   : Peter Eisentraut <[email protected]>    
date     : Wed, 24 Jul 2024 06:21:39 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Wed, 24 Jul 2024 06:21:39 +0200    

Click here for diff

Add extern declarations in appropriate header files for global  
variables related to GUC.  In many cases, this was handled quite  
inconsistently before, with some GUC variables declared in a header  
file and some only pulled in via ad-hoc extern declarations in various  
.c files.  
  
Also add PGDLLIMPORT qualifications to those variables.  These were  
previously missing because src/tools/mark_pgdllimport.pl has only been  
used with header files.  
  
This also fixes -Wmissing-variable-declarations warnings for GUC  
variables (not yet part of the standard warning options).  
  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/commands/variable.c
M src/backend/utils/error/elog.c
M src/backend/utils/misc/guc.c
M src/backend/utils/misc/guc_tables.c
M src/include/access/syncscan.h
M src/include/access/xlog.h
M src/include/access/xlogutils.h
M src/include/commands/tablespace.h
M src/include/storage/bufpage.h
M src/include/tcop/backend_startup.h
M src/include/tcop/tcopprot.h
M src/include/utils/guc.h

Detect integer overflow in array_set_slice().

commit   : 991f8cf8abe244547093ddffcc4b9209076f3525    
  
author   : Nathan Bossart <[email protected]>    
date     : Tue, 23 Jul 2024 21:59:02 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Tue, 23 Jul 2024 21:59:02 -0500    

Click here for diff

When provided an empty initial array, array_set_slice() fails to  
check for overflow when computing the new array's dimensions.  
While such overflows are ordinarily caught by ArrayGetNItems(),  
commands with the following form are accepted:  
  
	INSERT INTO t (i[-2147483648:2147483647]) VALUES ('{}');  
  
To fix, perform the hazardous computations using overflow-detecting  
arithmetic routines.  As with commit 18b585155a, the added test  
cases generate errors that include a platform-dependent value, so  
we again use psql's VERBOSITY parameter to suppress printing the  
message text.  
  
Reported-by: Alexander Lakhin  
Author: Joseph Koshakow  
Reviewed-by: Jian He  
Discussion: https://postgr.es/m/31ad2cd1-db94-bdb3-f91a-65ffdb4bef95%40gmail.com  
Backpatch-through: 12  

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

Move extern declarations for EXEC_BACKEND to header files

commit   : d3cc5ffe81f64c6418ba9b18a9db32392f8027e6    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 23 Jul 2024 14:58:30 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 23 Jul 2024 14:58:30 +0200    

Click here for diff

This fixes warnings from -Wmissing-variable-declarations (not yet part  
of the standard warning options) under EXEC_BACKEND.  The  
NON_EXEC_STATIC variables need a suitable declaration in a header file  
under EXEC_BACKEND.  
  
Also fix the inconsistent application of the volatile qualifier for  
PMSignalState, which was revealed by this change.  
  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/postmaster/launch_backend.c
M src/include/postmaster/postmaster.h
M src/include/postmaster/syslogger.h
M src/include/storage/pmsignal.h
M src/include/storage/proc.h

Fix private struct field name to match the code using it.

commit   : 840b3b5b4ee90ce8b692519e534dfb015d89fe8f    
  
author   : Noah Misch <[email protected]>    
date     : Tue, 23 Jul 2024 05:32:03 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Tue, 23 Jul 2024 05:32:03 -0700    

Click here for diff

Commit 8720a15e9ab121e49174d889eaeafae8ac89de7b added the wrong name.  
  
Nazir Bilal Yavuz  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/storage/buffer/bufmgr.c

commit   : 3937cadfd4383fd32f3fd8d8dc5efc32b3d12664    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 23 Jul 2024 17:59:05 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 23 Jul 2024 17:59:05 +0900    

Click here for diff

clog.c, async.c and predicate.c included some SLRU page numbers still  
handled as 4-byte integers, while int64 should be used for this purpose.  
  
These holes have been introduced in 4ed8f0913bfd, that has introduced  
the use of 8-byte integers for SLRU page numbers, still forgot about the  
code paths updated by this commit.  
  
Reported-by: Noah Misch  
Author: Aleksander Alekseev, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 17  

M src/backend/access/transam/clog.c
M src/backend/commands/async.c
M src/backend/storage/lmgr/predicate.c

ldapurl is supported with simple bind

commit   : f68d85bf69233ef842a08707bbd1204ef8216549    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 23 Jul 2024 10:14:38 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 23 Jul 2024 10:14:38 +0200    

Click here for diff

The docs currently imply that ldapurl is for search+bind only, but  
that's not true.  Rearrange the docs to cover this better.  
  
Add a test ldapurl with simple bind.  This was previously allowed but  
unexercised, and now that it's documented it'd be good to pin the  
behavior.  
  
Improve error when mixing LDAP bind modes.  The option names had gone  
stale; replace them with a more general statement.  
  
Author: Jacob Champion <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/CAOYmi+nyg9gE0LeP=xQ3AgyQGR=5ZZMkVVbWd0uR8XQmg_dd5Q@mail.gmail.com  

M doc/src/sgml/client-auth.sgml
M src/backend/libpq/hba.c
M src/test/ldap/t/001_auth.pl

Get rid of a global variable

commit   : 935e675f3c9efd0e39bf33db15ab85049cc4ee7c    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 23 Jul 2024 09:53:54 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 23 Jul 2024 09:53:54 +0200    

Click here for diff

bootstrap_data_checksum_version can just as easily be passed to where  
it is used via function arguments.  
  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/access/transam/xlog.c
M src/backend/bootstrap/bootstrap.c
M src/include/access/xlog.h

Improve comments in slru.{c,h} about segment name format

commit   : ffb0603929617f39d449e942abe96cdba36e7545    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 23 Jul 2024 16:54:51 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 23 Jul 2024 16:54:51 +0900    

Click here for diff

slru.h described incorrectly how SLRU segment names are formatted  
depending on the segment number and if long or short segment names are  
used.  This commit closes the gap with a better description, fitting  
with the reality.  
  
Reported-by: Noah Misch  
Author: Aleksander Alekseev  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 17  

M src/backend/access/transam/slru.c
M src/include/access/slru.h

Replace remaining strtok() with strtok_r()

commit   : 65504b747f3c217dfa91297db6ea219924a3fa8a    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 23 Jul 2024 09:13:48 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 23 Jul 2024 09:13:48 +0200    

Click here for diff

for thread-safety in the server in the future  
  
Reviewed-by: Kyotaro Horiguchi <[email protected]>  
Reviewed-by: David Steele <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

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

Windows replacement for strtok_r()

commit   : 4d130b28727ce5db4114bcc2a3e2c790643032de    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 23 Jul 2024 09:13:48 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 23 Jul 2024 09:13:48 +0200    

Click here for diff

They spell it "strtok_s" there.  
  
There are currently no uses, but some will be added soon.  
  
Reviewed-by: Kyotaro Horiguchi <[email protected]>  
Reviewed-by: David Steele <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/include/port/win32_port.h

Remove redundant code in create_gather_merge_path

commit   : 8b2e9fd26afd9f379ea8bedeb4b11a354c09a3e1    
  
author   : Richard Guo <[email protected]>    
date     : Tue, 23 Jul 2024 11:18:53 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Tue, 23 Jul 2024 11:18:53 +0900    

Click here for diff

In create_gather_merge_path, we should always guarantee that the  
subpath is adequately ordered, and we do not add a Sort node in  
createplan.c for a Gather Merge node.  Therefore, the 'else' branch in  
create_gather_merge_path, which computes the cost for a Sort node, is  
redundant.  
  
This patch removes the redundant code and emits an error if the  
subpath is not sufficiently ordered.  Meanwhile, this patch changes  
the check for the subpath's pathkeys in create_gather_merge_plan to an  
Assert.  
  
Author: Richard Guo  
Discussion: https://postgr.es/m/CAMbWs48u=0bWf3epVtULjJ-=M9Hbkz+ieZQAOS=BfbXZFqbDCg@mail.gmail.com  

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

Fix rowcount estimate for gather (merge) paths

commit   : 581df2148737fdb0ba6f2d8fda5ceb9d1e6302e6    
  
author   : Richard Guo <[email protected]>    
date     : Tue, 23 Jul 2024 10:33:26 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Tue, 23 Jul 2024 10:33:26 +0900    

Click here for diff

In the case of a parallel plan, when computing the number of tuples  
processed per worker, we divide the total number of tuples by the  
parallel_divisor obtained from get_parallel_divisor(), which accounts  
for the leader's contribution in addition to the number of workers.  
  
Accordingly, when estimating the number of tuples for gather (merge)  
nodes, we should multiply the number of tuples per worker by the same  
parallel_divisor to reverse the division.  However, currently we use  
parallel_workers rather than parallel_divisor for the multiplication.  
This could result in an underestimation of the number of tuples for  
gather (merge) nodes, especially when there are fewer than four  
workers.  
  
This patch fixes this issue by using the same parallel_divisor for the  
multiplication.  There is one ensuing plan change in the regression  
tests, but it looks reasonable and does not compromise its original  
purpose of testing parallel-aware hash join.  
  
In passing, this patch removes an unnecessary assignment for path.rows  
in create_gather_merge_path, and fixes an uninitialized-variable issue  
in generate_useful_gather_paths.  
  
No backpatch as this could result in plan changes.  
  
Author: Anthonin Bonnefoy  
Reviewed-by: Rafia Sabih, Richard Guo  
Discussion: https://postgr.es/m/CAO6_Xqr9+51NxgO=XospEkUeAg-p=EjAWmtpdcZwjRgGKJ53iA@mail.gmail.com  

M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/path/costsize.c
M src/backend/optimizer/plan/planner.c
M src/backend/optimizer/util/pathnode.c
M src/include/optimizer/cost.h
M src/test/regress/expected/join_hash.out

Doc: improve description of plpgsql's FETCH and MOVE commands.

commit   : d2cba4f2cbfe69b2c5f93f364da4e574e075cb03    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 22 Jul 2024 19:43:12 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 22 Jul 2024 19:43:12 -0400    

Click here for diff

We were not being clear about which variants of the "direction"  
clause are permitted in MOVE.  Also, the text seemed to be  
written with only the FETCH/MOVE NEXT case in mind, so it  
didn't apply very well to other variants.  
  
Also, document that "MOVE count IN cursor" only works if count  
is a constant.  This is not the whole truth, because some other  
cases such as a parenthesized expression will also work, but  
we want to push people to use "MOVE FORWARD count" instead.  
The constant case is enough to cover what we allow in plain SQL,  
and that seems sufficient to claim support for.  
  
Update a comment in pl_gram.y claiming that we don't document  
that point.  
  
Per gripe from Philipp Salvisberg.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/plpgsql.sgml
M src/pl/plpgsql/src/pl_gram.y

Revert "Test that vacuum removes tuples older than OldestXmin"

commit   : efcbb76efe406d59c2ba8b4a09e04c01158ba575    
  
author   : Melanie Plageman <[email protected]>    
date     : Mon, 22 Jul 2024 16:13:56 -0400    
  
committer: Melanie Plageman <[email protected]>    
date     : Mon, 22 Jul 2024 16:13:56 -0400    

Click here for diff

This reverts commit aa607980aee08416211f003ab41aa750f5559712.  
  
This test proved to be unstable on the buildfarm, timing out before the  
standby could catch up on 32-bit machines where more rows were required  
and failing to reliably trigger multiple index vacuum rounds on 64-bit  
machines where fewer rows should be required.  
  
Because the instability is only known to be present on versions of  
Postgres with TIDStore used for dead TID storage by vacuum, this is only  
being reverted on master and REL_17_STABLE.  
  
As having this coverage may be valuable, there is a discussion on the  
thread of possible ways to stabilize the test. If that happens, a fixed  
test can be committed again.  
  
Backpatch-through: 17  
Reported-by: Tom Lane  
  
Discussion: https://postgr.es/m/614152.1721580711%40sss.pgh.pa.us  

M src/test/recovery/meson.build
D src/test/recovery/t/043_vacuum_horizon_floor.pl

Initialize wal_level in the initial checkpoint record.

commit   : 6a6ebb92b0d4c0787797538ec3ff342fd8e7c1ed    
  
author   : Robert Haas <[email protected]>    
date     : Mon, 22 Jul 2024 15:32:43 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Mon, 22 Jul 2024 15:32:43 -0400    

Click here for diff

As per Coverity and Tom Lane, commit 402b586d0 (back-patched to v17  
as 2b5819e2b) forgot to initialize this new structure member in this  
code path.  

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

Remove grotty use of disable_cost for TID scan plans.

commit   : e4326fbc60c44aab6df5849d3d67a0cba4c71cf2    
  
author   : Robert Haas <[email protected]>    
date     : Mon, 22 Jul 2024 14:57:53 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Mon, 22 Jul 2024 14:57:53 -0400    

Click here for diff

Previously, the code charged disable_cost for CurrentOfExpr, and then  
subtracted disable_cost from the cost of a TID path that used  
CurrentOfExpr as the TID qual, effectively disabling all paths except  
that one. Now, we instead suppress generation of the disabled paths  
entirely, and generate only the one that the executor will actually  
understand.  
  
With this approach, we do not need to rely on disable_cost being  
large enough to prevent the wrong path from being chosen, and we  
save some CPU cycle by avoiding generating paths that we can't  
actually use. In my opinion, the code is also easier to understand  
like this.  
  
Patch by me. Review by Heikki Linnakangas.  
  
Discussion: http://postgr.es/m/[email protected]  

M src/backend/optimizer/path/allpaths.c
M src/backend/optimizer/path/costsize.c
M src/backend/optimizer/path/tidpath.c
M src/include/optimizer/paths.h

Add missing call to ConditionVariableCancelSleep().

commit   : c0348fd0e389c89003f309918705d1daea2217b0    
  
author   : Robert Haas <[email protected]>    
date     : Wed, 17 Jul 2024 14:53:00 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Wed, 17 Jul 2024 14:53:00 -0400    

Click here for diff

After calling ConditionVariableSleep() or ConditionVariableTimedSleep()  
one or more times, code is supposed to call ConditionVariableCancelSleep()  
to remove itself from the waitlist. This code neglected to do so.  
As far as I know, that had no observable consequences, but let's make  
the code correct.  
  
Discussion: http://postgr.es/m/CA+TgmoYW8eR+KN6zhVH0sin7QH6AvENqw_bkN-bB4yLYKAnsew@mail.gmail.com  

M src/backend/postmaster/walsummarizer.c

Replace some strtok() with strsep()

commit   : 5d2e1cc117b38db6bb5dc2e9ae9115304571ac70    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 22 Jul 2024 15:45:46 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 22 Jul 2024 15:45:46 +0200    

Click here for diff

strtok() considers adjacent delimiters to be one delimiter, which is  
arguably the wrong behavior in some cases.  Replace with strsep(),  
which has the right behavior: Adjacent delimiters create an empty  
token.  
  
Affected by this are parsing of:  
  
- Stored SCRAM secrets  
  ("SCRAM-SHA-256$<iterations>:<salt>$<storedkey>:<serverkey>")  
  
- ICU collation attributes  
  ("und@colStrength=primary;colCaseLevel=yes") for ICU older than  
  version 54  
  
- PG_COLORS environment variable  
  ("error=01;31:warning=01;35:note=01;36:locus=01")  
  
- pg_regress command-line options with comma-separated list arguments  
  (--dbname, --create-role) (currently only used pg_regress_ecpg)  
  
Reviewed-by: Kyotaro Horiguchi <[email protected]>  
Reviewed-by: David Steele <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/libpq/auth-scram.c
M src/backend/utils/adt/pg_locale.c
M src/common/logging.c
M src/test/regress/pg_regress.c

postgres_fdw: Split out the query_cancel test to its own file

commit   : 90c1ba52e06d0847e524b6e6c3259ab1843bb05f    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 22 Jul 2024 12:49:57 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 22 Jul 2024 12:49:57 +0200    

Click here for diff

This allows us to skip it in Cygwin, where it's reportedly flaky because  
of platform bugs or something.  
  
Backpatch to 17, where the test was introduced by commit 2466d6654f85.  
  
Reported-by: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M contrib/postgres_fdw/Makefile
M contrib/postgres_fdw/expected/postgres_fdw.out
A contrib/postgres_fdw/expected/query_cancel.out
A contrib/postgres_fdw/expected/query_cancel_1.out
M contrib/postgres_fdw/meson.build
M contrib/postgres_fdw/sql/postgres_fdw.sql
A contrib/postgres_fdw/sql/query_cancel.sql

Add port/ replacement for strsep()

commit   : 683be87fbba02b086cc05789fcbdc289120d1065    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 22 Jul 2024 09:47:02 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 22 Jul 2024 09:47:02 +0200    

Click here for diff

from OpenBSD, similar to strlcat, strlcpy  
  
There are currently no uses, but some will be added soon.  
  
Reviewed-by: Kyotaro Horiguchi <[email protected]>  
Reviewed-by: David Steele <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M configure
M configure.ac
M meson.build
M src/include/pg_config.h.in
M src/include/port.h
M src/port/meson.build
A src/port/strsep.c

Fix unstable test in select_parallel.sql

commit   : 7e187a7386cc922c8f770c0460bfc43f4806bd15    
  
author   : Richard Guo <[email protected]>    
date     : Mon, 22 Jul 2024 11:29:21 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Mon, 22 Jul 2024 11:29:21 +0900    

Click here for diff

One test case added in 22d946b0f verifies the plan of a non-parallel  
nestloop join.  The planner's choice of join order is arbitrary, and  
slight variations in underlying statistics could result in a different  
displayed plan.  To stabilize the test result, here we enforce the  
join order using a lateral join.  
  
While here, modify the test case to verify that parallel nestloop join  
is not generated if the inner path is not parallel-safe, which is what  
we wanted to test in 22d946b0f.  
  
Reported-by: Alexander Lakhin as per buildfarm  
Author: Richard Guo  
Discussion: https://postgr.es/m/[email protected]  

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

Add new error code for "file name too long"

commit   : 2d8ef5e24fd3d38ffc2379ca32eaeef8c9eee1a7    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 22 Jul 2024 09:28:01 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 22 Jul 2024 09:28:01 +0900    

Click here for diff

This new error code, named file_name_too_long, maps internally to the  
errno ENAMETOOLONG to produce a proper error code rather than an  
internal code under errcode_for_file_access().  This error code can be  
reached with some SQL command patterns, like a snapshot file name.  
  
Reported-by: Alexander Lakhin  
Reviewed-by: Daniel Gustafsson  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/errcodes.txt
M src/backend/utils/error/elog.c

meson: Add dependency lookups via names used by cmake

commit   : 5ec2c529f5537a5f5d5c929c49a5a2af2e4feda7    
  
author   : Andres Freund <[email protected]>    
date     : Sat, 20 Jul 2024 13:51:08 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Sat, 20 Jul 2024 13:51:08 -0700    

Click here for diff

Particularly on windows it's useful to look up dependencies via cmake, instead  
of pkg-config. Meson supports doing so. Unfortunately the dependency names  
used by various projects often differs between their pkg-config and cmake  
files.  
  
This would look a lot neater if we could rely on meson >= 0.60.0...  
  
Reviewed-by: Tristan Partin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 16-, where meson support was added  

M meson.build

meson: Add support for detecting ossp-uuid without pkg-config

commit   : 2416fdb3ee30bdd2810408f93f14d47bff840fea    
  
author   : Andres Freund <[email protected]>    
date     : Sat, 20 Jul 2024 13:51:08 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Sat, 20 Jul 2024 13:51:08 -0700    

Click here for diff

This is necessary as ossp-uuid on windows installs neither a pkg-config nor a  
cmake dependency information. Nor is there another supported uuid  
implementation available on windows.  
  
Reported-by: Dave Page <[email protected]>  
Reviewed-by: Tristan Partin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 16-, where meson support was added  

M meson.build

meson: Add support for detecting gss without pkg-config

commit   : 7ed2ce0b257fcceb37bec8520eb293c0522d8681    
  
author   : Andres Freund <[email protected]>    
date     : Sat, 20 Jul 2024 13:51:08 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Sat, 20 Jul 2024 13:51:08 -0700    

Click here for diff

This is required as MIT Kerberos does provide neither pkg-config nor cmake  
dependency information on windows.  
  
Reported-by: Dave Page <[email protected]>  
Reviewed-by: Tristan Partin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 16-, where meson support was added  

M meson.build

meson: Add missing argument to gssapi.h check

commit   : c3dafaaac389b23721e20f493580fddac7c95528    
  
author   : Andres Freund <[email protected]>    
date     : Sat, 20 Jul 2024 13:51:08 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Sat, 20 Jul 2024 13:51:08 -0700    

Click here for diff

These were missing since the initial introduction of the meson based build, in  
e6927270cd18. As-is this is unlikely to cause an issue, but a future commit  
will add support for detecting gssapi without use of dependency(), which could  
fail due to this.  
  
Discussion: https://postgr.es/m/[email protected]  
Backpatch: 16-, where the meson based build was added  

M meson.build

Correctly check updatability of columns targeted by INSERT...DEFAULT.

commit   : 220003b9b93729af1ffa861d1ae5f4724ce22cd8    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 20 Jul 2024 13:40:15 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 20 Jul 2024 13:40:15 -0400    

Click here for diff

If a view has some updatable and some non-updatable columns, we failed  
to verify updatability of any columns for which an INSERT or UPDATE  
on the view explicitly specifies a DEFAULT item (unless the view has  
a declared default for that column, which is rare anyway, and one  
would almost certainly not write one for a non-updatable column).  
This would lead to an unexpected "attribute number N not found in  
view targetlist" error rather than the intended error.  
  
Per bug #18546 from Alexander Lakhin.  This bug is old, so back-patch  
to all supported branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/rewrite/rewriteHandler.c
M src/test/regress/expected/updatable_views.out
M src/test/regress/sql/updatable_views.sql

Use read streams in CREATE DATABASE when STRATEGY=WAL_LOG.

commit   : 8720a15e9ab121e49174d889eaeafae8ac89de7b    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 20 Jul 2024 04:22:12 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 20 Jul 2024 04:22:12 -0700    

Click here for diff

While this doesn't significantly change runtime now, it arranges for  
STRATEGY=WAL_LOG to benefit automatically from future optimizations to  
the read_stream subsystem.  For large tables in the template database,  
this does read 16x as many bytes per system call.  Platforms with high  
per-call overhead, if any, may see an immediate benefit.  
  
Nazir Bilal Yavuz  
  
Discussion: https://postgr.es/m/CAN55FZ0JKL6vk1xQp6rfOXiNFV1u1H0tJDPPGHWoiO3ea2Wc=A@mail.gmail.com  

M src/backend/storage/buffer/bufmgr.c

Add a way to create read stream object by using SMgrRelation.

commit   : a858be17c3f85a2ce3ad5e3073c14ab948b85079    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 20 Jul 2024 04:22:12 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 20 Jul 2024 04:22:12 -0700    

Click here for diff

Currently read stream object can be created only by using Relation.  
  
Nazir Bilal Yavuz  
  
Discussion: https://postgr.es/m/CAN55FZ0JKL6vk1xQp6rfOXiNFV1u1H0tJDPPGHWoiO3ea2Wc=A@mail.gmail.com  

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

Refactor PinBufferForBlock() to remove checks about persistence.

commit   : af07a827b9c579be64f144f88e03bff3bb85582c    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 20 Jul 2024 04:22:12 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 20 Jul 2024 04:22:12 -0700    

Click here for diff

There are checks in PinBufferForBlock() function to set persistence of  
the relation.  This function is called for each block in the relation.  
Instead, set persistence of the relation before PinBufferForBlock().  
  
Nazir Bilal Yavuz  
  
Discussion: https://postgr.es/m/CAN55FZ0JKL6vk1xQp6rfOXiNFV1u1H0tJDPPGHWoiO3ea2Wc=A@mail.gmail.com  

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

Remove "smgr_persistence == 0" dead code.

commit   : e00c45f6850f86c53b48478f60c15be905dc914d    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 20 Jul 2024 04:22:12 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 20 Jul 2024 04:22:12 -0700    

Click here for diff

Reaching that code would have required multiple processes performing  
relation extension during recovery, which does not happen.  That caller  
has the persistence available, so pass it.  This was dead code as soon  
as commit 210622c60e1a9db2e2730140b8106ab57d259d15 added it.  
  
Discussion: https://postgr.es/m/CAN55FZ0JKL6vk1xQp6rfOXiNFV1u1H0tJDPPGHWoiO3ea2Wc=A@mail.gmail.com  

M src/backend/storage/buffer/bufmgr.c
M src/include/storage/bufmgr.h

Add overflow checks to money type.

commit   : 22b0ccd65d275d227a7d911aede12d34e1b5dfc9    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 19 Jul 2024 11:52:32 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 19 Jul 2024 11:52:32 -0500    

Click here for diff

None of the arithmetic functions for the the money type handle  
overflow.  This commit introduces several helper functions with  
overflow checking and makes use of them in the money type's  
arithmetic functions.  
  
Fixes bug #18240.  
  
Reported-by: Alexander Lakhin  
Author: Joseph Koshakow  
Discussion: https://postgr.es/m/18240-c5da758d7dc1ecf0%40postgresql.org  
Discussion: https://postgr.es/m/CAAvxfHdBPOyEGS7s%2Bxf4iaW0-cgiq25jpYdWBqQqvLtLe_t6tw%40mail.gmail.com  
Backpatch-through: 12  

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

Test that vacuum removes tuples older than OldestXmin

commit   : aa607980aee08416211f003ab41aa750f5559712    
  
author   : Melanie Plageman <[email protected]>    
date     : Fri, 19 Jul 2024 10:18:22 -0400    
  
committer: Melanie Plageman <[email protected]>    
date     : Fri, 19 Jul 2024 10:18:22 -0400    

Click here for diff

If vacuum fails to prune a tuple killed before OldestXmin, it will  
decide to freeze its xmax and later error out in pre-freeze checks.  
  
Add a test reproducing this scenario to the recovery suite which creates  
a table on a primary, updates the table to generate dead tuples for  
vacuum, and then, during the vacuum, uses a replica to force  
GlobalVisState->maybe_needed on the primary to move backwards and  
precede the value of OldestXmin set at the beginning of vacuuming the  
table.  
  
This commit is separate from the fix in case there are test stability  
issues.  
  
Author: Melanie Plageman  
Reviewed-by: Peter Geoghegan  
Discussion: https://postgr.es/m/CAAKRu_apNU2MPBK96V%2BbXjTq0RiZ-%3DA4ZTaysakpx9jxbq1dbQ%40mail.gmail.com  

M src/test/recovery/meson.build
A src/test/recovery/t/043_vacuum_horizon_floor.pl

Ensure vacuum removes all visibly dead tuples older than OldestXmin

commit   : 83c39a1f7f3f507058d5bc9f121a42a1a2494180    
  
author   : Melanie Plageman <[email protected]>    
date     : Fri, 19 Jul 2024 10:18:17 -0400    
  
committer: Melanie Plageman <[email protected]>    
date     : Fri, 19 Jul 2024 10:18:17 -0400    

Click here for diff

If vacuum fails to remove a tuple with xmax older than  
VacuumCutoffs->OldestXmin and younger than GlobalVisState->maybe_needed,  
it may attempt to freeze the tuple's xmax and then ERROR out in  
pre-freeze checks with "cannot freeze committed xmax".  
  
Fix this by having vacuum always remove tuples older than OldestXmin.  
  
It is possible for GlobalVisState->maybe_needed to precede OldestXmin if  
maybe_needed is forced to go backward while vacuum is running. This can  
happen if a disconnected standby with a running transaction older than  
VacuumCutoffs->OldestXmin reconnects to the primary after vacuum  
initially calculates GlobalVisState and OldestXmin.  
  
In back branches starting with 14, the first version using  
GlobalVisState, failing to remove tuples older than OldestXmin during  
pruning caused vacuum to infinitely loop in lazy_scan_prune(), as  
investigated on this [1] thread. After 1ccc1e05ae removed the retry loop  
in lazy_scan_prune() and stopped comparing tuples to OldestXmin, the  
hang could no longer happen, but we could still attempt to freeze dead  
tuples with xmax older than OldestXmin -- resulting in an ERROR.  
  
Fix this by always removing dead tuples with xmax older than  
VacuumCutoffs->OldestXmin. This is okay because the standby won't replay  
the tuple removal until the tuple is removable. Thus, the worst that can  
happen is a recovery conflict.  
  
[1] https://postgr.es/m/20240415173913.4zyyrwaftujxthf2%40awork3.anarazel.de#1b216b7768b5bd577a3d3d51bd5aadee  
  
Back-patch through 14  
  
Author: Melanie Plageman  
Reviewed-by: Peter Geoghegan, Robert Haas, Andres Freund, Heikki Linnakangas, and Noah Misch  
Discussion: https://postgr.es/m/CAAKRu_bDD7oq9ZwB2OJqub5BovMG6UjEYsoK2LVttadjEqyRGg%40mail.gmail.com  

M src/backend/access/heap/pruneheap.c
M src/backend/access/heap/vacuumlazy.c

Move resowner from common JitContext to LLVM specific

commit   : 5784a493f14e02ece767aec7b4d3ed96e16a3a20    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 19 Jul 2024 10:27:06 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 19 Jul 2024 10:27:06 +0300    

Click here for diff

Only the LLVM specific code uses it since resource owners were made  
extensible in commit b8bff07daa85c837a2747b4d35cd5a27e73fb7b2. This is  
new in v17, so backpatch there to keep the branches from diverging  
just yet.  
  
Author: Andreas Karlsson <[email protected]>  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/jit/llvm/llvmjit.c
M src/include/jit/jit.h
M src/include/jit/llvmjit.h

Add more test coverage for jsonpath "$.*" with arrays

commit   : 3a137ab7e575b683c410c46312799a4d88e2b2f2    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 19 Jul 2024 14:17:56 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 19 Jul 2024 14:17:56 +0900    

Click here for diff

There was no coverage for the code path to unwrap an array before  
applying ".*" to it, so add tests to provide more coverage for both  
objects and arrays.  
  
This shows, for example, that no results are returned for an array of  
scalars, and what results are returned when the array contains an  
object.  A few more scenarios are covered with the strict/lax modes and  
the operator "@?".  
  
Author: David Wheeler  
Reported-by: David G. Johnston, Stepan Neretin  
Discussion: https://postgr.es/m/[email protected]  

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

postgres_fdw: Avoid "cursor can only scan forward" error.

commit   : 5c571a34d0e99bb7df7aedd26b90ff490cd6d9ee    
  
author   : Etsuro Fujita <[email protected]>    
date     : Fri, 19 Jul 2024 13:15:00 +0900    
  
committer: Etsuro Fujita <[email protected]>    
date     : Fri, 19 Jul 2024 13:15:00 +0900    

Click here for diff

Commit d844cd75a disallowed rewind in a non-scrollable cursor to resolve  
anomalies arising from such a cursor operation.  However, this failed to  
take into account the assumption in postgres_fdw that when rescanning a  
foreign relation, it can rewind the cursor created for scanning the  
foreign relation without specifying the SCROLL option, regardless of its  
scrollability, causing this error when it tried to do such a rewind in a  
non-scrollable cursor.  Fix by modifying postgres_fdw to instead  
recreate the cursor, regardless of its scrollability, when rescanning  
the foreign relation.  (If we had a way to check its scrollability, we  
could improve this by rewinding it if it is scrollable and recreating it  
if not, but we do not have it, so this commit modifies it to recreate it  
in any case.)  
  
Per bug #17889 from Eric Cyr.  Devrim Gunduz also reported this problem.  
Back-patch to v15 where that commit enforced the prohibition.  
  
Reviewed by Tom Lane.  
  
Discussion: https://postgr.es/m/17889-e8c39a251d258dda%40postgresql.org  
Discussion: https://postgr.es/m/b415ac3255f8352d1ea921cf3b7ba39e0587768a.camel%40gunduz.org  

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

Propagate query IDs of utility statements in functions

commit   : c145f321b681ab6c3636849071ff30d5c6f6353c    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 19 Jul 2024 10:21:01 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 19 Jul 2024 10:21:01 +0900    

Click here for diff

For utility statements defined within a function, the query tree is  
copied to a PlannedStmt as utility commands do not require planning.  
However, the query ID was missing from the information passed down.  
  
This leads to plugins relying on the query ID like pg_stat_statements to  
not be able to track utility statements within function calls.  Tests  
are added to check this behavior, depending on pg_stat_statements.track.  
  
This is an old bug.  Now, query IDs for utilities are compiled using  
their parsed trees rather than the query string since v16  
(3db72ebcbe20), leading to less bloat with utilities, so backpatch down  
only to this version.  
  
Author: Anthonin Bonnefoy  
Discussion: https://postgr.es/m/CAO6_XqrGp-uwBqi3vBPLuRULKkddjC7R5QZCgsFren=8E+m2Sg@mail.gmail.com  
Backpatch-through: 16  

M contrib/pg_stat_statements/expected/level_tracking.out
M contrib/pg_stat_statements/sql/level_tracking.sql
M src/backend/executor/functions.c

Improve pg_ctl's message for shutdown after recovery.

commit   : cd85ae1114fedcce8602bca77b4557fe75165637    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 18 Jul 2024 13:48:58 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 18 Jul 2024 13:48:58 -0400    

Click here for diff

If pg_ctl tries to start the postmaster, but the postmaster shuts down  
because it completed a point-in-time recovery, pg_ctl used to report  
a message that indicated a failure.  It's not really a failure, so  
instead say "server shut down because of recovery target settings".  
  
Zhao Junwang, Crisp Lee, Laurenz Albe  
  
Discussion: https://postgr.es/m/CAGHPtV7GttPZ-HvxZuYRy70jLGQMEm5=LQc4fKGa=J74m2VZbg@mail.gmail.com  

M src/bin/pg_ctl/pg_ctl.c

Doc: improve description of plpgsql's RAISE command.

commit   : 56c6be57af6bd1c7eb7dff50e5f169ced4ed3045    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 18 Jul 2024 12:37:51 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 18 Jul 2024 12:37:51 -0400    

Click here for diff

RAISE accepts either = or := in the USING clause, so fix the  
syntax synopsis to show that.  
  
Rearrange and wordsmith the descriptions of the different syntax  
variants, in hopes of improving clarity.  
  
Igor Gnatyuk, reviewed by Jian He and Laurenz Albe; minor additional  
wordsmithing by me  
  
Discussion: https://postgr.es/m/CAEu6iLvhF5sdGeat2x4_L0FvWW_SiN--ma8ya7CZd-oJoV+yqQ@mail.gmail.com  

M doc/src/sgml/plpgsql.sgml

Do not summarize WAL if generated with wal_level=minimal.

commit   : 402b586d0a9caae9412d25fcf1b91dae45375833    
  
author   : Robert Haas <[email protected]>    
date     : Thu, 18 Jul 2024 12:09:48 -0400    
  
committer: Robert Haas <[email protected]>    
date     : Thu, 18 Jul 2024 12:09:48 -0400    

Click here for diff

To do this, we must include the wal_level in the first WAL record  
covered by each summary file; so add wal_level to struct Checkpoint  
and the payload of XLOG_CHECKPOINT_REDO and XLOG_END_OF_RECOVERY.  
  
This, in turn, requires bumping XLOG_PAGE_MAGIC and, since the  
Checkpoint is also stored in the control file, also  
PG_CONTROL_VERSION. It's not great to do that so late in the release  
cycle, but the alternative seems to ship v17 without robust  
protections against this scenario, which could result in corrupted  
incremental backups.  
  
A side effect of this patch is that, when a server with  
wal_level=replica is started with summarize_wal=on for the first time,  
summarization will no longer begin with the oldest WAL that still  
exists in pg_wal, but rather from the first checkpoint after that.  
This change should be harmless, because a WAL summary for a partial  
checkpoint cycle can never make an incremental backup possible when  
it would otherwise not have been.  
  
Report by Fujii Masao. Patch by me. Review and/or testing by Jakub  
Wartak and Fujii Masao.  
  
Discussion: http://postgr.es/m/[email protected]  

M doc/src/sgml/config.sgml
M doc/src/sgml/func.sgml
M src/backend/access/rmgrdesc/xlogdesc.c
M src/backend/access/transam/xlog.c
M src/backend/postmaster/walsummarizer.c
M src/bin/pg_combinebackup/meson.build
A src/bin/pg_combinebackup/t/007_wal_level_minimal.pl
M src/include/access/xlog_internal.h
M src/include/catalog/pg_control.h

Add INJECTION_POINT_CACHED() to run injection points directly from cache

commit   : a0a5869a8598cdeae1d2f2d632038d26dcc69d19    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 18 Jul 2024 09:50:41 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 18 Jul 2024 09:50:41 +0900    

Click here for diff

This new macro is able to perform a direct lookup from the local cache  
of injection points (refreshed each time a point is loaded or run),  
without touching the shared memory state of injection points at all.  
  
This works in combination with INJECTION_POINT_LOAD(), and it is better  
than INJECTION_POINT() in a critical section due to the fact that it  
would avoid all memory allocations should a concurrent detach happen  
since a LOAD(), as it retrieves a callback from the backend-private  
memory.  
  
The documentation is updated to describe in more details how to use this  
new macro with a load.  Some tests are added to the module  
injection_points based on a new SQL function that acts as a wrapper of  
INJECTION_POINT_CACHED().  
  
Based on a suggestion from Heikki Linnakangas.  
  
Author: Heikki Linnakangas, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/xfunc.sgml
M src/backend/utils/misc/injection_point.c
M src/include/utils/injection_point.h
M src/test/modules/injection_points/expected/injection_points.out
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/sql/injection_points.sql

Doc: fix minor syntax error in example.

commit   : 6159331acfbe2d08361947324e09e446138c7bc1    
  
author   : Tom Lane <[email protected]>    
date     : Wed, 17 Jul 2024 15:17:52 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Wed, 17 Jul 2024 15:17:52 -0400    

Click here for diff

The CREATE TABLE option is GENERATED BY DEFAULT *AS* IDENTITY.  
  
Per bug #18543 from Ondřej Navrátil.  Seems to have crept in  
in a37bb7c13, so back-patch to v17 where that was added.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/ddl.sgml

Use PqMsg_* macros in more places.

commit   : a99cc6c6b4bf083d72fb1e8adfb665a449b7a37f    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 17 Jul 2024 10:51:00 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 17 Jul 2024 10:51:00 -0500    

Click here for diff

Commit f4b54e1ed9, which introduced macros for protocol characters,  
missed updating a few places.  It also did not introduce macros for  
messages sent from parallel workers to their leader processes.  
This commit adds a new section in protocol.h for those.  
  
Author: Aleksander Alekseev  
Discussion: https://postgr.es/m/CAJ7c6TNTd09AZq8tGaHS3LDyH_CCnpv0oOz2wN1dGe8zekxrdQ%40mail.gmail.com  
Backpatch-through: 17  

M src/backend/access/common/printtup.c
M src/backend/commands/explain.c
M src/backend/replication/walsender.c
M src/backend/tcop/postgres.c
M src/backend/utils/activity/backend_progress.c
M src/include/libpq/protocol.h

Avoid error in recovery test if history file is not yet present

commit   : f2a0d5808c246e556efbe3df0fb2be7841e3c988    
  
author   : Andrew Dunstan <[email protected]>    
date     : Wed, 17 Jul 2024 10:35:50 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Wed, 17 Jul 2024 10:35:50 -0400    

Click here for diff

Error was detected when testing use of libpq sessions instead of psql  
for polling queries.  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch to all live branches  

M src/test/recovery/t/002_archiving.pl

SQL/JSON: Rethink c2d93c3802b

commit   : 86d33987e8b0364b468c9b40c5f2a0a1aed87ef1    
  
author   : Amit Langote <[email protected]>    
date     : Wed, 17 Jul 2024 17:10:57 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Wed, 17 Jul 2024 17:10:57 +0900    

Click here for diff

This essentially reverts c2d93c3802b except tests. The problem with  
c2d93c3802b was that it only changed the casting behavior for types  
with typmod, and had coding issues noted in the post-commit review.  
  
This commit changes coerceJsonFuncExpr() to use assignment-level casts  
instead of explicit casts to coerce the result of JSON constructor  
functions to the specified or the default RETURNING type.  Using  
assignment-level casts fixes the problem that using explicit casts was  
leading to the wrong typmod / length coercion behavior -- truncating  
results longer than the specified length instead of erroring out --  
which c2d93c3802b aimed to solve.  
  
That restricts the set of allowed target types to string types, the  
same set that's currently allowed.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/parser/parse_expr.c

Make write of pgstats file durable at shutdown

commit   : ec678692f6d0a8b05b86ca08e96b51e4063cba32    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 17 Jul 2024 11:50:36 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 17 Jul 2024 11:50:36 +0900    

Click here for diff

This switches the pgstats write code to use durable_rename() rather than  
rename().  This ensures that the stats file's data is durable when the  
statistics are written, which is something only happening at shutdown  
now with the checkpointer doing the job.  
  
This could cause the statistics to be lost even after PostgreSQL is shut  
down, should a host failure happen, for example.  
  
Suggested-by: Konstantin Knizhnik  
Reviewed-by: Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/activity/pgstat.c

When creating materialized views, use REFRESH to load data.

commit   : 4b74ebf726d444ba820830cad986a1f92f724649    
  
author   : Jeff Davis <[email protected]>    
date     : Tue, 16 Jul 2024 15:41:29 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Tue, 16 Jul 2024 15:41:29 -0700    

Click here for diff

Previously, CREATE MATERIALIZED VIEW ... WITH DATA populated the MV  
the same way as CREATE TABLE ... AS.  
  
Instead, reuse the REFRESH logic, which locks down security-restricted  
operations and restricts the search_path. This reduces the chance that  
a subsequent refresh will fail.  
  
Reported-by: Noah Misch  
Backpatch-through: 17  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/createas.c
M src/backend/commands/matview.c
M src/include/commands/matview.h
M src/test/regress/expected/namespace.out

Add a couple of recent commits to .git-blame-ignore-revs.

commit   : 0a8ca122e511884d98a640cb3302866b74638688    
  
author   : Nathan Bossart <[email protected]>    
date     : Tue, 16 Jul 2024 11:04:55 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Tue, 16 Jul 2024 11:04:55 -0500    

Click here for diff

M .git-blame-ignore-revs

Adjust recently added test for pg_signal_autovacuum role

commit   : 49546ae9c74f02dc2a0d6b5469ba0bb025ae25c2    
  
author   : Andrew Dunstan <[email protected]>    
date     : Tue, 16 Jul 2024 10:05:48 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Tue, 16 Jul 2024 10:05:48 -0400    

Click here for diff

This test was added by commit d2b74882ca, but fails if  
log_error_verbosity is set to verbose. Adjust the regex that checks the  
error message to allow for it containing an SQL status code.  

M src/test/modules/test_misc/t/006_signal_autovacuum.pl

SQL/JSON: Fix a paragraph in JSON_TABLE documentation

commit   : 884d791b213d6bc55f7f9b70d951f395e3ee29bb    
  
author   : Amit Langote <[email protected]>    
date     : Tue, 16 Jul 2024 14:10:58 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Tue, 16 Jul 2024 14:10:58 +0900    

Click here for diff

Using <replaceable>text</replaceable> inside parantheses is not a  
common or good style, so rephrase a sentence to avoid that style.  
Also rephrase the text in that paragraph a bit while at it.  
  
Reported-by: Marcos Pegoraro <[email protected]>  
Author: Jian He <[email protected]>  
Reviewed-by: Daniel Gustafsson <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Discussion: https://postgr.es/m/CAB-JLwZqH3Yec6Kz-4-+pa0ZG9QJBsxjJZwYcMZYzEDR_fXnKw@mail.gmail.com  

M doc/src/sgml/func.sgml

Add tap test for pg_signal_autovacuum role

commit   : d2b74882cab84b9f4fdce0f2f32e892ba9164f5c    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 16 Jul 2024 10:05:46 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 16 Jul 2024 10:05:46 +0900    

Click here for diff

This commit provides testig coverage for ccd38024bc3c, checking that a  
role granted pg_signal_autovacuum_worker is able to stop a vacuum  
worker.  
  
An injection point with a wait is placed at the beginning of autovacuum  
worker startup to make sure that a worker is still alive when sending  
and processing the signal sent.  
  
Author: Anthony Leung, Michael Paquier, Kirill Reshke  
Reviewed-by: Andrey Borodin, Nathan Bossart  
Discussion: https://postgr.es/m/CALdSSPiQPuuQpOkF7x0g2QkA5eE-3xXt7hiJFvShV1bHKDvf8w@mail.gmail.com  

M src/backend/postmaster/autovacuum.c
M src/test/modules/test_misc/meson.build
A src/test/modules/test_misc/t/006_signal_autovacuum.pl

Fix bad indentation introduced in 43cd30bcd1c

commit   : 47ecbfdfcc71e41d7dcc35f0be04f8adbe88397f    
  
author   : Andres Freund <[email protected]>    
date     : Mon, 15 Jul 2024 15:11:56 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Mon, 15 Jul 2024 15:11:56 -0700    

Click here for diff

Oops.  
  
Reported-by: Nathan Bossart <[email protected]>  
Discussion: https://postgr.es/m/ZpVZB9rH5tHllO75@nathan  
Backpatch: 12-, like 43cd30bcd1c  

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

ci: Use newer LLVM version with gcc, to avoid compiler warnings

commit   : 4128453003dc755d94dfd661fb04d741f08e7fc8    
  
author   : Andres Freund <[email protected]>    
date     : Mon, 15 Jul 2024 15:04:15 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Mon, 15 Jul 2024 15:04:15 -0700    

Click here for diff

gcc emits a warning for LLVM 14 code outside of our control. To avoid that,  
update to a newer LLVM version. Do so both in the CompilerWarnings and normal  
tasks - the latter don't fail, but the warnings make it more likely that we'd  
miss other warnings.  
  
We might want to backpatch this eventually. The higher priority right now is  
to unbreak CI though - which is only broken on master, due to 0c3930d0768  
interacting badly with c8a6ec206a9 (mea culpa, I should have noticed this  
before pushing, but I missed it due to another, independent CI failure).  
  
Discussion: https://postgr.es/m/[email protected]  

M .cirrus.tasks.yml

Add missing RestrictSearchPath() calls.

commit   : 8e28778ce396c3dac74a5fa8724e1ca7cea16d19    
  
author   : Jeff Davis <[email protected]>    
date     : Mon, 15 Jul 2024 12:07:03 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Mon, 15 Jul 2024 12:07:03 -0700    

Click here for diff

Reported-by: Noah Misch  
Backpatch-through: 17  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/indexcmds.c

ci: Upgrade to Debian Bookworm

commit   : c8a6ec206a9940551f3de80a6e5a10377056781c    
  
author   : Andres Freund <[email protected]>    
date     : Mon, 15 Jul 2024 09:26:01 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Mon, 15 Jul 2024 09:26:01 -0700    

Click here for diff

Bullseye is getting long in the tooth, upgrade to the current stable version.  
  
Backpatch to all versions with CI support, we don't want to generate CI images  
for multiple Debian versions.  
  
Author: Nazir Bilal Yavuz <[email protected]>  
Discussion: https://postgr.es/m/CAN55FZ0fY5EFHXLKCO_%3Dp4pwFmHRoVom_qSE_7B48gpchfAqzw%40mail.gmail.com  
Backpatch: 15-, where CI was added  

M .cirrus.tasks.yml

Fix type confusion in guc_var_compare()

commit   : 43cd30bcd1cd4f03bce207938f69a9dc190f1c48    
  
author   : Andres Freund <[email protected]>    
date     : Mon, 15 Jul 2024 09:26:01 -0700    
  
committer: Andres Freund <[email protected]>    
date     : Mon, 15 Jul 2024 09:26:01 -0700    

Click here for diff

Before this change guc_var_compare() cast the input arguments to  
const struct config_generic *.  That's not quite right however, as the input  
on one side is often just a char * on one side.  
  
Instead just use char *, the first field in config_generic.  
  
This fixes a -Warray-bounds warning with some versions of gcc. While the  
warning is only known to be triggered for <= 15, the issue the warning points  
out seems real, so apply the fix everywhere.  
  
Author: Nazir Bilal Yavuz <[email protected]>  
Reported-by: Erik Rijkers <[email protected]>  
Suggested-by: Andres Freund <[email protected]>  
Discussion: https://postgr.es/m/a74a1a0d-0fd2-3649-5224-4f754e8f91aa%40xs4all.nl  

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

Doc: minor improvements for plpgsql "Transaction Management" section.

commit   : a0899c0a97d19b0c330ff885af4b78b3e7efb100    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 15 Jul 2024 11:59:43 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 15 Jul 2024 11:59:43 -0400    

Click here for diff

Point out that savepoint commands cannot be issued in PL/pgSQL,  
and suggest that exception blocks can usually be used instead.  
  
Add a caveat to the discussion of cursor loops vs. transactions,  
pointing out that any locks taken by the cursor query will be lost  
at COMMIT.  This is implicit in what's already said, but the existing  
text leaves the distinct impression that the auto-hold behavior is  
transparent, which it's not really.  
  
Per a couple of recent complaints (one unsigned, and one in bug #18531  
from Dzmitry Jachnik).  Back-patch to v17, just so this makes it into  
current docs in less than a year-and-a-half.  
  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/plpgsql.sgml

Run LLVM verify pass on IR in assert builds.

commit   : 8583b1f99340f4de24661dc50ab63ec6965f6759    
  
author   : Thomas Munro <[email protected]>    
date     : Mon, 15 Jul 2024 16:20:09 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Mon, 15 Jul 2024 16:20:09 +1200    

Click here for diff

The problem fixed by commit 53c8d6c9 would have been noticed if we'd  
been running LLVM's verify pass on generated IR.  Doing so also reveals  
a complaint about incorrect name mangling, fixed here.  Only enabled for  
LLVM 17+ because it uses the new pass manager API.  
  
Suggested-by: Dmitry Dolgov <[email protected]>  
Discussion: https://postgr.es/m/CAFj8pRACpVFr7LMdVYENUkScG5FCYMZDDdSGNU-tch%2Bw98OxYg%40mail.gmail.com  

M src/backend/jit/llvm/llvmjit.c
M src/backend/jit/llvm/llvmjit_expr.c

Use correct type for pq_mq_parallel_leader_proc_number variable

commit   : 91651347bae1026afefc648ff939e286878c1cf3    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 15 Jul 2024 11:12:22 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 15 Jul 2024 11:12:22 +0300    

Click here for diff

It's a ProcNumber, not a process id. Both are integers, so it's  
harmless, but clearly wrong. It's been wrong since forever, the  
mistake has survived through a couple of refactorings already.  
  
Spotted-by: Thomas Munro  
Discussion: https://www.postgresql.org/message-id/CA+hUKGKPTLSGMyE4Brin-osY8omPLNXmVWDMfrRABLp=6QrR_Q@mail.gmail.com  

M src/backend/libpq/pqmq.c

Use atomics to avoid locking in InjectionPointRun()

commit   : 86db52a5062a77c6ee533586be2cef8672a20c7d    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 15 Jul 2024 10:21:16 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 15 Jul 2024 10:21:16 +0300    

Click here for diff

This allows using injection points without having a PGPROC, like early  
at backend startup, or in the postmaster.  
  
The injection points facility is new in v17, so backpatch there.  
  
Reviewed-by: Michael Paquier <[email protected]>  
Disussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/utils/misc/injection_point.c
M src/tools/pgindent/typedefs.list

Fix unstable tests in partition_merge.sql and partition_split.sql.

commit   : 4e5d6c40914e2b890c4780d33de8ad07b1d79689    
  
author   : Fujii Masao <[email protected]>    
date     : Mon, 15 Jul 2024 14:09:30 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Mon, 15 Jul 2024 14:09:30 +0900    

Click here for diff

The tests added by commit c086896625 were unstable due to  
missing schema names when checking pg_tables and pg_indexes.  
  
Backpatch to v17.  
  
Reported by buildfarm.  

M src/test/regress/expected/partition_merge.out
M src/test/regress/expected/partition_split.out
M src/test/regress/sql/partition_merge.sql
M src/test/regress/sql/partition_split.sql

Fix tablespace handling in MERGE/SPLIT partition commands.

commit   : c0868966253218d83caeeac4bfd92ca6f4994537    
  
author   : Fujii Masao <[email protected]>    
date     : Mon, 15 Jul 2024 13:11:51 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Mon, 15 Jul 2024 13:11:51 +0900    

Click here for diff

As commit ca4103025d stated, new partitions without a specified tablespace  
should inherit the parent relation's tablespace. However, previously,  
ALTER TABLE MERGE PARTITIONS and ALTER TABLE SPLIT PARTITION commands  
always created new partitions in the default tablespace, ignoring  
the parent's tablespace. This commit ensures new partitions inherit  
the parent's tablespace.  
  
Backpatch to v17 where these commands were introduced.  
  
Author: Fujii Masao  
Reviewed-by: Masahiko Sawada  
Discussion: https://postgr.es/m/[email protected]  

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

Check lateral references within PHVs for memoize cache keys

commit   : 069d0ff0226b9ac999030b894db8defd4df186e0    
  
author   : Richard Guo <[email protected]>    
date     : Mon, 15 Jul 2024 10:26:33 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Mon, 15 Jul 2024 10:26:33 +0900    

Click here for diff

If we intend to generate a Memoize node on top of a path, we need  
cache keys of some sort.  Currently we search for the cache keys in  
the parameterized clauses of the path as well as the lateral_vars of  
its parent.  However, it turns out that this is not sufficient because  
there might be lateral references derived from PlaceHolderVars, which  
we fail to take into consideration.  
  
This oversight can cause us to miss opportunities to utilize the  
Memoize node.  Moreover, in some plans, failing to recognize all the  
cache keys could result in performance regressions.  This is because  
without identifying all the cache keys, we would need to purge the  
entire cache every time we get a new outer tuple during execution.  
  
This patch fixes this issue by extracting lateral Vars from within  
PlaceHolderVars and subsequently including them in the cache keys.  
  
In passing, this patch also includes a comment clarifying that Memoize  
nodes are currently not added on top of join relation paths.  This  
explains why this patch only considers PlaceHolderVars that are due to  
be evaluated at baserels.  
  
Author: Richard Guo  
Reviewed-by: Tom Lane, David Rowley, Andrei Lepikhov  
Discussion: https://postgr.es/m/CAMbWs48jLxn0pAPZpJ50EThZ569Xrw+=4Ac3QvkpQvNszbeoNg@mail.gmail.com  

M contrib/postgres_fdw/expected/postgres_fdw.out
M src/backend/optimizer/path/joinpath.c
M src/test/regress/expected/memoize.out
M src/test/regress/sql/memoize.sql

Avoid unhelpful internal error for incorrect recursive-WITH queries.

commit   : f96c2c72788cab3005c8bc6b4934b4928b34a529    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 14 Jul 2024 13:49:46 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 14 Jul 2024 13:49:46 -0400    

Click here for diff

checkWellFormedRecursion would issue "missing recursive reference"  
if a WITH RECURSIVE query contained a single self-reference but  
that self-reference was inside a top-level WITH, ORDER BY, LIMIT,  
etc, rather than inside the second arm of the UNION as expected.  
We already intended to throw more-on-point errors for such cases,  
but those error checks must be done before examining the UNION arm  
in order to have the desired results.  So this patch need only  
move some code (and improve the comments).  
  
Per bug #18536 from Alexander Lakhin.  Back-patch to all supported  
branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/parser/parse_cte.c
M src/test/regress/expected/with.out
M src/test/regress/sql/with.sql

Fix new assertion for MERGE view_name ... DO NOTHING.

commit   : d5e6891502ca9e359aa5f5a381d904fe9d606338    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 13 Jul 2024 08:09:33 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 13 Jul 2024 08:09:33 -0700    

Click here for diff

Such queries don't expand automatically updatable views, and ModifyTable  
uses the wholerow attribute unconditionally.  The user-visible behavior  
is fine, so change to more-specific assertions.  Commit  
d5f788b41dc2cbdde6e7694c70dda54d829a5ed5 added the wrong assertion.  
Back-patch to v17, where commit 5f2e179bd31e5f5803005101eb12a8d7bf8db8f3  
introduced MERGE view_name.  
  
Reported by Alexander Lakhin.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/nodeModifyTable.c
M src/test/regress/expected/updatable_views.out
M src/test/regress/sql/updatable_views.sql

Don't lose partitioned table reltuples=0 after relhassubclass=f.

commit   : 7102070329d8147246d2791321f9915c3b5abf31    
  
author   : Noah Misch <[email protected]>    
date     : Sat, 13 Jul 2024 08:09:33 -0700    
  
committer: Noah Misch <[email protected]>    
date     : Sat, 13 Jul 2024 08:09:33 -0700    

Click here for diff

ANALYZE sets relhassubclass=f when a partitioned table no longer has  
partitions.  An ANALYZE doing that proceeded to apply the inplace update  
of pg_class.reltuples to the old pg_class tuple instead of the new  
tuple, losing that reltuples=0 change if the ANALYZE committed.  
Non-partitioning inheritance trees were unaffected.  Back-patch to v14,  
where commit 375aed36ad83f0e021e9bdd3a0034c0c992c66dc introduced  
maintenance of partitioned table pg_class.reltuples.  
  
Reported by Alexander Lakhin.  
  
Discussion: https://postgr.es/m/[email protected]  

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

Make sure to run pg_isready on correct port

commit   : 055891f374a347aedd53c5b4fc79caf0a5522e18    
  
author   : Andrew Dunstan <[email protected]>    
date     : Fri, 12 Jul 2024 18:29:15 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Fri, 12 Jul 2024 18:29:15 -0400    

Click here for diff

The current code can have pg_isready unexpectedly succeed if there is a  
server running on the default port. To avoid this we delay running the  
test until after a node has been created but before it starts, and then  
use that node's port, so we are fairly sure there is nothing running on  
the port.  
  
Backpatch to all live branches.  

M src/bin/scripts/t/080_pg_isready.pl

Fix lost Windows socket EOF events.

commit   : a8458f508a7a441242e148f008293128676df003    
  
author   : Thomas Munro <[email protected]>    
date     : Sat, 13 Jul 2024 14:59:46 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Sat, 13 Jul 2024 14:59:46 +1200    

Click here for diff

Winsock only signals an FD_CLOSE event once if the other end of the  
socket shuts down gracefully.  Because each WaitLatchOrSocket() call  
constructs and destroys a new event handle every time, with unlucky  
timing we can lose it and hang.  We get away with this only if the other  
end disconnects non-gracefully, because FD_CLOSE is repeatedly signaled  
in that case.  
  
To fix this design flaw in our Windows socket support fundamentally,  
we'd probably need to rearchitect it so that a single event handle  
exists for the lifetime of a socket, or switch to completely different  
multiplexing or async I/O APIs.  That's going to be a bigger job  
and probably wouldn't be back-patchable.  
  
This brute force kludge closes the race by explicitly polling with  
MSG_PEEK before sleeping.  
  
Back-patch to all supported releases.  This should hopefully clear up  
some random build farm and CI hang failures reported over the years.  It  
might also allow us to try using graceful shutdown in more places again  
(reverted in commit 29992a6) to fix instability in the transmission of  
FATAL error messages, but that isn't done by this commit.  
  
Reported-by: Tom Lane <[email protected]>  
Tested-by: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/176008.1715492071%40sss.pgh.pa.us  

M src/backend/storage/ipc/latch.c

Use diff --strip-trailing-cr in pg_regress.c

commit   : 291c420747211ffa04678434b43eac26b353f470    
  
author   : Andrew Dunstan <[email protected]>    
date     : Fri, 12 Jul 2024 18:20:40 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Fri, 12 Jul 2024 18:20:40 -0400    

Click here for diff

This was reverted in commit c194de0713. However with a correct  
collate.windows.win1252.out we can now re-enable it.  
  
Discussion: https://postgr.es/m/CAN55FZ1objLz3Vn5Afu4ojNESMQpxjxKcp2q18yrKF4eKMLENg@mail.gmail.com  

M src/test/regress/expected/collate.windows.win1252.out
M src/test/regress/pg_regress.c

Add ORDER BY to new test query

commit   : 74e12db19cbc78258a92da8be637a3fb0106b126    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 12 Jul 2024 13:44:19 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 12 Jul 2024 13:44:19 +0200    

Click here for diff

Per buildfarm.  

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

Fix ALTER TABLE DETACH for inconsistent indexes

commit   : 83917791385a601bfe8afe95f250cb2ae6c1fde7    
  
author   : Alvaro Herrera <[email protected]>    
date     : Fri, 12 Jul 2024 12:54:01 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Fri, 12 Jul 2024 12:54:01 +0200    

Click here for diff

When a partitioned table has an index that doesn't support a constraint,  
but a partition has an equivalent index that does, then a DETACH  
operation would misbehave: a crash in assertion-enabled systems (because  
we fail to find the constraint in the parent that we expect to), or a  
broken coninhcount value (-1) in production systems (because we blindly  
believe that we've successfully detached the parent).  
  
While we should reject an ATTACH of a partition with such an index, we  
have failed to do so in existing releases, so adding an error in stable  
releases might break the (unlikely) existing applications that rely on  
this behavior.  At this point I don't even want to reject them in  
master, because it'd break pg_upgrade if such databases exist, and there  
would be no easy way to fix existing databases without expensive index  
rebuilds.  
  
(Later on we could add ALTER TABLE ... ADD CONSTRAINT USING INDEX to  
partitioned tables, which would allow the user to fix such patterns.  At  
that point we could add more restrictions to prevent the problem from  
its root.)  
  
Also, add a test case that leaves one table in this condition, so that  
we can verify that pg_upgrade continues to work if we later decide to  
change the policy on the master branch.  
  
Backpatch to all supported branches.  
  
Co-authored-by: Tender Wang <[email protected]>  
Reported-by: Alexander Lakhin <[email protected]>  
Reviewed-by: Tender Wang <[email protected]>  
Reviewed-by: Michael Paquier <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

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

Add assertion in pgstat_write_statsfile() about processes allowed

commit   : 734c057a8935fca10ff67173c8b969ef799ea7d2    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 12 Jul 2024 15:09:53 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 12 Jul 2024 15:09:53 +0900    

Click here for diff

This routine can currently only be called from the postmaster in  
single-user mode or the checkpointer, but there was no sanity check to  
make sure that this was always the case.  
  
This has proved to be useful when hacking the zone (at least to me), to  
make sure that the write of the pgstats file happens at shutdown, as  
wanted by design, in the correct process context.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/activity/pgstat.c

Fix a typo in logicalrep_write_typ().

commit   : 63909da9783a4736b01911fe3ee829651ff3c7d8    
  
author   : Amit Kapila <[email protected]>    
date     : Fri, 12 Jul 2024 10:20:59 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Fri, 12 Jul 2024 10:20:59 +0530    

Click here for diff

Author: ChangAo Chen  
Discussion: https://postgr.es/m/[email protected]  

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

Fix unstable test in 040_pg_createsubscriber.

commit   : 9fd8b331dfe151b7c833e2c8fa17ce753830b891    
  
author   : Amit Kapila <[email protected]>    
date     : Fri, 12 Jul 2024 09:29:21 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Fri, 12 Jul 2024 09:29:21 +0530    

Click here for diff

The slot synchronization failed because the local slot's (created during  
slot synchronization) catalog_xmin on standby is ahead of remote slot.  
This happens because the INSERT before slot synchronization results in the  
generation of a new xid that could be replicated to the standby. Now  
before the xmin of the physical slot on the primary catches up via  
hot_standby_feedback, the test has created a logical slot that got some  
prior value of catalog_xmin.  
  
To fix this we could try to ensure that the physical slot's catalog_xmin  
is caught up to latest value before creating a logical slot but we took a  
simpler path to move the INSERT after synchronizing the logical slot.  
  
Reported-by: Alexander Lakhin as per buildfarm  
Diagnosed-by: Amit Kapila, Hou Zhijie, Alexander Lakhin  
Author: Hou Zhijie  
Backpatch-through: 17  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_basebackup/t/040_pg_createsubscriber.pl

Consider materializing the cheapest inner path in parallel nestloop

commit   : 22d946b0f86f9c13f869bb8b75444a77a20134d8    
  
author   : Richard Guo <[email protected]>    
date     : Fri, 12 Jul 2024 11:16:43 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Fri, 12 Jul 2024 11:16:43 +0900    

Click here for diff

When generating non-parallel nestloop paths for each available outer  
path, we always consider materializing the cheapest inner path if  
feasible.  Similarly, in this patch, we also consider materializing  
the cheapest inner path when building partial nestloop paths.  This  
approach potentially reduces the need to rescan the inner side of a  
partial nestloop path for each outer tuple.  
  
Author: Tender Wang  
Reviewed-by: Richard Guo, Robert Haas, David Rowley, Alena Rybakina  
Reviewed-by: Tomasz Rybak, Paul Jungwirth, Yuki Fujii  
Discussion: https://postgr.es/m/CAHewXNkPmtEXNfVQMou_7NqQmFABca9f4etjBtdbbm0ZKDmWvw@mail.gmail.com  

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

Improve comment of pgstat_read_statsfile()

commit   : 72c0b24b2ddd2d2a2b85d19222845c8c7ae3cbdb    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 12 Jul 2024 09:31:33 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 12 Jul 2024 09:31:33 +0900    

Click here for diff

The comment at the top of pgstat_read_statsfile() mentioned that the  
stats are read from the on-disk file into the pgstats dshash.  This is  
incorrect for fix-numbered stats as these are loaded directly into  
shared memory.  This commit simplifies the comment to be more general.  
  
Author: Bertrand Drouvot  
Discussion: https://postgr.es/m/Zo/[email protected]  

M src/backend/utils/activity/pgstat.c

Improve logical replication connection-failure messages.

commit   : 0d8bd0a72ea284ffb1d1154efbe799241cc5edc6    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 11 Jul 2024 13:21:13 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 11 Jul 2024 13:21:13 -0400    

Click here for diff

These messages mostly said "could not connect to the publisher: %s"  
which is lacking context.  Add some verbiage to indicate which  
subscription or worker process is failing.  
  
Nisha Moond  
  
Discussion: https://postgr.es/m/CABdArM7q1=zqL++cYd0hVMg3u_tc0S=0Of=Um-KvDhLony0cSg@mail.gmail.com  

M src/backend/commands/subscriptioncmds.c
M src/backend/replication/logical/slotsync.c
M src/backend/replication/logical/tablesync.c
M src/backend/replication/logical/worker.c
M src/backend/replication/slotfuncs.c
M src/backend/replication/walreceiver.c
M src/test/regress/expected/subscription.out

Add min and max aggregates for composite types (records).

commit   : a0f1fce80c0373c16b22a1bdc9b0b61958fc9b6a    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 11 Jul 2024 11:50:50 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 11 Jul 2024 11:50:50 -0400    

Click here for diff

Like min/max for arrays, these are just thin wrappers around  
the existing btree comparison function for records.  
  
Aleksander Alekseev  
  
Discussion: https://postgr.es/m/CAO=iB8L4WYSNxCJ8GURRjQsrXEQ2-zn3FiCsh2LMqvWq2WcONg@mail.gmail.com  

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

Fix possibility of logical decoding partial transaction changes.

commit   : bb19b70081e2248f242cd00227abff5b1e105eb6    
  
author   : Masahiko Sawada <[email protected]>    
date     : Thu, 11 Jul 2024 22:48:23 +0900    
  
committer: Masahiko Sawada <[email protected]>    
date     : Thu, 11 Jul 2024 22:48:23 +0900    

Click here for diff

When creating and initializing a logical slot, the restart_lsn is set  
to the latest WAL insertion point (or the latest replay point on  
standbys). Subsequently, WAL records are decoded from that point to  
find the start point for extracting changes in the  
DecodingContextFindStartpoint() function. Since the initial  
restart_lsn could be in the middle of a transaction, the start point  
must be a consistent point where we won't see the data for partial  
transactions.  
  
Previously, when not building a full snapshot, serialized snapshots  
were restored, and the SnapBuild jumps to the consistent state even  
while finding the start point. Consequently, the slot's restart_lsn  
and confirmed_flush could be set to the middle of a transaction. This  
could lead to various unexpected consequences. Specifically, there  
were reports of logical decoding decoding partial transactions, and  
assertion failures occurred because only subtransactions were decoded  
without decoding their top-level transaction until decoding the commit  
record.  
  
To resolve this issue, the changes prevent restoring the serialized  
snapshot and jumping to the consistent state while finding the start  
point.  
  
On v17 and HEAD, a flag indicating whether snapshot restores should be  
skipped has been added to the SnapBuild struct, and SNAPBUILD_VERSION  
has been bumpded.  
  
On backbranches, the flag is stored in the LogicalDecodingContext  
instead, preserving on-disk compatibility.  
  
Backpatch to all supported versions.  
  
Reported-by: Drew Callahan  
Reviewed-by: Amit Kapila, Hayato Kuroda  
Discussion: https://postgr.es/m/2444AA15-D21B-4CCE-8052-52C7C2DAFE5C%40amazon.com  
Backpatch-through: 12  

M contrib/test_decoding/Makefile
A contrib/test_decoding/expected/skip_snapshot_restore.out
M contrib/test_decoding/meson.build
A contrib/test_decoding/specs/skip_snapshot_restore.spec
M src/backend/replication/logical/logical.c
M src/backend/replication/logical/snapbuild.c
M src/include/replication/snapbuild.h

Change pg_regress.c back to using diff -w on Windows

commit   : c194de0713ebe71aaeeb5ebed4af2390cc1b521c    
  
author   : Andrew Dunstan <[email protected]>    
date     : Thu, 11 Jul 2024 09:34:27 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Thu, 11 Jul 2024 09:34:27 -0400    

Click here for diff

This partially reverts commit 628c1d1f2c.  
  
It appears that there are non line-end differences in some regression  
tests on Windows. To keep the buildfarm and CI clients happy, change  
this back for now, pending further investigation.  
  
Per reports from Tatsuo Ishii and Nazir Bilal Yavuz.  

M src/test/regress/pg_regress.c

Add a new 'F' entry type for fixed-numbered stats in pgstats file

commit   : 9e4664d950c125a1ff7bb29cd1593ca37f8b0c01    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 11 Jul 2024 16:12:04 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 11 Jul 2024 16:12:04 +0900    

Click here for diff

This new entry type is used for all the fixed-numbered statistics,  
making possible support for custom pluggable stats.  In short, we need  
to be able to detect more easily if a stats kind exists or not when  
reading back its data from the pgstats file without a dependency on the  
order of the entries read.  The kind ID of the stats is added to the  
data written.  
  
The data is written in the same fashion as previously, with the  
fixed-numbered stats first and the dshash entries next.  The read part  
becomes more flexible, loading fixed-numbered stats into shared memory  
based on the new entry type found.  
  
Bump PGSTAT_FILE_FORMAT_ID.  
  
Reviewed-by: Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

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

Add PgStat_KindInfo.init_shmem_cb

commit   : 21471f18e9d9aa3383314ed8bc9163bc369109ae    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 11 Jul 2024 09:21:40 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 11 Jul 2024 09:21:40 +0900    

Click here for diff

This new callback gives fixed-numbered stats the possibility to take  
actions based on the area of shared memory allocated for them.  
  
This removes from pgstat_shmem.c any knowledge specific to the types  
of fixed-numbered stats, and the initializations happen in their own  
files.  Like b68b29bc8fec, this change is useful to make this area of  
the code more pluggable, so as custom fixed-numbered stats can take  
actions after their shared memory area is initialized.  
  
Reviewed-by: Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/activity/pgstat.c
M src/backend/utils/activity/pgstat_archiver.c
M src/backend/utils/activity/pgstat_bgwriter.c
M src/backend/utils/activity/pgstat_checkpointer.c
M src/backend/utils/activity/pgstat_io.c
M src/backend/utils/activity/pgstat_shmem.c
M src/backend/utils/activity/pgstat_slru.c
M src/backend/utils/activity/pgstat_wal.c
M src/include/utils/pgstat_internal.h

Revamp documentation for predefined roles.

commit   : cc2236854e2bb4f2120927c390c63cc2aad77762    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 10 Jul 2024 16:35:25 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 10 Jul 2024 16:35:25 -0500    

Click here for diff

Presently, the page for predefined roles contains a table with  
brief descriptions of what each role allows.  Below the table,  
there is a separate section with more detailed information about  
some of the roles.  As the set of predefined roles has grown over  
the years, this page has (IMHO) become less readable.  
  
This commit attempts to improve the predefined roles documentation  
by abandoning the table in favor of listing each role with its own  
complete description, similar to how we document GUCs.  Besides  
merging the information that was split between the table and the  
section below it, this commit also alphabetizes the roles.  The  
alphabetization is imperfect because some of the roles are grouped  
(e.g., pg_read_all_data and pg_write_all_data), and we order such  
groups by the first role mentioned, but that seemed like a better  
choice than breaking the groups apart.  Finally, this commit makes  
some stylistic adjustments to the text.  
  
Reviewed-by: David G. Johnston, Robert Haas  
Discussion: https://postgr.es/m/ZmtM-4-eRtq8DRf6%40nathan  

M doc/src/sgml/config.sgml
M doc/src/sgml/monitoring.sgml
M doc/src/sgml/ref/checkpoint.sgml
M doc/src/sgml/ref/reindex.sgml
M doc/src/sgml/user-manag.sgml

Improve the numeric width_bucket() computation.

commit   : 0dcf753bd82a786922f4149248117b113353e257    
  
author   : Dean Rasheed <[email protected]>    
date     : Wed, 10 Jul 2024 20:07:20 +0100    
  
committer: Dean Rasheed <[email protected]>    
date     : Wed, 10 Jul 2024 20:07:20 +0100    

Click here for diff

Formerly, the computation of the bucket index involved calling  
div_var() with a scale determined by select_div_scale(), and then  
taking the floor of the result. That involved computing anything from  
16 to 1000 digits after the decimal point, only for floor_var() to  
throw them away. In addition, the quotient was computed with rounding  
in the final digit, which meant that in rare cases the whole result  
could round up to the wrong bucket, and could exceed count. Thus it  
was also necessary to clamp the result to the range [1, count], though  
that didn't prevent the result being in the wrong internal bucket.  
  
Instead, compute the quotient using floor division, which guarantees  
the correct result, as specified by the SQL spec, and doesn't need to  
be clamped. This is both much simpler and more efficient, since it no  
longer computes any quotient digits after the decimal point.  
  
In addition, it is not necessary to have separate code to handle  
reversed bounds, since the signs cancel out when dividing.  
  
As with b0e9e4d76c and a2a0c7c29e, no back-patch.  
  
Dean Rasheed, reviewed by Joel Jacobson.  
  
Discussion: https://postgr.es/m/CAEZATCVbJH%2BLE9EXW8Rk3AxLe%3DjbOk2yrT_AUJGGh5Rah6zoeg%40mail.gmail.com  

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

Use diff's --strip-trailing-cr flag where appropriate on Windows

commit   : 628c1d1f2c82f1983e5248b5dfe53170dc23d90a    
  
author   : Andrew Dunstan <[email protected]>    
date     : Wed, 10 Jul 2024 09:53:47 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Wed, 10 Jul 2024 09:53:47 -0400    

Click here for diff

Test result files might be checked out using Unix or Windows style line  
endings, depening on git flags, so on Windows we use the  
--strip-trailing-cr flag to tell diff to ignore line endings  
differences.  
  
The flag is added to the diff invocation for the test_json_parser module  
tests and the pg_bsd_indent tests. in pg_regress.c we replace the  
current use of the "-w" flag, which ignore all white space differences,  
with this one which only ignores line end differences.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/test/modules/test_json_parser/t/003_test_semantic.pl
M src/test/regress/pg_regress.c
M src/tools/pg_bsd_indent/t/001_pg_bsd_indent.pl

doc: Update track_io_timing documentation to mention pg_stat_io.

commit   : 05506510de6ae24ba6de00cef2f458920c8a72ea    
  
author   : Fujii Masao <[email protected]>    
date     : Wed, 10 Jul 2024 15:56:07 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Wed, 10 Jul 2024 15:56:07 +0900    

Click here for diff

The I/O timing information collected when track_io_timing is  
enabled is now documented to appear in the pg_stat_io view,  
which was previously not mentioned.  
  
This commit also enhances the description of track_io_timing  
to clarify that it monitors not only block read and write  
but also block extend and fsync operations. Additionally,  
the description of track_wal_io_timing has been improved  
to mention both WAL write and WAL fsync monitoring.  
  
Backpatch to v16 where pg_stat_io was added.  
  
Author: Hajime Matsunaga  
Reviewed-by: Melanie Plageman, Nazir Bilal Yavuz, Fujii Masao  
Discussion: https://postgr.es/m/TYWPR01MB10742EE4A6F34C33061429D38A4D52@TYWPR01MB10742.jpnprd01.prod.outlook.com  

M doc/src/sgml/config.sgml
M doc/src/sgml/monitoring.sgml

Extend pg_get_acl() to handle sub-object IDs

commit   : d898665bf7591514158954038ac43cea3240beaa    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 10 Jul 2024 10:14:37 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 10 Jul 2024 10:14:37 +0900    

Click here for diff

This patch modifies the pg_get_acl() function to accept a third argument  
called "objsubid", bringing it on par with similar functions in this  
area like pg_describe_object().  This enables the retrieval of ACLs for  
relation attributes when scanning dependencies.  
  
Bump catalog version.  
  
Author: Joel Jacobson  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml
M src/backend/catalog/objectaddress.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

Prevent CRLF conversion of inputs in json_parser test module

commit   : f7bd0a381de12a5c309f3c19d8c966b77e87cff3    
  
author   : Andrew Dunstan <[email protected]>    
date     : Tue, 9 Jul 2024 17:29:48 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Tue, 9 Jul 2024 17:29:48 -0400    

Click here for diff

Do this by opening the file in PG_BINARY_R mode. This prevents us from  
getting wrong byte count from stat().  
  
Per complaint from Andres Freund  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch to rlease 17 where this code was introduced  

M src/test/modules/test_json_parser/test_json_parser_incremental.c
M src/test/modules/test_json_parser/test_json_parser_perf.c

Remove new XML test cases added by e7192486d.

commit   : 896cd266fd34c2dfbf06297b9f2ea89ae8e5a0b1    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 9 Jul 2024 16:31:15 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 9 Jul 2024 16:31:15 -0400    

Click here for diff

These turn out to produce libxml2-version-dependent error reports.  
They aren't adding value that would justify dealing with that,  
so just remove them again.  (I had in fact guessed wrong about  
what versions matching xml_2.out would produce, but it doesn't  
matter because there are other discrepancies.)  
  
Per buildfarm.  
  
Discussion: https://postgr.es/m/trinity-b0161630-d230-4598-9ebc-7a23acdb37cb-1720186432160@3c-app-gmx-bap25  
Discussion: https://postgr.es/m/trinity-361ba18b-541a-4fe7-bc63-655ae3a7d599-1720259822452@3c-app-gmx-bs01  

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

Fix missing invalidations for search_path cache.

commit   : b3bd18294ee471c5a6f1db69be57f08c1e00f1a6    
  
author   : Jeff Davis <[email protected]>    
date     : Tue, 9 Jul 2024 11:27:17 -0700    
  
committer: Jeff Davis <[email protected]>    
date     : Tue, 9 Jul 2024 11:27:17 -0700    

Click here for diff

Reported-by: Noah Misch  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 17  

M src/backend/catalog/namespace.c

Suppress "chunk is not well balanced" errors from libxml2.

commit   : e7192486dded0ca82824fef95eb88b4231bdd4d2    
  
author   : Tom Lane <[email protected]>    
date     : Tue, 9 Jul 2024 15:01:05 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Tue, 9 Jul 2024 15:01:05 -0400    

Click here for diff

libxml2 2.13 has an entirely different rule than earlier versions  
about when to emit "chunk is not well balanced" errors.  This  
causes regression test output discrepancies for three test cases  
that formerly provoked that error (along with others) and now don't.  
  
Closer inspection shows that at least in 2.13, this error is pretty  
useless because it can only be emitted after some other more-relevant  
error.  So let's get rid of the cross-version discrepancy by just  
suppressing it.  In case some older libxml2 version is capable of  
emitting this error by itself, suppress only when some other error  
has already been captured.  
  
Like 066e8ac6e and 6082b3d5d, this will need to be back-patched,  
but let's check the results in HEAD first.  (The patch for xml_2.out,  
in particular, is blind since I can't test it here.)  
  
Erik Wienhold and Tom Lane, per report from Frank Streitzig.  
  
Discussion: https://postgr.es/m/trinity-b0161630-d230-4598-9ebc-7a23acdb37cb-1720186432160@3c-app-gmx-bap25  
Discussion: https://postgr.es/m/trinity-361ba18b-541a-4fe7-bc63-655ae3a7d599-1720259822452@3c-app-gmx-bs01  

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

Introduce pg_signal_autovacuum_worker.

commit   : ccd38024bc3c61e62af2097d408a670661713e68    
  
author   : Nathan Bossart <[email protected]>    
date     : Tue, 9 Jul 2024 13:03:40 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Tue, 9 Jul 2024 13:03:40 -0500    

Click here for diff

Since commit 3a9b18b309, roles with privileges of pg_signal_backend  
cannot signal autovacuum workers.  Many users treated the ability  
to signal autovacuum workers as a feature instead of a bug, so we  
are reintroducing it via a new predefined role.  Having privileges  
of this new role, named pg_signal_autovacuum_worker, only permits  
signaling autovacuum workers.  It does not permit signaling other  
types of superuser backends.  
  
Bumps catversion.  
  
Author: Kirill Reshke  
Reviewed-by: Anthony Leung, Michael Paquier, Andrey Borodin  
Discussion: https://postgr.es/m/CALdSSPhC4GGmbnugHfB9G0%3DfAxjCSug_-rmL9oUh0LTxsyBfsg%40mail.gmail.com  

M doc/src/sgml/func.sgml
M doc/src/sgml/user-manag.sgml
M src/backend/storage/ipc/signalfuncs.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_authid.dat

Fix comment in libpqrcv_check_conninfo().

commit   : 629520be5f9da9d0192c7f6c8796bfddb4746760    
  
author   : Fujii Masao <[email protected]>    
date     : Tue, 9 Jul 2024 21:03:56 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Tue, 9 Jul 2024 21:03:56 +0900    

Click here for diff

Previously, the comment incorrectly stated that libpqrcv_check_conninfo()  
returns true or false based on the connection string check.  
However, this function actually has a void return type and  
raises an error if the check fails.  
  
Author: Rintaro Ikeda  
Reviewed-by: Jelte Fennema-Nio, Fujii Masao  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Optimise numeric multiplication for short inputs.

commit   : ca481d3c9ab7bf69ff0c8d71ad3951d407f6a33c    
  
author   : Dean Rasheed <[email protected]>    
date     : Tue, 9 Jul 2024 10:00:42 +0100    
  
committer: Dean Rasheed <[email protected]>    
date     : Tue, 9 Jul 2024 10:00:42 +0100    

Click here for diff

When either input has a small number of digits, and the exact product  
is requested, the speed of numeric multiplication can be increased  
significantly by using a faster direct multiplication algorithm. This  
works by fully computing each result digit in turn, starting with the  
least significant, and propagating the carry up. This save cycles by  
not requiring a temporary buffer to store digit products, not making  
multiple passes over the digits of the longer input, and not requiring  
separate carry-propagation passes.  
  
For now, this is used when the shorter input has 1-4 NBASE digits (up  
to 13-16 decimal digits), and the longer input is of any size, which  
covers a lot of common real-world cases. Also, the relative benefit  
increases as the size of the longer input increases.  
  
Possible future work would be to try extending the technique to larger  
numbers of digits in the shorter input.  
  
Joel Jacobson and Dean Rasheed.  
  
Discussion: https://postgr.es/m/[email protected]  

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

SQL/JSON: Various improvements to SQL/JSON query function docs

commit   : 42de72fa7b80645347cd7ef3fbb6b0b58d0870f2    
  
author   : Amit Langote <[email protected]>    
date     : Tue, 9 Jul 2024 16:12:22 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Tue, 9 Jul 2024 16:12:22 +0900    

Click here for diff

1. Remove the keyword SELECT from the examples to be consistent  
with the examples of other JSON-related functions listed on the  
same page.  
  
2. Add <synopsis> tags around the functions' syntax definition  
  
3. Capitalize function names in the syntax synopsis and the examples  
  
4. Use <itemizedlist> lists for dividing the descriptions of  
   individual functions into bullet points  
  
5. Significantly rewrite the description of wrapper clauses of  
   JSON_QUERY  
  
6. Significantly rewrite the descriptions of ON ERROR / EMPTY  
   clauses of JSON_QUERY() and JSON_VALUE() functions  
  
7. Add a note about how JSON_VALUE() and JSON_QUERY() differ when  
   returning a JSON null result  
  
8. Move the description of the PASSING clause from the descriptions  
   of individual functions into the top paragraph  
  
And other miscellaneous text improvements, typo fixes.  
  
Suggested-by: Thom Brown <[email protected]>  
Suggested-by: David G. Johnston <[email protected]>  
Reviewed-by: Jian He <[email protected]>  
Reviewed-by: Erik Rijkers <[email protected]>  
Discussion: https://postgr.es/m/CAA-aLv7Dfy9BMrhUZ1skcg=OdqysWKzObS7XiDXdotJNF0E44Q@mail.gmail.com  
Discussion: https://postgr.es/m/CAKFQuwZNxNHuPk44zDF7z8qZec1Aof10aA9tWvBU5CMhEKEd8A@mail.gmail.com  

M doc/src/sgml/func.sgml

To improve the code, move the error check in logical_read_xlog_page().

commit   : 571f7f70865cdaf1a49e7934208ad139575e3f03    
  
author   : Amit Kapila <[email protected]>    
date     : Tue, 9 Jul 2024 09:00:45 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Tue, 9 Jul 2024 09:00:45 +0530    

Click here for diff

Commit 0fdab27ad6 changed the code to wait for WAL to be available before  
determining the timeline but forgot to move the failure check.  
  
This change is to make the related code easier to understand and enhance  
otherwise there is no bug in the current code.  
  
In the passing, improve the nearby comments to explain why we determine  
am_cascading_walsender after waiting for the required WAL.  
  
Author: Peter Smith  
Reviewed-by: Bertrand Drouvot, Amit Kapila  
Discussion: https://postgr.es/m/CAHut+PvqX49fusLyXspV1Mmd_EekPtXG0oT146vZjcb9XDvNgw@mail.gmail.com  

M src/backend/replication/walsender.c

Use pgstat_kind_infos to write fixed shared statistics

commit   : b68b29bc8feca0eb340cb857ff1d28d4099c7878    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 9 Jul 2024 10:27:12 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 9 Jul 2024 10:27:12 +0900    

Click here for diff

This is similar to 9004abf6206e, but this time for the write part of the  
stats file.  The code is changed so as, rather than referring to  
individual members of PgStat_Snapshot in an order based on their  
PgStat_Kind value, a loop based on pgstat_kind_infos is used to retrieve  
the contents to write from the snapshot structure, for a size of  
PgStat_KindInfo's shared_data_len.  
  
This requires the addition to PgStat_KindInfo of an offset to track the  
location of each fixed-numbered stats in PgStat_Snapshot.  This change  
is useful to make this area of the code more easily pluggable, and  
reduces the knowledge of specific fixed-numbered kinds in pgstat.c.  
  
Reviewed-by: Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

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

commit   : c048cd992c69ed20acbd9059763735e51781e95a    
  
author   : David Rowley <[email protected]>    
date     : Tue, 9 Jul 2024 12:46:48 +1200    
  
committer: David Rowley <[email protected]>    
date     : Tue, 9 Jul 2024 12:46:48 +1200    

Click here for diff

036bdcec9 added some code to perform some verification on portions of  
the planner costs in EXPLAIN ANALYZE but failed to consider that some  
buildfarm animals such as bushmaster and taipan are running very low jit  
thresholds.  This caused these animals to fail as they were outputting  
JIT-related details in EXPLAIN ANALYZE for the newly added tests.  
  
Here we avoid that by disabling JIT for the plans in question.  
  
Discussion: https://postgr.es/m/CAApHDvpxV4rrO3XUCgGS5N9Wg6f2r0ojJPD2tX2FRV-o9sRTJA@mail.gmail.com  

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

Fix limit block handling in pg_wal_summary_contents().

commit   : c8d5d6c78af4a55c5c36e2fa8e73d1f2b2e9d777    
  
author   : Fujii Masao <[email protected]>    
date     : Tue, 9 Jul 2024 09:26:54 +0900    
  
committer: Fujii Masao <[email protected]>    
date     : Tue, 9 Jul 2024 09:26:54 +0900    

Click here for diff

Previously, pg_wal_summary_contents() had two issues,  
causing discrepancies between pg_wal_summary_contents()  
and the pg_walsummary command on the same WAL summary file:  
  
(1) It did not emit the limit block when that's the only data for  
     a particular relation fork.  
(2) It emitted the same limit block multiple times if the list of  
     block numbers was long enough.  
  
This commit fixes these issues.  
  
Backpatch to v17 where pg_wal_summary_contents() was added.  
  
Author: Fujii Masao  
Reviewed-by: Robert Haas  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/backup/walsummaryfuncs.c

Show Parallel Bitmap Heap Scan worker stats in EXPLAIN ANALYZE

commit   : 5a1e6df3b84c91957f80b19edb497a5eec83c403    
  
author   : David Rowley <[email protected]>    
date     : Tue, 9 Jul 2024 12:15:47 +1200    
  
committer: David Rowley <[email protected]>    
date     : Tue, 9 Jul 2024 12:15:47 +1200    

Click here for diff

Nodes like Memoize report the cache stats for each parallel worker, so it  
makes sense to show the exact and lossy pages in Parallel Bitmap Heap Scan  
in a similar way.  Likewise, Sort shows the method and memory used for  
each worker.  
  
There was some discussion on whether the leader stats should include the  
totals for each parallel worker or not.  I did some analysis on this to  
see what other parallel node types do and it seems only Parallel Hash does  
anything like this.  All the rest, per what's supported by  
ExecParallelRetrieveInstrumentation() are consistent with each other.  
  
Author: David Geier <[email protected]>  
Author: Heikki Linnakangas <[email protected]>  
Author: Donghang Lin <[email protected]>  
Author: Alena Rybakina <[email protected]>  
Author: David Rowley <[email protected]>  
Reviewed-by: Dmitry Dolgov <[email protected]>  
Reviewed-by: Michael Christofides <[email protected]>  
Reviewed-by: Robert Haas <[email protected]>  
Reviewed-by: Dilip Kumar <[email protected]>  
Reviewed-by: Tomas Vondra <[email protected]>  
Reviewed-by: Melanie Plageman <[email protected]>  
Reviewed-by: Donghang Lin <[email protected]>  
Reviewed-by: Masahiro Ikeda <[email protected]>  
Discussion: https://postgr.es/m/b3d80961-c2e5-38cc-6a32-61886cdf766d%40gmail.com  

M src/backend/commands/explain.c
M src/backend/executor/execParallel.c
M src/backend/executor/nodeBitmapHeapscan.c
M src/include/executor/nodeBitmapHeapscan.h
M src/include/nodes/execnodes.h
M src/tools/pgindent/typedefs.list

Perform forgotten cat version bump

commit   : e41f7130979442362d9053d1ae24b2f87980e842    
  
author   : David Rowley <[email protected]>    
date     : Tue, 9 Jul 2024 09:56:46 +1200    
  
committer: David Rowley <[email protected]>    
date     : Tue, 9 Jul 2024 09:56:46 +1200    

Click here for diff

I missed this in 036bdcec9  

M src/include/catalog/catversion.h

Teach planner how to estimate rows for timestamp generate_series

commit   : 036bdcec9f9998a6e50711fadce69e482ff18f55    
  
author   : David Rowley <[email protected]>    
date     : Tue, 9 Jul 2024 09:54:59 +1200    
  
committer: David Rowley <[email protected]>    
date     : Tue, 9 Jul 2024 09:54:59 +1200    

Click here for diff

This provides the planner with row estimates for  
generate_series(TIMESTAMP, TIMESTAMP, INTERVAL),  
generate_series(TIMESTAMPTZ, TIMESTAMPTZ, INTERVAL) and  
generate_series(TIMESTAMPTZ, TIMESTAMPTZ, INTERVAL, TEXT) when the input  
parameter values can be estimated during planning.  
  
Author: David Rowley  
Reviewed-by: jian he <[email protected]>  
Discussion: https://postgr.es/m/CAApHDvrBE%3D%2BASo_sGYmQJ3GvO8GPvX5yxXhRS%3Dt_ybd4odFkhQ%40mail.gmail.com  

M src/backend/utils/adt/timestamp.c
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/misc_functions.out
M src/test/regress/sql/misc_functions.sql

commit   : 5193ca8e155ac0140d20361bdafa27744c016252    
  
author   : Andrew Dunstan <[email protected]>    
date     : Mon, 8 Jul 2024 13:46:21 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Mon, 8 Jul 2024 13:46:21 -0400    

Click here for diff

This reverts commit e9f15bc9. Instead of a hacky solution that didn't  
work on Windows, we avoid trying to move the directory possibly across  
drives, and instead remove it and recreate it in the new location.  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch to release 14 like the previous patch.  

M src/bin/pg_basebackup/t/010_pg_basebackup.pl

Use CREATE DATABASE ... STRATEGY = FILE_COPY in pg_upgrade.

commit   : 64f34eb2e2ce4bca7351d8c88a6999aeed000c4a    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 8 Jul 2024 16:18:00 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 8 Jul 2024 16:18:00 -0500    

Click here for diff

While this strategy is ordinarily quite costly because it requires  
performing two checkpoints, testing shows that it tends to be a  
faster choice than WAL_LOG during pg_upgrade, presumably because  
fsync is turned off.  Furthermore, we can skip the checkpoints  
altogether because the problems they are intended to prevent don't  
apply to pg_upgrade.  Instead, we just need to CHECKPOINT once in  
the new cluster after making any changes to template0 and before  
restoring the rest of the databases.  This ensures that said  
template0 changes are written out to disk prior to creating the  
databases via FILE_COPY.  
  
Co-authored-by: Matthias van de Meent  
Reviewed-by: Ranier Vilela, Dilip Kumar, Robert Haas, Michael Paquier  
Discussion: https://postgr.es/m/Zl9ta3FtgdjizkJ5%40nathan  

M src/backend/commands/dbcommands.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_upgrade/pg_upgrade.c

Choose ports for test servers less likely to result in conflicts

commit   : 4b4b931bcdf23f5facd49809278a3048c4fdba1f    
  
author   : Andrew Dunstan <[email protected]>    
date     : Mon, 8 Jul 2024 11:18:06 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Mon, 8 Jul 2024 11:18:06 -0400    

Click here for diff

If we choose ports in the range typically used for ephemeral ports there  
is a danger of encountering a port conflict due to a race condition  
between the time we choose the port in a range below that typically used  
to allocate ephemeral ports, but higher than the range typically used by  
well known services.  
  
Author: Jelte Fenema-Nio, with some editing by me.  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch to all live branches (12 and up)  

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

Force nodes for SSL tests to start in TCP mode

commit   : e4f4c5424cf9564b934ac6f632c6c90a2edddb77    
  
author   : Andrew Dunstan <[email protected]>    
date     : Mon, 8 Jul 2024 05:51:26 -0400    
  
committer: Andrew Dunstan <[email protected]>    
date     : Mon, 8 Jul 2024 05:51:26 -0400    

Click here for diff

Currently they are started in unix socket mode in ost cases, and then  
converted to run in TCP mode. This can result in port collisions, and  
there is no virtue in startng in unix socket mode, so start as we will  
be going on.  
  
Discussion: https://postgr.es/m/[email protected]  
  
Backpatch to all live branches (12 and up).  

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

Use xmlParseInNodeContext not xmlParseBalancedChunkMemory.

commit   : 6082b3d5d3d141aa1ec67ff98955a0d8e12d0e1a    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 8 Jul 2024 14:04:00 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 8 Jul 2024 14:04:00 -0400    

Click here for diff

xmlParseInNodeContext has basically the same functionality with  
a different API: we have to supply an xmlNode that's attached to a  
document rather than just the document.  That's not hard though.  
The benefits are two:  
  
* Early 2.13.x releases of libxml2 contain a bug that causes  
xmlParseBalancedChunkMemory to return the wrong status value in some  
cases.  This breaks our regression tests.  While that bug is now fixed  
upstream and will probably never be seen in any production-oriented  
distro, it is currently a problem on some more-bleeding-edge-friendly  
platforms.  
  
* xmlParseBalancedChunkMemory is considered to depend on libxml2's  
semi-deprecated SAX1 APIs, and will go away when and if they do.  
There may already be libxml2 builds out there that lack this function.  
  
So there are both short- and long-term reasons to make this change.  
  
While here, avoid allocating an xmlParserCtxt in DOCUMENT parse mode,  
since that code path is not going to use it.  
  
Like 066e8ac6e, this will need to be back-patched.  This is just a  
trial commit to see if the buildfarm agrees that we can use  
xmlParseInNodeContext unconditionally.  
  
Erik Wienhold and Tom Lane, per report from Frank Streitzig.  
  
Discussion: https://postgr.es/m/trinity-b0161630-d230-4598-9ebc-7a23acdb37cb-1720186432160@3c-app-gmx-bap25  
Discussion: https://postgr.es/m/trinity-361ba18b-541a-4fe7-bc63-655ae3a7d599-1720259822452@3c-app-gmx-bs01  

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

Fix scale clamping in numeric round() and trunc().

commit   : 1ff39f4ff2b68625cdc37076e5c8281a4eab7f4f    
  
author   : Dean Rasheed <[email protected]>    
date     : Mon, 8 Jul 2024 17:48:45 +0100    
  
committer: Dean Rasheed <[email protected]>    
date     : Mon, 8 Jul 2024 17:48:45 +0100    

Click here for diff

The numeric round() and trunc() functions clamp the scale argument to  
the range between +/- NUMERIC_MAX_RESULT_SCALE (2000), which is much  
smaller than the actual allowed range of type numeric. As a result,  
they return incorrect results when asked to round/truncate more than  
2000 digits before or after the decimal point.  
  
Fix by using the correct upper and lower scale limits based on the  
actual allowed (and documented) range of type numeric.  
  
While at it, use the new NUMERIC_WEIGHT_MAX constant instead of  
SHRT_MAX in all other overflow checks, and fix a comment thinko in  
power_var() introduced by e54a758d24 -- the minimum value of  
ln_dweight is -NUMERIC_DSCALE_MAX (-16383), not -SHRT_MAX, though this  
doesn't affect the point being made in the comment, that the resulting  
local_rscale value may exceed NUMERIC_MAX_DISPLAY_SCALE (1000).  
  
Back-patch to all supported branches.  
  
Dean Rasheed, reviewed by Joel Jacobson.  
  
Discussion: https://postgr.es/m/CAEZATCXB%2BrDTuMjhK5ZxcouufigSc-X4tGJCBTMpZ3n%3DxxQuhg%40mail.gmail.com  

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

Typo fix

commit   : 519d710720159046c90c08095e70fdb486d38053    
  
author   : Amit Langote <[email protected]>    
date     : Mon, 8 Jul 2024 22:12:55 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Mon, 8 Jul 2024 22:12:55 +0900    

Click here for diff

Reported-by: Junwang Zhao <[email protected]>  
Discussion: https://postgr.es/m/CAEG8a3KPi=LayiTwJ11ikF7bcqnZUrcj8NgX0V8nO1mQKZ9GfQ@mail.gmail.com  
Backpatch-through: 17  

M src/common/jsonapi.c

Fix outdated comment after removal of direct SSL fallback

commit   : cc68ca6d420e750fd90e76bafb64dd19e51823ac    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Mon, 8 Jul 2024 12:44:45 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Mon, 8 Jul 2024 12:44:45 +0300    

Click here for diff

The option to fall back from direct SSL to negotiated SSL or a  
plaintext connection was removed in commit fb5718f35f.  
  
Discussion: https://www.postgresql.org/message-id/[email protected]  

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

Renumber pg_get_acl() in pg_proc.dat

commit   : e311c6e53955e4529a47a36a4f26b0c3f7a29513    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 8 Jul 2024 15:34:33 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 8 Jul 2024 15:34:33 +0900    

Click here for diff

a6417078c414 has introduced as project policy that new features  
committed during the development cycle should use new OIDs in the  
[8000,9999] range.  
  
4564f1cebd43 did not respect that rule, so let's renumber pg_get_acl()  
to use an OID in the correct range.  
  
Bump catalog version.  

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

Widen lossy and exact page counters for Bitmap Heap Scan

commit   : 7340d9362a792d3cb5f38a512d8cecacc7aceb59    
  
author   : David Rowley <[email protected]>    
date     : Mon, 8 Jul 2024 14:43:09 +1200    
  
committer: David Rowley <[email protected]>    
date     : Mon, 8 Jul 2024 14:43:09 +1200    

Click here for diff

Both of these counters were using the "long" data type.  On MSVC that's  
a 32-bit type.  On modern hardware, I was able to demonstrate that we can  
wrap those counters with a query that only takes 15 minutes to run.  
  
This issue may manifest itself either by not showing the values of the  
counters because they've wrapped and are less than zero, resulting in  
them being filtered by the > 0 checks in show_tidbitmap_info(), or bogus  
numbers being displayed which are modulus 2^32 of the actual number.  
  
Widen these counters to uint64.  
  
Discussion: https://postgr.es/m/CAApHDvpS_97TU+jWPc=T83WPp7vJa1dTw3mojEtAVEZOWh9bjQ@mail.gmail.com  

M src/backend/commands/explain.c
M src/include/nodes/execnodes.h

Remove an extra period in code comment

commit   : d7db04dfdae361479e77054670ee9d806c6a6420    
  
author   : Richard Guo <[email protected]>    
date     : Mon, 8 Jul 2024 11:17:22 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Mon, 8 Jul 2024 11:17:22 +0900    

Click here for diff

Author: Junwang Zhao  
Discussion: https://postgr.es/m/CAEG8a3L9GgfKc+XT+NMHPY7atAOVYqjUqKEFQKhcPHFYRW=PuQ@mail.gmail.com  

M src/backend/storage/ipc/procarray.c

Fix right-anti-joins when the inner relation is proven unique

commit   : 0ffc0acaf3bf301ba8fd43dc0e004b8b7c9ecd3a    
  
author   : Richard Guo <[email protected]>    
date     : Mon, 8 Jul 2024 10:11:46 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Mon, 8 Jul 2024 10:11:46 +0900    

Click here for diff

For an inner_unique join, we always assume that the executor will stop  
scanning for matches after the first match.  Therefore, for a mergejoin  
that is inner_unique and whose mergeclauses are sufficient to identify a  
match, we set the skip_mark_restore flag to true, indicating that the  
executor need not do mark/restore calls.  However, merge-right-anti-join  
did not get this memo and continues scanning the inner side for matches  
after the first match.  If there are duplicates in the outer scan, we  
may incorrectly skip matching some inner tuples, which can lead to wrong  
results.  
  
Here we fix this issue by ensuring that merge-right-anti-join also  
advances to next outer tuple after the first match in inner_unique  
cases.  This also saves cycles by avoiding unnecessary scanning of inner  
tuples after the first match.  
  
Although hash-right-anti-join does not suffer from this wrong results  
issue, we apply the same change to it as well, to help save cycles for  
the same reason.  
  
Per bug #18522 from Antti Lampinen, and bug #18526 from Feliphe Pozzer.  
Back-patch to v16 where right-anti-join was introduced.  
  
Author: Richard Guo  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/executor/nodeHashjoin.c
M src/backend/executor/nodeMergejoin.c
M src/test/regress/expected/join.out
M src/test/regress/sql/join.sql

Re-enable autoruns for cmd.exe on Windows

commit   : 74b8e6a698025fbea5a5e22ea09d07d97188c1d6    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 8 Jul 2024 09:43:59 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 8 Jul 2024 09:43:59 +0900    

Click here for diff

This acts as a revert of b83747a8a65b and 9886744a361b.  As pointed out  
by Noah, HEAD and REL_17_STABLE are in a weird state where the code  
paths adding /D would limit the spawn of child processes, but we still  
have code paths where the spawn of more than one child process(es) would  
be possible.  
  
Let's remove these /D switches for now, to bring back the code into a  
state consistent with how autorun is configured on a Windows host.  
  
Reported-by: Noah Misch  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 17  

M src/bin/pg_ctl/pg_ctl.c
M src/test/regress/pg_regress.c

Use xmlAddChildList not xmlAddChild in XMLSERIALIZE.

commit   : 066e8ac6ea8bc2af79dc86273a09ba7c1a39f7fd    
  
author   : Tom Lane <[email protected]>    
date     : Sat, 6 Jul 2024 15:16:13 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sat, 6 Jul 2024 15:16:13 -0400    

Click here for diff

It looks like we should have been doing this all along,  
but we got away with the wrong coding until libxml2 2.13.0  
tightened up xmlAddChild's behavior.  
  
There is more stuff to be fixed to be compatible with 2.13.0,  
and it will all need to be back-patched.  This is just a  
trial commit to see if the buildfarm agrees that we can use  
xmlAddChildList unconditionally.  
  
Erik Wienhold, per report from Frank Streitzig.  
  
Discussion: https://postgr.es/m/trinity-b0161630-d230-4598-9ebc-7a23acdb37cb-1720186432160@3c-app-gmx-bap25  
Discussion: https://postgr.es/m/trinity-361ba18b-541a-4fe7-bc63-655ae3a7d599-1720259822452@3c-app-gmx-bs01  

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

Adjust tuplestore.c not to allocate BufFiles in generation context

commit   : 04bcf9e19a4261fe9c7df37c777592c2e10c32a7    
  
author   : David Rowley <[email protected]>    
date     : Sat, 6 Jul 2024 17:40:05 +1200    
  
committer: David Rowley <[email protected]>    
date     : Sat, 6 Jul 2024 17:40:05 +1200    

Click here for diff

590b045c3 made it so tuplestore.c would store tuples inside a  
generation.c memory context.  After fixing a bug report in 97651b013, it  
seems that it's probably best not to allocate BufFile related  
allocations in that context.  Let's keep it just for tuple data.  
  
This adjusts the code to switch to the Tuplestorestate.context's parent,  
which is the MemoryContext that tuplestore_begin_common() was called in.  
It does not seem worth adding a new field in Tuplestorestate to store  
this when we can access it by looking at the Tuplestorestate's  
context's parent.  
  
Discussion: https://postgr.es/m/CAApHDvqFt_CdJtSr+E9YLZb7jZAyRCy3hjQ+ktM+dcOFVq-xkg@mail.gmail.com  

M src/backend/utils/sort/tuplestore.c

Fix incorrect sentinel byte logic in GenerationRealloc()

commit   : 97651b0139cfa511eaf063b60c900c2ba81b8ba2    
  
author   : David Rowley <[email protected]>    
date     : Sat, 6 Jul 2024 13:59:34 +1200    
  
committer: David Rowley <[email protected]>    
date     : Sat, 6 Jul 2024 13:59:34 +1200    

Click here for diff

This only affects MEMORY_CONTEXT_CHECKING builds.  
  
This fixes an off-by-one issue in GenerationRealloc() where the  
fast-path code which tries to reuse the existing allocation if the  
existing chunk is >= the new requested size.  The code there thought it  
was always ok to use the existing chunk, but when oldsize == size there  
isn't enough space to store the sentinel byte.  If both sizes matched  
exactly set_sentinel() would overwrite the first byte beyond the chunk  
and then subsequent GenerationRealloc() calls could then fail the  
Assert(chunk->requested_size < oldsize) check which is trying to ensure  
the chunk is large enough to store the sentinel.  
  
The same issue does not exist in aset.c as the sentinel checking code  
only adds a sentinel byte if there's enough space in the chunk.  
  
Reported-by: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: 16, where the problem was introduced by 0e480385e  

M src/backend/utils/mmgr/generation.c

Cope with <regex.h> name clashes.

commit   : 2a5ef09830401071be64d4eff3f6db421263a880    
  
author   : Thomas Munro <[email protected]>    
date     : Sat, 6 Jul 2024 10:24:49 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Sat, 6 Jul 2024 10:24:49 +1200    

Click here for diff

macOS 15's SDK pulls in headers related to <regex.h> when we include  
<xlocale.h>.  This causes our own regex_t implementation to clash with  
the OS's regex_t implementation.  Luckily our function names already had  
pg_ prefixes, but the macros and typenames did not.  
  
Include <regex.h> explicitly on all POSIX systems, and fix everything  
that breaks.  Then we can prove that we are capable of fully hiding and  
replacing the system regex API with our own.  
  
1.  Deal with standard-clobbering macros by undefining them all first.  
POSIX says they are "symbolic constants".  If they are macros, this  
allows us to redefine them.  If they are enums or variables, our macros  
will hide them.  
  
2.  Deal with standard-clobbering types by giving our types pg_  
prefixes, and then using macros to redirect xxx_t -> pg_xxx_t.  
  
After including our "regex/regex.h", the system <regex.h> is hidden,  
because we've replaced all the standard names.  The PostgreSQL source  
tree and extensions can continue to use standard prefix-less type and  
macro names, but reach our implementation, if they included our  
"regex/regex.h" header.  
  
Back-patch to all supported branches, so that macOS 15's tool chain can  
build them.  
  
Reported-by: Stan Hu <[email protected]>  
Suggested-by: Tom Lane <[email protected]>  
Tested-by: Aleksander Alekseev <[email protected]>  
Discussion: https://postgr.es/m/CAMBWrQnEwEJtgOv7EUNsXmFw2Ub4p5P%2B5QTBEgYwiyjy7rAsEQ%40mail.gmail.com  

M src/include/regex/regex.h
M src/tools/pgindent/typedefs.list

Fix placement of "static".

commit   : 8212625e53f28ce2fb9f779f9fa5c003dba904d4    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 5 Jul 2024 17:32:55 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 5 Jul 2024 17:32:55 -0400    

Click here for diff

Various buildfarm critters were complaining about  
  
pgbench.c:304:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]  
  
Evidently a thinko in 720b0eaae.  

M src/bin/pgbench/pgbench.c

Remove check hooks for GUCs that contribute to MaxBackends.

commit   : 0b1fe1413ea84a381489ed1d1f718cb710229ab3    
  
author   : Nathan Bossart <[email protected]>    
date     : Fri, 5 Jul 2024 14:42:55 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Fri, 5 Jul 2024 14:42:55 -0500    

Click here for diff

Each of max_connections, max_worker_processes,  
autovacuum_max_workers, and max_wal_senders has a GUC check hook  
that verifies the sum of those GUCs does not exceed a hard-coded  
limit (see the comment for MAX_BACKENDS in postmaster.h).  In  
general, the hooks effectively guard against egregious  
misconfigurations.  
  
However, this approach has some problems.  Since these check hooks  
are called as each GUC is assigned its user-specified value, only  
one of the hooks will be called with all the relevant GUCs set.  If  
one or more of the user-specified values are less than the initial  
values of the GUCs' underlying variables, false positives can  
occur.  
  
Furthermore, the error message emitted when one of the check hooks  
fails is not tremendously helpful.  For example, the command  
  
	$ pg_ctl -D . start -o "-c max_connections=262100 -c max_wal_senders=10000"  
  
fails with the following error:  
  
	FATAL:  invalid value for parameter "max_wal_senders": 10000  
  
Fortunately, there is an extra copy of this check in  
InitializeMaxBackends() that we can rely on, so this commit removes  
the aforementioned GUC check hooks in favor of that one.  It also  
enhances the error message to clearly show the values of the  
relevant GUCs and the hard-coded limit their sum may not exceed.  
The downside of this change is that server startup progresses  
further before failing due to such misconfigurations (thus taking  
longer), but these failures are expected to be rare, so we don't  
anticipate any real harm in practice.  
  
Reviewed-by: Tom Lane  
Discussion: https://postgr.es/m/ZnMr2k-Nk5vj7T7H%40nathan  

M src/backend/utils/init/postinit.c
M src/backend/utils/misc/guc_tables.c
M src/include/utils/guc_hooks.h

Improve PL/Tcl's method for choosing Tcl names of procedures.

commit   : ba8f00eef6d6199b1d01f4b1eb6ed955dc4bd17e    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 5 Jul 2024 14:14:42 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 5 Jul 2024 14:14:42 -0400    

Click here for diff

Previously, the internal name of a PL/Tcl function was just  
"__PLTcl_proc_NNNN", where NNNN is the function OID.  That's pretty  
unhelpful when reading an error report.  Plus it prevents us from  
testing the CONTEXT output for PL/Tcl errors, since the OIDs shown  
in the regression tests wouldn't be stable.  
  
Instead, base the internal name on the result of format_procedure(),  
which will be unique in most cases.  For the edge cases where it's  
not, we can append the function OID to make it unique.  
  
Sadly, the pltcl_trigger.sql test script still has to suppress the  
context reports, because they'd include trigger arguments which  
contain relation OIDs per PL/Tcl's longstanding API for triggers.  
  
I had to modify one existing test case to throw a different error  
than before, because I found that Tcl 8.5 and Tcl 8.6 spell the  
context message for the original error slightly differently.  
We might have to make more adjustments in that vein once this  
gets wider testing.  
  
Patch by me; thanks to Pavel Stehule for the idea to use  
format_procedure() rather than just the proname.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/pltcl.sgml
M src/pl/tcl/expected/pltcl_queries.out
M src/pl/tcl/expected/pltcl_transaction.out
M src/pl/tcl/expected/pltcl_trigger.out
M src/pl/tcl/pltcl.c
M src/pl/tcl/sql/pltcl_queries.sql
M src/pl/tcl/sql/pltcl_transaction.sql
M src/pl/tcl/sql/pltcl_trigger.sql

Doc: minor improvements for our "Brief History" chapter.

commit   : aaab3ee9c64129b5afb2c35e743fba322a052bff    
  
author   : Tom Lane <[email protected]>    
date     : Fri, 5 Jul 2024 13:12:34 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Fri, 5 Jul 2024 13:12:34 -0400    

Click here for diff

Add a link to Joe Hellerstein's paper "Looking Back at Postgres",  
which is quite an interesting take on the history of Postgres.  
  
The reference to Appendix E was written when we were still keeping  
the entire release-note history there, which we stopped doing some  
years ago when the O(N^2) cost of that started to become apparent.  
Instead, point to the release note archives on the website.  
(This per suggestion from Daniel Gustafsson.)  
  
In passing, move the "ports12" biblioentry to be in alphabetical  
order within that section.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/biblio.sgml
M doc/src/sgml/history.sgml

Support loading of injection points

commit   : 4b211003ecc2946dc0052b650141ea4e8f35254c    
  
author   : Michael Paquier <[email protected]>    
date     : Fri, 5 Jul 2024 17:41:49 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Fri, 5 Jul 2024 17:41:49 +0900    

Click here for diff

This can be used to load an injection point and prewarm the  
backend-level cache before running it, to avoid issues if the point  
cannot be loaded due to restrictions in the code path where it would be  
run, like a critical section where no memory allocation can happen  
(load_external_function() can do allocations when expanding a library  
name).  
  
Tests can use a macro called INJECTION_POINT_LOAD() to load an injection  
point.  The test module injection_points gains some tests, and a SQL  
function able to load an injection point.  
  
Based on a request from Andrey Borodin, who has implemented a test for  
multixacts requiring this facility.  
  
Reviewed-by: Andrey Borodin  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/xfunc.sgml
M src/backend/utils/misc/injection_point.c
M src/include/utils/injection_point.h
M src/test/modules/injection_points/expected/injection_points.out
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/sql/injection_points.sql

commit   : 98347b5a3ab116dd0892d112531e376cff5066fd    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Fri, 5 Jul 2024 11:21:46 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Fri, 5 Jul 2024 11:21:46 +0300    

Click here for diff

Since commit 5764f611e1, we've been using the ilist.h functions for  
handling the linked list. There's no need for 'links' to be the first  
element of the struct anymore, except for one call in InitProcess  
where we used a straight cast from the 'dlist_node *' to PGPROC *,  
without the dlist_container() macro. That was just an oversight in  
commit 5764f611e1, fix it.  
  
There no imminent need to move 'links' from being the first field, but  
let's be tidy.  
  
Reviewed-by: Aleksander Alekseev, Andres Freund  
Discussion: https://www.postgresql.org/message-id/[email protected]  

M src/backend/storage/lmgr/proc.c
M src/include/storage/proc.h

Improve memory management and performance of tuplestore.c

commit   : 590b045c37aad44915f7f472343f24c2bafbe5d8    
  
author   : David Rowley <[email protected]>    
date     : Fri, 5 Jul 2024 17:51:27 +1200    
  
committer: David Rowley <[email protected]>    
date     : Fri, 5 Jul 2024 17:51:27 +1200    

Click here for diff

Here we make tuplestore.c use a generation.c memory context rather than  
allocating tuples into the CurrentMemoryContext, which primarily is the  
ExecutorState or PortalHoldContext memory context.  Not having a  
dedicated context can cause the CurrentMemoryContext context to become  
bloated when pfree'd chunks are not reused by future tuples.  Using  
generation speeds up users of tuplestore.c, such as the Materialize,  
WindowAgg and CTE Scan executor nodes.  The main reason for the speedup is  
due to generation.c being more memory efficient than aset.c memory  
contexts.  Specifically, generation does not round sizes up to the next  
power of 2 value.  This both saves memory, allowing more tuples to fit in  
work_mem, but also makes the memory usage more compact and fit on fewer  
cachelines.  One benchmark showed up to a 22% performance increase in a  
query containing a Materialize node.  Much higher gains are possible if  
the memory reduction prevents tuplestore.c from spilling to disk.  This is  
especially true for WindowAgg nodes where improvements of several thousand  
times are possible if the memory reductions made here prevent tuplestore  
from spilling to disk.  
  
Additionally, a generation.c memory context is much better suited for this  
job as it works well with FIFO palloc/pfree patterns, which is exactly how  
tuplestore.c uses it.  Because of the way generation.c allocates memory,  
tuples consecutively stored in tuplestores are much more likely to be  
stored consecutively in memory.  This allows the CPU's hardware prefetcher  
to work more efficiently as it provides a more predictable pattern to  
allow cachelines for the next tuple to be loaded from RAM in advance of  
them being needed by the executor.  
  
Using a dedicated memory context for storing tuples also allows us to more  
efficiently clean up the memory used by the tuplestore as we can reset or  
delete the context rather than looping over all stored tuples and  
pfree'ing them one by one.  
  
Also, remove a badly placed USEMEM call in readtup_heap().  The tuple  
wasn't being allocated in the Tuplestorestate's context, so no need to  
adjust the memory consumed by the tuplestore there.  
  
Author: David Rowley  
Reviewed-by: Matthias van de Meent, Dmitry Dolgov  
Discussion: https://postgr.es/m/CAApHDvp5Py9g4Rjq7_inL3-MCK1Co2CRt_YWFwTU2zfQix0p4A@mail.gmail.com  

M src/backend/utils/sort/tuplestore.c

Fix newly introduced issue in EXPLAIN for Materialize nodes

commit   : 53abb1e0ebc38818f31f2ddb15a06feba8e19e6c    
  
author   : David Rowley <[email protected]>    
date     : Fri, 5 Jul 2024 16:56:16 +1200    
  
committer: David Rowley <[email protected]>    
date     : Fri, 5 Jul 2024 16:56:16 +1200    

Click here for diff

The code added in 1eff8279d was lacking a check to see if the tuplestore  
had been created.  In nodeMaterial.c this is done by ExecMaterial() rather  
than by ExecInitMaterial(), so the tuplestore won't be created unless  
the node has been executed at least once, as demonstrated by Alexander  
in his report.  
  
Here we skip showing any of the new EXPLAIN ANALYZE information when the  
Materialize node has not been executed.  
  
Reported-by: Alexander Lakhin  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/commands/explain.c

Add simple codepoint redirections to unaccent.rules.

commit   : 18501841bcb4e693b9f1e9da2b2fb524c78940d8    
  
author   : Thomas Munro <[email protected]>    
date     : Fri, 5 Jul 2024 15:25:31 +1200    
  
committer: Thomas Munro <[email protected]>    
date     : Fri, 5 Jul 2024 15:25:31 +1200    

Click here for diff

Previously we searched for code points where the Unicode data file  
listed an equivalent combining character sequence that added accents.  
Some codepoints redirect to a single other codepoint, instead of doing  
any combining.  We can follow those references recursively to get the  
answer.  
  
Per bug report #18362, which reported missing Ancient Greek characters.  
Specifically, precomposed characters with oxia (from the polytonic  
accent system used for old Greek) just point to precomposed characters  
with tonos (from the monotonic accent system for modern Greek), and we  
have to follow the extra hop to find out that they are composed with  
an acute accent.  
  
Besides those, the new rule also:  
  
* pulls in a lot of 'Mathematical Alphanumeric Symbols', which are  
  copies of the Latin and Greek alphabets and numbers rendered  
  in different typefaces, and  
  
* corrects a single mathematical letter that previously came from the  
  CLDR transliteration file, but the new rule extracts from the main  
  Unicode database file, where clearly the latter is right and the  
  former is a wrong (reported to CLDR).  
  
Reported-by: Cees van Zeeland <[email protected]>  
Reviewed-by: Robert Haas <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Reviewed-by: Michael Paquier <[email protected]>  
Discussion: https://postgr.es/m/18362-be6d0cfe122b6354%40postgresql.org  

M contrib/unaccent/expected/unaccent.out
M contrib/unaccent/generate_unaccent_rules.py
M contrib/unaccent/unaccent.rules

Add memory/disk usage for Material nodes in EXPLAIN

commit   : 1eff8279d494b96f0073df78abc74954a2f6ee54    
  
author   : David Rowley <[email protected]>    
date     : Fri, 5 Jul 2024 14:05:08 +1200    
  
committer: David Rowley <[email protected]>    
date     : Fri, 5 Jul 2024 14:05:08 +1200    

Click here for diff

Up until now, there was no ability to easily determine if a Material  
node caused the underlying tuplestore to spill to disk or even see how  
much memory the tuplestore used if it didn't.  
  
Here we add some new functions to tuplestore.c to query this information  
and add some additional output in EXPLAIN ANALYZE to display this  
information for the Material node.  
  
There are a few other executor node types that use tuplestores, so we  
could also consider adding these details to the EXPLAIN ANALYZE for  
those nodes too.  Let's consider those independently from this.  Having  
the tuplestore.c infrastructure in to allow that is step 1.  
  
Author: David Rowley  
Reviewed-by: Matthias van de Meent, Dmitry Dolgov  
Discussion: https://postgr.es/m/CAApHDvp5Py9g4Rjq7_inL3-MCK1Co2CRt_YWFwTU2zfQix0p4A@mail.gmail.com  

M src/backend/commands/explain.c
M src/backend/utils/sort/tuplestore.c
M src/include/utils/tuplestore.h
M src/test/regress/expected/partition_prune.out
M src/test/regress/sql/partition_prune.sql

Support "Right Semi Join" plan shapes

commit   : aa86129e19d704afb93cb84ab9638f33d266ee9d    
  
author   : Richard Guo <[email protected]>    
date     : Fri, 5 Jul 2024 09:26:48 +0900    
  
committer: Richard Guo <[email protected]>    
date     : Fri, 5 Jul 2024 09:26:48 +0900    

Click here for diff

Hash joins can support semijoin with the LHS input on the right, using  
the existing logic for inner join, combined with the assurance that only  
the first match for each inner tuple is considered, which can be  
achieved by leveraging the HEAP_TUPLE_HAS_MATCH flag.  This can be very  
useful in some cases since we may now have the option to hash the  
smaller table instead of the larger.  
  
Merge join could likely support "Right Semi Join" too.  However, the  
benefit of swapping inputs tends to be small here, so we do not address  
that in this patch.  
  
Note that this patch also modifies a test query in join.sql to ensure it  
continues testing as intended.  With this patch the original query would  
result in a right-semi-join rather than semi-join, compromising its  
original purpose of testing the fix for neqjoinsel's behavior for  
semi-joins.  
  
Author: Richard Guo  
Reviewed-by: wenhui qiu, Alena Rybakina, Japin Li  
Discussion: https://postgr.es/m/CAMbWs4_X1mN=ic+SxcyymUqFx9bB8pqSLTGJ-F=MHy4PW3eRXw@mail.gmail.com  

M contrib/postgres_fdw/expected/postgres_fdw.out
M src/backend/commands/explain.c
M src/backend/executor/nodeHashjoin.c
M src/backend/optimizer/path/joinpath.c
M src/backend/optimizer/path/joinrels.c
M src/backend/optimizer/path/pathkeys.c
M src/backend/optimizer/prep/prepjointree.c
M src/include/nodes/nodes.h
M src/include/nodes/pathnodes.h
M src/test/regress/expected/join.out
M src/test/regress/expected/partition_join.out
M src/test/regress/expected/select_parallel.out
M src/test/regress/expected/updatable_views.out
M src/test/regress/sql/join.sql

Doc: small improvements in discussion of geometric data types.

commit   : 5a519abeddfe34659a8c0478f04a0acfd0d80ec6    
  
author   : Tom Lane <[email protected]>    
date     : Thu, 4 Jul 2024 13:23:32 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Thu, 4 Jul 2024 13:23:32 -0400    

Click here for diff

State explicitly that the coordinates in our geometric data types are  
float8.  Also explain that polygons store their bounding box.  
  
While here, fix the table of geometric data types to show type  
"line"'s size correctly: it's 24 bytes not 32.  This has somehow  
escaped notice since that table was made in 1998.  
  
Per suggestion from Sebastian Skałacki.  The size error seems  
important enough to justify back-patching.  
  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/datatype.sgml

Fix copy/paste mistake in comment

commit   : 2ef575c7803a55101352c0f6cb8f745af063a66c    
  
author   : Alvaro Herrera <[email protected]>    
date     : Thu, 4 Jul 2024 13:57:47 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Thu, 4 Jul 2024 13:57:47 +0200    

Click here for diff

Backpatch to 17  
  
Author: Yugo NAGATA <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

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

Remove bogus assertion in pg_atomic_monotonic_advance_u64

commit   : 768f0c3e21b31f92ebb510a7e4d0c2cd1c1ecb97    
  
author   : Alvaro Herrera <[email protected]>    
date     : Thu, 4 Jul 2024 13:25:31 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Thu, 4 Jul 2024 13:25:31 +0200    

Click here for diff

This code wanted to ensure that the 'exchange' variable passed to  
pg_atomic_compare_exchange_u64 has correct alignment, but apparently  
platforms don't actually require anything that doesn't come naturally.  
  
While messing with pg_atomic_monotonic_advance_u64: instead of using  
Max() to determine the value to return, just use  
pg_atomic_compare_exchange_u64()'s return value to decide; also, use  
pg_atomic_compare_exchange_u64 instead of the _impl version; also remove  
the unnecessary underscore at the end of variable name "target".  
  
Backpatch to 17, where this code was introduced by commit bf3ff7bf83bc.  
  
Reported-by: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

M src/include/port/atomics.h
M src/include/port/atomics/arch-ppc.h
M src/include/port/atomics/arch-x86.h
M src/include/port/atomics/generic-gcc.h
M src/include/port/atomics/generic-sunpro.h

doc: Specify when ssl_prefer_server_ciphers was added

commit   : ab0ae6432062ed318774981987272b4561b5616c    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Thu, 4 Jul 2024 11:38:37 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Thu, 4 Jul 2024 11:38:37 +0200    

Click here for diff

The ssl_prefer_server_ciphers setting is quite important from a  
security point of view, so simply stating that older versions  
doesn't have it isn't very helpful.  This adds the version when  
the GUC was added to help readers.  
  
Backpatch to all supported versions since this setting has been  
around since 9.4.  
  
Reviewed-by: Peter Eisentraut <[email protected]>  
Reviewed-by: Tom Lane <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  
Backpatch-through: v12  

M doc/src/sgml/config.sgml

Add pg_get_acl() to get the ACL for a database object

commit   : 4564f1cebd437d93590027c9ff46ef60bc3286ae    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 4 Jul 2024 17:09:06 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 4 Jul 2024 17:09:06 +0900    

Click here for diff

This function returns the ACL for a database object, specified by  
catalog OID and object OID.  This is useful to be able to  
retrieve the ACL associated to an object specified with a  
(class_id,objid) couple, similarly to the other functions for object  
identification, when joined with pg_depend or pg_shdepend.  
  
Original idea by Álvaro Herrera.  
  
Bump catalog version.  
  
Author: Joel Jacobson  
Reviewed-by: Isaac Morland, Michael Paquier, Ranier Vilela  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/func.sgml
M src/backend/catalog/objectaddress.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

SQL/JSON: Fix some obsolete comments.

commit   : 3a8a1f3254b2e3e981a91cb021ea0e9fdb5c3b9c    
  
author   : Amit Langote <[email protected]>    
date     : Fri, 28 Jun 2024 15:09:59 +0900    
  
committer: Amit Langote <[email protected]>    
date     : Fri, 28 Jun 2024 15:09:59 +0900    

Click here for diff

JSON_OBJECT(), JSON_OBJETAGG(), JSON_ARRAY(), and JSON_ARRAYAGG()  
added in 7081ac46ace are not transformed into direct calls to  
user-defined functions as the comments claim. Fix by mentioning  
instead that they are transformed into JsonConstructorExpr nodes,  
which may call them, for example, for the *AGG() functions.  
  
Reported-by: Alexander Lakhin <[email protected]>  
Discussion: https://postgr.es/m/058c856a-e090-ac42-ff00-ffe394f52a87%40gmail.com  
Backpatch-through: 16  

M src/backend/parser/parse_expr.c

Assign error codes where missing for user-facing failures

commit   : b81a71aa05f294705e1b1d4fe24548f175f9bfe9    
  
author   : Michael Paquier <[email protected]>    
date     : Thu, 4 Jul 2024 09:48:40 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Thu, 4 Jul 2024 09:48:40 +0900    

Click here for diff

All the errors triggered in the code paths patched here would cause the  
backend to issue an internal_error errcode, which is a state that should  
be used only for "can't happen" situations.  However, these code paths  
are reachable by the regression tests, and could be seen by users in  
valid cases.  Some regression tests expect internal errcodes as they  
manipulate the backend state to cause corruption (like checksums), or  
use elog() because it is more convenient (like injection points), these  
have no need to change.  
  
This reduces the number of internal failures triggered in a check-world  
by more than half, while providing correct errcodes for these valid  
cases.  
  
Reviewed-by: Robert Haas  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pg_walinspect/pg_walinspect.c
M src/backend/access/transam/xlogrecovery.c
M src/backend/backup/basebackup.c
M src/backend/commands/matview.c
M src/backend/commands/tablecmds.c
M src/backend/commands/trigger.c
M src/backend/commands/user.c
M src/backend/libpq/be-secure-openssl.c
M src/backend/optimizer/util/appendinfo.c
M src/backend/replication/slotfuncs.c
M src/backend/utils/adt/pg_locale.c
M src/backend/utils/adt/tid.c

Optimize memory access in GetRunningTransactionData()

commit   : 6897f0ec024582a570868939d3f34a6853374723    
  
author   : Alexander Korotkov <[email protected]>    
date     : Thu, 4 Jul 2024 02:05:37 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Thu, 4 Jul 2024 02:05:37 +0300    

Click here for diff

e85662df44 made GetRunningTransactionData() calculate the oldest running  
transaction id within the current database.  This commit optimized this  
calculation by performing a cheap transaction id comparison before fetching  
the process database id, while the latter could cause extra cache misses.  
  
Reported-by: Noah Misch  
Discussion: https://postgr.es/m/20240630231816.bf.nmisch%40google.com  

M src/backend/storage/ipc/procarray.c

Fix typo in GetRunningTransactionData()

commit   : 6c1af5482e6943a5f29b7f4ca773c720ec8202b0    
  
author   : Alexander Korotkov <[email protected]>    
date     : Thu, 4 Jul 2024 02:05:27 +0300    
  
committer: Alexander Korotkov <[email protected]>    
date     : Thu, 4 Jul 2024 02:05:27 +0300    

Click here for diff

e85662df44 made GetRunningTransactionData() calculate the oldest running  
transaction id within the current database.  However, because of the typo,  
the new code uses oldestRunningXid instead of oldestDatabaseRunningXid  
in comparison before updating oldestDatabaseRunningXid.  This commit fixes  
that issue.  
  
Reported-by: Noah Misch  
Discussion: https://postgr.es/m/20240630231816.bf.nmisch%40google.com  
Backpatch-through: 17  

M src/backend/storage/ipc/procarray.c

Remove incorrect Asserts in buffile.c

commit   : 4331a11c62eca7426ad4472be051fe512a04fc80    
  
author   : David Rowley <[email protected]>    
date     : Thu, 4 Jul 2024 09:44:34 +1200    
  
committer: David Rowley <[email protected]>    
date     : Thu, 4 Jul 2024 09:44:34 +1200    

Click here for diff

Both BufFileSize() and BufFileAppend() contained Asserts to ensure the  
given BufFile(s) had a valid fileset.  A valid fileset isn't required in  
either of these functions, so remove the Asserts and adjust the  
comments accordingly.  
  
This was noticed while work was being done on a new patch to call  
BufFileSize() on a BufFile without a valid fileset.  It seems there's  
currently no code in the tree which could trigger these Asserts, so no  
need to backpatch this, for now.  
  
Reviewed-by: Peter Geoghegan, Matthias van de Meent, Tom Lane  
Discussion: https://postgr.es/m/CAApHDvofgZT0VzydhyGH5MMb-XZzNDqqAbzf1eBZV5HDm3%2BosQ%40mail.gmail.com  

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

Improve performance of binary_upgrade_set_pg_class_oids().

commit   : 2329cad1b93f268c0ec6848732c6db43eb46156c    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 3 Jul 2024 14:21:50 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 3 Jul 2024 14:21:50 -0500    

Click here for diff

This function generates the commands that preserve the OIDs and  
relfilenodes of relations during pg_upgrade.  It is called once per  
relevant relation, and each such call executes a relatively  
expensive query to retrieve information for a single pg_class_oid.  
This can cause pg_dump to take significantly longer when  
--binary-upgrade is specified, especially when there are many  
tables.  
  
This commit improves the performance of this function by gathering  
all the required pg_class information with a single query at the  
beginning of pg_dump.  This information is stored in a sorted array  
that binary_upgrade_set_pg_class_oids() can bsearch() for what it  
needs.  This follows a similar approach as commit d5e8930f50, which  
introduced a sorted array for role information.  
  
With this patch, 'pg_dump --binary-upgrade' will use more memory,  
but that isn't expected to be too egregious.  Per the mailing list  
discussion, folks feel that this is worth the trade-off.  
  
Reviewed-by: Corey Huinker, Michael Paquier, Daniel Gustafsson  
Discussion: https://postgr.es/m/20240418041712.GA3441570%40nathanxps13  

M src/bin/pg_dump/pg_dump.c
M src/tools/pgindent/typedefs.list

Remove is_index parameter from binary_upgrade_set_pg_class_oids().

commit   : 6e1c4a03a978ed3574124d8f2be22ba2e5a4b1e9    
  
author   : Nathan Bossart <[email protected]>    
date     : Wed, 3 Jul 2024 10:58:26 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Wed, 3 Jul 2024 10:58:26 -0500    

Click here for diff

Since commit 9a974cbcba, this function retrieves the relkind before  
it needs to know whether the relation is an index, so we no longer  
need callers to provide this information.  
  
Suggested-by: Daniel Gustafsson  
Reviewed-by: Daniel Gustafsson  
Discussion: https://postgr.es/m/20240418041712.GA3441570%40nathanxps13  

M src/bin/pg_dump/pg_dump.c

Avoid 0-length memcpy to NULL with EXEC_BACKEND

commit   : f3412a61f3f92d795ce0c8bb715831ec02124bfb    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Wed, 3 Jul 2024 15:58:14 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Wed, 3 Jul 2024 15:58:14 +0300    

Click here for diff

memcpy(NULL, src, 0) is forbidden by POSIX, even though every  
production version of libc allows it. Let's be tidy.  
  
Per report from Thomas Munro, running UBSan with EXEC_BACKEND.  
Backpatch to v17, where this code was added.  
  
Discussion: https://www.postgresql.org/message-id/CA%2BhUKG%2Be-dV7YWBzfBZXsgovgRuX5VmvmOT%[email protected]  

M src/backend/postmaster/launch_backend.c

Tighten check for --forkchild argument when spawning child process

commit   : a06e8f84a1ac1158ca7d7a95d9df289fe5219502    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Wed, 3 Jul 2024 15:53:30 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Wed, 3 Jul 2024 15:53:30 +0300    

Click here for diff

Commit aafc05de1b removed all the other --fork* arguments. Altough  
this is inconsequential, backpatch to v17 since this is new.  
  
Author: Nathan Bossart  
Discussion: https://www.postgresql.org/message-id/ZnCCEN0l3qWv-XpW@nathan  

M src/backend/main/main.c

Fix the testcase introduced in commit 81d20fbf7a.

commit   : ae395f0f7edbbf8e9ebe92e2ed3a471192789f0c    
  
author   : Amit Kapila <[email protected]>    
date     : Wed, 3 Jul 2024 15:04:59 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Wed, 3 Jul 2024 15:04:59 +0530    

Click here for diff

The failed test was syncing failover replication slot to standby to test  
that we remove such slots after the standby is converted to subscriber by  
pg_createsubscriber.  
  
In one of the buildfarm members, the sync of the slot failed because the  
LSN on the standby was before the syncslot's LSN. We need to wait for  
standby to catch up before trying to sync the slot with  
pg_sync_replication_slots().  
  
The other buildfarm failed because autovacuum generated a xid which is  
replicated to the standby at some random point making slots at primary  
lag behind standby during slot sync.  
  
Both these failures wouldn't have occurred if we had used built-in  
slotsync worker as it would have waited for the standby to sync with  
primary but for this test, it is sufficient to use  
pg_sync_replication_slots().  
  
Reported-by: Alexander Lakhin as per buildfarm  
Author: Kuroda Hayato  
Reviewed-by: Amit Kapila  
Backpatch-through: 17  
Discussion: https://postgr.es/m/[email protected]  
Discussion: https://postgr.es/m/OSBPR01MB25528300C71FDD83EA1DCA12F5DD2@OSBPR01MB2552.jpnprd01.prod.outlook.com  

M src/bin/pg_basebackup/t/040_pg_createsubscriber.pl

Replace hardcoded identifiers of pgstats file by #defines

commit   : 9fd02525793f3e06c72ee0da45303c21f7067ccf    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 3 Jul 2024 13:09:20 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 3 Jul 2024 13:09:20 +0900    

Click here for diff

This changes pgstat.c so as the three types of entries that can exist in  
a pgstats file are not hardcoded anymore, replacing them with  
descriptively-named macros, when reading and writing stats files:  
- 'N' for named entries, like replication slot stats.  
- 'S' for entries identified by a hash.  
- 'E' for the end-of-file  
  
This has come up while working on making this area of the code more  
pluggable.  The format of the stats file is unchanged, hence there is no  
need to bump PGSTAT_FILE_FORMAT_ID.  
  
Reviewed-by: Bertrand Drouvot  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/utils/activity/pgstat.c

Clean up more unused variables in perl code

commit   : dd569214aa7d057a9676c49ddbf2da74ad9924e3    
  
author   : Michael Paquier <[email protected]>    
date     : Wed, 3 Jul 2024 12:43:57 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Wed, 3 Jul 2024 12:43:57 +0900    

Click here for diff

This is a continuation of 0c1aca461481, with some cleanup in:  
- msvc_gendef.pl  
- pgindent  
- 005_negotiate_encryption.pl, as of an oversight of d39a49c1e459 that  
has removed %params in test_matrix(), making also $server_config  
useless.  
  
Author: Dagfinn Ilmari Mannsåker  
Discussion: https://postgr.es/m/[email protected]  

M src/interfaces/libpq/t/005_negotiate_encryption.pl
M src/tools/msvc_gendef.pl
M src/tools/pgindent/pgindent

Add CODE_OF_CONDUCT.md, CONTRIBUTING.md, and SECURITY.md.

commit   : dec9d4acdb7d758c3cbe989ad80cf0367f4e166d    
  
author   : Nathan Bossart <[email protected]>    
date     : Tue, 2 Jul 2024 13:03:58 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Tue, 2 Jul 2024 13:03:58 -0500    

Click here for diff

These "community health files" provide important information about  
the project and will be displayed prominently on the PostgreSQL  
GitHub mirror.  For now, they just point to the website, but we may  
want to expand on the content in the future.  
  
Reviewed-by: Peter Eisentraut, Alvaro Herrera, Tom Lane  
Discussion: https://postgr.es/m/20240417023609.GA3228660%40nathanxps13  

A .github/CODE_OF_CONDUCT.md
A .github/CONTRIBUTING.md
A .github/SECURITY.md

Remove redundant SetProcessingMode(InitProcessing) calls

commit   : eb21f5bc67a02eb6f7de1bd2f07acdd471a4d320    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 2 Jul 2024 20:14:40 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 2 Jul 2024 20:14:40 +0300    

Click here for diff

After several refactoring iterations, auxiliary processes are no  
longer initialized from the bootstrapper. Using the InitProcessing  
mode for initializing auxiliary processes is more appropriate. Since  
the global variable Mode is initialized to InitProcessing, we can just  
remove the redundant calls of SetProcessingMode(InitProcessing).  
  
Author: Xing Guo <[email protected]>  
Discussion: https://www.postgresql.org/message-id/CACpMh%2BDBHVT4xPGimzvex%3DwMdMLQEu9PYhT%2BkwwD2x2nu9dU_Q%40mail.gmail.com  

M src/backend/postmaster/autovacuum.c
M src/backend/postmaster/auxprocess.c
M src/backend/postmaster/bgworker.c
M src/backend/replication/logical/slotsync.c
M src/backend/tcop/postgres.c

Move bgworker specific logic to bgworker.c

commit   : 4d22173ec08cfdb83f61cfff1d6fa67fe7d83296    
  
author   : Heikki Linnakangas <[email protected]>    
date     : Tue, 2 Jul 2024 20:12:05 +0300    
  
committer: Heikki Linnakangas <[email protected]>    
date     : Tue, 2 Jul 2024 20:12:05 +0300    

Click here for diff

For clarity, we've been slowly moving functions that are not called  
from the postmaster process out of postmaster.c.  
  
Author: Xing Guo <[email protected]>  
Discussion: https://www.postgresql.org/message-id/CACpMh%2BDBHVT4xPGimzvex%3DwMdMLQEu9PYhT%2BkwwD2x2nu9dU_Q%40mail.gmail.com  

M src/backend/postmaster/bgworker.c
M src/backend/postmaster/postmaster.c

pg_dump: Remove some unused return values.

commit   : 8213df9effaf0767efa7faf9b75fa500d4f45985    
  
author   : Nathan Bossart <[email protected]>    
date     : Tue, 2 Jul 2024 11:22:06 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Tue, 2 Jul 2024 11:22:06 -0500    

Click here for diff

getSchemaData() does not use the return values of many of its get*  
helper functions because they store the data elsewhere.  For  
example, commit 92316a4582 introduced a separate hash table for  
dumpable objects that said helper functions populate.  This commit  
changes these functions to return void and removes their "int *"  
parameters that returned the number of objects found.  
  
Reviewed-by: Neil Conway, Tom Lane, Daniel Gustafsson  
Discussion: https://postgr.es/m/ZmCAtVaOrHpf31PJ%40nathan  

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

Use safe string copy routine

commit   : e930c872b65c19c8950556fa94aa9ab53b2919b0    
  
author   : Daniel Gustafsson <[email protected]>    
date     : Tue, 2 Jul 2024 11:16:56 +0200    
  
committer: Daniel Gustafsson <[email protected]>    
date     : Tue, 2 Jul 2024 11:16:56 +0200    

Click here for diff

Using memcpy with strlen as the size parameter will not take the  
NULL terminator into account, relying instead on the destination  
buffer being properly initialized. Replace with strlcpy which is  
a safer alternative, and more in line with how we handle copying  
strings elsewhere.  
  
Author: Ranier Vilela <[email protected]>  
Discussion: https://postgr.es/m/CAEudQApAsbLsQ+gGiw-hT+JwGhgogFa_=5NUkgFO6kOPxyNidQ@mail.gmail.com  

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

Remove too demanding test

commit   : da3ea048ca568f570cb579c090cf1a84554b8bec    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 10:43:12 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 10:43:12 +0200    

Click here for diff

Remove the test from commit 9c2e660b07.  This test ends up allocating  
quite a bit of memory, which can make the test fail with out of memory  
errors on some build farm machines.  

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

Limit max parameter number with MaxAllocSize

commit   : 9c2e660b07fc16bdd79c25047cce6cde2acb3f37    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 09:24:04 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 09:24:04 +0200    

Click here for diff

MaxAllocSize puts an upper bound on the largest possible parameter  
number ($268435455).  Use that limit instead of INT_MAX to report that  
no parameters exist beyond that point instead of reporting an error  
about the maximum allocation size being exceeded.  
  
Author: Erik Wienhold <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/parser/parse_param.c
M src/test/regress/expected/prepare.out
M src/test/regress/sql/prepare.sql

Fix overflow in parsing of positional parameter

commit   : d35cd061998434747c0d1c0f6f2aa1f736f0edb4    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 09:16:36 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 09:16:36 +0200    

Click here for diff

Replace atol with pg_strtoint32_safe in the backend parser and with  
strtoint in ECPG to reject overflows when parsing the number of a  
positional parameter.  With atol from glibc, parameters $2147483648 and  
$4294967297 turn into $-2147483648 and $1, respectively.  
  
Author: Erik Wienhold <[email protected]>  
Reviewed-by: Michael Paquier <[email protected]>  
Reviewed-by: Peter Eisentraut <[email protected]>  
Reviewed-by: Alexander Lakhin <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

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

Drop pre-existing subscriptions from the converted subscriber.

commit   : 4867f8a555cea1bc6de1726b0030896aa4cd3c70    
  
author   : Amit Kapila <[email protected]>    
date     : Tue, 2 Jul 2024 11:36:21 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Tue, 2 Jul 2024 11:36:21 +0530    

Click here for diff

We don't need the pre-existing subscriptions on the newly formed  
subscriber by using pg_createsubscriber. The apply workers corresponding  
to these subscriptions can connect to other publisher nodes and either get  
some unwarranted data or can lead to ERRORs in connecting to such nodes.  
  
Author: Kuroda Hayato  
Reviewed-by: Amit Kapila, Shlok Kyal, Vignesh C  
Backpatch-through: 17  
Discussion: https://postgr.es/m/OSBPR01MB25526A30A1FBF863ACCDDA3AF5C92@OSBPR01MB2552.jpnprd01.prod.outlook.com  

M src/bin/pg_basebackup/pg_createsubscriber.c
M src/bin/pg_basebackup/t/040_pg_createsubscriber.pl

Improve some global variable declarations

commit   : 8f8bcb88833eecfffbbb0d048ff0b6c33e64f7ce    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 06:55:56 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 06:55:56 +0200    

Click here for diff

We have in launch_backend.c:  
  
    /*  
     * The following need to be available to the save/restore_backend_variables  
     * functions.  They are marked NON_EXEC_STATIC in their home modules.  
     */  
    extern slock_t *ShmemLock;  
    extern slock_t *ProcStructLock;  
    extern PGPROC *AuxiliaryProcs;  
    extern PMSignalData *PMSignalState;  
    extern pg_time_t first_syslogger_file_time;  
    extern struct bkend *ShmemBackendArray;  
    extern bool redirection_done;  
  
That comment is not completely true: ShmemLock, ShmemBackendArray, and  
redirection_done are not in fact NON_EXEC_STATIC.  ShmemLock once was,  
but was then needed elsewhere.  ShmemBackendArray was static inside  
postmaster.c before launch_backend.c was created.  redirection_done  
was never static.  
  
This patch moves the declaration of ShmemLock and redirection_done to  
a header file.  
  
ShmemBackendArray gets a NON_EXEC_STATIC.  This doesn't make a  
difference, since it only exists if EXEC_BACKEND anyway, but it makes  
it consistent.  
  
After that, the comment is now correct.  
  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/postmaster/launch_backend.c
M src/backend/postmaster/postmaster.c
M src/backend/postmaster/syslogger.c
M src/backend/storage/lmgr/lwlock.c
M src/backend/utils/error/elog.c
M src/include/postmaster/postmaster.h
M src/include/storage/shmem.h

Add missing includes for some global variables

commit   : 881455e57b1210174b89bb3b13cad6b30b236d50    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 06:53:48 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 06:53:48 +0200    

Click here for diff

src/backend/libpq/pqcomm.c: "postmaster/postmaster.h" for Unix_socket_group, Unix_socket_permissions  
src/backend/utils/init/globals.c: "postmaster/postmaster.h" for MyClientSocket  
src/backend/utils/misc/guc_tables.c: "utils/rls.h" for row_security  
src/backend/utils/sort/tuplesort.c: "utils/guc.h" for trace_sort  
  
Nothing currently diagnoses missing includes for global variables, but  
this is being cleaned up, and these ones had an obvious header file  
available.  
  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/libpq/pqcomm.c
M src/backend/utils/init/globals.c
M src/backend/utils/misc/guc_tables.c
M src/backend/utils/sort/tuplesort.c

Convert some extern variables to static

commit   : 720b0eaae9b8a8326b2b6a6ff88fca4f47c631d4    
  
author   : Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 06:53:19 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Tue, 2 Jul 2024 06:53:19 +0200    

Click here for diff

These probably should have been static all along, it was only  
forgotten out of sloppiness.  
  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M contrib/isn/EAN13.h
M contrib/isn/ISBN.h
M contrib/isn/ISMN.h
M contrib/isn/ISSN.h
M contrib/isn/UPC.h
M src/backend/commands/user.c
M src/backend/postmaster/launch_backend.c
M src/backend/replication/logical/slotsync.c
M src/backend/replication/logical/worker.c
M src/backend/utils/misc/guc_tables.c
M src/bin/pg_archivecleanup/pg_archivecleanup.c
M src/bin/pg_basebackup/bbstreamer_file.c
M src/bin/pg_basebackup/bbstreamer_gzip.c
M src/bin/pg_basebackup/bbstreamer_inject.c
M src/bin/pg_basebackup/bbstreamer_lz4.c
M src/bin/pg_basebackup/bbstreamer_tar.c
M src/bin/pg_basebackup/bbstreamer_zstd.c
M src/bin/pg_basebackup/walmethods.c
M src/bin/pg_checksums/pg_checksums.c
M src/bin/pg_combinebackup/pg_combinebackup.c
M src/bin/pg_rewind/pg_rewind.c
M src/bin/pg_test_timing/pg_test_timing.c
M src/bin/pgbench/pgbench.c
M src/bin/scripts/vacuumdb.c
M src/pl/plpgsql/src/pl_handler.c
M src/test/isolation/isolation_main.c
M src/test/modules/dummy_index_am/dummy_index_am.c
M src/test/modules/libpq_pipeline/libpq_pipeline.c
M src/test/modules/test_json_parser/test_json_parser_incremental.c

Remove unused structure member in pg_createsubscriber.c.

commit   : a4c87df43a45a407a1f3fd584a7ffb32342628cc    
  
author   : Amit Kapila <[email protected]>    
date     : Tue, 2 Jul 2024 10:28:51 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Tue, 2 Jul 2024 10:28:51 +0530    

Click here for diff

Author: Kuroda Hayato  
Backpatch-through: 17  
Discussion: https://postgr.es/m/OSBPR01MB25526A30A1FBF863ACCDDA3AF5C92@OSBPR01MB2552.jpnprd01.prod.outlook.com  

M src/bin/pg_basebackup/pg_createsubscriber.c

Use TupleDescAttr macro consistently

commit   : 65b71dec2d577e9ef7423773a88fdd075f3eb97f    
  
author   : David Rowley <[email protected]>    
date     : Tue, 2 Jul 2024 13:41:47 +1200    
  
committer: David Rowley <[email protected]>    
date     : Tue, 2 Jul 2024 13:41:47 +1200    

Click here for diff

A few places were directly accessing the attrs[] array. This goes  
against the standards set by 2cd708452. Fix that.  
  
Discussion: https://postgr.es/m/CAApHDvrBztXP3yx=NKNmo3xwFAFhEdyPnvrDg3=M0RhDs+4vYw@mail.gmail.com  

M contrib/pageinspect/gistfuncs.c
M src/backend/catalog/heap.c
M src/backend/commands/prepare.c
M src/backend/executor/nodeIndexonlyscan.c
M src/backend/executor/nodeMemoize.c
M src/backend/optimizer/util/plancat.c

Cleanup perl code from unused variables and routines

commit   : 0c1aca461481216ff5a0e65538c4880bcf346433    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 2 Jul 2024 09:47:16 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 2 Jul 2024 09:47:16 +0900    

Click here for diff

This commit removes unused variables and routines from some perl code  
that have accumulated across the years.  This touches the following  
areas:  
- Wait event generation script.  
- AdjustUpgrade.pm.  
- TAP perl code  
  
Author: Alexander Lakhin  
Reviewed-by: Dagfinn Ilmari Mannsåker  
Discussion: https://postgr.es/m/[email protected]  

M contrib/amcheck/t/001_verify_heapam.pl
M contrib/amcheck/t/002_cic.pl
M src/backend/utils/activity/generate-wait_event_types.pl
M src/bin/pg_dump/t/003_pg_dump_with_server.pl
M src/bin/pg_dump/t/005_pg_dump_filterfile.pl
M src/test/modules/ldap_password_func/t/001_mutated_bindpasswd.pl
M src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl
M src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
M src/test/recovery/t/021_row_visibility.pl
M src/test/recovery/t/032_relfilenode_reuse.pl
M src/test/recovery/t/035_standby_logical_decoding.pl

Add information about access method for partitioned relations in \dP+

commit   : 978f38c771fb3a19fdd5cb73cb662441eb9e551c    
  
author   : Michael Paquier <[email protected]>    
date     : Tue, 2 Jul 2024 09:01:38 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Tue, 2 Jul 2024 09:01:38 +0900    

Click here for diff

Since 374c7a229042, it is possible to set a table AM on a partitioned  
table.  This information was showing up already in psql with \d+, while  
\dP+ provided no information.  
  
This commit extends \dP+ to show the access method used by a partitioned  
table or index, if set.  
  
Author: Justin Pryzby  
Discussion: https://postgr.es/m/ZkyivySXnbvOogZz@pryzbyj2023  

M src/bin/psql/describe.c

Remove support for HPPA (a/k/a PA-RISC) architecture.

commit   : edadeb0710e838f6ce1f95973fae683a56fdba06    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 1 Jul 2024 13:55:52 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 1 Jul 2024 13:55:52 -0400    

Click here for diff

This old CPU architecture hasn't been produced in decades, and  
whatever instances might still survive are surely too underpowered  
for anyone to consider running Postgres on in production.  We'd  
nonetheless continued to carry code support for it (largely at my  
insistence), because its unique implementation of spinlocks seemed  
like a good edge case for our spinlock infrastructure.  However,  
our last buildfarm animal of this type was retired last year, and  
it seems quite unlikely that another will emerge.  Without the ability  
to run tests, the argument that this is useful test code fails to  
hold water.  Furthermore, carrying code support for an untestable  
architecture has costs not to be ignored.  So, remove HPPA-specific  
code, in the same vein as commits 718aa43a4 and 92d70b77e.  
  
Discussion: https://postgr.es/m/[email protected]  

M contrib/pgcrypto/crypt-blowfish.c
M doc/src/sgml/installation.sgml
M src/backend/storage/lmgr/s_lock.c
M src/include/port/atomics.h
D src/include/port/atomics/arch-hppa.h
M src/include/port/atomics/fallback.h
M src/include/storage/s_lock.h
M src/tools/pginclude/headerscheck

Remove redundant privilege check from pg_sequences system view.

commit   : 7967d10c5b49ccb82f67a0b80678a1a932bccdee    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 1 Jul 2024 11:47:40 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 1 Jul 2024 11:47:40 -0500    

Click here for diff

This commit adjusts pg_sequence_last_value() to return NULL instead  
of ERROR-ing for sequences for which the current user lacks  
privileges.  This allows us to remove the call to  
has_sequence_privilege() in the definition of the pg_sequences  
system view.  
  
Bumps catversion.  
  
Suggested-by: Michael Paquier  
Reviewed-by: Michael Paquier, Tom Lane  
Discussion: https://postgr.es/m/20240501005730.GA594666%40nathanxps13  

M src/backend/catalog/system_views.sql
M src/backend/commands/sequence.c
M src/include/catalog/catversion.h
M src/test/regress/expected/rules.out

Preserve CurrentMemoryContext across Start/CommitTransactionCommand.

commit   : 1afe31f03cd268a0bbb7a340d56b8eef6419bcb0    
  
author   : Tom Lane <[email protected]>    
date     : Mon, 1 Jul 2024 11:55:19 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Mon, 1 Jul 2024 11:55:19 -0400    

Click here for diff

Up to now, committing a transaction has caused CurrentMemoryContext to  
get set to TopMemoryContext.  Most callers did not pay any particular  
heed to this, which is problematic because TopMemoryContext is a  
long-lived context that never gets reset.  If the caller assumes it  
can leak memory because it's running in a limited-lifespan context,  
that behavior translates into a session-lifespan memory leak.  
  
The first-reported instance of this involved ProcessIncomingNotify,  
which is called from the main processing loop that normally runs in  
MessageContext.  That outer-loop code assumes that whatever it  
allocates will be cleaned up when we're done processing the current  
client message --- but if we service a notify interrupt, then whatever  
gets allocated before the next switch to MessageContext will be  
permanently leaked in TopMemoryContext.  sinval catchup interrupts  
have a similar problem, and I strongly suspect that some places in  
logical replication do too.  
  
To fix this in a generic way, let's redefine the behavior as  
"CommitTransactionCommand restores the memory context that was current  
at entry to StartTransactionCommand".  This clearly fixes the issue  
for the notify and sinval cases, and it seems to match the mental  
model that's in use in the logical replication code, to the extent  
that anybody thought about it there at all.  
  
For consistency, likewise make subtransaction exit restore the context  
that was current at subtransaction start (rather than always selecting  
the CurTransactionContext of the parent transaction level).  This case  
has less risk of resulting in a permanent leak than the outer-level  
behavior has, but it would not meet the principle of least surprise  
for some CommitTransactionCommand calls to restore the previous  
context while others don't.  
  
While we're here, also change xact.c so that we reset  
TopTransactionContext at transaction exit and then re-use it in later  
transactions, rather than dropping and recreating it in each cycle.  
This probably doesn't save a lot given the context recycling mechanism  
in aset.c, but it should save a little bit.  Per suggestion from David  
Rowley.  (Parenthetically, the text in src/backend/utils/mmgr/README  
implies that this is how I'd planned to implement it as far back as  
commit 1aebc3618 --- but the code actually added in that commit just  
drops and recreates it each time.)  
  
This commit also cleans up a few places outside xact.c that were  
needlessly making TopMemoryContext current, and thus risking more  
leaks of the same kind.  I don't think any of them represent  
significant leak risks today, but let's deal with them while the  
issue is top-of-mind.  
  
Per bug #18512 from wizardbrony.  Commit to HEAD only, as this change  
seems to have some risk of breaking things for some callers.  We'll  
apply a narrower fix for the known-broken cases in the back branches.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/backend/access/transam/xact.c
M src/backend/replication/walsender.c
M src/backend/tcop/backend_startup.c
M src/backend/tcop/postgres.c
M src/backend/utils/mmgr/mcxt.c

Add --no-sync to pg_upgrade's uses of pg_dump and pg_dumpall.

commit   : 6e16b1e42003d811562d30b572ac3972238e2957    
  
author   : Nathan Bossart <[email protected]>    
date     : Mon, 1 Jul 2024 10:18:26 -0500    
  
committer: Nathan Bossart <[email protected]>    
date     : Mon, 1 Jul 2024 10:18:26 -0500    

Click here for diff

There's no reason to ensure that the files pg_upgrade generates  
with pg_dump and pg_dumpall have been written safely to disk.  If  
there is a crash during pg_upgrade, the upgrade must be restarted  
from the beginning; dump files left behind by previous pg_upgrade  
attempts cannot be reused.  
  
Reviewed-by: Peter Eisentraut, Tom Lane, Michael Paquier, Daniel Gustafsson  
Discussion: https://postgr.es/m/20240503171348.GA1731524%40nathanxps13  

M src/bin/pg_upgrade/dump.c

Remove useless extern keywords

commit   : 3fb59e789dd9f21610101d1ec106ad58095e24f3    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 1 Jul 2024 16:40:25 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 1 Jul 2024 16:40:25 +0200    

Click here for diff

An extern keyword on a function definition (not declaration) is  
useless and not the normal style.  
  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/backup/basebackup_incremental.c
M src/backend/storage/file/fd.c
M src/bin/pg_basebackup/bbstreamer_inject.c
M src/bin/pg_basebackup/bbstreamer_tar.c

Fix copy-paste mistake in PQcancelCreate

commit   : 3497c87b05a6ba31e8d760591900d550b2ef98bc    
  
author   : Alvaro Herrera <[email protected]>    
date     : Mon, 1 Jul 2024 13:58:22 +0200    
  
committer: Alvaro Herrera <[email protected]>    
date     : Mon, 1 Jul 2024 13:58:22 +0200    

Click here for diff

When an OOM occurred, this function was incorrectly setting a status of  
CONNECTION_BAD on the passed in PGconn instead of on the newly created  
PGcancelConn.  
  
Mistake introduced with 61461a300c1c.  Backpatch to 17.  
  
Author: Jelte Fennema-Nio <[email protected]>  
Reported-by: Noah Misch <[email protected]>  
Discussion: https://postgr.es/m/[email protected]  

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

Add context type field to pg_backend_memory_contexts

commit   : 12227a1d5f8ecad296c4204cc924d33c6a6bcd34    
  
author   : David Rowley <[email protected]>    
date     : Mon, 1 Jul 2024 21:19:01 +1200    
  
committer: David Rowley <[email protected]>    
date     : Mon, 1 Jul 2024 21:19:01 +1200    

Click here for diff

Since we now (as of v17) have 4 MemoryContext types, the type of context  
seems like useful information to include in the pg_backend_memory_contexts  
view.  Here we add that.  
  
Reviewed-by: David Christensen, Michael Paquier  
Discussion: https://postgr.es/m/CAApHDvrXX1OR09Zjb5TnB0AwCKze9exZN%3D9Nxxg1ZCVV8W-3BA%40mail.gmail.com  

M doc/src/sgml/system-views.sgml
M src/backend/utils/adt/mcxtfuncs.c
M src/include/catalog/catversion.h
M src/include/catalog/pg_proc.dat
M src/test/regress/expected/rules.out
M src/test/regress/expected/sysviews.out
M src/test/regress/sql/sysviews.sql

Remove useless code

commit   : e26d313bad92e71e2b59cc2e81870bf6d750de1f    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 1 Jul 2024 08:50:29 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 1 Jul 2024 08:50:29 +0200    

Click here for diff

BuildDescForRelation() goes out of its way to fill in  
->constr->has_not_null, but that value is not used for anything later,  
so this code can all be removed.  Note that BuildDescForRelation()  
doesn't make any effort to fill in the rest of ->constr, so there is  
no claim that that structure is completely filled in.  
  
Reviewed-by: Tomasz Rybak <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/commands/tablecmds.c

Remove useless initializations

commit   : da2aeba8f53379e84a8f3f656b6c2ffe5878eff5    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 1 Jul 2024 08:50:10 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 1 Jul 2024 08:50:10 +0200    

Click here for diff

The struct is already initialized to all zeros right before this, and  
randomly initializing a few but not all fields to zero again has no  
technical or educational value.  
  
Reviewed-by: Tomasz Rybak <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/[email protected]  

M src/backend/utils/cache/relcache.c

doc: Clarify that pg_attrdef also stores generation expressions

commit   : da486d360103fbb3cd0d3f3b70134d47e9bb652a    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 1 Jul 2024 08:39:07 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 1 Jul 2024 08:39:07 +0200    

Click here for diff

This was documented with pg_attribute but not with pg_attrdef.  
  
Reported-by: jian he <[email protected]>  
Discussion: https://www.postgresql.org/message-id/CACJufxE+E-iYmBnZVZHiYA+WpyZZVv7BfiBLpo=T70EZHDU9rw@mail.gmail.com  

M doc/src/sgml/catalogs.sgml

Rename standby_slot_names to synchronized_standby_slots.

commit   : 2357c9223b710c91b0f05cbc56bd435baeac961f    
  
author   : Amit Kapila <[email protected]>    
date     : Mon, 1 Jul 2024 11:36:56 +0530    
  
committer: Amit Kapila <[email protected]>    
date     : Mon, 1 Jul 2024 11:36:56 +0530    

Click here for diff

The standby_slot_names GUC allows the specification of physical standby  
slots that must be synchronized before the logical walsenders associated  
with logical failover slots. However, for this purpose, the GUC name is  
too generic.  
  
Author: Hou Zhijie  
Reviewed-by: Bertrand Drouvot, Masahiko Sawada  
Backpatch-through: 17  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/config.sgml
M doc/src/sgml/func.sgml
M doc/src/sgml/logical-replication.sgml
M doc/src/sgml/logicaldecoding.sgml
M src/backend/replication/logical/slotsync.c
M src/backend/replication/slot.c
M src/backend/replication/walsender.c
M src/backend/utils/misc/guc_tables.c
M src/backend/utils/misc/postgresql.conf.sample
M src/include/replication/slot.h
M src/include/replication/walsender_private.h
M src/include/utils/guc_hooks.h
M src/test/recovery/t/040_standby_failover_slots_sync.pl
M src/tools/pgindent/typedefs.list

Apply COPT to CXXFLAGS as well

commit   : 0c3930d0768943ad1dedb5a6ace250ce9b65915c    
  
author   : Peter Eisentraut <[email protected]>    
date     : Mon, 1 Jul 2024 07:30:38 +0200    
  
committer: Peter Eisentraut <[email protected]>    
date     : Mon, 1 Jul 2024 07:30:38 +0200    

Click here for diff

The main use of that make variable is to pass in -Werror.  It makes  
sense to apply this to C++ as well.  
  
Reviewed-by: Tom Lane <[email protected]>  
Reviewed-by: Andres Freund <[email protected]>  
Discussion: https://www.postgresql.org/message-id/flat/fe3e200c-edee-44e0-a6e3-d45dca72873b%40eisentraut.org  

M doc/src/sgml/installation.sgml
M src/Makefile.global.in

Use pgstat_kind_infos to read fixed shared statistics

commit   : 9004abf6206e815d25b7b763c756cf97b457f3cd    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 1 Jul 2024 14:26:25 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 1 Jul 2024 14:26:25 +0900    

Click here for diff

Shared statistics with a fixed number of objects are read from the stats  
file in pgstat_read_statsfile() using members of PgStat_ShmemControl and  
following an order based on their PgStat_Kind value.  
  
Instead of being explicit, this commit changes the stats read to iterate  
over the pgstat_kind_infos array to find the memory locations to read  
into, based on a new shared_ctl_off in PgStat_KindInfo that can be used  
to define the position of this stats kind in shared memory.  This makes  
the read logic simpler, and eases the introduction of future  
improvements aimed at making this area more pluggable for external  
modules.  
  
Original idea suggested by Andres Freund.  
  
Author: Tristan Partin  
Reviewed-by: Andres Freund, Michael Paquier  
Discussion: https://postgr.es/m/[email protected]  

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

Further weaken new pg_createsubscriber test on Windows.

commit   : a1333ec048fb95ff47a5fc10a9cfde69fdbd2b01    
  
author   : Tom Lane <[email protected]>    
date     : Sun, 30 Jun 2024 23:20:57 -0400    
  
committer: Tom Lane <[email protected]>    
date     : Sun, 30 Jun 2024 23:20:57 -0400    

Click here for diff

Also omit backslashes (\) in the generated database names on Windows.  
As before, perhaps we can revert this after updating affected  
buildfarm animals.  
  
Discussion: https://postgr.es/m/[email protected]  

M src/bin/pg_basebackup/t/040_pg_createsubscriber.pl

Format better code for xact_decode()'s XLOG_XACT_INVALIDATIONS

commit   : 797adaf0febe02e097353fa6b21dd67fd6bd73c9    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 1 Jul 2024 10:08:00 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 1 Jul 2024 10:08:00 +0900    

Click here for diff

This makes the code more consistent with the surroundings.  
  
Author: ChangAo Chen  
Reviewed-by: Ashutosh Bapat  
Discussion: https://postgr.es/m/CAExHW5tNTevUh58SKddTtcX3yU_5_PDSC8Mdp-Q2hc9PpZHRJg@mail.gmail.com  

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

doc: Add ACL acronym for "Access Control List"

commit   : 00d819d46a6f5b7e9d2e02948a1c80d11c4ce260    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 1 Jul 2024 09:55:37 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 1 Jul 2024 09:55:37 +0900    

Click here for diff

Five places across the docs use this abbreviation, so let's use a proper  
acronym entry for it.  
  
Per suggestion from me.  
  
Author: Joel Jacobson  
Reviewed-by: Nathan Bossart, David G. Johnston  
Discussion: https://postgr.es/m/[email protected]  

M doc/src/sgml/acronyms.sgml
M doc/src/sgml/catalogs.sgml
M doc/src/sgml/ddl.sgml
M doc/src/sgml/func.sgml

Remove PgStat_KindInfo.named_on_disk

commit   : b19db55bd687af243dd1edf021ffb166e5270a06    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 1 Jul 2024 09:35:36 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 1 Jul 2024 09:35:36 +0900    

Click here for diff

This field is used to track if a stats kind can use a custom format  
representation on disk when reading or writing its stats case.  On HEAD,  
this exists for replication slots stats, that need a mapping between an  
internal index ID and the slot names.  
  
named_on_disk is currently used nowhere and the callbacks  
to_serialized_name and from_serialized_name are in charge of checking if  
the serialization of the stats data should apply, so let's remove it.  
  
Reviewed-by: Andres Freund  
Discussion: https://postgr.es/m/[email protected]  

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

Improve enlargeStringInfo's ERROR message

commit   : 1029bdec2d641f378eaa59f00a93b136f191f3c7    
  
author   : David Rowley <[email protected]>    
date     : Mon, 1 Jul 2024 12:11:10 +1200    
  
committer: David Rowley <[email protected]>    
date     : Mon, 1 Jul 2024 12:11:10 +1200    

Click here for diff

Until now, when an enlargeStringInfo() call would cause the StringInfo to  
exceed its maximum size, we reported an "out of memory" error.  This is  
misleading as it's no such thing.  
  
Here we remove the "out of memory" text and replace it with something  
more relevant to better indicate that it's a program limitation that's  
been reached.  
  
Reported-by: Michael Banck  
Reviewed-by: Daniel Gustafsson, Tom Lane  
Discussion: https://postgr.es/m/[email protected]  

M src/common/stringinfo.c

Stamp HEAD as 18devel.

commit   : e26810d01d441a457217a6eae9c2989fba29b80f    
  
author   : Michael Paquier <[email protected]>    
date     : Mon, 1 Jul 2024 07:56:10 +0900    
  
committer: Michael Paquier <[email protected]>    
date     : Mon, 1 Jul 2024 07:56:10 +0900    

Click here for diff

Let the hacking begin ...  

M configure
M configure.ac
M doc/src/sgml/filelist.sgml
D doc/src/sgml/release-17.sgml
A doc/src/sgml/release-18.sgml
M doc/src/sgml/release.sgml
M meson.build
M src/tools/git_changelog
M src/tools/version_stamp.pl