Daniel Gustafsson [Mon, 2 Sep 2024 16:36:57 +0000 (18:36 +0200)] doc: Consistently use result set in documentation
We use "result set" in all other places so let's be consistent
across the entire documentation.
Reported-by: [email protected]Discussion: https://postgr.es/m/
172187924855.915373.
15595156724215203822@wrigleys.postgresql.org
Peter Eisentraut [Mon, 2 Sep 2024 15:40:32 +0000 (17:40 +0200)] Fix rarely-run test for message wording change
fixup for
2e6a8047f0Reported-by: Nazir Bilal Yavuz <[email protected]>Daniel Gustafsson [Mon, 2 Sep 2024 11:52:27 +0000 (13:52 +0200)] Only perform pg_strong_random init when required
The random number generator in OpenSSL 1.1.1 was redesigned to provide
fork safety by default, thus removing the need for calling RAND_poll
after forking to ensure that two processes cannot share the same state.
Since we now support 1.1.0 as the minumum version, and 1.1.0 is being
increasingly phased out from production use, only perform the RAND_poll
initialization for installations running 1.1.0 by checking the OpenSSL
version number.
LibreSSL changed random number generator when forking OpenSSL and has
provided fork safety since version 2.0.2.
This removes the overhead of initializing the RNG for strong random
for the vast majority of users for whom it is no longer required.
Reviewed-by: Jacob Champion <[email protected]>Reviewed-by: Peter Eisentraut <[email protected]>Reviewed-by: Michael Paquier <[email protected]>Discussion: https://postgr.es/m/CA+hUKGKh7QrYzu=8yWEUJvXtMVm_CNWH1L_TLWCbZMwbi1XP2Q@mail.gmail.com
Daniel Gustafsson [Mon, 2 Sep 2024 11:51:48 +0000 (13:51 +0200)] Remove support for OpenSSL older than 1.1.0
OpenSSL 1.0.2 has been EOL from the upstream OpenSSL project for
some time, and is no longer the default OpenSSL version with any
vendor which package PostgreSQL. By retiring support for OpenSSL
1.0.2 we can remove a lot of no longer required complexity for
managing state within libcrypto which is now handled by OpenSSL.
Reviewed-by: Jacob Champion <[email protected]>Reviewed-by: Peter Eisentraut <[email protected]>Reviewed-by: Michael Paquier <[email protected]>Discussion: https://postgr.es/m/
[email protected]Discussion: https://postgr.es/m/CA+hUKGKh7QrYzu=8yWEUJvXtMVm_CNWH1L_TLWCbZMwbi1XP2Q@mail.gmail.com
Daniel Gustafsson [Mon, 2 Sep 2024 08:17:46 +0000 (10:17 +0200)] Cache typarray for fast lookups in binary upgrade mode
When upgrading a large schema it adds significant overhead to perform
individual catalog lookups per relation in order to retrieve Oid for
preserving Oid calls. This instead adds the typarray to the TypeInfo
cache which then allows for fast lookups using the existing API. A
35% reduction of pg_dump runtime in binary upgrade mode was observed
with this change.
Reviewed-by: Nathan Bossart <[email protected]>Discussion: https://postgr.es/m/
8F1F1E1D-D17B-4B33-B014-
EDBCD15F3F0B@yesql.se
Peter Eisentraut [Mon, 2 Sep 2024 06:16:25 +0000 (08:16 +0200)] More use of getpwuid_r() directly
Remove src/port/user.c, call getpwuid_r() directly. This reduces some
complexity and allows better control of the error behavior. For
example, the old code would in some circumstances silently truncate
the result string, or produce error message strings that the caller
wouldn't use.
src/port/user.c used to be called src/port/thread.c and contained
various portability complications to support thread-safety. These are
all obsolete, and all but the user-lookup functions have already been
removed. This completes this by also removing the user-lookup
functions.
Also convert src/backend/libpq/auth.c to use getpwuid_r() for
thread-safety.
Originally, I tried to be overly correct by using
sysconf(_SC_GETPW_R_SIZE_MAX) to get the buffer size for getpwuid_r(),
but that doesn't work on FreeBSD. All the OS where I could find the
source code internally use 1024 as the suggested buffer size, so I
just ended up hardcoding that. The previous code used BUFSIZ, which
is an unrelated constant from stdio.h, so its use seemed
inappropriate.
Reviewed-by: Heikki Linnakangas <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/
5f293da9-ceb4-4937-8e52-
82c25db8e4d3%40eisentraut.org
Michael Paquier [Sun, 1 Sep 2024 23:18:41 +0000 (08:18 +0900)] Rename enum labels of PG_Locale_Strategy
PG_REGEX_BUILTIN was added in
f69319f2f1fb but it did not follow the
same pattern as the previous labels, i.e. PG_LOCALE_*. In addition to
this, the two libc strategies did not include in the name that they were
related to this library.
The enum labels are renamed as PG_STRATEGY_type[_subtype] to make the
code clearer, in accordance to the library and the functions they rely
on.
Author: Andreas Karlsson
Discussion: https://postgr.es/m/
6f81200f-68fd-411e-97a1-
d1f291d2e222@proxel.se
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 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- to 17.
Reported-by: Alexander Lakhin <[email protected]>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- 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
Masahiko Sawada [Fri, 30 Aug 2024 22:06:09 +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.
Back to 12, where this GUC parameter was introduced.
Reviewed-by: Peter EisentrautDiscussion: https://postgr.es/m/
6a96f1af-22b4-4a80-8161-
1f26606b9ee2%40eisentraut.org
Back-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 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- 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:12 +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- such an improvement, but this change seems
safe and at least gets rid of the performance-regression cases.
Per complaint from Nikhil Raj. Back- to v16 where the
problem appeared.
Discussion: https://postgr.es/m/CAG1ps1xvnTZceKK24OUfMKLPvDP2vjT-d+F2AOCWbw_v3KeEgg@mail.gmail.com
Tom Lane [Fri, 30 Aug 2024 16:22:31 +0000 (12:22 -0400)] Remove one memoize test case added by commit
069d0ff02.
This test case turns out to depend on the assumption that a non-Var
subquery output that's underneath an outer join will always get
wrapped in a PlaceHolderVar. But that behavior causes performance
regressions in some cases compared to what happened before v16.
The next commit will avoid inserting a PHV in the same cases where
pre-v16 did, and that causes get_memoized_path to not detect that
a memoize plan could be used.
Commit this separately, in hopes that we can restore the test after
making get_memoized_path smarter. (It's failing to find memoize
plans in adjacent cases where no PHV was ever inserted, so there
is definitely room for improvement there.)
Discussion: https://postgr.es/m/CAG1ps1xvnTZceKK24OUfMKLPvDP2vjT-d+F2AOCWbw_v3KeEgg@mail.gmail.com
Michael Paquier [Fri, 30 Aug 2024 06:25:12 +0000 (15:25 +0900)] Define PG_LOGICAL_DIR for path pg_logical/ in data folder
This is similar to
2065ddf5e34c, but this time for pg_logical/ itself
and its contents, like the paths for snapshots, mappings or origin
checkpoints.
Author: Bertrand Drouvot
Reviewed-by: Ashutosh Bapat, Yugo Nagata, Michael PaquierDiscussion: https://postgr.es/m/
[email protected]Michael Paquier [Fri, 30 Aug 2024 01:42:21 +0000 (10:42 +0900)] Define PG_REPLSLOT_DIR for path pg_replslot/ in data folder
This commit replaces most of the hardcoded values of "pg_replslot" by a
new PG_REPLSLOT_DIR #define. This makes the style more consistent with
the existing PG_STAT_TMP_DIR, for example. More places will follow a
similar change.
Author: Bertrand Drouvot
Reviewed-by: Ashutosh Bapat, Yugo Nagata, Michael PaquierDiscussion: https://postgr.es/m/
[email protected]Michael Paquier [Thu, 29 Aug 2024 23:49:24 +0000 (08:49 +0900)] Rename pg_sequence_read_tuple() to pg_get_sequence_data()
This commit removes log_cnt from the tuple returned by the SQL function.
This field is an internal counter that tracks when a WAL record should
be generated for a sequence, and it is reset each time the sequence is
restored or recovered. It is not necessary to rebuild the sequence DDL
commands for pg_dump and pg_upgrade where this function is used. The
field can still be queried with a scan of the "table" created
under-the-hood for a sequence.
Issue noticed while hacking on a feature that can rely on this new
function rather than pg_sequence_last_value(), aimed at making sequence
computation more easily pluggable.
Bump catalog version.
Reviewed-by: Nathan BossartDiscussion: https://postgr.es/m/
[email protected]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 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- 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:43:34 +0000 (14:43 +0200)] Message style improvements
Peter Eisentraut [Thu, 29 Aug 2024 09:49:48 +0000 (11:49 +0200)] Put generated_stored test objects in a schema
This avoids naming conflicts with concurrent tests with similarly
named objects. Currently, there are none, but a tests for virtual
generated columns are planned to be added.
Reviewed-by: Corey Huinker <[email protected]>Reviewed-by: Tomasz Rybak <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/
a368248e-69e4-40be-9c07-
6c3b5880b0a6@eisentraut.org
Peter Eisentraut [Thu, 29 Aug 2024 09:49:48 +0000 (11:49 +0200)] Rename regress test generated to generated_stored
This makes naming room to have another test file for virtual generated
columns.
Reviewed-by: Corey Huinker <[email protected]>Reviewed-by: Tomasz Rybak <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/
a368248e-69e4-40be-9c07-
6c3b5880b0a6@eisentraut.org
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 <[email protected]>Reviewed-by: Yugo NAGATA <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/
c7083982-69f4-4b14-8315-
f9ddb20b9834%40eisentraut.org
Heikki Linnakangas [Thu, 29 Aug 2024 06:46:21 +0000 (09:46 +0300)] Rename some shared memory initialization routines
To make them follow the usual naming convention where
FoobarShmemSize() calculates the amount of shared memory needed by
Foobar subsystem, and FoobarShmemInit() performs the initialization.
I didn't rename CreateLWLocks() and InitShmmeIndex(), because they are
a little special. They need to be called before any of the other
ShmemInit() functions, because they set up the shared memory
bookkeeping itself. I also didn't rename InitProcGlobal(), because
unlike other Shmeminit functions, it's not called by individual
backends.
Reviewed-by: Andreas KarlssonDiscussion: https://www.postgresql.org/message-id/
c09694ff-2453-47e5-b26c-
32a16cd75ce6@iki.fi
Heikki Linnakangas [Thu, 29 Aug 2024 06:46:06 +0000 (09:46 +0300)] Refactor lock manager initialization to make it a bit less special
Split the shared and local initialization to separate functions, and
follow the common naming conventions. With this, we no longer create
the LockMethodLocalHash hash table in the postmaster process, which
was always pointless.
Reviewed-by: Andreas KarlssonDiscussion: https://www.postgresql.org/message-id/
c09694ff-2453-47e5-b26c-
32a16cd75ce6@iki.fi
Michael Paquier [Thu, 29 Aug 2024 06:31:30 +0000 (15:31 +0900)] Refactor some code for ALTER TABLE SET LOGGED/UNLOGGED in tablecmds.c
Both sub-commands use the same routine to switch the relpersistence of a
relation, duplicated the same checks, and used a style inconsistent with
access methods and tablespaces.
SET LOGEED/UNLOGGED is refactored to avoid any duplication, setting the
reason why a relation rewrite happens within ATPrepChangePersistence().
This shaves some code.
Discussion: https://postgr.es/m/
[email protected]Peter Eisentraut [Thu, 29 Aug 2024 06:22:28 +0000 (08:22 +0200)] Fixup for prefetching support on macOS
The new code path (commit
6654bb92047) should call FileAccess() first,
like the posix_fadvise() path.
Reported-by: Thomas Munro <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/
0827edec-1317-4917-a186-
035eb1e3241d%40eisentraut.org
Amit Kapila [Thu, 29 Aug 2024 03:42:12 +0000 (09:12 +0530)] Rename the conflict types for the origin differ cases.
The conflict types 'update_differ' and 'delete_differ' indicate that a row
to be modified was previously altered by another origin. Rename those to
'update_origin_differs' and 'delete_origin_differs' to clarify their
meaning.
Author: Hou Zhijie
Reviewed-by: Shveta Malik, Peter Smith
Discussion: https://postgr.es/m/CAA4eK1+HEKwG_UYt4Zvwh5o_HoCKCjEGesRjJX38xAH3OxuuYA@mail.gmail.com
Amit Kapila [Thu, 29 Aug 2024 03:26:52 +0000 (08:56 +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
Back-through: 17
Discussion: https://postgr.es/m/OS3PR01MB6390B660F4198BB9745E0526B18B2@OS3PR01MB6390.jpnprd01.prod.outlook.com
Peter Eisentraut [Wed, 28 Aug 2024 05:26:48 +0000 (07:26 +0200)] Add prefetching support on macOS
macOS doesn't have posix_fadvise(), but fcntl() with the F_RDADVISE
command does the same thing.
Some related documentation has been generalized to not mention
posix_advise() specifically anymore.
Reviewed-by: Thomas Munro <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/
0827edec-1317-4917-a186-
035eb1e3241d%40eisentraut.org
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:12 +0000 (16:16 -0700)] Fix identation.
Masahiko Sawada [Mon, 26 Aug 2024 18:00:07 +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.
Back to v17, where this was introducd.
Reviewed-by: Amit Kapila, Shlok KyalDiscussion: https://postgr.es/m/CAD21AoAqkNUvicgKPT_dXzNoOwpPkVTg0QPPxEcWmzT0moCJ1g%40mail.gmail.com
Back-through: 17
Peter Geoghegan [Mon, 26 Aug 2024 15:29:15 +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 <[email protected]>Discussion: https://postgr.es/m/
6c68ac42-bbb5-8b24-103e-
af0e279c536f@gmail.com
Back: 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
Dean Rasheed [Mon, 26 Aug 2024 10:00:20 +0000 (11:00 +0100)] Fix compiler warning in mul_var_short().
Some compilers (e.g., gcc before version 7) mistakenly think "carry"
might be used uninitialized.
Reported by Tom Lane, per various buildfarm members, e.g. arowana.
Alexander Korotkov [Sun, 25 Aug 2024 21:22:44 +0000 (00:22 +0300)] Revert: Avoid looping over all type cache entries in TypeCacheRelCallback()
This commit reverts
c14d4acb8 as the design didn't take into account
that TypeCacheEntry could be invalidated during the lookup_type_cache() call.
Reported-by: Alexander LakhinDiscussion: https://postgr.es/m/
1927cba4-177e-5c23-cbcc-
d444a850304f%40gmail.com
Alexander Korotkov [Sun, 25 Aug 2024 00:21:23 +0000 (03:21 +0300)] Avoid looping over all type cache entries in TypeCacheRelCallback()
Currently when a single relcache entry gets invalidated,
TypeCacheRelCallback() has to loop over all type cache entries to find
appropriate typentry to invalidate. Unfortunately, using the syscache here
is impossible, because this callback could be called outside a transaction
and this makes impossible catalog lookups. This is why present commit
introduces RelIdToTypeIdCacheHash to map relation OID to its composite type
OID.
We are keeping RelIdToTypeIdCacheHash entry while corresponding type cache
entry have something to clean. Therefore, RelIdToTypeIdCacheHash shouldn't
get bloat in the case of temporary tables flood.
Discussion: https://postgr.es/m/
5812a6e5-68ae-4d84-9d85-
b443176966a1%40sigaev.ru
Author: Teodor Sigaev
Reviewed-by: Aleksander Alekseev, Tom Lane, Michael Paquier, Roman ZharkovReviewed-by: Andrei Lepikhov, Pavel BorisovAlexander 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 HaasDiscussion: https://postgr.es/m/
20240808171351.a9.nmisch%40google.com
Back-through: 17
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
Peter Eisentraut [Fri, 23 Aug 2024 05:07:53 +0000 (07:07 +0200)] thread-safety: gmtime_r(), localtime_r()
Use gmtime_r() and localtime_r() instead of gmtime() and localtime(),
for thread-safety.
There are a few affected calls in libpq and ecpg's libpgtypes, which
are probably effectively bugs, because those libraries already claim
to be thread-safe.
There is one affected call in the backend. Most of the backend
otherwise uses the custom functions pg_gmtime() and pg_localtime(),
which are implemented differently.
While we're here, change the call in the backend to gmtime*() instead
of localtime*(), since for that use time zone behavior is irrelevant,
and this side-steps any questions about when time zones are
initialized by localtime_r() vs localtime().
Portability: gmtime_r() and localtime_r() are in POSIX but are not
available on Windows. Windows has functions gmtime_s() and
localtime_s() that can fulfill the same purpose, so we add some small
wrappers around them. (Note that these *_s() functions are also
different from the *_s() functions in the bounds-checking extension of
C11. We are not using those here.)
On MinGW, you can get the POSIX-style *_r() functions by defining
_POSIX_C_SOURCE appropriately before including <time.h>. This leads
to a conflict at least in plpython because apparently _POSIX_C_SOURCE
gets defined in some header there, and then our replacement
definitions conflict with the system definitions. To avoid that sort
of thing, we now always define _POSIX_C_SOURCE on MinGW and use the
POSIX-style functions here.
Reviewed-by: Stepan Neretin <[email protected]>Reviewed-by: Heikki Linnakangas <[email protected]>Reviewed-by: Thomas Munro <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/
eba1dc75-298e-4c46-8869-
48ba8aad7d70@eisentraut.org
Michael Paquier [Fri, 23 Aug 2024 03:11:36 +0000 (12:11 +0900)] Rework new SLRU test with injection points
Rather than the SQL injection_points_load(), this commit changes the
injection point test introduced in
768a9fd5535f to rely on the two
macros INJECTION_POINT_LOAD() and INJECTION_POINT_CACHED(), that have
been originally introduced for the sake of this test.
This runs the test as a two-step process: load the injection point, then
run its callback directly from the local cache loaded. What the test
did originally was also fine, but the point here is to have an example
in core of how to use these new macros.
While on it, fix the header ordering in multixact.c, as pointed out by
Alexander Korotkov. This was an oversight in
768a9fd5535f.
Per discussion with Álvaro Herrera.
Author: Michael Paquier
Discussion: https://postgr.es/m/
[email protected]Discussion: https://postgr.es/m/CAPpHfduzaBz7KMhwuVOZMTpG=JniPG4aUosXPZCxZydmzq_oEQ@mail.gmail.com
Michael Paquier [Fri, 23 Aug 2024 02:36:41 +0000 (11:36 +0900)] injection_point: Add injection_points.stats
This GUC controls if cumulative statistics are enabled or not in the
module. Custom statistics require the module to be loaded with
shared_preload_libraries, hence this GUC is made PGC_POSTMASTER. By
default, the stats are disabled. 001_stats.pl is updated to enable the
statistics, as it is the only area where these are required now.
This will be used by an upcoming change for the injection point test
added by
768a9fd5535f where stats should not be used, as the test runs a
point callback in a critical section. And the module injection_points
will need to be loaded with shared_preload_libraries there.
Per discussion with Álvaro Herrera.
Author: Michael Paquier
Discussion: https://postgr.es/m/
[email protected]Michael Paquier [Fri, 23 Aug 2024 01:12:58 +0000 (10:12 +0900)] injection_points: Add initialization of shmem state when loading module
This commits adds callbacks to initialize the shared memory state of the
module when loaded with shared_preload_libraries. This is necessary to
be able to update the test introduced in
768a9fd5535f to use the macros
INJECTION_POINT_{LOAD,CACHED}() rather than a SQL function in the module
injection_points forcing a load, as this test runs a callback in a
critical section where no memory allocation should happen.
Initializing the shared memory state of the module while loading
provides a strict control on the timing of its allocation. If the
module is not loaded at startup, it will use a GetNamedDSMSegment()
instead to initialize its shmem state on-the-fly.
Per discussion with Álvaro Herrera.
Author: Michael Paquier
Discussion: https://postgr.es/m/
[email protected]Amit Kapila [Thu, 22 Aug 2024 08:41:50 +0000 (14:11 +0530)] Doc: explain the log format of logical replication conflicts.
This commit adds a detailed explanation of the log format for logical
replication conflicts.
Author: Hou Zhijie
Reviewed-by: Shveta Malik, Peter Smith, Hayato Kuroda
Discussion: https://postgr.es/m/OS0PR01MB5716352552DFADB8E9AD1D8994C92@OS0PR01MB5716.jpnprd01.prod.outlook.com
Discussion: https://postgr.es/m/OS0PR01MB57162EDE8BA17F3EE08A24CA948D2@OS0PR01MB5716.jpnprd01.prod.outlook.com
Michael Paquier [Thu, 22 Aug 2024 07:25:57 +0000 (16:25 +0900)] psql: Add more meta-commands able to use the extended protocol
Currently, only unnamed prepared statement are supported by psql with
the meta-command \bind. With only this command, it is not possible to
test named statement creation, execution or close through the extended
protocol.
This commit introduces three additional commands:
* \parse creates a prepared statement using the extended protocol,
acting as a wrapper of libpq's PQsendPrepare().
* \bind_named binds and executes an existing prepared statement using
the extended protocol, for PQsendQueryPrepared().
* \close closes an existing prepared statement using the extended
protocol, for PQsendClosePrepared().
This is going to be useful to add regression tests for the extended
query protocol, and I have some plans for that on separate threads.
Note that \bind relies on PQsendQueryParams().
The code of psql is refactored so as bind_flag is replaced by an enum in
_psqlSettings that tracks the type of libpq routine to execute, based on
the meta-command involved, with the default being PQsendQuery(). This
refactoring piece has been written by me, while Anthonin has implemented
the rest.
Author: Anthonin Bonnefoy, Michael Paquier
Reviewed-by: Aleksander Alekseev, Jelte Fennema-Nio
Discussion: https://postgr.es/m/CAO6_XqpSq0Q0kQcVLCbtagY94V2GxNP3zCnR6WnOM8WqXPK4nw@mail.gmail.com
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- 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 MischDiscussion: https://postgr.es/m/
20240808171351.a9.nmisch%40google.com
Reviewed-by: Pavel Borisov, Dmitry KovalRichard Guo [Thu, 22 Aug 2024 02:41:08 +0000 (11:41 +0900)] Small code simplification
Apply the same code simplification to ATExecAddColumn as was done in
7ff9afbbd: apply GETSTRUCT() once instead of doing it repeatedly in
the same function.
Author: Tender Wang
Discussion: https://postgr.es/m/CAHewXNkO9+U437jvKT14s0MCu6Qpf6G-p2mZK5J9mAi4cHDgpQ@mail.gmail.com
Michael Paquier [Thu, 22 Aug 2024 01:48:25 +0000 (10:48 +0900)] Create syscache entries for pg_extension
Two syscache identifiers are added for extension names and OIDs.
Shared libraries of extensions might want to invalidate or update their
own caches whenever a CREATE, ALTER or DROP EXTENSION command is run for
their extension (in any backend). Right now this is non-trivial to do
correctly and efficiently, but, if an extension catalog is part of a
syscache, this could simply be done by registering an callback using
CacheRegisterSyscacheCallback for the relevant syscache.
Another case where this is useful is a loaded library where some of its
code paths rely on some objects of the extension to exist; it can be
simpler and more efficient to do an existence check directly on the
extension through the syscache.
Author: Jelte Fennema-Nio
Reviewed-by: Alexander Korotkov, Pavel Stehule
Discussion: https://postgr.es/m/CAGECzQTWm9sex719Hptbq4j56hBGUti7J9OWjeMobQ1ccRok9w@mail.gmail.com
Jeff Davis [Wed, 21 Aug 2024 16:19:21 +0000 (09:19 -0700)] Fix obsolete comments in varstr_cmp().
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
Robert Haas [Wed, 21 Aug 2024 14:14:35 +0000 (10:14 -0400)] Show number of disabled nodes in EXPLAIN ANALYZE output.
Now that disable_cost is not included in the cost estimate, there's
no visible sign in EXPLAIN output of which plan nodes are disabled.
Fix that by propagating the number of disabled nodes from Path to
Plan, and then showing it in the EXPLAIN output.
There is some question about whether this is a desirable change.
While I personally believe that it is, it seems best to make it a
separate commit, in case we decide to back out just this part, or
rework it.
Reviewed by Andres Freund, Heikki Linnakangas, and David Rowley.
Discussion: http://postgr.es/m/CA+TgmoZ_+MS+o6NeGK2xyBv-xM+w1AfFVuHE4f_aq6ekHv7YSQ@mail.gmail.com
Robert Haas [Wed, 21 Aug 2024 14:12:30 +0000 (10:12 -0400)] Treat number of disabled nodes in a path as a separate cost metric.
Previously, when a path type was disabled by e.g. enable_seqscan=false,
we either avoided generating that path type in the first place, or
more commonly, we added a large constant, called disable_cost, to the
estimated startup cost of that path. This latter approach can distort
planning. For instance, an extremely expensive non-disabled path
could seem to be worse than a disabled path, especially if the full
cost of that path node need not be paid (e.g. due to a Limit).
Or, as in the regression test whose expected output changes with this
commit, the addition of disable_cost can make two paths that would
normally be distinguishible in cost seem to have fuzzily the same cost.
To fix that, we now count the number of disabled path nodes and
consider that a high-order component of both the startup cost and the
total cost. Hence, the path list is now sorted by disabled_nodes and
then by total_cost, instead of just by the latter, and likewise for
the partial path list. It is important that this number is a count
and not simply a Boolean; else, as soon as we're unable to respect
disabled path types in all portions of the path, we stop trying to
avoid them where we can.
Because the path list is now sorted by the number of disabled nodes,
the join prechecks must compute the count of disabled nodes during
the initial cost phase instead of postponing it to final cost time.
Counts of disabled nodes do not cross subquery levels; at present,
there is no reason for them to do so, since the we do not postpone
path selection across subquery boundaries (see make_subplan).
Reviewed by Andres Freund, Heikki Linnakangas, and David Rowley.
Discussion: http://postgr.es/m/CA+TgmoZ_+MS+o6NeGK2xyBv-xM+w1AfFVuHE4f_aq6ekHv7YSQ@mail.gmail.com
Robert Haas [Wed, 21 Aug 2024 13:58:11 +0000 (09:58 -0400)] 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://.com/mesonbuild/meson/blob/
7d28ff29396f9d7043204de8ddc52226b9903811/mesonbuild/dependencies/dev.py#L184
[1]: https://.com/mesonbuild/meson/blob/
7d28ff29396f9d7043204de8ddc52226b9903811/mesonbuild/environment.py#L183
Author: Ole Peder Brandtzæg <
[email protected]>
Discussion: https://www.postgresql.org/message-id/
20240518224601.gtisttjerylukjr5%40samfundet.no
Amit Kapila [Wed, 21 Aug 2024 11:15:36 +0000 (16:45 +0530)] Fix typos in
9758174e2e.
Reported off-list by Erik Rijkers
Peter Eisentraut [Wed, 21 Aug 2024 07:21:25 +0000 (09:21 +0200)] Small code simplification
Apply GETSTRUCT() once instead of doing it repeatedly in the same
function. This simplifies the notation and makes the function's
structure more similar to the surrounding ones.
Discussion: https://www.postgresql.org/message-id/flat/
a368248e-69e4-40be-9c07-
6c3b5880b0a6@eisentraut.org
Amit Kapila [Wed, 21 Aug 2024 03:52:32 +0000 (09:22 +0530)] Don't advance origin during apply failure.
We advance origin progress during abort on successful and
application of ROLLBACK in parallel 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
Back-through: 16
Discussion: https://postgr.es/m/TYAPR01MB5692FAC23BE40C69DA8ED4AFF5B92@TYAPR01MB5692.jpnprd01.prod.outlook.com
Jeff Davis [Tue, 20 Aug 2024 21:29:34 +0000 (14:29 -0700)] Slightly refactor varstr_sortsupport() to improve readability.
Author: Andreas Karlsson
Discussion: https://postgr.es/m/
69c2a864-846f-4309-bd5a-
aaa1c34f9a11@proxel.se
Michael Paquier [Tue, 20 Aug 2024 22:24:03 +0000 (07:24 +0900)] Remove _PG_fini()
ab02d702ef08 has removed from the backend the code able to support the
unloading of modules, because this has never worked. This removes the
last references to _PG_fini(), that could be used as a callback for
modules to manipulate the stack when unloading a library.
The test module ldap_password_func had the idea to declare it, doing
nothing. The function declaration in fmgr.h is gone.
It was left around in 2022 to avoid breaking extension code, but at this
stage there are also benefits in letting extension developers know that
keeping the unloading code is pointless and this move leads to less
maintenance.
Reviewed-by: Tom Lane, Heikki LinnakangasDiscussion: https://postgr.es/m/
[email protected]Alvaro Herrera [Tue, 20 Aug 2024 21:53:40 +0000 (17:53 -0400)] Minor wording change in table "JSON Creation Functions"
For readability. Back to 16.
Author: Erik Wienhold <
[email protected]>
Discussion: https://postgr.es/m/
8ddac732-d650-4958-b9c9-
ea8e6116251e@ewie.name
Jeff Davis [Tue, 20 Aug 2024 18:24:00 +0000 (11:24 -0700)] Improve configure error for ICU libraries if pkg-config is absent.
If pkg-config is not installed, the ICU libraries cannot be found, but
the custom configure error message did not mention this. This might
lead to confusion about the actual problem. To improve this, remove
the explicit error message and rely on PKG_CHECK_MODULES' generic
error message.
Author: Michael Banck
Reported-by: Holger JakobsDiscussion: https://postgr.es/m/
ccd579ed-4949-d3de-ab13-
9e6456fd2caf%40jakobs.com
Discussion: https://postgr.es/m/
66b5d05c.
050a0220[email protected]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 KapilaDiscussion: https://postgr.es/m/CAGPeHmh6UMrKQHKCmX%2B5vV5TH9P%3DKw9en3k68qEem6J%3DyrZPUA%40mail.gmail.com
Back-through: 13
Alvaro Herrera [Tue, 20 Aug 2024 18:20:48 +0000 (14:20 -0400)] Add injection-point test for new multixact CV usage
Before commit
a0e0fb1ba56f, multixact.c contained a case in the
multixact-read path where it would loop sleeping 1ms each time until
another multixact-create path completed, which was uncovered by any
tests. That commit changed the code to rely on a condition variable
instead. Add a test now, which relies on injection points and "loading"
thereof (because of it being in a critical section), per commit
4b211003ecc2.
Author: Andrey Borodin <
[email protected]>
Reviewed-by: Michaël Paquier <[email protected]>Discussion: https://postgr.es/m/
0925F9A9-4D53-4B27-A87E-
3D83A757B0E0@yandex-team.ru
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
Back to all supported versions
Discussion: https://postgr.es/m/CAKZiRmwWhp2yxjqJLwbBjHdfbJBcUmmKMNAZyBjjtpgM9AMatQ%40mail.gmail.com
Amit Kapila [Tue, 20 Aug 2024 03:05:11 +0000 (08:35 +0530)] Log the conflicts while applying changes in logical replication.
This provides the additional logging information in the following
conflict scenarios while applying changes:
insert_exists: Inserting a row that violates a NOT DEFERRABLE unique constraint.
update_differ: Updating a row that was previously modified by another origin.
update_exists: The updated row value violates a NOT DEFERRABLE unique constraint.
update_missing: The tuple to be updated is missing.
delete_differ: Deleting a row that was previously modified by another origin.
delete_missing: The tuple to be deleted is missing.
For insert_exists and update_exists conflicts, the log can include the origin
and commit timestamp details of the conflicting key with track_commit_timestamp
enabled.
update_differ and delete_differ conflicts can only be detected when
track_commit_timestamp is enabled on the subscriber.
We do not offer additional logging for exclusion constraint violations because
these constraints can specify rules that are more complex than simple equality
checks. Resolving such conflicts won't be straightforward. This area can be
further enhanced if required.
Author: Hou Zhijie
Reviewed-by: Shveta Malik, Amit Kapila, Nisha Moond, Hayato Kuroda, Dilip Kumar
Discussion: https://postgr.es/m/OS0PR01MB5716352552DFADB8E9AD1D8994C92@OS0PR01MB5716.jpnprd01.prod.outlook.com
David Rowley [Tue, 20 Aug 2024 01:38:22 +0000 (13:38 +1200)] Speed up Hash Join by making ExprStates support hashing
Here we add ExprState support for obtaining a 32-bit hash value from a
list of expressions. This allows both faster hashing and also JIT
compilation of these expressions. This is especially useful when hash
joins have multiple join keys as the previous code called ExecEvalExpr on
each hash join key individually and that was inefficient as tuple
deformation would have only taken into account one key at a time, which
could lead to walking the tuple once for each join key. With the new
code, we'll determine the maximum attribute required and deform the tuple
to that point only once.
Some performance tests done with this change have shown up to a 20%
performance increase of a query containing a Hash Join without JIT
compilation and up to a 26% performance increase when JIT is enabled and
optimization and inlining were performed by the JIT compiler. The
performance increase with 1 join column was less with a 14% increase
with and without JIT. This test was done using a fairly small hash
table and a large number of hash probes. The increase will likely be
less with large tables, especially ones larger than L3 cache as memory
pressure is more likely to be the limiting factor there.
This commit only addresses Hash Joins, but lays expression evaluation
and JIT compilation infrastructure for other hashing needs such as Hash
Aggregate.
Author: David Rowley
Reviewed-by: Alexey Dvoichenkov <[email protected]>Reviewed-by: Tels <[email protected]>Discussion: https://postgr.es/m/CAApHDvoexAxgQFNQD_GRkr2O_eJUD1-wUGm%3Dm0L%2BGc%3DT%3DkEa4g%40mail.gmail.com
Bruce Momjian [Tue, 20 Aug 2024 00:18:03 +0000 (20:18 -0400)] doc: improve create/alter sequence CYCLE syntax
Reported-by: Peter Smith
Discussion: https://postgr.es/m/CAHut+PtqwZwPfGq62xq2614_ce2ejDmbB9CfP+a1azxpneFRBQ@mail.gmail.com
Author: Peter Smith
Back-through: master
Bruce Momjian [Mon, 19 Aug 2024 23:54:39 +0000 (19:54 -0400)] doc: mention of postpostgres_fdw INSERT ON CONFLICT limitation
Reported-by: Fujii MasaoDiscussion: https://postgr.es/m/
47801526-d017-4c89-9f52-
c02c449a139b@oss.nttdata.com
Author: Fujii Masao
Back-through: master
Bruce Momjian [Mon, 19 Aug 2024 23:22:10 +0000 (19:22 -0400)] doc: clarify create database in start docs uses command line
Reported-by: [email protected]Discussion: https://postgr.es/m/
172251463564.915373.
17748961617119647662@wrigleys.postgresql.org
Back-through: master
Bruce Momjian [Mon, 19 Aug 2024 22:27:22 +0000 (18:27 -0400)] doc: Improve vague pg_createsubscriber description
Discussion: https://postgr.es/m/
[email protected]Author: Euler Taveira
Back-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.
Back 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/
202408122233[email protected]Tomas Vondra [Mon, 19 Aug 2024 17:46:05 +0000 (19:46 +0200)] Document that search_path is reported by the server
Commit
28a1121fd912 marked search_path as GUC_REPORT, but failed to
update the relevant places in docs. There are two places listing the GUC
options reported to the client, so update both.
Reported-by: Tom LaneDiscussion: https://postgr.es/m/CAFh8B=k8s7WrcqhafmYhdN1+E5LVzZi_QaYDq8bKvrGJTAhY2Q@mail.gmail.com
Tomas Vondra [Mon, 19 Aug 2024 15:04:09 +0000 (17:04 +0200)] Mark search_path as GUC_REPORT
Report search_path changes to the client. Multi-tenant applications
often map tenants to schemas, and use search_path to pick the tenant a
given connection works with. This breaks when a connection pool (like
PgBouncer), because the search_path may change unexpectedly.
There are other GUCs we might want reported (e.g. various timeouts), but
search_path is by far the biggest foot gun that can lead either to
puzzling failures during query execution (when objects are missing or
are defined differently), or even to accessing incorrect data.
Many existing tools modify search_path, pg_dump being a notable example.
Ideally, clients could specify which GUCs are interesting and should be
subject to this reporting, but we don't support that. GUC_REPORT is what
connection pools rely on for other interesting GUCs, so just use that.
When this change was initially proposed in 2014, one of the concerns was
impact on performance. But this was addressed by commit
2432b1a04087,
which ensures we report each GUC at most once per query, no matter how
many times it changed during execution.
Eventually, this might be replaced / superseded by allowing doing this
by making the protocol extensible in this direction, but it's unclear
when (or if) that happens. Until then, we can leverage GUC_REPORT.
Author: Alexander Kukushkin, Jelte Fennema-Nio
Discussion: https://postgr.es/m/CAFh8B=k8s7WrcqhafmYhdN1+E5LVzZi_QaYDq8bKvrGJTAhY2Q@mail.gmail.com
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 by Yugo Nagata. Back to 12, same as the fix.
Author: Yugo Nagata
Back-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.
Back 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
Back-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- to 14, where
ca051d8b101 landed.
Heikki Linnakangas [Mon, 19 Aug 2024 06:48:25 +0000 (09:48 +0300)] Fix garbled process name on backend crash
The log message on backend crash used wrong variable, which could be
uninitialized. Introduced in commit
28a520c0b7.
Reported-by: Alexander LakhinDiscussion: https://www.postgresql.org/message-id/
451b0797-83b8-cdbc-727f-
8d7a7b0e3bca@gmail.com
Michael Paquier [Mon, 19 Aug 2024 03:34:18 +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 that have been missed in the actual commit. I have
managed to miss these diffs while doing a rebase of the original .
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]Back-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 <
[email protected]>
Discussion: https://postgr.es/m/18582-
5f301dd30ba91a38@postgresql.org
Michael Paquier [Mon, 19 Aug 2024 00:03:52 +0000 (09:03 +0900)] injection_points: Add stats for point caching and loading
This adds two counters to the fixed-numbered stats of injection points
to track the number of times injection points have been cached and
loaded from the cache, as of the additions coming from
a0a5869a8598 and
4b211003ecc2.
These should have been part of
f68cd847fa40, but I have lacked time and
energy back then, and it did not prevent the code to be a useful
template.
While on it, this commit simplifies the description of a few tests while
adding coverage for the new stats data.
Author: Yogesh Sharma
Discussion: https://postgr.es/m/
3a6977f7-54ab-43ce-8806-
11d5e15526a2@catprosystems.com
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- to 15, where CI began.
Reported-by: Peter Eisentraut <[email protected]>Discussion: https://postgr.es/m/
81f104e8-f0a9-43c0-85bd-
2bbbf590a5b8%40eisentraut.org
Michael Paquier [Sun, 18 Aug 2024 22:53:47 +0000 (07:53 +0900)] doc: Fix typo in section for custom pgstats
Per offline report from Erik Rijkers.
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. Back to 12. The DROP DATABASE fix
was backed to 11, but 11 is EOL at this point.
Reported-by: Ayush TiwariAuthor: Ayush Tiwari
Reviewed-by: Tomas VondraBack-through: 12
Discussion: https://postgr.es/m/CAJTYsWWNkCt+-UnMhg=BiCD3Mh8c2JdHLofPxsW3m2dkDFw8RA@mail.gmail.com
Thomas Munro [Sun, 18 Aug 2024 19:59:16 +0000 (07:59 +1200)] Fix cpluspluscheck for pg_verifybackup.h.
simplehash.h references pg_fatal(), which cpluspluscheck says is
undeclared, causing the CI CompilerWarnings task to fail since commit
aa2d6b15. Include the header it needs.
Discussion: https://postgr.es/m/CA%2BhUKGJC3d4PXkErpfOWrzQqcq6MLiCv0%2BAH0CMQnB6hdLUFEw%40mail.gmail.com
Noah Misch [Sun, 18 Aug 2024 19:03:59 +0000 (12:03 -0700)] Fix comments on wal_level=minimal, CREATE TABLESPACE and CREATE DATABASE.
Commit
97ddda8a82ac470ae581d0eb485b6577707678bc removed the rmtree()
behavior from XLOG_TBLSPC_CREATE, obsoleting that part of the comment.
The comment's point about XLOG_DBASE_CREATE was wrong when commit
fa0f466d5329e10b16f3b38c8eaf5306f7e234e8 introduced the point. (It
would have been accurate if that commit had predated commit
fbcbc5d06f53aea412130deb52e216aa3883fb8d introducing the second
checkpoint of CREATE DATABASE.) Nothing can skip log_smgrcreate() on
the basis of wal_level=minimal, so don't comment on that.
Commit
c6b92041d38512a4176ed76ad06f713d2e6c01a8 expanded WAL skipping
from five specific operations to relfilenodes generally, hence the
CreateDatabaseUsingFileCopy() comment change.
Discussion: https://postgr.es/m/
20231008022204[email protected]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
Back-through: 12
Bruce Momjian [Sat, 17 Aug 2024 01:11:55 +0000 (21:11 -0400)] C comment: fix for commit
b5a9b18cd0bThe commit was "Provide API for relation data.".
Reported-by: Nazir Bilal YavuzDiscussion: https://postgr.es/m/CAN55FZ3KsZ2faZs1sK5J0W+_8B3myB232CfLYGie4u4BBMwP3g@mail.gmail.com
Back-through: master
David Rowley [Fri, 16 Aug 2024 22:36:23 +0000 (10:36 +1200)] Relocate a badly placed Assert in COPY FROM code
There's not much point in asserting a pointer isn't NULL after some code
has already dereferenced that pointer.
Adjust the code so that the Assert occurs before the pointer dereference.
The Assert probably has questionable value in the first place, but it
seems worth keeping around to document the contract between
CopyMultiInsertInfoNextFreeSlot() and its callers.
Author: Amul Sul <
[email protected]>
Discussion: https://postgr.es/m/CAAJ_b94hXQzXaJxTLShkxQUgezf_SUxhzX9TH2f-g6gP7bne7g@mail.gmail.com
Nathan Bossart [Fri, 16 Aug 2024 20:06:40 +0000 (15:06 -0500)] Further reduce dependence on -fwrapv semantics in jsonb.
Commit
108d2adb9e missed updating a few places in the jsonb code
that rely on signed integer wrapping for correctness. These can
also be fixed by using pg_abs_s32() to negate a signed integer
(that is known to be negative) for comparison with an unsigned
integer.
Reported-by: Alexander LakhinDiscussion: https://postgr.es/m/
bfff906f-300d-81ea-83b7-
f2c93845e7f2%40gmail.com
Robert Haas [Fri, 16 Aug 2024 19:09:42 +0000 (15:09 -0400)] pg_verifybackup: Move some declarations to new pg_verifybackup.h
This is in preparation for adding a second source file to this
directory.
Amul Sul, reviewed by Sravan Kumar and revised a bit by me.
Discussion: http://postgr.es/m/CAAJ_b95mcGjkfAf1qduOR97CokW8-_i-dWLm3v6x1w2-OW9M+A@mail.gmail.com
Robert Haas [Fri, 16 Aug 2024 18:52:52 +0000 (14:52 -0400)] pg_verifybackup: Move skip_checksums into verifier_context.
This is in preparation for adding a second source file to this
directory. It will need access to this value. Also, fewer global
variables is usually a good thing.
Amul Sul, reviewed by Sravan Kumar and revised a bit by me.
Discussion: http://postgr.es/m/CAAJ_b95mcGjkfAf1qduOR97CokW8-_i-dWLm3v6x1w2-OW9M+A@mail.gmail.com
Robert Haas [Fri, 16 Aug 2024 17:34:18 +0000 (13:34 -0400)] Improve more comments in astreamer_gzip.c.
Duplicate the comment from astreamer_plain_writer_new instead of just
referring to it. Add a further note to mention that there are dangers
if anything else is written to the same FILE. Also add a comment where
we dup() the filehandle, referring to the existing comment in
astreamer_gzip_writer_finalize(), because the dup() looks wrong on
first glance without that comment to clarify.
Per concerns expressed by Tom Lane on pgsql-security, and using
some wording suggested by him.
Discussion: http://postgr.es/m/CA+TgmoYTFAD0YTh4HC1Nuhn0YEyoQi0_CENFgVzAY_YReiSksQ@mail.gmail.com
Alvaro Herrera [Fri, 16 Aug 2024 17:23:18 +0000 (13:23 -0400)] libpq: Trace all messages received from the server
Not all messages that libpq received from the server would be sent
through our message tracing logic. This commit tries to fix that by
introducing a new function pqParseDone which make it harder to forget
about doing so.
The messages that we now newly send through our tracing logic are:
- CopyData (received by COPY TO STDOUT)
- Authentication requests
- NegotiateProtocolVersion
- Some ErrorResponse messages during connection startup
- ReadyForQuery when received after a FunctionCall message
Author: Jelte Fennema-Nio <
[email protected]>
Discussion: https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com
Tom Lane [Fri, 16 Aug 2024 16:35:50 +0000 (12:35 -0400)] Fix extraction of week and quarter fields from intervals.
"EXTRACT(WEEK FROM interval_value)" formerly threw an error.
Define it as "tm->tm_mday / 7". (With C99 division semantics,
this gives consistent results for negative intervals.)
"EXTRACT(QUARTER FROM interval_value)" has been implemented
all along, but it formerly gave extremely strange results for
negative intervals. Fix it so that the output for -N months
is the negative of the output for N months.
Per bug #18348 from Michael Bondarenko and subsequent discussion.
Discussion: https://postgr.es/m/18348-
b097a3587dfde8a4@postgresql.org
Nathan Bossart [Fri, 16 Aug 2024 16:24:44 +0000 (11:24 -0500)] Remove dependence on -fwrapv semantics in jsonb.
This commit updates a couple of places in the jsonb code to no
longer rely on signed integer wrapping for correctness. Like
commit
9e9a2b7031, this is intended to move us closer towards
removing -fwrapv, which may enable some compiler optimizations.
However, there is presently no plan to actually remove that
compiler option in the near future.
This commit makes use of the newly introduced pg_abs_s32() routine
to negate a signed integer (that is known to be negative) for
comparison with an unsigned integer. In passing, change one use of
INT_MIN to the more portable PG_INT32_MIN.
Reported-by: Alexander LakhinAuthor: Joseph Koshakow
Reviewed-by: Jian HeDiscussion: https://postgr.es/m/CAAvxfHdBPOyEGS7s%2Bxf4iaW0-cgiq25jpYdWBqQqvLtLe_t6tw%40mail.gmail.com
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 <[email protected]>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.
Back to v17 where this was introduced.
Reviewed-by: Noah MischDiscussion: https://www.postgresql.org/message-id/
cac7d1b6-8358-40be-af0b-
21bc9b27d34c@iki.fi
Heikki Linnakangas [Fri, 16 Aug 2024 10:48:10 +0000 (13:48 +0300)] Refactor CopyOneRowTo
The handling of binary and text formats are quite different here, so
it's more clear to check for the format first and have two separate
loops.
Author: jian he <
[email protected]>
Reviewed-by: Ilia Evdokimov, Junwang ZhaoDiscussion: https://www.postgresql.org/message-id/CACJufxFzHCeFBQF0M%
[email protected]