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/E1jkyFX-0005RR-1Q@gemulon.postgresql.org
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/E1jkyFX-0005RR-1Q@gemulon.postgresql.org
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 <amitdkhan.pg@gmail.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Ibrar Ahmed <ibrar.ahmad@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
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 <tgl@sss.pgh.pa.us>
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.camel@cybertec.at
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/E1jkU7H-00024V-NZ@gemulon.postgresql.org
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/E1jkU7H-00024V-NZ@gemulon.postgresql.org
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.GC14879@telsasoft.com
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 <aphyr@jepsen.io>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Tatsuo Ishii <ishii@sraoss.co.jp>
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 <vik@postgresfriends.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
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/87y2ou3xuh.fsf@news-spur.riddles.org.uk
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.GC14879@telsasoft.com
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 <tgl@sss.pgh.pa.us>
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 <pg@bowt.ie>
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.GA14879@telsasoft.com
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 <jkatz@postgresql.org>
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 <pavel.stehule@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
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 <bossartn@amazon.com>
Author: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
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 <tgl@sss.pgh.pa.us>
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.ofvm4jztpqytwfye@alap3.anarazel.de
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.ofvm4jztpqytwfye@alap3.anarazel.de
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.camel@j-davis.com
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
Peter Eisentraut [Sun, 7 Jun 2020 11:10:18 +0000 (13:10 +0200)]
doc: Remove line breaks after <title>
This creates unnecessary rendering problem risks, and it's
inconsistent and gets copied around.
Thomas Munro [Sun, 7 Jun 2020 09:36:43 +0000 (21:36 +1200)]
Doc: Clean up references to obsolete OS versions.
Remove obsolete instructions for old operating system versions, and
update the text to reflect the defaults on modern systems.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Reviewed-by: Magnus Hagander <magnus@hagander.net>
Discussion: https://postgr.es/m/CA%2BhUKGLmJUSwybaPQv39rB8ABpqJq84im2UjZvyUY4feYhpWMw%40mail.gmail.com
Peter Eisentraut [Sun, 7 Jun 2020 09:16:51 +0000 (11:16 +0200)]
doc: Fix incorrect link target
Peter Eisentraut [Sat, 6 Jun 2020 17:56:21 +0000 (19:56 +0200)]
Add missing source files to nls.mk
Magnus Hagander [Sat, 6 Jun 2020 13:35:42 +0000 (15:35 +0200)]
Fix reference to wrong view in release notes
The estimate of total backup size effects the view
pg_stat_progress_basebackup, not pg_stat_progress_analyze.
Noah Misch [Sat, 6 Jun 2020 03:10:53 +0000 (20:10 -0700)]
Refresh function name in CRC-associated Valgrind suppressions.
Back-patch to 9.5, where commit
4f700bcd20c087f60346cb8aefd0e269be8e2157
first appeared.
Reviewed by Tom Lane. Reported by Andrew Dunstan.
Discussion: https://postgr.es/m/
4dfabec2-a3ad-0546-2d62-
f816c97edd0c@2ndQuadrant.com
Tom Lane [Fri, 5 Jun 2020 22:04:37 +0000 (18:04 -0400)]
Doc: remove annotations about multi-row output of set-returning functions.
I thought this added clarity, or at least was consistent with the way
these entries looked before v13 ... but apparently I'm in the minority.
Discussion: https://postgr.es/m/CAFj8pRAXuetiHUfs73zjsJD6B78FWcUsBS-j23sdCMFXkgx5Fg@mail.gmail.com
Tom Lane [Fri, 5 Jun 2020 20:55:16 +0000 (16:55 -0400)]
Improve ineq_histogram_selectivity's behavior for non-default orderings.
ineq_histogram_selectivity() can be invoked in situations where the
ordering we care about is not that of the column's histogram. We could
be considering some other collation, or even more drastically, the
query operator might not agree at all with what was used to construct
the histogram. (We'll get here for anything using scalarineqsel-based
estimators, so that's quite likely to happen for extension operators.)
Up to now we just ignored this issue and assumed we were dealing with
an operator/collation whose sort order exactly matches the histogram,
possibly resulting in junk estimates if the binary search gets confused.
It's past time to improve that, since the use of nondefault collations
is increasing. What we can do is verify that the given operator and
collation match what's recorded in pg_statistic, and use the existing
code only if so. When they don't match, instead execute the operator
against each histogram entry, and take the fraction of successes as our
selectivity estimate. This gives an estimate that is probably good to
about 1/histogram_size, with no assumptions about ordering. (The quality
of the estimate is likely to degrade near the ends of the value range,
since the two orderings probably don't agree on what is an extremal value;
but this is surely going to be more reliable than what we did before.)
At some point we might further improve matters by storing more than one
histogram calculated according to different orderings. But this code
would still be good fallback logic when no matches exist, so that is
not an argument for not doing this.
While here, also improve get_variable_range() to deal more honestly
with non-default collations.
This isn't back-patchable, because it requires adding another argument
to ineq_histogram_selectivity, and because it might have significant
impact on the estimation results for extension operators relying on
scalarineqsel --- mostly for the better, one hopes, but in any case
destabilizing plan choices in back branches is best avoided.
Per investigation of a report from James Lucas.
Discussion: https://postgr.es/m/CAAFmbbOvfi=wMM=3qRsPunBSLb8BFREno2oOzSBS=mzfLPKABw@mail.gmail.com
Joe Conway [Fri, 5 Jun 2020 20:49:25 +0000 (16:49 -0400)]
Add unlikely() to CHECK_FOR_INTERRUPTS()
Add the unlikely() branch hint macro to CHECK_FOR_INTERRUPTS().
Backpatch to REL_10_STABLE where we first started using unlikely().
Discussion: https://www.postgresql.org/message-id/flat/
8692553c-7fe8-17d9-cbc1-
7cddb758f4c6%40joeconway.com
Tom Lane [Fri, 5 Jun 2020 20:18:50 +0000 (16:18 -0400)]
Use query collation, not column's collation, while examining statistics.
Commit
5e0928005 changed the planner so that, instead of blindly using
DEFAULT_COLLATION_OID when invoking operators for selectivity estimation,
it would use the collation of the column whose statistics we're
considering. This was recognized as still being not quite the right
thing, but it seemed like a good incremental improvement. However,
shortly thereafter we introduced nondeterministic collations, and that
creates cases where operators can fail if they're passed the wrong
collation. We don't want planning to fail in cases where the query itself
would work, so this means that we *must* use the query's collation when
invoking operators for estimation purposes.
The only real problem this creates is in ineq_histogram_selectivity, where
the binary search might produce a garbage answer if we perform comparisons
using a different collation than the column's histogram is ordered with.
However, when the query's collation is significantly different from the
column's default collation, the estimate we previously generated would be
pretty irrelevant anyway; so it's not clear that this will result in
noticeably worse estimates in practice. (A follow-on patch will improve
this situation in HEAD, but it seems too invasive for back-patch.)
The patch requires changing the signatures of mcv_selectivity and allied
functions, which are exported and very possibly are used by extensions.
In HEAD, I just did that, but an API/ABI break of this sort isn't
acceptable in stable branches. Therefore, in v12 the patch introduces
"mcv_selectivity_ext" and so on, with signatures matching HEAD, and makes
the old functions into wrappers that assume DEFAULT_COLLATION_OID should
be used. That does not match the prior behavior, but it should avoid risk
of failure in most cases. (In practice, I think most extension datatypes
aren't collation-aware, so the change probably doesn't matter to them.)
Per report from James Lucas. Back-patch to v12 where the problem was
introduced.
Discussion: https://postgr.es/m/CAAFmbbOvfi=wMM=3qRsPunBSLb8BFREno2oOzSBS=mzfLPKABw@mail.gmail.com
Peter Eisentraut [Fri, 5 Jun 2020 09:18:11 +0000 (11:18 +0200)]
OpenSSL 3.0.0 compatibility in tests
DES has been deprecated in OpenSSL 3.0.0 which makes loading keys
encrypted with DES fail with "fetch failed". Solve by changing the
cipher used to aes256 which has been supported since 1.0.1 (and is
more realistic to use anyways).
Note that the minimum supported OpenSSL version is 1.0.1 as of
7b283d0e1d1d79bf1c962d790c94d2a53f3bb38a, so this does not introduce
any new version requirements.
Author: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/flat/
FEF81714-D479-4512-839B-
C769D2605F8A%40yesql.se
Michael Paquier [Fri, 5 Jun 2020 01:26:02 +0000 (10:26 +0900)]
Preserve pg_index.indisreplident across REINDEX CONCURRENTLY
If the flag value is lost, logical decoding would work the same way as
REPLICA IDENTITY NOTHING, meaning that no old tuple values would be
included in the changes anymore produced by logical decoding.
Author: Michael Paquier
Reviewed-by: Euler Taveira
Discussion: https://postgr.es/m/
20200603065340.GK89559@paquier.xyz
Backpatch-through: 12
Tom Lane [Thu, 4 Jun 2020 20:42:08 +0000 (16:42 -0400)]
Reject "23:59:60.nnn" in datetime input.
It's intentional that we don't allow values greater than 24 hours,
while we do allow "24:00:00" as well as "23:59:60" as inputs.
However, the range check was miscoded in such a way that it would
accept "23:59:60.nnn" with a nonzero fraction. For time or timetz,
the stored result would then be greater than "24:00:00" which would
fail dump/reload, not to mention possibly confusing other operations.
Fix by explicitly calculating the result and making sure it does not
exceed 24 hours. (This calculation is redundant with what will happen
later in tm2time or tm2timetz. Maybe someday somebody will find that
annoying enough to justify refactoring to avoid the duplication; but
that seems too invasive for a back-patched bug fix, and the cost is
probably unmeasurable anyway.)
Note that this change also rejects such input as the time portion
of a timestamp(tz) value.
Back-patch to v10. The bug is far older, but to change this pre-v10
we'd need to ensure that the logic behaves sanely with float timestamps,
which is possibly nontrivial due to roundoff considerations.
Doesn't really seem worth troubling with.
Per report from Christoph Berg.
Discussion: https://postgr.es/m/
20200520125807.GB296739@msg.df7cb.de
Peter Eisentraut [Thu, 4 Jun 2020 20:09:41 +0000 (22:09 +0200)]
psql: Clean up terminology in \dAp command
The preferred terminology has been support "function", not procedure,
for some time, so change that over. The command stays \dAp, since
\dAf is already something else.
Michael Paquier [Thu, 4 Jun 2020 04:02:59 +0000 (13:02 +0900)]
Fix comment in be-secure-openssl.c
Since
573bd08, hardcoded DH parameters have been moved to a different
file, making the comment on top of load_dh_buffer() incorrect.
Author: Daniel Gustafsson
Discussion: https://postgr.es/m/
D9492CCB-9A91-4181-A847-
1779630BE2A7@yesql.se
Michael Paquier [Thu, 4 Jun 2020 01:17:49 +0000 (10:17 +0900)]
Fix instance of elog() called while holding a spinlock
This broke the project rule to not call any complex code while a
spinlock is held. Issue introduced by
b89e151.
Discussion: https://postgr.es/m/
20200602.161518.
1399689010416646074.horikyota.ntt@gmail.com
Backpatch-through: 9.5
Tom Lane [Wed, 3 Jun 2020 16:36:00 +0000 (12:36 -0400)]
Don't call palloc() while holding a spinlock, either.
Fix some more violations of the "only straight-line code inside a
spinlock" rule. These are hazardous not only because they risk
holding the lock for an excessively long time, but because it's
possible for palloc to throw elog(ERROR), leaving a stuck spinlock
behind.
copy_replication_slot() had two separate places that did pallocs
while holding a spinlock. We can make the code simpler and safer
by copying the whole ReplicationSlot struct into a local variable
while holding the spinlock, and then referencing that copy.
(While that's arguably more cycles than we really need to spend
holding the lock, the struct isn't all that big, and this way seems
far more maintainable than copying fields piecemeal. Anyway this
is surely much cheaper than a palloc.) That bug goes back to v12.
InvalidateObsoleteReplicationSlots() not only did a palloc while
holding a spinlock, but for extra sloppiness then leaked the memory
--- probably for the lifetime of the checkpointer process, though
I didn't try to verify that. Fortunately that silliness is new
in HEAD.
pg_get_replication_slots() had a cosmetic violation of the rule,
in that it only assumed it's safe to call namecpy() while holding
a spinlock. Still, that's a hazard waiting to bite somebody, and
there were some other cosmetic coding-rule violations in the same
function, so clean it up. I back-patched this as far as v10; the
code exists before that but it looks different, and this didn't
seem important enough to adapt the patch further back.
Discussion: https://postgr.es/m/
20200602.161518.
1399689010416646074.horikyota.ntt@gmail.com
Bruce Momjian [Wed, 3 Jun 2020 02:11:47 +0000 (22:11 -0400)]
doc: PG 13 relnotes: fix link for grouping sets hash overflow
Use "guc-enable-groupingsets-hash-disk".
Reported-by: TAKATSUKA Haruka
Discussion: https://postgr.es/m/16468-
7939d39f1786516c@postgresql.org
Backpatch-through: master
Fujii Masao [Wed, 3 Jun 2020 00:59:43 +0000 (09:59 +0900)]
doc: Move wal_init_zero and wal_recycle descriptions to proper section.
The group of wal_init_zero and wal_recycle is WAL_SETTINGS in guc.c,
but previously their documents were located in
"Replication"/"Sending Servers" section. This commit moves them to
the proper section "Write Ahead Log"/"Settings".
Back-patch to v12 where wal_init_zero and wal_recycle parameters
were introduced.
Author: Fujii Masao
Discussion: https://postgr.es/m/
b5190ab4-a169-6a42-0e49-
aed0807c8976@oss.nttdata.com
Fujii Masao [Tue, 2 Jun 2020 10:18:13 +0000 (19:18 +0900)]
Don't call elog() while holding spinlock.
Previously UpdateSpillStats() called elog(DEBUG2) while holding
the spinlock even though the local variables that the elog() accesses
don't need to be protected by the lock. Since spinlocks are intended
for very short-term locks, they should not be used when calling
elog(DEBUG2). So this commit moves that elog() out of spinlock period.
Author: Kyotaro Horiguchi
Reviewed-by: Amit Kapila and Fujii Masao
Discussion: https://postgr.es/m/
20200602.161518.
1399689010416646074.horikyota.ntt@gmail.com
Amit Kapila [Tue, 2 Jun 2020 05:41:25 +0000 (11:11 +0530)]
Doc: Update the documentation for spilled transaction statistics.
Reported-by: Sawada Masahiko
Author: Sawada Masahiko, Amit Kapila
Reviewed-by: Amit Kapila
Discussion: https://postgr.es/m/CA+fd4k4vNg7dRO5ECHdtQXXf1=Q4M98pfLW0dU7BKD8h79pkqA@mail.gmail.com
Andrew Dunstan [Mon, 1 Jun 2020 21:32:32 +0000 (17:32 -0400)]
Make ssl certificate for ssl_passphrase_callback test via Makefile
The recipe was previously given in comments in the module's test
script, but now we have an explicit recipe in the Makefile. The now
redundant comments in the script are removed.
This recipe shouldn't be needed in normal use, as the certificate and
key are in git and don't need to be regenerated.
Discussion: https://postgr.es/m/
ae8f21fc-95cb-c98a-f241-
1936133f466f@2ndQuadrant.com
Peter Eisentraut [Mon, 1 Jun 2020 19:18:36 +0000 (21:18 +0200)]
Use correct and consistent unit abbreviation
Michael Paquier [Mon, 1 Jun 2020 05:41:18 +0000 (14:41 +0900)]
Fix use-after-release mistake in currtid() and currtid2() for views
This issue has been present since the introduction of this code as of
a3519a2 from 2002, and has been found by buildfarm member prion that
uses RELCACHE_FORCE_RELEASE via the tests introduced recently in
e786be5.
Discussion: https://postgr.es/m/
20200601022055.GB4121@paquier.xyz
Backpatch-through: 9.5