Stamp 14.14.
commit : 8abd1324049759c1cbd81a4793c470a4f43e1fdb
author : Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 17:47:15 -0500
committer: Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 17:47:15 -0500
M configure
M configure.ac
Last-minute updates for release notes.
commit : 575d673fe78f76e396ea7eb8160c30d96ccfea0f
author : Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 17:40:13 -0500
committer: Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 17:40:13 -0500
Security: CVE-2024-10976, CVE-2024-10977, CVE-2024-10978, CVE-2024-10979
M doc/src/sgml/release-14.sgml
Parallel workers use AuthenticatedUserId for connection privilege checks.
commit : 00b94e8e2f99a8ed1d7f854838234ce37f582da0
author : Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 17:05:53 -0500
committer: Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 17:05:53 -0500
Commit 5a2fed911 had an unexpected side-effect: the parallel worker
launched for the new test case would fail if it couldn't use a
superuser-reserved connection slot. The reason that test failed
while all our pre-existing ones worked is that the connection
privilege tests in InitPostgres had been based on the superuserness
of the leader's AuthenticatedUserId, but after the rearrangements
of 5a2fed911 we were testing the superuserness of CurrentUserId,
which the new test case deliberately made to be a non-superuser.
This all seems very accidental and probably not the behavior we really
want, but a security patch is no time to be redesigning things.
Pending some discussion about desirable semantics, hack it so that
InitPostgres continues to pay attention to the superuserness of
AuthenticatedUserId when starting a parallel worker.
Nathan Bossart and Tom Lane, per buildfarm member sawshark.
Security: CVE-2024-10978
M src/backend/utils/init/postinit.c
Fix cross-version upgrade tests.
commit : 256e34653aadd3582b98411d7d26f4fbb865e0ec
author : Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 13:57:21 -0500
committer: Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 13:57:21 -0500
TestUpgradeXversion knows how to make the main regression database's
references to pg_regress.so be version-independent. But it doesn't
do that for plperl's database, so that the C function added by
commit b7e3a52a8 is causing cross-version upgrade test failures.
Path of least resistance is to just drop the function at the end
of the new test.
In <= v14, also take the opportunity to clean up the generated
test files.
Security: CVE-2024-10979
M src/pl/plperl/GNUmakefile
M src/pl/plperl/input/plperl_env.source
M src/pl/plperl/output/plperl_env.source
src/tools/msvc: Respect REGRESS_OPTS in plcheck.
commit : c1fff7b1b311057fb0f8e78e7fca4efa80d48707
author : Noah Misch <[email protected]>
date : Mon, 11 Nov 2024 10:55:18 -0800
committer: Noah Misch <[email protected]>
date : Mon, 11 Nov 2024 10:55:18 -0800
v16 commit 8fe3e697a1a83a722b107c7cb9c31084e1f4d077 used REGRESS_OPTS in
a way needing this. That broke "vcregress plcheck". Back-patch
v16..v12; newer versions don't have this build system.
M src/tools/msvc/vcregress.pl
Add needed .gitignore files in back branches.
commit : f89bd92c963c3be30a1cf26960aa86aaad117235
author : Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 10:42:32 -0500
committer: Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 10:42:32 -0500
v14 and earlier use generated test files, which require being
.gitignore'd to avoid git complaints when testing in-tree.
Security: CVE-2024-10979
A src/pl/plperl/expected/.gitignore
A src/pl/plperl/sql/.gitignore
Fix improper interactions between session_authorization and role.
commit : 2a68808e241bf667ff72c31ea9d0c4eb0b893982
author : Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 10:29:54 -0500
committer: Tom Lane <[email protected]>
date : Mon, 11 Nov 2024 10:29:54 -0500
The SQL spec mandates that SET SESSION AUTHORIZATION implies
SET ROLE NONE. We tried to implement that within the lowest-level
functions that manipulate these settings, but that was a bad idea.
In particular, guc.c assumes that it doesn't matter in what order
it applies GUC variable updates, but that was not the case for these
two variables. This problem, compounded by some hackish attempts to
work around it, led to some security-grade issues:
* Rolling back a transaction that had done SET SESSION AUTHORIZATION
would revert to SET ROLE NONE, even if that had not been the previous
state, so that the effective user ID might now be different from what
it had been.
* The same for SET SESSION AUTHORIZATION in a function SET clause.
* If a parallel worker inspected current_setting('role'), it saw
"none" even when it should see something else.
Also, although the parallel worker startup code intended to cope
with the current role's pg_authid row having disappeared, its
implementation of that was incomplete so it would still fail.
Fix by fully separating the miscinit.c functions that assign
session_authorization from those that assign role. To implement the
spec's requirement, teach set_config_option itself to perform "SET
ROLE NONE" when it sets session_authorization. (This is undoubtedly
ugly, but the alternatives seem worse. In particular, there's no way
to do it within assign_session_authorization without incompatible
changes in the API for GUC assign hooks.) Also, improve
ParallelWorkerMain to directly set all the relevant user-ID variables
instead of relying on some of them to get set indirectly. That
allows us to survive not finding the pg_authid row during worker
startup.
In v16 and earlier, this includes back-patching 9987a7bf3 which
fixed a violation of GUC coding rules: SetSessionAuthorization
is not an appropriate place to be throwing errors from.
Security: CVE-2024-10978
M src/backend/access/transam/parallel.c
M src/backend/commands/variable.c
M src/backend/utils/init/miscinit.c
M src/backend/utils/misc/guc.c
M src/include/miscadmin.h
M src/test/regress/expected/privileges.out
M src/test/regress/sql/privileges.sql
Ensure cached plans are correctly marked as dependent on role.
commit : 4e51030af9e0a12d7fa06b73acd0c85024f81062
author : Nathan Bossart <[email protected]>
date : Mon, 11 Nov 2024 09:00:00 -0600
committer: Nathan Bossart <[email protected]>
date : Mon, 11 Nov 2024 09:00:00 -0600
If a CTE, subquery, sublink, security invoker view, or coercion
projection references a table with row-level security policies, we
neglected to mark the plan as potentially dependent on which role
is executing it. This could lead to later executions in the same
session returning or hiding rows that should have been hidden or
returned instead.
Reported-by: Wolfgang Walther
Reviewed-by: Noah Misch
Security: CVE-2024-10976
Backpatch-through: 12
M src/backend/executor/functions.c
M src/backend/rewrite/rewriteHandler.c
M src/test/regress/expected/rowsecurity.out
M src/test/regress/sql/rowsecurity.sql
M src/tools/pgindent/typedefs.list
Block environment variable mutations from trusted PL/Perl.
commit : d15ec27c977100037ae513ab7fe1a214bfc2507b
author : Noah Misch <[email protected]>
date : Mon, 11 Nov 2024 06:23:43 -0800
committer: Noah Misch <[email protected]>
date : Mon, 11 Nov 2024 06:23:43 -0800
Many process environment variables (e.g. PATH), bypass the containment
expected of a trusted PL. Hence, trusted PLs must not offer features
that achieve setenv(). Otherwise, an attacker having USAGE privilege on
the language often can achieve arbitrary code execution, even if the
attacker lacks a database server operating system user.
To fix PL/Perl, replace trusted PL/Perl %ENV with a tied hash that just
replaces each modification attempt with a warning. Sites that reach
these warnings should evaluate the application-specific implications of
proceeding without the environment modification:
Can the application reasonably proceed without the modification?
If no, switch to plperlu or another approach.
If yes, the application should change the code to stop attempting
environment modifications. If that's too difficult, add "untie
%main::ENV" in any code executed before the warning. For example,
one might add it to the start of the affected function or even to
the plperl.on_plperl_init setting.
In passing, link to Perl's guidance about the Perl features behind the
security posture of PL/Perl.
Back-patch to v12 (all supported versions).
Andrew Dunstan and Noah Misch
Security: CVE-2024-10979
M doc/src/sgml/plperl.sgml
M src/pl/plperl/GNUmakefile
A src/pl/plperl/input/plperl_env.source
A src/pl/plperl/output/plperl_env.source
M src/pl/plperl/plc_trusted.pl
M src/test/regress/regress.c
Translation updates
commit : 69f66fbf72adc50c7c99fd0e50a22a3cc8e638af
author : Peter Eisentraut <[email protected]>
date : Mon, 11 Nov 2024 13:57:37 +0100
committer: Peter Eisentraut <[email protected]>
date : Mon, 11 Nov 2024 13:57:37 +0100
Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash: aa68946b3e7aa4447636af97ee7b0f249144085d
M src/backend/po/de.po
M src/backend/po/es.po
M src/backend/po/fr.po
M src/backend/po/ja.po
M src/backend/po/ru.po
M src/backend/po/sv.po
M src/bin/initdb/po/es.po
M src/bin/initdb/po/fr.po
M src/bin/initdb/po/ru.po
M src/bin/pg_amcheck/po/es.po
M src/bin/pg_amcheck/po/fr.po
M src/bin/pg_amcheck/po/ru.po
M src/bin/pg_archivecleanup/po/es.po
M src/bin/pg_archivecleanup/po/fr.po
M src/bin/pg_archivecleanup/po/ru.po
M src/bin/pg_basebackup/po/es.po
M src/bin/pg_basebackup/po/fr.po
M src/bin/pg_basebackup/po/ru.po
M src/bin/pg_checksums/po/es.po
M src/bin/pg_checksums/po/fr.po
M src/bin/pg_checksums/po/ru.po
M src/bin/pg_config/po/es.po
M src/bin/pg_config/po/fr.po
M src/bin/pg_config/po/ru.po
M src/bin/pg_controldata/po/es.po
M src/bin/pg_controldata/po/fr.po
M src/bin/pg_controldata/po/ru.po
M src/bin/pg_ctl/po/es.po
M src/bin/pg_ctl/po/fr.po
M src/bin/pg_ctl/po/ru.po
M src/bin/pg_dump/po/es.po
M src/bin/pg_dump/po/fr.po
M src/bin/pg_dump/po/ru.po
M src/bin/pg_resetwal/po/es.po
M src/bin/pg_resetwal/po/fr.po
M src/bin/pg_resetwal/po/ru.po
M src/bin/pg_rewind/po/es.po
M src/bin/pg_rewind/po/fr.po
M src/bin/pg_rewind/po/ru.po
M src/bin/pg_test_fsync/po/es.po
M src/bin/pg_test_fsync/po/fr.po
M src/bin/pg_test_fsync/po/ru.po
M src/bin/pg_test_timing/po/es.po
M src/bin/pg_test_timing/po/fr.po
M src/bin/pg_test_timing/po/ru.po
M src/bin/pg_upgrade/po/es.po
M src/bin/pg_upgrade/po/fr.po
M src/bin/pg_upgrade/po/ru.po
M src/bin/pg_verifybackup/po/es.po
M src/bin/pg_verifybackup/po/fr.po
M src/bin/pg_verifybackup/po/ru.po
M src/bin/pg_waldump/po/es.po
M src/bin/pg_waldump/po/fr.po
M src/bin/pg_waldump/po/ru.po
M src/bin/psql/po/de.po
M src/bin/psql/po/es.po
M src/bin/psql/po/fr.po
M src/bin/psql/po/ja.po
M src/bin/psql/po/ru.po
M src/bin/scripts/po/es.po
M src/bin/scripts/po/fr.po
M src/bin/scripts/po/ru.po
M src/interfaces/ecpg/ecpglib/po/es.po
M src/interfaces/ecpg/ecpglib/po/fr.po
M src/interfaces/ecpg/preproc/po/es.po
M src/interfaces/ecpg/preproc/po/fr.po
M src/interfaces/ecpg/preproc/po/ru.po
M src/interfaces/libpq/po/es.po
M src/interfaces/libpq/po/fr.po
M src/interfaces/libpq/po/ja.po
M src/interfaces/libpq/po/ru.po
M src/pl/plperl/po/es.po
M src/pl/plperl/po/fr.po
M src/pl/plperl/po/ru.po
M src/pl/plpgsql/src/po/es.po
M src/pl/plpgsql/src/po/fr.po
M src/pl/plpgsql/src/po/ru.po
M src/pl/plpython/po/es.po
M src/pl/plpython/po/fr.po
M src/pl/tcl/po/es.po
M src/pl/tcl/po/fr.po
libpq: Bail out during SSL/GSS negotiation errors
commit : e6c9454764d880ee30735aa8c1e05d3674722ff9
author : Michael Paquier <[email protected]>
date : Mon, 11 Nov 2024 10:20:01 +0900
committer: Michael Paquier <[email protected]>
date : Mon, 11 Nov 2024 10:20:01 +0900
This commit changes libpq so that errors reported by the backend during
the protocol negotiation for SSL and GSS are discarded by the client, as
these may include bytes that could be consumed by the client and write
arbitrary bytes to a client's terminal.
A failure with the SSL negotiation now leads to an error immediately
reported, without a retry on any other methods allowed, like a fallback
to a plaintext connection.
A failure with GSS discards the error message received, and we allow a
fallback as it may be possible that the error is caused by a connection
attempt with a pre-11 server, GSS encryption having been introduced in
v12. This was a problem only with v17 and newer versions; older
versions discard the error message already in this case, assuming a
failure caused by a lack of support for GSS encryption.
Author: Jacob Champion
Reviewed-by: Peter Eisentraut, Heikki Linnakangas, Michael Paquier
Security: CVE-2024-10977
Backpatch-through: 12
M doc/src/sgml/protocol.sgml
M src/interfaces/libpq/fe-connect.c
Release notes for 17.1, 16.5, 15.9, 14.14, 13.17, 12.21.
commit : 28301cd4df386c263e85b9b3b6f2c5bd74f26767
author : Tom Lane <[email protected]>
date : Sun, 10 Nov 2024 13:40:41 -0500
committer: Tom Lane <[email protected]>
date : Sun, 10 Nov 2024 13:40:41 -0500
M doc/src/sgml/release-14.sgml
Improve fix for not entering parallel mode when holding interrupts.
commit : 989ccd26c838f9393b45e547f22b64e469d1dc04
author : Tom Lane <[email protected]>
date : Fri, 8 Nov 2024 13:42:01 -0500
committer: Tom Lane <[email protected]>
date : Fri, 8 Nov 2024 13:42:01 -0500
Commit ac04aa84a put the shutoff for this into the planner, which is
not ideal because it doesn't prevent us from re-using a previously
made parallel plan. Revert the planner change and instead put the
shutoff into InitializeParallelDSM, modeling it on the existing code
there for recovering from failure to allocate a DSM segment.
However, that code path is mostly untested, and testing a bit harder
showed there's at least one bug: ExecHashJoinReInitializeDSM is not
prepared for us to have skipped doing parallel DSM setup. I also
thought the Assert in ReinitializeParallelWorkers is pretty
ill-advised, and replaced it with a silent Min() operation.
The existing test case added by ac04aa84a serves fine to test this
version of the fix, so no change needed there.
Patch by me, but thanks to Noah Misch for the core idea that we
could shut off worker creation when !INTERRUPTS_CAN_BE_PROCESSED.
Back-patch to v12, as ac04aa84a was.
Discussion: https://postgr.es/m/CAC-SaSzHUKT=vZJ8MPxYdC_URPfax+yoA1hKTcF4ROz_Q6z0_Q@mail.gmail.com
M src/backend/access/transam/parallel.c
M src/backend/executor/nodeHashjoin.c
M src/backend/optimizer/plan/planner.c
Disallow partitionwise join when collations don't match
commit : 62df5484f976b76c95cbb00ae797e90de1b81f99
author : Amit Langote <[email protected]>
date : Fri, 8 Nov 2024 16:30:33 +0900
committer: Amit Langote <[email protected]>
date : Fri, 8 Nov 2024 16:30:33 +0900
If the collation of any join key column doesn’t match the collation of
the corresponding partition key, partitionwise joins can yield incorrect
results. For example, rows that would match under the join key collation
might be located in different partitions due to the partitioning
collation. In such cases, a partitionwise join would yield different
results from a non-partitionwise join, so disallow it in such cases.
Reported-by: Tender Wang <[email protected]>
Author: Jian He <[email protected]>
Reviewed-by: Tender Wang <[email protected]>
Reviewed-by: Junwang Zhao <[email protected]>
Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com
Backpatch-through: 12
M src/backend/optimizer/util/relnode.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql
Disallow partitionwise grouping when collations don't match
commit : 96f9b29a3e1ea3dd58e728814bf630d40ff77caa
author : Amit Langote <[email protected]>
date : Fri, 8 Nov 2024 16:06:46 +0900
committer: Amit Langote <[email protected]>
date : Fri, 8 Nov 2024 16:06:46 +0900
If the collation of any grouping column doesn’t match the collation of
the corresponding partition key, partitionwise grouping can yield
incorrect results. For example, rows that would be grouped under the
grouping collation may end up in different partitions under the
partitioning collation. In such cases, full partitionwise grouping
would produce results that differ from those without partitionwise
grouping, so disallowed that.
Partial partitionwise aggregation is still allowed, as the Finalize
step reconciles partition-level aggregates with grouping requirements
across all partitions, ensuring that the final output remains
consistent.
This commit also fixes group_by_has_partkey() by ensuring the
RelabelType node is stripped from grouping expressions when matching
them to partition key expressions to avoid false mismatches.
Bug: #18568
Reported-by: Webbo Han <[email protected]>
Author: Webbo Han <[email protected]>
Reviewed-by: Tender Wang <[email protected]>
Reviewed-by: Aleksander Alekseev <[email protected]>
Reviewed-by: Jian He <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Discussion: https://postgr.es/m/[email protected]
Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com
Backpatch-through: 12
M src/backend/optimizer/plan/planner.c
M src/test/regress/expected/collate.icu.utf8.out
M src/test/regress/sql/collate.icu.utf8.sql
Message style improvement
commit : a54a5c426bb5a3e216d715437a9a043aa82b6ec4
author : Peter Eisentraut <[email protected]>
date : Fri, 8 Nov 2024 07:17:55 +0100
committer: Peter Eisentraut <[email protected]>
date : Fri, 8 Nov 2024 07:17:55 +0100
Backpatch the part of edee0c621de that applies to a90bdd7a44d, which
was also backpatched. That way, the message is consistent in all
branches.
M src/backend/commands/tablecmds.c
M src/test/regress/expected/foreign_key.out
Replace pgwin32_is_junction() with lstat().
commit : ca9921936ea352df30db2955fb2662695d8377be
author : Thomas Munro <[email protected]>
date : Sat, 6 Aug 2022 12:02:43 +1200
committer: Andrew Dunstan <[email protected]>
date : Sat, 6 Aug 2022 12:02:43 +1200
Now that lstat() reports junction points with S_IFLNK/S_ISLINK(), and
unlink() can unlink them, there is no need for conditional code for
Windows in a few places. That was expressed by testing for WIN32 or
S_ISLNK, which we can now constant-fold.
The coding around pgwin32_is_junction() was a bit suspect anyway, as we
never checked for errors, and we also know that errors can be spuriously
reported because of transient sharing violations on this OS. The
lstat()-based code has handling for that.
This also reverts 4fc6b6ee on master only. That was done because
lstat() didn't previously work for symlinks (junction points), but now
it does.
Tested-by: Andrew Dunstan <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGLfOOeyZpm5ByVcAt7x5Pn-%3DxGRNCvgiUPVVzjFLtnY0w%40mail.gmail.com
(cherry picked from commit 5fc88c5d53e43fa7dcea93499d230a0bf70f4f77)
Author: Thomas Munro <[email protected]>
Author: Alexandra Wang <[email protected]>
M src/backend/commands/tablespace.c
M src/backend/replication/basebackup.c
M src/backend/storage/file/fd.c
M src/backend/utils/adt/misc.c
M src/bin/pg_checksums/pg_checksums.c
M src/bin/pg_rewind/file_ops.c
M src/common/file_utils.c
M src/include/port.h
M src/include/port/win32_port.h
M src/port/dirmod.c
Fix lstat() for broken junction points on Windows.
commit : 8a5e4982f9c536fafa4ae9b7c331ee656ded2fe5
author : Thomas Munro <[email protected]>
date : Tue, 25 Oct 2022 15:20:00 +1300
committer: Andrew Dunstan <[email protected]>
date : Tue, 25 Oct 2022 15:20:00 +1300
When using junction points to emulate symlinks on Windows, one edge case
was not handled correctly by commit c5cb8f3b: if a junction point is
broken (pointing to a non-existent path), we'd report ENOENT. This
doesn't break any known use case, but was noticed while developing a
test suite for these functions and is fixed here for completeness.
Also add translation ERROR_CANT_RESOLVE_FILENAME -> ENOENT, as that is
one of the errors Windows can report for some kinds of broken paths.
Discussion: https://postgr.es/m/CA%2BhUKG%2BajSQ_8eu2AogTncOnZ5me2D-Cn66iN_-wZnRjLN%2Bicg%40mail.gmail.com
(cherry picked from commit 387803d81d6256fcb60b9192bb5b00042442b4e3)
Author: Thomas Munro <[email protected]>
Author: Alexandra Wang <[email protected]>
M src/port/win32error.c
M src/port/win32stat.c
Provide lstat() for Windows.
commit : 895f23d9e174897a9c1a71a2c6cdb439fe5a3101
author : Thomas Munro <[email protected]>
date : Sat, 6 Aug 2022 12:00:57 +1200
committer: Andrew Dunstan <[email protected]>
date : Sat, 6 Aug 2022 12:00:57 +1200
Junction points will be reported with S_ISLNK(x.st_mode), simulating
POSIX lstat(). stat() will follow pseudo-symlinks, like in POSIX (but
only one level before giving up, unlike in POSIX).
This completes a TODO left by commit bed90759fcb.
Tested-by: Andrew Dunstan <[email protected]> (earlier version)
Discussion: https://postgr.es/m/CA%2BhUKGLfOOeyZpm5ByVcAt7x5Pn-%3DxGRNCvgiUPVVzjFLtnY0w%40mail.gmail.com
(cherry picked from commit c5cb8f3b770c043509b61528664bcd805e1777e6)
Author: Thomas Munro <[email protected]>
Author: Alexandra Wang <[email protected]>
M src/include/port/win32_port.h
M src/port/win32stat.c
Make unlink() work for junction points on Windows.
commit : 02a4ec478df8a4724b84d76f84e49248da204f95
author : Thomas Munro <[email protected]>
date : Sat, 6 Aug 2022 12:01:42 +1200
committer: Andrew Dunstan <[email protected]>
date : Sat, 6 Aug 2022 12:01:42 +1200
To support harmonization of Windows and Unix code, teach our unlink()
wrapper that junction points need to be unlinked with rmdir() on
Windows.
Tested-by: Andrew Dunstan <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGLfOOeyZpm5ByVcAt7x5Pn-%3DxGRNCvgiUPVVzjFLtnY0w%40mail.gmail.com
(cherry picked from commit f357233c9db8be2a015163da8e1ab0630f444340)
Author: Thomas Munro <[email protected]>
Author: Alexandra Wang <[email protected]>
M src/port/dirmod.c
Add missing include guard to win32ntdll.h.
commit : ce14dbbcafde5a629d4dbcabdadecea440e7955d
author : Thomas Munro <[email protected]>
date : Wed, 12 Jan 2022 10:11:50 +1300
committer: Andrew Dunstan <[email protected]>
date : Wed, 12 Jan 2022 10:11:50 +1300
Oversight in commit e2f0f8ed. Also add this file to the exclusion lists
in headerscheck and cpluscpluscheck, because Unix systems don't have a
header it includes.
Reported-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/2760528.1641929756%40sss.pgh.pa.us
(cherry picked from commit af9e6331aeba149c93052c3549140082a85a3cf9)
Author: Thomas Munro <[email protected]>
Author: Alexandra Wang <[email protected]>
M src/include/port/win32ntdll.h
M src/tools/pginclude/cpluspluscheck
M src/tools/pginclude/headerscheck
Check for STATUS_DELETE_PENDING on Windows.
commit : 1bf47d89776c2647d896f308687fa13d6c2877e2
author : Thomas Munro <[email protected]>
date : Fri, 10 Dec 2021 16:13:14 +1300
committer: Andrew Dunstan <[email protected]>
date : Fri, 10 Dec 2021 16:13:14 +1300
1. Update our open() wrapper to check for NT's STATUS_DELETE_PENDING
and translate it to Unix-like errors. This is done with
RtlGetLastNtStatus(), which is dynamically loaded from ntdll. A new
file win32ntdll.c centralizes lookup of NT functions, in case we decide
to add more in the future.
2. Remove non-working code that was trying to do something similar for
stat(), and just reuse the open() wrapper code. As a side effect,
stat() also gains resilience against "sharing violation" errors.
3. Since stat() is used very early in process startup, remove the
requirement that the Win32 signal event has been created before
pgwin32_open_handle() is reached. Instead, teach pg_usleep() to fall
back to a non-interruptible sleep if reached before the signal event is
available.
This could be back-patched, but for now it's in master only. The
problem has apparently been with us for a long time and generated only a
few complaints. Proposed patches trigger it more often, which led to
this investigation and fix.
Reviewed-by: Andres Freund <[email protected]>
Reviewed-by: Alexander Lakhin <[email protected]>
Reviewed-by: Juan José Santamaría Flecha <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGJz_pZTF9mckn6XgSv69%2BjGwdgLkxZ6b3NWGLBCVjqUZA%40mail.gmail.com
(cherry picked from commit e2f0f8ed251d02c1eda79e1ca3cb3db2681e7a86)
Author: Thomas Munro <[email protected]>
Author: Alexandra Wang <[email protected]>
M configure
M configure.ac
M src/backend/port/win32/signal.c
M src/include/port.h
A src/include/port/win32ntdll.h
M src/port/open.c
A src/port/win32ntdll.c
M src/port/win32stat.c
M src/tools/msvc/Mkvcbuild.pm
doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constraints
commit : 344ac149cfdfc1efe1608f46f40f05f4af91c8eb
author : Álvaro Herrera <[email protected]>
date : Thu, 7 Nov 2024 14:06:24 +0100
committer: Álvaro Herrera <[email protected]>
date : Thu, 7 Nov 2024 14:06:24 +0100
The previous wording is easy to read incorrectly; this change makes it
simpler, less ambiguous, and less prominent.
Backpatch to all live branches.
Reviewed-by: Amit Langote <[email protected]>
Discussion: https://postgr.es/m/[email protected]
M doc/src/sgml/ref/alter_table.sgml
Monkey-patch LLVM code to fix ARM relocation bug.
commit : 0b022ddf3e30c292a5246150492af15590e7f477
author : Thomas Munro <[email protected]>
date : Wed, 6 Nov 2024 22:04:44 +1300
committer: Thomas Munro <[email protected]>
date : Wed, 6 Nov 2024 22:04:44 +1300
Supply a new memory manager for RuntimeDyld, to avoid crashes in
generated code caused by memory placement that can overflow a 32 bit
data type. This is a drop-in replacement for the
llvm::SectionMemoryManager class in the LLVM library, with Michael
Smith's proposed fix from
https://www.github.com/llvm/llvm-project/pull/71968.
We hereby slurp it into our own source tree, after moving into a new
namespace llvm::backport and making some minor adjustments so that it
can be compiled with older LLVM versions as far back as 12. It's harder
to make it work on even older LLVM versions, but it doesn't seem likely
that people are really using them so that is not investigated for now.
The problem could also be addressed by switching to JITLink instead of
RuntimeDyld, and that is the LLVM project's recommended solution as
the latter is about to be deprecated. We'll have to do that soon enough
anyway, and then when the LLVM version support window advances far
enough in a few years we'll be able to delete this code. Unfortunately
that wouldn't be enough for PostgreSQL today: in most relevant versions
of LLVM, JITLink is missing or incomplete.
Several other projects have already back-ported this fix into their fork
of LLVM, which is a vote of confidence despite the lack of commit into
LLVM as of today. We don't have our own copy of LLVM so we can't do
exactly what they've done; instead we have a copy of the whole patched
class so we can pass an instance of it to RuntimeDyld.
The LLVM project hasn't chosen to commit the fix yet, and even if it
did, it wouldn't be back-ported into the releases of LLVM that most of
our users care about, so there is not much point in waiting any longer
for that. If they make further changes and commit it to LLVM 19 or 20,
we'll still need this for older versions, but we may want to
resynchronize our copy and update some comments.
The changes that we've had to make to our copy can be seen by diffing
our SectionMemoryManager.{h,cpp} files against the ones in the tree of
the pull request. Per the LLVM project's license requirements, a copy
is in SectionMemoryManager.LICENSE.
This should fix the spate of crash reports we've been receiving lately
from users on large memory ARM systems.
Back-patch to all supported releases.
Co-authored-by: Thomas Munro <[email protected]>
Co-authored-by: Anthonin Bonnefoy <[email protected]>
Reviewed-by: Anthonin Bonnefoy <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]> (license aspects)
Reported-by: Anthonin Bonnefoy <[email protected]>
Discussion: https://postgr.es/m/CAO6_Xqr63qj%3DSx7HY6ZiiQ6R_JbX%2B-p6sTPwDYwTWZjUmjsYBg%40mail.gmail.com
M src/backend/jit/llvm/Makefile
A src/backend/jit/llvm/SectionMemoryManager.LICENSE
A src/backend/jit/llvm/SectionMemoryManager.cpp
M src/backend/jit/llvm/llvmjit.c
M src/backend/jit/llvm/llvmjit_wrap.cpp
A src/include/jit/SectionMemoryManager.h
M src/include/jit/llvmjit.h
A src/include/jit/llvmjit_backport.h
M src/tools/pginclude/headerscheck
M src/tools/pgindent/exclude_file_patterns
Suppress new "may be used uninitialized" warning.
commit : 803655e660edbfa87e5479fc68799ba9780638ac
author : Noah Misch <[email protected]>
date : Sat, 2 Nov 2024 19:42:52 -0700
committer: Noah Misch <[email protected]>
date : Sat, 2 Nov 2024 19:42:52 -0700
Buildfarm member mamba fails to deduce that the function never uses this
variable without initializing it. Back-patch to v12, like commit
b412f402d1e020c5dac94f3bf4a005db69519b99.
M src/backend/catalog/index.c
Move I/O before the index_update_stats() buffer lock region.
commit : bb30542976618e6d0cd9eb2358824b741566ffbf
author : Noah Misch <[email protected]>
date : Sat, 2 Nov 2024 09:04:55 -0700
committer: Noah Misch <[email protected]>
date : Sat, 2 Nov 2024 09:04:55 -0700
Commit a07e03fd8fa7daf4d1356f7cb501ffe784ea6257 enlarged the work done
here under the pg_class heap buffer lock. Two preexisting actions are
best done before holding that lock. Both RelationGetNumberOfBlocks()
and visibilitymap_count() do I/O, and the latter might exclusive-lock a
visibility map buffer. Moving these reduces contention and risk of
undetected LWLock deadlock. Back-patch to v12, like that commit.
Discussion: https://postgr.es/m/[email protected]
M src/backend/catalog/index.c
Revert "For inplace update, send nontransactional invalidations."
commit : 4c708872950374dce23a61a1eba1411d9498d5d2
author : Noah Misch <[email protected]>
date : Sat, 2 Nov 2024 09:05:00 -0700
committer: Noah Misch <[email protected]>
date : Sat, 2 Nov 2024 09:05:00 -0700
This reverts commit 95c5acb3fc261067ab65ddc0b2dca8e162f09442 (v17) and
counterparts in each other non-master branch. If released, that commit
would have caused a worst-in-years minor release regression, via
undetected LWLock self-deadlock. This commit and its self-deadlock fix
warrant more bake time in the master branch.
Reported by Alexander Lakhin.
Discussion: https://postgr.es/m/[email protected]
M src/backend/access/heap/heapam.c
M src/backend/access/transam/xact.c
M src/backend/catalog/index.c
M src/backend/replication/logical/decode.c
M src/backend/utils/cache/catcache.c
M src/backend/utils/cache/inval.c
M src/backend/utils/cache/syscache.c
M src/include/utils/catcache.h
M src/include/utils/inval.h
M src/test/isolation/expected/inplace-inval.out
M src/test/isolation/specs/inplace-inval.spec
Revert "WAL-log inplace update before revealing it to other sessions."
commit : 9a1c73636d608f12cc0545e21d0d964a5f7bf3de
author : Noah Misch <[email protected]>
date : Sat, 2 Nov 2024 09:04:59 -0700
committer: Noah Misch <[email protected]>
date : Sat, 2 Nov 2024 09:04:59 -0700
This reverts commit bfd5c6e279c8e1702eea882439dc7ebdf4d4b3a5 (v17) and
counterparts in each other non-master branch. This unblocks reverting a
commit on which it depends.
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/transam/xloginsert.c
doc: fix ALTER DOMAIN domain_constraint to spell out options
commit : b165e7106086a66fa621d5ed7d8f773da0f9d07d
author : Bruce Momjian <[email protected]>
date : Fri, 1 Nov 2024 13:54:27 -0400
committer: Bruce Momjian <[email protected]>
date : Fri, 1 Nov 2024 13:54:27 -0400
It used to refer to CREATE DOMAIN, but CREATE DOMAIN allows NULL, while
ALTER DOMAIN does not.
Reported-by: [email protected]
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 12
M doc/src/sgml/ref/alter_domain.sgml
doc: remove mention of ActiveState for Perl and Tcl on Windows
commit : 3a6e352f7994701a532c42e866ec5c1559932ca5
author : Bruce Momjian <[email protected]>
date : Fri, 1 Nov 2024 11:30:53 -0400
committer: Bruce Momjian <[email protected]>
date : Fri, 1 Nov 2024 11:30:53 -0400
Replace with Strawberry Perl and Magicsplat Tcl.
Reported-by: Yasir Hussain
Discussion: https://postgr.es/m/CAA9OW9fAAM_WDYYpAquqF6j1hmfRMzHPsFkRfP5E6oSfkF=dMA@mail.gmail.com
Backpatch-through: 12
M doc/src/sgml/install-windows.sgml
Unpin buffer before inplace update waits for an XID to end.
commit : 11e3f288f3dbda8b460aba93e1c18b55017e7b08
author : Noah Misch <[email protected]>
date : Tue, 29 Oct 2024 09:39:55 -0700
committer: Noah Misch <[email protected]>
date : Tue, 29 Oct 2024 09:39:55 -0700
Commit a07e03fd8fa7daf4d1356f7cb501ffe784ea6257 changed inplace updates
to wait for heap_update() commands like GRANT TABLE and GRANT DATABASE.
By keeping the pin during that wait, a sequence of autovacuum workers
and an uncommitted GRANT starved one foreground LockBufferForCleanup()
for six minutes, on buildfarm member sarus. Prevent, at the cost of a
bit of complexity. Back-patch to v12, like the earlier commit. That
commit and heap_inplace_lock() have not yet appeared in any release.
Discussion: https://postgr.es/m/[email protected]
M src/backend/access/heap/heapam.c
M src/backend/access/index/genam.c
M src/include/access/heapam.h
Update time zone data files to tzdata release 2024b.
commit : dedced73e00fc048ba9fbaa5a416b61aebcb42f9
author : Tom Lane <[email protected]>
date : Tue, 29 Oct 2024 11:49:38 -0400
committer: Tom Lane <[email protected]>
date : Tue, 29 Oct 2024 11:49:38 -0400
Historical corrections for Mexico, Mongolia, and Portugal.
Notably, Asia/Choibalsan is now an alias for Asia/Ulaanbaatar
rather than being a separate zone, mainly because the differences
between those zones were found to be based on untrustworthy data.
M src/timezone/data/tzdata.zi
M src/timezone/known_abbrevs.txt
M src/timezone/tznames/Default
M src/timezone/tznames/Europe.txt
doc: Add better description for rewrite functions in event triggers
commit : bca802600c7fe002b21991b119ec7d95ed3ebecb
author : Michael Paquier <[email protected]>
date : Tue, 29 Oct 2024 15:35:21 +0900
committer: Michael Paquier <[email protected]>
date : Tue, 29 Oct 2024 15:35:21 +0900
There are two functions that can be used in event triggers to get more
details about a rewrite happening on a relation. Both had a limited
documentation:
- pg_event_trigger_table_rewrite_reason() and
pg_event_trigger_table_rewrite_oid() were not mentioned in the main
event trigger section in the paragraph dedicated to the event
table_rewrite.
- pg_event_trigger_table_rewrite_reason() returns an integer which is a
bitmap of the reasons why a rewrite happens. There was no explanation
about the meaning of these values, forcing the reader to look at the
code to find out that these are defined in event_trigger.h.
While on it, let's add a comment in event_trigger.h where the
AT_REWRITE_* are defined, telling to update the documentation when
these values are changed.
Backpatch down to 13 as a consequence of 1ad23335f36b, where this area
of the documentation has been heavily reworked.
Author: Greg Sabino Mullane
Discussion: https://postgr.es/m/CAKAnmmL+Z6j-C8dAx1tVrnBmZJu+BSoc68WSg3sR+CVNjBCqbw@mail.gmail.com
Backpatch-through: 13
M doc/src/sgml/event-trigger.sgml
M doc/src/sgml/func.sgml
M src/include/commands/event_trigger.h
Doc: clarify enable_indexscan=off also disabled Index Only Scans
commit : ca643bcd7a8173dc902f3be748f62893ae0f9cc0
author : David Rowley <[email protected]>
date : Tue, 29 Oct 2024 16:25:51 +1300
committer: David Rowley <[email protected]>
date : Tue, 29 Oct 2024 16:25:51 +1300
Disabling enable_indexscan has always also disabled Index Only Scans.
Here we make that more clear in the documentation in an attempt to
prevent future complaints complaining about this expected behavior.
Reported-by: Melanie Plageman
Author: David G. Johnston, David Rowley
Backpatch-through: 12, oldest supported version
Discussion: https://postgr.es/m/CAAKRu_atV=kovgpaLREyG68PB5+ncKvJ2UNoeRetEgyC3Yb5Sw@mail.gmail.com
M doc/src/sgml/config.sgml
Guard against enormously long input in pg_saslprep().
commit : d130a64ee003bd6f272ad63f2721e204b443a582
author : Tom Lane <[email protected]>
date : Mon, 28 Oct 2024 14:33:55 -0400
committer: Tom Lane <[email protected]>
date : Mon, 28 Oct 2024 14:33:55 -0400
Coverity complained that pg_saslprep() could suffer integer overflow,
leading to under-allocation of the output buffer, if the input string
exceeds SIZE_MAX/4. This hazard seems largely hypothetical, but it's
easy enough to defend against, so let's do so.
This patch creates a third place in src/common/ where we are locally
defining MaxAllocSize so that we can test against that in the same way
in backend and frontend compiles. That seems like about two places
too many, so the next patch will move that into common/fe_memutils.h.
I'm hesitant to do that in back branches however.
Back-patch to v14. The code looks similar in older branches, but
before commit 67a472d71 there was a separate test on the input string
length that prevented this hazard.
Per Coverity report.
M src/common/saslprep.c
Fix overflow in bsearch_arg() with more than INT_MAX elements
commit : 55327256a049e3926d4d1cda39a7bb5886cbe03c
author : Heikki Linnakangas <[email protected]>
date : Mon, 28 Oct 2024 14:07:38 +0200
committer: Heikki Linnakangas <[email protected]>
date : Mon, 28 Oct 2024 14:07:38 +0200
This was introduced in commit bfa2cee784, which replaced the old
bsearch_cmp() function we had in extended_stats.c with the current
implementation. The original discussion or commit message of
bfa2cee784 didn't mention where the new implementation came from, but
based on some googling, I'm guessing *BSD or libiberty, all of which
share this same code, with or without this fix.
Author: Ranier Vilela
Reviewed-by: Nathan Bossart
Backpatch-through: 14
Discussion: https://www.postgresql.org/message-id/CAEudQAp34o_8u6sGSVraLwuMv9F7T9hyHpePXHmRaxR2Aboi%2Bw%40mail.gmail.com
M src/port/bsearch_arg.c
WAL-log inplace update before revealing it to other sessions.
commit : acf49584e2165ded5396d107961b568fe8f5f954
author : Noah Misch <[email protected]>
date : Fri, 25 Oct 2024 06:51:03 -0700
committer: Noah Misch <[email protected]>
date : Fri, 25 Oct 2024 06:51:03 -0700
A buffer lock won't stop a reader having already checked tuple
visibility. If a vac_update_datfrozenid() and then a crash happened
during inplace update of a relfrozenxid value, datfrozenxid could
overtake relfrozenxid. That could lead to "could not access status of
transaction" errors. Back-patch to v12 (all supported versions). In
v14 and earlier, this also back-patches the assertion removal from
commit 7fcf2faf9c7dd473208fd6d5565f88d7f733782b.
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/transam/xloginsert.c
For inplace update, send nontransactional invalidations.
commit : e3914bd136e467b3af7e5a334e0e753df2a13f53
author : Noah Misch <[email protected]>
date : Fri, 25 Oct 2024 06:51:02 -0700
committer: Noah Misch <[email protected]>
date : Fri, 25 Oct 2024 06:51:02 -0700
The inplace update survives ROLLBACK. The inval didn't, so another
backend's DDL could then update the row without incorporating the
inplace update. In the test this fixes, a mix of CREATE INDEX and ALTER
TABLE resulted in a table with an index, yet relhasindex=f. That is a
source of index corruption. Back-patch to v12 (all supported versions).
The back branch versions don't change WAL, because those branches just
added end-of-recovery SIResetAll(). All branches change the ABI of
extern function PrepareToInvalidateCacheTuple(). No PGXN extension
calls that, and there's no apparent use case in extensions.
Reviewed by Nitin Motiani and (in earlier versions) Andres Freund.
Discussion: https://postgr.es/m/[email protected]
M src/backend/access/heap/heapam.c
M src/backend/access/transam/xact.c
M src/backend/catalog/index.c
M src/backend/replication/logical/decode.c
M src/backend/utils/cache/catcache.c
M src/backend/utils/cache/inval.c
M src/backend/utils/cache/syscache.c
M src/include/utils/catcache.h
M src/include/utils/inval.h
M src/test/isolation/expected/inplace-inval.out
M src/test/isolation/specs/inplace-inval.spec
At end of recovery, reset all sinval-managed caches.
commit : dca68242a81b39672557b77c72ce15790bf0f7fe
author : Noah Misch <[email protected]>
date : Fri, 25 Oct 2024 06:51:06 -0700
committer: Noah Misch <[email protected]>
date : Fri, 25 Oct 2024 06:51:06 -0700
An inplace update's invalidation messages are part of its transaction's
commit record. However, the update survives even if its transaction
aborts or we stop recovery before replaying its transaction commit.
After recovery, a backend that started in recovery could update the row
without incorporating the inplace update. That could result in a table
with an index, yet relhasindex=f. That is a source of index corruption.
This bulk invalidation avoids the functional consequences. A future
change can fix the !RecoveryInProgress() scenario without changing the
WAL format. Back-patch to v17 - v12 (all supported versions). v18 will
instead add invalidations to WAL.
Discussion: https://postgr.es/m/[email protected]
M src/backend/access/transam/xlog.c
M src/backend/storage/ipc/sinvaladt.c
M src/include/storage/sinvaladt.h
Stop reading uninitialized memory in heap_inplace_lock().
commit : ad24b75659100df76bf998956c59481c4262b3ec
author : Noah Misch <[email protected]>
date : Thu, 24 Oct 2024 09:16:14 -0700
committer: Noah Misch <[email protected]>
date : Thu, 24 Oct 2024 09:16:14 -0700
Stop computing a never-used value. This removes the read; the read had
no functional implications. Back-patch to v12, like commit
a07e03fd8fa7daf4d1356f7cb501ffe784ea6257.
Reported by Alexander Lakhin.
Discussion: https://postgr.es/m/[email protected]
M src/backend/access/heap/heapam.c
M src/test/isolation/expected/intra-grant-inplace.out
M src/test/isolation/specs/intra-grant-inplace.spec
Remove unnecessary word in a comment
commit : c3316a3b8dccf4d9cd17d66f1984bf7d4ce38fa9
author : Amit Langote <[email protected]>
date : Wed, 23 Oct 2024 17:54:48 +0900
committer: Amit Langote <[email protected]>
date : Wed, 23 Oct 2024 17:54:48 +0900
Relations opened by the executor are only closed once in
ExecCloseRangeTableRelations(), so the word "again" in the comment
for ExecGetRangeTableRelation() is misleading and unnecessary.
Discussion: https://postgr.es/m/CA+HiwqHnw-zR+u060i3jp4ky5UR0CjByRFQz50oZ05de7wUg=Q@mail.gmail.com
Backpatch-through: 12
M src/backend/executor/execUtils.c
ecpg: Fix out-of-bound read in DecodeDateTime()
commit : 9a51d4af12a7add717f7f2e4b82985b3a7a092f4
author : Michael Paquier <[email protected]>
date : Wed, 23 Oct 2024 08:35:05 +0900
committer: Michael Paquier <[email protected]>
date : Wed, 23 Oct 2024 08:35:05 +0900
It was possible for the code to read out-of-bound data from the
"day_tab" table with some crafted input data. Let's treat these as
invalid input as the month number is incorrect.
A test is added to test this case with a check on the errno returned by
the decoding routine. A test close to the new one added in this commit
was testing for a failure, but did not look at the errno generated, so
let's use this commit to also change it, adding a check on the errno
returned by DecodeDateTime().
Like the other test scripts, dt_test should likely be expanded to
include more checks based on the errnos generated in these code paths.
This is left as future work.
This issue exists since 2e6f97560a83, so backpatch all the way down.
Reported-by: Pavel Nekrasov
Author: Bruce Momjian, Pavel Nekrasov
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 12
M src/interfaces/ecpg/pgtypeslib/dt_common.c
M src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
M src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr
M src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stdout
M src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
Restructure foreign key handling code for ATTACH/DETACH
commit : 46a8c27a72269dcd631d30adc1f76cbee50bf969
author : Álvaro Herrera <[email protected]>
date : Tue, 22 Oct 2024 16:01:18 +0200
committer: Álvaro Herrera <[email protected]>
date : Tue, 22 Oct 2024 16:01:18 +0200
... to fix bugs when the referenced table is partitioned.
The catalog representation we chose for foreign keys connecting
partitioned tables (in commit f56f8f8da6af) is inconvenient, in the
sense that a standalone table has a different way to represent the
constraint when referencing a partitioned table, than when the same
table becomes a partition (and vice versa). Because of this, we need to
create additional catalog rows on detach (pg_constraint and pg_trigger),
and remove them on attach. We were doing some of those things, but not
all of them, leading to missing catalog rows in certain cases.
The worst problem seems to be that we are missing action triggers after
detaching a partition, which means that you could update/delete rows
from the referenced partitioned table that still had referencing rows on
that table, the server failing to throw the required errors.
!!!
Note that this means existing databases with FKs that reference
partitioned tables might have rows that break relational integrity, on
tables that were once partitions on the referencing side of the FK.
Another possible problem is that trying to reattach a table
that had been detached would fail indicating that internal triggers
cannot be found, which from the user's point of view is nonsensical.
In branches 15 and above, we fix this by creating a new helper function
addFkConstraint() which is in charge of creating a standalone
pg_constraint row, and repurposing addFkRecurseReferencing() and
addFkRecurseReferenced() so that they're only the recursive routine for
each side of the FK, and they call addFkConstraint() to create
pg_constraint at each partitioning level and add the necessary triggers.
These new routines can be used during partition creation, partition
attach and detach, and foreign key creation. This reduces redundant
code and simplifies the flow.
In branches 14 and 13, we have a much simpler fix that consists on
simply removing the constraint on detach. The reason is that those
branches are missing commit f4566345cf40, which reworked the way this
works in a way that we didn't consider back-patchable at the time.
We opted to leave branch 12 alone, because it's different from branch 13
enough that the fix doesn't apply; and because it is going in EOL mode
very soon, patching it now might be worse since there's no way to undo
the damage if it goes wrong.
Existing databases might need to be repaired.
In the future we might want to rethink the catalog representation to
avoid this problem, but for now the code seems to do what's required to
make the constraints operate correctly.
Co-authored-by: Jehan-Guillaume de Rorthais <[email protected]>
Co-authored-by: Tender Wang <[email protected]>
Co-authored-by: Alvaro Herrera <[email protected]>
Reported-by: Guillaume Lelarge <[email protected]>
Reported-by: Jehan-Guillaume de Rorthais <[email protected]>
Reported-by: Thomas Baehler (SBB CFF FFS) <[email protected]>
Discussion: https://postgr.es/m/20230420144344.40744130@karst
Discussion: https://postgr.es/m/20230705233028.2f554f73@karst
Discussion: https://postgr.es/m/GVAP278MB02787E7134FD691861635A8BC9032@GVAP278MB0278.CHEP278.PROD.OUTLOOK.COM
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
Fix wrong assertion and poor error messages in "COPY (query) TO".
commit : 5e94f616c8321a2e95986a236c10dfa26a3a844a
author : Tom Lane <[email protected]>
date : Mon, 21 Oct 2024 15:08:22 -0400
committer: Tom Lane <[email protected]>
date : Mon, 21 Oct 2024 15:08:22 -0400
If the query is rewritten into a NOTIFY command by a DO INSTEAD
rule, we'd get an assertion failure, or in non-assert builds
issue a rather confusing error message. Improve that.
Also fix a longstanding grammar mistake in a nearby error message.
Per bug #18664 from Alexander Lakhin. Back-patch to all supported
branches.
Tender Wang and Tom Lane
Discussion: https://postgr.es/m/[email protected]
M src/backend/commands/copyto.c
M src/test/regress/expected/copydml.out
M src/test/regress/sql/copydml.sql
Fix race condition in committing a serializable transaction
commit : 520ec2474b392805ca4d7f29205e245ac70ea0e1
author : Heikki Linnakangas <[email protected]>
date : Mon, 21 Oct 2024 09:49:21 +0300
committer: Heikki Linnakangas <[email protected]>
date : Mon, 21 Oct 2024 09:49:21 +0300
The finished transaction list can contain XIDs that are older than the
serializable global xmin. It's a short-lived state;
ClearOldPredicateLocks() removes any such transactions from the list,
and it's called whenever the global xmin advances. But if another
backend calls SummarizeOldestCommittedSxact() in that window, it will
call SerialAdd() on an XID that's older than the global xmin, or if
there are no more transactions running, when global xmin is
invalid. That trips the assertion in SerialAdd().
Fixes bug #18658 reported by Andrew Bille. Thanks to Alexander Lakhin
for analysis. Backpatch to all versions.
Discussion: https://www.postgresql.org/message-id/18658-7dab125ec688c70b%40postgresql.org
M src/backend/storage/lmgr/predicate.c
Note that index_name in ALTER INDEX ATTACH PARTITION can be schema-qualified
commit : fbbcbdef23349a81efad2bf742c94e2dc6c28130
author : Álvaro Herrera <[email protected]>
date : Sun, 20 Oct 2024 15:36:20 +0200
committer: Álvaro Herrera <[email protected]>
date : Sun, 20 Oct 2024 15:36:20 +0200
Missed in 8b08f7d4820f; backpatch to all supported branches.
Reported-by: [email protected]
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/[email protected]
M doc/src/sgml/ref/alter_index.sgml
Fix extreme skew detection in Parallel Hash Join.
commit : 20d94899414ac12634152050d5cd4b676fad22d3
author : Thomas Munro <[email protected]>
date : Thu, 17 Oct 2024 15:52:24 +1300
committer: Thomas Munro <[email protected]>
date : Thu, 17 Oct 2024 15:52:24 +1300
After repartitioning the inner side of a hash join that would have
exceeded the allowed size, we check if all the tuples from a parent
partition moved to one child partition. That is evidence that it
contains duplicate keys and later attempts to repartition will also
fail, so we should give up trying to limit memory (for lack of a better
fallback strategy).
A thinko prevented the check from working correctly in partition 0 (the
one that is partially loaded into memory already). After
repartitioning, we should check for extreme skew if the *parent*
partition's space_exhausted flag was set, not the child partition's.
The consequence was repeated futile repartitioning until per-partition
data exceeded various limits including "ERROR: invalid DSA memory alloc
request size 1811939328", OS allocation failure, or temporary disk space
errors. (We could also do something about some of those symptoms, but
that's material for separate patches.)
This problem only became likely when PostgreSQL 16 introduced support
for Parallel Hash Right/Full Join, allowing NULL keys into the hash
table. Repartitioning always leaves NULL in partition 0, no matter how
many times you do it, because the hash value is all zero bits. That's
unlikely for other hashed values, but they might still have caused
wasted extra effort before giving up.
Back-patch to all supported releases.
Reported-by: Craig Milhiser <[email protected]>
Reviewed-by: Andrei Lepikhov <[email protected]>
Discussion: https://postgr.es/m/CA%2BwnhO1OfgXbmXgC4fv_uu%3DOxcDQuHvfoQ4k0DFeB0Qqd-X-rQ%40mail.gmail.com
M src/backend/executor/nodeHash.c
Further refine _SPI_execute_plan's rule for atomic execution.
commit : ab13c46ff4314b3d399b5f5c2e72895f7f4b590a
author : Tom Lane <[email protected]>
date : Wed, 16 Oct 2024 17:36:30 -0400
committer: Tom Lane <[email protected]>
date : Wed, 16 Oct 2024 17:36:30 -0400
Commit 2dc1deaea turns out to have been still a brick shy of a load,
because CALL statements executing within a plpgsql exception block
could still pass the wrong snapshot to stable functions within the
CALL's argument list. That happened because standard_ProcessUtility
forces isAtomicContext to true if IsTransactionBlock is true, which
it always will be inside a subtransaction. Then ExecuteCallStmt
would think it does not need to push a new snapshot --- but
_SPI_execute_plan didn't do so either, since it thought it was in
nonatomic mode.
The best fix for this seems to be for _SPI_execute_plan to operate
in atomic execution mode if IsSubTransaction() is true, even when the
SPI context as a whole is non-atomic. This makes _SPI_execute_plan
have the same rules about when non-atomic execution is allowed as
_SPI_commit/_SPI_rollback have about when COMMIT/ROLLBACK are allowed,
which seems appropriately symmetric. (If anyone ever tries to allow
COMMIT/ROLLBACK inside a subtransaction, this would all need to be
rethought ... but I'm unconvinced that such a thing could be logically
consistent at all.)
For further consistency, also check IsSubTransaction() in
SPI_inside_nonatomic_context. That does not matter for its
one present-day caller StartTransaction, which can't be reached
inside a subtransaction. But if any other callers ever arise,
they'd presumably want this definition.
Per bug #18656 from Alexander Alehin. Back-patch to all
supported branches, like previous fixes in this area.
Discussion: https://postgr.es/m/[email protected]
M src/backend/executor/spi.c
M src/pl/plpgsql/src/expected/plpgsql_call.out
M src/pl/plpgsql/src/sql/plpgsql_call.sql
Reduce memory block size for decoded tuple storage to 8kB.
commit : 5c1ed0a516813b588e9b2ddf042f1eda0bbabec6
author : Masahiko Sawada <[email protected]>
date : Wed, 16 Oct 2024 12:07:55 -0700
committer: Masahiko Sawada <[email protected]>
date : Wed, 16 Oct 2024 12:07:55 -0700
Commit a4ccc1cef introduced the Generation Context and modified the
logical decoding process to use a Generation Context with a fixed
block size of 8MB for storing tuple data decoded during logical
decoding (i.e., rb->tup_context). Several reports have indicated that
the logical decoding process can be terminated due to
out-of-memory (OOM) situations caused by excessive memory usage in
rb->tup_context.
This issue can occur when decoding a workload involving several
concurrent transactions, including a long-running transaction that
modifies tuples. By design, the Generation Context does not free a
memory block until all chunks within that block are
released. Consequently, if tuples modified by the long-running
transaction are stored across multiple memory blocks, these blocks
remain allocated until the long-running transaction completes, leading
to substantial memory fragmentation. The memory usage during logical
decoding, tracked by rb->size, does not account for memory
fragmentation, resulting in potentially much higher memory consumption
than the value of the logical_decoding_work_mem parameter.
Various improvement strategies were discussed in the relevant
thread. This change reduces the block size of the Generation Context
used in rb->tup_context from 8MB to 8kB. This modification
significantly decreases the likelihood of substantial memory
fragmentation occurring and is relatively straightforward to
backport. Performance testing across multiple platforms has confirmed
that this change will not introduce any performance degradation that
would impact actual operation.
Backport to all supported branches.
Reported-by: Alex Richman, Michael Guissine, Avi Weinberg
Reviewed-by: Amit Kapila, Fujii Masao, David Rowley
Tested-by: Hayato Kuroda, Shlok Kyal
Discussion: https://postgr.es/m/CAD21AoBTY1LATZUmvSXEssvq07qDZufV4AF-OHh9VD2pC0VY2A%40mail.gmail.com
Backpatch-through: 12
M src/backend/replication/logical/reorderbuffer.c
Correctly identify which EC members are computable at a plan node.
commit : 4ca708eb3588d36a714f0e40f6cc49f63dfe25cb
author : Tom Lane <[email protected]>
date : Sat, 12 Oct 2024 14:56:08 -0400
committer: Tom Lane <[email protected]>
date : Sat, 12 Oct 2024 14:56:08 -0400
find_computable_ec_member() had the wrong mental model of what
its primary caller prepare_sort_from_pathkeys() would do with
the selected EquivalenceClass member expression. We will not
compute the EC expression in a plan node atop the one returning
the passed-in targetlist; rather, the EC expression will be
computed as an additional column of that targetlist. So any
Var or quasi-Var used in the given tlist is also available to the
EC expression. In simple cases this makes no difference because
the given tlist is just a list of Vars or quasi-Vars --- but if
we are considering an appendrel member produced by flattening
a UNION ALL, the tlist may contain expressions, resulting in
failure to match and a "could not find pathkey item to sort"
error.
To fix, we can flatten both the tlist and the EC members with
pull_var_clause(), and then just check for subset-ness, so
that the code is actually shorter than before.
While this bug is quite old, the present patch only works back to
v13. We could possibly make it work in v12 by back-patching parts
of 375398244. On the whole though I don't like the risk/reward
ratio of that idea. v12's final release is next month, meaning
there would be no chance to correct matters if the patch causes a
regression. Since this failure has escaped notice for 14 years,
it's likely nobody will hit it in the field with v12.
Per bug #18652 from Alexander Lakhin.
Andrei Lepikhov and Tom Lane
Discussion: https://postgr.es/m/[email protected]
M src/backend/optimizer/path/equivclass.c
M src/test/regress/expected/inherit.out
M src/test/regress/sql/inherit.sql
Remove incorrect function import from pgindent
commit : 4a75ff7afb4db0283cac79bff546369462890063
author : Daniel Gustafsson <[email protected]>
date : Wed, 9 Oct 2024 09:34:34 +0200
committer: Daniel Gustafsson <[email protected]>
date : Wed, 9 Oct 2024 09:34:34 +0200
Commit 149ac7d4559 which re-implemented pgindent in Perl explicitly
imported the devnull function from File::Spec, but the module does
not export anything. In recent versions of Perl calling a missing
import function cause a warning, which combined with warnings being
fatal cause pgindent to error out.
Backpatch to all supported versions.
Author: Erik Wienhold <[email protected]>
Reviewed-by: Andrew Dunstan <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Discusson: https://postgr.es/m/[email protected]
Backpatch-through: v12
M src/tools/pgindent/pgindent
Stabilize the test added by commit 022564f60c.
commit : 581092c9079f78194a4cff757de891fb2027de95
author : Amit Kapila <[email protected]>
date : Tue, 8 Oct 2024 11:01:53 +0530
committer: Amit Kapila <[email protected]>
date : Tue, 8 Oct 2024 11:01:53 +0530
The test was unstable in branches 14 and 15 as we were relying on the
number of changes in the table having a toast column to start streaming.
On branches >= 16, we have a GUC debug_logical_replication_streaming which
can stream each change, so the test was stable in those branches.
Change the test to use PREPARE TRANSACTION as that should make the result
consistent and test the code changed in 022564f60c.
Reported-by: Daniel Gustafsson as per buildfarm
Author: Hou Zhijie, Amit Kapila
Backpatch-through: 14
Discussion: https://postgr.es/m/[email protected]
M contrib/test_decoding/expected/stream.out
M contrib/test_decoding/expected/twophase.out
M contrib/test_decoding/sql/stream.sql
M contrib/test_decoding/sql/twophase.sql
vacuumdb: Schema-qualify operator in catalog query's WHERE clause.
commit : ce6f27857bba9e380a10365abf798dfbf453cc31
author : Nathan Bossart <[email protected]>
date : Mon, 7 Oct 2024 16:49:20 -0500
committer: Nathan Bossart <[email protected]>
date : Mon, 7 Oct 2024 16:49:20 -0500
Commit 1ab67c9dfa, which modified this catalog query so that it
doesn't return temporary relations, forgot to schema-qualify the
operator. A comment earlier in the function implores us to fully
qualify everything in the query:
* Since we execute the constructed query with the default search_path
* (which could be unsafe), everything in this query MUST be fully
* qualified.
This commit fixes that. While at it, add a newline for consistency
with surrounding code.
Reviewed-by: Noah Misch
Discussion: https://postgr.es/m/ZwQJYcuPPUsF0reU%40nathan
Backpatch-through: 12
M src/bin/scripts/vacuumdb.c
Fix Y2038 issues with MyStartTime.
commit : 5cea7168dfe622fe2e474bdfae59f966aad53ce3
author : Nathan Bossart <[email protected]>
date : Mon, 7 Oct 2024 13:51:03 -0500
committer: Nathan Bossart <[email protected]>
date : Mon, 7 Oct 2024 13:51:03 -0500
Several places treat MyStartTime as a "long", which is only 32 bits
wide on some platforms. In reality, MyStartTime is a pg_time_t,
i.e., a signed 64-bit integer. This will lead to interesting bugs
on the aforementioned systems in 2038 when signed 32-bit integers
are no longer sufficient to store Unix time (e.g., "pg_ctl start"
hanging). To fix, ensure that MyStartTime is handled as a 64-bit
value everywhere. (Of course, users will need to ensure that
time_t is 64 bits wide on their system, too.)
Co-authored-by: Max Johnson
Discussion: https://postgr.es/m/CO1PR07MB905262E8AC270FAAACED66008D682%40CO1PR07MB9052.namprd07.prod.outlook.com
Backpatch-through: 12
M src/backend/utils/error/elog.c
M src/backend/utils/init/miscinit.c
M src/bin/pg_ctl/pg_ctl.c
Fix fetching default toast value during decoding of in-progress transactions.
commit : efe706e273cec0ec83b4d72190fed6b000bd11fd
author : Amit Kapila <[email protected]>
date : Mon, 7 Oct 2024 14:45:39 +0530
committer: Amit Kapila <[email protected]>
date : Mon, 7 Oct 2024 14:45:39 +0530
During logical decoding of in-progress transactions, we perform the toast
table scan while fetching the default toast value for an attribute. We
forgot to initialize the flag during this scan to indicate that the system
table scan is in progress. We need this flag to ensure that during logical
decoding we never directly access the tableam or heap APIs because we check
for concurrent aborts only in systable_* APIs.
Reported-by: Alexander Lakhin
Author: Takeshi Ideriha, Hou Zhijie
Reviewed-by: Amit Kapila, Hou Zhijie
Backpatch-through: 14
Discussion: https://postgr.es/m/[email protected]
M contrib/test_decoding/expected/stream.out
M contrib/test_decoding/sql/stream.sql
M src/backend/access/index/genam.c
Ignore not-yet-defined Portals in pg_cursors view.
commit : 3922c9e9f3de7fee04249c9d65be172432b878cf
author : Tom Lane <[email protected]>
date : Sun, 6 Oct 2024 16:03:48 -0400
committer: Tom Lane <[email protected]>
date : Sun, 6 Oct 2024 16:03:48 -0400
pg_cursor() supposed that any Portal it finds in the hash table must
have sourceText set up, but there's an edge case where that is not so.
A newly-created Portal has sourceText = NULL, and that doesn't change
until PortalDefineQuery is called. In SPI_cursor_open_internal,
we perform GetCachedPlan between CreatePortal and PortalDefineQuery,
and it's possible for user-defined code to execute during that
planning and cause a fetch from the pg_cursors view, resulting in a
null-pointer-dereference crash. (It looks like the same could happen
in exec_bind_message, but I've not tried to provoke a failure there.)
I considered trying to fix this by setting sourceText sooner, but
there may be instances of this same calling pattern in extensions,
and we couldn't be sure they'd get the memo promptly. It seems
better to redefine pg_cursor as not showing Portals that have
not yet had PortalDefineQuery called on them, which we can do by
just skipping them if sourceText is still NULL.
(Before a1c692358, pg_cursor would instead return a row with NULL
in the statement column. We could revert to that behavior but it
doesn't really seem like a better definition, especially since our
documentation doesn't suggest that the column could be NULL.)
Per report from PetSerAl. Back-patch to all supported branches.
Discussion: https://postgr.es/m/CAKygsHTBXLXjwV43kpZa+Cs+XTiaeeJiZdL4cPBm9f4MTdw7wg@mail.gmail.com
M src/backend/utils/mmgr/portalmem.c
Parse libpq's "keepalives" option more like other integer options.
commit : e7af9b52f67998f72f3d57f506e235f3cda151cb
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
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
Fix race condition in COMMIT PREPARED causing orphaned 2PC files
commit : 5f15107875f232f80baf7bee516e3a905fe35b06
author : Michael Paquier <[email protected]>
date : Tue, 1 Oct 2024 15:44:12 +0900
committer: Michael Paquier <[email protected]>
date : Tue, 1 Oct 2024 15:44:12 +0900
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 : ec33fdcb06dcabc304d11f8856088ecc00571435
author : Tatsuo Ishii <[email protected]>
date : Tue, 1 Oct 2024 11:38:17 +0900
committer: Tatsuo Ishii <[email protected]>
date : Tue, 1 Oct 2024 11:38:17 +0900
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/ref/drop_extension.sgml
reindexdb: Skip reindexing temporary tables and indexes.
commit : 88e1153cb3c668f06ac24fdccd5fab7ec9413097
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
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
Remove NULL dereference from RenameRelationInternal().
commit : b9ee1339bfbe078ee04468dfce2820248061155b
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
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
Avoid 037_invalid_database.pl hang under debug_discard_caches.
commit : 0c827fbdb81ad873921c3fae4d973151d8a00785
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
Back-patch to v12 (all supported versions).
M src/test/recovery/t/037_invalid_database.pl
Fix incorrect memory access in VACUUM FULL with invalid toast indexes
commit : 6530b869c30212f56670a891c9ac73bf08fdaf38
author : Michael Paquier <[email protected]>
date : Fri, 27 Sep 2024 09:40:19 +0900
committer: Michael Paquier <[email protected]>
date : Fri, 27 Sep 2024 09:40:19 +0900
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
tests: Restrict pg_locks queries in advisory_locks.sql to current database
commit : e750e413325e7e2d1979efd82c212e3a91025435
author : Andres Freund <[email protected]>
date : Wed, 5 Oct 2022 10:44:38 -0700
committer: Michael Paquier <[email protected]>
date : Wed, 5 Oct 2022 10:44:38 -0700
Otherwise testing an existing installation can fail, if there are other locks,
e.g. from one of the isolation tests.
This was originally applied as c3315a7da57b in 16~, but it is possible
to see this test fail depending on the concurrent activity for older
active branches.
Reviewed-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 12
M src/test/regress/expected/advisory_lock.out
M src/test/regress/sql/advisory_lock.sql
vacuumdb: Skip temporary tables in query to build list of relations
commit : 60c618216ddbfcd65fc6c8078c1dbb775643662b
author : Michael Paquier <[email protected]>
date : Wed, 25 Sep 2024 14:44:57 +0900
committer: Michael Paquier <[email protected]>
date : Wed, 25 Sep 2024 14:44:57 +0900
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
For inplace update durability, make heap_update() callers wait.
commit : f51b34b3eddbc501063f7b8ac470d26ce4e18a48
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
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/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 : 82c2d9e0220666ff698c226db41cb119ed4bfa44
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
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/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
Warn if LOCKTAG_TUPLE is held at commit, under debug_assertions.
commit : c9de1b8ac8df344ea08316f2f7edd86b912d6b1c
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
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
Drop global objects after completed test
commit : 988ddbef978bb2f247f0e021a28527e3776d6906
author : Daniel Gustafsson <[email protected]>
date : Wed, 3 Apr 2024 13:33:25 +0200
committer: Michael Paquier <[email protected]>
date : Wed, 3 Apr 2024 13:33:25 +0200
Project policy is to not leave global objects behind after a regress
test run. This was found as a result of the development of a patch
to make pg_regress detect such leftovers automatically, which in the
end was withdrawn due to issues with parallel runs.
This was originally committed as 936e3fa3787a, but the issue also exists
in the 12~16 range.
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 12
M src/test/modules/test_pg_dump/expected/test_pg_dump.out
M src/test/modules/test_pg_dump/sql/test_pg_dump.sql
Doc: explain how to test ADMIN privilege with pg_has_role().
commit : cf9f6b4688626e8d0682f96879325019d39c9794
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
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
doc PG relnotes: remove warning about commit links in PDF build
commit : 6aed7c49ce173386edbe62d178218de6c9fbac42
author : Bruce Momjian <[email protected]>
date : Thu, 19 Sep 2024 18:05:21 -0400
committer: Bruce Momjian <[email protected]>
date : Thu, 19 Sep 2024 18:05:21 -0400
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 : 6c5d9b3f53510f710e62f175a822c96617a724db
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
Backpatch-through: 12
M doc/src/sgml/stylesheet-fo.xsl
doc PG relnotes: rename commit link paragraph for clarity
commit : 460c298b6dbe189acfc289fef0e0158c6dd5a6ab
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
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
Improve Perl script which adds commit links to release notes
commit : 211684380aee4c99a71fb6775883a598e284daea
author : Bruce Momjian <[email protected]>
date : Thu, 19 Sep 2024 08:45:32 -0400
committer: Bruce Momjian <[email protected]>
date : Thu, 19 Sep 2024 08:45:32 -0400
Reported-by: Andrew Dunstan
Discussion: https://postgr.es/m/[email protected]
Author: Andrew Dunstan
Backpatch-through: 12
M src/tools/add_commit_links.pl
doc PG relnotes: add paragraph explaining the section symbol
commit : 4c9f9a84bb149a9460d6ab507a1c5bf9dac3ec86
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
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
doc PG relnotes: no relnote footnotes for commit links in PDF
commit : 0d530cfd5a77b8b780af3c2003e5ffc8e6b4b43a
author : Bruce Momjian <[email protected]>
date : Wed, 18 Sep 2024 16:34:51 -0400
committer: Bruce Momjian <[email protected]>
date : Wed, 18 Sep 2024 16:34:51 -0400
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
Don't enter parallel mode when holding interrupts.
commit : 5c698e8987dbaf1d5079f451f1379abed3725c0c
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
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 : b36ee879c54cf42f21c9374aceb5baf65efecbc3
author : Michael Paquier <[email protected]>
date : Wed, 18 Sep 2024 09:59:26 +0900
committer: Michael Paquier <[email protected]>
date : Wed, 18 Sep 2024 09:59:26 +0900
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 src/backend/executor/execMain.c
M src/backend/tcop/postgres.c
doc PG relnotes: fix SGML markup for new commit links
commit : 46d277307fbeec2939e44f97d8ca01bc7b7e92b0
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
Backpatch-through: 12
M doc/src/sgml/postgres.sgml
doc PG relnotes: add links to commits
commit : e1f0b541a9c551fc42e30d0af1eb3032998c90eb
author : Bruce Momjian <[email protected]>
date : Mon, 16 Sep 2024 14:14:37 -0400
committer: Bruce Momjian <[email protected]>
date : Mon, 16 Sep 2024 14:14:37 -0400
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 12
M doc/src/sgml/release-14.sgml
scripts: add Perl script to add links to release notes
commit : a499f79fd01c74ec949c927fa656d689733a7c0e
author : Bruce Momjian <[email protected]>
date : Mon, 16 Sep 2024 13:26:36 -0400
committer: Bruce Momjian <[email protected]>
date : Mon, 16 Sep 2024 13:26:36 -0400
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
Replace usages of xmlXPathCompile() with xmlXPathCtxtCompile().
commit : 7721fff06cc52a1208d628310ce40c3698baa2cb
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
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
doc PG relnotes: add attribution for time zone data files items
commit : cc6d5bd91e9dbaeccf93f2c78de24ed80868a682
author : Bruce Momjian <[email protected]>
date : Sat, 14 Sep 2024 19:51:54 -0400
committer: Bruce Momjian <[email protected]>
date : Sat, 14 Sep 2024 19:51:54 -0400
This is needed for a future script to add commit links; specifically we
need the closing parentheses of the attribution.
Backpatch-through: 12
M doc/src/sgml/release-14.sgml
Run regression tests with timezone America/Los_Angeles.
commit : b27622c90869aab63cfe22159a459c57768b0fa4
author : Tom Lane <[email protected]>
date : Sat, 14 Sep 2024 17:55:03 -0400
committer: Tom Lane <[email protected]>
date : Sat, 14 Sep 2024 17:55:03 -0400
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/horology.sql
M src/test/regress/sql/timestamptz.sql
Only define NO_THREAD_SAFE_LOCALE for MSVC plperl when required
commit : 9f77494647ded10c5ffd67cea92abcfdaea7dddd
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
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 src/tools/msvc/Mkvcbuild.pm
Allow _h_indexbuild() to be interrupted.
commit : b49013f2e86ad2cf01953f79992574e7ec2cdf02
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
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
Fix contrib/pageinspect's test for sequences.
commit : 0970889e352ccef7d1b5f32855b3db02a9946e90
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
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
Reintroduce support for sequences in pgstattuple and pageinspect.
commit : 8a94af8a2d0f91ba9dbfb41a0c205e60afa509b2
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
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
Remove incorrect Assert.
commit : 14bb709b27fe3a3befc5d91358a8a9177155c00a
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
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
Fix waits of REINDEX CONCURRENTLY for indexes with predicates or expressions
commit : 9021515488dd8f2dc43b7eaca127e113346f0449
author : Michael Paquier <[email protected]>
date : Mon, 9 Sep 2024 13:50:16 +0900
committer: Michael Paquier <[email protected]>
date : Mon, 9 Sep 2024 13:50:16 +0900
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
Stabilize 039_end_of_wal test.
commit : 2534cd999e673b4e4a3c52233bbee5496a3c4b06
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
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 : 44ad6523ed08d866914e548e4c4dc847ba3e1e76
author : Masahiko Sawada <[email protected]>
date : Fri, 30 Aug 2024 15:06:00 -0700
committer: Masahiko Sawada <[email protected]>
date : Fri, 30 Aug 2024 15:06:00 -0700
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.c
Disallow USING clause when altering type of generated column
commit : ecd19a3cc1879118424ce730369dcfe3d7a41d75
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
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
Fix a couple of wait event descriptions.
commit : 6bc2bfc339ab44395fd0ef7a9bb30f8fdf205205
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
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 doc/src/sgml/monitoring.sgml
Document limit on the number of out-of-line values per table
commit : dda341b32c886ec707dac45a311dcf919b1f72a1
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
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
Avoid failure to open dropped detached partition
commit : 3ad4c8615a7616c0d3f6bf6fe9bdd22d43c95813
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
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
Explain dropdb can't use syscache because of TOAST
commit : 3acbe198e2ad0f7d790d04f87c662ee26738536a
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
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 : 8cea8c023edfc8ab8eadd4e68a9686727f494aaf
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
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 : f1707c5f4f647e58ba299af3750d24f6d3b00cd6
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
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 DROP DATABASE for databases with many ACLs
commit : b3bb1e24b62c664dae694bfae6b409ac2b0aad3d
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
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
docs: fix incorrect plpgsql error message
commit : 45c3bd1131c50c11187cadac44f2d5071df4835c
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
Change "$1" to "username".
Reported-by: [email protected]
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 12
M doc/src/sgml/plpgsql.sgml
Fix creation of partition descriptor during concurrent detach+drop
commit : 1b4bdf915861e9c7ba5a9223c55d5ac0eccccdb1
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
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
Suppress Coverity warnings about Asserts in get_name_for_var_field.
commit : bc5446a2189309460e14191771817954e17e12ff
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
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 : 546a26b3d8df771624163e7338f281ff8313a8b9
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
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/include/utils/guc.h
M src/test/regress/expected/select_parallel.out
M src/test/regress/sql/select_parallel.sql
doc: Fix name of CRC algorithm in "Reliability" section.
commit : b07a9ee36e57281efcd22bbca2bfd486c2037aa7
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
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 : 120dd033761dbd70ad6267ff7255430bc8a989ed
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
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
Refuse ATTACH of a table referenced by a foreign key
commit : e97121d90e91032e9ff5d963202e835c96f298dd
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
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
Fix pg_rewind debug output to print the source timeline history
commit : bb5592caceded690451869ac098b55dbb2142dfc
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
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
Revert ECPG's use of pnstrdup()
commit : 3557185538fe7b2e2a04b52a5ed8250597cd0a2d
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
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
Teach RPM the package name provided in Perl alias packages.
commit : ecf7c48462396b98c50d32cc77ec5a024fefc34c
author : Noah Misch <[email protected]>
date : Wed, 7 Aug 2024 11:43:34 -0700
committer: Noah Misch <[email protected]>
date : Wed, 7 Aug 2024 11:43:34 -0700
When commit 1185be355462d1dc7e2950a7e52eb7ca0cb6f3c8 introduced
installation of a file containing "use PostgreSQL::Test::Utils", the RPM
Package Manager said "nothing provides perl(PostgreSQL::Test::Utils)".
Discussed on pgsql-packagers. Back-patch to v12, v13, and v14 only;
newer versions don't have the alias packages.
Reviewed by Andrew Dunstan, Tom Lane, and John Harvey. Reported by John
Harvey.
M src/test/perl/PostgreSQL/Test/Cluster.pm
M src/test/perl/PostgreSQL/Test/Utils.pm
Fix edge case in plpgsql's make_callstmt_target().
commit : 7f875fb5bd603d8640cc7aca2c79c604aacd3890
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
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
Make fallback MD5 implementation thread-safe on big-endian systems
commit : 7696b2ea52416cc2f4046a359d3b6f760e4c013d
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
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