postgresql.git
16 months agoOptimize pg_atomic_exchange_u32 and pg_atomic_exchange_u64.
Nathan Bossart [Mon, 18 Dec 2023 16:53:32 +0000 (10:53 -0600)]
Optimize pg_atomic_exchange_u32 and pg_atomic_exchange_u64.

Presently, all platforms implement atomic exchanges by performing
an atomic compare-and-swap in a loop until it succeeds.  This can
be especially expensive when there is contention on the atomic
variable.  This commit optimizes atomic exchanges on many platforms
by using compiler intrinsics, which should compile into something
much less expensive than a compare-and-swap loop.  Since these
intrinsics have been available for some time, the inline assembly
implementations are omitted.

Suggested-by: Andres Freund
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/20231129212905.GA1258737%40nathanxps13

16 months agoMicro-optimize datum_to_json_internal() some more.
Nathan Bossart [Mon, 18 Dec 2023 16:34:33 +0000 (10:34 -0600)]
Micro-optimize datum_to_json_internal() some more.

Commit dc3f9bc549 mainly targeted the JSONTYPE_NUMERIC code path.
This commit applies similar optimizations (e.g., removing
unnecessary runtime calls to strlen() and palloc()) to nearby code.

Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/20231208203708.GA4126315%40nathanxps13

16 months agoProvide vectored variants of smgrread() and smgrwrite().
Thomas Munro [Mon, 18 Dec 2023 00:08:49 +0000 (13:08 +1300)]
Provide vectored variants of smgrread() and smgrwrite().

smgrreadv() and smgrwritev() and their md.c implementations call
FileReadV() and FileWriteV().  A range of disk blocks beginning at
'blocknum' and extending for 'nblocks' can be scattered to or gathered
from multiple buffers with a single system call.  The traditional
smgrread() and smgrwrite() functions are implemented in terms of the new
functions.

Later commits will introduce calls with nblocks > 1, but the following
behavioral changes can be seen already:

* After a short transfer we'll now retry until we eventually read 0
  bytes (= EOF) or get ENOSPC, EDQUOT, EFBIG etc, where previously we
  would infer the reason.  Retrying is consistent with xlog.c's
  treatment of large WAL writes, and arguably also xlog.c and fd.c's
  treatment of EINTR.  Arbitrary short returns for larger transfers have
  been observed on several OSes, and might in theory also happen for
  transient reasons with our own pg_p*v() fallback code.

* After unexpected EOF or -1, the error thrown now talks about
  a range even for the single block case, eg "blocks 42..42".

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/CA+hUKGJkOiOCa+mag4BF+zHo7qo=o9CFheB8=g6uT5TUm2gkvA@mail.gmail.com

16 months agoDoc: add a bit to indices.sgml about what is an indexable clause.
Tom Lane [Sun, 17 Dec 2023 21:49:44 +0000 (16:49 -0500)]
Doc: add a bit to indices.sgml about what is an indexable clause.

We didn't explain this clearly until somewhere deep in the
"Extending SQL" chapter, but really it ought to be mentioned
in the introductory material too.

Discussion: https://postgr.es/m/4097442.1694967650@sss.pgh.pa.us

16 months agoRefactor pgstat_prepare_io_time() with an input argument instead of a GUC
Michael Paquier [Sat, 16 Dec 2023 19:16:20 +0000 (20:16 +0100)]
Refactor pgstat_prepare_io_time() with an input argument instead of a GUC

Originally, this routine relied on track_io_timing to check if a time
interval for an I/O operation stored in pg_stat_io should be initialized
or not.  However, the addition of WAL statistics to pg_stat_io requires
that the initialization happens when track_wal_io_timing is enabled,
which is dependent on the code path where the I/O operation happens.

Author: Nazir Bilal Yavuz
Discussion: https://postgr.es/m/CAN55FZ3AiQ+ZMxUuXnBpd0Rrh1YhwJ5FudkHg=JU0P+-W8T4Vg@mail.gmail.com

16 months agoRemove useless LIMIT_OPTION_DEFAULT value from LimitOption
Alvaro Herrera [Sat, 16 Dec 2023 17:20:03 +0000 (18:20 +0100)]
Remove useless LIMIT_OPTION_DEFAULT value from LimitOption

During the development that led to commit 357889eb17bb, for a time we
had the value LIMIT_OPTION_DEFAULT, which was mostly but not completely
removed later on, before commit.  Complete the removal now.

Author: Zhang Mingli <avamingli@gmail.com>
Discussion: https://postgr.es/m/59d61a1a-3858-475a-964f-24468c97cc67@Spark

17 months agoProvide multi-block smgrprefetch().
Thomas Munro [Sat, 16 Dec 2023 03:14:47 +0000 (16:14 +1300)]
Provide multi-block smgrprefetch().

Previously smgrprefetch() could issue POSIX_FADV_WILLNEED advice for a
single block at a time.  Add an nblocks argument so that we can do the
same for a range of blocks.  This usually produces a single system call,
but might need to loop if it crosses a segment boundary.  Initially it
is only called with nblocks == 1, but proposed patches will make wider
calls.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> (earlier version)
Discussion: https://postgr.es/m/CA+hUKGJkOiOCa+mag4BF+zHo7qo=o9CFheB8=g6uT5TUm2gkvA@mail.gmail.com

17 months agoFix bugs in manipulation of large objects.
Tom Lane [Fri, 15 Dec 2023 18:55:05 +0000 (13:55 -0500)]
Fix bugs in manipulation of large objects.

In v16 and up (since commit afbfc0298), large object ownership
checking has been broken because object_ownercheck() didn't take care
of the discrepancy between our object-address representation of large
objects (classId == LargeObjectRelationId) and the catalog where their
ownership info is actually stored (LargeObjectMetadataRelationId).
This resulted in failures such as "unrecognized class ID: 2613"
when trying to update blob properties as a non-superuser.

Poking around for related bugs, I found that AlterObjectOwner_internal
would pass the wrong classId to the PostAlterHook in the no-op code
path where the large object already has the desired owner.  Also,
recordExtObjInitPriv checked for the wrong classId; that bug is only
latent because the stanza is dead code anyway, but as long as we're
carrying it around it should be less wrong.  These bugs are quite old.

In HEAD, we can reduce the scope for future bugs of this ilk by
changing AlterObjectOwner_internal's API to let the translation happen
inside that function, rather than requiring callers to know about it.

A more bulletproof fix, perhaps, would be to start using
LargeObjectMetadataRelationId as the dependency and object-address
classId for blobs.  However that has substantial risk of breaking
third-party code; even within our own code, it'd create hassles
for pg_dump which would have to cope with a version-dependent
representation.  For now, keep the status quo.

Discussion: https://postgr.es/m/2650449.1702497209@sss.pgh.pa.us

17 months agoFix typo
Peter Eisentraut [Thu, 14 Dec 2023 08:48:24 +0000 (09:48 +0100)]
Fix typo

Reported-by: Junwang Zhao <zhjwpku@gmail.com>
17 months agodocs: Fix typo in pg_stat_statements documentation
Daniel Gustafsson [Wed, 13 Dec 2023 10:32:13 +0000 (11:32 +0100)]
docs: Fix typo in pg_stat_statements documentation

Commit dc9f8a79830 accidentally misspelled minimum as minimun.

17 months agoPrevent tuples to be marked as dead in subtransactions on standbys
Michael Paquier [Tue, 12 Dec 2023 16:05:18 +0000 (17:05 +0100)]
Prevent tuples to be marked as dead in subtransactions on standbys

Dead tuples are ignored and are not marked as dead during recovery, as
it can lead to MVCC issues on a standby because its xmin may not match
with the primary.  This information is tracked by a field called
"xactStartedInRecovery" in the transaction state data, switched on when
starting a transaction in recovery.

Unfortunately, this information was not correctly tracked when starting
a subtransaction, because the transaction state used for the
subtransaction did not update "xactStartedInRecovery" based on the state
of its parent.  This would cause index scans done in subtransactions to
return inconsistent data, depending on how the xmin of the primary
and/or the standby evolved.

This is broken since the introduction of hot standby in efc16ea52067, so
backpatch all the way down.

Author: Fei Changhong
Reviewed-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/tencent_C4D907A5093C071A029712E73B43C6512706@qq.com
Backpatch-through: 12

17 months agoFix typo in comment
Daniel Gustafsson [Tue, 12 Dec 2023 11:16:38 +0000 (12:16 +0100)]
Fix typo in comment

Commit 98e675ed7af accidentally mistyped IDENTIFY_SYSTEM as
IDENTIFY_SERVER. Backpatch to all supported branches.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/68138521-5345-8780-4390-1474afdcba1f@gmail.com

17 months agoProvide vectored variants of FileRead() and FileWrite().
Thomas Munro [Mon, 11 Dec 2023 22:56:11 +0000 (11:56 +1300)]
Provide vectored variants of FileRead() and FileWrite().

