postgresql.git
2 years agoEnsure ParseTzFile() closes the input file after failing.
Tom Lane [Tue, 31 May 2022 18:47:44 +0000 (14:47 -0400)]
Ensure ParseTzFile() closes the input file after failing.

We hadn't noticed this because (a) few people feed invalid
timezone abbreviation files to the server, and (b) in typical
scenarios guc.c would throw ereport(ERROR) and then transaction
abort handling would silently clean up the leaked file reference.
However, it was possible to observe file leakage warnings if one
breaks an already-active abbreviation file, because guc.c does
not throw ERROR when loading supposedly-validated settings during
session start or SIGHUP processing.

Report and fix by Kyotaro Horiguchi (cosmetic adjustments by me)

Discussion: https://postgr.es/m/20220530.173740.748502979257582392.horikyota.ntt@gmail.com

2 years agoDoc: fix mention of psql's minimum supported server version.
Tom Lane [Tue, 31 May 2022 16:18:27 +0000 (12:18 -0400)]
Doc: fix mention of psql's minimum supported server version.

Commit cf0cab868 removed describe.c's support for pre-9.2 server
versions, but neglected to update this documentation reference.

Discussion: https://postgr.es/m/GV0P278MB041917EB3E2FE8704B5AE2C6D2DC9@GV0P278MB0419.CHEP278.PROD.OUTLOOK.COM

2 years agoDoc: fix mention of pg_dump's minimum supported server version.
Tom Lane [Tue, 31 May 2022 16:14:02 +0000 (12:14 -0400)]
Doc: fix mention of pg_dump's minimum supported server version.

runtime.sgml contains a passing reference to the minimum server
version that pg_dump[all] can dump from.  That was 7.0 for many
years, but when 64f3524e2 raised it to 8.0, we missed updating this
bit.  Then when 30e7c175b raised it to 9.2, we missed it again.

Given that track record, I'm not too hopeful that we'll remember
to fix this in future changes ... but for now, make the docs match
reality in each branch.

Noted by Daniel Westermann.

Discussion: https://postgr.es/m/GV0P278MB041917EB3E2FE8704B5AE2C6D2DC9@GV0P278MB0419.CHEP278.PROD.OUTLOOK.COM

2 years agoshm_mq_sendv: Fix flushing bug when receiver not yet attached.
Robert Haas [Tue, 24 May 2022 14:55:01 +0000 (10:55 -0400)]
shm_mq_sendv: Fix flushing bug when receiver not yet attached.

With the old logic, when the reciever had not yet attached, we would
never call shm_mq_inc_bytes_written(), even if force_flush = true
was specified. That could result in a situation where data that the
sender believes it has sent is never received.

Along the way, remove a useless function prototype for a nonexistent
function from shm_mq.h.

Commit 46846433a03dff4f2e08c8a161e54a842da360d6 introduced these
problems.

Pavan Deolasee, with a few changes by me.

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

2 years agoFix typo in hash README.
Amit Kapila [Tue, 31 May 2022 09:07:41 +0000 (14:37 +0530)]
Fix typo in hash README.

Author: Peter Smith
Discussion: https://postgr.es/m/CAHut+Pu-V22PiJF2ym9_NVZe-+qnycfyEX24dZm=7URWhDHJ3w@mail.gmail.com

2 years agoRemove useless tests for TRUNCATE on foreign tables
Michael Paquier [Tue, 31 May 2022 00:44:00 +0000 (09:44 +0900)]
Remove useless tests for TRUNCATE on foreign tables

foreign_data has kept around a set of tests for TRUNCATE to look after
the case of foreign tables, with[out] inheritance and with[out]
partitions, assuming that the command is not supported for this relkind.
However, TRUNCATE is supported on foreign tables if the FDW involved is
able to handle the command, like postgres_fdw.

Note that postgres_fdw includes tests to cover all the cases removed by
this commit (which had misleading comments), so these did not provide
any additional coverage anyway.

Author: Yugo Nagata
Discussion: https://postgr.es/m/20220527172543.0a2fdb469cf048b81c0967d3@sraoss.co.jp

2 years agoAdd debugging help in OwnLatch().
Thomas Munro [Mon, 30 May 2022 23:38:19 +0000 (11:38 +1200)]
Add debugging help in OwnLatch().

Build farm animal gharial recently failed a few times in a parallel
worker's call to OwnLatch() with "ERROR:  latch already owned".  Let's
turn that into a PANIC and show the PID of the owner, to try to learn
more.

Discussion: https://postgr.es/m/CA%2BhUKGJ_0RGcr7oUNzcHdn7zHqHSB_wLSd3JyS2YC_DYB%2B-V%3Dg%40mail.gmail.com

2 years agoMake STRING an unreserved_keyword.
Tom Lane [Mon, 30 May 2022 18:05:20 +0000 (14:05 -0400)]
Make STRING an unreserved_keyword.

Commit 1a36bc9db (SQL/JSON query functions) introduced STRING as a
type_func_name_keyword, thereby breaking applications that use
"string" as a table name, column name, function parameter name, etc.
That seems like a pretty bad thing, not least because the SQL spec
says that STRING is an unreserved keyword.

This is easy enough to fix so far as the core grammar is concerned.
However, doing so causes some ECPG test cases to fail, specifically
those that use "string" as a typedef name.  It turns out this is
because portions of the ECPG grammar allow type_func_name_keywords
but not unreserved_keywords as typedef names.  That's pretty horrid,
and it's mildly astonishing that we've not heard complaints about it
before.  We can fix two of those uses trivially, but the ones in the
var_type production are less easy.  As a stopgap, hard-code STRING as
an allowed alternative in var_type.

Per report from Alastair McKinley.

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

2 years agologging: Also add the command prefix to detail and hint messages
Peter Eisentraut [Mon, 30 May 2022 05:18:57 +0000 (07:18 +0200)]
logging: Also add the command prefix to detail and hint messages

This makes the output line up better and allows filtering messages by
command.

Discussion: https://www.postgresql.org/message-id/ba6d4fac-9e33-91f9-94fb-1e4c144a48b9@enterprisedb.com

2 years agodoc: Reword description of roles able to view track_activities's info
Michael Paquier [Mon, 30 May 2022 01:50:21 +0000 (10:50 +0900)]
doc: Reword description of roles able to view track_activities's info

The information generated when track_activities is accessible to
superusers, roles with the privileges of pg_read_all_stats, as well as
roles one has the privileges of.  The original text did not outline the
last point, while the change done in ac1ae47 was unclear about the
second point.

Per discussion with Nathan Bossart.

Discussion: https://postgr.es/m/20220521185743.GA886636@nathanxps13
Backpatch-through: 10

2 years agoFix COPY FROM when database encoding is SQL_ASCII.
Heikki Linnakangas [Sun, 29 May 2022 20:53:45 +0000 (23:53 +0300)]
Fix COPY FROM when database encoding is SQL_ASCII.

In the codepath when no encoding conversion is required, the check for
incomplete character at the end of input incorrectly used server
encoding's max character length, instead of the client's. Usually the
server and client encodings are the same when we're not performing
encoding conversion, but SQL_ASCII is an exception.

In the passing, also fix some outdated comments that still talked about
the old COPY protocol. It was removed in v14.

Per bug #17501 from Vitaly Voronov. Backpatch to v14 where this was
introduced.

Discussion: https://www.postgresql.org/message-id/17501-128b1dd039362ae6@postgresql.org

2 years agoDoc: fix missing/bogus documentation of range_intersect_agg().
Tom Lane [Sun, 29 May 2022 17:25:21 +0000 (13:25 -0400)]
Doc: fix missing/bogus documentation of range_intersect_agg().

The form taking anymultirange had not been documented.  This was
fixed in HEAD in b21c4cf95, but that should have been back-patched
to v14 since the function was added there.  Do so now.

