postgresql-pgindent.git
2 years agoValidate ltree siglen GiST option to be int-aligned master
Alexander Korotkov [Sun, 23 Apr 2023 10:58:25 +0000 (13:58 +0300)]
Validate ltree siglen GiST option to be int-aligned

Unaligned siglen could lead to an unaligned access to subsequent key fields.

Backpatch to 13, where opclass options were introduced.

Reported-by: Alexander Lakhin
Bug: 17847
Discussion: https://postgr.es/m/17847-171232970bea406b%40postgresql.org
Reviewed-by: Tom Lane, Pavel Borisov, Alexander Lakhin
Backpatch-through: 13

2 years agoFix custom validators call in build_local_reloptions()
Alexander Korotkov [Sun, 23 Apr 2023 10:55:49 +0000 (13:55 +0300)]
Fix custom validators call in build_local_reloptions()

We need to call them only when validate == true.

Backpatch to 13, where opclass options were introduced.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/2656633.1681831542%40sss.pgh.pa.us
Reviewed-by: Tom Lane, Pavel Borisov
Backpatch-through: 13

2 years agoDoc: update pgindent/README some more.
Tom Lane [Sat, 22 Apr 2023 15:52:46 +0000 (11:52 -0400)]
Doc: update pgindent/README some more.

In commit 2e6ba1315, I missed that there was a redundant
second reference to pg_bsd_indent's old repo.

2 years agoFix initdb --no-locale.
Jeff Davis [Fri, 21 Apr 2023 20:11:18 +0000 (13:11 -0700)]
Fix initdb --no-locale.

Discussion: https://postgr.es/m/[email protected]
Reported-by: Andrew Gierth
2 years agoAvoid character classification in regex escape parsing.
Jeff Davis [Fri, 21 Apr 2023 15:19:41 +0000 (08:19 -0700)]
Avoid character classification in regex escape parsing.

For regex escape sequences, just test directly for the relevant ASCII
characters rather than using locale-sensitive character
classification.

This fixes an assertion failure when a locale considers a non-ASCII
character, such as "൧", to be a digit.

Reported-by: Richard Guo
Discussion: https://postgr.es/m/CAMbWs49Q6UoKGeT8pBkMtJGJd+16CBFZaaWUk9Du+2ERE5g_YA@mail.gmail.com
Backpatch-through: 11

2 years agoReorder connection markers in loadbalance tests
Daniel Gustafsson [Fri, 21 Apr 2023 10:29:38 +0000 (12:29 +0200)]
Reorder connection markers in loadbalance tests

Commit 7f5b198 introduced TAP tests that use string literals to mark
the presence of a query in server logs.  Reorder the markers to make
sure they are used in alphabetical order for easier debugging.

Author: Gurjeet Singh <[email protected]>
Reviewed-by: Jelte Fennema <[email protected]>
Discussion: https://postgr.es/m/CABwTF4WcYAENqyUQS2crAYfDuJ497v82ty2-MirjaC+zz9e8nQ@mail.gmail.com

2 years agoMake libpq error messages consistent for translation
Daniel Gustafsson [Fri, 21 Apr 2023 08:23:38 +0000 (10:23 +0200)]
Make libpq error messages consistent for translation

The errormessage for an incorrect require_auth method wasn't using the
common "invalid %s value" errormessage which lessens the burden on our
translators.  Fix by changing to that format to make use of existing
translations and to make error messages consistent in wording.

Reported and fixed by Gurjeet Singh with some tweaking by myself.

Author: Gurjeet Singh <[email protected]>
Discussion: https://postgr.es/m/CABwTF4Xu3g9zohJ9obu8m7MKbf8g63NgpRDjwqPHQgAtB+Gb8Q@mail.gmail.com

2 years agodoc: Add documentation for PGLOADBALANCEHOSTS environment variable in libpq.
Fujii Masao [Fri, 21 Apr 2023 07:46:41 +0000 (16:46 +0900)]
doc: Add documentation for PGLOADBALANCEHOSTS environment variable in libpq.

Commit 7f5b19817e introduced the PGLOADBALANCEHOSTS environment
variable for connection load balancing in libpq. However, documentation
for this variable was missing.

Author: Fujii Masao
Reviewed-by: Jelte Fennema
Discussion: https://postgr.es/m/e2b44cf7-aa16-e726-1d4a-a69508ebf6b9@oss.nttdata.com

2 years agoRemove unused global variable
David Rowley [Thu, 20 Apr 2023 23:41:58 +0000 (11:41 +1200)]
Remove unused global variable

Author: Alexander Lakhin
Discussion: https://postgr.es/m/d5f68d19-c0fc-91a9-118d-7c6a5a3f5fad@gmail.com

2 years agoFix incorrect function name reference
David Rowley [Thu, 20 Apr 2023 22:46:08 +0000 (10:46 +1200)]
Fix incorrect function name reference

This function was renamed in 0c9d84427 but this comment wasn't updated.

Author: Alexander Lakhin
Discussion: https://postgr.es/m/699beab4-a6ca-92c9-f152-f559caf6dc25@gmail.com

2 years agoRemove io prefix from pg_stat_io columns
Michael Paquier [Thu, 20 Apr 2023 22:21:50 +0000 (07:21 +0900)]
Remove io prefix from pg_stat_io columns

a9c70b46 added the statistics view pg_stat_io which contained columns
"io_context" and "io_object".  Given that the columns are in the
pg_stat_io view, the "io" prefix is somewhat redundant, so remove it.

The code variables referring to these fields are kept unchanged so as
they can keep their context about I/O.

Bump catalog version.

Author: Melanie Plageman
Reviewed-by: Kyotaro Horiguchi, Fabrízio de Royes Mello
Discussion: https://postgr.es/m/CAAKRu_aAQoJWrvT2BYYQvJChFKra_O-5ra3jhzKJZqWsTR1CPQ@mail.gmail.com

2 years agoUse --strip-unneeded when stripping static libraries with GNU strip.
Tom Lane [Thu, 20 Apr 2023 22:12:32 +0000 (18:12 -0400)]
Use --strip-unneeded when stripping static libraries with GNU strip.

We've long used "--strip-unneeded" for shared libraries but plain
"-x" for static libraries when stripping symbols with GNU strip.
There doesn't seem to be any really good reason for that though,
since --strip-unneeded produces smaller output (as "-x" alone
does not remove debug symbols).  Moreover it seems that
llvm-strip, although it identifies as GNU strip, misbehaves when
given "-x" for this purpose.  It's unclear whether that's
intentional or a bug in llvm-strip, but in any case it seems like
changing to use --strip-unneeded in all cases should be a win.

Note that this doesn't change our behavior when dealing with
non-GNU strip.

Per gripes from Ed Maste and Palle Girgensohn.  Back-patch,
in case anyone wants to use llvm-strip with stable branches.

Discussion: https://postgr.es/m/17898-5308d09543463266@postgresql.org
Discussion: https://postgr.es/m/20230420153338[email protected]

2 years agoFix autovacuum cost debug logging
Daniel Gustafsson [Thu, 20 Apr 2023 13:45:44 +0000 (15:45 +0200)]
Fix autovacuum cost debug logging

Commit 7d71d3dd0 introduced finer grained updates of autovacuum option
changes by increasing the frequency of reading the configuration file.
The debug logging of cost parameter was however changed such that some
initial values weren't logged.  Fix by changing logging to use the old
frequency of logging regardless of them changing.

Also avoid taking a log for rendering the log message unless the set
loglevel is such that the log entry will be emitted.

Author: Masahiko Sawada <[email protected]>
Discussion: https://postgr.es/m/CAD21AoBS7o6Ljt_vfqPQPf67AhzKu3fR0iqk8B=vVYczMugKMQ@mail.gmail.com

2 years agoDoc: clarify NULLS NOT DISTINCT use in unique indexes
David Rowley [Thu, 20 Apr 2023 11:51:38 +0000 (23:51 +1200)]
Doc: clarify NULLS NOT DISTINCT use in unique indexes

indexes-unique.html mentioned nothing about the availability of NULLS NOT
DISTINCT to modify the NULLs-are-not-equal behavior of unique indexes.
Add this to the synopsis and clarify what it does regarding NULLs.