FileReadV() and FileWriteV() adapt pg_preadv() and pg_pwritev() for
fd.c's virtual file descriptors.  The simple FileRead() and FileWrite()
functions are now implemented in terms of the vectored functions, to
avoid code duplication, and they are converted back to the corresponding
simple system calls further down (commit 15c9ac36).  Later work will
make more interesting multi-iovec calls.

The traditional behavior of reporting a "fake" ENOSPC error is
simplified.  It's now always set for non-failing writes, for the benefit
of callers that expect to log a meaningful "%m" if they determine that
the write was short.  (Perhaps we should consider getting rid of that
expectation one day.)

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/CA+hUKGJkOiOCa+mag4BF+zHo7qo=o9CFheB8=g6uT5TUm2gkvA@mail.gmail.com

17 months agoProvide helper for retrying partial vectored I/O.
Thomas Munro [Mon, 11 Dec 2023 21:28:46 +0000 (10:28 +1300)]
Provide helper for retrying partial vectored I/O.

compute_remaining_iovec() is a re-usable routine for retrying after
pg_readv() or pg_writev() reports a short transfer.  This will gain new
users in a later commit, but can already replace the open-coded
equivalent code in the existing pg_pwritev_with_retry() function.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/CA+hUKGJkOiOCa+mag4BF+zHo7qo=o9CFheB8=g6uT5TUm2gkvA@mail.gmail.com

17 months agoDefine unconstify() and unvolatize() for C++.
Thomas Munro [Mon, 11 Dec 2023 20:31:44 +0000 (09:31 +1300)]
Define unconstify() and unvolatize() for C++.

These two macros wouldn't work if used in an inline function definition
in a header seen by g++, because __builtin_types_compatible_p is only
available in C.  Redirect to standard C++ const_cast (which also
adds/removes volatile despite its name).

Per cpluspluscheck failure in a development branch.

Suggested-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/CA%2BhUKGK3OXFjkOyZiw-DgL2bUqk9by1uGuCnViJX786W%2BfyDSw%40mail.gmail.com

17 months agoBe more wary about OpenSSL not setting errno on error.
Tom Lane [Mon, 11 Dec 2023 16:51:56 +0000 (11:51 -0500)]
Be more wary about OpenSSL not setting errno on error.

OpenSSL will sometimes return SSL_ERROR_SYSCALL without having set
errno; this is apparently a reflection of recv(2)'s habit of not
setting errno when reporting EOF.  Ensure that we treat such cases
the same as read EOF.  Previously, we'd frequently report them like
"could not accept SSL connection: Success" which is confusing, or
worse report them with an unrelated errno left over from some
previous syscall.

To fix, ensure that errno is zeroed immediately before the call,
and report its value only when it's not zero afterwards; otherwise
report EOF.

For consistency, I've applied the same coding pattern in libpq's
pqsecure_raw_read().  Bare recv(2) shouldn't really return -1 without
setting errno, but in case it does we might as well cope.

Per report from Andres Freund.  Back-patch to all supported versions.

Discussion: https://postgr.es/m/20231208181451.deqnflwxqoehhxpe@awork3.anarazel.de

17 months agoSimplify productions for FORMAT JSON [ ENCODING name ]
Alvaro Herrera [Mon, 11 Dec 2023 10:55:34 +0000 (11:55 +0100)]
Simplify productions for FORMAT JSON [ ENCODING name ]

This removes the production json_encoding_clause_opt, instead merging
it into json_format_clause.  Also remove the auxiliary
makeJsonEncoding() function.

Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/202312071841.u2gueb5dsrbk%40alvherre.pgsql

17 months agoRemove trace_recovery_messages
Michael Paquier [Mon, 11 Dec 2023 10:49:02 +0000 (11:49 +0100)]
Remove trace_recovery_messages

This GUC was intended as a debugging help in the 9.0 area when hot
standby and streaming replication were being developped, able to offer
more information at LOG level rather than DEBUGn.  There are more tools
available these days that are able to offer rather equivalent
information, like pg_waldump introduced in 9.3.  It is not obvious how
this facility is useful these days, so let's remove it.

Author: Bharath Rupireddy
Discussion: https://postgr.es/m/ZXEXEAUVFrvpquSd@paquier.xyz

17 months agoFix an undetected deadlock due to apply worker.
Amit Kapila [Mon, 11 Dec 2023 03:20:43 +0000 (08:50 +0530)]
Fix an undetected deadlock due to apply worker.

The apply worker needs to update the state of the subscription tables to
'READY' during the synchronization phase which requires locking the
corresponding subscription. The apply worker also waits for the
subscription tables to reach the 'SYNCDONE' state after holding the locks
on the subscription and the wait is done using WaitLatch. The 'SYNCDONE'
state is changed by tablesync workers again by locking the corresponding
subscription. Both the state updates use AccessShareLock mode to lock the
subscription, so they can't block each other. However, a backend can
simultaneously try to acquire a lock on the same subscription using
AccessExclusiveLock mode to alter the subscription. Now, the backend's
wait on a lock can sneak in between the apply worker and table sync worker
causing deadlock.

In other words, apply_worker waits for tablesync worker which waits for
backend, and backend waits for apply worker. This is not detected by the
deadlock detector because apply worker uses WaitLatch.

The fix is to release existing locks in apply worker before it starts to
wait for tablesync worker to change the state.

Reported-by: Tomas Vondra
Author: Shlok Kyal
Reviewed-by: Amit Kapila, Peter Smith
Backpatch-through: 12
Discussion: https://postgr.es/m/d291bb50-12c4-e8af-2af2-7bb9bb4d8e3e@enterprisedb.com

17 months agoRemove some unnecessary includes of "access/xlog_internal.h"
Peter Eisentraut [Sun, 10 Dec 2023 06:44:04 +0000 (07:44 +0100)]
Remove some unnecessary includes of "access/xlog_internal.h"

There were a few places where access/xlog_internal.h was apparently
included unnecessarily.  In some of those places, a more specific
header file (that somehow came in via access/xlog_internal.h) can be
used instead.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://www.postgresql.org/message-id/flat/a56a6eec-eb14-471b-9570-3cac23603964%40eisentraut.org

17 months agoFix nbtree backward scan race condition comments.
Peter Geoghegan [Fri, 8 Dec 2023 23:37:53 +0000 (15:37 -0800)]
Fix nbtree backward scan race condition comments.

Remove comments that supposed that holding a pin was a useful interlock
for _bt_walk_left().  There are times when _bt_walk_left() doesn't hold
either a lock or a pin on any page, so clearly this can't be true.
_bt_walk_left() is even prepared to deal with concurrent deletion of
both the original page and any pages to its left.

Oversight in commit 2ed5b87f96.

17 months agoMicro-optimize JSONTYPE_NUMERIC code path in json.c.
Nathan Bossart [Fri, 8 Dec 2023 19:39:08 +0000 (13:39 -0600)]
Micro-optimize JSONTYPE_NUMERIC code path in json.c.

This commit does the following:

