PostgreSQL 11.8 (upcoming) commit log

Fix bugs in gin_fuzzy_search_limit processing.

commit   : 0912fb39cab35913907ce0eaa11e0504203153c5    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Apr 2020 13:15:30 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Apr 2020 13:15:30 -0400    

Click here for diff

entryGetItem()'s three code paths each contained bugs associated  
with filtering the entries for gin_fuzzy_search_limit.  
  
The posting-tree path failed to advance "advancePast" after having  
decided to filter an item.  If we ran out of items on the current  
page and needed to advance to the next, what would actually happen  
is that entryLoadMoreItems() would re-load the same page.  Eventually,  
the random dropItem() test would accept one of the same items it'd  
previously rejected, and we'd move on --- but it could take awhile  
with small gin_fuzzy_search_limit.  To add insult to injury, this  
case would inevitably cause entryLoadMoreItems() to decide it needed  
to re-descend from the root, making things even slower.  
  
The posting-list path failed to implement gin_fuzzy_search_limit  
filtering at all, so that all entries in the posting list would  
be returned.  
  
The bitmap-result path used a "gotitem" variable that it failed to  
update in the one place where it'd actually make a difference, ie  
at the one "continue" statement.  I think this was unreachable in  
practice, because if we'd looped around then it shouldn't be the  
case that the entries on the new page are before advancePast.  
Still, the "gotitem" variable was contributing nothing to either  
clarity or correctness, so get rid of it.  
  
Refactor all three loops so that the termination conditions are  
more alike and less unreadable.  
  
The code coverage report showed that we had no coverage at all for  
the re-descend-from-root code path in entryLoadMoreItems(), which  
seems like a very bad thing, so add a test case that exercises it.  
We also had exactly no coverage for gin_fuzzy_search_limit, so add a  
simplistic test case that at least hits those code paths a little bit.  
  
Back-patch to all supported branches.  
  
Adé Heyward and Tom Lane  
  
Discussion: https://postgr.es/m/CAEknJCdS-dE1Heddptm7ay2xTbSeADbkaQ8bU2AXRCVC2LdtKQ@mail.gmail.com  

M src/backend/access/gin/ginget.c
M src/test/regress/expected/gin.out
M src/test/regress/sql/gin.sql

Fix bogus CALLED_AS_TRIGGER() defenses.

commit   : 7b1552283465acc10a88038fe87c7901198c3b5e    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Apr 2020 11:24:56 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 3 Apr 2020 11:24:56 -0400    

Click here for diff

contrib/lo's lo_manage() thought it could use  
trigdata->tg_trigger->tgname in its error message about  
not being called as a trigger.  That naturally led to a core dump.  
  
unique_key_recheck() figured it could Assert that fcinfo->context  
is a TriggerData node in advance of having checked that it's  
being called as a trigger.  That's harmless in production builds,  
and perhaps not that easy to reach in any case, but it's logically  
wrong.  
  
The first of these per bug #16340 from William Crowell;  
the second from manual inspection of other CALLED_AS_TRIGGER  
call sites.  
  
Back-patch the lo.c change to all supported branches, the  
other to v10 where the thinko crept in.  
  
Discussion: https://postgr.es/m/16340-591c7449dc7c8c47@postgresql.org  

M contrib/lo/lo.c
M src/backend/commands/constraint.c

doc: remove unnecessary INNER keyword

commit   : 42da1db7b9d5dd2d3d2e887adb19c6a3c28804b9    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 2 Apr 2020 17:42:09 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 2 Apr 2020 17:42:09 -0400    

Click here for diff

A join that was added in commit 9b2009c4cf that did not use the INNER  
keyword but the existing query used it.  It was cleaner to remove the  
existing INNER keyword.  
  
Reported-by: Peter Eisentraut  
  
Discussion: https://postgr.es/m/a1ffbfda-59d2-5732-e5fb-3df8582b6434@2ndquadrant.com  
  
Backpatch-through: 9.5  

M doc/src/sgml/pgbuffercache.sgml

commit   : a38f099aff2772ecdc6b527289f424d191c18e5e    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 2 Apr 2020 17:27:43 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 2 Apr 2020 17:27:43 -0400    

Click here for diff

Reported-by: Peter Eisentraut  
  
Discussion: https://postgr.es/m/750b8832-d123-7f9b-931e-43ce8321b2d7@2ndquadrant.com  
  
Backpatch-through: 9.5  

M doc/src/sgml/func.sgml

Check equality semantics for unique indexes on partitioned tables.

commit   : 76ddc88f4dde93154e3553546c7cffe97060a26c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Apr 2020 14:49:49 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 1 Apr 2020 14:49:49 -0400    

Click here for diff

We require the partition key to be a subset of the set of columns  
being made unique, so that physically-separate indexes on the different  
partitions are sufficient to enforce the uniqueness constraint.  
  
The existing code checked that the listed columns appear, but did not  
inquire into the index semantics, which is a serious oversight given  
that different index opclasses might enforce completely different  
notions of uniqueness.  
  
Ideally, perhaps, we'd just match the partition key opfamily to the  
index opfamily.  But hash partitioning uses hash opfamilies which we  
can't directly match to btree opfamilies.  Hence, look up the equality  
operator in each family, and accept if it's the same operator.  This  
should be okay in a fairly general sense, since the equality operator  
ought to precisely represent the opfamily's notion of uniqueness.  
  
A remaining weak spot is that we don't have a cross-index-AM notion of  
which opfamily member is "equality".  But we know which one to use for  
hash and btree AMs, and those are the only two that are relevant here  
at present.  (Any non-core AMs that know how to enforce equality are  
out of luck, for now.)  
  
Back-patch to v11 where this feature was introduced.  
  
Guancheng Luo, revised a bit by me  
  
Discussion: https://postgr.es/m/D9C3CEF7-04E8-47A1-8300-CA1DCD5ED40D@gmail.com  

M src/backend/commands/indexcmds.c

psql: do file completion for \gx

commit   : 7054e12e0fb64d7c1573a0b55c01b23b6d5e15eb    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 23:01:33 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 23:01:33 -0400    

Click here for diff

This was missed when the feature was added.  
  
Reported-by: Vik Fearing  
  
Discussion: https://postgr.es/m/eca20529-0b06-b493-ee38-f071a75dcd5b@postgresfriends.org  
  
Backpatch-through: 10  

M src/bin/psql/tab-complete.c

doc: remove mention of bitwise operators as solely type-limited

commit   : fd802bd92420adf32e872c16b75a7180bde876c7    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 18:44:29 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 18:44:29 -0400    

Click here for diff

There are other operators that have limited number data type support, so  
just remove the sentence.  
  
Reported-by: Sergei Agalakov  
  
Discussion: https://postgr.es/m/158032651854.19851.16261832706661813796@wrigleys.postgresql.org  
  
Backpatch-through: 9.5  

M doc/src/sgml/func.sgml

doc: clarify hierarchy of objects: global, db, schema, etc.

commit   : e472ebd65deb98940fca7a22e940e6cc73592ece    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 18:10:39 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 18:10:39 -0400    

Click here for diff

The previous wording was confusing because it wasn't in decreasing order  
and had to backtrack.  Also clarify role/user wording.  
  
Reported-by: jbird@nuna.com  
  
Discussion: https://postgr.es/m/158057750885.1123.2806779262588618988@wrigleys.postgresql.org  
  
Backpatch-through: 9.5  

M doc/src/sgml/ddl.sgml
M doc/src/sgml/manage-ag.sgml

doc: restore wording from recent patch "rolled back to"

commit   : e564c17d2aa283262bc8ee5a12bdd5ce70fa2afd    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 17:52:48 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 17:52:48 -0400    

Click here for diff

Reported-by: Tom Lane  
  
Discussion: https://postgr.es/m/31072.1585690490@sss.pgh.pa.us  
  
Backpatch-through: 9.5 - 12  

M doc/src/sgml/mvcc.sgml

doc: clarify when row-level locks are released

commit   : 6a4c58158bc01ef6452b0dcb3888d8e7994f0f35    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 17:27:32 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 17:27:32 -0400    

Click here for diff

They are released just like table-level locks.  Also clean up wording.  
  
Reported-by: me@sillymon.ch  
  
Discussion: https://postgr.es/m/158074944048.1095.4309647363871637715@wrigleys.postgresql.org  
  
Backpatch-through: 9.5  

M doc/src/sgml/mvcc.sgml

doc: add namespace column to pg_buffercache example query

commit   : 9e8aec433a29e42fe67a072aa9d9bb1da26145d6    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 17:16:33 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 17:16:33 -0400    

Click here for diff

Without the namespace, the table name could be ambiguous.  
  
Reported-by: adunham@arbormetrix.com  
  
Discussion: https://postgr.es/m/158155175140.23798.2189464781144503491@wrigleys.postgresql.org  
  
Backpatch-through: 9.5  

M doc/src/sgml/pgbuffercache.sgml

doc: clarify which table creation is used for inheritance part.

commit   : f116356deb75c113751db3410dec2ef59e46db73    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 17:07:43 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 17:07:43 -0400    

Click here for diff

Previously people might assume that the partition syntax version of  
CREATE TABLE is to be used for the inheritance partition table example;  
mention that the non-partitioned version should be used.  
  
Reported-by: mib@nic.at  
  
Discussion: https://postgr.es/m/158089540905.1098.15071165437284409576@wrigleys.postgresql.org  
  
Backpatch-through: 10  

M doc/src/sgml/ddl.sgml