Also, the form taking anyrange was incorrectly documented as
returning anymultirange, when it returns anyrange.

Remove b21c4cf95 from the v15 release notes, since it no longer
qualifies as new-in-v15.

Noted by Shay Rojansky.

Discussion: https://postgr.es/m/CADT4RqAktzP7t6SFf0Xqm9YhahzvsmxFbzXe-gFOd=+_CHm0JA@mail.gmail.com

2 years agoDoc: Document pg_stat_recovery_prefetch.stats_reset.
Thomas Munro [Sun, 29 May 2022 04:33:26 +0000 (16:33 +1200)]
Doc: Document pg_stat_recovery_prefetch.stats_reset.

This column was missing from the table that describes the new view.

Author: Shinoda, Noriyoshi (PN Japan FSIP) <noriyoshi.shinoda@hpe.com>
Discussion: https://postgr.es/m/DM4PR84MB173401C19A0EB9B1CAAB197CEED29@DM4PR84MB1734.NAMPRD84.PROD.OUTLOOK.COM

2 years agoAlign stats_fetch_consistency definition with guc.c default.
Andres Freund [Sat, 28 May 2022 20:08:19 +0000 (13:08 -0700)]
Align stats_fetch_consistency definition with guc.c default.

Somewhat embarrassing oversight in 98f897339b0. Does not have a functional
impact, but is unnecessarily confusing.

Reported-By: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/Yo2351qVYqd/bJws@paquier.xyz

2 years agoRevert "Add single-item cache when looking at topmost XID of a subtrans XID"
Michael Paquier [Sat, 28 May 2022 06:02:08 +0000 (15:02 +0900)]
Revert "Add single-item cache when looking at topmost XID of a subtrans XID"

This reverts commit 06f5295 as per issues with this approach, both in
terms of efficiency impact and stability.  First, contrary to the
single-item cache for transaction IDs in transam.c, the cache may finish
by not be hit for a long time, and without an invalidation mechanism to
clear it, it would cause inconsistent results on wraparound for
example.  Second, the use of SubTransGetTopmostTransaction() for the
caching has a limited impact on performance.  SubTransGetParent() could
have more impact, though the benchmarking of the single-item approach
still needs to be proved, particularly under the conditions where SLRU
lookups are stressed in parallel with overflowed snapshots (aka more
than 64 subxids generated, for example).

After discussion with Andres Freund.

Discussion: https://postgr.es/m/20220524235250.gtt3uu5zktfkr4hv@alap3.anarazel.de

2 years agoHandle NULL for short descriptions of custom GUC variables
Michael Paquier [Sat, 28 May 2022 03:12:40 +0000 (12:12 +0900)]
Handle NULL for short descriptions of custom GUC variables

If a short description is specified as NULL in one of the various
DefineCustomXXXVariable() functions available to external modules to
define a custom parameter, SHOW ALL would crash.  This change teaches
SHOW ALL to properly handle NULL short descriptions, as well as any code
paths that manipulate it, to gain in flexibility.  Note that
help_config.c was already able to do that, when describing a set of GUCs
for postgres --describe-config.

Author: Steve Chavez
Reviewed by: Nathan Bossart, Andres Freund, Michael Paquier, Tom Lane
Discussion: https://postgr.es/m/CAGRrpzY6hO-Kmykna_XvsTv8P2DshGiU6G3j8yGao4mk0CqjHA%40mail.gmail.com
Backpatch-through: 10

2 years agoTeach remove_unused_subquery_outputs about window run conditions
David Rowley [Thu, 26 May 2022 22:37:58 +0000 (10:37 +1200)]
Teach remove_unused_subquery_outputs about window run conditions

9d9c02ccd added code to allow the executor to take shortcuts when quals
on monotonic window functions guaranteed that once the qual became false
it could never become true again.  When possible, baserestrictinfo quals
are converted to become these quals, which we call run conditions.

Unfortunately, in 9d9c02ccd, I forgot to update
remove_unused_subquery_outputs to teach it about these run conditions.
This could cause a WindowFunc column which was unused in the target list
but referenced by an upper-level WHERE clause to be removed from the
subquery when the qual in the WHERE clause was converted into a window run
condition.  Because of this, the entire WindowClause would be removed from
the query resulting in additional rows making it into the resultset when
they should have been filtered out by the WHERE clause.

Here we fix this by recording which target list items in the subquery have
run conditions. That gets passed along to remove_unused_subquery_outputs
to tell it not to remove these items from the target list.

Bug: #17495
Reported-by: Jeremy Evans
Reviewed-by: Richard Guo
Discussion: https://postgr.es/m/17495-7ffe2fa0b261b9fa@postgresql.org

2 years agoRemove misguided SSL key file ownership check in libpq.
Tom Lane [Thu, 26 May 2022 18:14:05 +0000 (14:14 -0400)]
Remove misguided SSL key file ownership check in libpq.

Commits a59c79564 et al. tried to sync libpq's SSL key file
permissions checks with what we've used for years in the backend.
We did not intend to create any new failure cases, but it turns out
we did: restricting the key file's ownership breaks cases where the
client is allowed to read a key file despite not having the identical
UID.  In particular a client running as root used to be able to read
someone else's key file; and having seen that I suspect that there are
other, less-dubious use cases that this restriction breaks on some
platforms.

We don't really need an ownership check, since if we can read the key
file despite its having restricted permissions, it must have the right
ownership --- under normal conditions anyway, and the point of this
patch is that any additional corner cases where that works should be
deemed allowable, as they have been historically.  Hence, just drop
the ownership check, and rearrange the permissions check to get rid
of its faulty assumption that geteuid() can't be zero.  (Note that the
comparable backend-side code doesn't have to cater for geteuid() == 0,
since the server rejects that very early on.)

This does have the end result that the permissions safety check used
for a root user's private key file is weaker than that used for
anyone else's.  While odd, root really ought to know what she's doing
with file permissions, so I think this is acceptable.

Per report from Yogendra Suralkar.  Like the previous patch,
back-patch to all supported branches.

Discussion: https://postgr.es/m/MW3PR15MB3931DF96896DC36D21AFD47CA3D39@MW3PR15MB3931.namprd15.prod.outlook.com

2 years agoIn CREATE FOREIGN TABLE syntax synopsis, fix partitioning stuff.
Robert Haas [Thu, 26 May 2022 16:54:33 +0000 (12:54 -0400)]
In CREATE FOREIGN TABLE syntax synopsis, fix partitioning stuff.

Foreign tables can be partitioned, but previous documentation commits
left the syntax synopsis both incomplete and incorrect.

Justin Pryzby and Amit Langote

Discussion: http://postgr.es/m/20220521130922.GX19626@telsasoft.com

2 years agoAvoid ERRCODE_INTERNAL_ERROR in oracle_compat.c functions.
Tom Lane [Thu, 26 May 2022 16:25:10 +0000 (12:25 -0400)]
Avoid ERRCODE_INTERNAL_ERROR in oracle_compat.c functions.

repeat() checked for integer overflow during its calculation of the
required output space, but it just passed the resulting integer to
palloc().  This meant that result sizes between 1GB and 2GB led to
ERRCODE_INTERNAL_ERROR, "invalid memory alloc request size" rather
than ERRCODE_PROGRAM_LIMIT_EXCEEDED, "requested length too large".
That seems like a bit of a wart, so add an explicit AllocSizeIsValid
check to make these error cases uniform.

Do likewise in the sibling functions lpad() etc.  While we're here,
also modernize their overflow checks to use pg_mul_s32_overflow() etc
instead of expensive divisions.

Per complaint from Japin Li.  This is basically cosmetic, so I don't
feel a need to back-patch.

Discussion: https://postgr.es/m/ME3P282MB16676ED32167189CB0462173B6D69@ME3P282MB1667.AUSP282.PROD.OUTLOOK.COM