* In datum_to_json_internal(), the call to IsValidJsonNumber() is
  replaced with simplified validation code.  This avoids an extra
  call to strlen() in this path, and it avoids validating the
  entire string (which is okay since we know we're dealing with a
  numeric data type's output).

* In datum_to_json_internal(), the call to escape_json() in the
  JSONTYPE_NUMERIC path is replaced with code that just surrounds
  the string with quotes.  In passing, some other nearby calls to
  appendStringInfo() have been replaced with similar code to avoid
  unnecessary calls to vsnprintf().

* In composite_to_json(), the length of the separator is now
  determined at compile time to avoid unnecessary calls to
  strlen().

On my machine, this speeds up a benchmark for the proposed COPY TO
(FORMAT json) command with many integers by upwards of 20%.  There
are likely other code paths that could be given a similar
treatment, but that is left as a future exercise.

Reviewed-by: Jeff Davis, Tom Lane, David Rowley, John Naylor
Discussion: https://postgr.es/m/20231207231251.GB3359478%40nathanxps13

17 months agoCache opaque handle for GUC option to avoid repeasted lookups.
Jeff Davis [Fri, 8 Dec 2023 19:16:01 +0000 (11:16 -0800)]
Cache opaque handle for GUC option to avoid repeasted lookups.

When setting GUCs from proconfig, performance is important, and hash
lookups in the GUC table are significant.

Per suggestion from Robert Haas.

Discussion: https://postgr.es/m/CA+TgmoYpKxhR3HOD9syK2XwcAUVPa0+ba0XPnwWBcYxtKLkyxA@mail.gmail.com
Reviewed-by: John Naylor
17 months agoOptimize nbtree backward scan boundary cases.
Peter Geoghegan [Fri, 8 Dec 2023 19:05:17 +0000 (11:05 -0800)]
Optimize nbtree backward scan boundary cases.

Teach _bt_binsrch (and related helper routines like _bt_search and
_bt_compare) about the initial positioning requirements of backward
scans.  Routines like _bt_binsrch already know all about "nextkey"
searches, so it seems natural to teach them about "goback"/backward
searches, too.  These concepts are closely related, and are much easier
to understand when discussed together.

Now that certain implementation details are hidden from _bt_first, it's
straightforward to add a new optimization: backward scans using the <
strategy now avoid extra leaf page accesses in certain "boundary cases".
Consider the following example, which uses the tenk1 table (and its
tenk1_hundred index) from the standard regression tests:

SELECT * FROM tenk1 WHERE hundred < 12 ORDER BY hundred DESC LIMIT 1;

Before this commit, nbtree would scan two leaf pages, even though it was
only really necessary to scan one leaf page.  We'll now descend straight
to the leaf page containing a (12, -inf) high key instead.  The scan
will locate matching non-pivot tuples with "hundred" values starting
from the value 11.  The scan won't waste a page access on the right
sibling leaf page, which cannot possibly contain any matching tuples.

You can think of the optimization added by this commit as disabling an
optimization (the _bt_compare "!pivotsearch" behavior that was added to
Postgres 12 in commit dd299df8) for a small subset of cases where it was
always counterproductive.

Equivalently, you can think of the new optimization as extending the
"pivotsearch" behavior that page deletion by VACUUM has long required
(since the aforementioned Postgres 12 commit went in) to other, similar
cases.  Obviously, this isn't strictly necessary for these new cases
(unlike VACUUM, _bt_first is prepared to move the scan to the left once
on the leaf level), but the underlying principle is the same.

Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/CAH2-Wz=XPzM8HzaLPq278Vms420mVSHfgs9wi5tjFKHcapZCEw@mail.gmail.com

17 months agoAllow parallel CREATE INDEX for BRIN indexes
Tomas Vondra [Fri, 8 Dec 2023 17:15:23 +0000 (18:15 +0100)]
Allow parallel CREATE INDEX for BRIN indexes

Allow using multiple worker processes to build BRIN index, which until
now was supported only for BTREE indexes. For large tables this often
results in significant speedup when the build is CPU-bound.

The work is split in a simple way - each worker builds BRIN summaries on
a subset of the table, determined by the regular parallel scan used to
read the data, and feeds them into a shared tuplesort which sorts them
by blkno (start of the range). The leader then reads this sorted stream
of ranges, merges duplicates (which may happen if the parallel scan does
not align with BRIN pages_per_range), and adds the resulting ranges into
the index.

The number of duplicate results produced by workers (requiring merging
in the leader process) should be fairly small, thanks to how parallel
scans assign chunks to workers. The likelihood of duplicate results may
increase for higher pages_per_range values, but then there are fewer
page ranges in total. In any case, we expect the merging to be much
cheaper than summarization, so this should be a win.

Most of the parallelism infrastructure is a simplified copy of the code
used by BTREE indexes, omitting the parts irrelevant for BRIN indexes
(e.g. uniqueness checks).

This also introduces a new index AM flag amcanbuildparallel, determining
whether to attempt to start parallel workers for the index build.

Original patch by me, with reviews and substantial reworks by Matthias
van de Meent, certainly enough to make him a co-author.

Author: Tomas Vondra, Matthias van de Meent
Reviewed-by: Matthias van de Meent
Discussion: https://postgr.es/m/c2ee7d69-ce17-43f2-d1a0-9811edbda6e6%40enterprisedb.com

17 months agoAdd empty BRIN ranges during CREATE INDEX
Tomas Vondra [Fri, 8 Dec 2023 16:07:30 +0000 (17:07 +0100)]
Add empty BRIN ranges during CREATE INDEX

When building BRIN indexes, the brinbuildCallback only advances to the
next page range when seeing a tuple that doesn't belong to the current
one. This means that the index may end up missing ranges at the end of
the table, if those pages do not contain any indexable tuples.

We tend not to have completely empty pages at the end of a relation, but
this also applies to partial indexes, where the tuples may simply not
match the index predicate. This results in inefficient scans using the
affected BRIN index - without the summaries, the page ranges have to be
read and processed, which consumes I/O and possibly also CPU time.

The existing code already added empty ranges for earlier parts of the
table, this commit makes sure we add them for the ranges at the end of
the table too.

Patch by Matthias van de Meent, with review/improvements by me.

Author: Matthias van de Meent
Reviewed-by: Tomas Vondra
Discussion: https://postgr.es/m/CAEze2WiMsPZg%3DxkvSF_jt4%3D69k6K7gz5B8V2wY3gCGZ%2B1BzCbQ%40mail.gmail.com

17 months agoDon't clean initdb files on template creation failure
Daniel Gustafsson [Fri, 8 Dec 2023 12:42:54 +0000 (13:42 +0100)]
Don't clean initdb files on template creation failure

Commit 252dcb32397f6 introduced initdb template caching to speed up
tests by re-using initdb output.  The initdb command didn't however
use the --no-clean option to preserve generated data in case initdb
crashes unlike pg_regress which does do this.  This adds the option
to initdb to aid debugging.

While changing the commandline, switch to using long options for
initdb to make the code more self-documenting.

Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/CAEze2WhSTjfK_M+Ea4GSQp8odrEOaQS8HyORd1TJUEiyXaB+rw@mail.gmail.com

17 months agoRemove some unnecessary #includes of postmaster/interrupt.h
Heikki Linnakangas [Fri, 8 Dec 2023 11:19:37 +0000 (13:19 +0200)]
Remove some unnecessary #includes of postmaster/interrupt.h

Commit 44fc6e259b removed a bunch of references to
SignalHandlerForCrashExit, leaving these #includes unneeded.

17 months agoTest that it works to RESET an invalid reloption
Alvaro Herrera [Fri, 8 Dec 2023 10:58:58 +0000 (11:58 +0100)]
Test that it works to RESET an invalid reloption

This works today, and it's valuable to ensure it doesn't get broken
if/when we get around to refactoring the implementation.

Author: Nikolay Shaplov <dhyan@nataraj.su>
Discussion: https://postgr.es/m/4563991.km65PDbjlG@thinkpad-pgpro

17 months agoRename ShmemVariableCache to TransamVariables
Heikki Linnakangas [Fri, 8 Dec 2023 07:47:15 +0000 (09:47 +0200)]
Rename ShmemVariableCache to TransamVariables

The old name was misleading: It's not a cache, the values kept in the
struct are the authoritative source.

Reviewed-by: Tristan Partin, Richard Guo
Discussion: https://www.postgresql.org/message-id/6537d63d-4bb5-46f8-9b5d-73a8ba4720ab@iki.fi

17 months agoInitialize ShmemVariableCache like other shmem areas
Heikki Linnakangas [Fri, 8 Dec 2023 07:46:59 +0000 (09:46 +0200)]
Initialize ShmemVariableCache like other shmem areas

For sake of consistency.

Reviewed-by: Tristan Partin, Richard Guo
Discussion: https://www.postgresql.org/message-id/6537d63d-4bb5-46f8-9b5d-73a8ba4720ab@iki.fi

17 months agoDon't try to open visibilitymap when analyzing a foreign table
Heikki Linnakangas [Fri, 8 Dec 2023 07:16:21 +0000 (09:16 +0200)]
Don't try to open visibilitymap when analyzing a foreign table

It's harmless, visibilitymap_count() returns 0 if the file doesn't
exist. But it's also very pointless. I noticed this when I added an
assertion in smgropen() that the relnumber is valid.

Discussion: https://www.postgresql.org/message-id/621a52fd-3cd8-4f5d-a561-d510b853bbaf@iki.fi

17 months agoFix potential pointer overflow in xlogreader.c.
Thomas Munro [Fri, 8 Dec 2023 02:10:48 +0000 (15:10 +1300)]
Fix potential pointer overflow in xlogreader.c.

While checking if a record could fit in the circular WAL decoding
buffer, the coding from commit 3f1ce973 used arithmetic that could
overflow.  64 bit systems were unaffected for various technical reasons,
which probably explains the lack of problem reports.  Likewise for 32
bit systems running known 32 bit kernels.  The systems at risk of
problems appear to be 32 bit processes running on 64 bit kernels, with
unlucky placement in memory.

Per complaint from GCC -fsanitize=undefined -m32, while testing
variations of 039_end_of_wal.pl.

Back-patch to 15.

Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGKH0oRPOX7DhiQ_b51sM8HqcPp2J3WA-Oen%3DdXog%2BAGGQ%40mail.gmail.com

17 months agodoc: clarify handling of ON CONFLICT with triggers
Bruce Momjian [Fri, 8 Dec 2023 02:35:29 +0000 (21:35 -0500)]
doc:  clarify handling of ON CONFLICT with triggers

The previous wording was confusing.  Also move partitioning mention to a
more logical location.

Reported-by: neil@fairwindsoft.com
Discussion: https://postgr.es/m/20170703200710.27956.64565@wrigleys.postgresql.org

Backpatch-through: master

17 months agoFix path of regress shared library in pg_upgrade test
Michael Paquier [Fri, 8 Dec 2023 01:36:23 +0000 (10:36 +0900)]
Fix path of regress shared library in pg_upgrade test

During a pg_upgrade test using an old dump, all references to the old
regress shared library path (so, dylib or dll) are updated to point to
the library path used by the new build, to ensure a consistent
comparison between the old and new dumps.

The test previously relied on a hardcoded value of "src/test/regress/"
to build the new path value, which would point to an incorrect location
for the meson and vpath builds.  This is replaced by REGRESS_SHLIB, able
to point to the correct location of the regress shared library.

Author: Alexander Lakhin
Discussion: https://postgr.es/m/a628d8ad-a08a-2eab-4ca9-641bc82d3193@gmail.com
Backpatch-through: 15

17 months agodoc, pg_upgrade: add vacuumdb w/ tips for generating quick stats
Bruce Momjian [Fri, 8 Dec 2023 01:06:23 +0000 (20:06 -0500)]
doc, pg_upgrade: add vacuumdb w/ tips for generating quick stats

Reported-by: Magnus Hagander
Discussion: https://postgr.es/m/CABUevEwGBY-W7EkTbjMY1rC+mmRL3fMrnX6YaUkcr+7o9PSa3w@mail.gmail.com

Backpatch-through: master

17 months agodoc: FOR UPDATE / KEY / SHARE / KEY SHARE takes an table alias
Bruce Momjian [Fri, 8 Dec 2023 00:43:04 +0000 (19:43 -0500)]
doc:  FOR UPDATE / KEY / SHARE / KEY SHARE takes an table alias

Previously only a table name was documented for this SELECT clause.

Reported-by: robert <lists@humanleg.org.uk>
Discussion: https://postgr.es/m/152483686904.19805.3369061025704720797@wrigleys.postgresql.org

Backpatch-through: master

17 months agodoc, intagg: fix one-to-many mention to many-to-many
Bruce Momjian [Fri, 8 Dec 2023 00:36:52 +0000 (19:36 -0500)]
doc, intagg:  fix one-to-many mention to many-to-many

Reported-by: Christophe Courtois
Discussion: https://postgr.es/m/aa7cfd73-0d8d-596a-b684-39faa479afa5@dalibo.com

Author: Christophe Courtois

Backpatch-through: master

17 months agoShrink Unicode category table.
Jeff Davis [Thu, 7 Dec 2023 23:44:03 +0000 (15:44 -0800)]
Shrink Unicode category table.

Missing entries can implicitly be considered "unassigned".

Discussion: https://postgr.es/m/ff4c2f2f9c8fc7ca27c1c24ae37ecaeaeaff6b53.camel@j-davis.com

17 months agoVerify that attribute counts match in ExecCopySlot
David Rowley [Thu, 7 Dec 2023 08:28:24 +0000 (21:28 +1300)]
Verify that attribute counts match in ExecCopySlot

tts_virtual_copyslot() contained an Assert that checked that the srcslot
contained <= attributes than the dstslot.  This seems to be backwards as
if the srcslot contained fewer attributes then the dstslot could be left
with stale Datum values from the previously stored tuple.  It might make
more sense to allow the source to contain additional attributes and only
copy the leading ones that also exist in the destination, however, that's
not what we're doing here.

Here we just remove the Assert from tts_virtual_copyslot() and add an
Assert to ExecCopySlot() to verify the attribute counts match.  There
does not seem to be any places where the destination contains fewer
attributes, so instead of going to the trouble of making the code
properly handle this, let's just ensure the attribute counts match.  If
this Assert fails then that will indicate that we do have cases that
require us to handle the srcslot with more attributes than the dstslot.
It seems better to only write this code if there's a genuine requirement
for it rather than write it now only to leave it untested.

Thanks to Andres Freund for helping with the analysis of this.

Discussion: https://postgr.es/m/CAApHDvpMAvBL0T+TRORquyx1iqFQKMVTXtqNocOw0Pa2uh1heg@mail.gmail.com

17 months agoImprove some error messages with invalid indexes for REINDEX CONCURRENTLY
Michael Paquier [Thu, 7 Dec 2023 05:27:54 +0000 (14:27 +0900)]
Improve some error messages with invalid indexes for REINDEX CONCURRENTLY

An invalid index is skipped when doing REINDEX CONCURRENTLY at table
level, with INDEX_CORRUPTED used as errcode.  This is confusing,
because an invalid index could exist after an interruption.  The errcode
is switched to OBJECT_NOT_IN_PREREQUISITE_STATE instead, as per a
suggestion from Andres Freund.

While on it, the error messages are reworded, and a hint is added,
telling how to rebuild an invalid index in this case.  This has been
suggested by Noah Misch.

Discussion: https://postgr.es/m/20231118230958.4fm3fhk4ypshxopa@awork3.anarazel.de

17 months agoFix issues in binary_upgrade_logical_slot_has_caught_up().
Amit Kapila [Thu, 7 Dec 2023 03:12:48 +0000 (08:42 +0530)]
Fix issues in binary_upgrade_logical_slot_has_caught_up().

The commit 29d0a77fa6 labelled binary_upgrade_logical_slot_has_caught_up()
as a non-strict function to allow providing a better error message to callers
in case the passed slot_name is NULL. On further discussion, it seems that
it is not helpful to have a different error message for NULL input in this
function, so this patch marks the function as strict.

This patch also removes the explicit permission check to use replication
slots as this function is invoked only by superusers and instead adds an
Assert.

Reported-by: Masahiko Sawada
Author: Hayato Kuroda
Reviewed-by: Vignesh C
Discussion: https://postgr.es/m/CAD21AoDSyiBKkMXBxN_gUayZZUCOgyHnG8Ge8rcPXNP3Tf6B4g@mail.gmail.com

17 months agoFix assertion failure with REINDEX and event triggers
Michael Paquier [Wed, 6 Dec 2023 23:31:02 +0000 (08:31 +0900)]
Fix assertion failure with REINDEX and event triggers

A REINDEX CONCURRENTLY run on a table with no indexes would always pop
the topmost snapshot from the active snapshot stack, making the snapshot
handling inconsistent between the multiple-relation and single-relation
cases.  This commit slightly changes the snapshot stack handling so as a
snapshot is popped only ReindexMultipleInternal() in this case after a
relation has been reindexed, fixing a problem where an event trigger
function may need a snapshot but does not have one.  This also keeps the
places where PopActiveSnapshot() is called closer to each other.

While on it, this expands the existing tests to cover all the cases that
could be faced with REINDEX commands and such event triggers, for one or
more relations, with or without indexes.

This behavior is inconsistent since 5dc92b844e68, but we've never had a
need for an active snapshot at the end of a REINDEX until now.

Thanks also to Jian He for the input.

Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/cb538743-484c-eb6a-a8c5-359980cd3a17@gmail.com

17 months agoSuppress -Wunused-result warning about write().
Nathan Bossart [Wed, 6 Dec 2023 23:16:57 +0000 (17:16 -0600)]
Suppress -Wunused-result warning about write().

pg_test_fsync's signal_cleanup() intentionally ignores the write()
result since there's not much we could do about it, but certain
compilers make that harder than it ought to be.

This was missed in commit 52e98d4502.

Reviewed-by: Tristan Partin, Peter Eisentraut
Discussion: https://postgr.es/m/20231206161839.GA2828158%40nathanxps13

17 months agoUse signal-safe functions in signal handler
Peter Eisentraut [Wed, 6 Dec 2023 09:11:36 +0000 (10:11 +0100)]
Use signal-safe functions in signal handler

According to signal-safety(7), exit(3) and puts(3) are not safe to call
in a signal handler.

Author: Tristan Partin <tristan@neon.tech>
Discussion: https://www.postgresql.org/message-id/flat/CTVDKVZCCVSY.1XQ87UL50KQRD%40gonk

17 months agoFix compilation on Windows with WAL_DEBUG
Michael Paquier [Wed, 6 Dec 2023 05:10:39 +0000 (14:10 +0900)]
Fix compilation on Windows with WAL_DEBUG

This has been broken since b060dbe0001a that has reworked the callback
mechanism of XLogReader, most likely unnoticed because any form of
development involving WAL happens on platforms where this compiles fine.

Author: Bharath Rupireddy
Discussion: https://postgr.es/m/CALj2ACVF14WKQMFwcJ=3okVDhiXpuK5f7YdT+BdYXbbypMHqWA@mail.gmail.com
Backpatch-through: 13

17 months agoApply filters to dump files all the time in 002_pg_upgrade.pl
Michael Paquier [Wed, 6 Dec 2023 00:54:47 +0000 (09:54 +0900)]
Apply filters to dump files all the time in 002_pg_upgrade.pl

This commit removes the restriction that would not apply filters to the
dumps used for comparison in the TAP test of pg_upgrade when using the
same base version for the old and new nodes.

The previous logic would fail on Windows if loading a dump while using
the same set of binaries for the old and new nodes, as the library
dependencies updated in the old dump would append CRLFs to the dump
file as it is treated as a text file.  The dump filtering logic replaces
all CRLFs (\r\n) by LFs (\n), which is able to prevent this issue.

When the old and new versions of the binaries are the same,
AdjustUpgrade removes all blank lines, removes version-based comments
generated by pg_dump and replaces CRLFs by LFs.

Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/60d434b9-53d9-9ea1-819b-efebdcf44e41@gmail.com
Backpatch-through: 15

17 months agoAdd support for deparsing semi-joins to contrib/postgres_fdw
Alexander Korotkov [Tue, 5 Dec 2023 20:53:12 +0000 (22:53 +0200)]
Add support for deparsing semi-joins to contrib/postgres_fdw

SEMI-JOIN is deparsed as the EXISTS subquery. It references outer and inner
relations, so it should be evaluated as the condition in the upper-level WHERE
clause. The signatures of deparseFromExprForRel() and deparseRangeTblRef() are
revised so that they can add conditions to the upper level.

PgFdwRelationInfo now has a hidden_subquery_rels field, referencing the relids
used in the inner parts of semi-join.  They can't be referred to from upper
relations and should be used internally for equivalence member searches.

The planner can create semi-join, which refers to inner rel vars in its target
list. However, we deparse semi-join as an exists() subquery. So we skip the
case when the target list references to inner rel of semi-join.

Author: Alexander Pyhalov
Reviewed-by: Ashutosh Bapat, Ian Lawrence Barwick, Yuuki Fujii, Tomas Vondra
Discussion: https://postgr.es/m/c9e2a757cf3ac2333714eaf83a9cc184@postgrespro.ru

17 months agoRename pg_verifybackup's JsonManifestParseContext callback functions.
Robert Haas [Tue, 5 Dec 2023 17:51:39 +0000 (12:51 -0500)]
Rename pg_verifybackup's JsonManifestParseContext callback functions.

The old names were too generic, and would have applied to any binary
that made use of JsonManifestParseContext. Rename to make the names
specific to pg_verifybackup, since there are plans afoot to reuse
this infrastructure.

Per suggestion from Álvaro Herrra.

Discussion: http://postgr.es/m/202311131625.o7hzq3oukuyd@alvherre.pgsql

17 months agoRename JsonManifestParseContext callbacks.
Robert Haas [Tue, 5 Dec 2023 17:17:49 +0000 (12:17 -0500)]
Rename JsonManifestParseContext callbacks.

There is no real reason to just run multiple words together when
we can instead punctuate them with marks intended for that purpose.

Per suggestion from Álvaro Herrera.

Discussion: http://postgr.es/m/202311161021.nisg7imt7kyf@alvherre.pgsql

17 months agoFix indentation
Daniel Gustafsson [Tue, 5 Dec 2023 14:54:59 +0000 (15:54 +0100)]
Fix indentation

When preparing commit 98e675ed7af I accidentally forgot to run
pgindent, which did produce a diff. Fix by adding the required
whitespace per the koel buildfarm failure.

17 months agoFix incorrect error message for IDENTIFY_SYSTEM
Daniel Gustafsson [Tue, 5 Dec 2023 13:30:56 +0000 (14:30 +0100)]
Fix incorrect error message for IDENTIFY_SYSTEM

Commit 5a991ef8692e accidentally reversed the order of the tuples
and fields parameters, making the error message incorrectly refer
to 3 tuples with 1 field when IDENTIFY_SYSTEM returns 1 tuple and
3 or 4 fields. Fix by changing the order of the parameters.  This
also adds a comment describing why we check for < 3 when postgres
since 9.4 has been sending 4 fields.

Backpatch all the way since the bug is almost a decade old.

Author: Tomonari Katsumata <t.katsumata1122@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Bug: #18224
Backpatch-through: v12

17 months agoFix handling of errors in libpq pipelines
Alvaro Herrera [Tue, 5 Dec 2023 11:43:24 +0000 (12:43 +0100)]
Fix handling of errors in libpq pipelines

The logic to keep the libpq command queue in sync with queries that have
been processed had a bug when errors were returned for reasons other
than problems in queries -- for example, when a connection is lost.  We
incorrectly consumed an element from the command queue every time, but
this is wrong and can lead to the queue becoming empty ahead of time,
leading to later malfunction: PQgetResult would return nothing,
potentially causing the calling application to enter a busy loop.

Fix by making the SYNC queue element a barrier that can only be consumed
when a SYNC message is received.

Backpatch to 14.

Reported by: Иван Трофимов (Ivan Trofimov) <i.trofimow@yandex.ru>
Discussion: https://postgr.es/m/17948-fcace7557e449957@postgresql.org

17 months agoFix a random failure in 003_logical_slots.pl.
Amit Kapila [Tue, 5 Dec 2023 03:40:06 +0000 (09:10 +0530)]
Fix a random failure in 003_logical_slots.pl.

The failed test was trying to validate that the two_phase option for a
slot is retained after the upgrade. The problem was that it didn't get
enabled before the upgrade so expecting to be enabled after the upgrade
was not right in the first place. This is a timing issue because we enable
the two_phase once the initial sync for all the tables is finished.
Normally, we wait for the two_phase state to be enabled but this test
missed that step.

Per buildfarm.

Author: Hayato Kuroda
Discussion: https://postgr.es/m/TY3PR01MB98892396D1071FC4320D6B31F586A@TY3PR01MB9889.jpnprd01.prod.outlook.com

17 months agoOptimize SearchPathCache by saving the last entry.
Jeff Davis [Tue, 5 Dec 2023 01:19:16 +0000 (17:19 -0800)]
Optimize SearchPathCache by saving the last entry.

Repeated lookups are common, so it's worth it to check the last entry
before doing another hash lookup.

Discussion: https://postgr.es/m/04c8592dbd694e4114a3ed87139a7a04e4363030.camel%40j-davis.com

17 months agoTeach convert() and friends to avoid copying when possible.
Nathan Bossart [Mon, 4 Dec 2023 17:55:18 +0000 (11:55 -0600)]
Teach convert() and friends to avoid copying when possible.

Presently, pg_convert() allocates a new bytea and copies the result
regardless of whether any conversion actually happened.  This
commit adjusts this function to return the source pointer as-is if
no conversion occurred.  This optimization isn't expected to make a
tremendous difference, but it still seems worthwhile to avoid
unnecessary memory allocations.

Author: Yurii Rashkovskii
Reviewed-by: Bertrand Drouvot
Discussion: https://postgr.es/m/CA%2BRLCQyknBPSWXRBQGOi6aYEcdQ9RpH9Kch4GjoeY8dQ3D%2Bvhw%40mail.gmail.com

17 months agoRemove now-unnecessary Autovacuum[Launcher|Worker]IAm functions
Heikki Linnakangas [Mon, 4 Dec 2023 13:34:37 +0000 (15:34 +0200)]
Remove now-unnecessary Autovacuum[Launcher|Worker]IAm functions

After commit fd5e8b440d, InitProcess() is called later in the
EXEC_BACKEND startup sequence, so it's enough to set the
am_autovacuum_[launcher|worker] variables at the same place as in the
!EXEC_BACKEND case.

17 months agoDon't use pgbench -j in tests
Alvaro Herrera [Mon, 4 Dec 2023 13:00:51 +0000 (14:00 +0100)]
Don't use pgbench -j in tests

It draws an unnecessary error in builds compiled without thread support.

Added by commit 038f586d5f1d, which was backpatched to 14; though in
branch master we no longer support such builds, there's no reason to
have this there, so remove it in all branches since 14.

Reported-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/ZW2G9Ix4nBKLcSSO@paquier.xyz

17 months agoRemove unnecessary include of <math.h>
Peter Eisentraut [Mon, 4 Dec 2023 05:34:27 +0000 (06:34 +0100)]
Remove unnecessary include of <math.h>

This was probably never necessary.  (The header used to use random(),
but that shouldn't require <math.h> either.  In any case, that's gone,
too.)

Reviewed-by: Shubham Khanna <Shubham.Khanna@fujitsu.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/cff5475d-e0a9-4561-b094-794aa36bd031%40eisentraut.org

17 months agoRemove unnecessary include of <sys/socket.h>
Peter Eisentraut [Mon, 4 Dec 2023 05:34:27 +0000 (06:34 +0100)]
Remove unnecessary include of <sys/socket.h>

This was put here as part of a mechanical replacement of the old
"getaddrinfo.h" with <netdb.h> plus <sys/socket.h> (commit
5579388d2d).  But here, we only need netdb.h (for NI_MAXHOST), not
sys/socket.h.

Reviewed-by: Shubham Khanna <Shubham.Khanna@fujitsu.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/cff5475d-e0a9-4561-b094-794aa36bd031%40eisentraut.org

17 months agoRemove unnecessary includes of <signal.h>
Peter Eisentraut [Mon, 4 Dec 2023 05:34:27 +0000 (06:34 +0100)]
Remove unnecessary includes of <signal.h>

These were once needed for sig_atomic_t, but that no longer appears in
these headers, so the include is not needed.

Reviewed-by: Shubham Khanna <Shubham.Khanna@fujitsu.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/cff5475d-e0a9-4561-b094-794aa36bd031%40eisentraut.org

17 months agoAdd support for REINDEX in event triggers
Michael Paquier [Mon, 4 Dec 2023 00:53:49 +0000 (09:53 +0900)]
Add support for REINDEX in event triggers

This commit adds support for REINDEX in event triggers, making this
command react for the events ddl_command_start and ddl_command_end.  The
indexes rebuilt are collected with the ReindexStmt emitted by the
caller, for the concurrent and non-concurrent paths.

Thanks to that, it is possible to know a full list of the indexes that a
single REINDEX command has worked on.

Author: Garrett Thornburg, Jian He
Reviewed-by: Jim Jones, Michael Paquier
Discussion: https://postgr.es/m/CAEEqfk5bm32G7sbhzHbES9WejD8O8DCEOaLkxoBP7HNWxjPpvg@mail.gmail.com

17 months agodoc: Remove reference to trigger file regarding promotion
Michael Paquier [Sun, 3 Dec 2023 23:09:51 +0000 (08:09 +0900)]
doc: Remove reference to trigger file regarding promotion

The wording changed here comes from 991bfe11d28a, when the only way to
trigger a promotion was with a trigger file.  There are more options to
achieve this operation these days, like the SQL function pg_promote() or
the command `pg_ctl promote`, so it is confusing to assume that only a
trigger file is able to do the work.

Note also that promote_trigger_file has been removed as of cd4329d9393f
in 16~.

Author: Shinya Kato
Discussion: https://postgr.es/m/201b08ea29aa61f96162080e75be503c@oss.nttdata.com
Backpatch-through: 12

17 months agoRefactor how InitProcess is called
Heikki Linnakangas [Sun, 3 Dec 2023 14:39:18 +0000 (16:39 +0200)]
Refactor how InitProcess is called

The order of process initialization steps is now more consistent
between !EXEC_BACKEND and EXEC_BACKEND modes. InitProcess() is called
at the same place in either mode. We can now also move the
AttachSharedMemoryStructs() call into InitProcess() itself. This
reduces the number of "#ifdef EXEC_BACKEND" blocks.

Reviewed-by: Tristan Partin, Andres Freund, Alexander Lakhin
Discussion: https://www.postgresql.org/message-id/7a59b073-5b5b-151e-7ed3-8b01ff7ce9ef@iki.fi

17 months agoPass BackgroundWorker entry in the parameter file in EXEC_BACKEND mode
Heikki Linnakangas [Sun, 3 Dec 2023 14:38:54 +0000 (16:38 +0200)]
Pass BackgroundWorker entry in the parameter file in EXEC_BACKEND mode

The BackgroundWorker struct is now passed the same way as the Port
struct. Seems more consistent.

This makes it possible to move InitProcess later in SubPostmasterMain
(in next commit), as we no longer need to access shared memory to read
background worker entry.

Reviewed-by: Tristan Partin, Andres Freund, Alexander Lakhin
Discussion: https://www.postgresql.org/message-id/7a59b073-5b5b-151e-7ed3-8b01ff7ce9ef@iki.fi

17 months agoRefactor CreateSharedMemoryAndSemaphores
Heikki Linnakangas [Sun, 3 Dec 2023 14:09:42 +0000 (16:09 +0200)]
Refactor CreateSharedMemoryAndSemaphores

For clarity, have separate functions for *creating* the shared memory
and semaphores at postmaster or single-user backend startup, and
for *attaching* to existing shared memory structures in EXEC_BACKEND
case. CreateSharedMemoryAndSemaphores() is now called only at
postmaster startup, and a new AttachSharedMemoryStructs() function is
called at backend startup in EXEC_BACKEND mode.

Reviewed-by: Tristan Partin, Andres Freund
Discussion: https://www.postgresql.org/message-id/7a59b073-5b5b-151e-7ed3-8b01ff7ce9ef@iki.fi

17 months agoSilence Valgrind complaint with EXEC_BACKEND
Heikki Linnakangas [Fri, 1 Dec 2023 20:30:08 +0000 (22:30 +0200)]
Silence Valgrind complaint with EXEC_BACKEND

The padding bytes written to the backend params file were
uninitialized. That's harmless because we don't access the padding
bytes when we read the file back in, but Valgrind doesn't know
that. In any case, clear the padding bytes to make Valgrind happy.

Reported-by: Alexander Lakhin
Discussion: https://www.postgresql.org/message-id/014768ed-8b39-c44f-b07c-098c87b1644c@gmail.com

17 months agopgindent fix
Peter Eisentraut [Fri, 1 Dec 2023 16:58:18 +0000 (17:58 +0100)]
pgindent fix

for commit a11c9c42ea

17 months agoCheck collation when creating partitioned index
Peter Eisentraut [Fri, 1 Dec 2023 14:48:06 +0000 (15:48 +0100)]
Check collation when creating partitioned index

When creating a partitioned index, the partition key must be a subset
of the index's columns.  But this currently doesn't check that the
collations between the partition key and the index definition match.
So you can construct a unique index that fails to enforce uniqueness.
(This would most likely involve a nondeterministic collation, so it
would have to be crafted explicitly and is not something that would
just happen by accident.)

This patch adds the required collation check.  As a result, any
previously allowed unique index that has a collation mismatch would no
longer be allowed to be created.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/3327cb54-f7f1-413b-8fdb-7a9dceebb938%40eisentraut.org

17 months agodoc: Update info on information schema usage tables
Peter Eisentraut [Fri, 1 Dec 2023 07:40:45 +0000 (08:40 +0100)]
doc: Update info on information schema usage tables

Commit f40c6969d0 added the information schema usage tables but added
documentation that they did not fully work yet.  Commit e717a9a18b
then added SQL-standard function bodies, which made the information
schema views fully functional, but it neglected to update the
documentation.  This is now done here.

Reported-by: Erki Eessaar <erki.eessaar@taltech.ee>
Reviewed-by: Erki Eessaar <erki.eessaar@taltech.ee>
Discussion: https://www.postgresql.org/message-id/flat/AM9PR01MB8268EC7B696F9FE346CA5B93FEB8A%40AM9PR01MB8268.eurprd01.prod.exchangelabs.com

17 months agoFix an uninitialized access in hash_xlog_squeeze_page().
Amit Kapila [Fri, 1 Dec 2023 04:44:36 +0000 (10:14 +0530)]
Fix an uninitialized access in hash_xlog_squeeze_page().

Commit 861f86beea changed hash_xlog_squeeze_page() to start reading
the write buffer conditionally but forgot to initialize it leading to an
uninitialized access.

Reported-by: Alexander Lakhin
Author: Hayato Kuroda
Reviewed-by: Alexander Lakhin, Amit Kapila
Discussion: http://postgr.es/m/62ed1a9f-746a-8e86-904b-51b9b806a1d9@gmail.com

17 months agomeson: Stop using deprecated way getting path of files
Andres Freund [Fri, 1 Dec 2023 01:43:39 +0000 (17:43 -0800)]
meson: Stop using deprecated way getting path of files

The just released meson 1.3 strongly deprecated a hack we were using, emitting
a noisy warning (the hack basically depended on an implementation detail to
work). Turns out there has been a better way available for a while, I just
hadn't found it. 1.4 added a more convenient approach, but we can't rely on
that.

Reviewed-by: Tristan Partin <tristan@neon.tech>
Discussion: https://postgr.es/m/20231129185053.s6c7f73eg7b4ztfi@awork3.anarazel.de
Backpatch: 16-, where the meson build was added.

17 months agoAdjust obsolete comment explaining set_stack_base().
Thomas Munro [Fri, 1 Dec 2023 01:58:40 +0000 (14:58 +1300)]
Adjust obsolete comment explaining set_stack_base().

Commit 7389aad6 removed the notion of backends started from inside a
signal handler.  A stray comment still referred to them, while
explaining the need for a call to set_stack_base().  That leads to the
question of whether we still need the call in !EXEC_BACKEND builds.
There doesn't seem to be much point in suppressing it now, as it doesn't
hurt and probably helps to measure the stack base from the exact same
place in EXEC_BACKEND and !EXEC_BACKEND builds.

Back-patch to 16.

Reported-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reported-by: Tristan Partin <tristan@neon.tech>
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKG%2BEJHcevNGNOxVWxTNFbuB%3Dvjf4U68%2B85rAC_Sxvy2zEQ%40mail.gmail.com

17 months agoPrint lwlock stats also for aux processes, when built with LWLOCK_STATS
Heikki Linnakangas [Thu, 30 Nov 2023 23:00:03 +0000 (01:00 +0200)]
Print lwlock stats also for aux processes, when built with LWLOCK_STATS

InitAuxiliaryProcess() closely resembles InitProcess(), but it didn't
call InitLWLockAccess(). But because InitLWLockAccess() is a no-op
unless compiled with LWLOCK_STATS, and everything works even if it's
not called, the only consequence was that the stats were not printed
for aux processes.

This was an oversight in commit 1c6821be31f, in version 9.5, so it is
missing in all supported branches. But since it only affects
developers using LWLOCK_STATS and no one has complained, no
backpatching.

Discussion: https://www.postgresql.org/message-id/20231130202648.7k6agmuizdilufnv@awork3.anarazel.de

17 months agoFix typo in 5a1dfde8334b
Alexander Korotkov [Thu, 30 Nov 2023 11:45:28 +0000 (13:45 +0200)]
Fix typo in 5a1dfde8334b

Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/55d8800f-4a80-5256-1e84-246fbe79acd0@gmail.com

17 months agoFix spelling and punctuation
Daniel Gustafsson [Thu, 30 Nov 2023 09:56:53 +0000 (10:56 +0100)]
Fix spelling and punctuation

Remove trailing periods from pg_log_error emitted strings as only
hint and detail level error messages should be punctuated.  Also
reword the usage screen which was missing a word.

Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/20231130.105223.554982964895179414.horikyota.ntt@gmail.com
Discussion: https://postgr.es/m/20231130.103900.2069212175914114279.horikyota.ntt@gmail.com

17 months agoAdd missing file to nls Makefile
Daniel Gustafsson [Thu, 30 Nov 2023 09:56:51 +0000 (10:56 +0100)]
Add missing file to nls Makefile

Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/20231130.120009.1370713511317755874.horikyota.ntt@gmail.com

17 months agoFix array subscript warnings
Daniel Gustafsson [Thu, 30 Nov 2023 09:56:48 +0000 (10:56 +0100)]
Fix array subscript warnings

Commit a5cf808be55 accidentally passed signed chars to isalpha and
isspace in the parser code which leads to undefined behavior.  Fix
by casting the parameters to unsigned chars.

Author: Pavel Stehule <pavel.stehule@gmail.com>
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Reported-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/388186.1701315586@sss.pgh.pa.us
Discussion: https://postgr.es/m/ZWgg5xim2CXQcfmh@paquier.xyz

17 months agoFix warning due non-standard inline declaration in 4ed8f0913bfdb5f355
Alexander Korotkov [Thu, 30 Nov 2023 09:34:45 +0000 (11:34 +0200)]
Fix warning due non-standard inline declaration in 4ed8f0913bfdb5f355

Reported-by: Alexander Lakhin, Tom Lane
Author: Pavel Borisov
Discussion: https://postgr.es/m/55d8800f-4a80-5256-1e84-246fbe79acd0@gmail.com

17 months agoRemove redundant setting of hashkey after insertion
John Naylor [Thu, 30 Nov 2023 08:25:57 +0000 (15:25 +0700)]
Remove redundant setting of hashkey after insertion

It's not necessary to fill the key field in most cases, since
hash_search has already done that. Some existing call sites have an
assert or comment that this contract has been fulfilled, but those
are quite old and that practice seems unnecessary here.

While at it, remove a nearby redundant assignment that a smart compiler
will elide anyway.

Zhao Junwang, with some adjustments by me

Reviewed by Nathan Bossart, with additional feedback from Tom Lane

Discussion: http://postgr.es/m/CAEG8a3%2BUPF%3DR2QGPgJMF2mKh8xPd1H2TmfH77zPuVUFdBpiGUA%40mail.gmail.com

17 months agomeson: Improve/fix Python version selection
Peter Eisentraut [Thu, 30 Nov 2023 06:22:51 +0000 (07:22 +0100)]
meson: Improve/fix Python version selection

When we look for the Python installation using the meson python
module, we should make it use the python program previously determined
by the 'PYTHON' option.  Otherwise, it will just use its own search
and the 'PYTHON' option won't affect it.  We need this to be able to
select the Python installation to build PL/Python against.

Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/3f5427e8-cef6-474d-ae88-13db1bfdc1a7%40eisentraut.org

17 months agoAdd tests for XID wraparound.
Masahiko Sawada [Thu, 30 Nov 2023 05:29:48 +0000 (14:29 +0900)]
Add tests for XID wraparound.

The test module includes helper functions to quickly burn through lots
of XIDs. They are used in the tests, and are also handy for manually
testing XID wraparound.

Since these tests are very expensive the entire suite is disabled by
default. It requires to set PG_TEST_EXTRA to run it.

Reviewed-by: Daniel Gustafsson, John Naylor, Michael Paquier
Reviewed-by: vignesh C
Author: Heikki Linnakangas, Masahiko Sawada, Andres Freund
Discussion: https://www.postgresql.org/message-id/CAD21AoDVhkXp8HjpFO-gp3TgL6tCKcZQNxn04m01VAtcSi-5sA%40mail.gmail.com

17 months agodoc: Mention how to use quotes with GUC names in error messages
Michael Paquier [Thu, 30 Nov 2023 05:19:29 +0000 (14:19 +0900)]
doc: Mention how to use quotes with GUC names in error messages

Quotes should not be used except if a GUC name is a natural English
word.

Author: Álvaro Herrera
Discussion: https://postgr.es/m/CAHut+Pv-kSN8SkxSdoHano_wPubqcg5789ejhCDZAcLFceBR-w@mail.gmail.com

17 months agoApply quotes more consistently to GUC names in logs
Michael Paquier [Thu, 30 Nov 2023 05:11:45 +0000 (14:11 +0900)]
Apply quotes more consistently to GUC names in logs

Quotes are applied to GUCs in a very inconsistent way across the code
base, with a mix of double quotes or no quotes used.  This commit
removes double quotes around all the GUC names that are obviously
referred to as parameters with non-English words (use of underscore,
mixed case, etc).

This is the result of a discussion with Álvaro Herrera, Nathan Bossart,
Laurenz Albe, Peter Eisentraut, Tom Lane and Daniel Gustafsson.

Author: Peter Smith
Discussion: https://postgr.es/m/CAHut+Pv-kSN8SkxSdoHano_wPubqcg5789ejhCDZAcLFceBR-w@mail.gmail.com

17 months agoAdd option to specify timeout seconds to BackgroundPsql.pm.
Masahiko Sawada [Thu, 30 Nov 2023 05:08:34 +0000 (14:08 +0900)]
Add option to specify timeout seconds to BackgroundPsql.pm.

Previously, a background psql session uses the default timeout and it
cannot be overridden. This change adds a new option to set the timeout
during start.

There are no users of this new option. It is needed for an upcoming
patch adding tests for XID wraparound.

Reviewed-by: Daniel Gustafsson, Noah Misch
Discussion: https://postgr.es/m/C9CF2F76-0D81-4C9D-9832-202BE8517056%40yesql.se

17 months agoRemove unused macro
Peter Eisentraut [Thu, 30 Nov 2023 05:00:44 +0000 (06:00 +0100)]
Remove unused macro

Usage was removed in a33e17f210 but the definition was not removed.

17 months agoImprove "user mapping not found" error message
Peter Eisentraut [Thu, 30 Nov 2023 04:33:55 +0000 (05:33 +0100)]
Improve "user mapping not found" error message

Display the name of the foreign server for which the user mapping was
not found.

Author: Ian Lawrence Barwick <barwick@gmail.com>
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/CAB8KJ=jFzNaeyFtLcTZNOc6fd1+F93pGVLFa-wyt31wn7VNxqQ@mail.gmail.com

17 months agoFix a test in 003_logical_slots.
Amit Kapila [Thu, 30 Nov 2023 04:01:21 +0000 (09:31 +0530)]
Fix a test in 003_logical_slots.

We allow to upgrade the slot iff there is no pending WAL to be processed.
The test first disables the subscription to avoid unnecessary LOGs on the
subscriber and then stops the publisher node. It is quite possible that
just before the shutdown of the publisher, autovacuum generates some WAL
record that needs to be processed, so just disable the autovacuum for this
test.

Per buildfarm.

Author: Hayato Kuroda
Reviewed-by: Amit Kapila
Discussion: http://postgr.es/m/OS3PR01MB9882FED1F0060468FB01B9DAF583A@OS3PR01MB9882.jpnprd01.prod.outlook.com

17 months agoFix wrong description of BackgroundPsql's timeout.
Masahiko Sawada [Thu, 30 Nov 2023 02:23:00 +0000 (11:23 +0900)]
Fix wrong description of BackgroundPsql's timeout.

Backpatch through 16 where this was introduced by 664d757531e1.

Reviewed-by: Daniel Gustafsson
Backpatch-through: 16
Discussion: http://postgr.es/m/CAD21AoBXMEqDBLoDuAWVWoTLYB4aNsxx4oYNmyJJbhfq_vGQBQ@mail.gmail.com

17 months agoFix BackgroundPsql's set_query_timer_restart() issue without argument.
Masahiko Sawada [Thu, 30 Nov 2023 01:14:17 +0000 (10:14 +0900)]
Fix BackgroundPsql's set_query_timer_restart() issue without argument.

The set_query_timer_restart() required an argument to define a value
to query_timer_restart, but none of the existing callers passes an
argument to this function.

This changes the function to set a value without an argument.

Backpatch through 16 where the background psql TAP functions were
refactored by 664d757531e1.

Reviewed-by: Bharath Rupireddy, Tom Lane
Discussion: https://postgr.es/m/CAD21AoA0B6VKe_5A9nZi8i5umwSN-zJJuPVNht9DaOZ9SJumMA@mail.gmail.com
Backpatch-through: 16

17 months agoFix typo in comment
Daniel Gustafsson [Wed, 29 Nov 2023 13:56:26 +0000 (14:56 +0100)]
Fix typo in comment

Spotted while looking over changes for another patch.

17 months agoRead include/exclude commands for dump/restore from file
Daniel Gustafsson [Wed, 29 Nov 2023 13:56:24 +0000 (14:56 +0100)]
Read include/exclude commands for dump/restore from file

When there is a need to filter multiple tables with include and/or exclude
options it's quite possible to run into the limitations of the commandline.
This adds a --filter=FILENAME feature to pg_dump, pg_dumpall and pg_restore
which is used to supply a file containing object exclude/include commands
which work just like their commandline counterparts. The format of the file
is one command per row like:

    <command> <object> <objectpattern>

<command> can be "include" or "exclude", <object> can be table_data, index
table_data_and_children, database, extension, foreign_data, function, table
schema, table_and_children or trigger.

This patch has gone through many revisions and design changes over a long
period of time, the list of reviewers reflect reviewers of some version of
the patch, not necessarily the final version.

Patch by Pavel Stehule with some additional hacking by me.

Author: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Reviewed-by: Erik Rijkers <er@xs4all.nl>
Discussion: https://postgr.es/m/CAFj8pRB10wvW0CC9Xq=1XDs=zCQxer3cbLcNZa+qiX4cUH-G_A@mail.gmail.com

17 months agoOptimize pg_readv/pg_pwritev single vector case.
Thomas Munro [Wed, 29 Nov 2023 03:44:19 +0000 (16:44 +1300)]
Optimize pg_readv/pg_pwritev single vector case.

For the trivial case of iovcnt == 1, kernels are measurably slower at
dealing with the more complex arguments of preadv/pwritev than the
equivalent plain old pread/pwrite.  The overheads are worth it for
iovcnt > 1, but for 1 let's just redirect to the cheaper calls.  While
we could leave it to callers to worry about that, we already have to
have our own pg_ wrappers for portability reasons so it seems
reasonable to centralize this knowledge there (thanks to Heikki for this
suggestion).  Try to avoid function call overheads by making them
inlinable, which might also allow the compiler to avoid the branch in
some cases.  For systems that don't have preadv and pwritev (currently:
Windows and [closed] Solaris), we might as well pull the replacement
functions up into the static inline functions too.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/CA+hUKGJkOiOCa+mag4BF+zHo7qo=o9CFheB8=g6uT5TUm2gkvA@mail.gmail.com

