Tom Lane [Sun, 17 Jul 2022 21:43:28 +0000 (17:43 -0400)]
Fix omissions in support for the "regcollation" type.
The patch that added regcollation doesn't seem to have been too
thorough about supporting it everywhere that other reg* types
are supported. Fix that. (The find_expr_references omission
is moderately serious, since it could result in missing expression
dependencies. The others are less exciting.)
Noted while fixing bug #17483. Back-patch to v13 where
regcollation was added.
Discussion: https://postgr.es/m/
1423433.
1652722406@sss.pgh.pa.us
Tom Lane [Sun, 17 Jul 2022 21:27:50 +0000 (17:27 -0400)]
postgres_fdw: set search_path to 'pg_catalog' while deparsing constants.
The motivation for this is to ensure successful transmission of the
values of constants of regconfig and other reg* types. The remote
will be reading them with search_path = 'pg_catalog', so schema
qualification is necessary when referencing objects in other schemas.
Per bug #17483 from Emmanuel Quincerot. Back-patch to all supported
versions. (There's some other stuff to do here, but it's less
back-patchable.)
Discussion: https://postgr.es/m/
1423433.
1652722406@sss.pgh.pa.us
Thomas Munro [Fri, 15 Jul 2022 22:59:52 +0000 (10:59 +1200)]
Make dsm_impl_posix_resize more future-proof.
Commit
4518c798 blocks signals for a short region of code, but it
assumed that whatever called it had the signal mask set to UnBlockSig on
entry. That may be true today (or may even not be, in extensions in the
wild), but it would be better not to make that assumption. We should
save-and-restore the caller's signal mask.
The PG_SETMASK() portability macro couldn't be used for that, which is
why it wasn't done before. But... considering that commit
a65e0864
established back in 9.6 that supported POSIX systems have sigprocmask(),
and that this is POSIX-only code, there is no reason not to use standard
sigprocmask() directly to achieve that.
Back-patch to all supported releases, like
4518c798 and
80845b7c.
Reviewed-by: Alvaro Herrera
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/CA%2BhUKGKx6Biq7_UuV0kn9DW%2B8QWcpJC1qwhizdtD9tN-fn0H0g%40mail.gmail.com
David Rowley [Fri, 15 Jul 2022 03:27:14 +0000 (15:27 +1200)]
Fix inconsistent parameter names between prototype and declaration
Noticed while working in this area. This code was introduced in PG15,
which is still in beta, so backpatch to there for consistency.
Backpatch-through: 15
John Naylor [Fri, 1 Jul 2022 04:41:36 +0000 (11:41 +0700)]
Clarify that pg_dump takes ACCESS SHARE lock
Add link to the description of lock levels to avoid confusing "shared locks"
with SHARE locks.
Florin Irion
Reviewed-by: Álvaro Herrera, Tom Lane, and Nathan Bossart
Discussion: https://www.postgresql.org/message-id/flat/
d0f30cc2-3c76-1d43-f291-
7c4b2872d653@gmail.com
This is a backpatch of
4e2e8d71f, applied through version 14
Bruce Momjian [Fri, 15 Jul 2022 00:01:11 +0000 (20:01 -0400)]
docs: make monitoring "phases" table titles consistent
Reported-by: Nitin Jadhav
Discussion: https://postgr.es/m/CAMm1aWbmTHwHKC2PERH0CCaFVPoxrtLeS8=wNuoge94qdSp3vA@mail.gmail.com
Author: Nitin Jadhav
Backpatch-through: 13
Bruce Momjian [Thu, 14 Jul 2022 21:41:03 +0000 (17:41 -0400)]
doc: clarify how dropping of extensions affects dependent objs.
Clarify that functions/procedures are dropped when any extension that
depends on them is dropped.
Reported-by: David G. Johnston
Discussion: https://postgr.es/m/CAKFQuwbPSHMDGkisRUmewopweC1bFvytVqB=a=X4GFg=4ZWxPA@mail.gmail.com
Backpatch-through: 13
Bruce Momjian [Thu, 14 Jul 2022 20:34:30 +0000 (16:34 -0400)]
pg_upgrade doc: mention that replication slots must be recreated
Reported-by: Nikhil Shetty
Discussion: https://postgr.es/m/CAFpL5Vxastip0Jei-K-=7cKXTg=5sahSe5g=om=x68NOX8+PUA@mail.gmail.com
Backpatch-through: 10
Bruce Momjian [Thu, 14 Jul 2022 20:19:45 +0000 (16:19 -0400)]
doc: add documentation about ecpg Oracle-compatibility mode
Reported-by: Takeshi Ideriha
Discussion: https://postgr.es/m/TYCPR01MB7041A157067208327D8DAAF9EAA59@TYCPR01MB7041.jpnprd01.prod.outlook.com
Backpatch-through: 11
Bruce Momjian [Thu, 14 Jul 2022 20:07:12 +0000 (16:07 -0400)]
doc: move system views section to its own chapter
Previously it was inside the system catalogs chapter.
Reported-by: Peter Smith
Discussion: https://postgr.es/m/CAHut+PsMc18QP60D+L0hJBOXrLQT5m88yVaCDyxLq34gfPHsow@mail.gmail.com
Backpatch-through: 15
Bruce Momjian [Thu, 14 Jul 2022 19:44:22 +0000 (15:44 -0400)]
doc: clarify the behavior of identically-named savepoints
Original patch by David G. Johnston.
Reported-by: David G. Johnston
Discussion: https://postgr.es/m/CAKFQuwYQCxSSuSL18skCWG8QHFswOJ3hjovHsOZUE346i4OpVQ@mail.gmail.com
Backpatch-through: 10
Bruce Momjian [Thu, 14 Jul 2022 19:33:28 +0000 (15:33 -0400)]
doc: clarify that "excluded" ON CONFLICT is a single row
Original patch by David G. Johnston.
Reported-by: David G. Johnston
Discussion: https://postgr.es/m/CAKFQuwa4J0+WuO7kW1PLbjoEvzPN+Q_j+P2bXxNnCLaszY7ZdQ@mail.gmail.com
Backpatch-through: 10
Bruce Momjian [Thu, 14 Jul 2022 19:17:19 +0000 (15:17 -0400)]
doc: mention that INSERT can block because of unique indexes
Initial patch by David G. Johnston.
Reported-by: David G. Johnston
Discussion: https://postgr.es/m/CAKFQuwZpbdzceO41VE-xt1Xh8rWRRfgopTAK1wL9EhCo0Am-Sw@mail.gmail.com
Backpatch-through: 10
Bruce Momjian [Thu, 14 Jul 2022 16:08:55 +0000 (12:08 -0400)]
doc: mention the pg_locks lock names in parentheses
Reported-by: Troy Frericks
Discussion: https://postgr.es/m/
165653551130.665.
8240515669521441325@wrigleys.postgresql.org
Backpatch-through: 10
Thomas Munro [Thu, 14 Jul 2022 13:23:29 +0000 (01:23 +1200)]
Don't clobber postmaster sigmask in dsm_impl_resize.
Commit
4518c798 intended to block signals in regular backends that
allocate DSM segments, but dsm_impl_resize() is also reached by
dsm_postmaster_startup(). It's not OK to clobber the postmaster's
signal mask, so only manipulate the signal mask when under the
postmaster.
Back-patch to all releases, like
4518c798.
Discussion: https://postgr.es/m/CA%2BhUKGKNpK%3D2OMeea_AZwpLg7Bm4%3DgYWk7eDjZ5F6YbozfOf8w%40mail.gmail.com
Thomas Munro [Wed, 13 Jul 2022 04:16:07 +0000 (16:16 +1200)]
Block signals while allocating DSM memory.
On Linux, we call posix_fallocate() on shm_open()'d memory to avoid
later potential SIGBUS (see commit
899bd785).
Based on field reports of systems stuck in an EINTR retry loop there,
there, we made it possible to break out of that loop via slightly odd
coding where the CHECK_FOR_INTERRUPTS() call was somewhat removed from
the loop (see commit
422952ee).
On further reflection, that was not a great choice for at least two
reasons:
1. If interrupts were held, the CHECK_FOR_INTERRUPTS() would do nothing
and the EINTR error would be surfaced to the user.
2. If EINTR was reported but neither QueryCancelPending nor
ProcDiePending was set, then we'd dutifully retry, but with a bit more
understanding of how posix_fallocate() works, it's now clear that you
can get into a loop that never terminates. posix_fallocate() is not a
function that can do some of the job and tell you about progress if it's
interrupted, it has to undo what it's done so far and report EINTR, and
if signals keep arriving faster than it can complete (cf recovery
conflict signals), you're stuck.
Therefore, for now, we'll simply block most signals to guarantee
progress. SIGQUIT is not blocked (see InitPostmasterChild()), because
its expected handler doesn't return, and unblockable signals like
SIGCONT are not expected to arrive at a high rate. For good measure,
we'll include the ftruncate() call in the blocked region, and add a
retry loop.
Back-patch to all supported releases.
Reported-by: Alvaro Herrera
Reported-by: Nicola Contu
Reviewed-by: Alvaro Herrera
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/
20220701154105.jjfutmngoedgiad3%40alvherre.pgsql
Alvaro Herrera [Wed, 13 Jul 2022 10:10:03 +0000 (12:10 +0200)]
Plug memory leak
Commit
054325c5eeb3 created a memory leak in PQsendQueryInternal in case
an error occurs while sending the message. Repair.
Backpatch to 14, like that commit. Reported by Coverity.
David Rowley [Wed, 13 Jul 2022 05:01:39 +0000 (17:01 +1200)]
Small cleanup of create_list_bounds()
When checking for interleaved partitions, we mark the partition as
interleaved when;
1. we find an earlier partition index when looping over the
sorted-by-Datum indexes[] array, or;
2. we find that the NULL partition allows some non-NULL Datum value.
In the code, as it was written in
db632fbca we'll continue to check for
case 2 when we've already marked the partition as interleaved for case 1.
Here we make it so we don't bother marking the partition as interleaved
for case 2 when it's already been marked due to case 1.
Really all this saves is a useless call to bms_add_member(), but since
this code is new to PG15, it seems worth fixing it now to save anyone the
trouble of complaining at some time in the future. We have the
opportunity to improve this now before PG15 is out. This might ease some
future back-patching pain.
Per report and patch by Zhihong Yu. However, I slightly revised the
comments and altered the bms_add_member() code to match in both locations.
We already know that index is equal to boundinfo->null_index from the if
condition.
Author: Zhihong Yu
Discussion: https://postgr.es/m/CALNJ-vQbZR0pYxz9zQ5bqXVcwtGgNgVupeEpNT65HZ+yWZnc4g@mail.gmail.com
Backpatch-through: 15, same as
db632fbca.
David Rowley [Wed, 13 Jul 2022 02:03:24 +0000 (14:03 +1200)]
Tidy up code in get_cheapest_group_keys_order()
There are a few things that we could do a little better within
get_cheapest_group_keys_order():
1. We should be using list_free() rather than pfree() on a List.
2. We should use for_each_from() instead of manually coding a for loop to
skip the first n elements of a List
3. list_truncate(list_copy(...), n) is not a great way to copy the first n
elements of a list. Let's invent list_copy_head() for that. That way we
don't need to copy the entire list just to truncate it directly
afterwards.
4. We can simplify finding the cheapest cost by setting the cheapest cost
variable to DBL_MAX. That allows us to skip special-casing the initial
iteration of the loop.
Author: David Rowley
Discussion: https://postgr.es/m/CAApHDvrGyL3ft8waEkncG9y5HDMu5TFFJB1paoTC8zi9YK97Nw@mail.gmail.com
Backpatch-through: 15, where get_cheapest_group_keys_order was added.
Tom Lane [Tue, 12 Jul 2022 20:30:36 +0000 (16:30 -0400)]
Invent qsort_interruptible().
Justin Pryzby reported that some scenarios could cause gathering
of extended statistics to spend many seconds in an un-cancelable
qsort() operation. To fix, invent qsort_interruptible(), which is
just like qsort_arg() except that it will also do CHECK_FOR_INTERRUPTS
every so often. This bloats the backend by a couple of kB, which
seems like a good investment. (We considered just enabling
CHECK_FOR_INTERRUPTS in the existing qsort and qsort_arg functions,
but there are some callers for which that'd demonstrably be unsafe.
Opt-in seems like a better way.)
For now, just apply qsort_interruptible() in statistics collection.
There's probably more places where it could be useful, but we can
always change other call sites as we find problems.
Back-patch to v14. Before that we didn't have extended stats on
expressions, so that the problem was less severe. Also, this patch
depends on the sort_template infrastructure introduced in v14.
Tom Lane and Justin Pryzby
Discussion: https://postgr.es/m/
20220509000108[email protected]
Bruce Momjian [Mon, 11 Jul 2022 18:21:24 +0000 (14:21 -0400)]
relnotes: updates "cumulative statistics system" mention
Also add "the".
Reported-by: Justin Pryzby
Discussion: https://postgr.es/m/
20220711173923[email protected]
Backpatch-through: 15 only
Thomas Munro [Mon, 11 Jul 2022 02:47:16 +0000 (14:47 +1200)]
Fix lock assertions in dshash.c.
dshash.c previously maintained flags to be able to assert that you
didn't hold any partition lock. These flags could get out of sync with
reality in error scenarios.
Get rid of all that, and make assertions about the locks themselves
instead. Since LWLockHeldByMe() loops internally, we don't want to put
that inside another loop over all partition locks. Introduce a new
debugging-only interface LWLockAnyHeldByMe() to avoid that.
This problem was noted by Tom and Andres while reviewing changes to
support the new shared memory stats system, and later showed up in
reality while working on commit
389869af.
Back-patch to 11, where dshash.c arrived.
Reported-by: Tom Lane
Reported-by: Andres Freund
Reviewed-by: Kyotaro HORIGUCHI
Reviewed-by: Zhihong Yu
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/
20220311012712[email protected]
Discussion: https://postgr.es/m/CA%2BhUKGJ31Wce6HJ7xnVTKWjFUWQZPBngxfJVx4q0E98pDr3kAw%40mail.gmail.com
Michael Paquier [Mon, 11 Jul 2022 03:48:06 +0000 (12:48 +0900)]
Fix two portability issues with the tests of test_oat_hooks
This addresses two issues in the tests of test_oat_hooks:
- The role regress_test_user was being left behind, preventing the test
to succeed on repeated runs. It makes sense to leave some objects
behind to have more coverage for pg_upgrade (as does test_pg_dump), but
the role dropped here does not own any objects so there is no reason to
keep it.
- GRANT SET ON PARAMETER is issued, creating an entry in
pg_parameter_acl without cleaning up the entry created. This causes
an overlap with unsafe_tests as both use work_mem, making the latter
fail. This commit adds an extra REVOKE SET ON PARAMETER to clean the
contents of pg_parameter_acl, switching to maintenance_work_mem rather
than work_mem to avoid an overlap between both tests.
The tests of test_oat_hooks cannot use installcheck yet as these are
proving to be unstable with caching and the namespace search hooks, so
the issues fixed here cannot be reached yet, but they would be once the
hook issue is addressed and installcheck is allowed again in
test_oat_hooks.
Discussion: https://postgr.es/m/
[email protected]
Backpatch-through: 15
Michael Paquier [Mon, 11 Jul 2022 02:20:52 +0000 (11:20 +0900)]
Improve error message with JSON_SERIALIZE()
The error message introduced in
3c633f3 can share the same format string
with an existing message used for JSON(), reducing the translation
effort.
Author: Kyotaro Horiguchi
Discussion: https://postgr.es/m/
20220708.154135.
2123613118233840495[email protected]
Backpatch-through: 15
Michael Paquier [Mon, 11 Jul 2022 01:56:42 +0000 (10:56 +0900)]
doc: Fix inconsistent quotes in some jsonb fields
Single quotes are not allowed in json internals, double quotes are.
Reported-by: Eric Mutta
Discussion: https://postgr.es/m/
165715362165.665.
3875113264927503997@wrigleys.postgresql.org
Backpatch-through: 14
Thomas Munro [Sun, 10 Jul 2022 04:30:03 +0000 (16:30 +1200)]
Fix \watch's interaction with libedit on ^C.
When you hit ^C, the terminal driver in Unix-like systems echoes "^C" as
well as sending an interrupt signal (depending on stty settings). At
least libedit (but maybe also libreadline) is then confused about the
current cursor location, and corrupts the display if you try to scroll
back. Fix, by moving to a new line before the next prompt is displayed.
Back-patch to all supported released.
Author: Pavel Stehule
Reported-by: Tom Lane
Discussion: https://postgr.es/m/3278793.1626198638%40sss.pgh.pa.us
Bruce Momjian [Sat, 9 Jul 2022 00:23:35 +0000 (20:23 -0400)]
doc: add examples for array_length() and jsonb_array_length()
The examples show the output of array_length() and jsonb_array_length()
for empty arrays.
Discussion: https://postgr.es/m/CAKFQuwaoBmRuWdMLzLHDCFDJDX3wvfQ7egAF0bpik_BFgG1KWg@mail.gmail.com
Author: David G. Johnston
Backpatch-through: 13
Bruce Momjian [Fri, 8 Jul 2022 22:36:27 +0000 (18:36 -0400)]
doc: add pg_prewarm example
Discussion: https://postgr.es/m/
20220618085541.ezxdaljlpo6x7msc@home-desktop
Author: Dong Wook Lee
Backpatch-through: 11
Robert Haas [Fri, 8 Jul 2022 14:15:19 +0000 (10:15 -0400)]
Preserve relfilenode of pg_largeobject and its index across pg_upgrade.
Commit
9a974cbcba005256a19991203583a94b4f9a21a9 did this for user
tables, but pg_upgrade treats pg_largeobject as a user table, and so
needs the same treatment. Without this fix, if you rewrite the
pg_largeobject table and then perform an upgrade with pg_upgrade, the
table will apparently be empty on the new cluster, while all of your
objects will end up with an orphaned file.
With this fix, instead of the old cluster's pg_largeobject files ending
up orphaned, the original files fro the new cluster do. That's mostly
harmless because we expect the table to be empty, but we might want
to arrange to remove the as part of the upgrade. Since we're still
debating the best way of doing that, I (rhaas) have decided to postpone
dealing with that problem and get the basic fix committed.
Justin Pryzby, reviewed by Shruthi Gowda and by me.
Discussion: http://postgr.es/m/
20220701231413[email protected]
Andrew Dunstan [Thu, 7 Jul 2022 21:40:02 +0000 (17:40 -0400)]
Only allow returning string types or bytea from json_serialize
These are documented to be the allowed types for the RETURNING clause,
but the restriction was not being enforced, which caused a segfault if
another type was specified. Add some testing for this.
Per report from a.kozhemyakin
Backpatch to release 15.
Dean Rasheed [Thu, 7 Jul 2022 12:08:06 +0000 (13:08 +0100)]
Fix alias matching in transformLockingClause().
When locking a specific named relation for a FOR [KEY] UPDATE/SHARE
clause, transformLockingClause() finds the relation to lock by
scanning the rangetable for an RTE with a matching eref->aliasname.
However, it failed to account for the visibility rules of a join RTE.
If a join RTE doesn't have a user-supplied alias, it will have a
generated eref->aliasname of "unnamed_join" that is not visible as a
relation name in the parse namespace. Such an RTE needs to be skipped,
otherwise it might be found in preference to a regular base relation
with a user-supplied alias of "unnamed_join", preventing it from being
locked.
In addition, if a join RTE doesn't have a user-supplied alias, but
does have a join_using_alias, then the RTE needs to be matched using
that alias rather than the generated eref->aliasname, otherwise a
misleading "relation not found" error will be reported rather than a
"join cannot be locked" error.
Backpatch all the way, except for the second part which only goes back
to 14, where JOIN USING aliases were added.
Dean Rasheed, reviewed by Tom Lane.
Discussion: https://postgr.es/m/CAEZATCUY_KOBnqxbTSPf=7fz9HWPnZ5Xgb9SwYzZ8rFXe7nb=w@mail.gmail.com
Etsuro Fujita [Thu, 7 Jul 2022 07:25:00 +0000 (16:25 +0900)]
postgres_fdw: Fix grammar.
Oversight in commit
4036bcbbb; back-patch to v15 where that appeared.
Amit Kapila [Thu, 7 Jul 2022 03:45:52 +0000 (09:15 +0530)]
Re-order disable_on_error in tab-complete.
By convention, the tab-complete subscription parameters are listed in the
COMPLETE_WITH lists in alphabetical order, but when the "disable_on_error"
parameter was introduced this was not done.
This patch just tidies that up.
Reported-by: Peter Smith
Author: Peter Smith
Reviewed-by: Euler Taveira, Takamichi Osumi
Backpatch-through: 15, where it was introduced
Discussion: https://postgr.es/m/CAHut+PucvKZgg_eJzUW--iL6DXHg1Jwj6F09tQziE3kUF67uLg@mail.gmail.com
Andres Freund [Wed, 6 Jul 2022 22:50:38 +0000 (15:50 -0700)]
pgstat: slru: remove outdated comment
That comment might have been true at some point during development, but
definitely isn't anymore.
Reported-By: Melanie Plageman
Backpatch: 15-
Tom Lane [Wed, 6 Jul 2022 21:26:27 +0000 (17:26 -0400)]
Fix wrong field order in _readMergeWhenClause().
We hadn't noticed this because it's dead code: there is no
situation where we read raw parse trees from text format.
So maybe the right fix is to remove the function altogether,
but I'll forbear for now; it's not the only dead code in
readfuncs.c, I think.
Noted while comparing existing code to the results of
Peter's auto-generation script.
David Rowley [Wed, 6 Jul 2022 20:14:32 +0000 (08:14 +1200)]
Overload index_form_tuple to allow the memory context to be supplied
40af10b57 changed things so we make use of a generation memory context for
storing tuples to be sorted by tuplesort.c. That change does not play
nicely with the changes made in
9f03ca915 (back in 2014). That commit
changed things so that index_form_tuple() is called while switched into
the tuplestore's tuplecontext. In order to fetch the tuple from the index,
index_form_tuple() must do various memory allocations which are unrelated
to the storage of the final returned tuple. Although all of these
allocations are pfree'd, the fact that we now use a generation context
means that the memory for these pfree'd allocations won't be used again by
any other allocation due to generation.c's lack of freelists. This could
result in sorts used for building indexes exceeding maintenance_work_mem
by a very large amount.
Here we fix it so we no longer allocate anything apart from the tuple
itself into the generation context by adding a new version of
index_form_tuple named index_form_tuple_context, which can be called to
specify the MemoryContext to allocate the tuple into.
Discussion: https://postgr.es/m/CAApHDvrHQkiFRHiGiAS-LMOvJN-eK-s762=tVzBz8ZqUea-a_A@mail.gmail.com
Backpatch-through: 15, where
40af10b57 was added.
Andres Freund [Wed, 6 Jul 2022 15:46:04 +0000 (08:46 -0700)]
pgstat: drop subscription stats regardless of slot, fix comment
There's no reason anymore to only drop subscription stats if associated with a
slot, now that stats drops are transactional. Additionally, the comment
referring to autovacuum cleaning up stats was clearly outdated.
Author: Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoAwiby3HeJE7vJe16Gr75RFfJ640dyHqvsiUhyKJTXPtw@mail.gmail.com
Backpatch: 15-
David Rowley [Wed, 6 Jul 2022 07:41:09 +0000 (19:41 +1200)]
Remove size increase in ExprEvalStep caused by hashed saops
50e17ad28 increased the size of ExprEvalStep from 64 bytes up to 88 bytes.
Lots of effort was spent during the development of the current expression
evaluation code to make an instance of this struct as small as possible.
Making this struct larger than needed reduces CPU cache efficiency during
expression evaluation which causes noticeable slowdowns during query
execution.
In order to reduce the size of the struct, here we remove the fn_addr
field. The values from this field can be obtained via fcinfo, just with
some extra pointer dereferencing. The extra indirection does not seem to
cause any noticeable slowdowns.
Various other fields have been moved into the ScalarArrayOpExprHashTable
struct. These fields are only used when the ScalarArrayOpExprHashTable
pointer has already been dereferenced, so no additional pointer
dereferences occur for these. Here we also make hash_fcinfo_data the last
field in ScalarArrayOpExprHashTable so that we can avoid a further pointer
dereference to get the FunctionCallInfoBaseData. This also saves a call to
palloc().
50e17ad28 was added in 14, but it's too late to adjust the size of the
ExprEvalStep in that version, so here we just backpatch to 15, which is
currently in beta.
Author: Andres Freund, David Rowley
Discussion: https://postgr.es/m/
20220616233130[email protected]
Backpatch-through: 15
Tom Lane [Tue, 5 Jul 2022 22:23:19 +0000 (18:23 -0400)]
Tighten pg_upgrade's new check for non-upgradable anyarray usages.
We only need to reject cases when the aggregate or operator is
itself declared with a polymorphic type. Per buildfarm.
Discussion: https://postgr.es/m/
3383880.QJadu78ljV@vejsadalnx
Andres Freund [Fri, 17 Jun 2022 19:48:34 +0000 (12:48 -0700)]
pgstat: reduce timer overhead by leaving timer running.
Previously the timer was enabled whenever there were any pending stats after
executing a statement, just to then be disabled again when not idle
anymore. That lead to an increase in GetCurrentTimestamp() calls from within
timeout.c compared to 14.
To avoid that increase, leave the timer enabled until stats are reported,
rather than until idle. The timer is only disabled once the pending stats have
been reported.
For me this fixes the increase in GetCurrentTimestamp() calls, there now are
fewer calls in 15 than in 14, in the previously slowed down workload.
While at it, also update assertion in pgstat_report_stat() to be more precise.
Author: Andres Freund
Discussion: https://postgr.es/m/20220616233130[email protected]
Backpatch: 15-
Andres Freund [Fri, 17 Jun 2022 01:33:42 +0000 (18:33 -0700)]
expression eval: Fix EEOP_JSON_CONSTRUCTOR and EEOP_JSONEXPR size.
The new expression step types increased the size of ExprEvalStep by ~4 for all
types of expression steps, slowing down expression evaluation noticeably. Move
them out of line.
There's other issues with these expression steps, but addressing them is
largely independent of this aspect.
Author: Andres Freund
Reviewed-By: Andrew Dunstan
Discussion: https://postgr.es/m/20220616233130[email protected]
Backpatch: 15-
Andres Freund [Tue, 5 Jul 2022 18:01:10 +0000 (11:01 -0700)]
Revert 019_replslot_limit.pl related debugging aids.
This reverts most of
91c0570a791,
f28bf667f60,
fe0972ee5e6,
afdeff10526. The
only thing left is the retry loop in 019_replslot_limit.pl that avoids
spurious failures by retrying a couple times.
We haven't seen any hard evidence that this is caused by anything but slow
process shutdown. We did not find any cases where walsenders did not vanish
after waiting for longer. Therefore there's no reason for this debugging code
to remain.
Discussion: https://postgr.es/m/
20220530190155[email protected]
Backpatch: 15-
Bruce Momjian [Tue, 5 Jul 2022 18:06:45 +0000 (14:06 -0400)]
relnotes: clarify that PG 15 multi-xid is advanced more
Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzk-oOpKObMKJ=Df4WBERX0ja14ymu3h5JrDt_FtmvH1yQ@mail.gmail.com
Backpatch-through: 15 only
Robert Haas [Tue, 5 Jul 2022 17:31:55 +0000 (13:31 -0400)]
Rename pg_checkpointer predefined role to pg_checkpoint.
This is more consistent with how other predefined roles that confer
specific privileges are named.
Nathan Bosart
Discussion: http://postgr.es/m/CA+TgmoatH7+yYe+A8uJFNogg3VUDtFE6c-77yHAY8TRWR7oqyw@mail.gmail.com
Tom Lane [Tue, 5 Jul 2022 17:06:31 +0000 (13:06 -0400)]
Fix pg_upgrade to detect non-upgradable anyarray usages.
When we changed some built-in functions to use anycompatiblearray
instead of anyarray, we created a dump/restore hazard for user-defined
operators and aggregates relying on those functions: the user objects
have to be modified to change their signatures similarly. This causes
pg_upgrade to fail partway through if the source installation contains
such objects. We generally try to have pg_upgrade detect such hazards
and fail before it does anything exciting, so add logic to detect
this case too.
Back-patch to v14 where the change was made.
Justin Pryzby, reviewed by Andrey Borodin
Discussion: https://postgr.es/m/
3383880.QJadu78ljV@vejsadalnx
Tom Lane [Tue, 5 Jul 2022 15:12:33 +0000 (11:12 -0400)]
Fix errors in copyfuncs/equalfuncs support for JSON node types.
Noted while comparing existing code to the output of the proposed
patch to automate creation of these functions. Some of the changes
are just cosmetic, but others represent real bugs. I've not
attempted to analyze the user-visible impact.
Back-patch to v15 where this code came in.
Discussion: https://postgr.es/m/
1794155.
1656984188@sss.pgh.pa.us
Alvaro Herrera [Tue, 5 Jul 2022 12:21:20 +0000 (14:21 +0200)]
libpq: Improve idle state handling in pipeline mode
We were going into IDLE state too soon when executing queries via
PQsendQuery in pipeline mode, causing several scenarios to misbehave in
different ways -- most notably, as reported by Daniele Varrazzo, that a
warning message is produced by libpq:
message type 0x33 arrived from server while idle
But it is also possible, if queries are sent and results consumed not in
lockstep, for the expected mediating NULL result values from PQgetResult
to be lost (a problem which has not been reported, but which is more
serious).
Fix this by introducing two new concepts: one is a command queue element
PGQUERY_CLOSE to tell libpq to wait for the CloseComplete server
response to the Close message that is sent by PQsendQuery. Because the
application is not expecting any PGresult from this, the mechanism to
consume it is a bit hackish.
The other concept, authored by Horiguchi-san, is a PGASYNC_PIPELINE_IDLE
state for libpq's state machine to differentiate "really idle" from
merely "the idle state that occurs in between reading results from the
server for elements in the pipeline". This makes libpq not go fully
IDLE when the libpq command queue contains entries; in normal cases, we
only go IDLE once at the end of the pipeline, when the server response
to the final SYNC message is received. (However, there are corner cases
it doesn't fix, such as terminating the query sequence by
PQsendFlushRequest instead of PQpipelineSync; this sort of scenario is
what requires PGQUERY_CLOSE bit above.)
This last bit helps make the libpq state machine clearer; in particular
we can get rid of an ugly hack in pqParseInput3 to avoid considering
IDLE as such when the command queue contains entries.
A new test mode is added to libpq_pipeline.c to tickle some related
problematic cases.
Reported-by: Daniele Varrazzo
Co-authored-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/CA+mi_8bvD0_CW3sumgwPvWdNzXY32itoG_16tDYRu_1S2gV2iw@mail.gmail.com
Alvaro Herrera [Tue, 5 Jul 2022 11:38:26 +0000 (13:38 +0200)]
BRIN: improve documentation on summarization
The existing wording wasn't clear enough and some details weren't
anywhere, such as the fact that autosummarization is off by default.
Improve.
Authors: Roberto Mello, Jaime Casanova, Justin Pryzby, Álvaro Herrera
Discussion: https://postgr.es/m/CAKz==bK_NoJytRyQfX8K-erCW3Ff7--oGYpiB8+ePVS7dRVW_A@mail.gmail.com
Discussion: https://postgr.es/m/
20220224193520[email protected]
Tom Lane [Mon, 4 Jul 2022 01:38:32 +0000 (21:38 -0400)]
Use a short socket directory path in pg_upgrade testing.
Several buildfarm members are failing the pg_upgrade test in
REL_15_STABLE, though the identical test is fine in HEAD.
On thorntail it's possible to see that the problem is an
overlength socket path name, and I bet the same is true
on the others.
The normally-started postmasters used in the test are already
set up with short socket directory paths, but we neglected to
tell pg_upgrade itself to do likewise when starting child
postmasters, and indeed it seems to be explicitly selecting
the test directory instead.
Back-patch to v15 where the current test script was introduced.
(The previous script might have the same issue, because I don't
see any use of -s/--socketdir in it either; but we've had no
complaints, so leave it alone for now.)
Discussion: https://postgr.es/m/
1410025.
1656890531@sss.pgh.pa.us
Andrew Dunstan [Sun, 3 Jul 2022 21:08:25 +0000 (17:08 -0400)]
Remove %error-verbose directive from jsonpath parser
None of the other bison parsers contains this directive, and it gives
rise to some unfortunate and impenetrable messages, so just remove it.
Backpatch to release 12, where it was introduced.
Per gripe from Erik Rijkers
Discussion: https://postgr.es/m/
ba069ce2-a98f-dc70-dc17-
2ccf2a9bf7c7@xs4all.nl
Noah Misch [Sun, 3 Jul 2022 20:07:17 +0000 (13:07 -0700)]
Add Windows file version information to libpq/test programs.
Back-patch to v15, the first version to install these programs.
Discussion: https://postgr.es/m/
20220501080706[email protected]
Tom Lane [Sun, 3 Jul 2022 19:27:27 +0000 (15:27 -0400)]
Simplify tab completion of extension versions, redux.
After commit
662dbe2c8, psql tab completion didn't conveniently
support the case of "ALTER EXTENSION foo UPDATE". It'd always
add "TO", which is fine if you want to specify a target version
but not if you don't ... and surely the latter is the much more
common case.
To fix, remove "TO" from the initially offered completion; you now
need to press TAB one additional time to get that. We won't try to
duplicate the old behavior of attempting initial completion on the
target version along with TO. It's too squirrelly to get the quoting
right, and this is such an infrequent usage that it doesn't seem worth
expending a lot of effort and special code on.
Noted by Noah Misch. Back-patch to v15.
Discussion: https://postgr.es/m/
20220703083217[email protected]
Noah Misch [Sun, 3 Jul 2022 04:03:19 +0000 (21:03 -0700)]
Fix previous commit's ecpg_clocale for ppc Darwin.
Per buildfarm member prairiedog, this platform rejects uninitialized
global variables in shared libraries. Back-patch to v10, like the
addition of the variable.
Reviewed by Tom Lane.
Discussion: https://postgr.es/m/
20220703030619[email protected]
Noah Misch [Sat, 2 Jul 2022 20:00:30 +0000 (13:00 -0700)]
ecpglib: call newlocale() once per process.
ecpglib has been calling it once per SQL query and once per EXEC SQL GET
DESCRIPTOR. Instead, if newlocale() has not succeeded before, call it
while establishing a connection. This mitigates three problems:
- If newlocale() failed in EXEC SQL GET DESCRIPTOR, the command silently
proceeded without the intended locale change.
- On AIX, each newlocale()+freelocale() cycle leaked memory.
- newlocale() CPU usage may have been nontrivial.
Fail the connection attempt if newlocale() fails. Rearrange
ecpg_do_prologue() to validate the connection before its uselocale().
The sort of program that may regress is one running in an environment
where newlocale() fails. If that program establishes connections
without running SQL statements, it will stop working in response to this
change. I'm betting against the importance of such an ECPG use case.
Most SQL execution (any using ECPGdo()) has long required newlocale()
success, so there's little a connection could do without newlocale().
Back-patch to v10 (all supported versions).
Reviewed by Tom Lane. Reported by Guillaume Lelarge.
Discussion: https://postgr.es/m/
20220101074055[email protected]
Thomas Munro [Sat, 2 Jul 2022 04:06:47 +0000 (16:06 +1200)]
Default to dynamic_shared_memory_type=sysv on Solaris.
POSIX shm_open() can sleep for a long time and fail spuriously because
of contention on an internal lock file on Solaris (and presumably
illumos). Commit
389869af fixed the main problem with this, namely that
we could crash, but it's now clear that "posix" is not a good default.
Therefore, choose "sysv" at initdb time on Solaris and illumos. Other
choices are still available by editing the postgresql.conf file.
Back-patch only to 15, because contention is much less likely further
back, and it doesn't seem like a good idea to change this in released
branches. This should clear up the failures on build farm animal
margay.
Discussion: https://postgr.es/m/CA%2BhUKGKqKrCV5xKWfh9rnm%3Do%3DDwZLTLtnsj_XpUi9g5%3DV%2B9oyg%40mail.gmail.com
Noah Misch [Sat, 2 Jul 2022 01:27:18 +0000 (18:27 -0700)]
Fix race condition in t/028_pitr_timelines.pl.
Per buildfarm members sungazer and mylodon. Back-patch to v15, which
introduced this test.
Discussion: https://postgr.es/m/
20220627070457[email protected]
Peter Eisentraut [Fri, 1 Jul 2022 14:41:46 +0000 (16:41 +0200)]
Add missing GETTEXT_FLAGS entry
Fujii Masao [Fri, 1 Jul 2022 05:19:52 +0000 (14:19 +0900)]
doc: Add index entry for MERGE SQL command.
Back-patch to v15, where MERGE command was supported.
Author: Fujii Masao
Reviewed-by: Alvaro Herrera
Discussion: https://postgr.es/m/
4e7a4b38-c34a-ce2c-c71e-
832d2b768b29@oss.nttdata.com
Thomas Munro [Fri, 1 Jul 2022 00:05:52 +0000 (12:05 +1200)]
Harden dsm_impl.c against unexpected EEXIST.
Previously, we trusted the OS not to report EEXIST unless we'd passed in
IPC_CREAT | IPC_EXCL or O_CREAT | O_EXCL, as appropriate. Solaris's
shm_open() can in fact do that, causing us to crash because we didn't
ereport and then we blithely assumed the mapping was successful.
Let's treat EEXIST just like any other error, unless we're actually
trying to create a new segment. This applies to shm_open(), where this
behavior has been seen, and also to the equivalent operations for our
sysv and mmap modes just on principle.
Based on the underlying reason for the error, namely contention on a
lock file managed by Solaris librt for each distinct name, this problem
is only likely to happen on 15 and later, because the new shared memory
stats system produces shm_open() calls for the same path from
potentially large numbers of backends concurrently during
authentication. Earlier releases only shared memory segments between a
small number of parallel workers under one Gather node. You could
probably hit it if you tried hard enough though, and we should have been
more defensive in the first place. Therefore, back-patch to all
supported releases.
Per build farm animal margay. This isn't the end of the story, though,
it just changes random crashes into random "File exists" errors; more
work needed for a green build farm.
Reviewed-by: Robert Haas
Discussion: https://postgr.es/m/CA%2BhUKGKqKrCV5xKWfh9rnm%3Do%3DDwZLTLtnsj_XpUi9g5%3DV%2B9oyg%40mail.gmail.com
Tom Lane [Thu, 30 Jun 2022 15:08:12 +0000 (11:08 -0400)]
Add
82d0ffae3 to git-blame-ignore-revs.
Tom Lane [Thu, 30 Jun 2022 15:03:03 +0000 (11:03 -0400)]
pgindent run prior to branching v15.
pgperltidy and reformat-dat-files too. Not many changes.
Bruce Momjian [Tue, 28 Jun 2022 20:35:32 +0000 (16:35 -0400)]
relnotes: update item about public schema permission change
Also mention the bootstrap superuser.
Reported-by: Noah Misch
Discussion: https://postgr.es/m/
20220628063719[email protected]
Tom Lane [Mon, 27 Jun 2022 20:11:56 +0000 (16:11 -0400)]
Stamp 15beta2.
Magnus Hagander [Mon, 27 Jun 2022 17:43:27 +0000 (19:43 +0200)]
Remove outdated recommendation for manual VACUUM
We have had a working and tunable autovacuum
for at least a decade now, so remove the recommendation to
manually vacuum tables at least every night.
Autovacuum is now also triggered by INSERTs, so we can also
remove the recommendation to run VACUUM (ANALYZE) after lots
of INSERTs or DELETEs.
Instead, suggest using autovacuum by moving the respective
paragraph up to where the importance of VACUUM is emphasized.
Author: Laurenz Albe
Reviewed-By: Magnus Hagander, Peter Geoghegan
Discussion: https://postgr.es/m/6f5e3da98fec14640f389d7b84c3b413833697f4[email protected]
Peter Eisentraut [Mon, 27 Jun 2022 10:53:05 +0000 (12:53 +0200)]
PL/Python: Update guide to alternative expected files
plpython_unicode_3.out was already removed a long time ago, so it
being listed here was very out of date.
plpython_types_3.out was removed with the Python 2 removal.
Peter Eisentraut [Mon, 27 Jun 2022 07:06:44 +0000 (09:06 +0200)]
pg_upgrade: Fix version comparison for global ICU support
Reported-by: Justin Pryzby
Discussion: https://www.postgresql.org/message-id/
20220625151930[email protected]
Michael Paquier [Mon, 27 Jun 2022 06:33:39 +0000 (15:33 +0900)]
doc: Mention attribute "inherited" in pg_stats_ext[_exprs]
These have been added in
269b532, but the documentation did not reflect
that.
Author: Noriyoshi Shinoda
Reviewed-by: Justin Pryzby
Discussion: https://postgr.es/m/DM4PR84MB17349C4E7D88A68264C18AF3EED69@DM4PR84MB1734.NAMPRD84.PROD.OUTLOOK.COM
Peter Eisentraut [Mon, 27 Jun 2022 06:19:02 +0000 (08:19 +0200)]
Translation updates
Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash:
46c120873f1e906cc8dab74d8d756417e1b367f6
Heikki Linnakangas [Mon, 27 Jun 2022 05:21:08 +0000 (08:21 +0300)]
Fix visibility check when XID is committed in CLOG but not in procarray.
TransactionIdIsInProgress had a fast path to return 'false' if the
single-item CLOG cache said that the transaction was known to be
committed. However, that was wrong, because a transaction is first
marked as committed in the CLOG but doesn't become visible to others
until it has removed its XID from the proc array. That could lead to an
error:
ERROR: t_xmin is uncommitted in tuple to be updated
or for an UPDATE to go ahead without blocking, before the previous
UPDATE on the same row was made visible.
The window is usually very short, but synchronous replication makes it
much wider, because the wait for synchronous replica happens in that
window.
Another thing that makes it hard to hit is that it's hard to get such
a commit-in-progress transaction into the single item CLOG cache.
Normally, if you call TransactionIdIsInProgress on such a transaction,
it determines that the XID is in progress without checking the CLOG
and without populating the cache. One way to prime the cache is to
explicitly call pg_xact_status() on the XID. Another way is to use a
lot of subtransactions, so that the subxid cache in the proc array is
overflown, making TransactionIdIsInProgress rely on pg_subtrans and
CLOG checks.
This has been broken ever since it was introduced in 2008, but the race
condition is very hard to hit, especially without synchronous
replication. There were a couple of reports of the error starting from
summer 2021, but no one was able to find the root cause then.
TransactionIdIsKnownCompleted() is now unused. In 'master', remove it,
but I left it in place in backbranches in case it's used by extensions.
Also change pg_xact_status() to check TransactionIdIsInProgress().
Previously, it only checked the CLOG, and returned "committed" before
the transaction was actually made visible to other queries. Note that
this also means that you cannot use pg_xact_status() to reproduce the
bug anymore, even if the code wasn't fixed.
Report and analysis by Konstantin Knizhnik. Patch by Simon Riggs, with
the pg_xact_status() change added by me.
Author: Simon Riggs
Reviewed-by: Andres Freund
Discussion: https://www.postgresql.org/message-id/flat/
4da7913d-398c-e2ad-d777-
f752cf7f0bbb%40garret.ru
Thomas Munro [Sun, 26 Jun 2022 22:30:15 +0000 (10:30 +1200)]
Fix relptr's encoding of the base address.
Previously, we encoded both NULL and the first byte at the base address
as 0. That confusion led to the assertion in commit
e07d4ddc, which
failed when min_dynamic_shared_memory was used. Give them distinct
encodings, by switching to 1-based offsets for non-NULL pointers. Also
improve macro hygiene in passing (missing/misplaced parentheses), and
remove open-coded access to the raw offset value from freepage.c/h.
Although
e07d4ddc was back-patched to 10, the only code that actually
makes use of relptr at the base address arrived in
84b1c63a, so no need
to back-patch further than 14 for now.
Reported-by: Justin Pryzby
Reviewed-by: Robert Haas
Discussion: https://postgr.es/m/
20220519193839.GT19626%40telsasoft.com
Tom Lane [Sun, 26 Jun 2022 12:58:05 +0000 (08:58 -0400)]
Harden range_table_mutator() against null RangeTblEntry.subquery.
Commit
64919aaab made pull_up_simple_subquery set rte->subquery = NULL
after doing the deed, so that we don't waste cycles copying a
now-useless subquery tree around. This turns out to create a core dump
hazard in range_table_mutator, which supposes that that field is never
NULL. Apparently none of our own code invokes query_tree_mutator or
range_table_mutator on the top Query after subquery pullup; but it
wouldn't be surprising if outside code does, and anyway I'm working
on a v16 patch that will need it.
We can fix this cleanly by just getting rid of the special-case
handling of this field and treating it more like all the rest.
I think the special case might be left over from a time when
QTW_DONT_COPY_QUERY was the default behavior, but that was eons ago.
Thanks to Dean Rasheed for review.
Discussion: https://postgr.es/m/545569.
1656107045@sss.pgh.pa.us
Thomas Munro [Sat, 25 Jun 2022 22:40:06 +0000 (10:40 +1200)]
Don't trust signalfd() on illumos.
Since commit
6a2a70a02, we've used signalfd() to receive latch wakeups
when building with WAIT_USE_EPOLL (default for Linux and illumos), and
our traditional self-pipe when falling back to WAIT_USE_POLL (default
for other Unixes with neither epoll() nor kqueue()).
Unexplained hangs and kernel panics have been reported on illumos
systems, apparently linked to this use of signalfd(), leading illumos
users and build farm members to have to define WAIT_USE_POLL explicitly
as a work-around. A bug report exists at
https://www.illumos.org/issues/13700 but no fix is available yet.
Let's provide a way for illumos users to go back to self-pipes with
epoll(), like releases before 14, and choose that by default. No change
for Linux users. To help with development/debugging, macros
WAIT_USE_{EPOLL,POLL} and WAIT_USE_{SIGNALFD,SELF_PIPE} can be defined
explicitly to override the defaults.
Back-patch to 14, where we started using signalfd().
Reported-by: Japin Li
Reported-by: Olaf Bohlen (off-list)
Reviewed-by: Japin Li
Discussion: https://postgr.es/m/MEYP282MB1669C8D88F0997354C2313C1B6CA9%40MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Noah Misch [Sat, 25 Jun 2022 16:07:41 +0000 (09:07 -0700)]
CREATE INDEX: use the original userid for more ACL checks.
Commit
a117cebd638dd02e5c2e791c25e43745f233111b used the original userid
for ACL checks located directly in DefineIndex(), but it still adopted
the table owner userid for more ACL checks than intended. That broke
dump/reload of indexes that refer to an operator class, collation, or
exclusion operator in a schema other than "public" or "pg_catalog".
Back-patch to v10 (all supported versions), like the earlier commit.
Nathan Bossart and Noah Misch
Discussion: https://postgr.es/m/
f8a4105f076544c180a87ef0c4822352@stmuk.bayern.de
Noah Misch [Sat, 25 Jun 2022 16:07:41 +0000 (09:07 -0700)]
Use --no-unlogged-table-data in t/027_stream_regress.pl.
This removes the need to drop unlogged relations in the src/test/regress
suite, like commit
dec8ad367e46180f826d5b6dc820fbecba1b71d2 did.
Reviewed by Thomas Munro.
Discussion: https://postgr.es/m/39945.
1650895508@sss.pgh.pa.us
Peter Eisentraut [Fri, 24 Jun 2022 11:03:59 +0000 (13:03 +0200)]
Remove unportable test
The ssl test "IPv4 host with CIDR mask does not match" apparently has
a portability problem. Some operating systems don't reject the host
name specification "192.0.2.1/32" as an IP address, and that is then
later rejected when the SNI is set, which results in a different error
message that the test is supposed to verify.
The value of the test has been questioned in the discussion, and it
was suggested that removing it would be an acceptable fix, so that's
what this is doing.
Reported-by: Nazir Bilal Yavuz
Bug: #17522
Discussion: https://www.postgresql.org/message-id/flat/17522-
bfcd5c603b5f4daa%40postgresql.org
Amit Kapila [Fri, 24 Jun 2022 03:51:24 +0000 (09:21 +0530)]
Fix intermetent test failure in 028_row_filter.pl.
The test was not waiting for the subscriber's data synchronization to
happen after refreshing the publication on the subscriber side. This leads
subscriber's apply worker to skip applying the changes on the
corresponding relation which results in a test failure.
Reported-by: Hou Zhijie, as per buildfarm
Author: Hou Zhijie
Reviewed-by: Masahiko Sawada, Amit Kapila
Discussion: https://postgr.es/m/OS0PR01MB5716A69496A8E2F2E155DB8D94B59@OS0PR01MB5716.jpnprd01.prod.outlook.com
Amit Kapila [Fri, 24 Jun 2022 03:07:26 +0000 (08:37 +0530)]
Doc: clarify that tablesync ignores publish operation.
This patch documents that the initial data synchronization (tablesync) for
logical replication does not take into account the publication 'publish'
parameter when copying the existing table data.
Author: Peter Smith
Reviewed-by: Shi yu, Euler Taveira, Robert Haas, Amit Kapila
Discussion: https://postgr.es/m/CAHut+PtbfALjFpS2MkrvQ+wWQKByP7CNh9RtFta-r=BHEU3S3w@mail.gmail.com
Peter Eisentraut [Thu, 23 Jun 2022 20:40:52 +0000 (22:40 +0200)]
Fix missing newline at end of message
Michael Paquier [Thu, 23 Jun 2022 07:42:27 +0000 (16:42 +0900)]
Fix typo in pg_publication.c
Author: Peter Smith
Discussion: https://postgr.es/m/CAHut+PuV2XXjC4spHXy_EOhpD6MDrmmDMWnVJLYpd1_P=2+mJw@mail.gmail.com
Peter Eisentraut [Thu, 23 Jun 2022 06:59:27 +0000 (08:59 +0200)]
PL/Tcl: Don't link with -lc explicitly
It has been reported that PL/Tcl built on macOS with GCC >=11 crashes.
The reason is that there is a hash_search() function in the operating
system's libraries, and that ends up being called instead of the one
in postgres. This has something to do with how the linker resolves
references between the various possibilities it has been given, and
somehow something changed that it is now picking that one in this
configuration.
We found that removing the -lc from the link command line fixes this
problem. The -lc was introduced a long time ago in commit
e3909672f12e0ddf3e202b824fda068ad2195ef2, and we think the reasons
might be obsolete, so we decided that we'll try to just remove it and
see if any problems arise.
Discussion: https://www.postgresql.org/message-id/flat/
a78c847a-4f79-9286-be99-
e819e9e4139e%40enterprisedb.com
Amit Kapila [Thu, 23 Jun 2022 03:53:46 +0000 (09:23 +0530)]
Fix memory leak due to LogicalRepRelMapEntry.attrmap.
When rebuilding the relation mapping on subscribers, we were not releasing
the attribute mapping's memory which was no longer required.
The attribute mapping used in logical tuple conversion was refactored in
PG13 (by commit
e1551f96e6) but we forgot to update the related code that
frees the attribute map.
Author: Hou Zhijie
Reviewed-by: Amit Langote, Amit Kapila, Shi yu
Backpatch-through: 10, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
Michael Paquier [Thu, 23 Jun 2022 01:49:20 +0000 (10:49 +0900)]
Fix two issues with HEADER MATCH in COPY
072132f0 used the attnum offset to access the raw_fields array when
checking that the attribute names of the header and of the relation
match, leading to incorrect results or even crashes if the attribute
numbers of a relation are changed, like on a dropped attribute. This
fixes the logic to use the correct attribute names for the header
matching requirements.
Also, this commit disallows HEADER MATCH in COPY TO as there is no
validation that can be done in this case.
The tests are expanded for HEADER MATCH with COPY FROM and dropped
columns, with cases where a relation has a dropped and re-added column,
as well as a reduced set of columns.
Author: Julien Rouhaud
Reviewed-by: Peter Eisentraut, Michael Paquier
Discussion: https://postgr.es/m/
20220607154744.vvmitnqhyxrne5ms@jrouhaud
Andres Freund [Wed, 22 Jun 2022 23:50:14 +0000 (16:50 -0700)]
pgstat: Mention pgstat_replslot.c in pgstat.c.
Oversight, by me, in commit
5891c7a8ed8.
Author: "Drouvot, Bertrand"
Discussion: https://postgr.es/m/bd58e027-6598-57a2-679b-d576d17bfaa9@amazon.com
Bruce Momjian [Wed, 22 Jun 2022 20:59:54 +0000 (16:59 -0400)]
doc: improve wording of plpgsql RAISE format text
Reported-by: [email protected]
Discussion: https://postgr.es/m/
165455351426.573551.
7050474465030525109@wrigleys.postgresql.org
Backpatch-through: 10
Bruce Momjian [Wed, 22 Jun 2022 18:33:26 +0000 (14:33 -0400)]
doc: clarify wording about phantom reads
Reported-by: [email protected]
Discussion: https://postgr.es/m/
165222922369.669.
10475917322916060899@wrigleys.postgresql.org
Backpatch-through: 10
Robert Haas [Wed, 22 Jun 2022 17:11:49 +0000 (13:11 -0400)]
amcheck: Fix incorrect use of VARATT_IS_COMPRESSED.
The macro is being applied to a TOAST pointer, not a varlena header.
Therefore the use of VARATT_IS_COMPRESSED() is wrong. We can check
VARATT_EXTERNAL_IS_COMPRESSED(), but then we don't need the length
check that follows.
Report and fix by Kyotaro Horiguchi.
Discussion: http://postgr.es/m/
20220517.162719.
1671558681467343711[email protected]
Peter Eisentraut [Wed, 22 Jun 2022 12:24:48 +0000 (14:24 +0200)]
doc: Clean up title case use
Tom Lane [Tue, 21 Jun 2022 16:04:11 +0000 (12:04 -0400)]
Simplify tab completion of extension versions.
Second thoughts about
9cd43f6cb: given that we're staying bug-compatible
with the old behavior of using double not single quotes for extension
versions, we can simplify this completion code by pretending that
extension versions *are* identifiers, and not using VERBATIM. Then
_complete_from_query() will think that the query results are identifiers
in need of quoting, and we end up with the same behavior as before.
This doesn't work for Query_for_list_of_available_extension_versions_with_TO,
but let's just drop that: there is no other place where we handle
multi-keyword phrases that way, and it doesn't seem very desirable here
either. Handle completion of "UPDATE TO" in our more usual pattern.
Discussion: https://postgr.es/m/CAMkU=1yV+egSYrzWvbDY8VZ6bKEMrKbzxr-HTuiHi+wDgSUMgA@mail.gmail.com
Amit Kapila [Tue, 21 Jun 2022 10:09:35 +0000 (15:39 +0530)]
Fix stale values in partition map entries on subscribers.
We build the partition map entries on subscribers while applying the
changes for update/delete on partitions. The component relation in each
entry is closed after its use so we need to update it on successive use of
cache entries.
This problem was there since the original commit
f1ac27bfda that
introduced this code but we didn't notice it till the recent commit
26b3455afa started to use the component relation of partition map cache
entry.
Reported-by: Tom Lane, as per buildfarm
Author: Amit Langote, Hou Zhijie
Reviewed-by: Amit Kapila, Shi Yu
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
Peter Eisentraut [Tue, 21 Jun 2022 09:21:04 +0000 (11:21 +0200)]
doc: Make some synopsis punctuation consistent
Amit Kapila [Tue, 21 Jun 2022 02:37:43 +0000 (08:07 +0530)]
Fix partition table's REPLICA IDENTITY checking on the subscriber.
In logical replication, we will check if the target table on the
subscriber is updatable by comparing the replica identity of the table on
the publisher with the table on the subscriber. When the target table is a
partitioned table, we only check its replica identity but not for the
partition tables. This leads to assertion failure while applying changes
for update/delete as we expect those to succeed only when the
corresponding partition table has a primary key or has a replica
identity defined.
Fix it by checking the replica identity of the partition table while
applying changes.
Reported-by: Shi Yu
Author: Shi Yu, Hou Zhijie
Reviewed-by: Amit Langote, Amit Kapila
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
Peter Eisentraut [Mon, 20 Jun 2022 12:33:41 +0000 (14:33 +0200)]
Fix file references inside some SGML comments
In some cases, the comments mentioning their own file or another file
were not correct.
Author: Josh Soref
Discussion: https://www.postgresql.org/message-id/flat/CACZqfqCyhE-voJUrUkc3GQuDakfJKx1ViiCdY7B8tQwyL6727g%40mail.gmail.com
Bruce Momjian [Sun, 19 Jun 2022 22:05:27 +0000 (18:05 -0400)]
relnotes: simplify wording of pg_basebackup compression item
Peter Eisentraut [Sun, 19 Jun 2022 15:39:50 +0000 (17:39 +0200)]
Message and documentation refinements
Tom Lane [Sat, 18 Jun 2022 23:45:38 +0000 (19:45 -0400)]
Fix busted tab completion of extension versions.
In
02b8048ba I (tgl) got rid of the need for most tab-completion queries
to return pre-quoted identifiers. But I over-hastily removed the
quote_ident call from Query_for_list_of_available_extension_versions*
too; those still need it, because what is returned isn't an identifier
at all and will (almost?) always need quoting.
Arguably we should use quote_literal here instead. But quote_ident
works too and people may be used to that behavior, so stick with it.
In passing, fix inconsistent omission of schema-qualification in
Query_for_list_of_encodings. That's not a security issue per our
current guidelines, but it ought to be like the rest.
Jeff Janes
Discussion: https://postgr.es/m/CAMkU=1yV+egSYrzWvbDY8VZ6bKEMrKbzxr-HTuiHi+wDgSUMgA@mail.gmail.com
Michael Paquier [Fri, 17 Jun 2022 00:03:07 +0000 (09:03 +0900)]
doc: Do s/int/integer/ to describe the type of some GUC parameters
Three parameters have been using "int" rather than "integer" to describe
their type:
auth_delay.milliseconds
max_logical_replication_workers
pg_prewarm.autoprewarm_interval
This is inconsistent with any other integer GUCs listed in the docs
(148, as far as I can see).
Author: Peter Smith
Discussion: https://postgr.es/m/CAHut+Pv6X5T-veN2abUDUvBxZm+SSm-9otfi3LZPGyOc6u6hiA@mail.gmail.com
Tomas Vondra [Thu, 16 Jun 2022 13:02:48 +0000 (15:02 +0200)]
Revert changes in HOT handling of BRIN indexes
This reverts commits
5753d4ee32 and
fe60b67250 that modified HOT to
ignore BRIN indexes. The commit message for
5753d4ee32 claims that:
When determining whether an index update may be skipped by using
HOT, we can ignore attributes indexed only by BRIN indexes. There
are no index pointers to individual tuples in BRIN, and the page
range summary will be updated anyway as it relies on visibility
info.
This is partially incorrect - it's true BRIN indexes don't point to
individual tuples, so HOT chains are not an issue, but the visibitlity
info is not sufficient to keep the index up to date. This can easily
result in corrupted indexes, as demonstrated in the hackers thread.
This does not mean relaxing the HOT restrictions for BRIN is a lost
cause, but it needs to handle the two aspects (allowing HOT chains and
updating the page range summaries) as separate. But that requires a
major changes, and it's too late for that in the current dev cycle.
Reported-by: Tomas Vondra
Discussion: https://postgr.es/m/
05ebcb44-f383-86e3-4f31-
0a97a55634cf@enterprisedb.com
Michael Paquier [Thu, 16 Jun 2022 08:21:04 +0000 (17:21 +0900)]
Fix comment in regression tests for large objects
The values assigned to INV_WRITE and INV_READ were reversed in the
tests, which would be confusing when writing tests specific to read or
write operations on LOs.
Author: Yugo Nagata
Discussion: https://postgr.es/m/
20220527153028.
61a4608f66abcd026fd3806f@sraoss.co.jp
Amit Kapila [Thu, 16 Jun 2022 03:15:07 +0000 (08:45 +0530)]
Fix data inconsistency between publisher and subscriber.
We were not updating the partition map cache in the subscriber even when
the corresponding remote rel is changed. Due to this data was getting
incorrectly replicated for partition tables after the publisher has
changed the table schema.
Fix it by resetting the required entries in the partition map cache after
receiving a new relation mapping from the publisher.
Reported-by: Shi Yu
Author: Shi Yu, Hou Zhijie
Reviewed-by: Amit Langote, Amit Kapila
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
Alvaro Herrera [Wed, 15 Jun 2022 14:54:38 +0000 (16:54 +0200)]
Link to MVCC docs in MERGE docs
In addition, this moves the new paragraph in the MVCC page upwards, for
a more consistent flow; some minor markup mistakes, style issues and
typos are fixed too.
Per comments from Justin Pryzby.
Discussion: https://postgr.es/m/
20220511163350[email protected]