Author: David Gilman, David Rowley
Reviewed-by: Corey Huinker
Discussion: https://postgr.es/m/CALBH9DDr3NLqzWop1z5uZE-M5G_GYUuAeHFHQeyzFbNd8W0d=Q@mail.gmail.com
Backpatch-through: 15, where NULLS NOT DISTINCT was added

2 years agoRestart the apply worker if the 'password_required' option is changed.
Amit Kapila [Thu, 20 Apr 2023 03:26:18 +0000 (08:56 +0530)]
Restart the apply worker if the 'password_required' option is changed.

The apply worker is restarted if any subscription option that affects the
remote connection was changed. In commit c3afe8cf5a, we added the option
'password_required' which can affect the remote connection, so we should
restart the worker if it was changed.

Author: Amit Kapila
Reviewed-by: Robert Haas
Discussion: https://postgr.es/m/CAA4eK1+z9UDFEynXLsWeMMuUZc1iQkRwj2HNDtxUHTPo-u1F4A@mail.gmail.com
Discussion: https://postgr.es/m/9DFC88D3-1300-4DE8-ACBC-4CEF84399A53@enterprisedb.com

2 years agoRemove obsolete defense against strxfrm() bugs.
Thomas Munro [Thu, 20 Apr 2023 01:15:23 +0000 (13:15 +1200)]
Remove obsolete defense against strxfrm() bugs.

Old versions of Solaris and illumos had buffer overrun bugs in their
strxfrm() implementations.  The bugs were fixed more than a decade ago
and the relevant releases are long out of vendor support.  It's time to
remove the defense added by commit be8b06c3.

Reviewed-by: Nathan Bossart <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/CA+hUKGJ-ZPJwKHVLbqye92-ZXeLoCHu5wJL6L6HhNP7FkJ=meA@mail.gmail.com

2 years agoFix list_copy_head() with empty Lists
David Rowley [Wed, 19 Apr 2023 22:34:46 +0000 (10:34 +1200)]
Fix list_copy_head() with empty Lists

list_copy_head() given an empty List would crash from trying to
dereference the List to obtain its length.  Since NIL is how we represent
an empty List, we should just be returning another empty List in this
case.

list_copy_head() is new to v16, so let's fix it now before too many people
start coding around the buggy NIL behavior.

Reported-by: Miroslav Bendik
Discussion: https://postgr.es/m/CAPoEpV02WhawuWnmnKet6BqU63bEu7oec0pJc=nKMtPsHMzTXQ@mail.gmail.com

2 years agoUse nbtdesc "level" field name consistently.
Peter Geoghegan [Wed, 19 Apr 2023 19:15:15 +0000 (12:15 -0700)]
Use nbtdesc "level" field name consistently.

The "lev" name that appeared in NEWROOT nbtree record desc output was
inconsistent with the symbol name from the underlying C struct.  It was
also inconsistent with nbtdesc output for other nearby record types with
similar level fields.

Standardize on "level" to make everything consistent.

Follow-up to commit 1c453cfd.

2 years agoFix wal_consistency_checking enhanced desc output.
Peter Geoghegan [Wed, 19 Apr 2023 17:42:39 +0000 (10:42 -0700)]
Fix wal_consistency_checking enhanced desc output.

Recent enhancements to rmgr desc routines that made the output summarize
certain block data (added by commits 7d8219a4 and 1c453cfd) dealt with
records that lack relevant block data (and so have nothing to give a
more detailed summary of) by testing !DecodedBkpBlock.has_image.  As a
result, more detailed descriptions of block data were not output when
wal_consistency_checking was enabled.

This bug affected records with summarizable block data that also
happened to have an FPI that the REDO routine isn't supposed to apply
(FPIs used for consistency checking purposes only).  The presence of
such an FPI was incorrectly taken to indicate the absence of block data.

To fix, test DecodedBkpBlock.has_data, not !DecodedBkpBlock.has_image.
This is the exact condition that we care about, not an inexact proxy.

Author: Peter Geoghegan <[email protected]>
Discussion: https://postgr.es/m/CAH2-Wzm5Sc9cBg1qWV_cEBfLNJCrW9FjS-SoHVt8FLA7Ldn8yg@mail.gmail.com

2 years agoAdd missed case for tab completion of GRANT/REVOKE MAINTAIN.
Tom Lane [Wed, 19 Apr 2023 14:49:53 +0000 (10:49 -0400)]
Add missed case for tab completion of GRANT/REVOKE MAINTAIN.

We failed to offer "ON" after "GRANT MAINTAIN".
Oversight in commit 60684dd83.

Ken Kato

Discussion: https://postgr.es/m/6afe7712991882a864d6d10003264e7c@oss.nttdata.com

2 years agoFix errormessage for missing system CA in OpenSSL 3.1
Daniel Gustafsson [Wed, 19 Apr 2023 10:54:58 +0000 (12:54 +0200)]
Fix errormessage for missing system CA in OpenSSL 3.1

The error message for a missing or invalid system CA when using
sslrootcert=system differs based on the OpenSSL version used.

In OpenSSL 1.0.1-3.0 it is reported as SSL Error, with varying
degrees of helpfulness in the error message. With OpenSSL 3.1 it
is reported as an SSL SYSCALL error with "Undefined error" as
the error message. This fix pulls out the particular error in
OpenSSL 3.1 as a certificate verify error in order to help the
user better figure out what happened, and to keep the ssl test
working. While there is no evidence that extracing the errors
will clobber errno, this adds a guard against that regardless
to also make the consistent with how we handle OpenSSL errors
elsewhere. It also memorizes the output from OpenSSL 3.0 in
the test in cases where the system CA isn't responding.

Reported-by: Peter Eisentraut <[email protected]>
Discussion: https://postgr.es/m/c39be3c5-c1a5-1e33-1024-16f527e251a4@enterprisedb.com

2 years agoRemove some tabs in SQL code in C string literals
Peter Eisentraut [Wed, 19 Apr 2023 07:29:43 +0000 (09:29 +0200)]
Remove some tabs in SQL code in C string literals

This is not handled uniformly throughout the code, but at least nearby
code can be consistent.

2 years agoFix generation of distribution tarball
Michael Paquier [Wed, 19 Apr 2023 04:59:52 +0000 (13:59 +0900)]
Fix generation of distribution tarball

This issue can be reproduced by running `make dist` from the root of the
tree.  Error introduced in fcb21b3, where additions of links in
installation.sgml require custom rules in standalone-profile.xsl to make
sure that ./INSTALL is generated correctly for the distribution tarball,
where links are replaced by equivalent terms from the profile file
changed by this commit.

Per buildfarm member guaibasaurus.

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

2 years agoFix various typos and incorrect/outdated name references
David Rowley [Wed, 19 Apr 2023 01:50:33 +0000 (13:50 +1200)]
Fix various typos and incorrect/outdated name references

Author: Alexander Lakhin
Discussion: https://postgr.es/m/699beab4-a6ca-92c9-f152-f559caf6dc25@gmail.com

2 years agoBuild ICU support by default.
Jeff Davis [Tue, 18 Apr 2023 20:20:11 +0000 (13:20 -0700)]
Build ICU support by default.

Discussion: https://postgr.es/m/82c4c816-06f6-d3e3-ba02-fca4a5cef065%40enterprisedb.com
Reviewed-by: Peter Eisentraut
2 years agoUpdate time zone data files to tzdata release 2023c.
Tom Lane [Tue, 18 Apr 2023 18:46:39 +0000 (14:46 -0400)]
Update time zone data files to tzdata release 2023c.

DST law changes in Egypt, Greenland, Morocco, and Palestine.

When observing Moscow time, Europe/Kirov and Europe/Volgograd now
use the abbreviations MSK/MSD instead of numeric abbreviations,
for consistency with other timezones observing Moscow time.

Also, America/Yellowknife is no longer distinct from America/Edmonton;
this affects some pre-1948 timestamps in that area.

2 years agoRemove useless argument from nbtree dedup function.
Peter Geoghegan [Tue, 18 Apr 2023 17:33:15 +0000 (10:33 -0700)]
Remove useless argument from nbtree dedup function.

_bt_dedup_pass()'s heapRel argument hasn't been needed or used since
commit cf2acaf4dc made deleting any existing LP_DEAD index tuples the
caller's responsibility.

2 years agoFix Utils.pm's locale-munging so that Perl itself is also affected.
Tom Lane [Tue, 18 Apr 2023 17:31:31 +0000 (13:31 -0400)]
Fix Utils.pm's locale-munging so that Perl itself is also affected.