17 months agoAdd SLRU tests for 64-bit page case
Alexander Korotkov [Tue, 28 Nov 2023 23:44:01 +0000 (01:44 +0200)]
Add SLRU tests for 64-bit page case

4ed8f0913b added 64-bit page numbering for SLRU.  This commit adds tests for
page numbers higher than 2^32.

Author: Maxim Orlov
Reviewed-by: Aleksander Alekseev, Alexander Korotkov
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com

17 months agoMake use FullTransactionId in 2PC filenames
Alexander Korotkov [Tue, 28 Nov 2023 23:43:13 +0000 (01:43 +0200)]
Make use FullTransactionId in 2PC filenames

Switch from using TransactionId to FullTransactionId in naming of 2PC files.
Transaction state file in the pg_twophase directory now have extra 8 bytes in
the name to address an epoch of a given xid.

Author: Maxim Orlov, Aleksander Alekseev, Alexander Korotkov, Teodor Sigaev
Author: Nikita Glukhov, Pavel Borisov, Yura Sokolov
Reviewed-by: Jacob Champion, Heikki Linnakangas, Alexander Korotkov
Reviewed-by: Japin Li, Pavel Borisov, Tom Lane, Peter Eisentraut, Andres Freund
Reviewed-by: Andrey Borodin, Dilip Kumar, Aleksander Alekseev
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com

