Peter Geoghegan [Mon, 8 May 2023 20:17:31 +0000 (13:17 -0700)]
Doc: update VACUUM FREEZE query conflict guidance.
Commit
1de58df4, which added page-level freezing, taught VACUUM to reuse
each page's "set-visibility-map" snapshotConflictHorizon for freezing
(at least in the vast majority of cases where freezing went ahead).
This made VACUUM FREEZE much less prone to generating recovery conflicts
on standbys; VACUUM FREEZE became only slightly more likely to cause
recovery conflicts than an equivalent VACUUM.
Update old documentation that specifically warned of the likelihood of
recovery conflicts from VACUUM FREEZE. Explain the same general issue
(the issue of VACUUM generating recovery conflicts even in the absence
of dead row cleanup) using the example of conflicts caused by VISIBLE
WAL records.
Jeff Davis [Mon, 8 May 2023 17:34:51 +0000 (10:34 -0700)]
ICU: do not convert locale 'C' to 'en-US-u-va-posix'.
The conversion was intended to be for convenience, but it's more
likely to be confusing than useful.
The user can still directly specify 'en-US-u-va-posix' if desired.
Discussion: https://postgr.es/m/
f83f089ee1e9acd5dbbbf3353294d24e1f196e95[email protected]
Discussion: https://postgr.es/m/
37520ec1ae9591f83132f82dbd625f3fc2d69c16[email protected]
Tom Lane [Mon, 8 May 2023 15:24:47 +0000 (11:24 -0400)]
Adjust sepgsql expected output for
681d9e462 et al.
Security: CVE-2023-2454
Tom Lane [Mon, 8 May 2023 14:12:44 +0000 (10:12 -0400)]
Handle RLS dependencies in inlined set-returning functions properly.
If an SRF in the FROM clause references a table having row-level
security policies, and we inline that SRF into the calling query,
we neglected to mark the plan as potentially dependent on which
role is executing it. This could lead to later executions in the
same session returning or hiding rows that should have been hidden
or returned instead.
Our thanks to Wolfgang Walther for reporting this problem.
Stephen Frost and Tom Lane
Security: CVE-2023-2455
Noah Misch [Mon, 8 May 2023 13:14:07 +0000 (06:14 -0700)]
Replace last PushOverrideSearchPath() call with set_config_option().
The two methods don't cooperate, so set_config_option("search_path",
...) has been ineffective under non-empty overrideStack. This defect
enabled an attacker having database-level CREATE privilege to execute
arbitrary code as the bootstrap superuser. While that particular attack
requires v13+ for the trusted extension attribute, other attacks are
feasible in all supported versions.
Standardize on the combination of NewGUCNestLevel() and
set_config_option("search_path", ...). It is newer than
PushOverrideSearchPath(), more-prevalent, and has no known
disadvantages. The "override" mechanism remains for now, for
compatibility with out-of-tree code. Users should update such code,
which likely suffers from the same sort of vulnerability closed here.
Back-patch to v11 (all supported versions).
Alexander Lakhin. Reported by Alexander Lakhin.
Security: CVE-2023-2454
Peter Eisentraut [Mon, 8 May 2023 06:24:42 +0000 (08:24 +0200)]
Add missing source file to nls.mk
Peter Eisentraut [Mon, 8 May 2023 05:43:54 +0000 (07:43 +0200)]
pg_dump: Restore lost translation marker
The refactoring in
03d02f54a6 lost a translation marker.
Michael Paquier [Mon, 8 May 2023 04:47:36 +0000 (13:47 +0900)]
doc: Fix some markups in logical replication section
Author: Peter Smith
Reviewed-by: David Zhang
Discussion: https://postgr.es/m/CAHut+Pst11ac2hcmePt1=oTmBwTT=DAssRR1nsdoy4BT+68=Mg@mail.gmail.com
Peter Eisentraut [Mon, 8 May 2023 04:15:26 +0000 (06:15 +0200)]
pg_basebackup: Restore lost translation markers
The refactoring in
ebfb814f7c lost some translation markers.
Tom Lane [Sun, 7 May 2023 15:01:15 +0000 (11:01 -0400)]
Add ruleutils support for decompiling MERGE commands.
This was overlooked when MERGE was added, but it's essential
support for MERGE in new-style SQL functions.
Alvaro Herrera
Discussion: https://postgr.es/m/
3579737.
1683293801@sss.pgh.pa.us
Michael Paquier [Fri, 5 May 2023 12:25:44 +0000 (21:25 +0900)]
Fix typo with wait event for SLRU buffer of commit timestamps
This wait event was documented as "CommitTsBuffer" since its
introduction, but the code named it "CommitTSBuffer". This commit fixes
the code to follow the term documented, which is also more consistent
with the naming of the other wait events used for commit timestamps.
Introduced by
5da1493.
Author: Alexander Lakhin
Discussion: https://postgr.es/m/
e8c38840-596a-83d6-bd8d-
cebc51111572@gmail.com
Backpatch-through: 13
Alvaro Herrera [Fri, 5 May 2023 09:10:25 +0000 (11:10 +0200)]
Fix sepgsql expected test output
Commit
f75cec4fff87 changed the order in which the relations are
permission-checked in RI_Initial_Check, which the sepgsql test is
sensitive to. Adapt.
Discussion: https://postgr.es/m/
3468125.
1683238309@sss.pgh.pa.us
Peter Eisentraut [Fri, 5 May 2023 05:50:08 +0000 (07:50 +0200)]
Fix copy-and-pasto in error message
from
2fe3bdbd69
Peter Eisentraut [Fri, 5 May 2023 04:29:49 +0000 (06:29 +0200)]
Fix prove_installcheck when used with PGXS
Commit
153e215677 added the portlock directory. This is created in
$ENV{top_builddir} if it is set. Under PGXS, top_builddir points into
the installation directory, which is not necessarily writable and in
any case inappropriate to use by a test suite. The cause of the
problem is that the prove_installcheck target in Makefile.global
exports top_builddir, which isn't useful (since no other Perl code
actually reads it) and breaks this use case. The reason this code is
there is probably that is has been dragged around with various other
changes, in particular
a0fc813266, but without a real purpose of its
own. By just removing the exporting of top_builddir in
prove_installcheck, the portlock directory then ends up under
tmp_check in the build directory, which is more suitable.
Reviewed-by: Andrew Dunstan <[email protected]>
Discussion: https://www.postgresql.org/message-id/
78d1cfa6-0065-865d-584b-
cde6d8c18aff@enterprisedb.com
Nathan Bossart [Wed, 3 May 2023 18:32:43 +0000 (11:32 -0700)]
Move return statements out of PG_TRY blocks.
If we exit a PG_TRY block early via "continue", "break", "goto", or
"return", we'll skip unwinding its exception stack. This change
moves a couple of such "return" statements in PL/Python out of
PG_TRY blocks. This was introduced in
d0aa965c0a and affects all
supported versions.
We might also be able to add compile-time checks to prevent
recurrence, but that is left as a future exercise.
Reported-by: Mikhail Gribkov, Xing Guo
Author: Xing Guo
Reviewed-by: Michael Paquier, Andres Freund, Tom Lane
Discussion: https://postgr.es/m/CAMEv5_v5Y%2B-D%3DCO1%2Bqoe16sAmgC4sbbQjz%2BUtcHmB6zcgS%2B5Ew%40mail.gmail.com
Discussion: https://postgr.es/m/CACpMh%2BCMsGMRKFzFMm3bYTzQmMU5nfEEoEDU2apJcc4hid36AQ%40mail.gmail.com
Backpatch-through: 11 (all supported versions)
Alvaro Herrera [Thu, 4 May 2023 17:55:56 +0000 (19:55 +0200)]
Fix ExecCheckPermissions call in RI_Initial_Check
RI_Initial_Check was setting up a list of RTEPermissionInfo for
ExecCheckPermissions() wrong, and the problem is subtle enough that it
doesn't have any immediate effect in core code. However, if an
extension is using the ExecutorCheckPerms_hook, then it would get the
wrong parameters and perhaps arrive at a wrong conclusion, or outright
malfunction. Fix by constructing that list and the RTE list more
honestly.
We also add an assertion check to verify that these lists match. This
new assertion would have caught this bug.
Co-authored-by: Олег Целебровский (Oleg Tselebrovskii) <[email protected]>
Co-authored-by: Álvaro Herrera <[email protected]>
Reviewed-by: Amit Langote <[email protected]>
Discussion: https://postgr.es/m/
3722b7a2cbe27a1796ee40824bd86dd1@postgrespro.ru
Tom Lane [Thu, 4 May 2023 15:48:23 +0000 (11:48 -0400)]
In array_position()/array_positions(), beware of empty input array.
These functions incautiously fetched the array's first lower bound
even when the array is zero-dimensional, thus fetching the word
after the allocated array space. While almost always harmless,
with very bad luck this could result in SIGSEGV. Fix by adding
an early exit for empty input.
Per bug #17920 from Alexander Lakhin.
Discussion: https://postgr.es/m/17920-
f7c228c627b6d02e%40postgresql.org
Tom Lane [Thu, 4 May 2023 15:00:33 +0000 (11:00 -0400)]
Tighten array dimensionality checks in Python -> SQL array conversion.
Like plperl before
f47004add, plpython wasn't being sufficiently
careful about checking that list-of-list structures represent
rectangular arrays, so that it would accept some cases in which
different parts of the "array" are nested to different depths.
This was exacerbated by Python's weak distinction between
sequences and lists, so that in some cases strings could get
treated as though they are lists (and burst into individual
characters) even though a different ordering of the upper-level
list would give a different result.
Some of this behavior was unreachable (without risking a crash)
before
81eaaf65e. It seems like a good idea to clean it all up
in the same releases, rather than shipping a non-crashing but
nonetheless visibly buggy behavior in the name of minimal change.
Hence, back-patch.
Per bug #17912 and further testing by Alexander Lakhin.
Discussion: https://postgr.es/m/17912-
82ceed78731d9cdc@postgresql.org
Alvaro Herrera [Thu, 4 May 2023 10:09:59 +0000 (12:09 +0200)]
Revert "Move PartitionPruneInfo out of plan nodes into PlannedStmt"
This reverts commit
ec386948948c and its fixup
589bb816499e.
This change was intended to support query planning avoiding acquisition
of locks on partitions that were going to be pruned; however, the
overall project took a different direction at [1] and this bit is no
longer needed. Put things back the way they were as agreed in [2], to
avoid unnecessary complexity.
Discussion: [1] https://postgr.es/m/
4191508.
1674157166@sss.pgh.pa.us
Discussion: [2] https://postgr.es/m/
20230502175409[email protected]
Peter Eisentraut [Thu, 4 May 2023 04:44:38 +0000 (06:44 +0200)]
doc: New glossary entries
Add:
- "Restartpoint"
- "Log sequence number"
"LSN" was already listed in the Acronyms appendix, but it is more
suitable as a glossary entry, so move it there and have the acronyms
entry link into the glossary.
Also turn on DocBook parameter glossentry.show.acronym to show
acronyms for glossary entries, which is being used here.
Reviewed-by: Daniel Gustafsson <[email protected]>
Reviewed-by: Alvaro Herrera <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
60915312-62cd-9c94-0d94-
556023ece45f%40enterprisedb.com
Amit Kapila [Thu, 4 May 2023 03:03:56 +0000 (08:33 +0530)]
Test that invalidated logical slots doesn't retain WAL.
Author: Bertrand Drouvot
Reviewed-by: Shi yu, Amit Kapila, Vignesh C
Discussion: https://postgr.es/m/
2fefa454-5a70-2174-ddbf-
4a0e41537139@gmail.com
Peter Eisentraut [Wed, 3 May 2023 09:08:24 +0000 (11:08 +0200)]
Add missing TAP test name
Amit Kapila [Wed, 3 May 2023 04:43:13 +0000 (10:13 +0530)]
Fix assertion failure in apply worker.
During exit, the logical replication apply worker tries to release session
level locks, if any. However, if the apply worker exits due to an error
before its connection is initialized, trying to release locks can lead to
assertion failure. The locks will be acquired once the worker is
initialized, so we don't need to release them till the worker
initialization is complete.
Reported-by: Alexander Lakhin
Author: Hou Zhijie based on inputs from Sawada Masahiko and Amit Kapila
Reviewed-by: Amit Kapila
Discussion: https://postgr.es/m/
2185d65f-5aae-3efa-c48f-
fb42b173ef5c@gmail.com
Tom Lane [Tue, 2 May 2023 21:55:01 +0000 (17:55 -0400)]
Doc: clarify behavior of row-limit arguments in the PLs' SPI wrappers.
plperl, plpython, and pltcl all provide query-execution functions
that are thin wrappers around SPI_execute() or its variants.
The SPI functions document their row-count limit arguments clearly,
as "maximum number of rows to return, or 0 for no limit". However
the PLs' documentation failed to explain this special behavior of
zero, so that a reader might well assume it means "fetch zero
rows". Improve that.
Daniel Gustafsson and Tom Lane, per report from Kieran McCusker
Discussion: https://postgr.es/m/CAGgUQ6H6qYScctOhktQ9HLFDDoafBKHyUgJbZ6q_dOApnzNTXg@mail.gmail.com
Daniel Gustafsson [Tue, 2 May 2023 11:15:29 +0000 (13:15 +0200)]
Fix overridden callbacks in pg_rewind.
The <source>_traverse_files functions take a callback for processing
files, but both the local and libpq source implementations called the
function directly without using the callback argument. While there is
no bug right now as the function called is the same as the callback,
fix by calling the callback to reduce the risk of subtle bugs in the
future.
Author: Junwang Zhao <
[email protected]>
Reviewed-by: Richard Guo <[email protected]>
Discussion: https://postgr.es/m/CAEG8a3Jdwgh+PZr2zh1=t8apA4Yz8tKq+uubPqoCt14nvWKHEw@mail.gmail.com
Peter Eisentraut [Tue, 2 May 2023 08:59:21 +0000 (10:59 +0200)]
Update SQL features
Some updates for SQL:2023 and some new features in PostgreSQL 16.
Peter Eisentraut [Tue, 2 May 2023 07:41:03 +0000 (09:41 +0200)]
Add missing uninstallation rule for BackgroundPsql.pm
Commit
a4c17c8617 added in the install rule but not the uninstall
rule.
Michael Paquier [Tue, 2 May 2023 03:23:08 +0000 (12:23 +0900)]
Fix typos in comments
The changes done in this commit impact comments with no direct
user-visible changes, with fixes for incorrect function, variable or
structure names.
Author: Alexander Lakhin
Discussion: https://postgr.es/m/
e8c38840-596a-83d6-bd8d-
cebc51111572@gmail.com
Michael Paquier [Tue, 2 May 2023 02:40:46 +0000 (11:40 +0900)]
doc: Fix typo in pg_amcheck for term "schema"
Author: Alexander Lakhin
Discussion: https://postgr.es/m/
e8c38840-596a-83d6-bd8d-
cebc51111572@gmail.com
Backpatch-through: 14
Tom Lane [Sat, 29 Apr 2023 17:06:44 +0000 (13:06 -0400)]
Tighten array dimensionality checks in Perl -> SQL array conversion.
plperl_array_to_datum() wasn't sufficiently careful about checking
that nested lists represent a rectangular array structure; it would
accept inputs such as "[1, []]". This is a bit related to the
PL/Python bug fixed in commit
81eaaf65e, but it doesn't seem to
provide any direct route to a memory stomp. Instead the likely
failure mode is for makeMdArrayResult to be passed fewer Datums than
the claimed array dimensionality requires, possibly leading to a wild
pointer dereference and SIGSEGV.
Per report from Alexander Lakhin. It's been broken for a long
time, so back-patch to all supported branches.
Discussion: https://postgr.es/m/
5ebae5e4-d401-fadf-8585-
ac3eaf53219c@gmail.com
Tom Lane [Fri, 28 Apr 2023 16:24:29 +0000 (12:24 -0400)]
Handle zero-length sublist correctly in Python -> SQL array conversion.
If PLySequence_ToArray came across a zero-length sublist, it'd compute
the overall array size as zero, possibly leading to a memory clobber.
(This would likely qualify as a security bug, were it not that plpython
is an untrusted language already.)
I think there are other corner-case issues in this code as well, notably
that the error messages don't match the core code and for some ranges
of array sizes you'd get "invalid memory alloc request size" rather than
the intended message about array size.
Really this code has no business doing its own array size calculation
at all, so remove the faulty code in favor of using ArrayGetNItems().
Per bug #17912 from Alexander Lakhin. Bug seems to have come in with
commit
94aceed31, so back-patch to all supported branches.
Discussion: https://postgr.es/m/17912-
82ceed78731d9cdc@postgresql.org
Michael Paquier [Fri, 28 Apr 2023 10:29:12 +0000 (19:29 +0900)]
Fix crashes with CREATE SCHEMA AUTHORIZATION and schema elements
CREATE SCHEMA AUTHORIZATION with appended schema elements can lead to
crashes when comparing the schema name of the query with the schemas
used in the qualification of some clauses in the elements' queries.
The origin of the problem is that the transformation routine for the
elements listed in a CREATE SCHEMA query uses as new, expected, schema
name the one listed in CreateSchemaStmt itself. However, depending on
the query, CreateSchemaStmt.schemaname may be NULL, being computed
instead from the role specification of the query given by the
AUTHORIZATION clause, that could be either:
- A user name string, with the new schema name being set to the same
value as the role given.
- Guessed from CURRENT_ROLE, SESSION_ROLE or CURRENT_ROLE, with a new
schema name computed from the security context where CREATE SCHEMA is
running.
Regression tests are added for CREATE SCHEMA with some appended elements
(some of them with schema qualifications), covering also some role
specification patterns.
While on it, this simplifies the context structure used during the
transformation of the elements listed in a CREATE SCHEMA query by
removing the fields for the role specification and the role type. They
were not used, and for the role specification this could be confusing as
the schema name may by extracted from that at the beginning of
CreateSchemaCommand().
This issue exists for a long time, so backpatch down to all the versions
supported.
Reported-by: Song Hongyu
Author: Michael Paquier
Reviewed-by: Richard Guo
Discussion: https://postgr.es/m/17909-
f65c12dfc5f0451d@postgresql.org
Backpatch-through: 11
Daniel Gustafsson [Fri, 28 Apr 2023 08:30:05 +0000 (10:30 +0200)]
Fix assertion failure in heap_vacuum_rel
Commit
7d71d3dd08 changed resetting the VacuumFailsafeActive flag to an
assertion since the flag is reset before starting vacuuming a relation.
This however failed to take recursive calls of vacuum_rel() and vacuum
of TOAST tables into consideration. Fix by reverting back to resettting
the flag.
Author: Masahiko Sawada <
[email protected]>
Reviewed-by: Melanie Plageman <[email protected]>
Reported-by: John Naylor <[email protected]>
Discussion: https://postgr.es/m/CAFBsxsFz=GqaG5Ens5aNgVYoV2Y+pfMUijX0ku+CCkWfALwiqg@mail.gmail.com
Masahiko Sawada [Fri, 28 Apr 2023 06:40:12 +0000 (15:40 +0900)]
Add unit to vacuum_buffer_usage_limit value in postgresql.conf.sample.
Also adjust the indentation of the comment to the surrounding parameters.
Author: Masahiko Sawada
Reviewed-by: David Rowley, Daniel Gustafsson, Melanie Plageman
Discussion: https://postgr.es/m/CAD21AoCBSqmqOKVH4Q256DeCC_UE50gu1sgixcjLFZGLEbABVA@mail.gmail.com
Amit Kapila [Fri, 28 Apr 2023 03:15:19 +0000 (08:45 +0530)]
Improve one of the test cases in 035_standby_logical_decoding.pl.
The test to ensure that decoding changes via logical slot from another
database will fail was incorrectly done on the primary node instead of on
the standby node.
In the passing, make the test to wait for replay catchup by using
wait_for_replay_catchup(). This will make it consistent with the way we
wait at other places in the test.
Author: Shi yu
Reviewed-by: Bertrand Drouvot, Amit Kapila
Discussion: https://postgr.es/m/OSZPR01MB6310B0A507A0F2A2D379F38CFD6A9@OSZPR01MB6310.jpnprd01.prod.outlook.com
Nathan Bossart [Thu, 27 Apr 2023 20:43:48 +0000 (13:43 -0700)]
Prevent underflow in KeepLogSeg().
The call to XLogGetReplicationSlotMinimumLSN() might return a
greater LSN than the one given to the function. Subsequent segment
number calculations might then underflow, which could result in
unexpected behavior when removing or recyling WAL files. This was
introduced with max_slot_wal_keep_size in
c655077639. To fix, skip
the block of code for replication slots if the LSN is greater.
Reported-by: Xu Xingwang
Author: Kyotaro Horiguchi
Reviewed-by: Junwang Zhao
Discussion: https://postgr.es/m/17903-
4288d439dee856c6%40postgresql.org
Backpatch-through: 13
Alexander Korotkov [Thu, 27 Apr 2023 19:06:14 +0000 (22:06 +0300)]
Fix wrong construct_array_builtin() call in GUCArrayDelete()
The current code unintentionally uses the wrong datum to construct an array.
The bug was introduced by
096dd80f3c, so no backpatching is needed.
Reported-by: David Steele
Discussion: https://postgr.es/m/
d46f9265-ff3c-6743-2278-
6772598233c2%40pgmasters.net
Author: Nathan Bossart
Reviewed-by: David Steele, Tom Lane
Tom Lane [Thu, 27 Apr 2023 15:55:06 +0000 (11:55 -0400)]
In hstore_plpython, avoid crashing when return value isn't a mapping.
Python 3 changed the behavior of PyMapping_Check(), breaking the
test in plpython_to_hstore() that verifies whether a function result
to be transformed is acceptable. A backwards-compatible fix is to
first verify that the object doesn't pass PySequence_Check().
Perhaps accidentally, our other uses of PyMapping_Check() already
follow uses of PySequence_Check(), so that no other bugs were
created by this change.
Per bug #17908 from Alexander Lakhin. Back-patch to all supported
branches.
Dmitry Dolgov and Tom Lane
Discussion: https://postgr.es/m/17908-
3f19a125d56a11d6@postgresql.org
Amit Kapila [Thu, 27 Apr 2023 08:52:53 +0000 (14:22 +0530)]
Add a test to verify that subscription to the standby works.
Author: Bertrand Drouvot
Reviewed-by: Vignesh C, Alvaro Herrera, Amit Kapila
Discussion: https://postgr.es/m/
2fefa454-5a70-2174-ddbf-
4a0e41537139@gmail.com
Michael Paquier [Thu, 27 Apr 2023 04:34:05 +0000 (13:34 +0900)]
Rework code defining default compression for dir/custom formats in pg_dump
As written, pg_dump would call twice parse_compress_specification() for
the custom and directory formats to build a compression specification if
no compression option is defined, as these formats should be compressed
by default when compiled with zlib, or use no compression without zlib.
This made the code logic quite confusing, and the first compression
specification built would be incorrect before being overwritten by the
second one.
Rather than creating two compression specifications, this commit changes
a bit the order of the checks for the compression options so as
compression_algorithm_str is now set to a correct value for the custom
and format directory when no compression option is defined. This makes
the code easier to understand, as parse_compress_specification() is now
called once for all the format, with or without user-specified
compression methods. One comment was also confusing for the non-zlib
case, so remove it while on it.
This code has been introduced in
5e73a60 when adding support for
compression specifications in pg_dump.
Per discussion with Justin Pryzby and Georgios Kokolatos.
Discussion: https://postgr.es/m/
20230225050214[email protected]
Daniel Gustafsson [Wed, 26 Apr 2023 12:24:13 +0000 (14:24 +0200)]
Fix stop condition for dumping GRANT commands
Commit
ce6b672e44 changed dumping GRANT commands to ensure that
grantors already have an ADMIN OPTION on the role for which it
is granting permissions. Looping over the grants per role has a
stop condition on dumping the grant statements, but accidentally
missed updating the variable for the conditional check.
Author: Andreas Scherbaum <
[email protected]>
Co-authored-by: Artur Zakirov <[email protected]>
Discussion: https://postgr.es/m/
de44299d-cd31-b41f-2c2a-
161fa5e586a5@pgug.de
Etsuro Fujita [Wed, 26 Apr 2023 11:15:00 +0000 (20:15 +0900)]
doc: Fix grammar.
Daniel Gustafsson [Wed, 26 Apr 2023 09:40:01 +0000 (11:40 +0200)]
Fix missing installation rules for BackgroundPsql.pm
Commit
664d75753 added the BackgroundPsql module with helper functions
for tests running interactive or background psql tasks. The new module
was however not added to the install rules of the build systems.
Reported-by: Peter Eisentraut <[email protected]>
Discussion: https://postgr.es/m/
c0ba3008-dbc8-e53f-29f2-
2e9abe72b2a2@enterprisedb.com
Thomas Munro [Tue, 25 Apr 2023 22:39:46 +0000 (10:39 +1200)]
Remove bogus #include added by
d4e71df6d75.
The recently added inclusion of guc.h in smgr.h is not necessary and
introduces more server-related stuff. Removing the directive helps
avoid potential issues with including sgmr.h in frontends.
Author: Kyotaro Horiguchi <
[email protected]>
Discussion: https://postgr.es/m/
20230425.115748.
2130383825066921512.horikyota.ntt%40gmail.com
Michael Paquier [Tue, 25 Apr 2023 22:10:06 +0000 (07:10 +0900)]
Re-add tracking of wait event SLRUFlushSync
SLRUFlushSync has been accidently removed during
dee663f, that has moved
the flush of the SLRU files to the checkpointer, so add it back. The
issue has been noticed by Thomas when checking for orphaned wait
events.
Author: Thomas Munro
Reviewed-by: Bharath Rupireddy
Discussion: https://postgr.es/m/CA+hUKGK6tqm59KuF1z+h5Y8fsWcu5v8+84kduSHwRzwjB2aa_A@mail.gmail.com
Daniel Gustafsson [Tue, 25 Apr 2023 11:54:10 +0000 (13:54 +0200)]
Fix vacuum_cost_delay check for balance calculation.
Commit
1021bd6a89 excluded autovacuum workers from cost-limit balance
calculations when per-relation options were set. The code checks for
limit and cost_delay being greater than zero, but since cost_delay can
be set to -1 the test needs to check for greater than or zero.
Backpatch to all supported branches since
1021bd6a89 was backpatched
all the way at the time.
Author: Masahiko Sawada <
[email protected]>
Reviewed-by: Melanie Plageman <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Discussion: https://postgr.es/m/CAD21AoBS7o6Ljt_vfqPQPf67AhzKu3fR0iqk8B=vVYczMugKMQ@mail.gmail.com
Backpatch-through: v11 (all supported branches)
Amit Kapila [Tue, 25 Apr 2023 03:03:09 +0000 (08:33 +0530)]
Reduce the log level in 035_standby_logical_decoding.pl.
Reduce the log level in 035_standby_logical_decoding.pl as the test
doesn't require the higher log level. This helps to shrink the output size
and speed up the test a bit.
Author: Bertrand Drouvot
Discussion: https://postgr.es/m/
2fefa454-5a70-2174-ddbf-
4a0e41537139@gmail.com
Discussion: https://postgr.es/m/523315.
1681245505@sss.pgh.pa.us
Michael Paquier [Tue, 25 Apr 2023 00:42:19 +0000 (09:42 +0900)]
Fix buffer refcount leak with FDW bulk inserts
The leak would show up when using batch inserts with foreign tables
included in a partition tree, as the slots used in the batch were not
reset once processed. In order to fix this problem, some
ExecClearTuple() are added to clean up the slots used once a batch is
filled and processed, mapping with the number of slots currently in use
as tracked by the counter ri_NumSlots.
This buffer refcount leak has been introduced in
b676ac4 with the
addition of the executor facility to improve bulk inserts for FDWs, so
backpatch down to 14.
Alexander has provided the patch (slightly modified by me). The test
for postgres_fdw comes from me, based on the test case that the author
has sent in the report.
Author: Alexander Pyhalov
Discussion: https://postgr.es/m/
b035780a740efd38dc30790c76927255@postgrespro.ru
Backpatch-through: 14
Andres Freund [Mon, 24 Apr 2023 19:20:52 +0000 (12:20 -0700)]
Remove vacuum_defer_cleanup_age
vacuum_defer_cleanup_age was introduced before hot_standby_feedback and
replication slots existed. It is hard to use reasonably - commonly it will
either be set too low (not preventing recovery conflicts, while still causing
some bloat), or too high (causing a lot of bloat). The alternatives do not
have that issue.
That on its own might not be sufficient reason to remove
vacuum_defer_cleanup_age, but it also complicates computation of xid
horizons. See e.g. the bug fixed in
be504a3e974. It also is untested.
This commit removes TransactionIdRetreatSafely(), as there are no users
anymore. There might be potential future users, hence noting that here.
Reviewed-by: Daniel Gustafsson <[email protected]>
Reviewed-by: Justin Pryzby <[email protected]>
Reviewed-by: Alvaro Herrera <[email protected]>
Discussion: https://postgr.es/m/
20230317230930[email protected]
Tom Lane [Mon, 24 Apr 2023 18:19:46 +0000 (14:19 -0400)]
Fix memory leakage in plpgsql DO blocks that use cast expressions.
Commit
04fe805a1 modified plpgsql so that datatype casts make use of
expressions cached by plancache.c, in place of older code where these
expression trees were managed by plpgsql itself. However, I (tgl)
forgot that we use a separate, shorter-lived cast info hashtable in
DO blocks. The new mechanism thus resulted in session-lifespan
leakage of the plancache data once a DO block containing one or more
casts terminated. To fix, split the cast hash table into two parts,
one that tracks only the plancache's CachedExpressions and one that
tracks the expression state trees generated from them. DO blocks need
their own expression state trees and hence their own version of the
second hash table, but there's no reason they can't share the
CachedExpressions with regular plpgsql functions.
Per report from Ajit Awekar. Back-patch to v12 where the issue
was introduced.
Ajit Awekar and Tom Lane
Discussion: https://postgr.es/m/CAHv6PyrNaqdvyWUspzd3txYQguFTBSnhx+m6tS06TnM+KWc_LQ@mail.gmail.com
Tom Lane [Mon, 24 Apr 2023 17:01:33 +0000 (13:01 -0400)]
Rename ExecAggTransReparent, and improve its documentation.
The name of this function suggests that it ought to reparent R/W
expanded objects to be children of the persistent aggcontext, instead
of copying them. In fact it does no such thing, and if you try to
make it do so you will see multiple regression failures. Rename it
to the less-misleading ExecAggCopyTransValue, and add commentary
about why that attractive-sounding optimization won't work. Also
adjust comments at call sites, some of which were describing logic
that has since been moved into ExecAggCopyTransValue.
Discussion: https://postgr.es/m/
3004282.
1681930251@sss.pgh.pa.us
Peter Eisentraut [Mon, 24 Apr 2023 13:39:54 +0000 (15:39 +0200)]
doc: Update SQL features names
Some feature names have been adjusted over time upstream. This pulls
in those changes.
Daniel Gustafsson [Mon, 24 Apr 2023 09:40:23 +0000 (11:40 +0200)]
ci: Remove OpenSSL 3.1 workaround for missing system CA
Commit
0b5d1fb36 fixed the SSL test to properly handle the error message
from OpenSSL when the system CA pool is missing of invalid, so with that
we can remove the workaround in Cirrus for when Homebrew clears the cert
from OPENSSLDIR.
Author: Jacob Champion <
[email protected]>
Discussion: https://postgr.es/m/CAAWbhmj3JtKuRcHcMuf1eCJmoZxMXdzLaYpEGmzu9+kgRGpu3A@mail.gmail.com
Daniel Gustafsson [Mon, 24 Apr 2023 09:16:17 +0000 (11:16 +0200)]
Remove duplicate lines of code
Commit
6df7a9698bb accidentally included two identical prototypes for
default_multirange_selectivi() and commit
086cf1458c6 added a break;
statement where one was already present, thus duplicating it. While
there is no bug caused by this, fix by removing the duplicated lines
as they provide no value.
Backpatch the fix for duplicate prototypes to v14 and the duplicate
break statement fix to all supported branches to avoid backpatching
hazards due to the removal.
Reported-by: Anton Voloshin <[email protected]>
Discussion: https://postgr.es/m/
0e69cb60-0176-f6d0-7e15-
6478b7d85724@postgrespro.ru
Masahiko Sawada [Mon, 24 Apr 2023 06:37:14 +0000 (15:37 +0900)]
Use elog to report unexpected action in handle_streamed_transaction().
An oversight in commit
216a784829c.
Author: Masahiko Sawada
Reviewed-by: Kyotaro Horiguchi, Amit Kapila
Discussion: https://postgr.es/m/CAD21AoDDbM8_HJt-nMCvcjTK8K9hPzXWqJj7pyaUvR4mm_NrSg@mail.gmail.com
Amit Kapila [Mon, 24 Apr 2023 03:07:58 +0000 (08:37 +0530)]
Display 'password_required' option for \dRs+ command.
The commit
c3afe8cf5a added a new subscription option 'password_required'
which should be shown with \dRs+ command.
Author: Vignesh C
Reviewed-by: Amit Kapila, Robert Haas
Discussion: https://postgr.es/m/CAA4eK1LRz5sCZxwCW6OtpjLtWPvRwBihQOM4jzQm6ppfpexqGA@mail.gmail.com
Discussion: https://postgr.es/m/
9DFC88D3-1300-4DE8-ACBC-
4CEF84399A53@enterprisedb.com
Noah Misch [Mon, 24 Apr 2023 01:58:19 +0000 (18:58 -0700)]
Remove new <para id="contrib-obsolete">.
Just intagg is obsolete, and having a one-entry list gives undue weight.
Discussion: https://postgr.es/m/
20230409185050[email protected]
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
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
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.
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
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
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
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
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
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
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
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
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]
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
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
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
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
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
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.
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
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
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
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.
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]
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
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
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.
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.
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
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
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
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]
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
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
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
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]
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.
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
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
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.
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
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.
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
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]