2 years agorelnotes: update ordered partition scan item
Bruce Momjian [Thu, 26 May 2022 02:19:20 +0000 (22:19 -0400)]
relnotes: update ordered partition scan item

Reported-by: Amit Langote
Discussion: https://postgr.es/m/CA+HiwqFMmOK9cjrqxJeY1HKKbgMup0HcZ+Co7JuzJG_8ZypceA@mail.gmail.com

2 years agoAdd tab completion for table_rewrite's CREATE EVENT TRIGGER in psql
Michael Paquier [Wed, 25 May 2022 05:21:05 +0000 (14:21 +0900)]
Add tab completion for table_rewrite's CREATE EVENT TRIGGER in psql

Author: Hou Zhijie
Discussion: https://postgr.es/m/OS0PR01MB5716DEFF787B925C4778228C94D69@OS0PR01MB5716.jpnprd01.prod.outlook.com

2 years agoFix stats_fetch_consistency default value indicated in postgresql.conf.sample.
Andres Freund [Wed, 25 May 2022 04:24:13 +0000 (21:24 -0700)]
Fix stats_fetch_consistency default value indicated in postgresql.conf.sample.

Mistake in 5891c7a8ed8, likely made when switching the default value from none
to fetch during development.

Reported-By: Nathan Bossart <nathandbossart@gmail.com>
Author: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/20220524220147.GA1298892@nathanxps13

2 years agorelnotes: add Heikki to UTF8 item
Bruce Momjian [Tue, 24 May 2022 23:37:50 +0000 (19:37 -0400)]
relnotes:  add Heikki to UTF8 item

Reported-by: John Naylor
Discussion: https://postgr.es/m/CAFBsxsFhbhMbK_ZaLpH6J8BfJL_uowtGg+Qs9XA=F4uPU3aucA@mail.gmail.com

2 years agoRemove duplicated words in comments of pgstat.c and pgstat_internal.h
Michael Paquier [Tue, 24 May 2022 02:00:41 +0000 (11:00 +0900)]
Remove duplicated words in comments of pgstat.c and pgstat_internal.h

Author: Atsushi Torikoshi
Reviewed-by: Nathan Bossart
Discussion: https://postgr.es/m/d00ddbf29f9d09b3a471e64977560de1@oss.nttdata.com

2 years agodoc: Improve COPY synopsis
Peter Eisentraut [Mon, 23 May 2022 11:09:18 +0000 (13:09 +0200)]
doc: Improve COPY synopsis

Upper-case MATCH so that it is clearer that it is a keyword in this
context.

Discussion: https://www.postgresql.org/message-id/flat/20220517.174342.1884842412165214815.horikyota.ntt%40gmail.com

2 years agopg_upgrade: Tweak translatable strings
Peter Eisentraut [Mon, 23 May 2022 08:54:39 +0000 (10:54 +0200)]
pg_upgrade: Tweak translatable strings

"\r" (for progress output) must not be inside a translatable string
(gettext gets upset).

In passing, move the minimum supported version number to a separate
argument, so that we don't have to retranslate this string every year
now.

2 years agodoc: Add documentation for pg_database.datlocprovider column
Peter Eisentraut [Mon, 23 May 2022 08:31:33 +0000 (10:31 +0200)]
doc: Add documentation for pg_database.datlocprovider column

This was apparently missed in the original commit.

Author: Shinoda, Noriyoshi (PN Japan FSIP) <noriyoshi.shinoda@hpe.com>
Discussion: https://www.postgresql.org/message-id/flat/DM4PR84MB1734BA51BC8B08CF3FA239BBEED49%40DM4PR84MB1734.NAMPRD84.PROD.OUTLOOK.COM

2 years agopsql: Update \timing also in case of an error
Peter Eisentraut [Mon, 23 May 2022 08:07:36 +0000 (10:07 +0200)]
psql: Update \timing also in case of an error

The changes to show all query results (7844c9918) broke \timing output
in case of an error; it didn't update the timing result and showed
0.000 ms.

Fix by updating the timing result also in the error case.  Also, for
robustness, update the timing result any time a result is obtained,
not only for the last, so a sensible value is always available.

Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Author: Richard Guo <guofenglinux@gmail.com>
Author: Fabien COELHO <coelho@cri.ensmp.fr>
Discussion: https://www.postgresql.org/message-id/3813350.1652111765%40sss.pgh.pa.us

2 years agoRemove debug messages from tuplesort_sort_memtuples()
John Naylor [Mon, 23 May 2022 06:11:43 +0000 (13:11 +0700)]
Remove debug messages from tuplesort_sort_memtuples()

These were of value only during development.

Reported by Justin Pryzby
Discussion: https://www.postgresql.org/message-id/20220519201254.GU19626%40telsasoft.com

2 years agopgstat: fix stats.spec instability on slow machines.
Andres Freund [Sun, 22 May 2022 22:09:50 +0000 (15:09 -0700)]
pgstat: fix stats.spec instability on slow machines.

On slow machines the modified test could end up switching the order in which
transactional stats are reported in one session and non-transactional stats in
another session. As stats handling of truncate is implemented as setting
live/dead rows 0, the order in which a truncate's stats changes are applied,
relative to normal stats updates, matters. The handling of stats for truncate
hasn't changed due to shared memory stats, this is longstanding behavior.

We might want to improve truncate's stats handling in the future, but for now
just change the order of forced flushed to make the test stable.

Reported-By: Christoph Berg <myon@debian.org>
Discussion: https://postgr.es/m/YoZf7U/WmfmFYFEx@msg.df7cb.de

2 years agoShow 'AS "?column?"' explicitly when it's important.
Tom Lane [Sat, 21 May 2022 18:45:58 +0000 (14:45 -0400)]
Show 'AS "?column?"' explicitly when it's important.

ruleutils.c was coded to suppress the AS label for a SELECT output
expression if the column name is "?column?", which is the parser's
fallback if it can't think of something better.  This is fine, and
avoids ugly clutter, so long as (1) nothing further up in the parse
tree relies on that column name or (2) the same fallback would be
assigned when the rule or view definition is reloaded.  Unfortunately
(2) is far from certain, both because ruleutils.c might print the
expression in a different form from how it was originally written
and because FigureColname's rules might change in future releases.
So we shouldn't rely on that.

Detecting exactly whether there is any outer-level use of a SELECT
column name would be rather expensive.  This patch takes the simpler
approach of just passing down a flag indicating whether there *could*
be any outer use; for example, the output column names of a SubLink
are not referenceable, and we also do not care about the names exposed
by the right-hand side of a setop.  This is sufficient to suppress
unwanted clutter in all but one case in the regression tests.  That
seems like reasonable evidence that it won't be too much in users'
faces, while still fixing the cases we need to fix.

Per bug #17486 from Nicolas Lutic.  This issue is ancient, so
back-patch to all supported branches.

Discussion: https://postgr.es/m/17486-1ad6fd786728b8af@postgresql.org

2 years agoRemove unused-and-misspelled function extern declaration.
Tom Lane [Sat, 21 May 2022 17:26:08 +0000 (13:26 -0400)]
Remove unused-and-misspelled function extern declaration.

Commit c65507763 added "extern XLogRecPtr CalculateMaxmumSafeLSN(void)",
which bears no trace of connection to anything else in that patch
or anywhere else.  Remove it again.

Sergei Kornilov (also spotted by Bharath Rupireddy)

Discussion: https://postgr.es/m/706501646056870@vla3-6a5326aeb4ee.qloud-c.yandex.net
Discussion: https://postgr.es/m/CALj2ACVoQ7NEf43Xz0rfxsGOKYTN5r4VZp2DO2_5p+CMzsRPFw@mail.gmail.com