17 months agoUse larger segment file names for pg_notify
Alexander Korotkov [Tue, 28 Nov 2023 23:41:48 +0000 (01:41 +0200)]
Use larger segment file names for pg_notify

This avoids the wraparound in async.c and removes the corresponding code
complexity. The maximum amount of allocated SLRU pages for NOTIFY / LISTEN
queue is now determined by the max_notify_queue_pages GUC. The default
value is 1048576. It allows to consume up to 8 GB of disk space which is
exactly the limit we had previously.

Author: Maxim Orlov, Aleksander Alekseev, Alexander Korotkov, Teodor Sigaev
Author: Nikita Glukhov, Pavel Borisov, Yura Sokolov
Reviewed-by: Jacob Champion, Heikki Linnakangas, Alexander Korotkov
Reviewed-by: Japin Li, Pavel Borisov, Tom Lane, Peter Eisentraut, Andres Freund
Reviewed-by: Andrey Borodin, Dilip Kumar, Aleksander Alekseev
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com

17 months agoIndex SLRUs by 64-bit integers rather than by 32-bit integers
Alexander Korotkov [Tue, 28 Nov 2023 23:39:55 +0000 (01:39 +0200)]
Index SLRUs by 64-bit integers rather than by 32-bit integers

We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system.

This particular patch however only changes the indexing and doesn't address
the wraparound per se. This is going to be done in the following patches.

