Peter Eisentraut [Wed, 3 Jan 2024 20:02:49 +0000 (21:02 +0100)]
Revert "Reorganise jsonpath operators and methods"
This reverts commit
283a95da923605c1cc148155db2d865d0801b419.
The reordering of JsonPathItemType affects the binary on-disk
compatibility of the jsonpath type, so we must not change it. Revert
for now and consider.
Tom Lane [Wed, 3 Jan 2024 17:22:00 +0000 (12:22 -0500)]
Doc: Python's control flow construct is try/except not try/catch.
Very ancient thinko, dating evidently to
22690719e.
Spotted by gweatherby.
Discussion: https://postgr.es/m/
170423637139.
1288848.
11840082988774620003@wrigleys.postgresql.org
Robert Haas [Wed, 3 Jan 2024 14:59:46 +0000 (09:59 -0500)]
Fix defects in PrepareForIncrementalBackup.
Swap the arguments to TimestampDifferenceMilliseconds so that we get
a positive answer instead of zero.
Then use the result of that computation instead of ignoring it.
Per reports from Alexander Lakhin.
Discussion: http://postgr.es/m/
8b686764-7ac1-74c3-70f9-
b64685a2535f@gmail.com
Peter Eisentraut [Wed, 3 Jan 2024 12:16:55 +0000 (13:16 +0100)]
Make Perl warnings fatal in newly added TAP tests
New TAP tests added by commits
9a17be1e and
4710b67d missed to convert
warnings to FATAL. This commit fixes that.
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Peter Eisentraut [Wed, 3 Jan 2024 10:25:33 +0000 (11:25 +0100)]
Reorganise jsonpath operators and methods
Various jsonpath operators and methods add various keywords, switch
cases, and documentation entries in some order. However, they are not
consistent; reorder them for better maintainability or readability.
Author: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/CAM2+6=XjTyqrrqHAOj80r0wVQxJSxc0iyib9bPC55uFO9VKatg@mail.gmail.com
Peter Eisentraut [Wed, 3 Jan 2024 09:05:35 +0000 (10:05 +0100)]
Add numeric_int8_opt_error() to optionally suppress errors
This matches the existing numeric_int4_opt_error() (see commit
16d489b0fe). It will be used by a future JSON-related patch, which
wants to report errors in its own way and thus does not want the
internal functions to throw any error.
Author: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/CAM2+6=XjTyqrrqHAOj80r0wVQxJSxc0iyib9bPC55uFO9VKatg@mail.gmail.com
Peter Eisentraut [Wed, 3 Jan 2024 07:48:09 +0000 (08:48 +0100)]
Refactor: separate function to find all objects depending on a column
Move code from ATExecAlterColumnType() that finds the all the objects
that depend on the column to a separate function. A future patch will
reuse this code.
Author: Amul Sul <sulamul@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAAJ_b94yyJeGA-5M951_Lr+KfZokOp-2kXicpmEhi5FXhBeTog@mail.gmail.com
Michael Paquier [Wed, 3 Jan 2024 05:22:54 +0000 (14:22 +0900)]
Fix some typos
Author: Dagfinn Ilmari Mannsåker
Reviewed-by: Shubham Khanna
Discussion: https://postgr.es/m/87le9fmi01.fsf@wibble.ilmari.org
Michael Paquier [Wed, 3 Jan 2024 01:28:05 +0000 (10:28 +0900)]
Remove unnecessary PGDATABASE settings from TAP tests
Some of the TAP tests have been historically setting the environment
variable PGDATABASE to 'postgres', which is not needed because
PostgreSQL::Test::Cluster already sets it when initialized. This commit
removes these explicit setups.
Note that the dependency of cluster -a with PGDATABASE (from
1caef31d9e55) is still documented.
Author: Bharath Rupireddy
Discussion: https://postgr.es/m/CALj2ACXLAz5dW3ZP+Fec8g6jQMMmDyCVT+qdbye2h7QJJmhsdw@mail.gmail.com
Tom Lane [Tue, 2 Jan 2024 19:57:21 +0000 (14:57 -0500)]
Minor fixes for search path cache code.
Avoid leaving a dangling pointer in the unlikely event that
nsphash_create fails. Improve comments, and fix formatting by
adding typedefs.list entries.
Discussion: https://postgr.es/m/
3972900.
1704145107@sss.pgh.pa.us
Robert Haas [Tue, 2 Jan 2024 18:17:23 +0000 (13:17 -0500)]
Remove Lock suffix from WALSummarizerLock in wait_event_names.txt
Nathan Bossart
Discussion: https://postgr.es/m/
20240102173120.GA1061678@nathanxps13
Robert Haas [Tue, 2 Jan 2024 17:27:38 +0000 (12:27 -0500)]
jsonpath_exec: fix typo "absense" -> "absence"
Dagfinn Ilmari Mannsåker, reviewed by Shubham Khanna.
Discussion: http://postgr.es/m/87le9fmi01.fsf@wibble.ilmari.org
Robert Haas [Tue, 2 Jan 2024 17:27:09 +0000 (12:27 -0500)]
libpq: fix typo "occurences" -> "occurrences" in tests
Dagfinn Ilmari Mannsåker, reviewed by Shubham Khanna.
Discussion: http://postgr.es/m/87le9fmi01.fsf@wibble.ilmari.org
Robert Haas [Tue, 2 Jan 2024 17:24:28 +0000 (12:24 -0500)]
gist: fix typo "split(t)ed" -> "split"
Dagfinn Ilmari Mannsåker, reviewed by Shubham Khanna.
Discussion: http://postgr.es/m/87le9fmi01.fsf@wibble.ilmari.org
Robert Haas [Tue, 2 Jan 2024 17:23:36 +0000 (12:23 -0500)]
tsquery: fix typo "rewrited" -> "rewritten"
Dagfinn Ilmari Mannsåker, reviewed by Shubham Khanna.
Discussion: http://postgr.es/m/87le9fmi01.fsf@wibble.ilmari.org
Robert Haas [Tue, 2 Jan 2024 16:56:02 +0000 (11:56 -0500)]
Fix typos in comments and in one isolation test.
Dagfinn Ilmari Mannsåker, reviewed by Shubham Khanna. Some subtractions
by me.
Discussion: http://postgr.es/m/87le9fmi01.fsf@wibble.ilmari.org
Robert Haas [Tue, 2 Jan 2024 15:31:49 +0000 (10:31 -0500)]
Add WALSummarizerLock to wait_event_names.txt
Per report from Nathan Bossart.
Discussion: http://postgr.es/m/
20231227153647.GA601861@nathanxps13
Peter Eisentraut [Tue, 2 Jan 2024 09:18:47 +0000 (10:18 +0100)]
Fix typos in simplehash.h
Author: Richard Guo <guofenglinux@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/18252-
d46d27900a277d87@postgresql.org
Alexander Korotkov [Tue, 2 Jan 2024 07:48:50 +0000 (09:48 +0200)]
Replace the relid in some missing fields during SJE
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/
a89f480f-8143-0965-f22d-
0a892777f501%40gmail.com
Author: Andrei Lepikhov
Amit Kapila [Tue, 2 Jan 2024 02:38:46 +0000 (08:08 +0530)]
Allow upgrades to preserve the full subscription's state.
This feature will allow us to replicate the changes on subscriber nodes
after the upgrade.
Previously, only the subscription metadata information was preserved.
Without the list of relations and their state, it's not possible to
re-enable the subscriptions without missing some records as the list of
relations can only be refreshed after enabling the subscription (and
therefore starting the apply worker). Even if we added a way to refresh
the subscription while enabling a publication, we still wouldn't know
which relations are new on the publication side, and therefore should be
fully synced, and which shouldn't.
To preserve the subscription relations, this patch teaches pg_dump to
restore the content of pg_subscription_rel from the old cluster by using
binary_upgrade_add_sub_rel_state SQL function. This is supported only
in binary upgrade mode.
The subscription's replication origin is needed to ensure that we don't
replicate anything twice.
To preserve the replication origins, this patch teaches pg_dump to update
the replication origin along with creating a subscription by using
binary_upgrade_replorigin_advance SQL function to restore the
underlying replication origin remote LSN. This is supported only in
binary upgrade mode.
pg_upgrade will check that all the subscription relations are in 'i'
(init) or in 'r' (ready) state and will error out if that's not the case,
logging the reason for the failure. This helps to avoid the risk of any
dangling slot or origin after the upgrade.
Author: Vignesh C, Julien Rouhaud, Shlok Kyal
Reviewed-by: Peter Smith, Masahiko Sawada, Michael Paquier, Amit Kapila, Hayato Kuroda
Discussion: https://postgr.es/m/
20230217075433.u5mjly4d5cr4hcfe@jrouhaud
Peter Eisentraut [Mon, 1 Jan 2024 18:17:18 +0000 (19:17 +0100)]
Turn AT_PASS_* macros into an enum
This make this code simpler and easier to follow. Also, patches that
want to change the passes won't have to renumber the whole list.
Reviewed-by: Amul Sul <sulamul@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAAJ_b94yyJeGA-5M951_Lr+KfZokOp-2kXicpmEhi5FXhBeTog@mail.gmail.com
Peter Eisentraut [Sun, 31 Dec 2023 14:30:57 +0000 (15:30 +0100)]
Revert "pg_stat_statements: Add coverage for entry_dealloc()"
This reverts commit
742f6b3e6df980d7dafa4a18a165d285483d5f0e.
The new test failed on big-endian platforms.
Discussion: https://www.postgresql.org/message-id/flat/
40d1e4f2-835f-448f-a541-
8ff5db75bf3d@eisentraut.org
Michael Paquier [Sun, 31 Dec 2023 09:06:56 +0000 (18:06 +0900)]
Exclude files generated by generate-wait_event_types.pl from pgindent
The format of these files becomes arguably worse after being indented,
and, as they are generated, there is no point in applying an indentation
anyway.
Author: Bharath Rupireddy
Discussion: https://postgr.es/m/CALj2ACW2JUocmieuR3n9AXL4iSsHcL1LmNkiukuFRUvKNMoiKg@mail.gmail.com
Tomas Vondra [Sat, 30 Dec 2023 21:59:42 +0000 (22:59 +0100)]
Fix parallel BRIN builds with synchronized scans
The brinbuildCallbackParallel callback used by parallel BRIN builds did
not consider that the parallel table scans may be synchronized, starting
from an arbitrary block and then wrap around.
If this happened and the scan actually did wrap around, tuples from the
beginning of the table were added to the last range produced by the same
worker. The index would be missing range at the beginning of the table,
while the last range would be too wide. This would not produce incorrect
query results, but it'd be less efficient.
Fixed by checking for both past and future ranges in the callback. The
worker may produce multiple summaries for the same page range, but the
leader will merge them as if the summaries came from different workers.
Discussion: https://postgr.es/m/
c2ee7d69-ce17-43f2-d1a0-
9811edbda6e6%40enterprisedb.com
Tomas Vondra [Sat, 30 Dec 2023 21:50:54 +0000 (22:50 +0100)]
Minor cleanup of the BRIN parallel build code
Commit
b437571714 added support for parallel builds for BRIN indexes,
using code similar to BTREE parallel builds, and also a new tuplesort
variant. This commit simplifies the new code in two ways:
* The "spool" grouping tuplesort and the heap/index is not necessary.
The heap/index are available as separate arguments, causing confusion.
So remove the spool, and use the tuplesort directly.
* The new tuplesort variant does not need the heap/index, as it sorts
simply by the range block number, without accessing the tuple data.
So simplify that too.
Initial report and patch by Ranier Vilela, further cleanup by me.
Author: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAqD7f2i4iyEaAz-5o-bf6zXVX-AkNUBm-YjUXEemaEh6A%40mail.gmail.com
Heikki Linnakangas [Sat, 30 Dec 2023 20:18:54 +0000 (22:18 +0200)]
Don't send "cannot connect" errors on invalid startup packet
Commit
16671ba6e7 moved the code that sends "sorry, too many clients
already" and other such messages, but it had the effect that we would
send that error even if the the startup packet processing failed, e.g.
because the client sent an invalid startup packet. That was not
intentional.
Spotted while reading the code again.
Peter Eisentraut [Sat, 30 Dec 2023 18:55:32 +0000 (19:55 +0100)]
pg_stat_statements: Add TAP test for testing restarts
This tests that pg_stat_statement contents are successfully kept
across restart. (This similar to
src/test/recovery/t/029_stats_restart.pl for the stats collector.)
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/
40d1e4f2-835f-448f-a541-
8ff5db75bf3d@eisentraut.org
Peter Eisentraut [Sat, 30 Dec 2023 18:55:32 +0000 (19:55 +0100)]
pg_stat_statements: Add coverage for entry_dealloc()
This involves creating more than pg_stat_statements.max entries and
checking that the limit is kept and the least used entries are kicked
out.
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/
40d1e4f2-835f-448f-a541-
8ff5db75bf3d@eisentraut.org
Peter Eisentraut [Sat, 30 Dec 2023 10:11:26 +0000 (11:11 +0100)]
Add GUC backtrace_on_internal_error
When enabled (default off), this logs a backtrace anytime elog() or an
equivalent ereport() for internal errors is called.
This is not well covered by the existing backtrace_functions, because
there are many equally-worded low-level errors in many functions. And
if you find out where the error is, then you need to manually rewrite
the elog() to ereport() to attach the errbacktrace(), which is
annoying. Having a backtrace automatically on every elog() call could
be very helpful during development for various kinds of common errors
from palloc, syscache, node support, etc.
Discussion: https://www.postgresql.org/message-id/flat/
ba76c6bc-f03f-4285-bf16-
47759cfcab9e@eisentraut.org
Peter Eisentraut [Fri, 29 Dec 2023 22:54:40 +0000 (23:54 +0100)]
Follow-up fixes for "Make all Perl warnings fatal"
Mostly, we need to check whether $ENV{PG_TEST_EXTRA} is set before
doing regular expression matches against it.
Jeff Davis [Fri, 29 Dec 2023 19:26:10 +0000 (11:26 -0800)]
Fix collate.windows.win1252 test.
Do not rely on the OS recognizing a particular locale; find the right
locale by querying the "en_US" collation.
Author: Alexander Lakhin
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/
ae73f6f5-8221-c112-4640-
5cda812a69de@gmail.com
Peter Eisentraut [Fri, 29 Dec 2023 17:01:53 +0000 (18:01 +0100)]
Make all Perl warnings fatal
There are a lot of Perl scripts in the tree, mostly code generation
and TAP tests. Occasionally, these scripts produce warnings. These
are probably always mistakes on the developer side (true positives).
Typical examples are warnings from genbki.pl or related when you make
a mess in the catalog files during development, or warnings from tests
when they massage a config file that looks different on different
hosts, or mistakes during merges (e.g., duplicate subroutine
definitions), or just mistakes that weren't noticed because there is a
lot of output in a verbose build.
This changes all warnings into fatal errors, by replacing
use warnings;
by
use warnings FATAL => 'all';
in all Perl files.
Discussion: https://www.postgresql.org/message-id/flat/
06f899fd-1826-05ab-42d6-
adeb1fd5e200%40eisentraut.org
Tom Lane [Fri, 29 Dec 2023 15:57:11 +0000 (10:57 -0500)]
In pg_dump, don't dump a stats object unless dumping underlying table.
If the underlying table isn't being dumped, it's useless to dump
an extended statistics object; it'll just cause errors at restore.
We have always applied similar policies to, say, indexes.
(When and if we get cross-table stats objects, it might be profitable
to think a little harder about what to do with them. But for now
there seems no point in considering a stats object as anything but
an appendage of its table.)
Rian McGuire and Tom Lane, per report from Rian McGuire.
Back-patch to supported branches.
Discussion: https://postgr.es/m/
7075d3aa-3f05-44a5-b68f-
47dc6a8a0550@buildkite.com
Peter Eisentraut [Thu, 28 Dec 2023 16:25:47 +0000 (17:25 +0100)]
Fix variable name and comment
Should match the name of the related GUC variable.
Discussion: https://www.postgresql.org/message-id/
da4a680a-5d8a-4663-a5c8-
a3ccbf23394a@eisentraut.org
Michael Paquier [Thu, 28 Dec 2023 11:09:12 +0000 (20:09 +0900)]
doc: Mention AttributeRelationId in FDW validator function description
The documentation has been missing one value in the list of catalog OIDs
that can be given to the validator function of a FDW, as of
AttributeRelationId, when changing the attribute options of a foreign
table.
Author: Ian Lawrence Barwick
Discussion: https://postgr.es/m/CAB8KJ=i16t2yJU_Pq2Z+hnNGWFhagp_bJmzxHZu3ZkOjZm-+rQ@mail.gmail.com
Backpatch-through: 12
Tom Lane [Wed, 27 Dec 2023 20:55:46 +0000 (15:55 -0500)]
Improve the implementation of information_schema._pg_expandarray().
This function was originally coded with a handmade expansion
of the array subscripts. We can do it a little faster and far
more legibly today, by using unnest() WITH ORDINALITY.
While at it, let's apply the rowcount estimation support that exists
for the underlying unnest() function: reduce the default ROWS estimate
to 100 and attach array_unnest_support. I'm not sure that
array_unnest_support can do anything useful today with the call sites
that exist in information_schema, but it can't hurt, and the existing
default rowcount of 1000 is surely much too high for any of these
cases.
The psql.sql regression script is using _pg_expandarray() as a
test case for \sf+. While we could keep doing so, the new one-line
function body makes a poor test case for \sf+ row-numbering, so
switch it to print another information_schema function.
Discussion: https://postgr.es/m/
1424303.
1703355485@sss.pgh.pa.us
Tom Lane [Wed, 27 Dec 2023 18:52:01 +0000 (13:52 -0500)]
Doc: specify aclitem syntax more clearly.
The previous wording here relied solely on an example to explain
aclitem output format. Add an actual syntax synopsis and
explanation of the elements to make it clearer.
David Johnston and Tom Lane, per gripe from Eugen Konkov.
Discussion: https://postgr.es/m/
170326116972.
1876499.
18357820037829248593@wrigleys.postgresql.org
Tom Lane [Wed, 27 Dec 2023 18:05:16 +0000 (13:05 -0500)]
Fix another incorrect data type choice from commit
dc2123400.
add_file_to_manifest declared its mtime argument as pg_time_t,
apparently on the principle that copy-and-paste from the backend
is fine. However, the callers are passing struct stat's st_mtime
field which is plain time_t, and add_file_to_manifest itself is
passing the value to gmtime(3) which expects plain time_t,
so the whole thing would not work at all on any platform where
those types are different. Fortunately we can just switch this
variable to time_t.
Per warnings from assorted buildfarm members.
Peter Eisentraut [Wed, 27 Dec 2023 16:39:10 +0000 (17:39 +0100)]
Fix incorrect format placeholders
Peter Eisentraut [Wed, 27 Dec 2023 16:15:26 +0000 (17:15 +0100)]
Fix a warning in Perl test code
The code was passing a scalar argument to node->restart(), but it was
expecting a hash, which causes a warning from Perl ("Odd number of
elements in hash assignment").
But the node->restart() function doesn't take a mode argument anyway.
This was probably copied from an incorrect comment (see commit
750c59d7ec). The default restart mode is already "fast", so the test
should still be semantically correct without explicitly specifying the
mode.
Discussion: https://www.postgresql.org/message-id/
e3f4bf1b-63d3-408a-b07e-
d35a0fdf1b98@eisentraut.org
Tom Lane [Wed, 27 Dec 2023 16:02:53 +0000 (11:02 -0500)]
Fix incorrect data type choices in some read and write calls.
Recently-introduced code in reconstruct.c was using "unsigned"
to store the result of read(), pg_pread(), or write(). This is
completely bogus: it breaks subsequent tests for the result being
negative, as we're being reminded of by a chorus of buildfarm
warnings. Switch to "int" as was doubtless intended. (There are
several other uses of "unsigned" in this file that also look poorly
chosen to me, but for now I'm just trying to clean up the buildfarm.)
A larger problem is that "int" is not necessarily wide enough to hold
the result: per POSIX, all these functions return ssize_t. In places
where the requested read or write length clearly fits in int, that's
academic. It may be academic anyway as long as we constrain
individual data files to 1GB, since even a readv or writev-like
operation would then not be responsible for transferring more than
1GB. Nonetheless it seems like trouble waiting to happen, so I made
a pass over readv and writev calls and fixed the result variables
where that seemed appropriate. We might want to think about changing
some of the fd.c functions to return ssize_t too, for future-proofing;
but I didn't tackle that here.
Discussion: https://postgr.es/m/
1672202.
1703441340@sss.pgh.pa.us
Robert Haas [Wed, 27 Dec 2023 13:41:53 +0000 (08:41 -0500)]
Initialize variable to placate compiler.
I don't think there's a real problem here, because if we reach
the loop over 'tles' then we will either find at least one
TimeLineHistoryEntry such that oldest_segno != 0, in which case
unsummarized_lsn will be initialized, or else unsummarized_tli
will remain 0 and an error will occur before unsummarized_lsn
is used for anything. But some compilers are complainining, as
reported on list by Nathan Bossart and off-list by Andrew Dunstan.
Discussion: http://postgr.es/m/
20231223215147.GA69623@nathanxps13
Alexander Korotkov [Wed, 27 Dec 2023 12:22:02 +0000 (14:22 +0200)]
Improvements and fixes for
e0b1ee17dc
e0b1ee17dc introduced optimization for matching B-tree scan keys required for
the directional scan. However, it incorrectly assumed that all keys required
for opposite direction scan are satisfied by _bt_first(). It has been
illustrated that with multiple scan keys over the same column, a lesser one
(according to the scan direction) could win leaving the other one unsatisfied.
Instead of relying on _bt_first() this commit introduces code that memorizes
whether there was at least one match on the page. If that's true we know that
keys required for opposite-direction scan are satisfied as soon as
corresponding values are not NULLs.
Also, this commit simplifies the description for the optimization of keys
required for the current direction scan. Now the flag used for this is named
continuescanPrechecked and means exactly that *continuescan flag is known
to be true for the last item on the page.
Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzn0LeLcb1PdBnK0xisz8NpHkxRrMr3NWJ%2BKOK-WZ%2BQtTQ%40mail.gmail.com
Reviewed-by: Pavel Borisov
Alexander Korotkov [Wed, 27 Dec 2023 12:21:49 +0000 (14:21 +0200)]
Remove BTScanOpaqueData.firstPage
It's not necessary to keep the firstPage flag as a field of BTScanOpaqueData.
This commit makes it an argument of the _bt_readpage() function. We can easily
distinguish first-time and repeated calls (within the scan) of this function.
Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzk4SOsw%2BtHuTFiz8U9Jqj-R77rYPkhWKODCBb1mdHACXA%40mail.gmail.com
Reviewed-by: Pavel Borisov
Peter Eisentraut [Wed, 27 Dec 2023 09:48:01 +0000 (10:48 +0100)]
pg_stat_statements: Add test coverage for pg_stat_statements_reset_1_7
Run pg_stat_statements_reset() once while the appropriate extension
version is installed.
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/
40d1e4f2-835f-448f-a541-
8ff5db75bf3d@eisentraut.org
Peter Eisentraut [Wed, 27 Dec 2023 09:48:01 +0000 (10:48 +0100)]
pg_stat_statements: Add test coverage for pg_stat_statements_1_8()
This requires reading pg_stat_statements at least once while the 1.8
version of the extension is installed.
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/
40d1e4f2-835f-448f-a541-
8ff5db75bf3d@eisentraut.org
John Naylor [Wed, 27 Dec 2023 06:30:12 +0000 (13:30 +0700)]
Fix typo and case in messages
Follow up to
dc2123400
Kyotaro Horiguchi
Discussion: https://postgr.es/m/
20231222.154939.
1509525390095583358.horikyota.ntt@gmail.com
Discussion: https://postgr.es/m/
20231225.145124.
1745560266993421173.horikyota.ntt@gmail.com
Alexander Korotkov [Wed, 27 Dec 2023 01:34:29 +0000 (03:34 +0200)]
Make replace_relid() leave argument unmodified
There are a lot of situations when we share the same pointer to a Bitmapset
structure across different places. In order to evade undesirable side effects
replace_relid() function should always return a copy.
Reported-by: Richard Guo
Discussion: https://postgr.es/m/CAMbWs4_wJthNtYBL%2BSsebpgF-5L2r5zFFk6xYbS0A78GKOTFHw%40mail.gmail.com
Reviewed-by: Richard Guo, Andres Freund, Ashutosh Bapat, Andrei Lepikhov
Alexander Korotkov [Wed, 27 Dec 2023 01:34:23 +0000 (03:34 +0200)]
REALLOCATE_BITMAPSETS manual compile-time option
This option forces each bitmapset modification to reallocate bitmapset. This
is useful for debugging hangling pointers to bitmapset's.
Discussion: https://postgr.es/m/CAMbWs4_wJthNtYBL%2BSsebpgF-5L2r5zFFk6xYbS0A78GKOTFHw%40mail.gmail.com
Reviewed-by: Richard Guo, Andres Freund, Ashutosh Bapat, Andrei Lepikhov
Alexander Korotkov [Wed, 27 Dec 2023 01:34:12 +0000 (03:34 +0200)]
Add asserts to bimapset manipulation functions
New asserts validate that arguments are really bitmapsets. This should help
to early detect accesses to dangling pointers.
Discussion: https://postgr.es/m/CAMbWs4_wJthNtYBL%2BSsebpgF-5L2r5zFFk6xYbS0A78GKOTFHw%40mail.gmail.com
Reviewed-by: Richard Guo, Andres Freund, Ashutosh Bapat, Andrei Lepikhov
Tom Lane [Tue, 26 Dec 2023 22:57:48 +0000 (17:57 -0500)]
Fix failure to verify PGC_[SU_]BACKEND GUCs in pg_file_settings view.
set_config_option() bails out early if it detects that the option to
be set is PGC_BACKEND or PGC_SU_BACKEND class and we're reading the
config file in a postmaster child; we don't want to apply any new
value in such a case. That's fine as far as it goes, but it fails
to consider the requirements of the pg_file_settings view: for that,
we need to check validity of the value even though we have no
intention to apply it. Because we didn't, even very silly values
for affected GUCs would be reported as valid by the view. There
are only half a dozen such GUCs, which perhaps explains why this
got overlooked for so long.
Fix by continuing when changeVal is false; this parallels the logic
in some other early-exit paths.
Also, the check added by commit
924bcf4f1 to prevent GUC changes in
parallel workers seems a few bricks shy of a load: it's evidently
assuming that ereport(elevel, ...) won't return. Make sure we
bail out if it does. The lack of trouble reports suggests that
this is only a latent bug, i.e. parallel workers don't actually
reach here with elevel < ERROR. (Per the code coverage report,
we never reach here at all in the regression suite.) But we clearly
don't want to risk proceeding if that does happen.
Per report from Rıdvan Korkmaz. These are ancient bugs, so back-patch
to all supported branches.
Discussion: https://postgr.es/m/
2089235.
1703617353@sss.pgh.pa.us
Tom Lane [Tue, 26 Dec 2023 22:03:02 +0000 (17:03 -0500)]
Fix mistaken file name in plpython's meson recipe.
Brown-paper-bag bug in commit
58c3151bb. Per buildfarm.
Tom Lane [Tue, 26 Dec 2023 21:16:29 +0000 (16:16 -0500)]
Hide warnings from Python headers when using gcc-compatible compiler.
Like commit
388e80132, use "#pragma GCC system_header" to silence
warnings appearing within the Python headers, since newer Python
versions no longer worry about some restrictions we still use like
-Wdeclaration-after-statement.
This patch improves on
388e80132 by inventing a separate wrapper
header file, allowing the pragma to be tightly scoped to just
the Python headers and not other stuff we have laying about in
plpython.h. I applied the same technique to plperl for the same
reason: the original patch suppressed warnings for a good deal
of our own code, not only the Perl headers.
Like the previous commit, back-patch to supported branches.
Peter Eisentraut and Tom Lane
Discussion: https://postgr.es/m/
ae523163-6d2a-4b81-a875-
832e48dec502@eisentraut.org
Peter Eisentraut [Tue, 26 Dec 2023 20:31:39 +0000 (21:31 +0100)]
Add meson NLS support for pg_combinebackup
Bruce Momjian [Tue, 26 Dec 2023 20:31:50 +0000 (15:31 -0500)]
doc: add ISO 8601 extended format example using to_char()
Reported-by: juha.mustonen@iki.fi
Discussion: https://postgr.es/m/
20170217160154.6101.52806@wrigleys.postgresql.org
Co-authored-by: Erik Wienhold
Backpatch-through: master
Tom Lane [Tue, 26 Dec 2023 19:37:46 +0000 (14:37 -0500)]
Add empty placeholder LINGUAS file for pg_combinebackup.
This will eventually be replaced once some translations exist
for pg_combinebackup's messages. In the meantime, we need
something here to prevent "make" from complaining in
builds with --enable-nls. Per advice added in
88dad06b4.
Peter Eisentraut [Tue, 26 Dec 2023 19:13:11 +0000 (20:13 +0100)]
Remove unused macro
Usage was removed in
6c5576075b but the definition was not removed.
Michael Paquier [Tue, 26 Dec 2023 09:54:36 +0000 (18:54 +0900)]
Fix some translatable strings in pg_basebackup and pg_combinebackup
Two translatable strings introduced in
dc212340058b were split into two
parts, making their translation harder than necessary.
Author: Kyotaro Horiguchi
Discussion: https://postgr.es/m/
20231225.134747.
2287499067164862136.horikyota.ntt@gmail.com
Amit Kapila [Tue, 26 Dec 2023 05:00:42 +0000 (10:30 +0530)]
Doc: Add missing pgoutput options.
We forgot to update the docs while adding new options in pgoutput.
Author: Emre Hasegeli
Reviewed-by: Peter Smith, Amit Kapila
Backpatch-through: 12
Discussion: https://postgr.es/m/CAE2gYzwdwtUbs-tPSV-QBwgTubiyGD2ZGsSnAVsDfAGGLDrGOA%40mail.gmail.com
Tom Lane [Mon, 25 Dec 2023 04:36:33 +0000 (23:36 -0500)]
Fix erroneous -Werror=missing-braces on old GCC.
In the same spirit as
5e0c761d0 and some earlier commits,
suppress a chorus of buildfarm warnings about braces in
these initializers.
Richard Guo
Discussion: https://postgr.es/m/CAMbWs48GzM-Ff7vr=_CeqaXxFBB9UntqtaW1cjU8hOo62AbOOg@mail.gmail.com
Alexander Korotkov [Sun, 24 Dec 2023 23:31:24 +0000 (01:31 +0200)]
Fix a comment for remove_self_joins_recurse()
Discussion: https://postgr.es/m/18187-
831da249cbd2ff8e%40postgresql.org
Author: Richard Guo
Reviewed-by: Andrei Lepikhov
Alexander Korotkov [Sun, 24 Dec 2023 23:24:25 +0000 (01:24 +0200)]
Don't constrain self-join removal due to PHVs
Self-join removal appears to be safe to apply with placeholder variables
as long as we handle PlaceHolderVar in replace_varno_walker() and replace
relid in phinfo->ph_lateral.
Discussion: https://postgr.es/m/18187-
831da249cbd2ff8e%40postgresql.org
Author: Richard Guo
Reviewed-by: Andrei Lepikhov
Alexander Korotkov [Sun, 24 Dec 2023 23:16:09 +0000 (01:16 +0200)]
Handle PlaceHolderVar case in replace_varno_walker
This commit also retires sje_walker. This increases the generalty of replacing
varno in the parse tree and simplifies the code.
Discussion: https://postgr.es/m/18187-
831da249cbd2ff8e%40postgresql.org
Author: Richard Guo
Reviewed-by: Andrei Lepikhov
Alexander Korotkov [Sun, 24 Dec 2023 22:52:42 +0000 (00:52 +0200)]
Enhance checkpointer restartpoint statistics
Bhis commit introduces enhancements to the pg_stat_checkpointer view by adding
three new columns: restartpoints_timed, restartpoints_req, and
restartpoints_done. These additions aim to improve the visibility and
monitoring of restartpoint processes on replicas.
Previously, it was challenging to differentiate between successful and failed
restartpoint requests. This limitation arises because restartpoints on replicas
are dependent on checkpoint records from the primary, and cannot occur more
frequently than these checkpoints.
The new columns allow for clear distinction and tracking of restartpoint
requests, their triggers, and successful completions. This enhancement aids
database administrators and developers in better understanding and diagnosing
issues related to restartpoint behavior, particularly in scenarios where
restartpoint requests may fail.
System catalog is changed. Catversion is bumped.
Discussion: https://postgr.es/m/
99b2ccd1-a77a-962a-0837-
191cdf56c2b9%40inbox.ru
Author: Anton A. Melnikov
Reviewed-by: Kyotaro Horiguchi, Alexander Korotkov
Michael Paquier [Sun, 24 Dec 2023 02:49:14 +0000 (11:49 +0900)]
pgbench: Fix overflow in table populating when rows >= 2^31-1
Using a scale factor large enough so as the number of rows to insert
gets larger than INT32_MAX would cause an infinite loop in
initPopulateTable(), preventing pgbench to finish its initialization.
Oversight in
e35cc3b3f2d0 that has refactored the data generation logic.
Author: John Hsu
Reviewed-by: Tatsuo Ishii, Japin Li
Discussion: https://postgr.es/m/CA+-JvFvHsOafjHcuFPfkyouHNZvbOXhBNhwZxKm3WNgYz9bwzA@mail.gmail.com
Tom Lane [Sat, 23 Dec 2023 16:50:33 +0000 (11:50 -0500)]
Set readline-relevant ENV vars in interactive_psql(), not caller.
Commit
664d75753 pulled 010_tab_completion.pl's infrastructure for
invoking an interactive psql session out into a generally-useful test
function, but it didn't move enough stuff. We need to set up various
environment variables that readline will look at, both to ensure
stability of test results and to prevent test actions from cluttering
the calling user's ~/.psql_history. Expecting calling scripts to
remember to do that is too failure-prone: the other existing caller
001_password.pl did not do it. Hence, remove those initialization
steps from 010_tab_completion.pl and put them into interactive_psql().
Since interactive_psql was already making a local ENV hash, this has
no effect on calling scripts.
Discussion: https://postgr.es/m/794610.
1703182896@sss.pgh.pa.us
Peter Eisentraut [Fri, 22 Dec 2023 20:44:55 +0000 (21:44 +0100)]
Set all variable-length fields of pg_attribute to null on column drop
When a column is dropped, the fields attacl, attoptions, and
attfdwoptions were kept unchanged. This is probably harmless, but it
seems wasteful, and leaves potentially dangling data lying around (for
example, attacl could contain references to users that are later also
dropped).
Change this to set those fields to null when a column is marked as
dropped.
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/flat/
249d819d-1763-4580-8110-
0bf91a0f08b7@eisentraut.org
Tom Lane [Fri, 22 Dec 2023 18:32:15 +0000 (13:32 -0500)]
Stop generating plain-text INSTALL instructions.
Up to now, our distribution tarballs have included a plain-text form
of the installation.sgml chapter. The rationale for that was that a
recipient might not have either ready internet access or HTML-viewing
tools; a theory that seems downright quaint today. Maintaining the
ability to generate this file is not without cost, because it puts
special requirements on installation.sgml that are often overlooked.
Moreover, we are moving in the direction of making our distribution
tarballs be pure git snapshots for traceability/reproducibility
reasons; including generated files doesn't fit into that plan.
Hence, let's just drop INSTALL and remove the infrastructure for
generating it. The top-level README will now recommend visiting
our website to see the installation instructions. As a useful
side-effect, we can get rid of README.git which has provoked
confusion.
Discussion: https://postgr.es/m/
20231220114927.faccqqprmuyrzdip@alap3.anarazel.de
Discussion: https://postgr.es/m/
e07408d9-e5f2-d9fd-5672-
f53354e9305e@eisentraut.org
Andrew Dunstan [Fri, 22 Dec 2023 13:56:27 +0000 (13:56 +0000)]
Make win32tzlist.pl checkable again
Commit
1301c80b21 removed some infrastructure needed to check
windows-oriented perl scripts. It also removed most such scripts, but
this one was left over. We repair the damage by making Win32::Registry a
conditional requirement that is only loaded on Windows. With this change
`perl -cw win32tzlist.pl` once again passes on non-Windows machines.
Discussion: https://postgr.es/m/
a2bd77fd-61b8-4c2b-b12e-
3e22ae260f82@eisentraut.org
Jeff Davis [Thu, 21 Dec 2023 23:10:13 +0000 (15:10 -0800)]
Initialize data directories with --lc-messages=C for tests.
Commit
db6d9891e8 changed them to be initialized with --no-locale, but
that reduced the test coverage for non-C locales.
Discussion: https://postgr.es/m/
0d47e5ecc037b3908149aad5f2a987793cf938bd.camel%40j-davis.com
Robert Haas [Thu, 21 Dec 2023 21:03:03 +0000 (16:03 -0500)]
Replace nonsense comment with a relevant one.
Per report from Alexander Lakhin.
Discussion: http://postgr.es/m/
061cccf7-0cac-804f-4c2a-
9d6da8e3848b@gmail.com
Robert Haas [Thu, 21 Dec 2023 20:36:17 +0000 (15:36 -0500)]
Fix numerous typos in incremental backup commits.
Apparently, spell check would have been a really good idea.
Alexander Lakhin, with a few additions as per an off-list report
from Andres Freund.
Discussion: http://postgr.es/m/
f08f7c60-1ad3-0b57-d580-
54b11f07cddf@gmail.com
Tom Lane [Thu, 21 Dec 2023 20:04:00 +0000 (15:04 -0500)]
pg_combinebackup didn't clean its tmp_check directory, either.
Another oversight in
dc2123400, visible when building/testing
in the source directory. (There's a lot of stuff we could
simplify if we stop supporting that case, but for now it's
still mainstream.)
Tom Lane [Thu, 21 Dec 2023 17:43:36 +0000 (12:43 -0500)]
Avoid trying to fetch metapage of an SPGist partitioned index.
This is necessary when spgcanreturn() is invoked on a partitioned
index, and the failure might be reachable in other scenarios as
well. The rest of what spgGetCache() does is perfectly sensible
for a partitioned index, so we should allow it to go through.
I think the main takeaway from this is that we lack sufficient test
coverage for non-btree partitioned indexes. Therefore, I added
simple test cases for brin and gin as well as spgist (hash and
gist AMs were covered already in indexing.sql).
Per bug #18256 from Alexander Lakhin. Although the known test case
only fails since v16 (
3c569049b), I've got no faith at all that there
aren't other ways to reach this problem; so back-patch to all
supported branches.
Discussion: https://postgr.es/m/18256-
0b0e1b6e4a620f1b@postgresql.org
Tom Lane [Thu, 21 Dec 2023 16:50:41 +0000 (11:50 -0500)]
pg_combinebackup's .gitignore file is incomplete.
Oversight in commit
dc2123400, evidently.
Dean Rasheed [Thu, 21 Dec 2023 12:55:22 +0000 (12:55 +0000)]
Fix BEFORE ROW trigger handling in cross-partition MERGE update.
Fix a bug during MERGE if a cross-partition update is attempted on a
partitioned table with a BEFORE DELETE ROW trigger that returns NULL,
to prevent the update. This would cause an error to be thrown, or an
assert failure in an assert-enabled build.
This was an oversight in
9321c79c86, which failed to properly
distinguish a DELETE prevented by a trigger from one prevented by a
concurrent update. Fix by having ExecDelete() return the TM_Result
status to ExecCrossPartitionUpdate(), so that it can distinguish the
two cases, and make ExecCrossPartitionUpdate() return the TM_Result
status to ExecUpdateAct(), so that it can return the correct status
from a concurrent update.
In addition, ensure that the command tag is correctly updated by
having ExecMergeMatched() pass canSetTag to ExecUpdateAct(), rather
than passing false, so that it updates the command tag if it does a
cross-partition update, making this code path in ExecMergeMatched()
consistent with ExecUpdate().
Per bug #18238 from Alexander Lakhin. Back-patch to v15, where MERGE
was introduced.
Dean Rasheed, reviewed by Richard Guo and Jian He.
Discussion: https://postgr.es/m/18238-
2f2bdc7f720180b9%40postgresql.org
Peter Eisentraut [Thu, 21 Dec 2023 10:42:12 +0000 (11:42 +0100)]
Fix prologue of get_partition_ancestors()
The callers of this function assume that the first Oid in the list
returned by this function corresponds to the immediate parent and the
last on corresponds to the topmost parent. Make that explicit in the
function prologue.
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5vCbATEmht861=G-BFPHNwLUqyeGa_=8-xibJ6Q1UxAeA@mail.gmail.com
Peter Eisentraut [Thu, 21 Dec 2023 07:40:32 +0000 (08:40 +0100)]
meson: Make gzip and tar optional
They are only used for some tests. The tests are already set to skip
as appropriate if they are not available.
Discussion: https://www.postgresql.org/message-id/flat/ZQzp_VMJcerM1Cs_%40paquier.xyz
Peter Eisentraut [Thu, 21 Dec 2023 07:40:32 +0000 (08:40 +0100)]
meson: Make sed optional
sed is used only if dtrace or selinux are enabled. Those options are
only used on Unix platforms, which should have sed. But we don't want
to make sed a hard requirement on Windows, which was the case in meson
until now.
This just changes sed to be not-required by meson. If you happen to
use a system with, say, dtrace but without sed, you might get a
slightly complicated error from meson during the build, but that seems
better than making the requiredness a complicated conditional that
will need to be maintained.
Discussion: https://www.postgresql.org/message-id/flat/ZQzp_VMJcerM1Cs_%40paquier.xyz
Michael Paquier [Thu, 21 Dec 2023 01:19:17 +0000 (10:19 +0900)]
Add PostgreSQL::Test::Cluster::advance_wal
This is a function that makes a node jump by N WAL segments, which is
something a couple of tests have been relying on for some cases related
to streaming, replication slot limits and logical decoding on standbys.
Hence, this centralizes the logic, while making it cheaper by relying on
pg_logical_emit_message() to emit WAL records before switching to a new
segment.
Author: Bharath Rupireddy
Reviewed-by: Kyotaro Horiguchi, Euler Taveira
Discussion: https://postgr.es/m/CALj2ACU3R8QFCvDewHCMKjgb2w_-CMCyd6DAK=Jb-af14da5eg@mail.gmail.com
Masahiko Sawada [Thu, 21 Dec 2023 01:09:38 +0000 (10:09 +0900)]
Show isCatalogRel in several rmgr descriptions.
Commit
6af179395 added isCatalogRel field to some WAL record types,
but this field was not shown in the rmgr descriptions. This commit
changes the several rmgr descriptions to display the isCatalogRel
field.
Author: Bertrand Drouvot
Reviewed-by: Michael Paquier, Masahiko Sawada
Discussion: https://postgr.es/m/
957dc8f9-2a02-4640-9c01-
9dcbf97c4187%40gmail.com
Andrew Dunstan [Wed, 20 Dec 2023 22:28:57 +0000 (22:28 +0000)]
Rename pgindent options
--show-diff becomes --diff, and --silent-diff becomes --check. These
options may now be given together. Without --check, --diff will exit
with a zero status even if diffs are found. With --check, it will now
exit with a non-zero status in that case.
Author: Tristan Partin
Reviewed-by: Daniel Gustafsson, Jelte Fennema-Nio
Discussion: https://postgr.es/m/CXLX2XYTH9S6.140SC6Y61VD88@neon.tech
Daniel Gustafsson [Wed, 20 Dec 2023 22:07:44 +0000 (23:07 +0100)]
doc: Fix typo in pg_combinebackup documentation
Commit
dc2123400 accidentally misspelled "combination".
Daniel Gustafsson [Wed, 20 Dec 2023 21:37:28 +0000 (22:37 +0100)]
Fix unchecked return value from strdup
The pg_dump compression was using strdup() instead of pg_strdup()
and failed to check the returned pointer for out-of-memory before
dereferencing it. Fix by using pg_strdup() instead which probably
was the intention here in the original patch.
Backpatch to v16 where pg_dump compression was introduced.
Reviewed-by: Tristan Partin <tristan@neon.tech>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/
CC661D60-6F4C-474D-B9CF-
E789ACA3CEFC@yesql.se
Backpatch-through: 16
Robert Haas [Wed, 20 Dec 2023 14:49:12 +0000 (09:49 -0500)]
Add support for incremental backup.
To take an incremental backup, you use the new replication command
UPLOAD_MANIFEST to upload the manifest for the prior backup. This
prior backup could either be a full backup or another incremental
backup. You then use BASE_BACKUP with the INCREMENTAL option to take
the backup. pg_basebackup now has an --incremental=PATH_TO_MANIFEST
option to trigger this behavior.
An incremental backup is like a regular full backup except that
some relation files are replaced with files with names like
INCREMENTAL.${ORIGINAL_NAME}, and the backup_label file contains
additional lines identifying it as an incremental backup. The new
pg_combinebackup tool can be used to reconstruct a data directory
from a full backup and a series of incremental backups.
Patch by me. Reviewed by Matthias van de Meent, Dilip Kumar, Jakub
Wartak, Peter Eisentraut, and Álvaro Herrera. Thanks especially to
Jakub for incredibly helpful and extensive testing.
Discussion: http://postgr.es/m/CA+TgmoYOYZfMCyOXFyC-P+-mdrZqm5pP2N7S-r0z3_402h9rsA@mail.gmail.com
Robert Haas [Wed, 20 Dec 2023 13:41:09 +0000 (08:41 -0500)]
Add a new WAL summarizer process.
When active, this process writes WAL summary files to
$PGDATA/pg_wal/summaries. Each summary file contains information for a
certain range of LSNs on a certain TLI. For each relation, it stores a
"limit block" which is 0 if a relation is created or destroyed within
a certain range of WAL records, or otherwise the shortest length to
which the relation was truncated during that range of WAL records, or
otherwise InvalidBlockNumber. In addition, it stores a list of blocks
which have been modified during that range of WAL records, but
excluding blocks which were removed by truncation after they were
modified and never subsequently modified again.
In other words, it tells us which blocks need to copied in case of an
incremental backup covering that range of WAL records. But this
doesn't yet add the capability to actually perform an incremental
backup; the next patch will do that.
A new parameter summarize_wal enables or disables this new background
process. The background process also automatically deletes summary
files that are older than wal_summarize_keep_time, if that parameter
has a non-zero value and the summarizer is configured to run.
Patch by me, with some design help from Dilip Kumar and Andres Freund.
Reviewed by Matthias van de Meent, Dilip Kumar, Jakub Wartak, Peter
Eisentraut, and Álvaro Herrera.
Discussion: http://postgr.es/m/CA+TgmoYOYZfMCyOXFyC-P+-mdrZqm5pP2N7S-r0z3_402h9rsA@mail.gmail.com
Michael Paquier [Wed, 20 Dec 2023 06:07:55 +0000 (15:07 +0900)]
Fix generation of distribution tarball
1301c80b2167 has introduced in installation.sgml a link reference that
`make dist` was not able to understand.
Per buildfarm member guaibasaurus.
Jeff Davis [Wed, 20 Dec 2023 01:35:54 +0000 (17:35 -0800)]
Additional write barrier in AdvanceXLInsertBuffer().
First, mark the xlblocks member with InvalidXLogRecPtr, then issue a
write barrier, then initialize it. That ensures that the xlblocks
member doesn't appear valid while the contents are being initialized.
In preparation for reading WAL buffer contents without a lock.
Author: Bharath Rupireddy
Discussion: https://postgr.es/m/CALj2ACVfFMfqD5oLzZSQQZWfXiJqd-NdX0_317veP6FuB31QWA@mail.gmail.com
Reviewed-by: Andres Freund
Jeff Davis [Wed, 20 Dec 2023 01:35:42 +0000 (17:35 -0800)]
Use 64-bit atomics for xlblocks array elements.
In preparation for reading the contents of WAL buffers without a
lock. Also, avoids the previously-needed comment in GetXLogBuffer()
explaining why it's safe from torn reads.
Author: Bharath Rupireddy
Discussion: https://postgr.es/m/CALj2ACVfFMfqD5oLzZSQQZWfXiJqd-NdX0_317veP6FuB31QWA@mail.gmail.com
Reviewed-by: Andres Freund
Michael Paquier [Wed, 20 Dec 2023 00:44:37 +0000 (09:44 +0900)]
Remove MSVC scripts
This commit removes all the scripts located in src/tools/msvc/ to build
PostgreSQL with Visual Studio on Windows, meson becoming the recommended
way to achieve that. The scripts held some information that is still
relevant with meson, information kept and moved to better locations.
Comments that referred directly to the scripts are removed.
All the documentation still relevant that was in install-windows.sgml
has been moved to installation.sgml under a new subsection for Visual.
All the content specific to the scripts is removed. Some adjustments
for the documentation are planned in a follow-up set of changes.
Author: Michael Paquier
Reviewed-by: Peter Eisentraut, Andres Freund
Discussion: https://postgr.es/m/ZQzp_VMJcerM1Cs_@paquier.xyz
Michael Paquier [Tue, 19 Dec 2023 23:39:54 +0000 (08:39 +0900)]
basic_archive: Fix comments related to NO_INSTALLCHECK
These comments incorrectly referred to shared_preload_libraries as being
required for the test to work.
Thinko in commit
c68a1839902d.
Author: Bharath Rupireddy
Discussion: https://postgr.es/m/CALj2ACXpjFDiXf-L7AARQ4ppuxiDYSKZjyZb=wOa+cgg0zuWAw@mail.gmail.com
Robert Haas [Tue, 19 Dec 2023 20:21:34 +0000 (15:21 -0500)]
Move src/bin/pg_verifybackup/parse_manifest.c into src/common.
This makes it possible for the code to be easily reused by other
client-side tools, and/or by the server.
Patch by me. Review of this patch in particular by at least Peter
Eisentraut; reviewers for the patch series in general include Dilip
Kumar, Andres Fruend, David Steele, Álvaro Herrera, and Jakub Wartak.
Discussion: http://postgr.es/m/CA+TgmoZ6UGZVnSy5iak6s6+AXu_DewXovDjhLs3-su6nmU_x_g@mail.gmail.com
Robert Haas [Tue, 19 Dec 2023 20:00:23 +0000 (15:00 -0500)]
Fix brown paper bag bug in
5c47c6546c413d5eb51c1626070a807026e6139d.
The previous logic failed to work for anything other than the first
segment of a relation.
Report by Jakub Wartak. Patch by me.
Discussion: http://postgr.es/m/CAKZiRmwd3KTNMQhm9Bv4oR_1uMehXroO6kGyJQkiw9DfM8cMwQ@mail.gmail.com
Tom Lane [Tue, 19 Dec 2023 16:12:16 +0000 (11:12 -0500)]
Prevent integer overflow when forming tuple width estimates.
It's at least theoretically possible to overflow int32 when adding up
column width estimates to make a row width estimate. (The bug example
isn't terribly convincing as a real use-case, but perhaps wide joins
would provide a more plausible route to trouble.) This'd lead to
assertion failures or silly planner behavior. To forestall it, make
the relevant functions compute their running sums in int64 arithmetic
and then clamp to int32 range at the end. We can reasonably assume
that MaxAllocSize is a hard limit on actual tuple width, so clamping
to that is simply a correction for dubious input values, and there's
no need to go as far as widening width variables to int64 everywhere.
Per bug #18247 from RekGRpth. There've been no reports of this issue
arising in practical cases, so I feel no need to back-patch.
Richard Guo and Tom Lane
Discussion: https://postgr.es/m/18247-
11ac477f02954422@postgresql.org
Peter Eisentraut [Tue, 19 Dec 2023 13:58:47 +0000 (14:58 +0100)]
Update comment for Cardinality typedef
Author: Richard Guo <guofenglinux@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAMbWs4-Zd7Yy80RL1NdskLLo-wz6QoqsbC5TKs%3D3yZxG3BT_aA%40mail.gmail.com
Daniel Gustafsson [Tue, 19 Dec 2023 13:13:50 +0000 (14:13 +0100)]
doc: Fix syntax in ALTER FOREIGN DATA WRAPPER example
The example for dropping an option was incorrectly quoting the
option key thus making it a value turning the command into an
unqualified ADD operation. The result of dropping became adding
a new key/value pair instead:
d=# alter foreign data wrapper f options (drop 'b');
ALTER FOREIGN DATA WRAPPER
d=# select fdwoptions from pg_foreign_data_wrapper where fdwname='f';
fdwoptions
------------
{drop=b}
(1 row)
This has been incorrect for a long time so backpatch to all
supported branches.
Author: Tim <tim.needham2@gmail.com>
Discussion: https://postgr.es/m/
170292280173.
1876505.
5204623074024041738@wrigleys.postgresql.org
Heikki Linnakangas [Tue, 19 Dec 2023 10:11:47 +0000 (12:11 +0200)]
Simplify newNode() by removing special cases
- Remove MemoryContextAllocZeroAligned(). It was supposed to be a
faster version of MemoryContextAllocZero(), but modern compilers turn
the MemSetLoop() into a call to memset() anyway, making it more or
less identical to MemoryContextAllocZero(). That was the only user of
MemSetTest, MemSetLoop, so remove those too, as well as palloc0fast().
- Convert newNode() to a static inline function. When this was
originally originally written, it was written as a macro because
testing showed that gcc didn't inline the size check as we
intended. Modern compiler versions do, and now that it just calls
palloc0() there is no size-check to inline anyway.
One nice effect is that the palloc0() takes one less argument than
MemoryContextAllocZeroAligned(), which saves a few instructions in the
callers of newNode().
Reviewed-by: Peter Eisentraut, Tom Lane, John Naylor, Thomas Munro
Discussion: https://www.postgresql.org/message-id/
b51f1fa7-7e6a-4ecc-936d-
90a8a1659e7c@iki.fi
Michael Paquier [Tue, 19 Dec 2023 09:19:05 +0000 (18:19 +0900)]
pageinspect: Fix failure with hash_bitmap_info() for partitioned indexes
This function reads directly a page from a relation, relying on
index_open() to open the index to read from. Unfortunately, this would
crash when using partitioned indexes, as these can be opened with
index_open() but they have no physical pages.
Alexander has fixed the module, while I have written the test.
Author: Alexander Lakhin, Michael Paquier
Discussion: https://postgr.es/m/18246-
f4d9ff7cb3af77e6@postgresql.org
Backpatch-through: 12
Michael Paquier [Tue, 19 Dec 2023 06:20:39 +0000 (15:20 +0900)]
pgstattuple: Fix failure with pgstathashindex() for partitioned indexes
As coded, the function relied on index_open() when opening an index
relation, allowing partitioned indexes to be processed by
pgstathashindex(). This was leading to a "could not open file" error
because partitioned indexes have no physical files, or to a crash with
an assertion failure (like on HEAD).
This issue is fixed by applying the same checks as the other stat
functions for indexes, with a lookup at both RELKIND_INDEX and the index
AM expected.
Author: Alexander Lakhin
Discussion: https://postgr.es/m/18246-
f4d9ff7cb3af77e6@postgresql.org
Backpatch-through: 12
Amit Kapila [Tue, 19 Dec 2023 04:23:33 +0000 (09:53 +0530)]
pgoutput: Raise an error for missing protocol version parameter.
Currently, we give a misleading error if the user omits to pass the
required parameter 'proto_version' in SQL API
pg_logical_slot_get_changes() or during START_REPLICATION protocol
message. The error raised is as follows which indicates that the wrong
version is passed.
ERROR: client sent proto_version=0 but server only supports protocol 1 or higher
Author: Emre Hasegeli
Reviewed-by: Peter Smith, Amit Kapila
Discussion: https://postgr.es/m/CAE2gYzwdwtUbs-tPSV-QBwgTubiyGD2ZGsSnAVsDfAGGLDrGOA@mail.gmail.com