2 years agoAvoid overflow hazard when clamping group counts to "long int".
Tom Lane [Sat, 21 May 2022 17:13:41 +0000 (13:13 -0400)]
Avoid overflow hazard when clamping group counts to "long int".

Several places in the planner tried to clamp a double value to fit
in a "long" by doing
(long) Min(x, (double) LONG_MAX);
This is subtly incorrect, because it casts LONG_MAX to double and
potentially back again.  If long is 64 bits then the double value
is inexact, and the platform might round it up to LONG_MAX+1
resulting in an overflow and an undesirably negative output.

While it's not hard to rewrite the expression into a safe form,
let's put it into a common function to reduce the risk of someone
doing it wrong in future.

In principle this is a bug fix, but since the problem could only
manifest with group count estimates exceeding 2^63, it seems unlikely
that anyone has actually hit this or will do so anytime soon.  We're
fixing it mainly to satisfy fuzzer-type tools.  That being the case,
a HEAD-only fix seems sufficient.

Andrey Lepikhov

Discussion: https://postgr.es/m/ebbc2efb-7ef9-bf2f-1ada-d6ec48f70e58@postgrespro.ru

2 years agodoc: Mention pg_read_all_stats in description of track_activities
Michael Paquier [Sat, 21 May 2022 10:05:47 +0000 (19:05 +0900)]
doc: Mention pg_read_all_stats in description of track_activities

The description of track_activities mentioned that it is visible to
superusers and that the information related to the current session can
be seen, without telling about pg_read_all_stats.  Roles that are
granted the privileges of pg_read_all_stats can also see this
information, so mention it in the docs.

Author: Ian Barwick
Reviewed-by: Nathan Bossart
Discussion: https://postgr.es/m/CAB8KJ=jhPyYFu-A5r-ZGP+Ax715mUKsMxAGcEQ9Cx_mBAmrPow@mail.gmail.com
Backpatch-through: 10

2 years agodoc: Fix description of the JIT time fields in pg_stat_statements
Michael Paquier [Sat, 21 May 2022 08:57:23 +0000 (17:57 +0900)]
doc: Fix description of the JIT time fields in pg_stat_statements

The four fields tracking the time spent by queries for JIT operations
added in 57d6aea were listed as having bigint as data type, but these
are of type double precision.

Author: Noriyoshi Shinoda
Reviewed-by: Nathan Bossart
Discussion: https://postgr.es/m/DM4PR84MB1734375E63148AADC6A1E6B4EED39@DM4PR84MB1734.NAMPRD84.PROD.OUTLOOK.COM

2 years agoImprove and fix some issues in the TAP tests of pg_upgrade
Michael Paquier [Sat, 21 May 2022 03:01:48 +0000 (12:01 +0900)]
Improve and fix some issues in the TAP tests of pg_upgrade

This is based on a set of suggestions from Noah, with the following
changes made:
- The set of databases created in the tests are now prefixed with
"regression" to not trigger any warnings with name restrictions when
compiling the code with -DENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS, and
now only the first name checks after the Windows case of double quotes
mixed with backslashes.
- Fix an issue with EXTRA_REGRESS_OPTS, which were not processed in a
way consistent with 027_stream_regress.pl (missing space between the
option string and pg_regress).  This got introduced in 7dd3ee5.
- Add a check on the exit code of the pg_regress command, to catch
failures after running the regression tests.

Reviewed-by: Noah Misch
Discussion: https://postgr.es/m/YoHhWD5vQzb2mmiF@paquier.xyz

2 years agoRemove portability hazard in unsafe_tests/sql/guc_privs.sql.
Tom Lane [Fri, 20 May 2022 17:42:02 +0000 (13:42 -0400)]
Remove portability hazard in unsafe_tests/sql/guc_privs.sql.

This new-in-v15 test case assumed it could set max_stack_depth as high
as 2MB.  You might think that'd be true on any modern platform but
you'd be wrong, as I found out while experimenting with NetBSD/hppa.

This test is about privileges not platform capabilities, so there seems
no need to use any value greater than the 100kB setting already used
in a couple of places in the core regression tests.  There's certainly
no call to expect people to raise their platform's default ulimit just
to run this test.

2 years agoFix DDL deparse of CREATE OPERATOR CLASS
Alvaro Herrera [Fri, 20 May 2022 16:52:55 +0000 (18:52 +0200)]
Fix DDL deparse of CREATE OPERATOR CLASS

When an implicit operator family is created, it wasn't getting reported.
Make it do so.

This has always been missing.  Backpatch to 10.

Author: Masahiko Sawada <sawada.mshk@gmail.com>
Reported-by: Leslie LEMAIRE <leslie.lemaire@developpement-durable.gouv.fr>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Michael Paquiër <michael@paquier.xyz>
Discussion: https://postgr.es/m/f74d69e151b22171e8829551b1159e77@developpement-durable.gouv.fr

2 years agoAdd pg_version() to PostgreSQL::Test::Cluster
Michael Paquier [Fri, 20 May 2022 09:29:51 +0000 (18:29 +0900)]
Add pg_version() to PostgreSQL::Test::Cluster

_pg_version (version number based on PostgreSQL::Version) is a field
private to Cluster.pm but there was no helper routine to retrieve it
from a Cluster's node.  The same is done for install_path, for example,
and the version object becomes handy when writing tests that need
version-specific handling.

Reviewed-by: Andrew Dunstan, Daniel Gustafsson
Discussion: https://postgr.es/m/YoWfoJTc987tsxpV@paquier.xyz

2 years agodoc: Explain 'invalid' index state for CREATE INDEX CONCURRENTLY
Alvaro Herrera [Fri, 20 May 2022 08:05:31 +0000 (10:05 +0200)]
doc: Explain 'invalid' index state for CREATE INDEX CONCURRENTLY

It wasn't previously mentioned that the index is created as invalid,
which is confusing to new users.

Backpatch to 14 (only because of a conflict in 13).

Author: Laurenz Albe <laurenz.albe@cybertec.at>
Reported-by: Lauren Fliksteen <dancernerd32@gmail.com>
Reviewed-by: Rajakavitha Kodhandapani <krajakavitha@gmail.com>
Discussion: https://postgr.es/m/165290238488.670.7500177735573254738@wrigleys.postgresql.org

2 years agopg_waldump: Improve option parsing error messages
Peter Eisentraut [Fri, 20 May 2022 07:26:21 +0000 (09:26 +0200)]
pg_waldump: Improve option parsing error messages

I rephrased the error messages to be more in the style of
option_parse_int(), and also made use of the new "detail" message
facility.  I didn't actually use option_parse_int() (which could be
used for -n) because libpgfeutils wasn't used here yet and I wanted to
keep this just to string changes.  But it could be done in the future.

2 years agoDoc: clarify location of libpq's default service file on Windows.
Tom Lane [Thu, 19 May 2022 22:36:07 +0000 (18:36 -0400)]
Doc: clarify location of libpq's default service file on Windows.

The documentation didn't specify the name of the per-user service file
on Windows, and extrapolating from the pattern used for other config
files gave the wrong answer.  The fact that it isn't consistent with the
others sure seems like a bug, but it's far too late to change that now;
we'd just penalize people who worked it out in the past.  So, simply
document the true state of affairs.

In passing, fix some gratuitous differences between the discussions
of the service file and the password file.

Julien Rouhaud, per question from Dominique Devienne.

Backpatch to all supported branches.  I (tgl) also chose to back-patch
the part of commit ba356a397 that touched libpq.sgml's description of
the service file --- in hindsight, I'm not sure why I didn't do so at
the time, as it includes some fairly essential information.

Discussion: https://postgr.es/m/CAFCRh-_mdLrh8eYVzhRzu4c8bAFEBn=rwoHOmFJcQOTsCy5nig@mail.gmail.com