Utils.pm has a BEGIN block that editorializes on the locale-related
environment variables, primarily in order to stabilize the behavior
of child programs.  It turns out that if the calling test script
has already done "use locale", this fails to affect the behavior
of Perl itself, causing locale behavior to be different between
Perl and child programs.  That breaks commit cd82e5c79's attempt
to deal with locale-specific behavior in psql.

To fix, we just need to call setlocale() to redo the calculation
of locale.

Per report from Aleksander Alekseev.  No back-patch for now, since
there are no locale-dependent TAP tests in prior branches, and
I'm not yet convinced that this won't have side-effects of its own.

Discussion: https://postgr.es/m/CAJ7c6TO9KpYYxoVVseWEQB5KtjWDkt8NfyAeKPcHoe2Jq+ykpw@mail.gmail.com

2 years agoFix pg_basebackup with in-place tablespaces some more.
Robert Haas [Tue, 18 Apr 2023 15:23:34 +0000 (11:23 -0400)]
Fix pg_basebackup with in-place tablespaces some more.

Commit c6f2f01611d4f2c412e92eb7893f76fa590818e8 purported to make
this work, but problems remained. In a plain-format backup, the
files from an in-place tablespace got included in the tar file for
the main tablespace, which is wrong but it's not clear that it
has any user-visible consequences. In a tar-format backup, the
TABLESPACE_MAP option is used, and so we never iterated over
pg_tblspc and thus never backed up the in-place tablespaces
anywhere at all.

To fix this, reverse the changes in that commit, so that when we scan
pg_tblspc during a backup, we create tablespaceinfo objects even for
in-place tablespaces. We set the field that would normally contain the
absolute pathname to the relative path pg_tblspc/${TSOID}, and that's
good enough to make basebackup.c happy without any further changes.

However, pg_basebackup needs a couple of adjustments to make it work.
First, it needs to understand that a relative path for a tablespace
means it's an in-place tablespace.  Second, it needs to tolerate the
situation where restoring the main tablespace tries to create
pg_tblspc or a subdirectory and finds that it already exists, because
we restore user-defined tablespaces before the main tablespace.

Since in-place tablespaces are only intended for use in development
and testing, no back-patch.

Patch by me, reviewed by Thomas Munro and Michael Paquier.

Discussion: http://postgr.es/m/CA+TgmobwvbEp+fLq2PykMYzizcvuNv0a7gPMJtxOTMOuuRLMHg@mail.gmail.com

2 years agoecpg: Fix handling of strings in ORACLE compat code with SQLDA
Michael Paquier [Tue, 18 Apr 2023 02:20:41 +0000 (11:20 +0900)]
ecpg: Fix handling of strings in ORACLE compat code with SQLDA

When compiled with -C ORACLE, ecpg_get_data() had a one-off issue where
it would incorrectly store the null terminator byte to str[-1] when
varcharsize is 0, which is something that can happen when using SQLDA.
This would eat 1 byte from the previous field stored, corrupting the
results generated.

All the callers of ecpg_get_data() estimate and allocate enough storage
for the data received, and the fix of this commit relies on this
assumption.  Note that this maps to the case where no padding or
truncation is required.

This issue has been introduced by 3b7ab43 with the Oracle compatibility
option, so backpatch down to v11.

Author: Kyotaro Horiguchi
Discussion: https://postgr.es/m/20230410.173500.440060475837236886[email protected]
Backpatch-through: 11

2 years agoFix some typos and some incorrectly duplicated words
David Rowley [Tue, 18 Apr 2023 02:03:30 +0000 (14:03 +1200)]
Fix some typos and some incorrectly duplicated words

Author: Justin Pryzby
Reviewed-by: David Rowley
Discussion: https://postgr.es/m/[email protected]

2 years agoFix various typos
David Rowley [Tue, 18 Apr 2023 01:23:23 +0000 (13:23 +1200)]
Fix various typos

This fixes many spelling mistakes in comments, but a few references to
invalid parameter names, function names and option names too in comments
and also some in string constants

Also, fix an #undef that was undefining the incorrect definition

Author: Alexander Lakhin
Reviewed-by: Justin Pryzby
Discussion: https://postgr.es/m/d5f68d19-c0fc-91a9-118d-7c6a5a3f5fad@gmail.com

2 years agoComment fix for 60684dd834.
Jeff Davis [Mon, 17 Apr 2023 20:39:32 +0000 (13:39 -0700)]
Comment fix for 60684dd834.

Reported-by: Peter Eisentraut
Discussion: https://postgr.es/m/766f3799-0269-162f-ba63-4cae34a5534f@enterprisedb.com

2 years agoUpdate Solution.pm for HAVE_GSSAPI[_GSSAPI]_EXT_H, too.
Tom Lane [Mon, 17 Apr 2023 20:00:39 +0000 (16:00 -0400)]
Update Solution.pm for HAVE_GSSAPI[_GSSAPI]_EXT_H, too.

Commit d48ac0070 was still a brick shy of a load.
Per buildfarm (via Andrew Dunstan).

Discussion: https://postgr.es/m/08dd6053-deee-52e9-954b-eb69232905c9@dunslane.net

2 years agoAvoid trying to write an empty WAL record in log_newpage_range().
Tom Lane [Mon, 17 Apr 2023 18:22:06 +0000 (14:22 -0400)]
Avoid trying to write an empty WAL record in log_newpage_range().

If the last few pages in the specified range are empty (all zero),
then log_newpage_range() could try to emit an empty WAL record
containing no FPIs.  This at least upsets an Assert in
ReserveXLogInsertLocation, and might perhaps have bad real-world
consequences in non-assert builds.

This has been broken since log_newpage_range() was introduced,
but the case was hard if not impossible to hit before commit 3d6a98457
decided it was okay to leave VM and FSM pages intentionally zero.
Nonetheless, it seems prudent to back-patch.  log_newpage_range()
was added in v12 but later back-patched, so this affects all
supported branches.

Matthias van de Meent, per report from Justin Pryzby

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

2 years agoFix incorrect comment about nbtree WAL record.
Peter Geoghegan [Mon, 17 Apr 2023 16:58:18 +0000 (09:58 -0700)]
Fix incorrect comment about nbtree WAL record.

The nbtree VACUUM WAL record stores its page offset number payload in
blk 0 (just like the closely related nbtree DELETE WAL record).  Commit
ebd551f5 fixed a similar issue with the DELETE WAL record, but missed
this one.

2 years agoFurther cleanup of autoconf output files for GSSAPI changes.
Tom Lane [Mon, 17 Apr 2023 15:21:50 +0000 (11:21 -0400)]
Further cleanup of autoconf output files for GSSAPI changes.

Running autoheader was missed in f7431bca8.  This is cosmetic since
we aren't using these HAVE_ symbols, but let's get everything in
sync while we're looking at this.

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

2 years agoUpdate configure for ab969a376
Stephen Frost [Mon, 17 Apr 2023 14:13:08 +0000 (10:13 -0400)]
Update configure for ab969a376

Commit ab969a376 updated configure.ac but neglected to update the actual
configure script.  Fix that.

Pointed out by Tom Lane

2 years agodoc: Add additional SQL features codes from SQL:2023
Peter Eisentraut [Mon, 17 Apr 2023 14:04:54 +0000 (16:04 +0200)]
doc: Add additional SQL features codes from SQL:2023

These were mysteriously omitted in c9f57541d9.

2 years agoUpdate Kerberos/GSSAPI configure/meson check
Stephen Frost [Mon, 17 Apr 2023 13:51:04 +0000 (09:51 -0400)]
Update Kerberos/GSSAPI configure/meson check

Instead of checking for the much older gss_init_sec_context, check for
gss_store_cred_into which was added in MIT Kerberos 1.11 (circa 2012).

Discussion: https://postgr.es/m/2313469.1681695223%40sss.pgh.pa.us

2 years agoPut new command-line option into sensible order in help output
Peter Eisentraut [Mon, 17 Apr 2023 09:09:17 +0000 (11:09 +0200)]
Put new command-line option into sensible order in help output

We have two existing conventions for long options: either alphabetical
among short options, or all long options after all the short options.
But the convention apparently used here, next to a functionally
related option, is not one of them.