doc: adjust UPDATE/DELETE's FROM/USING to match SELECT's FROM

commit   : 3ee692d82f8001c95f3154080886dd764e21d5b0    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 16:31:44 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Tue, 31 Mar 2020 16:31:44 -0400    

Click here for diff

Previously the syntax and wording were unclear.  
  
Reported-by: Alexey Bashtanov  
  
Discussion: https://postgr.es/m/968d4724-8e58-788f-7c45-f7b1813824cc@imap.cc  
  
Backpatch-through: 9.5  

M doc/src/sgml/ref/delete.sgml
M doc/src/sgml/ref/update.sgml

Teach pg_ls_dir_files() to ignore ENOENT failures from stat().

commit   : 5b22ff764b0f60c24d89ec0180476cda361ec126    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 31 Mar 2020 12:57:55 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 31 Mar 2020 12:57:55 -0400    

Click here for diff

Buildfarm experience shows that this function can fail with ENOENT  
if some other process unlinks a file between when we read the directory  
entry and when we try to stat() it.  The problem is old but we had  
not noticed it until 085b6b667 added regression test coverage.  
  
To fix, just ignore ENOENT failures.  There is one other case that  
this might hide: a symlink that points to nowhere.  That seems okay  
though, at least better than erroring.  
  
Back-patch to v10 where this function was added, since the regression  
test cases were too.  
  
Discussion: https://postgr.es/m/20200308173103.GC1357@telsasoft.com  

M src/backend/utils/adt/genfile.c

Back-patch addition of stack overflow and interrupt checks for lquery.

commit   : fade4d4dffca760252c0d7ee69598e7b441ed2f4    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 31 Mar 2020 11:37:44 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 31 Mar 2020 11:37:44 -0400    

Click here for diff

Experimentation shows that it's not hard at all to drive the  
old implementation of "ltree ~ lquery" match to stack overflow,  
so throw in a check_stack_depth() call, as I just did in HEAD.  
  
I wasn't able to make it take a long time, because all the  
pathological cases I tried hit stack overflow first; but  
I bet there are some others that do take a long time, so add  
CHECK_FOR_INTERRUPTS() too.  
  
Discussion: https://postgr.es/m/CAP_rww=waX2Oo6q+MbMSiZ9ktdj6eaJj0cQzNu=Ry2cCDij5fw@mail.gmail.com  

M contrib/ltree/lquery_op.c

Be more careful about extracting encoding from locale strings on Windows.

commit   : 4bc3a16677be061e60abd8d9e732c434784566db    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 30 Mar 2020 11:14:58 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 30 Mar 2020 11:14:58 -0400    

Click here for diff

GetLocaleInfoEx() can fail on strings that setlocale() was perfectly  
happy with.  A common way for that to happen is if the locale string  
is actually a Unix-style string, say "et_EE.UTF-8".  In that case,  
what's after the dot is an encoding name, not a Windows codepage number;  
blindly treating it as a codepage number led to failure, with a fairly  
silly error message.  Hence, check to see if what's after the dot is  
all digits, and if not, treat it as a literal encoding name rather than  
a codepage number.  This will do the right thing with many Unix-style  
locale strings, and produce a more sensible error message otherwise.  
  
Somewhat independently of that, treat a zero (CP_ACP) result from  
GetLocaleInfoEx() as meaning that we must use UTF-8 encoding.  
  
Back-patch to all supported branches.  
  
Juan José Santamaría Flecha  
  
Discussion: https://postgr.es/m/24905.1585445371@sss.pgh.pa.us  

M src/port/chklocale.c

Doc: correct misstatement about ltree label maximum length.

commit   : 550041728d65c78a58fe76f89e68b75d56c39645    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 29 Mar 2020 18:54:19 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sun, 29 Mar 2020 18:54:19 -0400    

Click here for diff

The documentation says that the max length is 255 bytes, but  
code inspection says it's actually 255 characters; and relevant  
lengths are stored as uint16 so that that works.  

M doc/src/sgml/ltree.sgml

Protect against overflow of ltree.numlevel and lquery.numlevel.

commit   : 5feb3d0b3f6bf2f65757acbad6578cc8318f1f70    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 28 Mar 2020 17:09:51 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 28 Mar 2020 17:09:51 -0400    

Click here for diff

These uint16 fields could be overflowed by excessively long input,  
producing strange results.  Complain for invalid input.  
  