2 years agoRepurpose PROC_COPYABLE_FLAGS as PROC_XMIN_FLAGS
Alvaro Herrera [Thu, 19 May 2022 14:20:32 +0000 (16:20 +0200)]
Repurpose PROC_COPYABLE_FLAGS as PROC_XMIN_FLAGS

This is a slight, convenient semantics change from what commit
0f0cfb494004 ("Fix parallel operations that prevent oldest xmin from
advancing") introduced that lets us simplify the coding in the one place
where it is used.

Backpatch to 13.  This is related to commit 6fea65508a1a ("Tighten
ComputeXidHorizons' handling of walsenders") rewriting the code site
where this is used, which has not yet been backpatched, but it may well
be in the future.

Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/202204191637.eldwa2exvguw@alvherre.pgsql

2 years agoRework SQL/JSON documentation
Andrew Dunstan [Thu, 19 May 2022 14:03:43 +0000 (10:03 -0400)]
Rework SQL/JSON documentation

This makes the documentation conform more closely the style of other
function sections.

Includes suggestions from Erik Rijkers, Alvaro Herrera, and Justin
Pryzby.

Discussion: https://postgr.es/m/CAKFQuwaq5Ny6d3nWbJo=QO4RmhSk9JD8zrkURLR-wWmB2Pkz7Q@mail.gmail.com

3 years agodoc: Properly punctuate "etc."
Peter Eisentraut [Thu, 19 May 2022 07:27:34 +0000 (09:27 +0200)]
doc: Properly punctuate "etc."

3 years agoFix incorrect comments for Memoize struct
David Rowley [Thu, 19 May 2022 05:14:23 +0000 (17:14 +1200)]
Fix incorrect comments for Memoize struct

Reported-by: Peter Eisentraut
Discussion: https://postgr.es/m/0635f5aa-4973-8dc2-4e4e-df9fd5778a65@enterprisedb.com
Backpatch-through: 14, where Memoize was added

3 years agoExtend pg_publication_tables to display column list and row filter.
Amit Kapila [Thu, 19 May 2022 02:50:55 +0000 (08:20 +0530)]
Extend pg_publication_tables to display column list and row filter.

Commit 923def9a53 and 52e4f0cd47 allowed to specify column lists and row
filters for publication tables. This commit extends the
pg_publication_tables view and pg_get_publication_tables function to
display that information.

This information will be useful to users and we also need this for the
later commit that prohibits combining multiple publications with different
column lists for the same table.

Author: Hou Zhijie
Reviewed By: Amit Kapila, Alvaro Herrera, Shi Yu, Takamichi Osumi
Discussion: https://postgr.es/m/202204251548.mudq7jbqnh7r@alvherre.pgsql

3 years agoUpdate xml_1.out and xml_2.out
Alvaro Herrera [Wed, 18 May 2022 21:19:53 +0000 (23:19 +0200)]
Update xml_1.out and xml_2.out

Commit 0fbf01120023 should have updated them but didn't.

3 years agoFix EXPLAIN MERGE output when no tuples are processed
Alvaro Herrera [Wed, 18 May 2022 19:20:49 +0000 (21:20 +0200)]
Fix EXPLAIN MERGE output when no tuples are processed

An 'else' clause was misplaced in commit 598ac10be1c2, making zero-rows
output look a bit silly.  Add a test case for it.

Pointed out by Tom Lane.

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

3 years agoCheck column list length in XMLTABLE/JSON_TABLE alias
Alvaro Herrera [Wed, 18 May 2022 18:28:31 +0000 (20:28 +0200)]
Check column list length in XMLTABLE/JSON_TABLE alias

We weren't checking the length of the column list in the alias clause of
an XMLTABLE or JSON_TABLE function (a "tablefunc" RTE), and it was
possible to make the server crash by passing an overly long one.  Fix it
by throwing an error in that case, like the other places that deal with
alias lists.

In passing, modify the equivalent test used for join RTEs to look like
the other ones, which was different for no apparent reason.

This bug came in when XMLTABLE was born in version 10; backpatch to all
stable versions.

Reported-by: Wang Ke <krking@zju.edu.cn>
Discussion: https://postgr.es/m/17480-1c9d73565bb28e90@postgresql.org

3 years agoMake EXPLAIN MERGE output format more compact
Alvaro Herrera [Wed, 18 May 2022 16:33:04 +0000 (18:33 +0200)]
Make EXPLAIN MERGE output format more compact

We can use a single line to print all tuple counts that MERGE processed,
for conciseness, and elide those that are zeroes.  Non-text formats
report all numbers, as is typical.

Per comment from Justin Pryzby <pryzby@telsasoft.com>

Discussion: https://postgr.es/m/20220511163350.GL19626@telsasoft.com

3 years agoFix markup in synopsis
Peter Eisentraut [Wed, 18 May 2022 16:18:22 +0000 (18:18 +0200)]
Fix markup in synopsis

There is no need for a <literal> inside a <synopsis>, since the latter
is already all "literal" implicitly.  Also, create_help.pl misparses
it.  So just remove it.

Reported-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/20220517.174342.1884842412165214815.horikyota.ntt%40gmail.com

3 years agopgbench: Restore compatibility of --partitions=0
Michael Paquier [Wed, 18 May 2022 00:47:38 +0000 (09:47 +0900)]
pgbench: Restore compatibility of --partitions=0

A value of 0 is allowed for this option since its creation, that would
map with the default of having no partitions for pgbench_accounts, but
6f164e6 broke that by enforcing an error.  This commit restores the
original behavior.

Author: Amit Langote
Discussion: https://postgr.es/m/CA+HiwqGAGobiiHR8nH382HJxqm1mzZs8=3oKPXnXivWoFSZmNA@mail.gmail.com

3 years agoFix typo in walreceiver.c
Michael Paquier [Wed, 18 May 2022 00:06:22 +0000 (09:06 +0900)]
Fix typo in walreceiver.c

s/primary_slotname/primary_slot_name/.

Author: Bharath Rupireddy
Discussion: https://postgr.es/m/CALj2ACX3=pHkCpoGG-z+O=7Gp5YZv70jmfTyGnNV7YF3SkK73g@mail.gmail.com

3 years agoStamp 15beta1. REL_15_BETA1
Tom Lane [Mon, 16 May 2022 21:10:42 +0000 (17:10 -0400)]
Stamp 15beta1.

3 years agorelnotes: improve updated UTF8 item wording
Bruce Momjian [Mon, 16 May 2022 14:18:17 +0000 (10:18 -0400)]
relnotes: improve updated UTF8 item wording

3 years agorelnotes: improve UTF8 text item in relation to ASCII
Bruce Momjian [Mon, 16 May 2022 14:09:36 +0000 (10:09 -0400)]
relnotes: improve UTF8 text item in relation to ASCII

Reported-by: John Naylor
Discussion: https://postgr.es/m/CAFBsxsE-US0sgVxVHjt99GCGky4TCD57gwMHWPF9XWo7R5rXPg@mail.gmail.com

3 years agoTranslation updates
Peter Eisentraut [Mon, 16 May 2022 09:12:42 +0000 (11:12 +0200)]
Translation updates

Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash: dde45df385dab9032155c1f867b677d55695310c

3 years agopg_upgrade: Add missing gettext triggers
Peter Eisentraut [Mon, 16 May 2022 07:41:02 +0000 (09:41 +0200)]
pg_upgrade: Add missing gettext triggers

Forgot to add it in one place in the previous commit.

3 years agopg_upgrade: Add missing gettext triggers
Peter Eisentraut [Mon, 16 May 2022 06:55:01 +0000 (08:55 +0200)]
pg_upgrade: Add missing gettext triggers

prep_status_progress() is new.

3 years agoFix incorrect row estimates used for Memoize costing
David Rowley [Mon, 16 May 2022 04:07:56 +0000 (16:07 +1200)]
Fix incorrect row estimates used for Memoize costing

In order to estimate the cache hit ratio of a Memoize node, one of the
inputs we require is the estimated number of times the Memoize node will
be rescanned.  The higher this number, the large the cache hit ratio is
likely to become.  Unfortunately, the value being passed as the number of
"calls" to the Memoize was incorrectly using the Nested Loop's
outer_path->parent->rows instead of outer_path->rows.  This failed to
account for the fact that the outer_path might be parameterized by some
upper-level Nested Loop.

This problem could lead to Memoize plans appearing more favorable than
they might actually be.  It could also lead to extended executor startup
times when work_mem values were large due to the planner setting overly
large MemoizePath->est_entries resulting in the Memoize hash table being
initially made much larger than might be required.

Fix this simply by passing outer_path->rows rather than
outer_path->parent->rows.  Also, adjust the expected regression test
output for a plan change.

Reported-by: Pavel Stehule
Author: David Rowley
Discussion: https://postgr.es/m/CAFj8pRAMp%3DQsMi6sPQJ4W3hczoFJRvyXHJV3AZAZaMyTVM312Q%40mail.gmail.com
Backpatch-through: 14, where Memoize was introduced

3 years agoAdd link to HBA docs in initdb --auth documentation
Alvaro Herrera [Sat, 14 May 2022 07:57:03 +0000 (09:57 +0200)]
Add link to HBA docs in initdb --auth documentation

Reaction to a suggestion from jhebert@micron.com, though this doesn't
directly address the complaint.

Discussion: https://postgr.es/m/165117307860.683.10308862820133754390@wrigleys.postgresql.org

3 years agoAdd link to initdb in pg_hba.conf docs
Alvaro Herrera [Sat, 14 May 2022 07:03:16 +0000 (09:03 +0200)]
Add link to initdb in pg_hba.conf docs

Suggested by David G. Johnston <david.g.johnston@gmail.com>

Discussion: https://postgr.es/m/CAKFQuwYK4OqwoHscZi3yws-urv3NvVfoKHessyso5D=5qqChYQ@mail.gmail.com

3 years agoFix slow animal timeouts in 032_relfilenode_reuse.pl.
Thomas Munro [Fri, 13 May 2022 23:58:10 +0000 (11:58 +1200)]
Fix slow animal timeouts in 032_relfilenode_reuse.pl.

Per BF animal chipmunk:  CREATE DATABASE could apparently fail due to an
AV process being in the template database and not quitting fast enough
for the 5 second timeout in CountOtherDBBackends().  The test script had
autovacuum_naptime=1s to encourage more activity and opening of fds, but
that wasn't strictly necessary for this test.  Take it out.

Per BF animal skink:  there was a 300s timeout for all tests in the
script, but apparently that was not enough under valgrind.  Let's use
the standard timeout $PostgreSQL::Test::Utils::timeout_default, but
restart it for each query we run.

Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGKa8HNJaA24gqiiFoGy0ysndeVoJsHvX_q1-DVLFaGAmw%40mail.gmail.com

3 years agoFix comment in pg_proc.c
Michael Paquier [Fri, 13 May 2022 23:27:59 +0000 (08:27 +0900)]
Fix comment in pg_proc.c

pgstat_create_function() creates stats for a function in a transactional
fashion, so the stats would be dropped if transaction creating the
function is aborted, not committed.

Author: Amul Sul
Discussion: https://postgr.es/m/CAAJ_b97x1T3xgAMWNj4w7kSgN0nTuG-vLrQJ4NB-dsNr0Kudxw@mail.gmail.com

3 years agoClean up newlines following left parentheses
Alvaro Herrera [Fri, 13 May 2022 21:52:35 +0000 (23:52 +0200)]
Clean up newlines following left parentheses

Like commit c9d297751959.

3 years agorelnotes: add null logical replication item
Bruce Momjian [Fri, 13 May 2022 15:50:24 +0000 (11:50 -0400)]
relnotes:  add null logical replication item

Also move system view item to logical replication, mention "infinite
_error_ loops".

Reported-by: Euler Taveira, Takamichi Osumi, Amit Langote
Discussion: https://postgr.es/m/21e8ef3b-6ffb-49d8-867f-4622a4dffcf3@www.fastmail.com

3 years agoRename JsonIsPredicate.value_type, fix JSON backend/nodes/ infrastructure.
Tom Lane [Fri, 13 May 2022 15:40:01 +0000 (11:40 -0400)]
Rename JsonIsPredicate.value_type, fix JSON backend/nodes/ infrastructure.

I started out with the intention to rename value_type to item_type to
avoid a collision with a typedef name that appears on some platforms.

Along the way, I noticed that the adjacent field "format" was not being
correctly handled by the backend/nodes/ infrastructure functions:
copyfuncs.c erroneously treated it as a scalar, while equalfuncs,
outfuncs, and readfuncs omitted handling it at all.  This looks like
it might be cosmetic at the moment because the field is always NULL
after parse analysis; but that's likely a bug in itself, and the code's
certainly not very future-proof.  Let's fix it while we can still do so
without forcing an initdb on beta testers.

Further study found a few other inconsistencies in the backend/nodes/
infrastructure for the recently-added JSON node types, so fix those too.

catversion bumped because of potential change in stored rules.

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

3 years agoIndent protocol.sgml
Peter Eisentraut [Fri, 13 May 2022 14:14:16 +0000 (16:14 +0200)]
Indent protocol.sgml

protocol.sgml had some unusual indentation that kept getting added on
to with new additions in that file.  This reindents it to be more in
line with the style elsewhere.

Discussion: https://www.postgresql.org/message-id/flat/15113594-649b-ce82-24c8-7522f1373da4%40enterprisedb.com

3 years agoAdd a new shmem_request_hook hook.
Robert Haas [Fri, 13 May 2022 13:31:06 +0000 (09:31 -0400)]
Add a new shmem_request_hook hook.

Currently, preloaded libraries are expected to request additional
shared memory and LWLocks in _PG_init().  However, it is not unusal
for such requests to depend on MaxBackends, which won't be
initialized at that time.  Such requests could also depend on GUCs
that other modules might change.  This introduces a new hook where
modules can safely use MaxBackends and GUCs to request additional
shared memory and LWLocks.

Furthermore, this change restricts requests for shared memory and
LWLocks to this hook.  Previously, libraries could make requests
until the size of the main shared memory segment was calculated.
Unlike before, we no longer silently ignore requests received at
invalid times.  Instead, we FATAL if someone tries to request
additional shared memory or LWLocks outside of the hook.

Nathan Bossart and Julien Rouhaud

Discussion: https://postgr.es/m/20220412210112.GA2065815%40nathanxps13
Discussion: https://postgr.es/m/Yn2jE/lmDhKtkUdr@paquier.xyz

3 years agoDoc: Improve description of the "parallel_commit" option for postgres_fdw.
Etsuro Fujita [Fri, 13 May 2022 09:30:00 +0000 (18:30 +0900)]
Doc: Improve description of the "parallel_commit" option for postgres_fdw.

It wasn't very clear that if this option was enabled, postgres_fdw would
commit remote transactions in parallel at main-transaction end, and
commit remote subtransactions in parallel at subtransaction end, due to
the references to (sub)transaction and other too specific documentation.
Clarify that.  Also reword to simplify.

Follow-up for commit 04e706d42.

Jonathan S. Katz, reviewed by Justin Pryzby, with some modifications by
me.

Discussion: https://postgr.es/m/1435bfd1-172b-de38-f590-4404a5a62eb0%40postgresql.org

3 years agoIndent C code in flex and bison files
Peter Eisentraut [Fri, 13 May 2022 05:17:29 +0000 (07:17 +0200)]
Indent C code in flex and bison files

In the style of pgindent, done semi-manually.

Discussion: https://www.postgresql.org/message-id/flat/7d062ecc-7444-23ec-a159-acd8adf9b586%40enterprisedb.com

3 years agoDon't report stats in LogicalRepApplyLoop() when in xact.
Andres Freund [Fri, 13 May 2022 01:49:33 +0000 (18:49 -0700)]
Don't report stats in LogicalRepApplyLoop() when in xact.

pgstat_report_stat() is only supposed to be called outside of transactions. In
5891c7a8ed8 I added a pgstat_report_stat() call into LogicalRepApplyLoop()'s
timeout branch. While not commonly reached inside a transaction, it is
reachable (e.g. due to network bottlenecks or the sender being stalled / slow
for some reason).

To fix, add a !IsTransactionState() check.

No test added because there's no easy way to reproduce this case without
patching the code.

Reported-By: Erik Rijkers <er@xs4all.nl>
Discussion: https://postgr.es/m/b3463b8c-2328-dcac-0136-af95715493c1@xs4all.nl

3 years agoRemove PGDLLIMPORT marker from __pg_log_level
Michael Paquier [Fri, 13 May 2022 00:39:13 +0000 (09:39 +0900)]
Remove PGDLLIMPORT marker from __pg_log_level

Per discussion with Tom Lane and Andres Freund.  I have misunderstood
the intention behind the choice done in 9a374b7.

Discussion: https://postgr.es/m/20220512153737.6kbbcf4qyvwgq4s2@alap3.anarazel.de

3 years agoRemove function declaration for function in pg_proc.
Andres Freund [Thu, 12 May 2022 16:25:14 +0000 (09:25 -0700)]
Remove function declaration for function in pg_proc.

The declaration is automatically generated. Noticed when experimenting with
adding PGDLLIMPORT markers for functions.

Discussion: https://postgr.es/m/20220512164513.vaheofqp2q24l65r@alap3.anarazel.de

3 years agoAdd missing binary_upgrade.h includes.
Andres Freund [Thu, 12 May 2022 16:20:36 +0000 (09:20 -0700)]
Add missing binary_upgrade.h includes.

A few places used binary_upgrade_* variables without including the header,
which worked without warnings because the variables are defined in those
places. However that can cause linker complaints with MSVC - except that we
don't see them right now, due to the use of a symbol export file.

Discussion: https://postgr.es/m/20220512164513.vaheofqp2q24l65r@alap3.anarazel.de

3 years agoAdd 'static' to file-local variables missing it.
Andres Freund [Thu, 12 May 2022 16:19:04 +0000 (09:19 -0700)]
Add 'static' to file-local variables missing it.

Noticed when comparing the set of exported symbols without / with
-fvisibility=hidden after adding PGDLLIMPORT to intentionally exported
symbols.

Discussion: https://postgr.es/m/20220512164513.vaheofqp2q24l65r@alap3.anarazel.de

3 years agoAdd missing 'extern' to function prototypes.
Andres Freund [Thu, 12 May 2022 16:17:14 +0000 (09:17 -0700)]
Add missing 'extern' to function prototypes.

Postgres style is to spell out extern. Noticed while scripting adding
PGDLLIMPORT markers to functions.

Discussion: https://postgr.es/m/20220512164513.vaheofqp2q24l65r@alap3.anarazel.de

3 years agoDo pre-release housekeeping on catalog data.
Tom Lane [Thu, 12 May 2022 19:35:15 +0000 (15:35 -0400)]
Do pre-release housekeeping on catalog data.

Run renumber_oids.pl to move high-numbered OIDs down, as per pre-beta
tasks specified by RELEASE_CHANGES.  For reference, the command was

./renumber_oids.pl --first-mapped-oid 8000 --target-oid 6205

3 years agoAdd 23e7b38bf to git-blame-ignore-revs.
Tom Lane [Thu, 12 May 2022 19:22:20 +0000 (15:22 -0400)]
Add 23e7b38bf to git-blame-ignore-revs.

3 years agoPre-beta mechanical code beautification.
Tom Lane [Thu, 12 May 2022 19:17:30 +0000 (15:17 -0400)]
Pre-beta mechanical code beautification.

Run pgindent, pgperltidy, and reformat-dat-files.
I manually fixed a couple of comments that pgindent uglified.

3 years agolibpq: drop pending pipelined commands in pqDropConnection().
Tom Lane [Thu, 12 May 2022 16:42:29 +0000 (12:42 -0400)]
libpq: drop pending pipelined commands in pqDropConnection().

The original coding did this in pqDropServerData(), which seems
fairly backwards.  Pending commands are more like already-queued
output data, which is dropped in pqDropConnection().  Moving the
operation means that we clear the command queue immediately upon
detecting connection drop, which improves the sanity of subsequent
behavior.  In particular this eliminates duplicated error message
text as a consequence of code added in b15f25446, which supposed
that a nonempty command queue must mean the prior operation is
still active.

There might be an argument for backpatching this to v14; but as with
b15f25446, I'm unsure about interactions with 618c16707.  For now,
given the lack of complaints about v14's behavior, leave it alone.

Per report from Peter Eisentraut.

Discussion: https://postgr.es/m/de57761c-b99b-3435-b0a6-474c72b1149a@enterprisedb.com

3 years agoMark a few 'bbsink' related functions / variables static.
Andres Freund [Thu, 12 May 2022 16:10:03 +0000 (09:10 -0700)]
Mark a few 'bbsink' related functions / variables static.

Discussion: https://postgr.es/m/20220506234924.6mxxotl3xl63db3l@alap3.anarazel.de

3 years agoMake pull_var_clause() handle GroupingFuncs exactly like Aggrefs.
Tom Lane [Thu, 12 May 2022 15:31:46 +0000 (11:31 -0400)]
Make pull_var_clause() handle GroupingFuncs exactly like Aggrefs.

This follows in the footsteps of commit 2591ee8ec by removing one more
ill-advised shortcut from planning of GroupingFuncs.  It's true that
we don't intend to execute the argument expression(s) at runtime, but
we still have to process any Vars appearing within them, or we risk
failure at setrefs.c time (or more fundamentally, in EXPLAIN trying
to print such an expression).  Vars in upper plan nodes have to have
referents in the next plan level, whether we ever execute 'em or not.

Per bug #17479 from Michael J. Sullivan.  Back-patch to all supported
branches.

Richard Guo

Discussion: https://postgr.es/m/17479-6260deceaf0ad304@postgresql.org

3 years agorelnotes: adjust several logical replication items and FK text
Bruce Momjian [Thu, 12 May 2022 14:11:55 +0000 (10:11 -0400)]
relnotes:  adjust several logical replication items and FK text

Reported-by: Amit Langote, Amit Kapila, Takamichi Osumi
Discussion: https://postgr.es/m/CAA4eK1KdAho_fNkYRe=o=XpxWs_TG4O0V8CJBAvTG8HamWt6OQ@mail.gmail.com

3 years agopostgres_fdw: Update comments in make_new_connection().
Etsuro Fujita [Thu, 12 May 2022 08:30:00 +0000 (17:30 +0900)]
postgres_fdw: Update comments in make_new_connection().

Expand the comment about the parallel_commit option to mention that the
default is false.

Also, since the comment about alteration of the keep_connections option,
which was located above the expanded comment, holds true for the
parallel_commit option, rewrite it to reflect this, and move it to after
the expanded comment.

Follow-up for commit 04e706d42.

Discussion: https://postgr.es/m/CAPmGK16Kg2Bf90sqzcZ4YM5cN_G-4h7wFUS01qQpqNB%2B2BG5_w%40mail.gmail.com

3 years agoAdd some missing PGDLLIMPORT markings
Michael Paquier [Thu, 12 May 2022 06:08:45 +0000 (15:08 +0900)]
Add some missing PGDLLIMPORT markings

Three variables in pqsignal.h (UnBlockSig, BlockSig and StartupBlockSig)
were not marked with PGDLLIMPORT, as they are declared in a way that
prevents mark_pgdllimport.pl to detect them.  These variables are
redefined in a style more consistent with the other headers, allowing
the script to find and mark them.

PGDLLIMPORT was missing for __pg_log_level in logging.h, so add it
back.  The marking got accidentally removed in 9a374b77, just after its
addition in 8ec5694.

While on it, add a comment in mark_pgdllimport.pl explaining what are
the arguments needed by the script (aka a list of header paths).

Reported-by: Andres Freund
Discussion: https://postgr.es/m/20220506234924.6mxxotl3xl63db3l@alap3.anarazel.de

3 years agorelnotes: mention non-exclusive backup mode was deprecated
Bruce Momjian [Thu, 12 May 2022 02:46:36 +0000 (22:46 -0400)]
relnotes:  mention non-exclusive backup mode was deprecated

Reported-by: Ian Lawrence Barwick
Discussion: https://postgr.es/m/CAB8KJ=j9VhsFXuN+xv5qzxQV7gj-6TKqqwVLSgz5zU7F8nHCYw@mail.gmail.com

3 years agoUse correct datum macros in more tuplesort specialization functions.
John Naylor [Thu, 12 May 2022 02:18:21 +0000 (09:18 +0700)]
Use correct datum macros in more tuplesort specialization functions.

Also clarify that ApplySignedSortComparator() is not built on 32-bit machines.

Folow-up to c90c16591

Reviewed-by: David Rowley
Discussion: https://www.postgresql.org/message-id/CAFBsxsFmt4_JUP8XgSJqwaAS9a9s8K8_PvMu%3Dj%3DDfwU%3D8QjNPw%40mail.gmail.com

3 years agorelnotes: add author to in-memory sorts item
Bruce Momjian [Thu, 12 May 2022 02:19:12 +0000 (22:19 -0400)]
relnotes:  add author to in-memory sorts item

Reported-by: Thomas Munro
Discussion: https://postgr.es/m/CA+hUKGKha50-H2ye-9x3PJWU5wBq_MPc2rmVKM1xJ0tL+ntROw@mail.gmail.com

3 years agorelnotes: update for non-exclusive backup mode removal
Bruce Momjian [Thu, 12 May 2022 02:01:46 +0000 (22:01 -0400)]
relnotes:  update for non-exclusive backup mode removal

Reported-by: Ian Lawrence Barwick
Discussion: https://postgr.es/m/CAB8KJ=jmLBMAmxjcew12-yntb7m3FH-8A2+Qb7+RybZp1w9GOg@mail.gmail.com

3 years agorelnote: improve sorting entries
Bruce Momjian [Thu, 12 May 2022 00:55:01 +0000 (20:55 -0400)]
relnote:  improve sorting entries

Reported-by: David Rowley
Discussion: https://postgr.es/m/CAApHDvrToHFvL-W03vSi6T50uScyhrdUGzTtcuLAjdjtRF8FLA@mail.gmail.com

3 years agoRemove non-functional code for unloading loadable modules.
Robert Haas [Wed, 11 May 2022 19:27:33 +0000 (15:27 -0400)]
Remove non-functional code for unloading loadable modules.

The code for unloading a library has been commented-out for over 12
years, ever since commit 602a9ef5a7c60151e10293ae3c4bb3fbb0132d03, and we're
no closer to supporting it now than we were back then.

Nathan Bossart, reviewed by Michael Paquier and by me.

Discussion: http://postgr.es/m/Ynsc9bRL1caUSBSE@paquier.xyz

3 years agorelnotes: adjustments from Álvaro Herrera
Bruce Momjian [Wed, 11 May 2022 15:28:29 +0000 (11:28 -0400)]
relnotes:  adjustments from Álvaro Herrera

Reported-by: Álvaro Herrera
Discussion: https://postgr.es/m/202205111412.n7xgu3eppins@alvherre.pgsql

3 years agorelnotes: update foreign key partition and add sort items
Bruce Momjian [Wed, 11 May 2022 14:45:17 +0000 (10:45 -0400)]
relnotes:  update foreign key partition and add sort items

Reported-by: David Rowley, Amit Langote
Discussion: https://postgr.es/m/CA+HiwqFcEdbNinfK94aTgBJKmtkYGdtkPnjt3b0fVzKi+WZ+KA@mail.gmail.com

3 years agoFix typos and grammar in code and test comments
Michael Paquier [Wed, 11 May 2022 06:38:55 +0000 (15:38 +0900)]
Fix typos and grammar in code and test comments

This fixes the grammar of some comments in a couple of tests (SQL and
TAP), and in some C files.

Author: Justin Pryzby
Discussion: https://postgr.es/m/20220511020334.GH19626@telsasoft.com

3 years agoAdd logging for excessive ProcSignalBarrier waits.
Thomas Munro [Wed, 11 May 2022 06:03:03 +0000 (18:03 +1200)]
Add logging for excessive ProcSignalBarrier waits.

To enable diagnosis of systems that are not processing ProcSignalBarrier
requests promptly, add a LOG message every 5 seconds if we seem to be
wedged.  Although you could already see this state as a wait event in
pg_stat_activity, the log message also shows the PID of the process that
is preventing progress.

Also add DEBUG1 logging around the whole wait loop.

Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/CA%2BTgmoYJ03r5359gQutRGP9BtigYCg3_UskcmnVjBf-QO3-0pQ%40mail.gmail.com

3 years agoFix the logical replication timeout during large transactions.
Amit Kapila [Wed, 11 May 2022 05:41:44 +0000 (11:11 +0530)]
Fix the logical replication timeout during large transactions.

The problem is that we don't send keep-alive messages for a long time
while processing large transactions during logical replication where we
don't send any data of such transactions. This can happen when the table
modified in the transaction is not published or because all the changes
got filtered. We do try to send the keep_alive if necessary at the end of
the transaction (via WalSndWriteData()) but by that time the
subscriber-side can timeout and exit.

To fix this we try to send the keepalive message if required after
processing certain threshold of changes.

Reported-by: Fabrice Chapuis
Author: Wang wei and Amit Kapila
Reviewed By: Masahiko Sawada, Euler Taveira, Hou Zhijie, Hayato Kuroda
Backpatch-through: 10
Discussion: https://postgr.es/m/CAA5-nLARN7-3SLU_QUxfy510pmrYK6JJb=bk3hcgemAM_pAv+w@mail.gmail.com

3 years agoSilence extra logging when using "postgres -C" on runtime-computed GUCs
Michael Paquier [Wed, 11 May 2022 05:21:06 +0000 (14:21 +0900)]
Silence extra logging when using "postgres -C" on runtime-computed GUCs

Presently, the server may emit a variety of log messages when inspecting
a runtime-computed GUC, mostly in the shape of one LOG message with the
default configuration, related to the startup sequence launched as such
GUCs require a load of the control file and of external shared
libraries.

For example, the server will always emit a "database system is shut
down" LOG (unless the user has set log_min_messages higher than LOG),
which is an annoying behavior as "postgres -C" is expected to only emit
in its output the parameter value we are looking for.  The parameter
value is sent to stdout, while the logs are sent to stderr so we could
recommend to use a redirection, but there was not much love for this
workaround either.

To avoid such extra log messages, per discussion, this change sets
log_min_messages to FATAL internally when -C is used on a
runtime-computed GUC (even if set to PANIC in postgresql.conf).  At
FATAL, the user will still receive messages explaining why a GUC value
cannot be inspected, and will know if the command is attempted on a
server already running, something not supported yet for a
runtime-computed GUC.

Reported-by: Magnus Hagander, Bruce Momjian
Author: Nathan Bossart, Michael Paquier
Discussion: https://postgr.es/m/Yni6ZHkGotUU+RSf@paquier.xyz