Michael Paquier [Tue, 3 Sep 2024 23:56:28 +0000 (08:56 +0900)]
Avoid installcheck failure in TAP tests using injection_points
These tests depend on the test module injection_points to be installed,
but it may not be available as the contents of src/test/modules/ are not
installed by default.
This commit adds a workaround based on a scan of pg_available_extensions
to check if the extension is available, skipping the test if it is not.
This allows installcheck to work transparently.
There are more tests impacted by this problem on HEAD, but for now this
addresses only the tests that exist on HEAD and v17 as the release is
close by.
Reported-by: Maxim Orlov
Discussion: https://postgr.es/m/CACG=ezZkoT-pFz6a9XnyToiuR-Wg8fGELqHLoyBodr+2h-77qA@mail.gmail.com
Backpatch-through: 17
Michael Paquier [Tue, 3 Sep 2024 23:05:56 +0000 (08:05 +0900)]
Simplify makefiles exporting twice enable_injection_points
This is confusing, as it exports twice the same variable. Oversight in
6782709df81f that has spread in more places afterwards.
Reported-by: Alvaro Herrera, Tom Lane
Discussion: https://postgr.es/m/
202408201630[email protected]
Backpatch-through: 17
Tom Lane [Mon, 2 Sep 2024 20:11:07 +0000 (16:11 -0400)]
Stamp 17rc1.
Peter Eisentraut [Mon, 2 Sep 2024 16:03:47 +0000 (18:03 +0200)]
Fix warnings from msgfmt
/usr/bin/msgfmt: po/fr.po: warning: PO file header fuzzy
warning: older versions of msgfmt will give an error on this
Apparently, not all versions of msgfmt produce this. Quick fix for
now, more to be researched later.
Peter Eisentraut [Mon, 2 Sep 2024 15:40:32 +0000 (17:40 +0200)]
Fix rarely-run test for message wording change
fixup for
2e6a8047f0
Reported-by: Nazir Bilal Yavuz
Peter Eisentraut [Mon, 2 Sep 2024 10:02:42 +0000 (12:02 +0200)]
Translation updates
Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash:
d0110df9f34c2d32cb2652d4477c3135dabe84f7
Thomas Munro [Sat, 31 Aug 2024 05:27:38 +0000 (17:27 +1200)]
Fix unfairness in all-cached parallel seq scan.
Commit
b5a9b18c introduced block streaming infrastructure with a special
fast path for all-cached scans, and commit
b7b0f3f2 connected the
infrastructure up to sequential scans. One of the fast path
micro-optimizations had an unintended consequence: it interfered with
parallel sequential scan's block range allocator (from commit
56788d21),
which has its own ramp-up and ramp-down algorithm when handing out
groups of pages to workers. A scan of an all-cached table could give
extra blocks to one worker, when others had finished. In some plans
(probably already very bad plans, such as the one reported by
Alexander), the unfairness could be magnified.
An internal buffer of 16 block numbers is removed, keeping just a single
block buffer for technical reasons.
Back-patch to 17.
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/
63a63690-dd92-c809-0b47-
af05459e95d1%40gmail.com
Thomas Munro [Sat, 31 Aug 2024 02:32:08 +0000 (14:32 +1200)]
Stabilize 039_end_of_wal test.
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
Reported-by: Nathan Bossart
Reviewed-by: Tom Lane
Reviewed-by: Nathan Bossart
Discussion: https://postgr.es/m/
b26aeac2-cb6d-4633-a7ea-
945baae83dcf%40postgrespro.ru
Masahiko Sawada [Fri, 30 Aug 2024 22:06:07 +0000 (15:06 -0700)]
Clarify restrict_nonsystem_relation_kind description.
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
Tom Lane [Fri, 30 Aug 2024 20:47:39 +0000 (16:47 -0400)]
Make postgres_fdw's query_cancel test less flaky.
This test occasionally shows
+WARNING: could not get result of cancel request due to timeout
which appears to be because the cancel request is sometimes unluckily
sent to the remote session between queries, and then it's ignored.
This patch tries to make that less probable in three ways:
1. Use a test query that does not involve remote estimates, so that
no EXPLAINs are sent.
2. Make sure that the remote session is ready-to-go (transaction
started, SET commands sent) before we start the timer.
3. Increase the statement_timeout to 100ms, to give the local
session enough time to plan and issue the query.
We might have to go higher than 100ms to make this adequately
stable in the buildfarm, but let's see how it goes.
Back-patch to v17 where this test was introduced.
Jelte Fennema-Nio and Tom Lane
Discussion: https://postgr.es/m/578934.
1725045685@sss.pgh.pa.us
Tom Lane [Fri, 30 Aug 2024 16:42:13 +0000 (12:42 -0400)]
Avoid inserting PlaceHolderVars in cases where pre-v16 PG did not.
Commit
2489d76c4 removed some logic from pullup_replace_vars()
that avoided wrapping a PlaceHolderVar around a pulled-up
subquery output expression if the expression could be proven
to go to NULL anyway (because it contained Vars or PHVs of the
pulled-up relation and did not contain non-strict constructs).
But removing that logic turns out to cause performance regressions
in some cases, because the extra PHV blocks subexpression folding,
and will do so even if outer-join reduction later turns it into a
no-op with no phnullingrels bits. This can for example prevent
an expression from being matched to an index.
The reason for always adding a PHV was to ensure we had someplace
to put the varnullingrels marker bits of the Var being replaced.
However, it turns out we can optimize in exactly the same cases that
the previous code did, because we can instead attach the needed
varnullingrels bits to the contained Var(s)/PHV(s).
This is not a complete solution --- it would be even better if we
could remove PHVs after reducing them to no-ops. It doesn't look
practical to back-patch such an improvement, but this change seems
safe and at least gets rid of the performance-regression cases.
Per complaint from Nikhil Raj. Back-patch to v16 where the
problem appeared.
Discussion: https://postgr.es/m/CAG1ps1xvnTZceKK24OUfMKLPvDP2vjT-d+F2AOCWbw_v3KeEgg@mail.gmail.com
Peter Eisentraut [Fri, 30 Aug 2024 08:03:48 +0000 (10:03 +0200)]
Update list of acknowledgments in release notes
current through
df80b1d6cd
Peter Eisentraut [Fri, 30 Aug 2024 06:38:16 +0000 (08:38 +0200)]
Remove duplicate name from list of acknowledgments
Reported-by: [email protected]
Peter Eisentraut [Fri, 30 Aug 2024 06:34:39 +0000 (08:34 +0200)]
Correct name in list of acknowledgments
Reported-by: Etsuro Fujita
Tom Lane [Thu, 29 Aug 2024 17:24:17 +0000 (13:24 -0400)]
Fix mis-deparsing of ORDER BY lists when there is a name conflict.
If an ORDER BY item in SELECT is a bare identifier, the parser
first seeks it as an output column name of the SELECT (for SQL92
compatibility). However, ruleutils.c is expecting the SQL99
interpretation where such a name is an input column name. So it's
possible to produce an incorrect display of a view in the (admittedly
pretty ill-advised) case where some other column is renamed in the
SELECT output list to match an ORDER BY column.
This can be fixed by table-qualifying such names in the dumped
view text. To avoid cluttering less-ill-advised queries, we'd
like to do so only when there's an actual name conflict.
That requires passing the current get_query_def call's resultDesc
parameter down to get_variable, so that it can determine what
the output column names are. In hopes of reducing rather than
increasing notational clutter in ruleutils.c, I moved that value
into the deparse_context struct and removed it from the parameter
lists of get_query_def's other subroutines.
I made a few other cosmetic changes while at it:
* Likewise move the colNamesVisible parameter into deparse_context.
* Rename deparse_context's windowTList field to targetList,
since it's no longer used only in connection with WINDOW clauses.
* Replace the special_exprkind field with a bool inGroupBy,
since that was all it was being used for, and the apparent
flexibility of storing a ParseExprKind proved to be illusory.
(We need a separate varInOrderBy field to make this patch work.)
* Remove useless save/restore logic in get_select_query_def.
In principle, this bug is quite old. However, it seems unreachable
before
1b4d280ea, because before that the presence of "new" and "old"
entries in a view's rangetable caused us to always table-qualify every
Var reference in dumped views. Hence, back-patch to v16 where that
came in.
Per bug #18589 from Quynh Tran.
Discussion: https://postgr.es/m/18589-
70091cb81db1a3f1@postgresql.org
Peter Eisentraut [Thu, 29 Aug 2024 12:33:18 +0000 (14:33 +0200)]
Message style improvements
Peter Eisentraut [Thu, 29 Aug 2024 06:38:29 +0000 (08:38 +0200)]
Disallow USING clause when altering type of generated column
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
Reviewed-by: Yugo NAGATA
Discussion: https://www.postgresql.org/message-id/flat/
c7083982-69f4-4b14-8315-
f9ddb20b9834%40eisentraut.org
Amit Kapila [Thu, 29 Aug 2024 03:15:41 +0000 (08:45 +0530)]
Doc: Fix the ambiguity in the description of failover slots.
The failover slots ensure a seamless transition of a subscriber after the
standby is promoted. But the docs for it also explain the behavior of
asynchronous replication which can confuse the readers.
Reported-by: Masahiro Ikeda
Backpatch-through: 17
Discussion: https://postgr.es/m/OS3PR01MB6390B660F4198BB9745E0526B18B2@OS3PR01MB6390.jpnprd01.prod.outlook.com
Peter Eisentraut [Tue, 27 Aug 2024 14:54:10 +0000 (16:54 +0200)]
Message style improvements
Peter Eisentraut [Tue, 27 Aug 2024 14:15:28 +0000 (16:15 +0200)]
Fix misplaced translator comments
They did not immediately precede the code they were applying to.
Masahiko Sawada [Mon, 26 Aug 2024 23:16:09 +0000 (16:16 -0700)]
Fix identation.
Masahiko Sawada [Mon, 26 Aug 2024 18:00:04 +0000 (11:00 -0700)]
Fix memory counter update in ReorderBuffer.
Commit
5bec1d6bc5e changed the memory usage updates of the
ReorderBufferTXN to zero all at once by subtracting txn->size, rather
than updating it for each change. However, if TOAST reconstruction
data remained in the transaction when freeing it, there were cases
where it further subtracted the memory counter from zero, resulting in
an assertion failure.
This change calculates the memory size for each change and updates the
memory usage to precisely the amount that has been freed.
Backpatch to v17, where this was introducd.
Reviewed-by: Amit Kapila, Shlok Kyal
Discussion: https://postgr.es/m/CAD21AoAqkNUvicgKPT_dXzNoOwpPkVTg0QPPxEcWmzT0moCJ1g%40mail.gmail.com
Backpatch-through: 17
Peter Geoghegan [Mon, 26 Aug 2024 15:29:13 +0000 (11:29 -0400)]
Fix nbtree lookahead overflow bug.
Add bounds checking to nbtree's lookahead/skip-within-a-page mechanism.
Otherwise it's possible for cases with lots of before-array-keys tuples
to overflow an int16 variable, causing the mechanism to generate an out
of bounds page offset number.
Oversight in commit
5bf748b8, which enhanced nbtree ScalarArrayOp
execution.
Reported-By: Alexander Lakhin
Discussion: https://postgr.es/m/
6c68ac42-bbb5-8b24-103e-
af0e279c536f@gmail.com
Backpatch: 17-, where nbtree SAOP execution was enhanced.
Peter Eisentraut [Mon, 26 Aug 2024 12:38:59 +0000 (14:38 +0200)]
pg_upgrade: Message style improvements
Bruce Momjian [Mon, 26 Aug 2024 02:09:18 +0000 (22:09 -0400)]
doc PG 17 relnotes: remove ALTER TABLE SPLIT/MERGE PARTITION
Reverted in commit
84f594da358
Backpatch-through: 17 only
Alexander Korotkov [Sat, 24 Aug 2024 15:48:48 +0000 (18:48 +0300)]
Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands
This commit reverts
1adf16b8fb,
87c21bb941, and subsequent fixes and
improvements including
df64c81ca9,
c99ef1811a,
9dfcac8e15,
885742b9f8,
842c9b2705,
fcf80c5d5f,
96c7381c4c,
f4fc7cb54b,
60ae37a8bc,
259c96fa8f,
449cdcd486,
3ca43dbbb6,
2a679ae94e,
3a82c689fd,
fbd4321fd5,
d53a4286d7,
c086896625,
4e5d6c4091,
04158e7fa3.
The reason for reverting is security issues related to repeatable name lookups
(CVE-2014-0062). Even though
04158e7fa3 solved part of the problem, there
are still remaining issues, which aren't feasible to even carefully analyze
before the RC deadline.
Reported-by: Noah Misch, Robert Haas
Discussion: https://postgr.es/m/
20240808171351.a9.nmisch%40google.com
Backpatch-through: 17
Peter Eisentraut [Sat, 24 Aug 2024 14:15:13 +0000 (16:15 +0200)]
Add list of acknowledgments to release notes
This contains all individuals mentioned in the commit messages during
PostgreSQL 17 development.
current through REL_17_BETA3
Peter Eisentraut [Sat, 24 Aug 2024 13:56:32 +0000 (15:56 +0200)]
pg_createsubscriber: Message style improvements
Tom Lane [Fri, 23 Aug 2024 14:12:56 +0000 (10:12 -0400)]
Provide feature-test macros for libpq features added in v17.
As per the policy established in commit
6991e774e, invent macros
that can be tested at compile time to detect presence of new libpq
features. This should make calling code more readable and less
error-prone than checking the libpq version would be (especially
since we don't expose that at compile time; the server version is
an unreliable substitute).
Discussion: https://postgr.es/m/
2042418.
1724346970@sss.pgh.pa.us
Noah Misch [Thu, 22 Aug 2024 07:07:04 +0000 (00:07 -0700)]
Fix attach of a previously-detached injection point.
It's normal for the name in a free slot to match the new name. The
max_inuse mechanism kept simple cases from reaching the problem. The
problem could appear when index 0 was the previously-detached entry and
index 1 is in use. Back-patch to v17, where this code first appeared.
Alexander Korotkov [Thu, 22 Aug 2024 06:50:48 +0000 (09:50 +0300)]
Avoid repeated table name lookups in createPartitionTable()
Currently, createPartitionTable() opens newly created table using its name.
This approach is prone to privilege escalation attack, because we might end
up opening another table than we just created.
This commit address the issue above by opening newly created table by its
OID. It appears to be tricky to get a relation OID out of ProcessUtility().
We have to extend TableLikeClause with new newRelationOid field, which is
filled within ProcessUtility() to be further accessed by caller.
Security: CVE-2014-0062
Reported-by: Noah Misch
Discussion: https://postgr.es/m/
20240808171351.a9.nmisch%40google.com
Reviewed-by: Pavel Borisov, Dmitry Koval
Tom Lane [Wed, 21 Aug 2024 16:00:03 +0000 (12:00 -0400)]
Disallow creating binary-coercible casts involving range types.
For a long time we have forbidden binary-coercible casts to or from
composite and array types, because such a cast cannot work correctly:
the type OID embedded in the value would need to change, but it won't
in a binary coercion. That reasoning applies equally to range types,
but we overlooked installing a similar restriction here when we
invented range types. Do so now.
Given the lack of field complaints, we won't change this in stable
branches, but it seems not too late for v17.
Per discussion of a problem noted by Peter Eisentraut.
Discussion: https://postgr.es/m/
076968e1-0852-40a9-bc0b-
117cd3f0e43c@eisentraut.org
Peter Eisentraut [Wed, 21 Aug 2024 13:11:21 +0000 (15:11 +0200)]
doc: remove llvm-config search from configure documentation
As of
4dd29b6833, we no longer attempt to locate any other llvm-config
variant than plain llvm-config in configure-based builds; update the
documentation accordingly. (For Meson-based builds, we still use Meson's
LLVMDependencyConfigTool [0], which runs through a set of possible
suffixes [1], so no need to update the documentation there.)
[0]: https://github.com/mesonbuild/meson/blob/
7d28ff29396f9d7043204de8ddc52226b9903811/mesonbuild/dependencies/dev.py#L184
[1]: https://github.com/mesonbuild/meson/blob/
7d28ff29396f9d7043204de8ddc52226b9903811/mesonbuild/environment.py#L183
Author: Ole Peder Brandtzæg
Discussion: https://www.postgresql.org/message-id/20240518224601.gtisttjerylukjr5%40samfundet.no
Amit Kapila [Wed, 21 Aug 2024 03:38:16 +0000 (09:08 +0530)]
Don't advance origin during apply failure.
We advance origin progress during abort on successful streaming and
application of ROLLBACK in parallel streaming mode. But the origin
shouldn't be advanced during an error or unsuccessful apply due to
shutdown. Otherwise, it will result in a transaction loss as such a
transaction won't be sent again by the server.
Reported-by: Hou Zhijie
Author: Hayato Kuroda and Shveta Malik
Reviewed-by: Amit Kapila
Backpatch-through: 16
Discussion: https://postgr.es/m/TYAPR01MB5692FAC23BE40C69DA8ED4AFF5B92@TYAPR01MB5692.jpnprd01.prod.outlook.com
Alvaro Herrera [Tue, 20 Aug 2024 21:53:40 +0000 (17:53 -0400)]
Minor wording change in table "JSON Creation Functions"
For readability. Backpatch to 16.
Author: Erik Wienhold
Discussion: https://postgr.es/m/8ddac732-d650-4958-b9c9-ea8e6116251e@ewie.name
Nathan Bossart [Tue, 20 Aug 2024 18:43:20 +0000 (13:43 -0500)]
Fix a couple of wait event descriptions.
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
John Naylor [Tue, 20 Aug 2024 03:02:34 +0000 (10:02 +0700)]
Document limit on the number of out-of-line values per table
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
Bruce Momjian [Mon, 19 Aug 2024 22:27:21 +0000 (18:27 -0400)]
doc: Improve vague pg_createsubscriber description
Discussion: https://postgr.es/m/
[email protected]
Author: Euler Taveira
Backpatch-through: 17
Alvaro Herrera [Mon, 19 Aug 2024 20:09:10 +0000 (16:09 -0400)]
Avoid failure to open dropped detached partition
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
Reviewed-by: Kuntal Ghosh
Reviewed-by: Junwang Zhao
Discussion: https://postgr.es/m/202408122233[email protected]
Tomas Vondra [Mon, 19 Aug 2024 11:31:51 +0000 (13:31 +0200)]
Explain dropdb can't use syscache because of TOAST
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
Daniel Gustafsson [Mon, 19 Aug 2024 10:55:11 +0000 (12:55 +0200)]
Fix regression in TLS session ticket disabling
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
Reported-by: Fire Emerald
Reviewed-by: Jacob Champion
Discussion: https://postgr.es/m/DM6PR16MB3145CF62857226F350C710D1AB852@DM6PR16MB3145.namprd16.prod.outlook.com
Backpatch-through: v12
Thomas Munro [Mon, 19 Aug 2024 09:21:03 +0000 (21:21 +1200)]
Fix harmless LC_COLLATE[_MASK] confusion.
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.
Michael Paquier [Mon, 19 Aug 2024 03:34:52 +0000 (12:34 +0900)]
Fix more holes with SLRU code in need of int64 for segment numbers
This is a continuation of
c9e24573905b, containing changes included into
the proposed patch that have been missed in the actual commit. I have
managed to miss these diffs while doing a rebase of the original patch.
Thanks to Noah Misch, Peter Eisentraut and Alexander Korotkov for the
pokes.
Discussion: https://postgr.es/m/
92fe572d-638e-4162-aef6-
1c42a2936f25@eisentraut.org
Discussion: https://postgr.es/m/
20240810175055[email protected]
Backpatch-through: 17
Alvaro Herrera [Mon, 19 Aug 2024 00:49:57 +0000 (20:49 -0400)]
Search for SLRU page only in its own bank
One of the two slot scans in SlruSelectLRUPage was not walking only the
slots in the specific bank where the buffer could be; change it to do
that.
Oversight in
53c2a97a9266.
Author: Sergey Sargsyan
Discussion: https://postgr.es/m/18582-5f301dd30ba91a38@postgresql.org
Thomas Munro [Sun, 18 Aug 2024 23:47:37 +0000 (11:47 +1200)]
ci: Upgrade MacPorts version to 2.10.1.
MacPorts version 2.9.3 started failing in our ci_macports_packages.sh
script, for reasons not fully determined, but plausibly linked to the
release of 2.10.1. 2.10.1 seems to work, so let's switch to it.
Back-patch to 15, where CI began.
Reported-by: Peter Eisentraut
Discussion: https://postgr.es/m/
81f104e8-f0a9-43c0-85bd-
2bbbf590a5b8%40eisentraut.org
Tomas Vondra [Sun, 18 Aug 2024 22:04:41 +0000 (00:04 +0200)]
Fix DROP DATABASE for databases with many ACLs
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
Bruce Momjian [Sat, 17 Aug 2024 02:50:54 +0000 (22:50 -0400)]
docs: fix incorrect plpgsql error message
Change "$1" to "username".
Reported-by: [email protected]
Discussion: https://postgr.es/m/
172112109590.736590.
12219129462878821880@wrigleys.postgresql.org
Backpatch-through: 12
Bruce Momjian [Fri, 16 Aug 2024 17:11:23 +0000 (13:11 -0400)]
doc PG 17 relnotes: fix incorrect reference to huge_page_status
Reported-by: Justin Pryzby
Discussion: https://postgr.es/m/ZrTOaaxuG3JRSvwM@pryzbyj2023
Backpatch-through: 17 only
Bruce Momjian [Fri, 16 Aug 2024 17:01:34 +0000 (13:01 -0400)]
doc PG 17 relnotes: improve text for pg_walfile_name*()
Reported-by: Yugo Nagata
Discussion: https://postgr.es/m/
20240726132224.
3a77e79c4e563125c451e865@sraoss.co.jp
Backpatch-through: 17 only
Bruce Momjian [Fri, 16 Aug 2024 16:53:02 +0000 (12:53 -0400)]
doc PG 17 relnotes: fix pg_statistic_ext.stxstattarget ref.
Reported-by: Kisoon Kwon
Discussion: https://postgr.es/m/CAGOrKoVhjP_AeKGgzxWjRwdPqKL5Y-3TcVZoaz0bVTPwU8Yz+g@mail.gmail.com
Backpatch-through: 17 only
Peter Eisentraut [Fri, 16 Aug 2024 15:14:32 +0000 (17:14 +0200)]
Remove incidental md5() function use from test
To allow test to pass in OpenSSL FIPS mode, similar to
657f5f223e, for
a new test that has been added since.
Reviewed-by: Tomas Vondra
Discussion: https://www.postgresql.org/message-id/
86763810-70a1-4872-8ba7-
1676f788e5a2@eisentraut.org
Heikki Linnakangas [Fri, 16 Aug 2024 11:45:37 +0000 (14:45 +0300)]
Relax fsyncing at end of a bulk load that was not WAL-logged
And improve the comments.
Backpatch to v17 where this was introduced.
Reviewed-by: Noah Misch
Discussion: https://www.postgresql.org/message-id/
cac7d1b6-8358-40be-af0b-
21bc9b27d34c@iki.fi
Jeff Davis [Thu, 15 Aug 2024 02:05:39 +0000 (19:05 -0700)]
Fix doc typo: unicode_assigned() return type.
Reported-by: Hironobu SUZUKI
Discussion: https://postgr.es/m/
5dd88820-bb00-4b90-904b-
738ea2e4ee2e@interdb.jp
Backpatch-through: 17
Peter Eisentraut [Tue, 13 Aug 2024 08:01:49 +0000 (10:01 +0200)]
Use errmsg_internal for debug messages
Some newer code was applying this inconsistently.
Alvaro Herrera [Mon, 12 Aug 2024 22:17:56 +0000 (18:17 -0400)]
Fix creation of partition descriptor during concurrent detach+drop
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
Reviewed-by: Junwang Zhao
Reviewed-by: Tender Wang
Discussion: https://postgr.es/m/18559-b48286d2eacd9a4e@postgresql.org
Tom Lane [Mon, 12 Aug 2024 17:18:36 +0000 (13:18 -0400)]
Log more info when wait-for-catchup tests time out.
Cluster.pm's wait_for_catchup and allied subroutines don't provide
enough information to diagnose the problem when a wait times out.
In hopes of debugging some intermittent buildfarm failures, let's
dump the ending state of the relevant system view when that happens.
Add this to v17 too, but not stable branches.
Discussion: https://postgr.es/m/352068.
1723422725@sss.pgh.pa.us
Tom Lane [Sun, 11 Aug 2024 16:24:56 +0000 (12:24 -0400)]
Suppress Coverity warnings about Asserts in get_name_for_var_field.
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.
Tom Lane [Sat, 10 Aug 2024 19:51:28 +0000 (15:51 -0400)]
Allow adjusting session_authorization and role in parallel workers.
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/
2833457.
1723229039@sss.pgh.pa.us
John Naylor [Tue, 6 Aug 2024 13:38:33 +0000 (20:38 +0700)]
Lower minimum maintenance_work_mem to 64kB
Since the introduction of TID store, vacuum uses far less memory in
the common case than in versions 16 and earlier. Invoking multiple
rounds of index vacuuming in turn requires a much larger table. It'd
be a good idea anyway to cover this case in regression testing, and a
lower limit is less painful for slow buildfarm animals. The reason to
do it now is to re-enable coverage of the bugfix in commit
83c39a1f7f.
For consistency, give autovacuum_work_mem the same treatment.
Suggested by Andres Freund
Tested by Melanie Plageman
Backpatch to v17, where TID store was introduced
Discussion: https://postgr.es/m/
20240516205458[email protected]
Discussion: https://postgr.es/m/
20240722164745.fvaoh6g6zprisqgp%40awork3.anarazel.de
Nathan Bossart [Fri, 9 Aug 2024 15:52:37 +0000 (10:52 -0500)]
doc: Fix name of CRC algorithm in "Reliability" section.
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
Tom Lane [Fri, 9 Aug 2024 15:21:39 +0000 (11:21 -0400)]
Fix "failed to find plan for subquery/CTE" errors in EXPLAIN.
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/18576-
9feac34e132fea9e@postgresql.org
Alvaro Herrera [Thu, 8 Aug 2024 23:35:13 +0000 (19:35 -0400)]
Refuse ATTACH of a table referenced by a foreign key
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
Reviewed-by: Tender Wang
Discussion: https://postgr.es/m/18541-
628a61bc267cd2d3@postgresql.org
Alvaro Herrera [Thu, 8 Aug 2024 19:17:11 +0000 (15:17 -0400)]
Refactor error messages to reduce duplication
I also took the liberty of changing
errmsg("COPY DEFAULT only available using COPY FROM")
to
errmsg("COPY %s cannot be used with %s", "DEFAULT", "COPY TO")
because the original wording is unlike all other messages that indicate
option incompatibility. This message was added by commit
9f8377f7a279
(16-era), in whose development thread there was no discussion on this
point.
Backpatch to 17.
Heikki Linnakangas [Thu, 8 Aug 2024 07:20:25 +0000 (10:20 +0300)]
Fix pg_rewind debug output to print the source timeline history
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/
092dd515-b7b4-4fd0-8407-
ceca2f02f6ec@iki.fi
Peter Eisentraut [Wed, 7 Aug 2024 07:21:07 +0000 (09:21 +0200)]
Revert ECPG's use of pnstrdup()
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
Discussion: https://www.postgresql.org/message-id/CAOYmi+=pg=W5L1h=3MEP_EB24jaBu2FyATrLXqQHGe7cpuvwyg@mail.gmail.com
Noah Misch [Wed, 7 Aug 2024 18:43:08 +0000 (11:43 -0700)]
Fix names of "Visual Studio" and Meson in a documentation sentence.
Commit
3cffe7946c268be91a340ec9a27081cb93d67d35 missed this. Back-patch
to v17, which introduced this.
Discussion: https://postgr.es/m/CAJ7c6TM7ct0EjoCQaLSVYoxxnEw4xCUFebWj77GktWsqEdyCtQ@mail.gmail.com
Tom Lane [Wed, 7 Aug 2024 16:54:39 +0000 (12:54 -0400)]
Fix edge case in plpgsql's make_callstmt_target().
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/18574-
2ce7ba3249221389@postgresql.org
Alvaro Herrera [Wed, 7 Aug 2024 15:30:36 +0000 (11:30 -0400)]
Refactor/reword some error messages to avoid duplicates
Also, remove brackets around "EMPTY [ ARRAY ]". An error message is
not the place to state that a keyword is optional.
Backpatch to 17.
Heikki Linnakangas [Wed, 7 Aug 2024 07:43:52 +0000 (10:43 +0300)]
Make fallback MD5 implementation thread-safe on big-endian systems
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/
dfa2015d-ad21-4802-a4cc-
3850fc5fff3f@iki.fi
Tom Lane [Mon, 5 Aug 2024 20:03:01 +0000 (16:03 -0400)]
Stamp 17beta3.
Masahiko Sawada [Mon, 5 Aug 2024 13:05:30 +0000 (06:05 -0700)]
Restrict accesses to non-system views and foreign tables during pg_dump.
When pg_dump retrieves the list of database objects and performs the
data dump, there was possibility that objects are replaced with others
of the same name, such as views, and access them. This vulnerability
could result in code execution with superuser privileges during the
pg_dump process.
This issue can arise when dumping data of sequences, foreign
tables (only 13 or later), or tables registered with a WHERE clause in
the extension configuration table.
To address this, pg_dump now utilizes the newly introduced
restrict_nonsystem_relation_kind GUC parameter to restrict the
accesses to non-system views and foreign tables during the dump
process. This new GUC parameter is added to back branches too, but
these changes do not require cluster recreation.
Back-patch to all supported branches.
Reviewed-by: Noah Misch
Security: CVE-2024-7348
Backpatch-through: 12
Peter Eisentraut [Mon, 5 Aug 2024 10:12:32 +0000 (12:12 +0200)]
Translation updates
Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash:
f1fa38f3bf3e0a5d3a95304dcf6a11acf304577c
Noah Misch [Fri, 2 Aug 2024 19:49:56 +0000 (12:49 -0700)]
Fix name of "Visual Studio" in documentation.
Back-patch to v17, which introduced this.
Aleksander Alekseev
Discussion: https://postgr.es/m/CAJ7c6TM7ct0EjoCQaLSVYoxxnEw4xCUFebWj77GktWsqEdyCtQ@mail.gmail.com
Alvaro Herrera [Fri, 2 Aug 2024 16:05:38 +0000 (12:05 -0400)]
Fix NLS file reference in pg_createsubscriber
pg_createsubscriber is referring to a non-existent message translation
file, causing NLS to not work correctly. This command should use the
same file as pg_basebackup.
Author: Kyotaro Horiguchi
Discussion: https://postgr.es/m/20240802.115717.1083441453338151622[email protected]
Alvaro Herrera [Fri, 2 Aug 2024 16:01:10 +0000 (12:01 -0400)]
pg_createsubscriber: Fix bogus error message
Also some desultory style improvement
Peter Eisentraut [Thu, 1 Aug 2024 10:09:56 +0000 (12:09 +0200)]
pg_createsubscriber: Rename option --socket-directory to --socketdir
For consistency with the equivalent option in pg_upgrade.
Reviewed-by: Hayato Kuroda
Reviewed-by: Euler Taveira
Discussion: https://www.postgresql.org/message-id/flat/
1ed82b9b-8e20-497d-a2f8-
aebdd793d595%40eisentraut.org
Etsuro Fujita [Thu, 1 Aug 2024 08:45:00 +0000 (17:45 +0900)]
Update comment in portal.h.
We store tuples into the portal's tuple store for a PORTAL_ONE_MOD_WITH
query as well.
Back-patch to all supported branches.
Reviewed by Andy Fan.
Discussion: https://postgr.es/m/CAPmGK14HVYBZYZtHabjeCd-e31VT%3Dwx6rQNq8QfehywLcpZ2Hw%40mail.gmail.com
Tom Lane [Thu, 1 Aug 2024 00:54:31 +0000 (20:54 -0400)]
Revert "Allow parallel workers to cope with a newly-created session user ID."
This reverts commit
5887dd4894db5ac1c6411615160555ac6e57e49b.
Some buildfarm animals are failing with "cannot change
"client_encoding" during a parallel operation". It looks like
assign_client_encoding is unhappy at being asked to roll back a
client_encoding setting after a parallel worker encounters a
failure. There must be more to it though: why didn't I see this
during local testing? In any case, it's clear that moving the
RestoreGUCState() call is not as side-effect-free as I thought.
Given that the bug
f5f30c22e intended to fix has gone unreported
for years, it's not something that's urgent to fix; I'm not
willing to risk messing with it further with only days to our
next release wrap.
Tom Lane [Wed, 31 Jul 2024 22:54:10 +0000 (18:54 -0400)]
Allow parallel workers to cope with a newly-created session user ID.
Parallel workers failed after a sequence like
BEGIN;
CREATE USER foo;
SET SESSION AUTHORIZATION foo;
because check_session_authorization could not see the uncommitted
pg_authid row for "foo". This is because we ran RestoreGUCState()
in a separate transaction using an ordinary just-created snapshot.
The same disease afflicts any other GUC that requires catalog lookups
and isn't forgiving about the lookups failing.
To fix, postpone RestoreGUCState() into the worker's main transaction
after we've set up a snapshot duplicating the leader's. This affects
check_transaction_isolation and check_transaction_deferrable, which
think they should only run during transaction start. Make them
act like check_transaction_read_only, which already knows it should
silently accept the value when InitializingParallelWorker.
Per bug #18545 from Andrey Rachitskiy. Back-patch to all
supported branches, because this has been wrong for awhile.
Discussion: https://postgr.es/m/18545-
feba138862f19aaa@postgresql.org
David Rowley [Wed, 31 Jul 2024 13:26:16 +0000 (01:26 +1200)]
Doc: mention executor memory usage for enable_partitionwise* GUCs
Prior to this commit, the docs for enable_partitionwise_aggregate and
enable_partitionwise_join mentioned the additional overheads enabling
these causes for the query planner, but they mentioned nothing about the
possible surge in work_mem-consuming executor nodes that could end up in
the final plan. Dimitrios reported the OOM killer intervened on his
query as a result of using enable_partitionwise_aggregate=on.
Here we adjust the docs to mention the possible increase in the number of
work_mem-consuming executor nodes that can appear in the final plan as a
result of enabling these GUCs.
Reported-by: Dimitrios Apostolou
Reviewed-by: Ashutosh Bapat
Discussion: https://postgr.es/m/
3603c380-d094-136e-e333-
610914fb3e80%40gmx.net
Discussion: https://postgr.es/m/CAApHDvoZ0_yqwPFEpb6h261L76BUpmh5GxBQq0LeRzQ5Jh3zzg@mail.gmail.com
Backpatch-through: 12, oldest supported version
Jeff Davis [Tue, 30 Jul 2024 23:23:20 +0000 (16:23 -0700)]
Relax check for return value from second call of pg_strnxfrm().
strxfrm() is not guaranteed to return the exact number of bytes needed
to store the result; it may return a higher value.
Discussion: https://postgr.es/m/
32f85d88d1f64395abfe5a10dd97a62a4d3474ce[email protected]
Reviewed-by: Heikki Linnakangas
Backpatch-through: 16
Andrew Dunstan [Tue, 30 Jul 2024 11:57:16 +0000 (07:57 -0400)]
Preserve tz when converting to jsonb timestamptz
This removes an inconsistency in the treatment of different datatypes by
the jsonpath timestamp_tz() function. Conversions from data types that
are not timestamp-aware, such as date and timestamp, are now treated
consistently with conversion from those that are such as timestamptz.
Author: David Wheeler
Reviewed-by: Junwang Zhao and Jeevan Chalke
Discussion: https://postgr.es/m/
7DE080CE-6D8C-4794-9BD1-
7D9699172FAB%40justatheory.com
Backpatch to release 17.
Peter Eisentraut [Tue, 30 Jul 2024 10:21:20 +0000 (12:21 +0200)]
pg_createsubscriber: Remove obsolete comment
This comment should have been removed by commit
b9639138262. There is
no replication slot check on the primary anymore.
Author: Euler Taveira
Discussion: https://www.postgresql.org/message-id/697d692f-f9d3-41f6-9f0e-29a4fb18e544@app.fastmail.com
Andrew Dunstan [Tue, 30 Jul 2024 10:17:48 +0000 (06:17 -0400)]
Stabilize xid_wraparound tests
The tests had a race condition if autovacuum was set to off. Instead we
create all the tables we are interested in with autovacuum disabled, so
they are only ever touched when in danger of wraparound.
Discussion: https://postgr.es/m/
3e2cbd24-f45e-4b2b-ba83-
8149214f0a4d@dunslane.net
Masahiko Sawada (slightly tweaked by me)
Backpatch to release 17 where these tests were introduced.
Amit Kapila [Tue, 30 Jul 2024 08:47:30 +0000 (14:17 +0530)]
pg_createsubscriber: Fix an unpredictable recovery wait time.
The problem is that the tool is using the LSN returned by
pg_create_logical_replication_slot() as recovery_target_lsn. This LSN is
ahead of the current WAL position and the recovery waits until the
publisher writes a WAL record to reach the target and ends the recovery.
On idle systems, this wait time is unpredictable and could lead to failure
in promoting the subscriber. To avoid that, insert a harmless WAL record.
Reported-by: Alexander Lakhin and Tom Lane
Diagnosed-by: Hayato Kuroda
Author: Euler Taveira
Reviewed-by: Hayato Kuroda, Amit Kapila
Backpatch-through: 17
Discussion: https://postgr.es/m/
2377319.
1719766794%40sss.pgh.pa.us
Discussion: https://postgr.es/m/CA+TgmoYcY+Wb67NAwaHT7MvxCSeV86oSc+va9hHKaasE42ukyw@mail.gmail.com
Amit Langote [Tue, 30 Jul 2024 01:12:23 +0000 (10:12 +0900)]
SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE
The current method of coercing the boolean result value of
JsonPathExists() to the target type specified for an EXISTS column,
which is to call the type's input function via json_populate_type(),
leads to an error when the target type is integer, because the
integer input function doesn't recognize boolean literal values as
valid.
Instead use the boolean-to-integer cast function for coercion in that
case so that using integer or domains thereof as type for EXISTS
columns works. Note that coercion for ON ERROR values TRUE and FALSE
already works like that because the parser creates a cast expression
including the cast function, but the coercion of the actual result
value is not handled by the parser.
Tests by Jian He.
Reported-by: Jian He
Author: Jian He
Author: Amit Langote
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
Backpatch-through: 17
Amit Langote [Tue, 30 Jul 2024 01:37:56 +0000 (10:37 +0900)]
SQL/JSON: Some fixes to JsonBehavior expression casting
1. Remove the special case handling when casting the JsonBehavior
expressions to types with typmod, like
86d33987 did for the casting
of SQL/JSON constructor functions.
2. Fix casting for fixed-length character and bit string types by
using assignment-level casts. This is again similar to what
86d33987 did, but for ON ERROR / EMPTY expressions.
3. Use runtime coercion for the boolean ON ERROR constants so that
using fixed-length character string types, for example, for an
EXISTS column doesn't cause a "value too long for type
character(n)" when the parser tries to coerce the default ON ERROR
value "false" to that type, that is, even when clause is not
specified.
4. Simplify the conditions of when to use runtime coercion vs
creating the cast expression in the parser itself. jsonb-valued
expressions are now always coerced at runtime and boolean
expressions too if the target type is a string type for the
reasons mentioned above.
New tests are from a patch that Jian He posted. Outputs of some
existing tests change because the coercion now happens at runtime
instead of at parse time.
Reported-by: Jian He
Author: Jian He
Author: Amit Langote
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
Backpatch-through: 17
Heikki Linnakangas [Mon, 29 Jul 2024 19:21:34 +0000 (22:21 +0300)]
Detach syslogger from shared memory
Commit
aafc05de1b removed the calls to detach from shared memory from
syslogger startup. That was not intentional, so put them back.
Author: Rui Zhao
Reviewed-by: Aleksander Alekseev
Backpatch-through: 17
Discussion: https://www.postgresql.org/message-id/
11505016-8cf3-4691-b996-
7faed99b7877[email protected]
Tom Lane [Mon, 29 Jul 2024 16:17:24 +0000 (12:17 -0400)]
Count individual SQL commands in pg_restore's --transaction-size mode.
The initial implementation in commit
959b38d77 counted one action
per TOC entry (except for some special cases for multi-blob BLOBS
entries). This assumes that TOC entries are all about equally
complex, but it turns out that that assumption doesn't hold up very
well in binary-upgrade mode. For example, even after the previous
commit I was able to cause backend bloat with tables having many
inherited constraints. There may be other cases too. (Since no
serious problems have been reported with --single-transaction mode,
we can conclude that the backend copes well with psql's regular
restore scripts; but before
959b38d77 we never ran binary-upgrade
restores with multi-command transactions.)
To fix, count multi-command TOC entries as N actions, allowing the
transaction size to be scaled down when we hit a complex TOC entry.
Rather than add a SQL parser to pg_restore, approximate "multi
command" by counting semicolons in the TOC entry's defn string.
This will be fooled by semicolons appearing in string literals ---
but the error is in the conservative direction, so it doesn't seem
worth working harder. The biggest risk is with function/procedure
TOC entries, but we can just explicitly skip those.
(This is undoubtedly a hack, and maybe someday we'll be able to
revert it after fixing the backend's bloat issues or rethinking
what pg_dump emits in binary upgrade mode. But that surely isn't
a project for v17.)
Thanks to Alexander Korotkov for the let's-count-semicolons idea.
Per report from Justin Pryzby. Back-patch to v17 where txn_size mode
was introduced.
Discussion: https://postgr.es/m/ZqEND4ZcTDBmcv31@pryzbyj2023
Tom Lane [Mon, 29 Jul 2024 15:53:49 +0000 (11:53 -0400)]
Reduce number of commands dumpTableSchema emits for binary upgrade.
Avoid issuing a separate SQL UPDATE command for each column when
directly manipulating pg_attribute contents in binary upgrade mode.
With the separate updates, we triggered a relcache invalidation with
each update. For a table with N columns, that causes O(N^2) relcache
bloat in txn_size mode because the table's newly-created relcache
entry can't be flushed till end of transaction. Reducing the number
of commands should make it marginally faster as well as avoiding that
problem.
While at it, likewise avoid issuing a separate UPDATE on pg_constraint
for each inherited constraint. This is less exciting, first because
inherited (non-partitioned) constraints are relatively rare, and
second because the backend has a good deal of trouble anyway with
restoring tables containing many such constraints, due to
MergeConstraintsIntoExisting being horribly inefficient. But it seems
more consistent to do it this way here too, and it surely can't hurt.
In passing, fix one place in dumpTableSchema that failed to use ONLY
in ALTER TABLE. That's not a live bug, but it's inconsistent.
Also avoid silently casting away const from string literals.
Per report from Justin Pryzby. Back-patch to v17 where txn_size mode
was introduced.
Discussion: https://postgr.es/m/ZqEND4ZcTDBmcv31@pryzbyj2023
David Rowley [Sun, 28 Jul 2024 10:23:32 +0000 (22:23 +1200)]
Fix incorrect return value for pg_size_pretty(bigint)
pg_size_pretty(bigint) would return the value in bytes rather than PB
for the smallest-most bigint value. This happened due to an incorrect
assumption that the absolute value of -
9223372036854775808 could be
stored inside a signed 64-bit type.
Here we fix that by instead storing that value in an unsigned 64-bit type.
This bug does exist in versions prior to 15 but the code there is
sufficiently different and the bug seems sufficiently non-critical that
it does not seem worth risking backpatching further.
Author: Joseph Koshakow
Discussion: https://postgr.es/m/CAAvxfHdTsMZPWEHUrZ=h3cky9Ccc3Mtx2whUHygY+ABP-mCmUw@mail.gmail.com
Backpatch-through: 15
Peter Eisentraut [Sun, 28 Jul 2024 07:12:00 +0000 (09:12 +0200)]
libpq: Use strerror_r instead of strerror
Commit
453c4687377 introduced a use of strerror() into libpq, but that
is not thread-safe. Fix by using strerror_r() instead.
In passing, update some of the code comments added by
453c4687377, as
we have learned more about the reason for the change in OpenSSL that
started this.
Reviewed-by: Daniel Gustafsson
Discussion: Discussion: https://postgr.es/m/
b6fb018b-f05c-4afd-abd3-
318c649faf18@highgo.ca
Bruce Momjian [Sun, 28 Jul 2024 08:10:11 +0000 (04:10 -0400)]
doc PG 17 relnotes: add "()" to PQsocketPoll mention
Backpatch-through: 17 only
Heikki Linnakangas [Sat, 27 Jul 2024 10:53:16 +0000 (13:53 +0300)]
Support falling back to non-preferred readline implementation with meson
To build with -Dreadline=enabled one can use either readline or
libedit. The -Dlibedit_preferred flag is supposed to control the order
of names to lookup. This works fine when either both libraries are
present or -Dreadline is set to auto. However, explicitly enabling
readline with only libedit present, but not setting libedit_preferred,
or alternatively enabling readline with only readline present, but
setting libedit_preferred, too, are both broken. This is because
cc.find_library will throw an error for a not found dependency as soon
as the first required dependency is checked, thus it's impossible to
fallback to the alternative.
Here we only check the second of the two dependencies for
requiredness, thus we only fail when none of the two can be found.
Author: Wolfgang Walther
Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut
Reviewed-by: Tristan Partin
Discussion: https://www.postgresql.org/message-id/
ca8f37e1-a2c3-40e2-91f6-
59c3d3652ad4@technowledgy.de
Backpatch: 16-, where meson support was added
Heikki Linnakangas [Sat, 27 Jul 2024 10:53:14 +0000 (13:53 +0300)]
Support absolute bindir/libdir in regression tests with meson
Passing an absolute bindir/libdir will install the binaries and
libraries to
/tmp_install/ and
/tmp_install/ respectively.
This path is correctly passed to the regression test suite via
configure/make, but not via meson, yet. This is because the "/"
operator in the following expression throws away the whole left side
when the right side is an absolute path:
test_install_location / get_option('libdir')
This was already correctly handled for dir_prefix, which is likely
absolute as well. This patch handles both bindir and libdir in the
same way - prefixing absolute paths with the tmp_install path
correctly.
Author: Wolfgang Walther
Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut
Reviewed-by: Tristan Partin
Discussion: https://www.postgresql.org/message-id/ca8f37e1-a2c3-40e2-91f6-59c3d3652ad4@technowledgy.de
Backpatch: 16-, where meson support was added
Heikki Linnakangas [Sat, 27 Jul 2024 10:53:11 +0000 (13:53 +0300)]
Fallback to clang in PATH with meson
Some distributions put clang into a different path than the llvm
binary path.
For example, this is the case on NixOS / nixpkgs, which failed to find
clang with meson before this patch.
Author: Wolfgang Walther
Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut
Reviewed-by: Tristan Partin
Discussion: https://www.postgresql.org/message-id/
ca8f37e1-a2c3-40e2-91f6-
59c3d3652ad4@technowledgy.de
Backpatch: 16-, where meson support was added
Heikki Linnakangas [Sat, 27 Jul 2024 10:53:08 +0000 (13:53 +0300)]
Fallback to uuid for ossp-uuid with meson
The upstream name for the ossp-uuid package / pkg-config file is
"uuid". Many distributions change this to be "ossp-uuid" to not
conflict with e2fsprogs.
This lookup fails on distributions which don't change this name, for
example NixOS / nixpkgs. Both "ossp-uuid" and "uuid" are also checked
in configure.ac.
Author: Wolfgang Walther
Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut
Reviewed-by: Tristan Partin
Discussion: https://www.postgresql.org/message-id/
ca8f37e1-a2c3-40e2-91f6-
59c3d3652ad4@technowledgy.de
Backpatch: 16-, where meson support was added
Michael Paquier [Fri, 26 Jul 2024 22:16:59 +0000 (07:16 +0900)]
Fix more holes with SLRU code in need of int64 for segment numbers
This is a continuation of
3937cadfd438, taking care of more areas I have
managed to miss previously.
Reported-by: Noah Misch
Reviewed-by: Noah Misch
Discussion: https://postgr.es/m/
20240724130059[email protected]
Backpatch-through: 17
Robert Haas [Fri, 26 Jul 2024 18:50:21 +0000 (14:50 -0400)]
Wait for WAL summarization to catch up before creating .partial file.
When a standby is promoted, CleanupAfterArchiveRecovery() may decide
to rename the final WAL file from the old timeline by adding ".partial"
to the name. If WAL summarization is enabled and this file is renamed
before its partial contents are summarized, WAL summarization breaks:
the summarizer gets stuck at that point in the WAL stream and just
errors out.
To fix that, first make the startup process wait for WAL summarization
to catch up before renaming the file. Generally, this should be quick,
and if it's not, the user can shut off summarize_wal and try again.
To make this fix work, also teach the WAL summarizer that after a
promotion has occurred, no more WAL can appear on the previous
timeline: previously, the WAL summarizer wouldn't switch to the new
timeline until we actually started writing WAL there, but that meant
that when the startup process was waiting for the WAL summarizer, it
was waiting for an action that the summarizer wasn't yet prepared to
take.
In the process of fixing these bugs, I realized that the logic to wait
for WAL summarization to catch up was spread out in a way that made
it difficult to reuse properly, so this code refactors things to make
it easier.
Finally, add a test case that would have caught this bug and the
previously-fixed bug that WAL summarization sometimes needs to back up
when the timeline changes.
Discussion: https://postgr.es/m/CA+TgmoZGEsZodXC4f=XZNkAeyuDmWTSkpkjCEOcF19Am0mt_OA@mail.gmail.com
Robert Haas [Fri, 26 Jul 2024 15:58:52 +0000 (11:58 -0400)]
Fix indentation.