Tom Lane [Mon, 3 Oct 2022 19:07:10 +0000 (15:07 -0400)]
Fix psql's behavior with \g for a multiple-command string.
The pre-v15 behavior was to discard all but the last result,
but with the new behavior of printing all results by default,
we will send each such result to the \g file. However,
we're still opening and closing the \g file for each result,
so you lose all but the last result anyway. Move the output-file
state up to ExecQueryAndProcessResults so that we open/close the
\g file only once per command string.
To support this without changing other behavior, we must
adjust PrintQueryResult to have separate FILE * arguments
for query and status output (since status output has never
gone to the \g file). That in turn makes it a good idea
to push the responsibility for fflush'ing output down to
PrintQueryTuples and PrintQueryStatus.
Also fix an infinite loop if COPY IN/OUT is attempted in \watch.
We used to reject that, but that error exit path got broken
somewhere along the line in v15. There seems no real reason
to reject it anyway as the code now stands, so just remove
the error exit and make sure that COPY OUT data goes to the
right place.
Also remove PrintQueryResult's unused is_watch parameter,
and make some other cosmetic cleanups (adjust obsolete
comments, break some overly-long lines).
Daniel Vérité and Tom Lane
Discussion: https://postgr.es/m/
4333844c-2244-4d6e-a49a-
1d483fbe304f@manitou-mail.org
Tom Lane [Mon, 3 Oct 2022 15:06:33 +0000 (11:06 -0400)]
Doc: update v15 release notes.
Tom Lane [Mon, 3 Oct 2022 14:56:16 +0000 (10:56 -0400)]
Revert "Optimize order of GROUP BY keys".
This reverts commit
db0d67db2401eb6238ccc04c6407a4fd4f985832 and
several follow-on fixes. The idea of making a cost-based choice
of the order of the sorting columns is not fundamentally unsound,
but it requires cost information and data statistics that we don't
really have. For example, relying on procost to distinguish the
relative costs of different sort comparators is pretty pointless
so long as most such comparator functions are labeled with cost 1.0.
Moreover, estimating the number of comparisons done by Quicksort
requires more than just an estimate of the number of distinct values
in the input: you also need some idea of the sizes of the larger
groups, if you want an estimate that's good to better than a factor of
three or so. That's data that's often unknown or not very reliable.
Worse, to arrive at estimates of the number of calls made to the
lower-order-column comparison functions, the code needs to make
estimates of the numbers of distinct values of multiple columns,
which are necessarily even less trustworthy than per-column stats.
Even if all the inputs are perfectly reliable, the cost algorithm
as-implemented cannot offer useful information about how to order
sorting columns beyond the point at which the average group size
is estimated to drop to 1.
Close inspection of the code added by
db0d67db2 shows that there
are also multiple small bugs. These could have been fixed, but
there's not much point if we don't trust the estimates to be
accurate in-principle.
Finally, the changes in cost_sort's behavior made for very large
changes (often a factor of 2 or so) in the cost estimates for all
sorting operations, not only those for multi-column GROUP BY.
That naturally changes plan choices in many situations, and there's
precious little evidence to show that the changes are for the better.
Given the above doubts about whether the new estimates are really
trustworthy, it's hard to summon much confidence that these changes
are better on the average.
Since we're hard up against the release deadline for v15, let's
revert these changes for now. We can always try again later.
Note: in v15, I left T_PathKeyInfo in place in nodes.h even though
it's unreferenced. Removing it would be an ABI break, and it seems
a bit late in the release cycle for that.
Discussion: https://postgr.es/m/TYAPR01MB586665EB5FB2C3807E893941F5579@TYAPR01MB5866.jpnprd01.prod.outlook.com
Andres Freund [Sat, 1 Oct 2022 23:55:16 +0000 (16:55 -0700)]
ci: macos: Reduce test concurrency
Test performance regresses noticably when using all cores. This is more
pronounced with meson than with autoconf, presumably because meson will
schedule the "full number" of tests more consistently. 8 seems to work
OK.
Discussion: https://postgr.es/m/
20220927040208[email protected]
Backpatch: 15-, where CI was introduced
Michael Paquier [Sat, 1 Oct 2022 06:28:11 +0000 (15:28 +0900)]
doc: Fix some grammar and typos
This fixes some areas related to logical replication and custom RMGRs.
Author: Ekaterina Kiryanova
Discussion: https://postgr.es/m/
fa4773f1-1396-384a-bcd7-
85b5e013f399@postgrespro.ru
Backpatch-through: 15
Tom Lane [Fri, 30 Sep 2022 23:36:46 +0000 (19:36 -0400)]
Avoid improbable PANIC during heap_update, redux.
Commit
34f581c39 intended to ensure that RelationGetBufferForTuple
would acquire a visibility-map page pin in case the otherBuffer's
all-visible bit had become set since we last had lock on that page.
But I missed a case: when we're extending the relation, VM concerns
were dealt with only in the relatively-less-likely case that we
fail to conditionally lock the otherBuffer. I think I'd believed
that we couldn't need to worry about it if the conditional lock
succeeds, which is true for the target buffer; but the otherBuffer
was unlocked for awhile so its bit might be set anyway. So we need
to do the GetVisibilityMapPins dance, and then also recheck the
page's free space, in both cases.
Per report from Jaime Casanova. Back-patch to v12 as the previous
patch was (although there's still no evidence that the bug is
reachable pre-v14).
Discussion: https://postgr.es/m/
[email protected]
Alvaro Herrera [Fri, 30 Sep 2022 10:53:31 +0000 (12:53 +0200)]
Fix tab-completion after commit
790bf615ddba
I (Álvaro) broke tab-completion for GRANT .. ALL TABLES IN SCHEMA while
removing ALL from the publication syntax for schemas in the
aforementioned commit. I also missed to update a bunch of
tab-completion rules for ALTER/CREATE PUBLICATION that match each
individual piece of ALL TABLES IN SCHEMA. Repair those bugs.
While fixing up that commit, update a couple of outdated comments
related to the same change.
Backpatch to 15.
Author: Shi yu <
[email protected]>
Reviewed-by: Peter Smith <[email protected]>
Discussion: https://postgr.es/m/OSZPR01MB6310FCE8609185A56344EED2FD559@OSZPR01MB6310.jpnprd01.prod.outlook.com
Daniel Gustafsson [Fri, 30 Sep 2022 10:03:48 +0000 (12:03 +0200)]
doc: Fix PQsslAttribute docs for compression
The compression parameter to PQsslAttribute has never returned the
compression method used, it has always returned "on" or "off since
it was added in commit
91fa7b4719ac. Backpatch through v10.
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/
B9EC60EC-F665-47E8-A221-
398C76E382C9@yesql.se
Backpatch-through: v10
Tom Lane [Thu, 29 Sep 2022 21:28:09 +0000 (17:28 -0400)]
Fix bogus behavior of PQsslAttribute(conn, "library").
Commit
ebc8b7d44 intended to change the behavior of
PQsslAttribute(NULL, "library"), but accidentally also changed
what happens with a non-NULL conn pointer. Undo that so that
only the intended behavior change happens. Clarify some
associated documentation.
Per bug #17625 from Heath Lord. Back-patch to v15.
Discussion: https://postgr.es/m/17625-
fc47c78b7d71b534@postgresql.org
Etsuro Fujita [Thu, 29 Sep 2022 07:55:01 +0000 (16:55 +0900)]
Update comment in ExecInsert() regarding batch insertion.
Remove the stale text that is a leftover from an earlier version of the
patch to add support for batch insertion, and adjust the wording in the
remaining text.
Back-patch to v14 where batch insertion came in.
Review and wording adjustment by Tom Lane.
Discussion: https://postgr.es/m/CAPmGK14goatHPHQv2Aeu_UTKqZ%2BBO%2BP%2Bzd3HKv5D%2BdyyfWKDSw%40mail.gmail.com
David Rowley [Wed, 28 Sep 2022 22:43:40 +0000 (11:43 +1300)]
Restrict Datum sort optimization to byval types only
91e9e89dc modified nodeSort.c so that it used datum sorts when the
targetlist of the outer node contained only a single column. That commit
failed to recognise that the Datum returned by tuplesort_getdatum() must
be pfree'd when the type is a byref type. Ronan Dunklau did originally
propose the patch with that restriction, but that, probably through my own
fault, got lost during further development work.
Due to the timing of this report (PG15 RC1 is almost out the door), let's
just restrict the datum sort optimization to apply for byval types only.
We might want to look harder into making this work for byref types in
PG16.
Reported-by: Önder Kalacı
Diagnosis-by: Tom Lane
Discussion: https://postgr.es/m/CACawEhVxe0ufR26UcqtU7GYGRuubq3p6ZWPGXL4cxy_uexpAAQ@mail.gmail.com
Backpatch-through: 15, where
91e9e89dc was introduced.
Bruce Momjian [Wed, 28 Sep 2022 17:14:38 +0000 (13:14 -0400)]
doc: clarify internal behavior of RECURSIVE CTE queries
Reported-by: Tom Lane
Discussion: https://postgr.es/m/
3976627.
1662651004@sss.pgh.pa.us
Backpatch-through: 10
Bruce Momjian [Wed, 28 Sep 2022 17:05:20 +0000 (13:05 -0400)]
revert "warn of SECURITY DEFINER schemas for non-sql_body funcs"
doc revert of commit
1703726488. Change was applied to irrelevant
branches, and was not detailed enough to be helpful in relevant
branches.
Reported-by: Peter Eisentraut, Noah Misch
Discussion: https://postgr.es/m/
a2dc9de4-24fc-3222-87d3-
0def8057d7d8@enterprisedb.com
Backpatch-through: 10
Alvaro Herrera [Wed, 28 Sep 2022 15:14:53 +0000 (17:14 +0200)]
Change some errdetail() to errdetail_internal()
This prevents marking the argument string for translation for gettext,
and it also prevents the given string (which is already translated) from
being translated at runtime.
Also, mark the strings used as arguments to check_rolespec_name for
translation.
Backpatch all the way back as appropriate. None of this is caught by
any tests (necessarily so), so I verified it manually.
Alvaro Herrera [Wed, 28 Sep 2022 11:47:25 +0000 (13:47 +0200)]
Remove publicationcmds.c's expr_allowed_in_node as a function
Its API is quite strange, and since there's only one caller, there's no
reason for it to be a separate function in the first place. Inline it
instead.
Discussion: https://postgr.es/m/
20220927124249[email protected]
Alvaro Herrera [Tue, 27 Sep 2022 12:11:31 +0000 (14:11 +0200)]
Improve some publication-related error messages
While at it, remove an unused queryString parameter from
CheckPubRelationColumnList() and make other minor stylistic changes.
Backpatch to 15.
Reported by Kyotaro Horiguchi <
[email protected]>
Co-authored-by: Hou zj <[email protected]>
Discussion: https://postgr.es/m/
20220926.160426.
454497059203258582[email protected]
Alvaro Herrera [Tue, 27 Sep 2022 08:44:42 +0000 (10:44 +0200)]
Fix pg_stat_statements for MERGE
We weren't jumbling the merge action list, so wildly different commands
would be considered to use the same query ID. Add that, mention it in
the docs, and some test lines.
Backpatch to 15.
Author: Tatsu <
[email protected]>
Reviewed-by: Julien Rouhaud <[email protected]>
Discussion: https://postgr.es/m/
d87e391694db75a038abc3b2597828e8@oss.nttdata.com
Andres Freund [Tue, 27 Sep 2022 03:02:26 +0000 (20:02 -0700)]
ci: Add hint about downloadable logs to README
I (Andres) chose to backpatch this to 15, as it seems better to keep the
README the same.
Author: James Coleman <
[email protected]>
Discussion: https://postgr.es/m/CAAaqYe_7BXDjpk0Ks_eqf1r6LZpC_rfB7kjhb_T3+eC4t6yiGQ@mail.gmail.com
Backpatch: 15-, where CI came in
David Rowley [Mon, 26 Sep 2022 21:57:07 +0000 (10:57 +1300)]
Doc: last minute adjustment to the release notes
The change made in
9d9c02ccd also affects the dense_rank() function.
Mention this in the release notes.
Author: Jonathan S. Katz
Discussion: https://postgr.es/m/
5c6d3f50-e9b5-f62d-d58a-
7b22eb91d8b8@postgresql.org
Tom Lane [Mon, 26 Sep 2022 20:36:49 +0000 (16:36 -0400)]
Stamp 15rc1.
Tom Lane [Mon, 26 Sep 2022 18:32:51 +0000 (14:32 -0400)]
Doc: more tweaking of v15 release notes.
Per suggestions from Justin Pryzby.
Discussion: https://postgr.es/m/
20220925215009[email protected]
Tom Lane [Mon, 26 Sep 2022 18:19:21 +0000 (14:19 -0400)]
Doc: further adjust notes about pg_upgrade_output.d.
I'd misunderstood how it worked in
5f1048881.
Discussion: https://postgr.es/m/
20220925215009[email protected]
Peter Eisentraut [Mon, 26 Sep 2022 11:16:06 +0000 (13:16 +0200)]
Translation updates
Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash:
0a336c1e07ac371cf445a0cecac6b27720da228c
Peter Eisentraut [Mon, 26 Sep 2022 10:57:12 +0000 (12:57 +0200)]
Update list of acknowledgments in release notes
current through
15113bfb467a84688744b57b74a14550878d0224
Amit Kapila [Mon, 26 Sep 2022 03:56:47 +0000 (09:26 +0530)]
Doc: Remove the use of a duplicate word.
This has been removed in HEAD by commit
a234177906, so doing just backpatch
to 15 where it was introduced in commit
860ea46ba7.
Author: Zhang Mingli
Discussion: https://postgr.es/m/OS0PR01MB57162559C01FE2848C12E8F7944D9@OS0PR01MB5716.jpnprd01.prod.outlook.com
Tom Lane [Sun, 25 Sep 2022 21:10:58 +0000 (17:10 -0400)]
Fix tupdesc lifespan bug with AfterTriggersTableData.storeslot.
Commit
25936fd46 adjusted things so that the "storeslot" we use
for remapping trigger tuples would have adequate lifespan, but it
neglected to consider the lifespan of the tuple descriptor that
the slot depends on. It turns out that in at least some cases, the
tupdesc we are passing is a refcounted tupdesc, and the refcount for
the slot's reference can get assigned to a resource owner having
different lifespan than the slot does. That leads to an error like
"tupdesc reference 0x7fdef236a1b8 is not owned by resource owner
SubTransaction". Worse, because of a second oversight in the same
commit, we'd try to free the same tupdesc refcount again while
cleaning up after that error, leading to recursive errors and an
"ERRORDATA_STACK_SIZE exceeded" PANIC.
To fix the initial problem, let's just make a non-refcounted copy
of the tupdesc we're supposed to use. That seems likely to guard
against additional problems, since there's no strong reason for
this code to assume that what it's given is a refcounted tupdesc;
in which case there's an independent hazard of the tupdesc having
shorter lifespan than the slot does. (I didn't bother trying to
free said copy, since it should go away anyway when the (sub)
transaction context is cleaned up.)
The other issue can be fixed by making the code added to
AfterTriggerFreeQuery work like the rest of that function, ie be
sure that it doesn't try to free the same slot twice in the event
of recursive error cleanup.
While here, also clean up minor stylistic issues in the test case
added by
25936fd46: don't use "create or replace function", as any
name collision within the tests is likely to have ill effects
that that won't mask; and don't use function names as generic as
trigger_function1, especially if you're not going to drop them
at the end of the test stanza.
Per bug #17607 from Thomas Mc Kay. Back-patch to v12, as the
previous fix was.
Discussion: https://postgr.es/m/17607-
bd8ccc81226f7f80@postgresql.org
Tom Lane [Sun, 25 Sep 2022 17:10:10 +0000 (13:10 -0400)]
Avoid loss of code coverage with unlogged-index test cases.
Commit
4fb5c794e intended to add coverage of some ambuildempty
methods that were not getting reached, without removing any
test coverage. However, by changing a temp table to unlogged
it managed to negate the intent of
4c51a2d1e, which means that
we didn't have reliable test coverage of ginvacuum.c anymore.
As things stand, much of that file might or might not get reached
depending on timing, which seems pretty undesirable.
Although this is only clearly broken for the GIN test, it seems
best to revert
4fb5c794e altogether and instead add bespoke test
cases covering unlogged indexes for these four AMs. We don't
need to do very much with them, so the extra tests are cheap.
(Note that btree, hash, and bloom already have similar test cases,
so they need no additional work.)
We can also undo
dec8ad367. Since the testing deficiency that that
hacked around was later fixed by
2f2e24d90, let's intentionally leave
an unlogged table behind to improve test coverage in the modules that
use the regression database for other test purposes. (The case I used
also leaves an unlogged sequence behind.)
Per report from Alex Kozhemyakin. Back-patch to v15 where the
faulty test came in.
Discussion: https://postgr.es/m/
b00c8ee096ee46cd25c183125562a1a7@postgrespro.ru
Alvaro Herrera [Sun, 25 Sep 2022 15:48:03 +0000 (17:48 +0200)]
Add missing source files to pg_waldump/nls.mk
Peter Eisentraut [Sat, 24 Sep 2022 22:38:35 +0000 (18:38 -0400)]
Message style improvements
Peter Eisentraut [Sat, 24 Sep 2022 01:16:08 +0000 (21:16 -0400)]
Improve terminology
Use "prepared transaction" instead of "two-phrase transaction". This
is in line with
c5d67881d343a507269bde124a49df19e0296157.
Tom Lane [Fri, 23 Sep 2022 22:22:33 +0000 (18:22 -0400)]
Doc: make an editorial pass over the v15 release notes.
Rearrange, reword, clarify, fix markup, etc etc.
Also include commit
bd8ac900d.
Tom Lane [Fri, 23 Sep 2022 22:20:11 +0000 (18:20 -0400)]
Doc: minor cleanups.
Improve a couple of things I noticed while working on v15
release notes.
Andres Freund [Fri, 23 Sep 2022 20:00:55 +0000 (13:00 -0700)]
pgstat: Fix transactional stats dropping for indexes
Because index creation does not go through heap_create_with_catalog() we
didn't call pgstat_create_relation(), leading to index stats of a newly
created realtion not getting dropped during rollback. To fix, move the
pgstat_create_relation() to heap_create(), which indexes do use.
Similarly, because dropping an index does not go through
heap_drop_with_catalog(), we didn't drop index stats when the transaction
dropping an index committed. Here there's no convenient common path for
indexes and relations, so index_drop() now calls pgstat_drop_relation().
Add tests for transactional index stats handling.
Author: "Drouvot, Bertrand" <
[email protected]>
Reviewed-by: Andres Freund <[email protected]>
Reviewed-by: Kyotaro Horiguchi <[email protected]>
Discussion: https://postgr.es/m/
51bbf286-2b4a-8998-bd12-
eaae4b765d99@amazon.com
Backpatch: 15-, like
8b1dccd37c71, which introduced the bug
Tom Lane [Fri, 23 Sep 2022 17:59:29 +0000 (13:59 -0400)]
Doc: update v15 release notes through today.
Account for commits since 2022-06-11.
Alvaro Herrera [Fri, 23 Sep 2022 16:21:22 +0000 (18:21 +0200)]
Remove PQsendQuery support in pipeline mode
The extended query protocol implementation I added in commit
acb7e4eb6b1c has bugs when used in pipeline mode. Rather than spend
more time trying to fix it, remove that code and make the function rely
on simple query protocol only, meaning it can no longer be used in
pipeline mode.
Users can easily change their applications to use PQsendQueryParams
instead. We leave PQsendQuery in place for Postgres 14, just in case
somebody is using it and has not hit the mentioned bugs; but we should
recommend that it not be used.
Backpatch to 15.
Per bug report from Gabriele Varrazzo.
Discussion: https://postgr.es/m/CA+mi_8ZGSQNmW6-mk_iSR4JZB_LJ4ww3suOF+1vGNs3MrLsv4g@mail.gmail.com
Alvaro Herrera [Fri, 23 Sep 2022 16:11:48 +0000 (18:11 +0200)]
Stop using PQsendQuery in libpq_pipeline
The "emulation" I wrote for PQsendQuery in pipeline mode to use extended
query protocol, in commit
acb7e4eb6b1c, is problematic. Due to numerous
bugs we'll soon remove it. As a first step and for all branches back to
14, stop using PQsendQuery in libpq_pipeline. Also remove a few test
lines that will no longer be relevant.
Backpatch to 14.
Discussion: https://postgr.es/m/CA+mi_8ZGSQNmW6-mk_iSR4JZB_LJ4ww3suOF+1vGNs3MrLsv4g@mail.gmail.com
Tom Lane [Fri, 23 Sep 2022 15:24:12 +0000 (11:24 -0400)]
Doc: add list of major features to the v15 release notes.
Jonathan Katz (word-smithed a bit by me)
Discussion: https://postgr.es/m/
a6661e2c-72e0-b4bd-9301-
9225bdddda4c@postgresql.org
Amit Kapila [Fri, 23 Sep 2022 02:38:24 +0000 (08:08 +0530)]
Allow publications with schema and table of the same schema.
We previously thought that allowing such cases can confuse users when they
specify DROP TABLES IN SCHEMA but that doesn't seem to be the case based
on discussion. This helps to uplift the restriction during
ALTER TABLE ... SET SCHEMA which used to ensure that we couldn't end up
with a publication having both a schema and the same schema's table.
To allow this, we need to forbid having any schema on a publication if
column lists on a table are specified (and vice versa). This is because
otherwise we still need a restriction during ALTER TABLE ... SET SCHEMA to
forbid cases where it could lead to a publication having both a schema and
the same schema's table with column list.
Based on suggestions by Peter Eisentraut.
Author: Hou Zhijie and Vignesh C
Reviewed-By: Peter Smith, Amit Kapila
Backpatch-through: 15, where it was introduced
Discussion: https://postgr.es/m/
2729c9e2-9aac-8cda-f2f4-
34f2bcc18f4e@enterprisedb.com
Jeff Davis [Thu, 22 Sep 2022 17:58:49 +0000 (10:58 -0700)]
Fix race condition where heap_delete() fails to pin VM page.
Similar to
5f12bc94dc, the code must re-check PageIsAllVisible() after
buffer lock is re-acquired. Backpatching to the same version, 12.
Discussion: https://postgr.es/m/CAEP4nAw9jYQDKd_5Y+-s2E4YiUJq1vqiikFjYGpLShtp-K3gag@mail.gmail.com
Reported-by: Robins Tharakan
Reviewed-by: Robins Tharakan
Backpatch-through: 12
Alvaro Herrera [Thu, 22 Sep 2022 17:02:25 +0000 (19:02 +0200)]
Remove ALL keyword from TABLES IN SCHEMA for publication
This may be a bit too subtle, but removing that word from there makes
this clause no longer a perfect parallel of the GRANT variant "ALL
TABLES IN SCHEMA": indeed, for publications what we record is the schema
itself, not the tables therein, which means that any tables added to the
schema in the future are also published. This is completely different
to what GRANT does, which is affect only the tables that exist when the
command is executed.
There isn't resounding support for this change, but there are a few
positive votes and no opposition. Because the time to 15 RC1 is very
short, let's get this out now.
Backpatch to 15.
Discussion: https://postgr.es/m/
2729c9e2-9aac-8cda-f2f4-
34f2bcc18f4e
Peter Eisentraut [Sat, 17 Sep 2022 09:34:20 +0000 (11:34 +0200)]
Restore archive_command documentation
Commit
5ef1eefd76f404ddc59b885d50340e602b70f05f, which added
archive_library, purged most mentions of archive_command from the
documentation. This is inappropriate, since archive_command is still
a feature in use and users will want to see information about it.
This restores all the removed mentions and rephrases things so that
archive_command and archive_library are presented as alternatives of
each other.
Reviewed-by: Nathan Bossart <[email protected]>
Discussion: https://www.postgresql.org/message-id/
9366d634-a917-85a9-4991-
b2a4859edaf9@enterprisedb.com
Michael Paquier [Thu, 22 Sep 2022 11:03:30 +0000 (20:03 +0900)]
Use min/max bounds defined by Zstd for compression level
The bounds hardcoded in compression.c since
ffd5365 (minimum at 1 and
maximum at 22) do not match the reality of what zstd is able to
handle, these values being available via ZSTD_maxCLevel() and
ZSTD_minCLevel() at run-time. The maximum of 22 is actually correct
in recent versions, but the minimum was not as the library can go down
to -131720 by design. This commit changes the code to use the run-time
values in the code instead of some hardcoded ones.
Zstd seems to assume that these bounds could change in the future, and
Postgres will be able to adapt automatically to such changes thanks to
what's being done in this commit.
Reported-by: Justin Prysby
Discussion: https://postgr.es/m/
20220922033716[email protected]
Backpatch-through: 15
Etsuro Fujita [Thu, 22 Sep 2022 06:55:01 +0000 (15:55 +0900)]
Fix thinko in comment.
This comment has been wrong since its introduction in commit
0d5f05cde;
backpatch to v12 where that came in.
Discussion: https://postgr.es/m/CAPmGK14VGf-xQjGQN4o1QyAbXAaxugU5%3DqfcmTDh1iufUDnV_w%40mail.gmail.com
Michael Paquier [Thu, 22 Sep 2022 05:25:12 +0000 (14:25 +0900)]
Clear ps display of startup process at the end of recovery
If the ps display is not cleared at this point, the process could
continue displaying "recovering NNN" even if handling end-of-recovery
steps.
df9274a has tackled that by providing some information with the
end-of-recovery checkpoint but
7ff23c6 has nullified the effect of the
first commit.
Per a suggestion from Justin, just clear the ps display when we are done
with recovery, so as no incorrect information is displayed. This may
get extended in the future, but for now restore the pre-
7ff23c6
behavior.
Author: Justin Prysby
Discussion: https://postgr.es/m/
20220913223954[email protected]
Backpatch-through: 15
Fujii Masao [Thu, 22 Sep 2022 03:54:26 +0000 (12:54 +0900)]
docs: Fix snapshot name in SET TRANSACTION docs.
Commit
6c2003f8a1 changed the snapshot names mentioned in
SET TRANSACTION docs, however, there was one place that
the commit missed updating the name.
Back-patch to all supported versions.
Author: Japin Li
Reviewed-by: Fujii Masao
Discussion: https://postgr.es/m/MEYP282MB1669BD4280044501165F8B07B64F9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Fujii Masao [Thu, 22 Sep 2022 00:25:29 +0000 (09:25 +0900)]
psql: Improve tab-completion for MERGE.
Commit
7103ebb7aa added the tab-completion for MERGE accidentally
in the middle of that for LOCK TABLE. This commit fixes this issue.
This also adds some tab-completion for MERGE.
Back-patch to v15 where MERGE was introduced.
Author: Kotaro Kawamoto, Fujii Masao
Reviewed-by: Shinya Kato, Álvaro Herrera
Discussion: https://postgr.es/m/
9f1ad2a87a58cd5e7d64f3993130958d@oss.nttdata.com
Andres Freund [Thu, 22 Sep 2022 00:15:54 +0000 (17:15 -0700)]
ci: windows: set error mode to not include SEM_NOGPFAULTERRORBOX
Cirrus defaults to SetErrorMode(SEM_NOGPFAULTERRORBOX | ...). That prevents
crash reporting from working unless binaries do SetErrorMode()
themselves. Furthermore, it appears that either python or, more likely, the C
runtime has a bug where SEM_NOGPFAULTERRORBOX can very occasionally *trigger*
a crash on process exit - which is hard to debug, given that it explicitly
prevents crash dumps from working...
Discussion: https://postgr.es/m/
20220909235836.lz3igxtkcjb5w7zb%40awork3.anarazel.de
Backpatch: 15-, where CI was added
Thomas Munro [Wed, 21 Sep 2022 23:35:46 +0000 (11:35 +1200)]
ci: Increase requested memory size.
CI builds recently started failing with:
"Memory size for 4.0 vCPU instance should be between 3840MiB and
26624MiB, while 2048MiB is requested."
Ok then, let's ask for 4G instead of 2G.
This may be due to a change in the type of instance used to work around
an outage, per:
https://twitter.com/cirrus_labs/status/
1572657320093712384
Peter Eisentraut [Wed, 21 Sep 2022 14:28:40 +0000 (10:28 -0400)]
Improve ICU option handling in CREATE DATABASE
We check that the ICU locale is only specified if the ICU locale
provider is selected. But we did that too early. We need to wait
until we load the settings of the template database, since that could
also set what the locale provider is.
Reported-by: Marina Polyakova <[email protected]>
Discussion: https://www.postgresql.org/message-id/
9ba4cd1ea6ed6b7b15c0ff15e6f540cd@postgrespro.ru
Peter Eisentraut [Wed, 21 Sep 2022 13:34:22 +0000 (09:34 -0400)]
Tighten pg_get_object_address argument checking
For publication schemas (OBJECT_PUBLICATION_NAMESPACE) and user
mappings (OBJECT_USER_MAPPING), pg_get_object_address() checked the
array length of the second argument, but not of the first argument.
If the first argument was too long, it would just silently ignore
everything but the first argument. Fix that by checking the length of
the first argument as well.
Reviewed-by: Amit Kapila <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
caaef70b-a874-1088-92ef-
5ac38269c33b%40enterprisedb.com
Alvaro Herrera [Wed, 21 Sep 2022 10:29:38 +0000 (12:29 +0200)]
Improve some GUC description strings
It is not our usual style to use "we" in messages. Also, remove some
noise words. Backpatch to 15.
Noted by Kyotaro Horiguchi.
Discussion: https://postgr.es/m/
20220914.111507.
13049297635620898[email protected]
Tom Lane [Tue, 20 Sep 2022 22:59:53 +0000 (18:59 -0400)]
Disable -Wdeprecated-non-prototype in the back branches.
There doesn't seem to be any good ABI-preserving way to silence
clang 15's -Wdeprecated-non-prototype warnings about our tree-walk
APIs. While we've fixed it properly in HEAD, the only way to not
see hundreds of these in the back branches is to disable the
warnings. We're not going to do anything about them, so we might
as well disable them.
I noticed that we also get some of these warnings about fmgr.c's
support for V0 function call convention, in branches before v10
where we removed that. That's another area we aren't going to
change, so turning off the warning seems fine for that too.
Per project policy, this is a candidate for back-patching into
out-of-support branches: it suppresses annoying compiler warnings
but changes no behavior. Hence, back-patch all the way to 9.2.
Discussion: https://postgr.es/m/CA+hUKGKpHPDTv67Y+s6yiC8KH5OXeDg6a-twWo_xznKTcG0kSA@mail.gmail.com
Tom Lane [Tue, 20 Sep 2022 16:04:37 +0000 (12:04 -0400)]
Suppress variable-set-but-not-used warnings from clang 15.
clang 15+ will issue a set-but-not-used warning when the only
use of a variable is in autoincrements (e.g., "foo++;").
That's perfectly sensible, but it detects a few more cases that
we'd not noticed before. Silence the warnings with our usual
methods, such as PG_USED_FOR_ASSERTS_ONLY, or in one case by
actually removing a useless variable.
One thing that we can't nicely get rid of is that with %pure-parser,
Bison emits "yynerrs" as a local variable that falls foul of this
warning. To silence those, I inserted "(void) yynerrs;" in the
top-level productions of affected grammars.
Per recently-established project policy, this is a candidate
for back-patching into out-of-support branches: it suppresses
annoying compiler warnings but changes no behavior. Hence,
back-patch to 9.5, which is as far as these patches go without
issues. (A preliminary check shows that the prior branches
need some other set-but-not-used cleanups too, so I'll leave
them for another day.)
Discussion: https://postgr.es/m/514615.
1663615243@sss.pgh.pa.us
Alvaro Herrera [Tue, 20 Sep 2022 10:38:48 +0000 (12:38 +0200)]
Disable autovacuum in MERGE test script
Otherwise, it can fail given sufficient bad luck.
Backpatch to 15.
Discussion: https://postgr.es/m/537759.
1663625579@sss.pgh.pa.us
Michael Paquier [Tue, 20 Sep 2022 10:28:43 +0000 (19:28 +0900)]
doc: Fix parameter name for pg_create_logical_replication_slot()
The parameter controlling if two-phase transactions can be decoded was
named "two_phase" in the documentation while its procedure defines
"twophase".
Author: Florin Irion
Discussion: https://postgr.es/m/
5eeabd10-1aff-ea61-f92d-
9fa0d9a7e207@gmail.com
Backpatch-through: 14
Michael Paquier [Tue, 20 Sep 2022 09:13:39 +0000 (18:13 +0900)]
Fix incorrect variable types for origin IDs in decode.c
These variables used XLogRecPtr instead of RepOriginId.
Author: Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoBm-vNyBSXGp4bmJGvhr=S-EGc5q1dtV70cFTcJvLhC=Q@mail.gmail.com
Backpatch-through: 14
David Rowley [Mon, 19 Sep 2022 22:04:13 +0000 (10:04 +1200)]
Fix misleading comment for get_cheapest_group_keys_order
The header comment for get_cheapest_group_keys_order() claimed that the
output arguments were set to a newly allocated list which may be freed by
the calling function, however, this was not always true as the function
would simply leave these arguments untouched in some cases.
This tripped me up when working on
1349d2790 as I mistakenly assumed I
could perform a list_concat with the output parameters. That turned out
bad due to list_concat modifying the original input lists.
In passing, make it more clear that the number of distinct values is
important to reduce tiebreaks during sorts. Also, explain what the
n_preordered parameter means.
Backpatch-through: 15, where get_cheapest_group_keys_order was introduced.
David Rowley [Mon, 19 Sep 2022 21:15:04 +0000 (09:15 +1200)]
Fix out-dated comment in preprocess_groupclause()
The comment claimed we don't consider other orders of the GROUP BY clause,
but this is no longer true as of
db0d67db2.
Discussion: https://postgr.es/m/CAApHDvq65=9Ro+hLX1i9ugWEiNDvHrBibAO7ARcTnf38_JE+UQ@mail.gmail.com
Backpatch-through: 15, where
db0d67db2 was introduced.
Peter Eisentraut [Mon, 19 Sep 2022 19:22:43 +0000 (15:22 -0400)]
Fix icu tests with C locale
Similar to
1e08576691bf1a25c0e28745e5e800c44f2a1c76, but for the icu
test suite.
Reported-by: Christoph Berg <[email protected]>
Discussion: https://www.postgresql.org/message-id/
[email protected]
Tom Lane [Mon, 19 Sep 2022 16:16:02 +0000 (12:16 -0400)]
Future-proof the recursion inside ExecShutdownNode().
The API contract for planstate_tree_walker() callbacks is that they
take a PlanState pointer and a context pointer. Somebody figured
they could save a couple lines of code by ignoring that, and passing
ExecShutdownNode itself as the walker even though it has but one
argument. Somewhat remarkably, we've gotten away with that so far.
However, it seems clear that the upcoming C2x standard means to
forbid such cases, and compilers that actively break such code
likely won't be far behind. So spend the extra few lines of code
to do it honestly with a separate walker function.
In HEAD, we might as well go further and remove ExecShutdownNode's
useless return value. I left that as-is in back branches though,
to forestall complaints about ABI breakage.
Back-patch, with the thought that this might become of practical
importance before our stable branches are all out of service.
It doesn't seem to be fixing any live bug on any currently known
platform, however.
Discussion: https://postgr.es/m/208054.
1663534665@sss.pgh.pa.us
Peter Eisentraut [Mon, 19 Sep 2022 10:45:23 +0000 (06:45 -0400)]
Improve GUC description punctuation
partial backpatch of
0b039e3a8489c08ec61b4d40382047c389af91ad
Peter Eisentraut [Mon, 19 Sep 2022 10:35:01 +0000 (06:35 -0400)]
Add missing serial commas
Peter Geoghegan [Sat, 17 Sep 2022 23:54:16 +0000 (16:54 -0700)]
Make check_usermap() parameter names consistent.
The function has a bool argument named "case_insensitive", but that was
spelled "case_sensitive" in the declaration. Make them consistent now
to avoid confusion in the future.
Author: Peter Geoghegan <
[email protected]>
Reviewed-By: Michael Paquiër <[email protected]>
Discussion: https://postgr.es/m/CAH2-WznJt9CMM9KJTMjJh_zbL5hD9oX44qdJ4aqZtjFi-zA3Tg@mail.gmail.com
Backpatch: 10-
Andres Freund [Sat, 17 Sep 2022 16:21:59 +0000 (09:21 -0700)]
Include c.h instead of postgres.h in src/port/*p{read,write}*.c
Frontend code shouldn't include postgres.h. Some files in src/port/ need to
include postgres.h/postgres_fe.h, but these files don't.
Discussion: https://postgr.es/m/
20220915022626[email protected]
Backpatch: 12-, where
3fd2a7932ef introduced (some) of these files
Andres Freund [Fri, 16 Sep 2022 21:08:40 +0000 (14:08 -0700)]
pgstat: Create memory contexts below TopMemoryContext
So far they were created below CacheMemoryContext. However, that's not
guaranteed to exist in all situations, leading to memory contexts created as
top-level contexts. There isn't actually a good reason anymore to create them
below CacheMemoryContext, so just creating them below TopMemoryContext seems
the best approach.
Reported-by: Reid Thompson <[email protected]>
Reviewed-by: Kyotaro Horiguchi <[email protected]>
Reviewed-by: Andres Freund <[email protected]>
Author: "Drouvot, Bertrand" <
[email protected]>
Discussion: https://postgr.es/m/
b948b729-42fe-f88c-2f4a-
0e65d84c049b@amazon.com
Backpatch: 15-
Peter Eisentraut [Sat, 17 Sep 2022 06:10:59 +0000 (08:10 +0200)]
Message style improvements
Andres Freund [Fri, 16 Sep 2022 17:07:12 +0000 (10:07 -0700)]
Fix race condition in stats.sql added in
5264add7847
Very occasionally the stats test failed due to the number of sessions not
being updated yet. Likely this requires that there is contention on the
database's stats entry. Solve this by forcing pending stats to be flushed
before fetching the stats.
I verified that there are no other test failures after making
pgstat_report_stat() only flush stats when force = true.
Per message from Tom Lane and buildfarm member crake.
Discussion: https://postgr.es/m/
3428246.
1663271992@sss.pgh.pa.us
Backpatch: 15-, where
5264add7847 added the test
Tom Lane [Fri, 16 Sep 2022 17:23:01 +0000 (13:23 -0400)]
Improve plpgsql's ability to handle arguments declared as RECORD.
Treat arguments declared as RECORD as if that were a polymorphic type
(which it is, sort of), in that we substitute the actual argument type
while forming the function cache lookup key. This allows the specific
composite type to be known in some cases where it was not before,
at the cost of making a separate function cache entry for each named
composite type that's passed to the function during a session. The
particular symptom discussed in bug #17610 could be solved in other
more-efficient ways, but only at the cost of considerable development
work, and there are other cases where we'd still fail without this.
Per bug #17610 from Martin Jurča. Back-patch to v11 where we first
allowed plpgsql functions to be declared as taking type RECORD.
Discussion: https://postgr.es/m/17610-
fb1eef75bf6c2364@postgresql.org
Peter Eisentraut [Fri, 16 Sep 2022 14:37:53 +0000 (16:37 +0200)]
Message wording improvements
Peter Eisentraut [Fri, 16 Sep 2022 09:10:41 +0000 (11:10 +0200)]
Fix createdb tests for C locale
If the createdb tests run under the C locale, the database cluster
will be initialized with encoding SQL_ASCII. With the checks added in
c7db01e325a530ec38ec7ba57cd3ed32e123e33c, this will cause several
ICU-related tests to fail because SQL_ASCII is not supported by ICU.
To work around that, use initdb option -E UTF8 for those tests to get
past that check.
Peter Eisentraut [Fri, 16 Sep 2022 07:37:54 +0000 (09:37 +0200)]
Don't allow creation of database with ICU locale with unsupported encoding
Check in CREATE DATABASE and initdb that the selected encoding is
supported by ICU. Before, they would pass but users would later get
an error from the server when they tried to use the database.
Also document that initdb sets the encoding to UTF8 by default if the
ICU locale provider is chosen.
Author: Marina Polyakova <
[email protected]>
Reviewed-by: Kyotaro Horiguchi <[email protected]>
Discussion: https://www.postgresql.org/message-id/
6dd6db0984d86a51b7255ba79f111971@postgrespro.ru
Tom Lane [Thu, 15 Sep 2022 21:17:53 +0000 (17:17 -0400)]
Detect format-string mistakes in the libpq_pipeline test module.
I happened to notice that libpq_pipeline's private implementation
of pg_fatal lacked any pg_attribute_printf decoration. Indeed,
adding that turned up a mistake! We'd likely never have noticed
because the error exits in this code are unlikely to get hit,
but still, it's a bug.
We're so used to having the compiler check this stuff for us that
a printf-like function without pg_attribute_printf is a land mine.
I wonder if there is a way to detect such omissions.
Back-patch to v14 where this code came in.
Alvaro Herrera [Thu, 15 Sep 2022 16:04:00 +0000 (18:04 +0200)]
Copy-edit docs for logical replication column lists
There was a excessive structure, leading to somewhat disorganized
presentation of the information. Remove a few tags and reorder
paragraphs to make the text flow more easily. Also, reword some of it
to be more concise.
The bit about column list combination is not modified, other than to
remove an uninteresting (and IMO confusing and wrong) paragraph; I
intend to deal with it differently afterwards.
Backpatch to 15.
Discussion: https://postgr.es/m/
20220913121138[email protected]
Noah Misch [Thu, 15 Sep 2022 13:45:23 +0000 (06:45 -0700)]
Reset InstallXLogFileSegmentActive after walreceiver self-initiated exit.
After commit
cc2c7d65fc27e877c9f407587b0b92d46cd6dd16 added this flag,
failure to reset it caused assertion failures. In non-assert builds, it
made the system fail to achieve the objectives listed in that commit;
chiefly, we might emit a spurious log message. Back-patch to v15, where
that commit first appeared.
Bharath Rupireddy and Kyotaro Horiguchi. Reviewed by Dilip Kumar,
Nathan Bossart and Michael Paquier. Reported by Dilip Kumar.
Discussion: https://postgr.es/m/CAFiTN-sE3ry=ycMPVtC+Djw4Fd7gbUGVv_qqw6qfzp=JLvqT3g@mail.gmail.com
John Naylor [Thu, 15 Sep 2022 04:40:17 +0000 (11:40 +0700)]
Fix grammar in error message
While at it, make ellipses formatting consistent when describing SQL statements.
Ekaterina Kiryanova and Alexander Lakhin
Reviewed by myself and Álvaro Herrera
Discussion: https://www.postgresql.org/message-id/
eed5cec0-a542-53da-6a5e-
7789c6ed9817%40postgrespro.ru
Backpatch only the grammar fix to v15
David Rowley [Wed, 14 Sep 2022 21:41:32 +0000 (09:41 +1200)]
Fix outdated convert_saop_to_hashed_saop comment
In
29f45e299, we added support for optimizing the execution of NOT
IN(values) by using a hash table instead of a linear search over the
array. That commit neglected to update the header comment for
convert_saop_to_hashed_saop() to mention this fact. Here we fix that.
Author: James Coleman
Discussion: https://postgr.es/m/CAAaqYe99NUpAPcxgchGstgM23fmiGjqQPot8627YgkBgNt=BfA@mail.gmail.com
Backpatch-through: 15, where
29f45e299 was added.
Peter Eisentraut [Wed, 14 Sep 2022 20:30:51 +0000 (22:30 +0200)]
Small wording improvements
Alvaro Herrera [Wed, 14 Sep 2022 13:36:21 +0000 (15:36 +0200)]
Remove duplicate initialization
This appears to be a merge mistake in
96ef3237bf74. We could put it
back the way it was before JSON_TABLE and it'd be two lines shorter, but
it's likely that JSON_TABLE will be back and will prefer things this
way. It makes no other difference in practice.
Backpatch to 15.
Reported by Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAr4nOcNQskC4oBEZN4S+4heJ=1ch_ZKOxU+_Ef-FQSf-g@mail.gmail.com
Etsuro Fujita [Wed, 14 Sep 2022 09:45:01 +0000 (18:45 +0900)]
postgres_fdw: Avoid 'variable not found in subplan target list' error.
The tlist of the EvalPlanQual outer plan for a ForeignScan node is
adjusted to produce a tuple whose descriptor matches the scan tuple slot
for the ForeignScan node. But in the case where the outer plan contains
an extra Sort node, if the new tlist contained columns required only for
evaluating PlaceHolderVars or columns required only for evaluating local
conditions, this would cause setrefs.c to fail with the error.
The cause of this is that when creating the outer plan by injecting the
Sort node into an alternative local join plan that could emit such extra
columns as well, we fail to arrange for the outer plan to propagate them
up through the Sort node, causing setrefs.c to fail to match up them in
the new tlist to what is available from the outer plan. Repair.
Per report from Alexander Pyhalov.
Richard Guo and Etsuro Fujita, reviewed by Alexander Pyhalov and Tom Lane.
Backpatch to all supported versions.
Discussion: http://postgr.es/m/
cfb17bf6dfdf876467bd5ef533852d18%40postgrespro.ru
Michael Paquier [Wed, 14 Sep 2022 05:52:26 +0000 (14:52 +0900)]
Fix incorrect value for "strategy" with deflateParams() in walmethods.c
The zlib documentation mentions the values supported for the compression
strategy, but this code has been using a hardcoded value of 0 rather
than Z_DEFAULT_STRATEGY. This commit adjusts the code to use
Z_DEFAULT_STRATEGY.
Backpatch down to where this code has been added to ease the backport of
any future patch touching this area.
Reported-by: Tom Lane
Discussion: https://postgr.es/m/
1400032.
1662217889@sss.pgh.pa.us
Backpatch-through: 10
Peter Eisentraut [Wed, 14 Sep 2022 04:04:24 +0000 (06:04 +0200)]
Expand palloc/pg_malloc API for more type safety
This adds additional variants of palloc, pg_malloc, etc. that
encapsulate common usage patterns and provide more type safety.
Specifically, this adds palloc_object(), palloc_array(), and
repalloc_array(), which take the type name of the object to be
allocated as its first argument and cast the return as a pointer to
that type. There are also palloc0_object() and palloc0_array()
variants for initializing with zero, and pg_malloc_*() variants of all
of the above.
Inspired by the talloc library.
This is backpatched from master so that future backpatchable code can
make use of these APIs. This patch by itself does not contain any
users of these APIs.
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
bb755632-2a43-d523-36f8-
a1e7a389a907@enterprisedb.com
Michael Paquier [Wed, 14 Sep 2022 03:17:03 +0000 (12:17 +0900)]
Simplify handling of compression level with compression specifications
PG_COMPRESSION_OPTION_LEVEL is removed from the compression
specification logic, and instead the compression level is always
assigned with each library's default if nothing is directly given. This
centralizes the checks on the compression methods supported by a given
build, and always assigns a default compression level when parsing a
compression specification. This results in complaining at an earlier
stage than previously if a build supports a compression method or not,
aka when parsing a specification in the backend or the frontend, and not
when processing it. zstd, lz4 and zlib are able to handle in their
respective routines setting up the compression level the case of a
default value, hence the backend or frontend code (pg_receivewal or
pg_basebackup) has now no need to know what the default compression
level should be if nothing is specified: the logic is now done so as the
specification parsing assigns it. It can also be enforced by passing
down a "level" set to the default value, that the backend will accept
(the replication protocol is for example able to handle a command like
BASE_BACKUP (COMPRESSION_DETAIL 'gzip:level=-1')).
This code simplification fixes an issue with pg_basebackup --gzip
introduced by
ffd5365, where the tarball of the streamed WAL segments
would be created as of pg_wal.tar.gz with uncompressed contents, while
the intention is to compress the segments with gzip at a default level.
The origin of the confusion comes from the handling of the default
compression level of gzip (-1 or Z_DEFAULT_COMPRESSION) and the value of
0 was getting assigned, which is what walmethods.c would consider
as equivalent to no compression when streaming WAL segments with its tar
methods. Assigning always the compression level removes the confusion
of some code paths considering a value of 0 set in a specification as
either no compression or a default compression level.
Note that 010_pg_basebackup.pl has to be adjusted to skip a few tests
where the shape of the compression detail string for client and
server-side compression was checked using gzip. This is a result of the
code simplification, as gzip specifications cannot be used if a build
does not support it.
Reported-by: Tom Lane
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/
1400032.
1662217889@sss.pgh.pa.us
Backpatch-through: 15
Peter Eisentraut [Tue, 13 Sep 2022 12:18:45 +0000 (14:18 +0200)]
Make locale option behavior more consistent
Locale options can be specified for initdb, createdb, and CREATE
DATABASE. In initdb, it has always been possible to specify --locale
and then some --lc-* option to override a category. CREATE DATABASE
and createdb didn't allow that, requiring either the all-categories
option or only per-category options. In
f2553d43060edb210b36c63187d52a632448e1d2, this was changed in CREATE
DATABASE (perhaps by accident?) to be more like the initdb behavior,
but createdb still had the old behavior.
Now we change createdb to match the behavior of CREATE DATABASE and
initdb, and also update the documentation of CREATE DATABASE to match
the new behavior, which was not done in the above commit.
Author: Marina Polyakova <
[email protected]>
Reviewed-by: Justin Pryzby <[email protected]>
Discussion: https://www.postgresql.org/message-id/
7c99c132dc9c0ac630e0127f032ac480@postgrespro.ru
Alvaro Herrera [Tue, 13 Sep 2022 10:02:56 +0000 (12:02 +0200)]
Improve wal_decode_buffer_size description some more
Per Thomas Munro
Discussion: https://postgr.es/m/CA+hUKGJ9wP9kpvgoxHvqA=4g1d9-y_w3LhhdhFVU=mFiqjwHww@mail.gmail.com
Michael Paquier [Tue, 13 Sep 2022 01:38:59 +0000 (10:38 +0900)]
Move any remaining files generated by pg_upgrade into an internal subdir
This change concerns a couple of .txt files (for internal state checks)
that were still written in the path where the binary is executed, and
not in the subdirectory located in the target cluster. Like the other
.txt files doing already so (like loadable_libraries.txt), these are
saved in the base output directory. Note that on failure, the logs
report the full path to the .txt file generated, so these are easy to
find.
Oversight in
38bfae3.
Author: Daniel Gustafsson
Reviewed-by: Michael Paquier, Justin Prysby
Discussion: https://postgr.es/m/
181A6DA8-3B7F-4B71-82D5-
363FF0146820@yesql.se
Backpatch-through: 15
David Rowley [Mon, 12 Sep 2022 23:04:37 +0000 (11:04 +1200)]
Don't reference out-of-bounds array elements in brin_minmax_multi.c
The primary fix here is to fix has_matching_range() so it does not
reference ranges->values[-1] when nranges == 0. Similar problems existed
in AssertCheckRanges() too. It does not look like any of these problems
could lead to a crash as the array in question is at the end of the Ranges
struct, and values[-1] is memory that belongs to other fields in the
struct. However, let's get rid of these rather unsafe coding practices.
In passing, I (David) adjusted some comments to try to make it more clear
what some of the fields are for in the Ranges struct. I had to study the
code to find out what nsorted was for as I couldn't tell from the
comments.
Author: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAqJQzPitufX-jR=YUbJafpCDAKUnwgdbX_MzSc93wuvdw@mail.gmail.com
Backpatch-through: 14, where multi-range brin was added.
Daniel Gustafsson [Mon, 12 Sep 2022 20:17:17 +0000 (22:17 +0200)]
doc: Fix link to FreeBSD documentation project
The FreeBSD site was changed with a redirect, which in turn seems to
lead to a 404. Replace with the working link.
Author: James Coleman <
[email protected]>
Discussion: https://postgr.es/m/CAAaqYe_JZRj+KPn=hACtwsg1iLRYs=jYvxG1NW4AnDeUL1GD-Q@mail.gmail.com
Peter Eisentraut [Mon, 12 Sep 2022 14:51:00 +0000 (16:51 +0200)]
Add list of acknowledgments to release notes
This contains all individuals mentioned in the commit messages during
PostgreSQL 15 development.
current through REL_15_BETA4
Daniel Gustafsson [Mon, 12 Sep 2022 10:59:06 +0000 (12:59 +0200)]
Fix NaN comparison in circle_same test
Commit
c4c340088 changed geometric operators to use float4 and float8
functions, and handle NaN's in a better way. The circle sameness test
had a typo in the code which resulted in all comparisons with the left
circle having a NaN radius considered same.
postgres=# select '<(0,0),NaN>'::circle ~= '<(0,0),1>'::circle;
?column?
----------
t
(1 row)
This fixes the sameness test to consider the radius of both the left
and right circle.
Backpatch to v12 where this was introduced.
Author: Ranier Vilela <
[email protected]>
Discussion: https://postgr.es/m/CAEudQAo8dK=yctg2ZzjJuzV4zgOPBxRU5+Kb+yatFiddtQk6Rw@mail.gmail.com
Backpatch-through: v12
Peter Eisentraut [Mon, 12 Sep 2022 07:38:07 +0000 (09:38 +0200)]
Use float8 datatype for percentiles in pg_walinspect stat functions
pg_walinspect uses datatype double (double precision floating point
number) for WAL stats percentile calculations and expose them via
float4 (single precision floating point number), which an unnecessary
loss of precision and confusing. Even though, it's harmless that way,
let's use float8 (double precision floating-point number) to be in
sync with what pg_walinspect does internally and what it exposes to
the users. This seems to be the pattern used elsewhere in the code.
Reported-by: Peter Eisentraut
Author: Bharath Rupireddy
Reviewed-by: Peter Eisentraut
Discussion: https://www.postgresql.org/message-id/
36ee692b-232f-0484-ce94-
dc39d82021ad%40enterprisedb.com
Tom Lane [Sat, 10 Sep 2022 20:42:25 +0000 (16:42 -0400)]
Doc: improve explanation of when custom GUCs appear in pg_settings.
Be more clear about when and how an extension-defined GUC comes to be
visible in pg_settings. (Move the para to the bottom of the page, too;
whoever thought this point was more important than the para about the
view being updatable had odd priorities IMNSHO.)
Back-patch to v15 where archive modules were added, since that seems
to have made this more of a sore spot than it was before.
Benoit Lobréau, Nathan Bossart
Discussion: https://postgr.es/m/CAPE8EZ7KHaXMHKwT=HOim23tDVKYA1PruRuTfeYdCrYWwPGhag@mail.gmail.com
Tom Lane [Fri, 9 Sep 2022 19:34:04 +0000 (15:34 -0400)]
Fix possible omission of variable storage markers in ECPG.
The ECPG preprocessor converted code such as
static varchar str1[10], str2[20], str3[30];
into
static struct varchar_1 { int len; char arr[ 10 ]; } str1 ;
struct varchar_2 { int len; char arr[ 20 ]; } str2 ;
struct varchar_3 { int len; char arr[ 30 ]; } str3 ;
thus losing the storage attribute for the later variables.
Repeat the declaration for each such variable.
(Note that this occurred only for variables declared "varchar"
or "bytea", which may help explain how it escaped detection
for so long.)
Andrey Sokolov
Discussion: https://postgr.es/m/
942241662288242@mail.yandex.ru
Tom Lane [Fri, 9 Sep 2022 17:50:42 +0000 (13:50 -0400)]
Doc: improve documentation about where the psqlrc files are.
Remove no-longer-accurate claim that Windows lacks home directories.
Clarify the text by more clearly distinguishing which statements
reflect hard-wired choices versus which ones reflect overridable
defaults. Update the examples of version-specific file names,
and make them track future version changes by using "&majorversion;"
and "&version;". (BTW, in devel and beta releases this method
correctly says that you can use strings like "16devel" and "15beta4"
as minor version identifiers.)
Back-patch to v15, but not further, with the thought that in older
releases the examples with three-part version numbers still had
some historical relevance. v15 will be the first major release after
the last 9.x branch went out of support.
Robert Treat and Tom Lane, reviewed by Julien Rouhaud
Discussion: https://postgr.es/m/CAJSLCQ07F-WCYYYOY8+dWhHcVeJ1Pb01cWc-c0Hu=M3EjKT2Eg@mail.gmail.com
Tom Lane [Fri, 9 Sep 2022 16:41:36 +0000 (12:41 -0400)]
Reject bogus output from uuid_create(3).
When using the BSD UUID functions, contrib/uuid-ossp expects
uuid_create() to produce a version-1 UUID. FreeBSD still does so,
but in recent NetBSD releases that function produces a version-4
(random) UUID instead. That's not acceptable for our purposes:
if the user wanted v4 she would have asked for v4, not v1.
Hence, check the version digit and complain if it's not '1'.
Also drop the documentation's claim that the NetBSD implementation
is usable. It might be, depending on which OS version you're using,
but we're not going to get into that kind of detail.
(Maybe someday we should ditch all these external libraries
and just write our own UUID code, but today is not that day.)
Nazir Bilal Yavuz, with cosmetic adjustments and docs by me.
Backpatch to all supported versions.
Discussion: https://postgr.es/m/
3848059.
1661038772@sss.pgh.pa.us
Discussion: https://postgr.es/m/17358-
89806e7420797025@postgresql.org
Alvaro Herrera [Fri, 9 Sep 2022 11:51:45 +0000 (13:51 +0200)]
Doc fixes for MERGE statement
In commit
3d895bc846f2 I introduced a bogus semicolon mid-statement by
careless cut-n-paste; move it. This had already been reported by Justin
Pryzby.
Also, change the styling a bit by avoiding names in CamelCase. This is
more consistent with the style we use elsewhere.
Backpatch to 15.
Author: Vitaly Burovoy <
[email protected]>
Reviewed-by: Vik Fearing <[email protected]>
Discussion: https://postgr.es/m/
9afe5766-5a61-7860-598c-
136867fad065@gmail.com
Discussion: https://postgr.es/m/
20220819133016[email protected]
Alvaro Herrera [Fri, 9 Sep 2022 10:22:20 +0000 (12:22 +0200)]
Fix GetForeignKey*Triggers for self-referential FKs
Because of inadequate filtering, the check triggers were confusing the
search for action triggers in GetForeignKeyActionTriggers and vice-versa
in GetForeignKeyCheckTriggers; this confusion results in seemingly
random assertion failures, and can have real impact in non-asserting
builds depending on catalog order. Change these functions so that they
correctly ignore triggers that are not relevant to each side.
To reduce the odds of further problems, do not break out of the
searching loop in assertion builds. This break is likely to hide bugs;
without it, we would have detected this bug immediately.
This problem was introduced by
f4566345cf40, so backpatch to 15 where
that commit first appeared.
Author: Amit Langote <
[email protected]>
Discussion: https://postgr.es/m/
20220908172029[email protected]
Discussion: https://postgr.es/m/
4104619.
1662663056@sss.pgh.pa.us
Michael Paquier [Fri, 9 Sep 2022 01:01:14 +0000 (10:01 +0900)]
Add more error context to RestoreBlockImage() and consume it
On failure in restoring a block image, no details were provided, while
it is possible to see failure with an inconsistent record state, a
failure in processing decompression or a failure in decompression
because a build does not support this option.
RestoreBlockImage() is used in two code paths in the backend code,
during recovery and when checking a page consistency after applying
masking, and both places are changed to consume the error message
produced by the internal routine when it returns a false status. All
the error messages are reported under ERRCODE_INTERNAL_ERROR, that gets
used also when attempting to access a page compressed by a method
not supported by the build attempting the decompression. This is
something that can happen in core when doing physical replication with
primary and standby using inconsistent build options, for example.
This routine is available since
2c03216d and it has never provided any
context about the error happening when it failed. This change is
justified even more after
57aa5b2, that introduced compression of FPWs
in WAL.
Reported-by: Justin Prysby
Author: Michael Paquier
Discussion: https://postgr.es/m/
20220905002320[email protected]
Backpatch-through: 15
Alvaro Herrera [Thu, 8 Sep 2022 11:17:02 +0000 (13:17 +0200)]
Choose FK name correctly during partition attachment
During ALTER TABLE ATTACH PARTITION, if the name of a parent's foreign
key constraint is already used on the partition, the code tries to
choose another one before the FK attributes list has been populated,
so the resulting constraint name was "<relname>__fkey" instead of
"<relname>_<attrs>_fkey". Repair, and add a test case.
Backpatch to 12. In 11, the code to attach a partition was not smart
enough to cope with conflicting constraint names, so the problem doesn't
exist there.
Author: Jehan-Guillaume de Rorthais <
[email protected]>
Discussion: https://postgr.es/m/
20220901184156.
738ebee5@karst
Thomas Munro [Thu, 8 Sep 2022 08:25:20 +0000 (20:25 +1200)]
Fix recovery_prefetch with low maintenance_io_concurrency.
We should process completed IOs *before* trying to start more, so that
it is always possible to decode one more record when the decoded record
queue is empty, even if maintenance_io_concurrency is set so low that a
single earlier WAL record might have saturated the IO queue.
That bug was hidden because the effect of maintenance_io_concurrency was
arbitrarily clamped to be at least 2. Fix the ordering, and also remove
that clamp. We need a special case for 0, which is now treated the same
as recovery_prefetch=off, but otherwise the number is used directly.
This allows for testing with 1, which would have made the problem
obvious in simple test scenarios.
Also add an explicit error message for missing contrecords. It was a
bit strange that we didn't report an error already, and became a latent
bug with prefetching, since the internal state that tracks aborted
contrecords would not survive retrying, as revealed by
026_overwrite_contrecord.pl with this adjustment. Reporting an error
prevents that.
Back-patch to 15.
Reported-by: Justin Pryzby <[email protected]>
Reviewed-by: Kyotaro Horiguchi <[email protected]>
Discussion: https://postgr.es/m/
20220831140128.GS31833%40telsasoft.com
Alvaro Herrera [Wed, 7 Sep 2022 15:33:49 +0000 (17:33 +0200)]
Message style fixes