2 years agoDoc: remove notes about the version vacuumdb options are valid from
David Rowley [Sun, 16 Apr 2023 21:28:34 +0000 (09:28 +1200)]
Doc: remove notes about the version vacuumdb options are valid from

Here we remove the notes which mention which version the given vacuumdb
option is available from.  There are now 11 of these notes and they're
both quite untidy and take up far more space than they seem to be worth.
On running a print preview of the compiled HTML, removing these notes
saves about 1 A4 page (~20% less space).

If people need to see which options are available on older versions, then
consulting the documents for that version seems like a good idea.  In any
case, when using newer vacuumdb versions on older servers, the user will
receive an error if they try to use an unsupported option.

Additionally, 3 of the notes are warning about the option only being
available from PostgreSQL 9.6 and later.  That version's support ended 2.5
years ago.  So, it's quite clear that the value of these notes diminishes
over time.

Discussion: https://postgr.es/m/CAApHDvrCQn6tupx2R67VL9RP1Qy4dDuWKRvt4jaB0vk2akQchw@mail.gmail.com

2 years agoEnsure result of an aggregate's finalfunc is made read-only.
Tom Lane [Sun, 16 Apr 2023 18:16:40 +0000 (14:16 -0400)]
Ensure result of an aggregate's finalfunc is made read-only.

The finalfunc might return a read-write expanded object.  If we
de-duplicate multiple call sites for the aggregate, any function(s)
receiving the aggregate result earlier could alter or destroy the
value that reaches the ones called later.  This is a brown-paper-bag
bug in commit 42b746d4c, because we actually considered the need
for read-only-ness but failed to realize that it applied to the case
with a finalfunc as well as the case without.

Per report from Justin Pryzby.  New error in HEAD,
no need for back-patch.

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

2 years agoAvoid using non-ASCII commentary in daitch_mokotoff.c.
Tom Lane [Sun, 16 Apr 2023 16:57:32 +0000 (12:57 -0400)]
Avoid using non-ASCII commentary in daitch_mokotoff.c.

Commit d6b5dee42 failed to suppress that warning from MSVC,
so let's just get rid of all non-ASCII glyphs in the comments.
The comment for iso8859_1_to_ascii_upper[] is not essential,
and the other cases can be handled by spelling out the
Unicode character names.

