Alexander Korotkov [Sat, 20 Jun 2020 10:34:54 +0000 (13:34 +0300)]
Add documentation for opclass options
911e7020770 added opclass options and adjusted documentation for each
particular affected opclass. However, documentation for extendability was
not adjusted. This commit adjusts documentation for interfaces of index AMs
and opclasses.
Discussion: https://postgr.es/m/CAH2-WzmQnW6%2Bz5F9AW%2BSz%2BzEcEvXofTwh_A9J3%3D_WA-FBP0wYg%40mail.gmail.com
Author: Alexander Korotkov
Reported-by: Peter Geoghegan
Reviewed-by: Peter Geoghegan
Noah Misch [Sat, 20 Jun 2020 08:25:40 +0000 (01:25 -0700)]
Remove dead forceSync parameter of XactLogCommitRecord().
The function has been reading global variable forceSyncCommit, mirroring
the intent of the caller that passed forceSync=forceSyncCommit. The
other caller, RecordTransactionCommitPrepared(), passed false. Since
COMMIT PREPARED can't share a transaction with any command, it certainly
doesn't share a transaction with a command that sets forceSyncCommit.
Reviewed by Michael Paquier.
Discussion: https://postgr.es/m/
20200617032615[email protected]
Amit Kapila [Sat, 20 Jun 2020 03:48:57 +0000 (09:18 +0530)]
Removal unused function parameter in CopyReadBinaryAttribute.
The function parameter column_no is not used in CopyReadBinaryAttribute,
this can be removed.
Commit
0e319c7ad7 removed the usage of column_no parameter in function
CopyReadBinaryAttribute but forgot to remove the parameter.
Reported-by: Vignesh C
Author: Vignesh C
Discussion: https://postgr.es/m/CALDaNm1TYSNTfqx_jfz9_mwEZ2Er=dZnu++duXpC1uQo1cG=WA@mail.gmail.com
Alvaro Herrera [Fri, 19 Jun 2020 20:46:07 +0000 (16:46 -0400)]
Ensure write failure reports no-disk-space
A few places calling fwrite and gzwrite were not setting errno to ENOSPC
when reporting errors, as is customary; this led to some failures being
reported as
"could not write file: Success"
which makes us look silly. Make a few of these places in pg_dump and
pg_basebackup use our customary pattern.
Backpatch-to: 9.5
Author: Justin Pryzby <
[email protected]>
Author: Tom Lane <
[email protected]>
Author: Álvaro Herrera <
[email protected]>
Discussion: https://postgr.es/m/
20200611153753[email protected]
Tom Lane [Fri, 19 Jun 2020 17:55:21 +0000 (13:55 -0400)]
Future-proof regression tests against possibly-missing posixrules file.
The IANA time zone folk have deprecated use of a "posixrules" file in
the tz database. While for now it's our choice whether to keep
supplying one in our own builds, installations built with
--with-system-tzdata will soon be needing to cope with that file not
being present, at least on some platforms.
This causes a problem for the horology test, which expected the
nonstandard POSIX zone spec "CST7CDT" to apply pre-2007 US daylight
savings rules. That does happen if the posixrules file supplies such
information, but otherwise the test produces undesired results.
To fix, add an explicit transition date rule that matches 2005 practice.
(We could alternatively have switched the test to use some real time
zone, but it seems useful to have coverage of this type of zone spec.)
While at it, update a documentation example that also relied on
"CST7CDT"; use a real-world zone name instead. Also, document why
the zone names EST5EDT, CST6CDT, MST7MDT, PST8PDT aren't subject to
similar failures when "posixrules" is missing.
Back-patch to all supported branches, since the hazard is the same
for all.
Discussion: https://postgr.es/m/
1665379.
1592581287@sss.pgh.pa.us
Alvaro Herrera [Fri, 19 Jun 2020 16:55:43 +0000 (12:55 -0400)]
Adjust some glossary terms
Mostly in response to Jürgen Purtz critique of previous definitions,
though I added many other changes.
Author: Álvaro Herrera <
[email protected]>
Reviewed-by: Jürgen Purtz <[email protected]>
Reviewed-by: Justin Pryzby <[email protected]>
Reviewed-by: Erik Rijkers <[email protected]>
Discussion: https://postgr.es/m/
c1e06008-2132-30f4-9b38-
877e8683d418@purtz.de
Peter Geoghegan [Fri, 19 Jun 2020 15:57:24 +0000 (08:57 -0700)]
Fix deduplication "single value" strategy bug.
It was possible for deduplication's single value strategy to mistakenly
believe that a very small duplicate tuple counts as one of the six large
tuples that it aims to leave behind after the page finally splits. This
could cause slightly suboptimal space utilization with very low
cardinality indexes, though only under fairly narrow conditions.
To fix, be particular about what kind of tuple counts as a
maxpostingsize-capped tuple. This avoids confusion in the event of a
small tuple that gets "wedged" between two large tuples, where all
tuples on the page are duplicates of the same value.
Discussion: https://postgr.es/m/CAH2-Wz=Y+sgSFc-O3LpiZX-POx2bC+okec2KafERHuzdVa7-rQ@mail.gmail.com
Backpatch: 13-, where deduplication was introduced (by commit
0d861bbb)
Fujii Masao [Fri, 19 Jun 2020 08:15:52 +0000 (17:15 +0900)]
Fix issues in invalidation of obsolete replication slots.
This commit fixes the following issues.
1. There is the case where the slot is dropped while trying to invalidate it.
InvalidateObsoleteReplicationSlots() did not handle this case, and
which could cause checkpoint to fail.
2. InvalidateObsoleteReplicationSlots() could emit the same log message
multiple times unnecessary. It should be logged only once.
3. When marking the slot as used, we always searched the target slot from
all the replication slots even if we already found it. This could cause
useless waste of cycles.
Back-patch to v13 where these issues were added as a part of
max_slot_wal_keep_size code.
Author: Fujii Masao
Reviewed-by: Kyotaro Horiguchi, Alvaro Herrera
Discussion: https://postgr.es/m/
66c05b67-3396-042c-1b41-
bfa6c3ddcf82@oss.nttdata.com
David Rowley [Fri, 19 Jun 2020 05:24:27 +0000 (17:24 +1200)]
Fix EXPLAIN ANALYZE for parallel HashAgg plans
Since
1f39bce02, HashAgg nodes have had the ability to spill to disk when
memory consumption exceeds work_mem. That commit added new properties to
EXPLAIN ANALYZE to show the maximum memory usage and disk usage, however,
it didn't quite go as far as showing that information for parallel
workers. Since workers may have experienced something very different from
the main process, we should show this information per worker, as is done
in Sort.
Reviewed-by: Justin Pryzby
Reviewed-by: Jeff Davis
Discussion: https://postgr.es/m/CAApHDvpEKbfZa18mM1TD7qV6PG+w97pwCWq5tVD0dX7e11gRJw@mail.gmail.com
Backpatch-through: 13, where the hashagg spilling code was added.
Andres Freund [Fri, 19 Jun 2020 02:40:09 +0000 (19:40 -0700)]
Clean up includes of s_lock.h.
Users of spinlocks should use spin.h, not s_lock.h. And lwlock.h
hasn't utilized spinlocks for quite a while.
Discussion: https://postgr.es/m/
20200618183041[email protected]
Andres Freund [Mon, 8 Jun 2020 23:50:37 +0000 (16:50 -0700)]
Fix deadlock danger when atomic ops are done under spinlock.
This was a danger only for --disable-spinlocks in combination with
atomic operations unsupported by the current platform.
While atomics.c was careful to signal that a separate semaphore ought
to be used when spinlock emulation is active, spin.c didn't actually
implement that mechanism. That's my (Andres') fault, it seems to have
gotten lost during the development of the atomic operations support.
Fix that issue and add test for nesting atomic operations inside a
spinlock.
Author: Andres Freund
Discussion: https://postgr.es/m/
20200605023302[email protected]
Backpatch: 9.5-
Andres Freund [Mon, 8 Jun 2020 23:36:51 +0000 (16:36 -0700)]
Add basic spinlock tests to regression tests.
As s_lock_test, the already existing test for spinlocks, isn't run in
an automated fashion (and doesn't test a normal backend environment),
adding tests that are run as part of a normal regression run is a good
idea. Particularly in light of several recent and upcoming spinlock
related fixes.
Currently the new tests are run as part of the pre-existing
test_atomic_ops() test. That perhaps can be quibbled about, but for
now seems ok.
The only operations that s_lock_test tests but the new tests don't are
the detection of a stuck spinlock and S_LOCK_FREE (which is otherwise
unused, not implemented on all platforms, and will be removed).
This currently contains a test for more than INT_MAX spinlocks (only
run with --disable-spinlocks), to ensure the recent commit fixing a
bug with more than INT_MAX spinlock initializations is correct. That
test is somewhat slow, so we might want to disable it after a few
days.
It might be worth retiring s_lock_test after this. The added coverage
of a stuck spinlock probably isn't worth the added complexity?
Author: Andres Freund
Discussion: https://postgr.es/m/
20200606023103[email protected]
Tom Lane [Thu, 18 Jun 2020 20:27:18 +0000 (16:27 -0400)]
Doc: document POSIX-style time zone specifications in full.
We'd glossed over most of this complexity for years, but it's hard
to avoid writing it all down now, so that we can explain what happens
when there's no "posixrules" file in the IANA time zone database.
That was at best a tiny minority situation till now, but it's likely
to become quite common in the future, so we'd better explain it.
Nonetheless, we don't really encourage people to use POSIX zone specs;
picking a named zone is almost always what you really want, unless
perhaps you're stuck with an out-of-date zone database. Therefore,
let's shove all this detail into an appendix.
Patch by me; thanks to Robert Haas for help with some awkward wording.
Discussion: https://postgr.es/m/1390.
1562258309@sss.pgh.pa.us
Michael Paquier [Thu, 18 Jun 2020 07:34:59 +0000 (16:34 +0900)]
Fix oldest xmin and LSN computation across repslots after advancing
Advancing a replication slot did not recompute the oldest xmin and LSN
values across replication slots, preventing resource removal like
segments not recycled at checkpoint time. The original commit that
introduced the slot advancing in
9c7d06d never did the update of those
oldest values, and
b0afdca removed this code.
This commit adds a TAP test to check segment recycling with advancing
for physical slots, enforcing an extra segment switch before advancing
to check if the segment gets correctly recycled after a checkpoint.
Reported-by: Andres Freund
Reviewed-by: Alexey Kondratov, Kyptaro Horiguchi
Discussion: https://postgr.es/m/
20200609171904[email protected]
Backpatch-through: 11
Peter Eisentraut [Thu, 18 Jun 2020 06:41:31 +0000 (08:41 +0200)]
Disallow factorial of negative numbers
The previous implementation returned 1 for all negative numbers, which
is not sensible under any definition.
Discussion: https://www.postgresql.org/message-id/flat/
6ce1df0e-86a3-e544-743a-
f357ff663f68%402ndquadrant.com
Peter Eisentraut [Thu, 18 Jun 2020 06:41:31 +0000 (08:41 +0200)]
Expand tests for factorial
Move from int4 to numeric test. (They were originally int4 functions,
but were reimplemented for numeric in
04a4821adef38155b7920ba9eb83c4c3c29156f8.) Add some tests for edge
cases.
Discussion: https://www.postgresql.org/message-id/flat/
6ce1df0e-86a3-e544-743a-
f357ff663f68%402ndquadrant.com
Michael Paquier [Thu, 18 Jun 2020 01:40:10 +0000 (10:40 +0900)]
Remove reset of testtablespace from pg_regress on Windows
testtablespace is an extra path used as tablespace location in the main
regression test suite, computed from --outputdir as defined by the
caller of pg_regress (current directory if undefined).
This special handling was introduced as of
f10589e to be specific to
MSVC, as we let pg_regress' Makefile handle this cleanup in other
environments. This moves the cleanup to the MSVC script running
regression tests instead where needed: check, installcheck and
upgradecheck. I have also checked this patch on MSVC with repeated runs
of each target.
Author: Kyotaro Horiguchi, Michael Paquier
Discussion: https://postgr.es/m/
20200219.142519.
437573253063431435[email protected]
Tom Lane [Wed, 17 Jun 2020 22:29:29 +0000 (18:29 -0400)]
Sync our copy of the timezone library with IANA release tzcode2020a.
This absorbs a leap-second-related bug fix in localtime.c, and
teaches zic to handle an expiration marker in the leapseconds file.
Neither are of any interest to us (for the foreseeable future
anyway), but we need to stay more or less in sync with upstream.
Also adjust some over-eager changes in the README from commit
957338418.
I have no intention of making changes that require C99 in this code,
until such time as all the live back branches require C99. Otherwise
back-patching will get too exciting.
For the same reason, absorb assorted whitespace and other cosmetic
changes from HEAD into the back branches; mostly this reflects use of
improved versions of pgindent.
All in all then, quite a boring update. But I figured I'd get it
done while I was looking at this code.
Peter Geoghegan [Wed, 17 Jun 2020 22:23:55 +0000 (15:23 -0700)]
Fix nbtree.h dedup state comment.
Oversight in commit
0d861bbb.
Andres Freund [Mon, 8 Jun 2020 22:25:49 +0000 (15:25 -0700)]
spinlock emulation: Fix bug when more than INT_MAX spinlocks are initialized.
Once the counter goes negative we ended up with spinlocks that errored
out on first use (due to check in tas_sema).
Author: Andres Freund
Reviewed-By: Robert Haas
Discussion: https://postgr.es/m/
20200606023103[email protected]
Backpatch: 9.5-
Andres Freund [Tue, 16 Jun 2020 01:23:10 +0000 (18:23 -0700)]
Avoid potential spinlock in a signal handler as part of global barriers.
On platforms without support for 64bit atomic operations where we also
cannot rely on 64bit reads to have single copy atomicity, such atomics
are implemented using a spinlock based fallback. That means it's not
safe to even read such atomics from within a signal handler (since the
signal handler might run when the spinlock already is held).
To avoid this issue defer global barrier processing out of the signal
handler. Instead of checking local / shared barrier generation to
determine whether to set ProcSignalBarrierPending, introduce
PROCSIGNAL_BARRIER and always set ProcSignalBarrierPending when
receiving such a signal. Additionally avoid redundant work in
ProcessProcSignalBarrier if ProcSignalBarrierPending is unnecessarily.
Also do a small amount of other polishing.
Author: Andres Freund
Reviewed-By: Robert Haas
Discussion: https://postgr.es/m/
20200609193723[email protected]
Backpatch: 13-, where the code was introduced.
Robert Haas [Wed, 17 Jun 2020 15:39:17 +0000 (11:39 -0400)]
Improve server code to read files as part of a base backup.
Don't use fread(), since that doesn't necessarily set errno. We could
use read() instead, but it's even better to use pg_pread(), which
allows us to avoid some extra calls to seek to the desired location in
the file.
Also, advertise a wait event while reading from a file, as we do for
most other places where we're reading data from files.
Patch by me, reviewed by Hamid Akhtar.
Discussion: http://postgr.es/m/CA+TgmobBw-3573vMosGj06r72ajHsYeKtksT_oTxH8XvTL7DxA@mail.gmail.com
Robert Haas [Wed, 17 Jun 2020 15:05:42 +0000 (11:05 -0400)]
Minor code cleanup for perform_base_backup().
Merge two calls to sendDir() that are exactly the same except for
the fifth argument. Adjust comments to match.
Also, don't bother checking whether tblspc_map_file is NULL. We
initialize it in all cases, so it can't be.
Patch by me, reviewed by Amit Kapila and Kyotaro Horiguchi.
Discussion: http://postgr.es/m/CA+TgmoYq+59SJ2zBbP891ngWPA9fymOqntqYcweSDYXS2a620A@mail.gmail.com
Robert Haas [Wed, 17 Jun 2020 14:57:34 +0000 (10:57 -0400)]
Don't export basebackup.c's sendTablespace().
Commit
72d422a5227ef6f76f412486a395aba9f53bf3f0 made xlog.c call
sendTablespace() with the 'sizeonly' argument set to true, which
required basebackup.c to export sendTablespace(). However, that's
kind of ugly, so instead defer the call to sendTablespace() until
basebackup.c regains control. That way, it can still be a static
function.
Patch by me, reviewed by Amit Kapila and Kyotaro Horiguchi.
Discussion: http://postgr.es/m/CA+TgmoYq+59SJ2zBbP891ngWPA9fymOqntqYcweSDYXS2a620A@mail.gmail.com
Peter Eisentraut [Wed, 17 Jun 2020 07:14:37 +0000 (09:14 +0200)]
Remove STATUS_WAITING
Add a separate enum for use in the locking APIs, which were the only
user.
Discussion: https://www.postgresql.org/message-id/flat/
a6f91ead-0ce4-2a34-062b-
7ab9813ea308%402ndquadrant.com
Tom Lane [Tue, 16 Jun 2020 20:41:11 +0000 (16:41 -0400)]
Doc: fix copy-and-pasteo in ecpg docs.
The synopsis for PGTYPESinterval_free() used the wrong name.
Discussion: https://postgr.es/m/
159231203030.679.
3061023914894071953@wrigleys.postgresql.org
Tom Lane [Tue, 16 Jun 2020 19:28:37 +0000 (15:28 -0400)]
Lobotomize test for float -Inf ^ -2, at least for now.
Per POSIX this case should produce +0, but buildfarm member fossa
(with icc (ICC) 19.0.5.281
20190815) is reporting -0. icc has a
boatload of unsafe floating-point optimizations, with a corresponding
boatload of not-too-well-documented compiler switches, and it seems our
default use of "-mp1" isn't whacking it hard enough to keep it from
misoptimizing the stanza in dpow() that checks whether y is odd.
There's nothing wrong with that code (seeing that no other buildfarm
member has trouble with it), so I'm content to blame this on the
compiler. But without access to the compiler I'm not going to guess at
what switches might be needed to fix it. For now, tweak the test case
so it will accept either -0 or +0 as a correct answer.
Discussion: https://postgr.es/m/
[email protected]
Peter Eisentraut [Tue, 16 Jun 2020 15:25:20 +0000 (17:25 +0200)]
Fix file reference in nls.mk
Broken by move of fe_archive.c to fe_utils.
Tom Lane [Tue, 16 Jun 2020 15:09:42 +0000 (11:09 -0400)]
In dpow(), remove redundant check for whether y is an integer.
I failed to notice that we don't really need to check for y being an
integer in the code path where x = -inf; we already did.
Also make some further cosmetic rearrangements in that spot in hopes
of dodging the seeming compiler bug that buildfarm member fossa is
hitting. And be consistent about declaring variables as "float8"
not "double", since the pre-existing variables in this function are
like that.
Discussion: https://postgr.es/m/
[email protected]
Thomas Munro [Tue, 16 Jun 2020 05:40:06 +0000 (17:40 +1200)]
Remove useless variable.
Thomas Munro [Tue, 16 Jun 2020 05:23:36 +0000 (17:23 +1200)]
Make BufFileWrite() void.
It now either returns after it wrote all the data you gave it, or raises
an error. Not done in back-branches, because it might cause problems
for external code.
Discussion: https://postgr.es/m/CA%2BhUKGJE04G%3D8TLK0DLypT_27D9dR8F1RQgNp0jK6qR0tZGWOw%40mail.gmail.com
Thomas Munro [Tue, 16 Jun 2020 01:50:56 +0000 (13:50 +1200)]
Fix buffile.c error handling.
Convert buffile.c error handling to use ereport. This fixes cases where
I/O errors were indistinguishable from EOF or not reported. Also remove
"%m" from error messages where errno would be bogus. While we're
modifying those strings, add block numbers and short read byte counts
where appropriate.
Back-patch to all supported releases.
Reported-by: Amit Khandekar <[email protected]>
Reviewed-by: Melanie Plageman <[email protected]>
Reviewed-by: Alvaro Herrera <[email protected]>
Reviewed-by: Robert Haas <[email protected]>
Reviewed-by: Ibrar Ahmed <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGJE04G%3D8TLK0DLypT_27D9dR8F1RQgNp0jK6qR0tZGWOw%40mail.gmail.com
Peter Eisentraut [Mon, 15 Jun 2020 06:51:46 +0000 (08:51 +0200)]
doc: Document factorial function
This has existed for a very long time, equivalent to the ! and !!
operators, but it was never documented.
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
6ce1df0e-86a3-e544-743a-
f357ff663f68%402ndquadrant.com
Bruce Momjian [Tue, 16 Jun 2020 00:59:40 +0000 (20:59 -0400)]
pg_upgrade: set vacuum_defer_cleanup_age to zero
Non-zero vacuum_defer_cleanup_age values cause pg_upgrade freezing of
the system catalogs to be incomplete, or do nothing. This will cause
the upgrade to fail in confusing ways.
Reported-by: Laurenz Albe
Discussion: https://postgr.es/m/
7d6f6c22ba05ce0c526e9e8b7bfa8105e7da45e6[email protected]
Backpatch-through: 9.5
Tom Lane [Mon, 15 Jun 2020 23:10:30 +0000 (19:10 -0400)]
Fix power() for large inputs yet more.
Buildfarm results for commit
e532b1d57 reveal the error in my thinking
about the unexpected-EDOM case. I'd supposed this was no longer really
a live issue, but it seems the fix for glibc's bug #3866 is not all that
old, and we still have at least one buildfarm animal (lapwing) with the
bug. Hence, resurrect essentially the previous logic (but, I hope, less
opaquely presented), and explain what it is we're really doing here.
Also, blindly try to fix fossa's failure by tweaking the logic that
figures out whether y is an odd integer when x is -inf. This smells
a whole lot like a compiler bug, but I lack access to icc to try to
pin it down. Maybe doing division instead of multiplication will
dodge the issue.
Discussion: https://postgr.es/m/
[email protected]
Robert Haas [Fri, 24 Apr 2020 14:38:10 +0000 (10:38 -0400)]
Assorted cleanup of tar-related code.
Introduce TAR_BLOCK_SIZE and replace many instances of 512 with
the new constant. Introduce function tarPaddingBytesRequired
and use it to replace numerous repetitions of (x + 511) & ~511.
Add preprocessor guards against multiple inclusion to pgtar.h.
Reformat the prototype for tarCreateHeader so it doesn't extend
beyond 80 characters.
Discussion: http://postgr.es/m/CA+TgmobWbfReO9-XFk8urR1K4wTNwqoHx_v56t7=T8KaiEoKNw@mail.gmail.com
Tom Lane [Mon, 15 Jun 2020 16:15:56 +0000 (12:15 -0400)]
Fix power() for infinity inputs some more.
Buildfarm results for commit
decbe2bfb show that AIX and illumos
have non-POSIX-compliant pow() functions, as do ancient NetBSD
and HPUX releases. While it's dubious how much we should care
about the latter two platforms, the former two are probably enough
reason to put in manual handling of infinite-input cases. Hence,
do so, and clean up the post-pow() error handling to reflect its
now-more-limited scope. (Notably, while we no longer expect to
ever see EDOM from pow(), report it as a domain error if we do.
The former coding had the net effect of expensively converting the
error to ERANGE, which seems highly questionable: if pow() wanted
to report ERANGE, it would have done so.)
Patch by me; thanks to Michael Paquier for review.
Discussion: https://postgr.es/m/
[email protected]
Michael Paquier [Mon, 15 Jun 2020 12:18:14 +0000 (21:18 +0900)]
Fix some comments referring to past features
Timestamp can only be an int64 since
b9d092c, and support for WITH OIDS
has been removed as of
578b229.
Author: Justin Pryzby
Discussion: https://postgr.es/m/
20200612023709[email protected]
Peter Eisentraut [Mon, 15 Jun 2020 08:47:59 +0000 (10:47 +0200)]
pg_dump: Unbreak dumping of aggregates from very old server versions
Recently broken by
d9fa17aa7c34dea66ce64da6fb4c643e75ba452c.
Peter Eisentraut [Mon, 15 Jun 2020 06:22:52 +0000 (08:22 +0200)]
Error message refactoring
Take some untranslatable things out of the message and replace by
format placeholders, to reduce translatable strings and reduce
translation mistakes.
Michael Paquier [Mon, 15 Jun 2020 06:26:51 +0000 (15:26 +0900)]
Bump catversion for ACL changes on replication origin functions
Oversight in
cc07264.
Reported-by: Tom Lane
Discussion: https://postgr.es/m/
1098356.
1592196242@sss.pgh.pa.us
Thomas Munro [Sun, 14 Jun 2020 23:33:13 +0000 (11:33 +1200)]
Doc: Add references for SI and SSI.
Our documentation failed to point out that REPEATABLE READ is really
snapshot isolation, which might be important to some users. Point to
the standard reference paper for this complicated topic.
Likewise, add a reference to the VLDB paper about PostgreSQL SSI, for
technical information about our SSI implementation and how it compares
to S2PL.
While here, add a note about catalog access using a lower isolation
level, per recent user complaint.
Back-patch to all releases.
Reported-by: Kyle Kingsbury <[email protected]>
Reviewed-by: Andres Freund <[email protected]>
Reviewed-by: Peter Geoghegan <[email protected]>
Reviewed-by: Tatsuo Ishii <[email protected]>
Discussion: https://postgr.es/m/
db7b729d-0226-d162-a126-
8a8ab2dc4443%40jepsen.io
Discussion: https://postgr.es/m/16454-
9408996bb1750faf%40postgresql.org
Tom Lane [Sun, 14 Jun 2020 15:00:07 +0000 (11:00 -0400)]
Fix behavior of exp() and power() for infinity inputs.
Previously, these functions tended to throw underflow errors for
negative-infinity exponents. The correct thing per POSIX is to
return 0, so let's do that instead. (Note that the SQL standard
is silent on such issues, as it lacks the concepts of either Inf
or NaN; so our practice is to follow POSIX whenever a corresponding
C-library function exists.)
Also, add a bunch of test cases verifying that exp() and power()
actually do follow POSIX for Inf and NaN inputs. While this patch
should guarantee that exp() passes the tests, power() will not unless
the platform's pow(3) is fully POSIX-compliant. I already know that
gaur fails some of the tests, and I am suspicious that the Windows
animals will too; the extent of compliance of other old platforms
remains to be seen. We might choose to drop failing test cases, or
to work harder at overriding pow(3) for these cases, but first let's
see just how good or bad the situation is.
Discussion: https://postgr.es/m/582552.
1591917752@sss.pgh.pa.us
Peter Eisentraut [Sun, 14 Jun 2020 05:48:15 +0000 (07:48 +0200)]
Add test coverage for EXTRACT()
The variants for time and timetz had zero test coverage, the variant
for interval only very little. This adds practically full coverage
for those functions.
Reviewed-by: Vik Fearing <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
c3306ac7-fcae-a1b8-1e30-
6a379d605bcb%402ndquadrant.com
Michael Paquier [Sun, 14 Jun 2020 03:40:37 +0000 (12:40 +0900)]
Replace superuser check by ACLs for replication origin functions
This patch removes the hardcoded check for superuser privileges when
executing replication origin functions. Instead, execution is revoked
from public, meaning that those functions can be executed by a superuser
and that access to them can be granted.
Author: Martín Marqués
Reviewed-by: Kyotaro Horiguchi, Michael Paquier, Masahiko Sawada
Discussion: https:/postgr.es/m/CAPdiE1xJMZOKQL3dgHMUrPqysZkgwzSMXETfKkHYnBAB7-0VRQ@mail.gmail.com
Tom Lane [Sat, 13 Jun 2020 18:01:46 +0000 (14:01 -0400)]
Sync behavior of var_samp and stddev_samp for single NaN inputs.
var_samp(numeric) and stddev_samp(numeric) disagreed with their float
cousins about what to do for a single non-null input value that is NaN.
The float versions return NULL on the grounds that the calculation is
only defined for more than one non-null input, which seems like the
right answer. But the numeric versions returned NaN, as a result of
dealing with edge cases in the wrong order. Fix that. The patch
also gets rid of an insignificant memory leak in such cases.
This inconsistency is of long standing, but on the whole it seems best
not to back-patch the change into stable branches; nobody's complained
and it's such an obscure point that nobody's likely to complain.
(Note that v13 and v12 now contain test cases that will notice if we
accidentally back-patch this behavior change in future.)
Report and patch by me; thanks to Dean Rasheed for review.
Discussion: https://postgr.es/m/353062.
1591898766@sss.pgh.pa.us
Tom Lane [Sat, 13 Jun 2020 17:43:24 +0000 (13:43 -0400)]
Fix behavior of float aggregates for single Inf or NaN inputs.
When there is just one non-null input value, and it is infinity or NaN,
aggregates such as stddev_pop and covar_pop should produce a NaN
result, because the calculation is not well-defined. They used to do
so, but since we adopted Youngs-Cramer aggregation in commit
e954a727f,
they produced zero instead. That's an oversight, so fix it. Add tests
exercising these edge cases.
Affected aggregates are
var_pop(double precision)
stddev_pop(double precision)
var_pop(real)
stddev_pop(real)
regr_sxx(double precision,double precision)
regr_syy(double precision,double precision)
regr_sxy(double precision,double precision)
regr_r2(double precision,double precision)
regr_slope(double precision,double precision)
regr_intercept(double precision,double precision)
covar_pop(double precision,double precision)
corr(double precision,double precision)
Back-patch to v12 where the behavior change was accidentally introduced.
Report and patch by me; thanks to Dean Rasheed for review.
Discussion: https://postgr.es/m/353062.
1591898766@sss.pgh.pa.us
Peter Geoghegan [Sat, 13 Jun 2020 16:33:33 +0000 (09:33 -0700)]
Silence _bt_check_unique compiler warning.
Reported-By: Tom Lane
Discussion: https://postgr.es/m/841649.
1592065060@sss.pgh.pa.us
Peter Eisentraut [Sat, 13 Jun 2020 07:03:28 +0000 (09:03 +0200)]
Refactor AlterExtensionContentsStmt grammar
Make use of the general object support already used by COMMENT, DROP,
and SECURITY LABEL.
Discussion: https://www.postgresql.org/message-id/flat/
163c00a5-f634-ca52-fc7c-
0e53deda8735%402ndquadrant.com
Peter Eisentraut [Sat, 13 Jun 2020 07:03:28 +0000 (09:03 +0200)]
Grammar object type refactoring
Unify the grammar of COMMENT, DROP, and SECURITY LABEL further. They
all effectively just take an object address for later processing, so
we can make the grammar more generalized. Some extra checking about
which object types are supported can be done later in the statement
execution.
Discussion: https://www.postgresql.org/message-id/flat/
163c00a5-f634-ca52-fc7c-
0e53deda8735%402ndquadrant.com
Michael Paquier [Sat, 13 Jun 2020 05:04:56 +0000 (14:04 +0900)]
Create by default sql/ and expected/ for output directory in pg_regress
Using --outputdir with a custom output repository has never created by
default the sql/ and expected/ paths generated with contents from
respectively input/ and output/ if they don't exist, while the base
output directory gets created if it does not exist. If sql/ and
expected/ are not present, pg_regress would fail with the path missing,
requiring test scripts to create those extra paths by themselves. This
commit changes pg_regress so as both get created by default if they do
not exist, removing the need for external test scripts to do so.
This cleans up two code paths in the tree for pg_upgrade tests in MSVC
and environments able to use test.sh. sql/ and expected/ were created
as part of each test script, but this is not needed anymore as
pg_regress handles the work now.
Author: Roman Zharkov, Daniel Gustafsson
Reviewed-by: Michael Paquier, Tom Lane
Discussion: https://postgr.es/m/16484-
4d89e9cc11241996@postgresql.org
Michael Paquier [Sat, 13 Jun 2020 00:34:38 +0000 (09:34 +0900)]
Add more TAP tests for pg_dump options with range checks
This adds two tests for --extra-float-digits and --rows-per-insert,
similar to what exists for --compress.
Author: Dong Wook Lee
Discussion: https://postgr.es/m/CAAcByaJsgrB-qc-ALb0mALprRGLAdmcBap7SZxO4kCAU-JEHcQ@mail.gmail.com
David Rowley [Sat, 13 Jun 2020 00:32:00 +0000 (12:32 +1200)]
Have pg_itoa, pg_ltoa and pg_lltoa return the length of the string
Core by no means makes excessive use of these functions, but quite a large
number of those usages do require the caller to call strlen() on the
returned string. This is quite wasteful since these functions do already
have a good idea of the length of the string, so we might as well just
have them return that.
Reviewed-by: Andrew Gierth
Discussion: https://postgr.es/m/CAApHDvrm2A5x2uHYxsqriO2cUaGcFvND%2BksC9e7Tjep0t2RK_A%40mail.gmail.com
David Rowley [Fri, 12 Jun 2020 23:27:25 +0000 (11:27 +1200)]
Add missing extern keyword for a couple of numutils functions
In passing, also remove a few surplus empty lines from pg_ltoa and
pg_ulltoa_n in numutils.c
Reported-by: Andrew Gierth
Discussion: https://postgr.es/m/
[email protected]
Backpatch-through: 13, where these changes were introduced
Tom Lane [Fri, 12 Jun 2020 16:14:32 +0000 (12:14 -0400)]
Avoid using a cursor in plpgsql's RETURN QUERY statement.
plpgsql has always executed the query given in a RETURN QUERY command
by opening it as a cursor and then fetching a few rows at a time,
which it turns around and dumps into the function's result tuplestore.
The point of this was to keep from blowing out memory with an oversized
SPITupleTable result (note that while a tuplestore can spill tuples
to disk, SPITupleTable cannot). However, it's rather inefficient, both
because of extra data copying and because of executor entry/exit
overhead. In recent versions, a new performance problem has emerged:
use of a cursor prevents use of a parallel plan for the executed query.
We can improve matters by skipping use of a cursor and having the
executor push result tuples directly into the function's result
tuplestore. However, a moderate amount of new infrastructure is needed
to make that idea work:
* We can use the existing tstoreReceiver.c DestReceiver code to funnel
executor output to the tuplestore, but it has to be extended to support
plpgsql's requirement for possibly applying a tuple conversion map.
* SPI needs to be extended to allow use of a caller-supplied
DestReceiver instead of its usual receiver that puts tuples into
a SPITupleTable. Two new API calls are needed to handle both the
RETURN QUERY and RETURN QUERY EXECUTE cases.
I also felt that I didn't want these new API calls to use the legacy
method of specifying query parameter values with "char" null flags
(the old ' '/'n' convention); rather they should accept ParamListInfo
objects containing the parameter type and value info. This required
a bit of additional new infrastructure since we didn't yet have any
parse analysis callback that would interpret $N parameter symbols
according to type data supplied in a ParamListInfo. There seems to be
no harm in letting makeParamList install that callback by default,
rather than leaving a new ParamListInfo's parserSetup hook as NULL.
(Indeed, as of HEAD, I couldn't find anyplace that was using the
parserSetup field at all; plpgsql was using parserSetupArg for its
own purposes, but parserSetup seemed to be write-only.)
We can actually get plpgsql out of the business of using legacy null
flags altogether, and using ParamListInfo instead of its ad-hoc
PreparedParamsData structure; but this requires inventing one more
SPI API call that can replace SPI_cursor_open_with_args. That seems
worth doing, though.
SPI_execute_with_args and SPI_cursor_open_with_args are now unused
anywhere in the core PG distribution. Perhaps someday we could
deprecate/remove them. But cleaning up the crufty bits of the SPI
API is a task for a different patch.
Per bug #16040 from Jeremy Smith. This is unfortunately too invasive to
consider back-patching. Patch by me; thanks to Hamid Akhtar for review.
Discussion: https://postgr.es/m/16040-
eaacad11fecfb198@postgresql.org
Michael Paquier [Fri, 12 Jun 2020 12:05:10 +0000 (21:05 +0900)]
Fix typos and some format mistakes in comments
Author: Justin Pryzby
Discussion: https://postgr.es/m/
20200612023709[email protected]
Peter Eisentraut [Fri, 12 Jun 2020 06:51:16 +0000 (08:51 +0200)]
Make more use of RELKIND_HAS_STORAGE()
Make use of RELKIND_HAS_STORAGE() where appropriate, instead of
listing out the relkinds individually. No behavior change intended.
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
7a22bf51-2480-d999-1794-
191ba67ff47c%402ndquadrant.com
Thomas Munro [Thu, 11 Jun 2020 22:44:32 +0000 (10:44 +1200)]
Improve comments for [Heap]CheckForSerializableConflictOut().
Rewrite the documentation of these functions, in light of recent bug fix
commit
5940ffb2.
Back-patch to 13 where the check-for-conflict-out code was split up into
AM-specific and generic parts, and new documentation was added that now
looked wrong.
Reviewed-by: Peter Geoghegan <[email protected]>
Discussion: https://postgr.es/m/
db7b729d-0226-d162-a126-
8a8ab2dc4443%40jepsen.io
Bruce Momjian [Thu, 11 Jun 2020 22:44:49 +0000 (18:44 -0400)]
doc: document problems with using xreflabel in XML docs
Reported-by: Peter Eisentraut
Discussion: https://postgr.es/m/
8315c0ca-7758-8823-fcb6-
f37f9413e6b6@2ndquadrant.com
Backpatch-through: master
Bruce Momjian [Thu, 11 Jun 2020 22:19:25 +0000 (18:19 -0400)]
doc: remove xreflabels from commits
75fcdd2ae2 and
85af628da5
xreflabels prevent references to the chapter numbers of sections id's.
It should only be used in specific cases.
Discussion: https://postgr.es/m/
8315c0ca-7758-8823-fcb6-
f37f9413e6b6@2ndquadrant.com
Backpatch-through: 9.5
Tom Lane [Thu, 11 Jun 2020 21:38:42 +0000 (17:38 -0400)]
Fix mishandling of NaN counts in numeric_[avg_]combine.
When merging two NumericAggStates, the code missed adding the new
state's NaNcount unless its N was also nonzero; since those counts
are independent, this is wrong.
This would only have visible effect if some partial aggregate scans
found only NaNs while earlier ones found only non-NaNs; then we could
end up falsely deciding that there were no NaNs and fail to return a
NaN final result as expected. That's pretty improbable, so it's no
surprise this hasn't been reported from the field. Still, it's a bug.
I didn't try to produce a regression test that would show the bug,
but I did notice that these functions weren't being reached at all
in our regression tests, so I improved the tests to at least
exercise them. With these additions, I see pretty complete code
coverage on the aggregation-related functions in numeric.c.
Back-patch to 9.6 where this code was introduced. (I only added
the improved test case as far back as v10, though, since the
relevant part of aggregates.sql isn't there at all in 9.6.)
Jeff Davis [Thu, 11 Jun 2020 18:58:16 +0000 (11:58 -0700)]
Rework HashAgg GUCs.
Eliminate enable_groupingsets_hash_disk, which was primarily useful
for testing grouping sets that use HashAgg and spill. Instead, hack
the table stats to convince the planner to choose hashed aggregation
for grouping sets that will spill to disk. Suggested by Melanie
Plageman.
Rename enable_hashagg_disk to hashagg_avoid_disk_plan, and invert the
meaning of on/off. The new name indicates more strongly that it only
affects the planner. Also, the word "avoid" is less definite, which
should avoid surprises when HashAgg still needs to use the
disk. Change suggested by Justin Pryzby, though I chose a different
GUC name.
Discussion: https://postgr.es/m/CAAKRu_aisiENMsPM2gC4oUY1hHG3yrCwY-fXUg22C6_MJUwQdA%40mail.gmail.com
Discussion: https://postgr.es/m/
20200610021544[email protected]
Backpatch-through: 13
Peter Geoghegan [Thu, 11 Jun 2020 17:09:47 +0000 (10:09 -0700)]
Avoid update conflict out serialization anomalies.
SSI's HeapCheckForSerializableConflictOut() test failed to correctly
handle conditions involving a concurrently inserted tuple which is later
concurrently updated by a separate transaction . A SELECT statement
that called HeapCheckForSerializableConflictOut() could end up using the
same XID (updater's XID) for both the original tuple, and the successor
tuple, missing the XID of the xact that created the original tuple
entirely. This only happened when neither tuple from the chain was
visible to the transaction's MVCC snapshot.
The observable symptoms of this bug were subtle. A pair of transactions
could commit, with the later transaction failing to observe the effects
of the earlier transaction (because of the confusion created by the
update to the non-visible row). This bug dates all the way back to
commit
dafaa3ef, which added SSI.
To fix, make sure that we check the xmin of concurrently inserted tuples
that happen to also have been updated concurrently.
Author: Peter Geoghegan
Reported-By: Kyle Kingsbury
Reviewed-By: Thomas Munro
Discussion: https://postgr.es/m/
db7b729d-0226-d162-a126-
8a8ab2dc4443@jepsen.io
Backpatch: All supported versions
Peter Eisentraut [Thu, 11 Jun 2020 12:14:12 +0000 (14:14 +0200)]
pg_dump: Remove dead code
Remove some code relevant only for dumping from pre-7.1 servers,
support for which had already been removed by
64f3524e2c8deebc02808aa5ebdfa17859473add.
Amit Kapila [Thu, 11 Jun 2020 08:40:43 +0000 (14:10 +0530)]
Fix typos.
Reported-by: John Naylor
Author: John Naylor
Backpatch-through: 9.5
Discussion: https://postgr.es/m/CACPNZCtRuvs6G+EYqejhVJgBq2AKeZdXRVJsbX4syhO9gn5SNQ@mail.gmail.com
Peter Eisentraut [Thu, 11 Jun 2020 09:18:15 +0000 (11:18 +0200)]
Refactor DROP LANGUAGE grammar
Fold it into the generic DropStmt.
Discussion: https://www.postgresql.org/message-id/flat/
163c00a5-f634-ca52-fc7c-
0e53deda8735%402ndquadrant.com
Peter Eisentraut [Thu, 11 Jun 2020 08:26:12 +0000 (10:26 +0200)]
Remove deprecated syntax from CREATE/DROP LANGUAGE
Remove the option to specify the language name as a single-quoted
string. This has been obsolete since
ee8ed85da3b. Removing it allows
better grammar refactoring.
The syntax of the CREATE FUNCTION LANGUAGE clause is not changed.
Discussion: https://www.postgresql.org/message-id/flat/
163c00a5-f634-ca52-fc7c-
0e53deda8735%402ndquadrant.com
Michael Paquier [Thu, 11 Jun 2020 06:48:46 +0000 (15:48 +0900)]
Move frontend-side archive APIs from src/common/ to src/fe_utils/
fe_archive.c was compiled only for the frontend in src/common/, but as
it will never share anything with the backend, it makes most sense to
move this file to src/fe_utils/.
Reported-by: Peter Eisentraut
Discussion: https://postgr.es/m/
e9766d71-8655-ac86-bdf6-
77e0e7169977@2ndquadrant.com
Backpatch-through: 13
Peter Eisentraut [Thu, 11 Jun 2020 06:21:24 +0000 (08:21 +0200)]
Fold AlterForeignTableStmt into AlterTableStmt
All other relation types are handled by AlterTableStmt, so it's
unnecessary to make a different statement for foreign tables.
Discussion: https://www.postgresql.org/message-id/flat/
163c00a5-f634-ca52-fc7c-
0e53deda8735%402ndquadrant.com
Peter Eisentraut [Wed, 10 Jun 2020 20:58:46 +0000 (22:58 +0200)]
Remove redundant grammar symbols
access_method, database_name, and index_name are all just name, and
they are not used consistently for their alleged purpose, so remove
them. They have been around since ancient times but have no current
reason for existing. Removing them can simplify future grammar
refactoring.
Discussion: https://www.postgresql.org/message-id/flat/
163c00a5-f634-ca52-fc7c-
0e53deda8735%402ndquadrant.com
Peter Eisentraut [Wed, 10 Jun 2020 14:16:37 +0000 (16:16 +0200)]
Change default of password_encryption to scram-sha-256
Also, the legacy values on/true/yes/1 for password_encryption that
mapped to md5 are removed. The only valid values are now
scram-sha-256 and md5.
Reviewed-by: Jonathan S. Katz <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
d5b0ad33-7d94-bdd1-caac-
43a1c782cab2%402ndquadrant.com
Peter Eisentraut [Wed, 10 Jun 2020 09:57:41 +0000 (11:57 +0200)]
Update description of parameter password_encryption
The previous description string still described the pre-PostgreSQL
10 (pre
eb61136dc75a76caef8460fa939244d8593100f2) behavior of
selecting between encrypted and unencrypted, but it is now choosing
between encryption algorithms.
Amit Kapila [Wed, 10 Jun 2020 04:50:10 +0000 (10:20 +0530)]
Fix ReorderBuffer memory overflow check.
Commit
cec2edfa78 introduced logical_decoding_work_mem to limit
ReorderBuffer memory usage. We spill the changes once the memory occupied
by changes exceeds logical_decoding_work_mem. There was an assumption
in the code that by evicting the largest (sub)transaction we will come
under the memory limit as the selected transaction will be at least as
large as the most recent change (which caused us to go over the memory
limit). However, that is not true because a user can reduce the
logical_decoding_work_mem to a smaller value before the most recent
change.
We fix it by allowing to evict the transactions until we reach under the
memory limit.
Reported-by: Fujii Masao
Author: Amit Kapila
Reviewed-by: Fujii Masao
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/
2b7ba291-22e0-a187-d167-
9e5309a3458d@oss.nttdata.com
Peter Eisentraut [Tue, 9 Jun 2020 08:41:41 +0000 (10:41 +0200)]
Peter Eisentraut [Tue, 9 Jun 2020 07:10:14 +0000 (09:10 +0200)]
Unify drop-by-OID functions
There are a number of Remove${Something}ById() functions that are
essentially identical in structure and only different in which catalog
they are working on. Refactor this to be one generic function. The
information about which oid column, index, etc. to use was already
available in ObjectProperty for most catalogs, in a few cases it was
easily added.
Reviewed-by: Pavel Stehule <[email protected]>
Reviewed-by: Robert Haas <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
331d9661-1743-857f-1cbb-
d5728bcd62cb%402ndquadrant.com
David Rowley [Tue, 9 Jun 2020 06:43:15 +0000 (18:43 +1200)]
Fix invalid function references in a few comments
These appear to have been forgotten when the functions were renamed in
1fd687a03.
Backpatch-through: 13, where the functions were renamed
Tom Lane [Tue, 9 Jun 2020 05:17:59 +0000 (01:17 -0400)]
Repair unstable regression test.
Commit
0c882e52a tried to force table atest12 to have more-accurate-
than-default statistics; but transiently setting default_statistics_target
isn't enough for that, because autovacuum could come along and overwrite
the stats later. This evidently explains some intermittent buildfarm
failures we've seen since then. Repair by disabling autovac on this table.
Thanks to David Rowley for correctly diagnosing the cause.
Discussion: https://postgr.es/m/CA+hUKG+OUkQSOUTg=qo=S=fWa_tbm99i7rB7mfbHz1SYm4v-jQ@mail.gmail.com
Jeff Davis [Tue, 9 Jun 2020 03:59:45 +0000 (20:59 -0700)]
Fix HashAgg regression from choosing too many initial buckets.
Diagnosis by Andres.
Reported-by: Pavel Stehule
Discussion: https://postgr.es/m/CAFj8pRDLVakD5Aagt3yZeEQeTeEWaS3YE5h8XC3Q3qJ6TYkc2Q%40mail.gmail.com
Backpatch-through: 13
Andres Freund [Tue, 9 Jun 2020 02:52:19 +0000 (19:52 -0700)]
Avoid need for valgrind suppressions for pg_atomic_init_u64 on some platforms.
Previously we used pg_atomic_write_64_impl inside
pg_atomic_init_u64. That works correctly, but on platforms without
64bit single copy atomicity it could trigger spurious valgrind errors
about uninitialized memory, because we use compare_and_swap for atomic
writes on such platforms.
I previously suppressed one instance of this problem (
6c878edc1df),
but as Tom reports that wasn't enough. As the atomic variable cannot
yet be concurrently accessible during initialization, it seems better
to have pg_atomic_init_64_impl set the value directly.
Change pg_atomic_init_u32_impl for symmetry.
Reported-By: Tom Lane
Author: Andres Freund
Discussion: https://postgr.es/m/
1714601.
1591503815@sss.pgh.pa.us
Backpatch: 9.5-
Peter Eisentraut [Mon, 8 Jun 2020 20:44:15 +0000 (22:44 +0200)]
Update documentation for snowball update
Discussion: https://www.postgresql.org/message-id/flat/
a8eeabd6-2be1-43fe-401e-
a97594c38478%402ndquadrant.com
Peter Eisentraut [Mon, 8 Jun 2020 05:58:51 +0000 (07:58 +0200)]
Update snowball
Update to snowball tag v2.0.0. Major changes are new stemmers for
Basque, Catalan, and Hindi.
Discussion: https://www.postgresql.org/message-id/flat/
a8eeabd6-2be1-43fe-401e-
a97594c38478%402ndquadrant.com
Thomas Munro [Mon, 8 Jun 2020 01:57:24 +0000 (13:57 +1200)]
Fix locking bugs that could corrupt pg_control.
The redo routines for XLOG_CHECKPOINT_{ONLINE,SHUTDOWN} must acquire
ControlFileLock before modifying ControlFile->checkPointCopy, or the
checkpointer could write out a control file with a bad checksum.
Likewise, XLogReportParameters() must acquire ControlFileLock before
modifying ControlFile and calling UpdateControlFile().
Back-patch to all supported releases.
Author: Nathan Bossart <
[email protected]>
Author: Fujii Masao <
[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Reviewed-by: Thomas Munro <[email protected]>
Discussion: https://postgr.es/m/
70BF24D6-DC51-443F-B55A-
95735803842A%40amazon.com
Thomas Munro [Mon, 8 Jun 2020 01:20:46 +0000 (13:20 +1200)]
Doc: Update example symptom of systemd misconfiguration.
In PostgreSQL 10, we stopped using System V semaphores on Linux
systems. Update the example we give of an error message from a
misconfigured system to show what people are most likely to see these
days.
Back-patch to 10, where PREFERRED_SEMAPHORES=UNNAMED_POSIX arrived.
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGLmJUSwybaPQv39rB8ABpqJq84im2UjZvyUY4feYhpWMw%40mail.gmail.com
Michael Paquier [Mon, 8 Jun 2020 01:12:24 +0000 (10:12 +0900)]
Fix crash in WAL sender when starting physical replication
Since database connections can be used with WAL senders in 9.4, it is
possible to use physical replication. This commit fixes a crash when
starting physical replication with a WAL sender using a database
connection, caused by the refactoring done in
850196b.
There have been discussions about forbidding the use of physical
replication in a database connection, but this is left for later,
taking care only of the crash new to 13.
While on it, add a test to check for a failure when attempting logical
replication if the WAL sender does not have a database connection. This
part is extracted from a larger patch by Kyotaro Horiguchi.
Reported-by: Vladimir Sitnikov
Author: Michael Paquier, Kyotaro Horiguchi
Reviewed-by: Kyotaro Horiguchi, Álvaro Herrera
Discussion: https://postgr.es/m/CAB=Je-GOWMj1PTPkeUhjqQp-4W3=nW-pXe2Hjax6rJFffB5_Aw@mail.gmail.com
Backpatch-through: 13
Noah Misch [Sun, 7 Jun 2020 23:27:13 +0000 (16:27 -0700)]
MSVC: Avoid warning when testing a TAP suite without PROVE_FLAGS.
Commit
7be5d8df1f74b78620167d3abf32ee607e728919 surfaced the logic
error, which had no functional implications, by adding "use warnings".
The buildfarm always customizes PROVE_FLAGS, so the warning did not
appear there. Back-patch to 9.5 (all supported versions).
Tom Lane [Sun, 7 Jun 2020 21:16:30 +0000 (17:16 -0400)]
Stamp HEAD as 14devel.
Let the hacking begin ...
Tom Lane [Sun, 7 Jun 2020 20:57:08 +0000 (16:57 -0400)]
pgindent run prior to branching v13.
pgperltidy and reformat-dat-files too, though those didn't
find anything to change.
Tom Lane [Sun, 7 Jun 2020 17:44:13 +0000 (13:44 -0400)]
Try to read data from the socket in pqSendSome's write_failed paths.
Even when we've concluded that we have a hard write failure on the
socket, we should continue to try to read data. This gives us an
opportunity to collect any final error message that the backend might
have sent before closing the connection; moreover it is the job of
pqReadData not pqSendSome to close the socket once EOF is detected.
Due to an oversight in
1f39a1c06, pqSendSome failed to try to collect
data in the case where we'd already set write_failed. The problem was
masked for ordinary query operations (which really only make one write
attempt anyway), but COPY to the server would continue to send data
indefinitely after a mid-COPY connection loss.
Hence, add pqReadData calls into the paths where pqSendSome drops data
because of write_failed. If we've lost the connection, this will
eventually result in closing the socket and setting CONNECTION_BAD,
which will cause PQputline and siblings to report failure, allowing
the application to terminate the COPY sooner. (Basically this restores
what happened before
1f39a1c06.)
There are related issues that this does not solve; for example, if the
backend sends an error but doesn't drop the connection, we did and
still will keep pumping COPY data as long as the application sends it.
Fixing that will require application-visible behavior changes though,
and anyway it's an ancient behavior that we've had few complaints about.
For now I'm just trying to fix the regression from
1f39a1c06.
Per a complaint from Andres Freund. Back-patch into v12 where
1f39a1c06 came in.
Discussion: https://postgr.es/m/
20200603201242[email protected]
Tom Lane [Sun, 7 Jun 2020 17:07:31 +0000 (13:07 -0400)]
Rethink definition of cancel.c's CancelRequested flag.
As it stands, this flag is only set when we've successfully sent a
cancel request, not if we get SIGINT and then fail to send a cancel.
However, for almost all callers, that's the Wrong Thing: we'd prefer
to abort processing after control-C even if no cancel could be sent.
As an example, since commit
1d468b9ad "pgbench -i" fails to give up
sending COPY data even after control-C, if the postmaster has been
stopped, which is clearly not what the code intends and not what anyone
would want. (The fact that it keeps going at all is the fault of a
separate bug in libpq, but not letting CancelRequested become set is
clearly not what we want here.)
The sole exception, as far as I can find, is that scripts_parallel.c's
ParallelSlotsGetIdle tries to consume a query result after issuing a
cancel, which of course might not terminate quickly if no cancel
happened. But that behavior was poorly thought out too. No user of
ParallelSlotsGetIdle tries to continue processing after a cancel,
so there is really no point in trying to clear the connection's state.
Moreover this has the same defect as for other users of cancel.c,
that if the cancel request fails for some reason then we end up with
control-C being completely ignored. (On top of that, select_loop failed
to distinguish clearly between SIGINT and other reasons for select(2)
failing, which means that it's possible that the existing code would
think that a cancel has been sent when it hasn't.)
Hence, redefine CancelRequested as simply meaning that SIGINT was
received. We could add a second flag with the other meaning, but
in the absence of any compelling argument why such a flag is needed,
I think it would just offer an opportunity for future callers to
get it wrong. Also remove the consumeQueryResult call in
ParallelSlotsGetIdle's failure exit. In passing, simplify the
API of select_loop.
It would now be possible to re-unify psql's cancel_pressed with
CancelRequested, partly undoing
5d43c3c54. But I'm not really
convinced that that's worth the trouble, so I left psql alone,
other than fixing a misleading comment.
This code is new in v13 (cf
a4fd3aa71), so no need for back-patch.
Per investigation of a complaint from Andres Freund.
Discussion: https://postgr.es/m/
20200603201242[email protected]
Jeff Davis [Sun, 7 Jun 2020 16:14:24 +0000 (09:14 -0700)]
Fix platform-specific performance regression in logtape.c.
Commit
24d85952 made a change that indirectly caused a performance
regression by triggering a change in the way GCC optimizes memcpy() on
some platforms.
The behavior seemed to contradict a GCC document, so I filed a report:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95556
This patch implements a narrow workaround which eliminates the
regression I observed. The workaround is benign enough that it seems
unlikely to cause a different regression on another platform.
Discussion: https://postgr.es/m/
99b2eab335c1592c925d8143979c8e9e81e1575f[email protected]
Peter Eisentraut [Sun, 7 Jun 2020 14:12:05 +0000 (16:12 +0200)]
psql: Format \? output a little better
Peter Eisentraut [Sun, 7 Jun 2020 13:11:51 +0000 (15:11 +0200)]
Fix message translatability
Two parts of the same message shouldn't be split across two function
calls.
Peter Eisentraut [Sun, 7 Jun 2020 13:06:51 +0000 (15:06 +0200)]
Spelling adjustments
Peter Eisentraut [Sun, 7 Jun 2020 12:54:28 +0000 (14:54 +0200)]
doc: Fix man page whitespace issues
Whitespace between tags is significant, and in some cases it creates
extra vertical space in man pages. The fix is either to remove some
newlines or in some cases to reword slightly to avoid the awkward
markup layout.
Peter Eisentraut [Sun, 7 Jun 2020 12:35:12 +0000 (14:35 +0200)]
Formatting and punctuation improvements in postgresql.conf.sample
Peter Eisentraut [Sun, 7 Jun 2020 12:07:33 +0000 (14:07 +0200)]
doc: Move options on man pages into more alphabetical order
Peter Eisentraut [Sun, 7 Jun 2020 11:34:37 +0000 (13:34 +0200)]
doc: Fix up spacing around verbatim DocBook elements
Peter Eisentraut [Sun, 7 Jun 2020 11:27:57 +0000 (13:27 +0200)]
doc: Language review
Peter Eisentraut [Sun, 7 Jun 2020 11:24:40 +0000 (13:24 +0200)]
doc: Trim trailing whitespace
Peter Eisentraut [Sun, 7 Jun 2020 11:18:36 +0000 (13:18 +0200)]
doc: Clean up title case use