Author: Maxim Orlov, Aleksander Alekseev, Alexander Korotkov, Teodor Sigaev
Author: Nikita Glukhov, Pavel Borisov, Yura Sokolov
Reviewed-by: Jacob Champion, Heikki Linnakangas, Alexander Korotkov
Reviewed-by: Japin Li, Pavel Borisov, Tom Lane, Peter Eisentraut, Andres Freund
Reviewed-by: Andrey Borodin, Dilip Kumar, Aleksander Alekseev
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com

17 months agoClean up usage of bison precedence for non-operator keywords.
Tom Lane [Tue, 28 Nov 2023 18:32:15 +0000 (13:32 -0500)]
Clean up usage of bison precedence for non-operator keywords.

Assigning a precedence to a keyword that isn't a kind of expression
operator is rather dangerous, because it might mask grammar
ambiguities that we'd rather know about.  It's much safer to attach
explicit precedences to individual rules, which will affect the
behavior of only that one rule.  Moreover, when we do have to give
a precedence to a non-operator keyword, we should try to give it the
same precedence as IDENT, thereby reducing the risk of surprising
side-effects.

Apply this hard-won knowledge to SET (which I misassigned ages ago
in commit 2647ad658) and some SQL/JSON-related productions
(from commits 6ee30209a71bfd1543).