(I'm now really in the dark as to why MSVC doesn't complain
about predicate.c's comment.  But whatever.)

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

2 years agoDoc: add note about --buffer-usage-limit being v16 onwards
David Rowley [Sun, 16 Apr 2023 09:47:01 +0000 (21:47 +1200)]
Doc: add note about --buffer-usage-limit being v16 onwards

Other vacuumdb options seem to have notes about which version they're
available from, so let's follow this trend for the newly added
--buffer-usage-limit option.

2 years agoImprove VACUUM/ANALYZE BUFFER_USAGE_LIMIT docs
David Rowley [Sun, 16 Apr 2023 00:05:34 +0000 (12:05 +1200)]
Improve VACUUM/ANALYZE BUFFER_USAGE_LIMIT docs

This addresses various deficiencies in the documentation for VACUUM and
ANALYZE's BUFFER_USEAGE_LIMIT docs.

Here we declare "size" in the syntax synopsis for VACUUM and ANALYZE's
BUFFER_USAGE_LIMIT option and then define exactly what values can be
specified for it in the section for that below.

Also, fix the incorrect ordering of vacuumdb options both in the documents
and in vacuumdb's --help output.  These should be in alphabetical order.

In passing also add the minimum/maximum range for the BUFFER_USAGE_LIMIT
option.  These will also serve as example values that can be modified and
used.

Reported-by: Peter Eisentraut
Discussion: https://postgr.es/m/16845cb1-b228-e157-f293-5892bced9253@enterprisedb.com

2 years agoFix assignment to array of domain over composite, redux.
Tom Lane [Sat, 15 Apr 2023 16:01:39 +0000 (12:01 -0400)]
Fix assignment to array of domain over composite, redux.

Commit 3e310d837 taught isAssignmentIndirectionExpr() to look through
CoerceToDomain nodes.  That's not sufficient, because since commit
04fe805a1 it's been possible for the planner to simplify
CoerceToDomain to RelabelType when the domain has no constraints
to enforce.  So we need to look through RelabelType too.

Per bug #17897 from Alexander Lakhin.  Although 3e310d837 was
back-patched to v11, it seems sufficient to apply this change
to v12 and later, since 04fe805a1 came in in v12.

Dmitry Dolgov

Discussion: https://postgr.es/m/17897-4216c546c3874044@postgresql.org

2 years agoRemove some non-ASCII symbols from a comment.
Tom Lane [Sat, 15 Apr 2023 15:20:46 +0000 (11:20 -0400)]
Remove some non-ASCII symbols from a comment.

Buildfarm member hamerkop is unhappy that daitch_mokotoff.c "contains
a character that cannot be represented in the current code page
(932). Save the file in Unicode format to prevent data loss".  There
are a lot of non-ASCII characters in comments, but I do not see any
outside a comment, so this is just cosmetic.  Nonetheless the warning
is fairly scary and people might waste time trying to understand the
cause, so we ought to silence it.

We have only one other occurrence of a non-ASCII character in .c or .h
files in the tree: predicate.c mentions "Uwe Röhm".  It's far from
clear why hamerkop isn't complaining about that too; but it isn't,
so maybe there is some special provision for accented Roman letters.
We can remove the non-letter symbols from the comment for
iso8859_1_to_ascii_upper without any real loss of usefulness,
so let's try that first to see if it silences the warning.

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

2 years agoAdjust Valgrind macro usage to protect chunk headers
David Rowley [Fri, 14 Apr 2023 23:59:52 +0000 (11:59 +1200)]
Adjust Valgrind macro usage to protect chunk headers

Prior to this commit we only ever protected MemoryChunk's requested_size
field with Valgrind NOACCESS.  This means that if the hdrmask field is
ever accessed accidentally then we're not going to get any warnings from
Valgrind about it.  Valgrind would have warned us about the problem fixed
in 92957ed98 had we already been doing this.

Per suggestion from Tom Lane

Reviewed-by: Richard Guo
Discussion: https://postgr.es/m/1650235.1672694719@sss.pgh.pa.us
Discussion: https://postgr.es/m/CAApHDvr=FZNGbj252Z6M9BSFKoq6BMxgkQ2yEAGUYoo7RquqZg@mail.gmail.com

2 years agoSupport RBM_ZERO_AND_CLEANUP_LOCK in ExtendBufferedRelTo(), add tests
Andres Freund [Fri, 14 Apr 2023 18:30:20 +0000 (11:30 -0700)]
Support RBM_ZERO_AND_CLEANUP_LOCK in ExtendBufferedRelTo(), add tests

For some reason I had not implemented RBM_ZERO_AND_CLEANUP_LOCK support in
ExtendBufferedRelTo(), likely thinking it not being reachable. But it is
reachable, e.g. when replaying a WAL record for a page in a relation that
subsequently is truncated (likely only reachable when doing crash recovery or
PITR, not during ongoing streaming replication).

As now all of the RBM_* modes are supported, remove assertions checking mode.

As we had no test coverage for this scenario, add a new TAP test. There's
plenty more that ought to be tested in this area...

Reported-by: Tom Lane <[email protected]>
Reported-by: Alexander Lakhin <[email protected]>
Reviewed-by: Alexander Lakhin <[email protected]>
Discussion: https://postgr.es/m/392271.1681238924%40sss.pgh.pa.us
Discussion: https://postgr.es/m/0b5eb82b-cb99-e0a4-b932-3dc60e2e3926@gmail.com

2 years agoNULL is not an ideal way to spell bool "false".
Tom Lane [Fri, 14 Apr 2023 17:31:51 +0000 (13:31 -0400)]
NULL is not an ideal way to spell bool "false".

Thinko in commit 6633cfb21, detected by buildfarm member hamerkop.

2 years agodoc: PQinitOpenSSL and PQinitSSL are obsolete in OpenSSL 1.1.0+
Daniel Gustafsson [Fri, 14 Apr 2023 08:15:50 +0000 (10:15 +0200)]
doc: PQinitOpenSSL and PQinitSSL are obsolete in OpenSSL 1.1.0+

Starting with OpenSSL 1.1.0 there is no need to call PQinitOpenSSL
or PQinitSSL to avoid duplicate initialization of OpenSSL.  Add a
note to the documentation to explain this.

Backpatch to all supported versions as older OpenSSL versions are
equally likely to be used for all branches.

Reported-by: Sebastien Flaesch <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/DBAP191MB12895BFFEC4B5FE0460D0F2FB0459@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM
Backpatch-through: 11, all supported versions

2 years agoFix whitespace
Peter Eisentraut [Fri, 14 Apr 2023 08:04:57 +0000 (10:04 +0200)]
Fix whitespace

2 years agoAdd missing source files to nls.mk
Peter Eisentraut [Fri, 14 Apr 2023 07:56:04 +0000 (09:56 +0200)]
Add missing source files to nls.mk

2 years agoFix incorrect partition pruning logic for boolean partitioned tables
David Rowley [Fri, 14 Apr 2023 04:20:27 +0000 (16:20 +1200)]
Fix incorrect partition pruning logic for boolean partitioned tables

The partition pruning logic assumed that "b IS NOT true" was exactly the
same as "b IS FALSE".  This is not the case when considering NULL values.
Fix this so we correctly include any partition which could hold NULL
values for the NOT case.

Additionally, this fixes a bug in the partition pruning code which handles
partitioned tables partitioned like ((NOT boolcol)).  This is a seemingly
unlikely schema design, and it was untested and also broken.

Here we add tests for the ((NOT boolcol)) case and insert some actual data
into those tables and verify we do get the correct rows back when running
queries.  I've also adjusted the existing boolpart tests to include some
data and verify we get the correct results too.

Both the bugs being fixed here could lead to incorrect query results with
fewer rows being returned than expected.  No additional rows could have
been returned accidentally.

In passing, remove needless ternary expression.  It's more simple just to
pass !is_not_clause to makeBoolConst().  It makes sense to do this so the
code is consistent with the bug fix in the "else if" condition just below.

David Kimura did submit a patch to fix the first of the issues here, but
that's not what's being committed here.

Reported-by: David Kimura
Reviewed-by: Richard Guo, David Kimura
Discussion: https://postgr.es/m/CAHnPFjQ5qxs6J_p+g8=ww7GQvfn71_JE+Tygj0S7RdRci1uwPw@mail.gmail.com
Backpatch-through: 11, all supported versions

2 years agodoc: Fix some grammar for logical decoding description and functions
Michael Paquier [Fri, 14 Apr 2023 04:08:02 +0000 (13:08 +0900)]
doc: Fix some grammar for logical decoding description and functions

This documentation is has been added for the support of logical decoding
on standbys.  Some markups were missing, hence add some where required.

Author: Thom Brown
Reviewed-by: Justin Pryzby, Daniel Gustafsson
Discussion: https://postgr.es/m/CAA-aLv7xCZ0nBJa-NWe0rxBB28TjFjS2JtjiZMoQ+0wsugG+hQ@mail.gmail.com

2 years agoFix PHJ match bit initialization.
Thomas Munro [Thu, 13 Apr 2023 22:52:58 +0000 (10:52 +1200)]
Fix PHJ match bit initialization.

Hash join tuples reuse the HOT status bit to indicate match status
during hash join execution. Correct reuse requires clearing the bit in
all tuples. Serial hash join and parallel multi-batch hash join do so
upon inserting the tuple into the hashtable. Single batch parallel hash
join and batch 0 of unexpected multi-batch hash joins forgot to do this.

It hadn't come up before because hashtable tuple match bits are only
used for right and full outer joins and parallel ROJ and FOJ were
unsupported. 11c2d6fdf5 introduced support for parallel ROJ/FOJ but
neglected to ensure the match bits were reset.

Author: Melanie Plageman <[email protected]>
Reported-by: Richard Guo <[email protected]>
Discussion: https://postgr.es/m/flat/CAMbWs48Nde1Mv%3DBJv6_vXmRKHMuHZm2Q_g4F6Z3_pn%2B3EV6BGQ%40mail.gmail.com

2 years agoRemove code in charge of freeing regexps generation by Lab.c
Michael Paquier [Thu, 13 Apr 2023 22:27:44 +0000 (07:27 +0900)]
Remove code in charge of freeing regexps generation by Lab.c

bea3d7e has redesigned the regexp engine so as all the allocations go
through palloc() with a dedicated memory context.  hba.c had to cope
with the past memory management logic by going through all the HBA and
ident lines generated, then directly free all the regexps found in
AuthTokens to ensure that no leaks would happen.  Such leaks could
happen for example in the postmaster after a SIGHUP, in the event of
an HBA and/or ident reload failure where all the new content parsed must
be discarded, including all the regexps that may have been compiled.

Now that regexps are palloc()'d in their own memory context,
MemoryContextDelete() is enough to ensure that all the compiled regexps
are properly gone.  Simplifying this logic in hba.c has the effect to
only remove code.  Most of it is new in v16, except the part for regexps
compiled in ident entries for the system username, so doing this cleanup
now rather than when v17 opens for business will reduce future diffs
with the upcoming REL_16_STABLE.

Some comments were incorrect since bea3d7e, now fixed to reflect the
reality.

Reviewed-by: Bertrand Drouvot, Álvaro Herrera
Discussion: https://postgr.es/m/[email protected]

2 years agoRemove old GUC name mapping for "force_parallel_mode"
David Rowley [Thu, 13 Apr 2023 22:19:45 +0000 (10:19 +1200)]
Remove old GUC name mapping for "force_parallel_mode"

This GUC was renamed to debug_parallel_query in 5352ca22e.  That commit
added an entry into map_old_guc_names[] to allow the old name still to
work.  That was done to allow a transition time where the buildfarm
configs could be swapped over to use debug_parallel_query instead.  That
work is now complete.

Here we remove the old name with the intention of breaking any user code
which is using force_parallel_query.  As mentioned in the commit message
for 5352ca22e, it appeared many users were misled into thinking that
setting this GUC was doing something useful for them to make queries run
more quickly.

Discussion: https://postgr.es/m/CAApHDvoR7EOz7Tvyzrd18FO-Dw2Cp4Uyq25TEWguK+XyCJtzOw@mail.gmail.com

2 years agoUpdate Unicode data to CLDR 43
Peter Eisentraut [Thu, 13 Apr 2023 20:10:08 +0000 (22:10 +0200)]
Update Unicode data to CLDR 43

No actual changes result.

2 years agoHarmonize some more function parameter names.
Peter Geoghegan [Thu, 13 Apr 2023 17:15:20 +0000 (10:15 -0700)]
Harmonize some more function parameter names.

Make sure that function declarations use names that exactly match the
corresponding names from function definitions in a few places.  These
inconsistencies were all introduced relatively recently, after the code
base had parameter name mismatches fixed in bulk (see commits starting
with commits 4274dc22 and 035ce1fe).

pg_bsd_indent still has a couple of similar inconsistencies, which I
(pgeoghegan) have left untouched for now.

Like all earlier commits that cleaned up function parameter names, this
commit was written with help from clang-tidy.

2 years agoExplicitly require MIT Kerberos for GSSAPI
Stephen Frost [Thu, 13 Apr 2023 12:55:13 +0000 (08:55 -0400)]
Explicitly require MIT Kerberos for GSSAPI

WHen building with GSSAPI support, explicitly require MIT Kerberos and
check for gssapi_ext.h in configure.ac and meson.build.  Also add
documentation explicitly stating that we now require MIT Kerberos when
building with GSSAPI support.

Reveiwed by: Johnathan Katz
Discussion: https://postgr.es/m/abcc73d0-acf7-6896-e0dc-f5bc12a61bb1@postgresql.org

2 years agoDe-Revert "Add support for Kerberos credential delegation"
Stephen Frost [Thu, 13 Apr 2023 12:55:07 +0000 (08:55 -0400)]
De-Revert "Add support for Kerberos credential delegation"

This reverts commit 3d03b24c3 (Revert Add support for Kerberos
credential delegation) which was committed on the grounds of concern
about portability, but on further review and discussion, it's clear that
we are better off explicitly requiring MIT Kerberos as that appears to
be the only GSSAPI library currently that's under proper maintenance
and ongoing development.  The API used for storing credentials was added
to MIT Kerberos over a decade ago while for the other libraries which
appear to be mainly based on Heimdal, which exists explicitly to be a
re-implementation of MIT Kerberos, the API never made it to a released
version (even though it was added to the Heimdal git repo over 5 years
ago..).

This post-feature-freeze change was approved by the RMT.

Discussion: https://postgr.es/m/ZDDO6jaESKaBgej0%40tamriel.snowman.net

2 years agodoc: Make HTML ids discoverable
Peter Eisentraut [Thu, 13 Apr 2023 08:15:20 +0000 (10:15 +0200)]
doc: Make HTML ids discoverable

In the HTML output, this decorates section headers and variable list
terms with a marker ("#") that is a link to the same section/term.
That way, links inside a page can be discovered for easier sharing.
The marker only appears when hovering.

This now requires that all elements that are candidates for such a
link have an id attribute.  Otherwise, an error will be generated.
All previously missing ids have been added prior to this patch.

Author: Brar Piening <[email protected]>
Reviewed-by: Karl O. Pinc <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CAB8KJ=jpuQU9QJe4+RgWENrK5g9jhoysMw2nvTN_esoOU0=a_w@mail.gmail.com

2 years agoAdd missing XML ID attribute
Peter Eisentraut [Thu, 13 Apr 2023 07:48:38 +0000 (09:48 +0200)]
Add missing XML ID attribute

Discussion: https://www.postgresql.org/message-id/dc813a6f-60d9-991f-eecd-675a0921de11@gmx.de

2 years agoSkip the 004_io_direct.pl test if a pre-flight check fails.
Thomas Munro [Thu, 13 Apr 2023 01:47:39 +0000 (13:47 +1200)]
Skip the 004_io_direct.pl test if a pre-flight check fails.

The test previously had a list of OSes that direct I/O was expected to
work on.  That worked well enough for the systems in our build farm, but
didn't survive contact with the Debian build bots running on tmpfs via
overlayfs.  tmpfs does not support O_DIRECT, but we don't want to
exclude Linux generally.

The new approach is to try to create an empty file with O_DIRECT from
Perl first.  If that fails, we'll skip the test and report what the
error was.

Reported-by: Christoph Berg <[email protected]>
Reviewed-by: Dagfinn Ilmari Mannsåker <[email protected]>
Reviewed-by: Andrew Dunstan <[email protected]>
Discussion: https://postgr.es/m/ZDYd4A78cT2ULxZZ%40msg.df7cb.de

2 years agoRemove overzealous assertion from PHJ.
Thomas Munro [Wed, 12 Apr 2023 21:19:54 +0000 (09:19 +1200)]
Remove overzealous assertion from PHJ.

We can't assert that we're the only process attached to a barrier after
BarrierArriveAndDetachExceptLast().  Although that'll be true almost
always, a late-starting parallel worker can attach very briefly (that
is, immediately detach after checking the phase) right at that moment.
BarrierArriveAndDetachExceptLast() already contains an assertion like
that, but it holds a spinlock preventing the race.  This thinko caused a
one-off failure on build farm animal chimaera.

Diagnosed-by: Melanie Plageman <[email protected]>
Reported-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/3590249.1680971629@sss.pgh.pa.us

2 years agoRevert "Adjust contrib/sepgsql regression test expected outputs."
Alvaro Herrera [Wed, 12 Apr 2023 18:22:17 +0000 (20:22 +0200)]
Revert "Adjust contrib/sepgsql regression test expected outputs."

This reverts commit 76c111a7f166; should have been included in
9ce04b50e120.

Noted by Joe Conway

2 years agoImprove error messages introduced in be87200efd9 and 0fdab27ad68
Andres Freund [Wed, 12 Apr 2023 18:00:37 +0000 (11:00 -0700)]
Improve error messages introduced in be87200efd9 and 0fdab27ad68

Author: Kyotaro Horiguchi <[email protected]>
Discussion: https://postgr.es/m/20230411.120301.93333867350615278[email protected]
Discussion: https://postgr.es/m/20230412174244[email protected]

2 years agoRevert "Catalog NOT NULL constraints" and fallout
Alvaro Herrera [Wed, 12 Apr 2023 17:29:21 +0000 (19:29 +0200)]
Revert "Catalog NOT NULL constraints" and fallout

This reverts commit e056c557aef4 and minor later fixes thereof.

There's a few problems in this new feature -- most notably regarding
pg_upgrade behavior, but others as well.  This new feature is not in any
way critical on its own, so instead of scrambling to fix it we revert it
and try again in early 17 with these issues in mind.

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

2 years agobasebackup_to_shell: Check for a NULL return from OpenPipeStream.
Robert Haas [Wed, 12 Apr 2023 15:37:13 +0000 (11:37 -0400)]
basebackup_to_shell: Check for a NULL return from OpenPipeStream.

Per complaint from Peter Eisentraut.

Discussion: http://postgr.es/m/4f1707cc-2432-da35-64a2-5c2a8d92a388@enterprisedb.com

2 years agoDocument BaseBackupSync and BaseBackupWrite wait events.
Robert Haas [Wed, 12 Apr 2023 15:18:40 +0000 (11:18 -0400)]
Document BaseBackupSync and BaseBackupWrite wait events.

Commit 3500ccc39b0dadd1068a03938e4b8ff562587ccc should have done
this, but I overlooked it.

Per complaint from Thomas Munro.

Discussion: http://postgr.es/m/CA+hUKGJixAHc860Ej9Qzd_z96Z6aoajAgJ18bYfV3Lfn6t9=+Q@mail.gmail.com

2 years agoFix parallel-safety marking when moving initplans to another node.
Tom Lane [Wed, 12 Apr 2023 14:46:30 +0000 (10:46 -0400)]
Fix parallel-safety marking when moving initplans to another node.

Our policy since commit ab77a5a45 has been that a plan node having
any initplans is automatically not parallel-safe.  (This could be
relaxed, but not today.)  clean_up_removed_plan_level neglected
this, and could attach initplans to a parallel-safe child plan
node without clearing the plan's parallel-safe flag.  That could
lead to "subplan was not initialized" errors at runtime, in case
an initplan referenced another one and only the referencing one
got transmitted to parallel workers.

The fix in clean_up_removed_plan_level is trivial enough.
materialize_finished_plan also moves initplans from one node
to another, but it's okay because it already copies the source
node's parallel_safe flag.  The other place that does this kind
of thing is standard_planner's hack to inject a top-level Gather
when debug_parallel_query is active.  But that's actually dead
code given that we're correctly enforcing the "initplans aren't
parallel safe" rule, so just replace it with an Assert that
there are no initplans.

Also improve some related comments.

Normally we'd add a regression test case for this sort of bug.
The mistake itself is already reached by existing tests, but there
is accidentally no visible problem.  The only known test case that
creates an actual failure seems too indirect and fragile to justify
keeping it as a regression test (not least because it fails to fail
in v11, though the bug is clearly present there too).

Per report from Justin Pryzby.  Back-patch to all supported branches.

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

2 years agodoc: Reword unexplained abbreviation
Daniel Gustafsson [Wed, 12 Apr 2023 14:16:12 +0000 (16:16 +0200)]
doc: Reword unexplained abbreviation

The previous wording used MVF to indicate the Most Common Values'
Frequencies, but the abbreviation was never explained or defined.
Reword to mcv_freqs to make the use clearer.

Also add MCF and MCV as acronyms as they were using <acronym>
markup but were missing from the acronyms page.

Reported-by: Eric Mutta <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/166112292492.654.5377188452604176150@wrigleys.postgresql.org

2 years agoFix incorrect format placeholders
Peter Eisentraut [Wed, 12 Apr 2023 08:05:50 +0000 (10:05 +0200)]
Fix incorrect format placeholders

2 years agoUpdate config.guess and config.sub
Peter Eisentraut [Wed, 12 Apr 2023 07:16:19 +0000 (09:16 +0200)]
Update config.guess and config.sub

2 years agodoc: Fix some typos and grammar
Michael Paquier [Wed, 12 Apr 2023 04:03:09 +0000 (13:03 +0900)]
doc: Fix some typos and grammar

This is a first batch of the fixes, for the most obvious fixes.  A
little bit more is under discussion.

Author: Thom Brown, Justin Pryzby
Discussion: https://postgr.es/m/CAA-aLv7xCZ0nBJa-NWe0rxBB28TjFjS2JtjiZMoQ+0wsugG+hQ@mail.gmail.com

2 years agoFix detection of unseekable files for fseek() and ftello() with MSVC
Michael Paquier [Wed, 12 Apr 2023 00:09:38 +0000 (09:09 +0900)]
Fix detection of unseekable files for fseek() and ftello() with MSVC

Calling fseek() or ftello() on a handle to a non-seeking device such as
a pipe or a communications device is not supported.  Unfortunately,
MSVC's flavor of these routines, _fseeki64() and _ftelli64(), do not
return an error when given a pipe as handle.  Some of the logic of
pg_dump and restore relies on these routines to check if a handle is
seekable, causing failures when passing the contents of pg_dump to
pg_restore through a pipe, for example.

This commit introduces wrappers for fseeko() and ftello() on MSVC so as
any callers are able to properly detect the cases of non-seekable
handles.  This relies mainly on GetFileType(), sharing a bit of code
with the MSVC port for fstat().  The code in charge of getting a file
type is refactored into a new file called win32common.c, shared by
win32stat.c and the new win32fseek.c.  It includes the MSVC ports for
fseeko() and ftello().

Like 765f5df, this is backpatched down to 14, where the fstat()
implementation for MSVC is able to understand about files larger than
4GB in size.  Using a TAP test for that is proving to be tricky as
IPC::Run handles the pipes by itself, still I have been able to check
the fix manually.

Reported-by: Daniel Watzinger
Author: Juan José Santamaría Flecha, Michael Paquier
Discussion: https://postgr.es/m/CAC+AXB26a4EmxM2suXxPpJaGrqAdxracd7hskLg-zxtPB50h7A@mail.gmail.com
Backpatch-through: 14

2 years agoRefine the guidelines for rmgrdesc authors.
Peter Geoghegan [Tue, 11 Apr 2023 22:26:24 +0000 (15:26 -0700)]
Refine the guidelines for rmgrdesc authors.

Clarify the goals of the recently added guidelines for rmgrdesc authors:
to avoid gratuitous inconsistencies across resource managers, and to
make it reasonably easy to write a reusable custom parser.

Beyond that, the guidelines leave rmgrdesc authors with a significant
amount of leeway.  This even includes the leeway to invent custom
conventions (in cases where it's warranted).

Follow-up to commit 7d8219a4.

Author: Peter Geoghegan <[email protected]>
Reviewed-By: Melanie Plageman <[email protected]>
Discussion: https://postgr.es/m/CAH2-WzkbYuvwYKm-Y-72QEh6SPMQcAo9uONv+mR3bMGcu9E_Cg@mail.gmail.com

2 years agoFix Heap rmgr's desc output for infobits arrays.
Peter Geoghegan [Tue, 11 Apr 2023 22:25:02 +0000 (15:25 -0700)]
Fix Heap rmgr's desc output for infobits arrays.

Make heap desc routines that output status bit as arrays of constants
avoid outputting array literals that contain superfluous punctuation
characters that complicate parsing the output.  Also make sure that no
heap desc routine repeats the same key name (at the same nesting level),
for the same reason.  Arguably, these were both oversights in commit
7d8219a4.

In passing, make the desc output code (which covers Heap's DELETE,
UPDATE, HOT_UPDATE, LOCK, and LOCK_UPDATED record types) consistent in
terms of the output order of each field.  This order also matches WAL
record struct order.  Heap's DELETE desc output now shows the record's
xmax field for the first time (just like UPDATE/HOT_UPDATE records).

Author: Peter Geoghegan <[email protected]>
Reviewed-By: Melanie Plageman <[email protected]>
Discussion: https://postgr.es/m/CAH2-Wz=pNYtxiJ2Jx5Lj=fKo1OEZ4GE0p_kct+ugAUTqBwU46g@mail.gmail.com

2 years agoFix xl_heap_lock WAL record field's data type.
Peter Geoghegan [Tue, 11 Apr 2023 21:07:54 +0000 (14:07 -0700)]
Fix xl_heap_lock WAL record field's data type.

Make xl_heap_lock's infobits_set field of type uint8, not int8.  Using
int8 isn't appropriate given that the field just holds status bits.
This fixes an oversight in commit 0ac5ad5134.

In passing rename the nearby TransactionId field to "xmax" to make
things consistency with related records, such as xl_heap_lock_updated.

Deliberately avoid a bump in XLOG_PAGE_MAGIC.  No backpatch, either.

Author: Peter Geoghegan <[email protected]>
Discussion: https://postgr.es/m/CAH2-WzkCd3kOS8b7Rfxw7Mh1_6jvX=Nzo-CWR1VBTiOtVZkWHA@mail.gmail.com

2 years ago035_standby_logical_decoding: Add missing waits for replication
Andres Freund [Tue, 11 Apr 2023 18:17:36 +0000 (11:17 -0700)]
035_standby_logical_decoding: Add missing waits for replication

At least one slow buildfarm system (hoverfly) showed that the database
creation was not replicated before we try to create logical replication slots
on the standby, in that database.

Reported-by: Noah Misch <[email protected]>
Author: "Drouvot, Bertrand" <[email protected]>
Discussion: https://postgr.es/m/20230411053657[email protected]

2 years agoDocument new pg_subscription columns.
Robert Haas [Tue, 11 Apr 2023 15:00:36 +0000 (11:00 -0400)]
Document new pg_subscription columns.

Commit 482675987bcdffb390ae735cfd5f34b485ae97c6 and commit
c3afe8cf5a1e465bd71e48e4bc717f5bfdc7a7d6 forgot to take care
of this.

Noriyoshi Shinoda

Discussion: http://postgr.es/m/DM4PR84MB17345D8760165F14A199B81CEE9A9@DM4PR84MB1734.NAMPRD84.PROD.OUTLOOK.COM

2 years agoFix uninitialized variable in transformTableLikeClause()
David Rowley [Tue, 11 Apr 2023 11:01:12 +0000 (23:01 +1200)]
Fix uninitialized variable in transformTableLikeClause()

process_notnull_constraints should be set to false until we discover a NOT
NULL column.

Discovered while running Valgrind.

Discussion: https://postgr.es/m/CAApHDvoMyiZVi1KW5WVdqMRzWsWkD3F7n6QD+BbAO6WTeAWsUQ@mail.gmail.com

2 years agoImprove ereports for VACUUM's BUFFER_USAGE_LIMIT option
David Rowley [Tue, 11 Apr 2023 07:36:34 +0000 (19:36 +1200)]
Improve ereports for VACUUM's BUFFER_USAGE_LIMIT option

There's no need to check if opt->arg is NULL since defGetString() already
does that and raises an ERROR if it is.  Let's just remove that check.

Also, combine the two remaining ERRORs into a single check.  It seems
better to give an indication about what sort of values we're looking for
rather than just to state that the value given isn't valid.  Make
BUFFER_USAGE_LIMIT uppercase in this ERROR message too.  It's already
upper case in one other error message, so make that consistent.

Reported-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/20230411.102335.1643720544536884844[email protected]

2 years agoDoc: use "an SQL" consistently rather than "a SQL"
David Rowley [Tue, 11 Apr 2023 06:52:17 +0000 (18:52 +1200)]
Doc: use "an SQL" consistently rather than "a SQL"

Similarly to what was done in 04539e73f and 7bdd489d3, we standardized on
SQL being pronounced "es-que-ell" rather than "sequel" in our
documentation.

This fixes the instances of "a SQL" that have crept in during the v16
cycle.

Discussion: https://postgr.es/m/CAApHDvpML27UqFXnrYO1MJddsKVMQoiZisPvsAGhKE_tsKXquw%40mail.gmail.com

2 years agoClarify nbtree posting list update desc issue.
Peter Geoghegan [Tue, 11 Apr 2023 00:55:23 +0000 (17:55 -0700)]
Clarify nbtree posting list update desc issue.

Per complaint from Melanie Plageman.

Follow-up to commit 5d6728e5.

Reported-By: Melanie Plageman <[email protected]>
Discussion: https://postgr.es/m/20230411002315.oyaicmcqrq2hb3ek@liskov

2 years agoDoc: add missed entries in BRIN extensibility tables.
Tom Lane [Mon, 10 Apr 2023 19:49:48 +0000 (15:49 -0400)]
Doc: add missed entries in BRIN extensibility tables.

The tables in "71.3. Extensibility" listing the support functions
for bloom and minmax-multi opclasses should include the associated
options function.  While this isn't quite as required as the rest,
you need it for full functionality of the opclass.

Back-patch to v14 where these functions were added.

2 years agoFix nbtree posting list update desc output.
Peter Geoghegan [Mon, 10 Apr 2023 18:15:41 +0000 (11:15 -0700)]
Fix nbtree posting list update desc output.

We cannot use the generic array_desc approach with per-tuple nbtree
posting list update metadata because array_desc can only deal with fixed
width elements (e.g., page offset numbers).  Using array_desc led to
incorrect rmgr descriptions for updates from nbtree DELETE/VACUUM WAL
records.

To fix, add specialized code to describe the update metadata as array
elements in desc output.  We now iterate over the update metadata using
an approach that matches related REDO routines.

Also stop showing the updates offset number array separately in nbtree
DELETE/VACUUM desc output.  It's redundant information, since the same
page offset numbers appear in the description of each individual update
element.  Also make some small tweaks to the way that we format arrays
in all desc routines (not just nbtree desc routines) to make arrays a
little less verbose.

Oversight in commit 1c453cfd, which enhanced the nbtree rmgr desc
routines.

Author: Peter Geoghegan <[email protected]>
Discussion: https://postgr.es/m/CAH2-WzkbYuvwYKm-Y-72QEh6SPMQcAo9uONv+mR3bMGcu9E_Cg@mail.gmail.com

2 years agoDoc: adjust examples of EXTRACT() output to match current reality.
Tom Lane [Mon, 10 Apr 2023 17:09:18 +0000 (13:09 -0400)]
Doc: adjust examples of EXTRACT() output to match current reality.

EXTRACT(EPOCH), EXTRACT(SECOND), and some related cases print more
trailing zeroes than they used to.  This behavior change happened
with commit a2da77cdb (Change return type of EXTRACT to numeric),
and it was intentional according to the commit log:

    - Return values when extracting fields with possibly fractional
      values, such as second and epoch, now have the full scale that the
      value has internally (so, for example, '1.000000' instead of just
      '1').

It's been like that for two releases now, so while I suggested
changing this back, it's probably better to adjust the documentation
examples.

Per bug #17866 from Евгений Жужнев.  Back-patch to v14 where the
change came in.

Discussion: https://postgr.es/m/17866-18eb70095b1594e2@postgresql.org

2 years agoDoc: avoid using pg_get_publication_tables() in an example.
Tom Lane [Mon, 10 Apr 2023 16:22:10 +0000 (12:22 -0400)]
Doc: avoid using pg_get_publication_tables() in an example.

pg_get_publication_tables() is undocumented because it's only meant
as infrastructure for the pg_publication_tables system view.
That being the case, we should use the view not the bare function
in this sample query.

Shi Yu

Discussion: https://postgr.es/m/OSZPR01MB63107E83D07FEDEEABD83A23FD949@OSZPR01MB6310.jpnprd01.prod.outlook.com

2 years agoSimplify version check for SKIP clause
Daniel Gustafsson [Sat, 8 Apr 2023 21:32:11 +0000 (23:32 +0200)]
Simplify version check for SKIP clause

Checking for the required versions of IO::Pty as well as IPC::Run
can be achieved with a single eval call, and by using the VERSION
function the comparison is guaranteed to follow the same rules as
calling 'use' on the module with a version.

Reported-by: Andrew Dunstan <[email protected]>
Discussion: https://postgr.es/m/6d880ea2-f8ca-f458-4dcd-a7a3e6d6cd7c@dunslane.net

2 years agoUse higher wal_level for 004_io_direct.pl.
Thomas Munro [Sat, 8 Apr 2023 20:27:36 +0000 (08:27 +1200)]
Use higher wal_level for 004_io_direct.pl.

The new direct I/O test deliberately uses a very small shared_buffers to
force some disk transfers without making the data set large and slow,
but ran into a problem with wal_level = minimal: log_newpage_range()
pins many buffers, leading to a few intermittent "no unpinned buffers
available" errors.

We could presumably fix that by adjusting shared_buffers, but crake
seems to be trying to tell us something interesting with these settings,
so let's just avoid wal_level = minimal in this test for now.

Reported-by: Andres Freund <[email protected]>
Discussion: https://postgr.es/m/20230408060408.n7xdwk3mxj5oykt6%40awork3.anarazel.de

2 years agoImprove indentation of multiline initialization expressions.
Tom Lane [Sat, 8 Apr 2023 15:48:36 +0000 (11:48 -0400)]
Improve indentation of multiline initialization expressions.

If a variable has an initialization expression that wraps onto the
next line(s), pg_bsd_indent will now indent the continuation lines
one stop, instead of aligning them flush with the variable declaration.

We've been holding off applying this until the last v16 CF finished,
but now it's time.

Thomas Munro and Tom Lane

Discussion: https://postgr.es/m/20230120013137[email protected]

2 years agoTry to unbreak MSVC builds for pg_waldump
Andrew Dunstan [Sat, 8 Apr 2023 15:19:18 +0000 (11:19 -0400)]
Try to unbreak MSVC builds for pg_waldump

remedy an omission in commit 7d8219a444

2 years agoSuppress bogus printout during new 035_standby_logical_decoding.pl test.
Tom Lane [Sat, 8 Apr 2023 14:50:46 +0000 (10:50 -0400)]
Suppress bogus printout during new 035_standby_logical_decoding.pl test.

Our convention for some time has been that successful tests shouldn't
print anything on stderr.  A stray "diag" call violated that, and
for that matter messed up the normal TAP progress display.

2 years agoSkip \password TAP test on old IPC::Run versions
Daniel Gustafsson [Sat, 8 Apr 2023 13:51:45 +0000 (15:51 +0200)]
Skip \password TAP test on old IPC::Run versions

IPC::Run versions prior to 0.98 cause the interactive session to time out,
so SKIP the test in case these versions are detected (they are within the
base requirement for our TAP tests in general).  Error reported by the BF
and investigation by Tom Lane.

Discussion: https://postgr.es/m/414A86BD-986B-48A7-A1E4-EEBCE5AF08CB@yesql.se

2 years agoTry to unbreak MSVC builds for fuzzystrmatch
Andrew Dunstan [Sat, 8 Apr 2023 12:26:19 +0000 (08:26 -0400)]
Try to unbreak MSVC builds for fuzzystrmatch

Commit a290378a37 neglrected to add a recipe for MSVC to build the
daitch_motokoff.h file.

Per buildfarm animal bowerbird.

2 years agoRevert "Add support for Kerberos credential delegation"
Stephen Frost [Sat, 8 Apr 2023 11:21:35 +0000 (07:21 -0400)]
Revert "Add support for Kerberos credential delegation"

This reverts commit 3d4fa227bce4294ce1cc214b4a9d3b7caa3f0454.

Per discussion and buildfarm, this depends on APIs that seem to not
be available on at least one platform (NetBSD).  Should be certainly
possible to rework to be optional on that platform if necessary but bit
late for that at this point.

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

2 years agoRedesign interrupt/cancel API for regex engine.
Thomas Munro [Sat, 8 Apr 2023 09:57:46 +0000 (21:57 +1200)]
Redesign interrupt/cancel API for regex engine.

Previously, a PostgreSQL-specific callback checked by the regex engine
had a way to trigger a special error code REG_CANCEL if it detected that
the next call to CHECK_FOR_INTERRUPTS() would certainly throw via
ereport().

A later proposed bugfix aims to move some complex logic out of signal
handlers, so that it won't run until the next CHECK_FOR_INTERRUPTS(),
which makes the above design impossible unless we split
CHECK_FOR_INTERRUPTS() into two phases, one to run logic and another to
ereport().  We may develop such a system in the future, but for the
regex code it is no longer necessary.

An earlier commit moved regex memory management over to our
MemoryContext system.  Given that the purpose of the two-phase interrupt
checking was to free memory before throwing, something we don't need to
worry about anymore, it seems simpler to inject CHECK_FOR_INTERRUPTS()
directly into cancelation points, and just let it throw.

Since the plan is to keep PostgreSQL-specific concerns separate from the
main regex engine code (with a view to bein able to stay in sync with
other projects), do this with a new macro INTERRUPT(), customizable in
regcustom.h and defaulting to nothing.

Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGK3PGKwcKqzoosamn36YW-fsuTdOPPF1i_rtEO%3DnEYKSg%40mail.gmail.com