Likewise check for out-of-range values of the repeat counts in lquery.  
(We don't try too hard on that one, notably not bothering to detect  
if atoi's result has overflowed.)  
  
Also detect length overflow in ltree_concat.  
  
In passing, be more consistent about whether "syntax error" messages  
include the type name.  Also, clarify the documentation about what  
the size limit is.  
  
This has been broken for a long time, so back-patch to all supported  
branches.  
  
Nikita Glukhov, reviewed by Benjie Gillam and Tomas Vondra  
  
Discussion: https://postgr.es/m/CAP_rww=waX2Oo6q+MbMSiZ9ktdj6eaJj0cQzNu=Ry2cCDij5fw@mail.gmail.com  

M contrib/ltree/expected/ltree.out
M contrib/ltree/ltree.h
M contrib/ltree/ltree_io.c
M contrib/ltree/ltree_op.c
M contrib/ltree/sql/ltree.sql
M doc/src/sgml/ltree.sgml

Ensure snapshot is registered within ScanPgRelation().

commit   : 00a0a428ef503d50b74b8a08d6365a4a0ce04c14    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Sat, 28 Mar 2020 11:52:11 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Sat, 28 Mar 2020 11:52:11 -0700    

Click here for diff

In 9.4 I added support to use a historical snapshot in  
ScanPgRelation(), while adding logical decoding. Unfortunately a  
conflict with the concurrent removal of SnapshotNow was incorrectly  
resolved, leading to an unregistered snapshot being used.  
  
It is not correct to use an unregistered (or non-active) snapshot for  
anything non-trivial, because catalog invalidations can cause the  
snapshot to be invalidated.  
  
Luckily it seems unlikely to actively cause problems in practice, as  
ScanPgRelation() requires that we already have a lock on the relation,  
we only look for a single row, and we don't appear to rely on the  
result's tid to be correct. It however is clearly wrong and potential  
negative consequences would likely be hard to find. So it seems worth  
backpatching the fix, even without a concrete hazard.  
  
Discussion: https://postgr.es/m/20200229052459.wzhqnbhrriezg4v2@alap3.anarazel.de  
Backpatch: 9.5-  

M src/backend/utils/cache/relcache.c

Ensure that plpgsql cleans up cleanly during parallel-worker exit.

commit   : deeda011b316c5c27e4f1c926050a81ffe86c9ef    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 26 Mar 2020 18:06:55 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Thu, 26 Mar 2020 18:06:55 -0400    

Click here for diff

plpgsql_xact_cb ought to treat events XACT_EVENT_PARALLEL_COMMIT and  
XACT_EVENT_PARALLEL_ABORT like XACT_EVENT_COMMIT and XACT_EVENT_ABORT  
respectively, since its goal is to do process-local cleanup.  This  
oversight caused plpgsql's end-of-transaction cleanup to not get done  
in parallel workers.  Since a parallel worker will exit just after the  
transaction cleanup, the effects of this are limited.  I couldn't find  
any case in the core code with user-visible effects, but perhaps there  
are some in extensions.  In any case it's wrong, so let's fix it before  
it bites us not after.  
  
In passing, add some comments around the handling of expression  
evaluation resources in DO blocks.  There's no live bug there, but it's  
quite unobvious what's happening; at least I thought so.  This isn't  
related to the other issue, except that I found both things while poking  
at expression-evaluation performance.  
  
Back-patch the plpgsql_xact_cb fix to 9.5 where those event types  
were introduced, and the DO-block commentary to v11 where DO blocks  
gained the ability to issue COMMIT/ROLLBACK.  
  
Discussion: https://postgr.es/m/10353.1585247879@sss.pgh.pa.us  

M src/pl/plpgsql/src/pl_exec.c
M src/pl/plpgsql/src/pl_handler.c

Drop slot's LWLock before returning from SaveSlotToPath()

commit   : ba4cc05ce22d8b83194f46085f54c23b7e2f448c    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 26 Mar 2020 11:51:39 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Thu, 26 Mar 2020 11:51:39 +0100    

Click here for diff

When SaveSlotToPath() is called with elevel=LOG, the early exits didn't  
release the slot's io_in_progress_lock.  
  
This could result in a walsender being stuck on the lock forever.  A  
possible way to get into this situation is if the offending code paths  
are triggered in a low disk space situation.  
  
Author: Pavan Deolasee <pavan.deolasee@2ndquadrant.com>  
Reported-by: Craig Ringer <craig@2ndquadrant.com>  
Discussion: https://www.postgresql.org/message-id/flat/56a138c5-de61-f553-7e8f-6789296de785%402ndquadrant.com  

M src/backend/replication/slot.c

Add regression tests for constraint errors in partitioned tables.

commit   : 58995db07e374c2878960e0516acc49683ea102b    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 23 Mar 2020 14:24:06 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Mon, 23 Mar 2020 14:24:06 -0700    

Click here for diff

While #16293 only applied to 11 (and 10 to some degree), it seems best  
to add tests to all branches with partitioning support.  
  
Reported-By: Daniel WM  
Author: Andres Freund  
Bug: #16293  
Discussion: https://postgr.es/m/16293-26f5777d10143a66@postgresql.org  
Backpatch: 10-  

M src/test/regress/expected/inherit.out
M src/test/regress/sql/inherit.sql

Fix potential crash after constraint violation errors in partitioned tables.

commit   : d35631e37cab25e57f9402fdf208176a1951c87f    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Mon, 23 Mar 2020 13:57:43 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Mon, 23 Mar 2020 13:57:43 -0700    

Click here for diff

During the reporting of constraint violations for partitioned tables,  
ExecPartitionCheckEmitError(), ExecConstraints(),  
ExecWithCheckOptions() set the slot descriptor of the input slot to  
the root partition's tuple desc.  That's generally problematic when  
the slot could be used by other routines, but can cause crashes after  
the introduction of slots with "fixed" tuple descriptors in  
ad7dbee368a.  
  
The problem likely escaped detection so far for two reasons: First,  
currently the only known way that these routines are used with a  
partitioned table that is not "owned" by partitioning code is when  
"fast defaults" are used for the child partition. Second, as an error  
is raised afterwards, an "external" slot that had its descriptor  
changed, is very unlikely to continue being used.  
  
Even though the issue currently is only known to cause a crash for  
11 (as that has both fast defaults and "fixed" slot descriptors), it  
seems worth applying the fix to 10 too. Potentially changing random  
slots is hazardous.  
  
Regression tests will be added in a separate commit, as it seems best  
to add them for master and 12 too.  
  
Reported-By: Daniel WM  
Author: Andres Freund  
Bug: #16293  
Discussion: https://postgr.es/m/16293-26f5777d10143a66@postgresql.org  
Backpatch: 11, 10 only  

M src/backend/executor/execMain.c

Doc: explain that LIKE et al can be used in ANY (sub-select) etc.

commit   : 25bf317ccd5aa6050f1f0ac6aa5ed48cb5c6e98c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 23 Mar 2020 12:42:15 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 23 Mar 2020 12:42:15 -0400    

Click here for diff

This wasn't stated anywhere, and it's perhaps not that obvious,  
since we get questions about it from time to time.  Also undocumented  
was that the parser actually translates these into operators.  
  
Discussion: https://postgr.es/m/CAFj8pRBkvZ71BqGKZnBBG4=0cKG+s50Dy+DYmrizUKEpAtdc+w@mail.gmail.com  

M doc/src/sgml/func.sgml

Fix our getopt_long's behavior for a command line argument of just "-".

commit   : aae7e8530dac411fe4d9021e2392917458b37f8d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 23 Mar 2020 11:58:01 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 23 Mar 2020 11:58:01 -0400    

Click here for diff

src/port/getopt_long.c failed on such an argument, always seeing it  
as an unrecognized switch.  This is unhelpful; better is to treat such  
an item as a non-switch argument.  That behavior is what we find in  
GNU's getopt_long(); it's what src/port/getopt.c does; and it is  
required by POSIX for getopt(), which getopt_long() ought to be  
generally a superset of.  Moreover, it's expected by ecpg, which  
intends an argument of "-" to mean "read from stdin".  So fix it.  
  
Also add some documentation about ecpg's behavior in this area, since  
that was miserably underdocumented.  I had to reverse-engineer it  
from the code.  
  
Per bug #16304 from James Gray.  Back-patch to all supported branches,  
since this has been broken forever.  
  
Discussion: https://postgr.es/m/16304-c662b00a1322db7f@postgresql.org  

M doc/src/sgml/ref/ecpg-ref.sgml
M src/port/getopt_long.c

Doc: Fix type of some storage parameters in CREATE TABLE page

commit   : 26a26d9f2b20c2fab60ecb67e2f385abb784cc43    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 23 Mar 2020 13:38:14 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 23 Mar 2020 13:38:14 +0900    

Click here for diff

autovacuum_vacuum_scale_factor and autovacuum_analyze_scale_factor have  
been documented as "float4", but "floating type" is used in this case  
for GUCs and relation options in the documentation.  
  
Author: Atsushi Torikoshi  
Discussion: https://postgr.es/m/CACZ0uYFf_p9BpbjLccx3CA=eM1Hk2Te=ULY4iptGLUhL-JxCPA@mail.gmail.com  
Backpatch-through: 9.5  

M doc/src/sgml/ref/create_table.sgml

Revert "Skip WAL for new relfilenodes, under wal_level=minimal."

commit   : 2fbdebc248ec0694b1399f9bb2e317835baca066    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sun, 22 Mar 2020 09:24:09 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sun, 22 Mar 2020 09:24:09 -0700    

Click here for diff

This reverts commit cb2fd7eac285b1b0a24eeb2b8ed4456b66c5a09f.  Per  
numerous buildfarm members, it was incompatible with parallel query, and  
a test case assumed LP64.  Back-patch to 9.5 (all supported versions).  
  
Discussion: https://postgr.es/m/20200321224920.GB1763544@rfd.leadboat.com  

M doc/src/sgml/config.sgml
M doc/src/sgml/perform.sgml
M src/backend/access/gist/gistbuild.c
M src/backend/access/gist/gistutil.c
M src/backend/access/gist/gistxlog.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/rewriteheap.c
M src/backend/access/nbtree/nbtsort.c
M src/backend/access/rmgrdesc/gistdesc.c
M src/backend/access/transam/README
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlogutils.c
M src/backend/bootstrap/bootparse.y
M src/backend/catalog/storage.c
M src/backend/commands/cluster.c
M src/backend/commands/copy.c
M src/backend/commands/createas.c
M src/backend/commands/indexcmds.c
M src/backend/commands/matview.c
M src/backend/commands/tablecmds.c
M src/backend/nodes/copyfuncs.c
M src/backend/nodes/equalfuncs.c
M src/backend/nodes/outfuncs.c
M src/backend/parser/gram.y
M src/backend/parser/parse_utilcmd.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/lmgr/lock.c
M src/backend/storage/smgr/md.c
M src/backend/storage/smgr/smgr.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/misc/guc.c
M src/backend/utils/misc/postgresql.conf.sample
M src/include/access/gist_private.h
M src/include/access/gistxlog.h
M src/include/access/heapam.h
M src/include/access/rewriteheap.h
M src/include/catalog/storage.h
M src/include/nodes/parsenodes.h
M src/include/storage/bufmgr.h
M src/include/storage/lock.h
M src/include/storage/smgr.h
M src/include/utils/rel.h
M src/include/utils/relcache.h
D src/test/recovery/t/018_wal_optimize.pl
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/create_table.out
M src/test/regress/sql/alter_table.sql
M src/test/regress/sql/create_table.sql

Skip WAL for new relfilenodes, under wal_level=minimal.

commit   : 03b89f1949a99797ed21b0dabdf0aba1bbee8d0b    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    

Click here for diff

Until now, only selected bulk operations (e.g. COPY) did this.  If a  
given relfilenode received both a WAL-skipping COPY and a WAL-logged  
operation (e.g. INSERT), recovery could lose tuples from the COPY.  See  
src/backend/access/transam/README section "Skipping WAL for New  
RelFileNode" for the new coding rules.  Maintainers of table access  
methods should examine that section.  
  
To maintain data durability, just before commit, we choose between an  
fsync of the relfilenode and copying its contents to WAL.  A new GUC,  
wal_skip_threshold, guides that choice.  If this change slows a workload  
that creates small, permanent relfilenodes under wal_level=minimal, try  
adjusting wal_skip_threshold.  Users setting a timeout on COMMIT may  
need to adjust that timeout, and log_min_duration_statement analysis  
will reflect time consumption moving to COMMIT from commands like COPY.  
  
Internally, this requires a reliable determination of whether  
RollbackAndReleaseCurrentSubTransaction() would unlink a relation's  
current relfilenode.  Introduce rd_firstRelfilenodeSubid.  Amend the  
specification of rd_createSubid such that the field is zero when a new  
rel has an old rd_node.  Make relcache.c retain entries for certain  
dropped relations until end of transaction.  
  
Back-patch to 9.5 (all supported versions).  This introduces a new WAL  
record type, XLOG_GIST_ASSIGN_LSN, without bumping XLOG_PAGE_MAGIC.  As  
always, update standby systems before master systems.  This changes  
sizeof(RelationData) and sizeof(IndexStmt), breaking binary  
compatibility for affected extensions.  (The most recent commit to  
affect the same class of extensions was  
089e4d405d0f3b94c74a2c6a54357a84a681754b.)  
  
Kyotaro Horiguchi, reviewed (in earlier, similar versions) by Robert  
Haas.  Heikki Linnakangas and Michael Paquier implemented earlier  
designs that materially clarified the problem.  Reviewed, in earlier  
designs, by Andrew Dunstan, Andres Freund, Alvaro Herrera, Tom Lane,  
Fujii Masao, and Simon Riggs.  Reported by Martijn van Oosterhout.  
  
Discussion: https://postgr.es/m/20150702220524.GA9392@svana.org  

M doc/src/sgml/config.sgml
M doc/src/sgml/perform.sgml
M src/backend/access/gist/gistbuild.c
M src/backend/access/gist/gistutil.c
M src/backend/access/gist/gistxlog.c
M src/backend/access/heap/heapam.c
M src/backend/access/heap/rewriteheap.c
M src/backend/access/nbtree/nbtsort.c
M src/backend/access/rmgrdesc/gistdesc.c
M src/backend/access/transam/README
M src/backend/access/transam/xact.c
M src/backend/access/transam/xlogutils.c
M src/backend/bootstrap/bootparse.y
M src/backend/catalog/storage.c
M src/backend/commands/cluster.c
M src/backend/commands/copy.c
M src/backend/commands/createas.c
M src/backend/commands/indexcmds.c
M src/backend/commands/matview.c
M src/backend/commands/tablecmds.c
M src/backend/nodes/copyfuncs.c
M src/backend/nodes/equalfuncs.c
M src/backend/nodes/outfuncs.c
M src/backend/parser/gram.y
M src/backend/parser/parse_utilcmd.c
M src/backend/storage/buffer/bufmgr.c
M src/backend/storage/lmgr/lock.c
M src/backend/storage/smgr/md.c
M src/backend/storage/smgr/smgr.c
M src/backend/utils/cache/relcache.c
M src/backend/utils/misc/guc.c
M src/backend/utils/misc/postgresql.conf.sample
M src/include/access/gist_private.h
M src/include/access/gistxlog.h
M src/include/access/heapam.h
M src/include/access/rewriteheap.h
M src/include/catalog/storage.h
M src/include/nodes/parsenodes.h
M src/include/storage/bufmgr.h
M src/include/storage/lock.h
M src/include/storage/smgr.h
M src/include/utils/rel.h
M src/include/utils/relcache.h
A src/test/recovery/t/018_wal_optimize.pl
M src/test/regress/expected/alter_table.out
M src/test/regress/expected/create_table.out
M src/test/regress/sql/alter_table.sql
M src/test/regress/sql/create_table.sql

Back-patch log_newpage_range().

commit   : ae86e46c3b7b90903d89b65385e2b77d2c1cf63e    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 21 Mar 2020 09:38:33 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 21 Mar 2020 09:38:33 -0700    

Click here for diff

Back-patch a subset of commit 9155580fd5fc2a0cbb23376dfca7cd21f59c2c7b  
to v11, v10, 9.6, and 9.5.  Include the latest repairs to this function.  
Use a new XLOG_FPI_MULTI value instead of reusing XLOG_FPI.  That way,  
if an older server reads WAL from this function, that server will PANIC  
instead of applying just one page of the record.  The next commit adds a  
call to this function.  
  
Discussion: https://postgr.es/m/20200304.162919.898938381201316571.horikyota.ntt@gmail.com  

M src/backend/access/rmgrdesc/xlogdesc.c
M src/backend/access/transam/xlog.c
M src/backend/access/transam/xloginsert.c
M src/backend/replication/logical/decode.c
M src/include/access/xloginsert.h
M src/include/catalog/pg_control.h

During heap rebuild, lock any TOAST index until end of transaction.

commit   : 4433c6e8c0a5d0891c9bb52d14e73464086c0375    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    

Click here for diff

swap_relation_files() calls toast_get_valid_index() to find and lock  
this index, just before swapping with the rebuilt TOAST index.  The  
latter function releases the lock before returning.  Potential for  
mischief is low; a concurrent session can issue ALTER INDEX ... SET  
(fillfactor = ...), which is not alarming.  Nonetheless, changing  
pg_class.relfilenode without a lock is unconventional.  Back-patch to  
9.5 (all supported versions), because another fix needs this.  
  
Discussion: https://postgr.es/m/20191226001521.GA1772687@rfd.leadboat.com  

M src/backend/access/heap/tuptoaster.c
M src/backend/commands/cluster.c

Fix cosmetic blemishes involving rd_createSubid.

commit   : 03e99a674979b6143e0917243fe9517fede278a2    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Sat, 21 Mar 2020 09:38:26 -0700    

Click here for diff

Remove an obsolete comment from AtEOXact_cleanup().  Restore formatting  
of a comment in struct RelationData, mangled by the pgindent run in  
commit 9af4159fce6654aa0e081b00d02bca40b978745c.  Back-patch to 9.5 (all  
supported versions), because another fix stacks on this.  

M src/backend/utils/cache/relcache.c
M src/include/utils/rel.h

docs: use alias in WHERE clause of full text search example

commit   : 0c96744a8769c4651c8ecce91762b6c606bb01ae    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 20 Mar 2020 20:19:32 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 20 Mar 2020 20:19:32 -0400    

Click here for diff

The current doc query specified an alias in the FROM clause and used in  
it the target list, but not in the WHERE clause.  
  
Reported-by: axykon@gmail.com  
  
Discussion: https://postgr.es/m/158316348159.30450.16075357948244298217@wrigleys.postgresql.org  
  
Backpatch-through: 9.5  

M doc/src/sgml/textsearch.sgml

Turn off deprecated bison warnings under MSVC

commit   : e8a6391fc1837416b7251f62485323af01789559    
  
author   : Andrew Dunstan <andrew@dunslane.net>    
date     : Fri, 20 Mar 2020 13:55:15 -0400    
  
committer: Andrew Dunstan <andrew@dunslane.net>    
date     : Fri, 20 Mar 2020 13:55:15 -0400    

Click here for diff

These are disabled by the configure code, so this is just fixing an  
inconsistency in the MSVC code.  
  
Backpatch to all live branches.  

M src/tools/msvc/pgbison.pl

pg_upgrade: make get_major_server_version() err msg consistent

commit   : 6802942fa2a638c6f5614e56546af276308cf4bd    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 19 Mar 2020 15:20:55 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 19 Mar 2020 15:20:55 -0400    

Click here for diff

This patch fixes the error message in get_major_server_version() to be  
"could not parse version file", and uses the full file path name, rather  
than just the data directory path.  
  
Also, commit 4109bb5de4 added the cause of the failure to the  "could  
not open" error message, and improved quoting.  This patch backpatches  
the "could not open" cause to PG 12, where it was first widely used, and  
backpatches the quoting fix in that patch to all supported releases.  
  
Reported-by: Tom Lane  
  
Discussion: https://postgr.es/m/87pne2w98h.fsf@wibble.ilmari.org  
  
Author: Dagfinn Ilmari Mannsåker  
  
Backpatch-through: 9.5  

M src/bin/pg_upgrade/server.c

commit   : 375aa3fc2cb21132db6790305b433d81061367e2    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 18 Mar 2020 23:07:17 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 18 Mar 2020 23:07:17 +0900    

Click here for diff

This commit corrects the descriptions of RecoveryWalAll and RecoveryWalStream  
wait events in the documentation.  
  
Back-patch to v10 where those wait events were added.  
  
Author: Fujii Masao  
Reviewed-by: Kyotaro Horiguchi, Atsushi Torikoshi  
Discussion: https://postgr.es/m/124997ee-096a-5d09-d8da-2c7a57d0816e@oss.nttdata.com  

M doc/src/sgml/monitoring.sgml

Add missing errcode() in a few ereport calls.

commit   : 18c41cb6b7140a0d360900c10ac23072579194a1    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 18 Mar 2020 09:37:08 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 18 Mar 2020 09:37:08 +0530    

Click here for diff

This will allow to specifying SQLSTATE error code for the errors in the  
missing places.  
  
Reported-by: Sawada Masahiko  
Author: Sawada Masahiko  
Backpatch-through: 9.5  
Discussion: https://postgr.es/m/CA+fd4k6N8EjNvZpM8nme+y+05mz-SM8Z_BgkixzkA34R+ej0Kw@mail.gmail.com  

M contrib/adminpack/adminpack.c
M src/backend/storage/page/bufpage.c

Doc: clarify behavior of "anyrange" pseudo-type.

commit   : 974c8ea0afe35a55c1b9ffb9f2090058b9f356dd    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 17 Mar 2020 15:05:17 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 17 Mar 2020 15:05:17 -0400    

Click here for diff

I noticed that we completely failed to document the restriction  
that an "anyrange" result type has to be inferred from an "anyrange"  
input.  The docs also were less clear than they could be about the  
relationship between "anyrange" and "anyarray".  
  
It's been like this all along, so back-patch.  

M doc/src/sgml/extend.sgml

Use pkg-config, if available, to locate libxml2 during configure.

commit   : 9af2f7dc9603bf1fd1f80a6326cc80e83acd3076    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 17 Mar 2020 12:09:27 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Tue, 17 Mar 2020 12:09:27 -0400    

Click here for diff

If pkg-config is installed and knows about libxml2, use its information  
rather than asking xml2-config.  Otherwise proceed as before.  This  
patch allows "configure --with-libxml" to succeed on platforms that  
have pkg-config but not xml2-config, which is likely to soon become  
a typical situation.  
  
The old mechanism can be forced by setting XML2_CONFIG explicitly  
(hence, build processes that were already doing so will certainly  
not need adjustment).  Also, it's now possible to set XML2_CFLAGS  
and XML2_LIBS explicitly to override both programs.  
  
There is a small risk of this breaking existing build processes,  
if there are multiple libxml2 installations on the machine and  
pkg-config disagrees with xml2-config about which to use.  The  
only case where that seems really likely is if a builder has tried  
to select a non-default xml2-config by putting it early in his PATH  
rather than setting XML2_CONFIG.  Plan to warn against that in the  
minor release notes.  
  
Back-patch to v10; before that we had no pkg-config infrastructure,  
and it doesn't seem worth adding it for this.  
  
Hugh McMaster and Tom Lane; Peter Eisentraut also made an earlier  
attempt at this, from which I lifted most of the docs changes.  
  
Discussion: https://postgr.es/m/CAN9BcdvfUwc9Yx5015bLH2TOiQ-M+t_NADBSPhMF7dZ=pLa_iw@mail.gmail.com  

M configure
M configure.in
M doc/src/sgml/installation.sgml

Avoid holding a directory FD open across assorted SRF calls.

commit   : 819d5525744bff600b6073804a7a5eb7a9342a8b    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 16 Mar 2020 21:05:29 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 16 Mar 2020 21:05:29 -0400    

Click here for diff

This extends the fixes made in commit 085b6b667 to other SRFs with the  
same bug, namely pg_logdir_ls(), pgrowlocks(), pg_timezone_names(),  
pg_ls_dir(), and pg_tablespace_databases().  
  
Also adjust various comments and documentation to warn against  
expecting to clean up resources during a ValuePerCall SRF's final  
call.  
  
Back-patch to all supported branches, since these functions were  
all born broken.  
  
Justin Pryzby, with cosmetic tweaks by me  
  
Discussion: https://postgr.es/m/20200308173103.GC1357@telsasoft.com  

M contrib/adminpack/adminpack.c
M contrib/pgrowlocks/pgrowlocks.c
M doc/src/sgml/xfunc.sgml
M src/backend/utils/adt/datetime.c
M src/backend/utils/adt/genfile.c
M src/backend/utils/adt/misc.c
M src/backend/utils/fmgr/README
M src/include/funcapi.h
M src/test/regress/expected/misc_functions.out
M src/test/regress/sql/misc_functions.sql

Document pg_ls_*dir hiding of directories and special files

commit   : a6b5ddf64ce24532c69a24f1b3e13dbaa81ccbba    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Mon, 16 Mar 2020 19:12:14 -0300    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Mon, 16 Mar 2020 19:12:14 -0300    

Click here for diff

It's strange that a directory-listing function does not list all entries  
in a directory, so let's at least document it.  This involves  
  
pg_ls_logdir  
pg_ls_waldir  
pg_ls_archive_statusdir  
pg_ls_tmpdir  
  
Backpatch as far back as it applies cleanly (and as far as as each  
function exists).  REL_10_STABLE uses different wording, but hopefully  
people are not reading docs so old to write new apps anyway.  
  
Author: Justin Pryzby <pryzby@telsasoft.com>  
Discussion: https://postgr.es/m/20200305161838.GJ684@telsasoft.com  

M doc/src/sgml/func.sgml

Plug memory leak

commit   : 55978e28cd50e7db02289e1dca93a9284c7c2b05    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Mon, 16 Mar 2020 16:27:13 -0300    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Mon, 16 Mar 2020 16:27:13 -0300    

Click here for diff

Introduced by b08dee24a557.  Noted by Coverity.  

M src/bin/pg_dump/pg_dump.c

Restructure polymorphic-type resolution in funcapi.c.

commit   : 540ef37cc00d5b4ad3ae2bde8410bcb572bd174d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 14 Mar 2020 14:42:22 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 14 Mar 2020 14:42:22 -0400    

Click here for diff

resolve_polymorphic_tupdesc() and resolve_polymorphic_argtypes() failed to  
cover the case of having to resolve anyarray given only an anyrange input.  
The bug was masked if anyelement was also used (as either input or  
output), which probably helps account for our not having noticed.  
  
While looking at this I noticed that resolve_generic_type() would produce  
the wrong answer if asked to make that same resolution.  ISTM that  
resolve_generic_type() is confusingly defined and overly complex, so  
rather than fix it, let's just make funcapi.c do the specific lookups  
it requires for itself.  
  
With this change, resolve_generic_type() is not used anywhere, so remove  
it in HEAD.  In the back branches, leave it alone (complete with bug)  
just in case any external code is using it.  
  
While we're here, make some other refactoring adjustments in funcapi.c  
with an eye to upcoming future expansion of the set of polymorphic types:  
  
* Simplify quick-exit tests by adding an overall have_polymorphic_result  
flag.  This is about a wash now but will be a win when there are more  
flags.  
  
* Reduce duplication of code between resolve_polymorphic_tupdesc() and  
resolve_polymorphic_argtypes().  
  
* Don't bother to validate correct matching of anynonarray or anyenum;  
the parser should have done that, and even if it didn't, just doing  
"return false" here would lead to a very confusing, off-point error  
message.  (Really, "return false" in these two functions should only  
occur if the call_expr isn't supplied or we can't obtain data type  
info from it.)  
  
* For the same reason, throw an elog rather than "return false" if  
we fail to resolve a polymorphic type.  
  
The bug's been there since we added anyrange, so back-patch to  
all supported branches.  
  
Discussion: https://postgr.es/m/6093.1584202130@sss.pgh.pa.us  

M src/backend/utils/fmgr/funcapi.c
M src/test/regress/expected/rangetypes.out
M src/test/regress/sql/rangetypes.sql

Doc: fix mistaken reference to "PG_ARGNULL_xxx()" macro.

commit   : 7e32aaab589a8927c22d3b83d55fc0e77424b348    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 13 Mar 2020 12:49:10 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 13 Mar 2020 12:49:10 -0400    

Click here for diff

This should of course be just "PG_ARGISNULL()".  
  
Also reorder a couple of paras to make the discussion of PG_ARGISNULL  
less disjointed.  
  
Back-patch to v10 where the error was introduced.  
  
Laurenz Albe and Tom Lane, per an anonymous docs comment  
  
Discussion: https://postgr.es/m/158399487096.5708.10696365251766477013@wrigleys.postgresql.org  

M doc/src/sgml/xfunc.sgml

Preserve replica identity index across ALTER TABLE rewrite

commit   : 15cbbf81a58fd04479c0e5ff134838492473e935    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 13 Mar 2020 11:28:11 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Fri, 13 Mar 2020 11:28:11 +0100    

Click here for diff

If an index was explicitly set as replica identity index, this setting  
was lost when a table was rewritten by ALTER TABLE.  Because this  
setting is part of pg_index but actually controlled by ALTER  
TABLE (not part of CREATE INDEX, say), we have to do some extra work  
to restore it.  
  
Based-on-patch-by: Quan Zongliang <quanzongliang@gmail.com>  
Reviewed-by: Euler Taveira <euler.taveira@2ndquadrant.com>  
Discussion: https://www.postgresql.org/message-id/flat/c70fcab2-4866-0d9f-1d01-e75e189db342@gmail.com  

M src/backend/commands/tablecmds.c
M src/backend/utils/cache/lsyscache.c
M src/include/utils/lsyscache.h
M src/test/regress/expected/replica_identity.out
M src/test/regress/sql/replica_identity.sql

Fix nextXid tracking bug on standbys (9.5-11 only).

commit   : a493f933422c97f40584efbd07c3e6884ed3ace3    
  
author   : Thomas Munro <tmunro@postgresql.org>    
date     : Thu, 12 Mar 2020 18:06:54 +1300    
  
committer: Thomas Munro <tmunro@postgresql.org>    
date     : Thu, 12 Mar 2020 18:06:54 +1300    

Click here for diff

RecordKnownAssignedTransactionIds() should never move  
nextXid backwards.  Before this commit, that could happen  
if some other code path had advanced it without advancing  
latestObservedXid.  
  
One consequence is that a well timed XLOG_CHECKPOINT_ONLINE  
could cause hot standby feedback messages to get confused  
and report an xmin from a future epoch, potentially allowing  
vacuum to run too soon on the primary.  
  
Repair, by making sure RecordKnownAssignedTransactionIds()  
can only move nextXid forwards.  
  
In release 12 and master, this was already done by commit  
2fc7af5e, which consolidated similar code and straightened  
out this bug.  Back-patch to supported releases before that.  
  
Author: Eka Palamadai <ekanatha@amazon.com>  
Discussion: https://postgr.es/m/98BB4805-D0A2-48E1-96F4-15014313EADC@amazon.com  

M src/backend/storage/ipc/procarray.c

Fix test case instability introduced in 085b6b667.

commit   : 13f353b0e0775642c212ac557b371eefa171d179    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 11 Mar 2020 18:23:57 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 11 Mar 2020 18:23:57 -0400    

Click here for diff

I forgot that the WAL directory might hold other files besides WAL  
segments, notably including new segments still being filled.  
That means a blind test for the first file's size being 16MB can  
fail.  Restrict based on file name length to make it more robust.  
  
Per buildfarm.  

M src/test/regress/expected/misc_functions.out
M src/test/regress/sql/misc_functions.sql

Paper over bt_metap() oldest_xact bug in backbranches.

commit   : c788115b5eb50d666023aa6f6e7faee21288401c    
  
author   : Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 11 Mar 2020 14:15:00 -0700    
  
committer: Peter Geoghegan <pg@bowt.ie>    
date     : Wed, 11 Mar 2020 14:15:00 -0700    

Click here for diff

The data types that contrib/pageinspect's bt_metap() function were  
declared to return as OUT arguments were wrong in some cases.  In  
particular, the oldest_xact column (a TransactionId/xid field) was  
declared integer/int4 within the pageinspect extension's sql file.  This  
led to errors when an oldest_xact value that exceeded 2^31-1 was  
encountered.  
  
We cannot fix the declaration on Postgres 11 or 12.  All we can do is  
ameliorate the problem.  Use "%d" instead of "%u" to format the output  
of the oldest_xact value.  This makes the C code match the declaration,  
suppressing unhelpful error messages that might otherwise make  
bt_metap() totally unusable.  A bogus negative oldest_xact value will be  
displayed instead of raising an error.  
  
This commit addresses the same issue as master branch commit 691e8b2e18,  
which actually fixed the problem.  Backpatch to the 11 and 12 branches  
only, since they are the only branches (other than master) that have  
oldest_xact.  All of the other problematic columns already display bogus  
output for out of range values.  
  
Reported-By: Victor Yegorov  
Bug: #16285  
Discussion: https://postgr.es/m/20200309223557.aip5n6ewln4ixbbi@alap3.anarazel.de  
Backpatch: 11 and 12 only  

M contrib/pageinspect/btreefuncs.c

Add pg_dump support for ALTER obj DEPENDS ON EXTENSION

commit   : e70187c9b47cc1035a42196e62c4b5958f122a77    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 11 Mar 2020 16:54:54 -0300    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 11 Mar 2020 16:54:54 -0300    

Click here for diff

pg_dump is oblivious to this kind of dependency, so they're lost on  
dump/restores (and pg_upgrade).  Have pg_dump emit ALTER lines so that  
they're preserved.  Add some pg_dump tests for the whole thing, also.  
  
Reviewed-by: Tom Lane (offlist)  
Reviewed-by: Ibrar Ahmed  
Reviewed-by: Ahsan Hadi (who also reviewed commit 899a04f5ed61)  
Discussion: https://postgr.es/m/20200217225333.GA30974@alvherre.pgsql  

M src/bin/pg_dump/common.c
M src/bin/pg_dump/pg_dump.c
M src/bin/pg_dump/pg_dump.h
M src/test/modules/test_pg_dump/t/001_base.pl

Avoid holding a directory FD open across pg_ls_dir_files() calls.

commit   : 63b51dfec18eb3c280adfa0f6e970946c441f574    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 11 Mar 2020 15:27:59 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 11 Mar 2020 15:27:59 -0400    

Click here for diff

This coding technique is undesirable because (a) it leaks the FD for  
the rest of the transaction if the SRF is not run to completion, and  
(b) allocated FDs are a scarce resource, but multiple interleaved  
uses of the relevant functions could eat many such FDs.  
  
In v11 and later, a query such as "SELECT pg_ls_waldir() LIMIT 1"  
yields a warning about the leaked FD, and the only reason there's  
no warning in earlier branches is that fd.c didn't whine about such  
leaks before commit 9cb7db3f0.  Even disregarding the warning, it  
wouldn't be too hard to run a backend out of FDs with careless use  
of these SQL functions.  
  
Hence, rewrite the function so that it reads the directory within  
a single call, returning the results as a tuplestore rather than  
via value-per-call mode.  
  
There are half a dozen other built-in SRFs with similar problems,  
but let's fix this one to start with, just to see if the buildfarm  
finds anything wrong with the code.  
  
In passing, fix bogus error report for stat() failure: it was  
whining about the directory when it should be fingering the  
individual file.  Doubtless a copy-and-paste error.  
  
Back-patch to v10 where this function was added.  
  
Justin Pryzby, with cosmetic tweaks and test cases by me  
  
Discussion: https://postgr.es/m/20200308173103.GC1357@telsasoft.com  

M src/backend/utils/adt/genfile.c
M src/test/regress/expected/misc_functions.out
M src/test/regress/sql/misc_functions.sql

Avoid duplicates in ALTER ... DEPENDS ON EXTENSION

commit   : 7c094a11c70d4790ae4067023806a026c6fd2fe1    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 11 Mar 2020 11:04:59 -0300    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 11 Mar 2020 11:04:59 -0300    

Click here for diff

If the command is attempted for an extension that the object already  
depends on, silently do nothing.  
  
In particular, this means that if a database containing multiple such  
entries is dumped, the restore will silently do the right thing and  
record just the first one.  (At least, in a world where pg_dump does  
dump such entries -- which it doesn't currently, but it will.)  
  
Backpatch to 9.6, where this kind of dependency was introduced.  
  
Reviewed-by: Ibrar Ahmed, Tom Lane (offlist)  
Discussion: https://postgr.es/m/20200217225333.GA30974@alvherre.pgsql  

M src/backend/catalog/pg_depend.c
M src/backend/commands/alter.c
M src/include/catalog/dependency.h
M src/test/modules/test_extensions/expected/test_extdepend.out
M src/test/modules/test_extensions/sql/test_extdepend.sql

Fix pg_dump/pg_restore to restore event triggers later.

commit   : f5d49f22653e6af61eee027153dcfd13e0256d85    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Mar 2020 14:58:11 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 9 Mar 2020 14:58:11 -0400    

Click here for diff

Previously, event triggers were restored just after regular triggers  
(and FK constraints, which are basically triggers).  This is risky  
since an event trigger, once installed, could interfere with subsequent  
restore commands.  Worse, because event triggers don't have any  
particular dependencies on any post-data objects, a parallel restore  
would consider them eligible to be restored the moment the post-data  
phase starts, allowing them to also interfere with restoration of a  
whole bunch of objects that would have been restored before them in  
a serial restore.  There's no way to completely remove the risk of a  
misguided event trigger breaking the restore, since if nothing else  
it could break other event triggers.  But we can certainly push them  
to later in the process to minimize the hazard.  
  
To fix, tweak the RestorePass mechanism introduced by commit 3eb9a5e7c  
so that event triggers are handled as part of the post-ACL processing  
pass (renaming the "REFRESH" pass to "POST_ACL" to reflect its more  
general use).  This will cause them to restore after everything except  
matview refreshes, which seems OK since matview refreshes really ought  
to run in the post-restore state of the database.  In a parallel  
restore, event triggers and matview refreshes might be intermixed,  
but that seems all right as well.  
  
Also update the code and comments in pg_dump_sort.c so that its idea  
of how things are sorted agrees with what actually happens due to  
the RestorePass mechanism.  This is mostly cosmetic: it'll affect the  
order of objects in a dump's TOC, but not the actual restore order.  
But not changing that would be quite confusing to somebody reading  
the code.  
  
Back-patch to all supported branches.  
  
Fabrízio de Royes Mello, tweaked a bit by me  
  
Discussion: https://postgr.es/m/CAFcNs+ow1hmFox8P--3GSdtwz-S3Binb6ZmoP6Vk+Xg=K6eZNA@mail.gmail.com  

M src/bin/pg_dump/pg_backup_archiver.c
M src/bin/pg_dump/pg_backup_archiver.h
M src/bin/pg_dump/pg_dump_sort.c

Fix bug that causes to report waiting in PS display twice, in hot standby.

commit   : e54183cb0bfda14b89f9e01caaec089aec8a29e8    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 10 Mar 2020 00:14:43 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 10 Mar 2020 00:14:43 +0900    

Click here for diff

Previously "waiting" could appear twice via PS in case of lock conflict  
in hot standby mode. Specifically this issue happend when the delay  
in WAL application determined by max_standby_archive_delay and  
max_standby_streaming_delay had passed but it took more than 500 msec  
to cancel all the conflicting transactions. Especially we can observe this  
easily by setting those delay parameters to -1.  
  
The cause of this issue was that WaitOnLock() and  
ResolveRecoveryConflictWithVirtualXIDs() added "waiting" to  
the process title in that case. This commit prevents  
ResolveRecoveryConflictWithVirtualXIDs() from reporting waiting  
in case of lock conflict, to fix the bug.  
  
Back-patch to all back branches.  
  
Author: Masahiko Sawada  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/CA+fd4k4mXWTwfQLS3RPwGr4xnfAEs1ysFfgYHvmmoUgv6Zxvmg@mail.gmail.com  

M src/backend/storage/ipc/standby.c

Avoid assertion failure with targeted recovery in standby mode.

commit   : 500fe161edd0eee20fb12365609f0db215db34f7    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 9 Mar 2020 15:31:31 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 9 Mar 2020 15:31:31 +0900    

Click here for diff

At the end of recovery, standby mode is turned off to re-fetch the last  
valid record from archive or pg_wal. Previously, if recovery target was  
reached and standby mode was turned off while the current WAL source  
was stream, recovery could try to retrieve WAL file containing the last  
valid record unexpectedly from stream even though not in standby mode.  
This caused an assertion failure. That is, the assertion test confirms that  
WAL file should not be retrieved from stream if standby mode is not true.  
  
This commit moves back the current WAL source to archive if it's stream  
even though not in standby mode, to avoid that assertion failure.  
  
This issue doesn't cause the server to crash when built with assertion  
disabled. In this case, the attempt to retrieve WAL file from stream not  
in standby mode just fails. And then recovery tries to retrieve WAL file  
from archive or pg_wal.  
  
Back-patch to all supported branches.  
  
Author: Kyotaro Horiguchi  
Reviewed-by: Fujii Masao  
Discussion: https://postgr.es/m/20200227.124830.2197604521555566121.horikyota.ntt@gmail.com  

M src/backend/access/transam/xlog.c

Fix typo

commit   : 53a039da62bb967c60522572e1e69e25cc94d6ed    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 7 Mar 2020 08:51:59 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Sat, 7 Mar 2020 08:51:59 +0100    

Click here for diff

M src/backend/catalog/objectaddress.c

Fix assertion failure with ALTER TABLE ATTACH PARTITION and indexes

commit   : 75839fcf829f25f6b1c78416a6161617285fe201    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Tue, 3 Mar 2020 13:56:34 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Tue, 3 Mar 2020 13:56:34 +0900    

Click here for diff

Using ALTER TABLE ATTACH PARTITION causes an assertion failure when  
attempting to work on a partitioned index, because partitioned indexes  
cannot have partition bounds.  
  
The grammar of ALTER TABLE ATTACH PARTITION requires partition bounds,  
but not ALTER INDEX, so mixing ALTER TABLE with partitioned indexes is  
confusing.  Hence, on HEAD, prevent ALTER TABLE to attach a partition if  
the relation involved is a partitioned index.  On back-branches, as  
applications may rely on the existing behavior, just remove the  
culprit assertion.  
  
Reported-by: Alexander Lakhin  
Author: Amit Langote, Michael Paquier  
Discussion: https://postgr.es/m/16276-5cd1dcc8fb8be7b5@postgresql.org  
Backpatch-through: 11  

M src/backend/parser/parse_utilcmd.c
M src/test/regress/expected/indexing.out
M src/test/regress/sql/indexing.sql

Fix the name of the first WAL segment file, in docs.

commit   : 53fc42c6d13c72653b929c968bc1e8de6263508a    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Mar 2020 12:22:04 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Tue, 3 Mar 2020 12:22:04 +0900    

Click here for diff

Previously the documentation explains that WAL segment files  
start at 000000010000000000000000. But the first WAL segment file  
that initdb creates is 000000010000000000000001 not  
000000010000000000000000. This change was caused by old  
commit 8c843fff2d, but the documentation had not been updated  
a long time.  
  
Back-patch to all supported branches.  
  
Author: Fujii Masao  
Reviewed-by: David Zhang  
Discussion: https://postgr.es/m/CAHGQGwHOmGe2OqGOmp8cOfNVDivq7dbV74L5nUGr+3eVd2CU2Q@mail.gmail.com  

M doc/src/sgml/wal.sgml

Correctly re-use hash tables in buildSubPlanHash().

commit   : 9eb6b652a46d0b13658be80013f5b893ac1d7894    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 29 Feb 2020 13:48:10 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Sat, 29 Feb 2020 13:48:10 -0500    

Click here for diff

Commit 356687bd8 omitted to remove leftover code for destroying  
a hashed subplan's hash tables, with the result that the tables  
were always rebuilt not reused; this leads to severe memory  
leakage if a hashed subplan is re-executed enough times.  
Moreover, the code for reusing the hashnulls table had a typo  
that would have made it do the wrong thing if it were reached.  
  
Looking at the code coverage report shows severe under-coverage  
of the potential callers of ResetTupleHashTable, so add some test  
cases that exercise them.  
  
Andreas Karlsson and Tom Lane, per reports from Ranier Vilela  
and Justin Pryzby.  
  
Backpatch to v11, as the faulty commit was.  
  
Discussion: https://postgr.es/m/edb62547-c453-c35b-3ed6-a069e4d6b937@proxel.se  
Discussion: https://postgr.es/m/CAEudQAo=DCebm1RXtig9OH+QivpS97sMkikt0A9qHmMUs+g6ZA@mail.gmail.com  
Discussion: https://postgr.es/m/20200210032547.GA1412@telsasoft.com  

M src/backend/executor/nodeSubplan.c
M src/test/regress/expected/subselect.out
M src/test/regress/sql/subselect.sql

Avoid failure if autovacuum tries to access a just-dropped temp namespace.

commit   : 7ea20a2bc6bdd2dccc8e63a03fcd0a002ed447ab    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 28 Feb 2020 20:28:34 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 28 Feb 2020 20:28:34 -0500    

Click here for diff

Such an access became possible when commit 246a6c8f7 added more  
aggressive cleanup of orphaned temp relations by autovacuum.  
Since autovacuum's snapshot might be slightly stale, it could  
attempt to access an already-dropped temp namespace, resulting in  
an assertion failure or null-pointer dereference.  (In practice,  
since we don't drop temp namespaces automatically but merely  
recycle them, this situation could only arise if a superuser does  
a manual drop of a temp namespace.  Still, that should be allowed.)  
  
The core of the bug, IMO, is that isTempNamespaceInUse and its callers  
failed to think hard about whether to treat "temp namespace isn't there"  
differently from "temp namespace isn't in use".  In hopes of forestalling  
future mistakes of the same ilk, replace that function with a new one  
checkTempNamespaceStatus, which makes the same tests but returns a  
three-way enum rather than just a bool.  isTempNamespaceInUse is gone  
entirely in HEAD; but just in case some external code is relying on it,  
keep it in the back branches, as a bug-compatible wrapper around the  
new function.  
  
Per report originally from Prabhat Kumar Sahu, investigated by Mahendra  
Singh and Michael Paquier; the final form of the patch is my fault.  
This replaces the failed fix attempt in a052f6cbb.  
  
Backpatch as far as v11, as 246a6c8f7 was.  
  
Discussion: https://postgr.es/m/CAKYtNAr9Zq=1-ww4etHo-VCC-k120YxZy5OS01VkaLPaDbv2tg@mail.gmail.com  

M src/backend/catalog/namespace.c
M src/backend/postmaster/autovacuum.c
M src/include/catalog/namespace.h

Doc: correct thinko in pg_buffercache documentation.

commit   : 880643b9cd1b87c1afb376a9f9a6f5a1df7aa644    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 28 Feb 2020 11:29:59 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 28 Feb 2020 11:29:59 -0500    

Click here for diff

Access to this module is granted to the pg_monitor role, not  
pg_read_all_stats.  (Given the view's performance impact,  
it seems wise to be restrictive, so I think this was the  
correct decision --- and anyway it was clearly intentional.)  
  
Per bug #16279 from Philip Semanchuk.  
  
Discussion: https://postgr.es/m/16279-fcaac33c68aab0ab@postgresql.org  

M doc/src/sgml/pgbuffercache.sgml

Remove TAP test for createdb --lc-ctype

commit   : 8e076f4f9ae3c19c8142e88ca1b6b1d25899dc64    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 27 Feb 2020 21:58:50 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 27 Feb 2020 21:58:50 +0900    

Click here for diff

OpenBSD falls back to "C" when using an incorrect input with setlocale()  
and LC_CTYPE, causing this test, introduced by 008cf04, to fail.  This  
removes the culprit test to avoid the portability issue.  
  
Per report from Robert Haas, via buildfarm member curculio.  
  
Discussion: https://postgr.es/m/CA+TgmoZ6ddh3mHD9gU8DvNYoFmuJaYYn1+4AvZNp25vTdRwCAQ@mail.gmail.com  
Backpatch-through: 11  

M src/bin/scripts/t/020_createdb.pl

Skip foreign tablespaces when running pg_checksums/pg_verify_checksums

commit   : 8f9aba1874eccae860d5a6ced9b2899b2f7895b4    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 27 Feb 2020 15:31:52 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 27 Feb 2020 15:31:52 +0900    

Click here for diff

Attempting to use pg_checksums (pg_verify_checksums in 11) on a data  
folder which includes tablespace paths used across multiple major  
versions would cause pg_checksums to scan all directories present in  
pg_tblspc, and not only marked with TABLESPACE_VERSION_DIRECTORY.  This  
could lead to failures when for example running sanity checks on an  
upgraded instance with --check.  Even worse, it was possible to rewrite  
on-disk pages with --enable for a cluster potentially online.  
  
This commit makes pg_checksums skip any directories not named  
TABLESPACE_VERSION_DIRECTORY, similarly to what is done for base  
backups.  
  
Reported-by: Michael Banck  
Author: Michael Banck, Bernd Helmle  
Discussion: https://postgr.es/m/62031974fd8e941dd8351fbc8c7eff60d59c5338.camel@credativ.de  
backpatch-through: 11  

M src/bin/pg_verify_checksums/pg_verify_checksums.c

createdb: Fix quoting of --encoding, --lc-ctype and --lc-collate

commit   : 83bd732eb2c83a26db9eefb4595615fa289620a8    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 27 Feb 2020 11:21:07 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 27 Feb 2020 11:21:07 +0900    

Click here for diff

The original coding failed to properly quote those arguments, leading to  
failures when using quotes in the values used.  As the quoting can be  
encoding-sensitive, the connection to the backend needs to be taken  
before applying the correct quoting.  
  
Author: Michael Paquier  
Reviewed-by: Daniel Gustafsson  
Discussion: https://postgr.es/m/20200214041004.GB1998@paquier.xyz  
Backpatch-through: 9.5  

M src/bin/scripts/createdb.c
M src/bin/scripts/t/020_createdb.pl

Fix docs regarding AFTER triggers on partitioned tables

commit   : 143152439dc9482b1ae983f2819453e7300eca7f    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 26 Feb 2020 19:57:14 -0300    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Wed, 26 Feb 2020 19:57:14 -0300    

Click here for diff

In commit 86f575948c77 I forgot to update the trigger.sgml paragraph  
that needs to explain that AFTER triggers are allowed in partitioned  
tables.  Do so now.  
  
Discussion: https://postgr.es/m/20200224185850.GA30899@alvherre.pgsql  

M doc/src/sgml/trigger.sgml

Add prefix checks in exclude lists for pg_rewind, pg_checksums and base backups

commit   : da2a7180aa0ed18d4e283a934d3f789912fd99c5    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Mon, 24 Feb 2020 18:14:22 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Mon, 24 Feb 2020 18:14:22 +0900    

Click here for diff

An instance of PostgreSQL crashing with a bad timing could leave behind  
temporary pg_internal.init files, potentially causing failures when  
verifying checksums.  As the same exclusion lists are used between  
pg_rewind, pg_checksums and basebackup.c, all those tools are extended  
with prefix checks to keep everything in sync, with dedicated checks  
added for pg_internal.init.  
  
Backpatch down to 11, where pg_checksums (pg_verify_checksums in 11) and  
checksum verification for base backups have been introduced.  
  
Reported-by: Michael Banck  
Author: Michael Paquier  
Reviewed-by: Kyotaro Horiguchi, David Steele  
Discussion: https://postgr.es/m/62031974fd8e941dd8351fbc8c7eff60d59c5338.camel@credativ.de  
Backpatch-through: 11  

M src/backend/replication/basebackup.c
M src/bin/pg_basebackup/t/010_pg_basebackup.pl
M src/bin/pg_rewind/filemap.c
M src/bin/pg_verify_checksums/pg_verify_checksums.c

Remove extra word from comment.

commit   : 2eadd00dd475e8f8731d67baf2a2296b8c13eeec    
  
author   : Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 20 Feb 2020 19:15:03 +0900    
  
committer: Etsuro Fujita <efujita@postgresql.org>    
date     : Thu, 20 Feb 2020 19:15:03 +0900    

Click here for diff

M src/backend/partitioning/partbounds.c

Doc: discourage use of partial indexes for poor-man's-partitioning.

commit   : bbce2912fa899de30783a6a76a6443b5a2aede8d    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 19 Feb 2020 18:52:18 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 19 Feb 2020 18:52:18 -0500    

Click here for diff

Creating a bunch of non-overlapping partial indexes is generally  
a bad idea, so add an example saying not to do that.  
  
Back-patch to v10.  Before that, the alternative of using (real)  
partitioning wasn't available, so that the tradeoff isn't quite  
so clear cut.  
  
Discussion: https://postgr.es/m/CAKVFrvFY-f7kgwMRMiPLbPYMmgjc8Y2jjUGK_Y0HVcYAmU6ymg@mail.gmail.com  

M doc/src/sgml/indices.sgml

Fix typo

commit   : c987c9d42bc698fb2930280d46d191a50abe68f1    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 19 Feb 2020 20:52:42 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Wed, 19 Feb 2020 20:52:42 +0100    

Click here for diff

Reported-by: Daniel Verite <daniel@manitou-mail.org>  

M src/common/unicode_norm.c

Fix confusion about event trigger vs. plain function in plpgsql.

commit   : 612d207bcc05d1048a8648407b064df14cd3104a    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 19 Feb 2020 14:44:58 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 19 Feb 2020 14:44:58 -0500    

Click here for diff

The function hash table keys made by compute_function_hashkey() failed  
to distinguish event-trigger call context from regular call context.  
This meant that once we'd successfully made a hash entry for an event  
trigger (either by validation, or by normal use as an event trigger),  
an attempt to call the trigger function as a plain function would  
find this hash entry and thereby bypass the you-can't-do-that check in  
do_compile().  Thus we'd attempt to execute the function, leading to  
strange errors or even crashes, depending on function contents and  
server version.  
  
To fix, add an isEventTrigger field to PLpgSQL_func_hashkey,  
paralleling the longstanding infrastructure for regular triggers.  
This fits into what had been pad space, so there's no risk of an ABI  
break, even assuming that any third-party code is looking at these  
hash keys.  (I considered replacing isTrigger with a PLpgSQL_trigtype  
enum field, but felt that that carried some API/ABI risk.  Maybe we  
should change it in HEAD though.)  
  
Per bug #16266 from Alexander Lakhin.  This has been broken since  
event triggers were invented, so back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/16266-fcd7f838e97ba5d4@postgresql.org  

M src/pl/plpgsql/src/pl_comp.c
M src/pl/plpgsql/src/plpgsql.h
M src/test/regress/expected/event_trigger.out
M src/test/regress/sql/event_trigger.sql

Fix mesurement of elapsed time during truncating heap in VACUUM.

commit   : 414ed1ca232134e512ecfed1849f092f24f2a27a    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Wed, 19 Feb 2020 20:37:26 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Wed, 19 Feb 2020 20:37:26 +0900    

Click here for diff

VACUUM may truncate heap in several batches. The activity report  
is logged for each batch, and contains the number of pages in the table  
before and after the truncation, and also the elapsed time during  
the truncation. Previously the elapsed time reported in each batch was  
the total elapsed time since starting the truncation until finishing  
each batch. For example, if the truncation was processed dividing into  
three batches, the second batch reported the accumulated time elapsed  
during both first and second batches. This is strange and confusing  
because the number of pages in the table reported together is not  
total. Instead, each batch should report the time elapsed during  
only that batch.  
  
The cause of this issue was that the resource usage snapshot was  
initialized only at the beginning of the truncation and was never  
reset later. This commit fixes the issue by changing VACUUM so that  
the resource usage snapshot is reset at each batch.  
  
Back-patch to all supported branches.  
  
Reported-by: Tatsuhito Kasahara  
Author: Tatsuhito Kasahara  
Reviewed-by: Masahiko Sawada, Fujii Masao  
Discussion: https://postgr.es/m/CAP0=ZVJsf=NvQuy+QXQZ7B=ZVLoDV_JzsVC1FRsF1G18i3zMGg@mail.gmail.com  

M src/backend/commands/vacuumlazy.c

Stop demanding that top xact must be seen before subxact in decoding.

commit   : bff456d7a0b3dbd3dc5fc74f83e424a8ead458d1    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Wed, 12 Feb 2020 12:00:01 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Wed, 12 Feb 2020 12:00:01 +0530    

Click here for diff

Manifested as  
  
ERROR:  subtransaction logged without previous top-level txn record  
  
this check forbids legit behaviours like  
 - First xl_xact_assignment record is beyond reading, i.e. earlier  
   restart_lsn.  
 - After restart_lsn there is some change of a subxact.  
 - After that, there is second xl_xact_assignment (for another subxact)  
   revealing the relationship between top and first subxact.  
  
Such a transaction won't be streamed anyway because we hadn't seen it in  
full.  Saying for sure whether xact of some record encountered after  
the snapshot was deserialized can be streamed or not requires to know  
whether it wrote something before deserialization point --if yes, it  
hasn't been seen in full and can't be decoded. Snapshot doesn't have such  
info, so there is no easy way to relax the check.  
  
Reported-by: Hsu, John  
Diagnosed-by: Arseny Sher  
Author: Arseny Sher, Amit Kapila  
Reviewed-by: Amit Kapila, Dilip Kumar  
Backpatch-through: 9.5  
Discussion: https://postgr.es/m/AB5978B2-1772-4FEE-A245-74C91704ECB0@amazon.com  

M contrib/test_decoding/Makefile
A contrib/test_decoding/expected/subxact_without_top.out
A contrib/test_decoding/specs/subxact_without_top.spec
M src/backend/replication/logical/reorderbuffer.c

Teach pg_dump to dump comments on RLS policy objects.

commit   : bd2cd138f9bbaea99f8d632914c33ae5103afa6c    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Feb 2020 18:40:02 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Mon, 17 Feb 2020 18:40:02 -0500    

Click here for diff

This was unaccountably omitted in the original RLS patch.  
The SQL syntax is basically the same as for comments on triggers,  
so crib code from dumpTrigger().  
  
Per report from Marc Munro.  Back-patch to all supported branches.  
  
Discussion: https://postgr.es/m/1581889298.18009.15.camel@bloodnok.com  

M src/bin/pg_dump/pg_dump.c

Add description about LogicalRewriteTruncate wait event into document.

commit   : 12bea22a78c147ff3a8cf6db8f03514171952610    
  
author   : Fujii Masao <fujii@postgresql.org>    
date     : Mon, 17 Feb 2020 15:33:32 +0900    
  
committer: Fujii Masao <fujii@postgresql.org>    
date     : Mon, 17 Feb 2020 15:33:32 +0900    

Click here for diff

Back-patch to v10 where commit 249cf070e3 introduced  
LogicalRewriteTruncate wait event.  
  
Author: Fujii Masao  
Reviewed-by: Michael Paquier  
Discussion: https://postgr.es/m/949931aa-4ed4-d867-a7b5-de9c02b2292b@oss.nttdata.com  

M doc/src/sgml/monitoring.sgml

Doc: fix old oversights in GRANT/REVOKE documentation.

commit   : 736ba917f4849915b70794f291f85dedd890d2f8    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 12 Feb 2020 14:13:13 -0500    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Wed, 12 Feb 2020 14:13:13 -0500    

Click here for diff

The GRANTED BY clause in GRANT/REVOKE ROLE has been there since 2005  
but was never documented.  I'm not sure now whether that was just an  
oversight or was intentional (given the limited capability of the  
option).  But seeing that pg_dumpall does emit code that uses this  
option, it seems like not documenting it at all is a bad idea.  
  
Also, when we upgraded the syntax to allow CURRENT_USER/SESSION_USER  
as the privilege recipient, the role form of GRANT was incorrectly  
not modified to show that, and REVOKE's docs weren't touched at all.  
  
Although I'm not that excited about GRANTED BY, the other oversight  
seems serious enough to justify a back-patch.  
  
Discussion: https://postgr.es/m/3070.1581526786@sss.pgh.pa.us  

M doc/src/sgml/ref/grant.sgml
M doc/src/sgml/ref/revoke.sgml

Document the pg_upgrade -j/--jobs option as taking an argument

commit   : 9dc4e15c8a6339f81dba3b078cd9f0f37f45179b    
  
author   : Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Feb 2020 23:47:36 +0100    
  
committer: Peter Eisentraut <peter@eisentraut.org>    
date     : Tue, 11 Feb 2020 23:47:36 +0100    

Click here for diff

M doc/src/sgml/ref/pgupgrade.sgml
M src/bin/pg_upgrade/option.c