Patch HEAD only, since there's no evidence of actual bugs here.

Discussion: https://postgr.es/m/CADT4RqBPdbsZW7HS1jJP319TMRHs1hzUiP=iRJYR6UqgHCrgNQ@mail.gmail.com

17 months agoUse BIO_{get,set}_app_data instead of BIO_{get,set}_data.
Tom Lane [Tue, 28 Nov 2023 17:34:03 +0000 (12:34 -0500)]
Use BIO_{get,set}_app_data instead of BIO_{get,set}_data.

We should have done it this way all along, but we accidentally got
away with using the wrong BIO field up until OpenSSL 3.2.  There,
the library's BIO routines that we rely on use the "data" field
for their own purposes, and our conflicting use causes assorted
weird behaviors up to and including core dumps when SSL connections
are attempted.  Switch to using the approved field for the purpose,
i.e. app_data.

While at it, remove our configure probes for BIO_get_data as well
as the fallback implementation.  BIO_{get,set}_app_data have been
there since long before any OpenSSL version that we still support,
even in the back branches.

Also, update src/test/ssl/t/001_ssltests.pl to allow for a minor
change in an error message spelling that evidently came in with 3.2.

Tristan Partin and Bo Andreson.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAN55FZ1eDDYsYaL7mv+oSLUij2h_u6hvD4Qmv-7PK7jkji0uyQ@mail.gmail.com

17 months agoFix comment about ressortgrouprefs being unique in setop plans.
Heikki Linnakangas [Tue, 28 Nov 2023 12:08:43 +0000 (14:08 +0200)]
Fix comment about ressortgrouprefs being unique in setop plans.

Author: Richard Guo, Tom Lane
Discussion: https://www.postgresql.org/message-id/CAMbWs49rAfFS-yd7=QxtDUrZDFfRBGy4rGBJNyGDH7=CLipFPg@mail.gmail.com