PostgreSQL 11.9 (upcoming) commit log

llvmjit: Fix building against LLVM 11 by removing unnecessary include.

commit   : c001c115bcb2accddc23a25c605886e01475db4f    
  
author   : Andres Freund <andres@anarazel.de>    
date     : Thu, 28 May 2020 15:08:12 -0700    
  
committer: Andres Freund <andres@anarazel.de>    
date     : Thu, 28 May 2020 15:08:12 -0700    

Click here for diff

LLVM has removed this header, in the branch that will become llvm  
11. But as it turns out we didn't actually need it, so just remove it.  
  
Author: Jesse Zhang <sbjesse@gmail.com>  
Discussion: https://postgr.es/m/CAGf+fX7bvtP0YXMu7pOsu_NwhxW6dArTkxb=jt7M2-UJkyJ_3g@mail.gmail.com  
Backpatch: 11, where JIT support using llvm was introduced.  

M src/backend/jit/llvm/llvmjit_inline.cpp

commit   : 49a00e07c534d0d4378d40b6240e061640051304    
  
author   : Joe Conway <mail@joeconway.com>    
date     : Thu, 28 May 2020 13:45:02 -0400    
  
committer: Joe Conway <mail@joeconway.com>    
date     : Thu, 28 May 2020 13:45:02 -0400    

Click here for diff

Two of the members of rconn were left uninitialized. When  
dblink_open() is called without an outer transaction it  
handles the initialization for us, but with an outer  
transaction it does not. Arrange for initialization  
in all cases. Backpatch to all supported versions.  
  
Reported-by: Alexander Lakhin  
Discussion: https://www.postgresql.org/message-id/flat/9bd0744f-5f04-c778-c5b3-809efe9c30c7%40joeconway.com#c545909a41664991aca60c4d70a10ce7  

M contrib/dblink/dblink.c

Add CHECK_FOR_INTERRUPTS() to the repeat() function

commit   : 36758c472ea71dae96f4b495df65490413c79c83    
  
author   : Joe Conway <mail@joeconway.com>    
date     : Thu, 28 May 2020 13:17:04 -0400    
  
committer: Joe Conway <mail@joeconway.com>    
date     : Thu, 28 May 2020 13:17:04 -0400    

Click here for diff

The repeat() function loops for potentially a long time without  
ever checking for interrupts. This prevents, for example, a query  
cancel from interrupting until the work is all done. Fix by  
inserting a CHECK_FOR_INTERRUPTS() into the loop.  
  
Backpatch to all supported versions.  
  
Discussion: https://www.postgresql.org/message-id/flat/8692553c-7fe8-17d9-cbc1-7cddb758f4c6%40joeconway.com  

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

Add missing error code to "cannot attach index ..." error.

commit   : 34301c9c5674919ef2e786f1157b3ced543b02e2    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 28 May 2020 12:37:00 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 28 May 2020 12:37:00 +0300    

Click here for diff

ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE was used in an ereport with the  
same message but different errdetail a few lines earlier, so use that  
here as well.  
  
Backpatch-through: 11  

M src/backend/commands/tablecmds.c

Fix typo in test comment.

commit   : 25fc24ba90df99d3c331627f3e4efb795a440dd0    
  
author   : Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 28 May 2020 12:35:18 +0300    
  
committer: Heikki Linnakangas <heikki.linnakangas@iki.fi>    
date     : Thu, 28 May 2020 12:35:18 +0300    

Click here for diff

The same comment was copied to a few different places, with the same typo.  
Backpatch down to v11, where this typo was introduced.  

M src/test/regress/expected/alter_table.out
M src/test/regress/expected/hash_part.out
M src/test/regress/expected/insert.out
M src/test/regress/expected/partition_prune.out
M src/test/regress/sql/alter_table.sql
M src/test/regress/sql/hash_part.sql
M src/test/regress/sql/insert.sql
M src/test/regress/sql/partition_prune.sql

Add a temp-install prerequisite to top-level "check-tests".

commit   : 9d47294ab7c45a64cd844fb7298bef91c16fafbe    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Mon, 25 May 2020 16:21:04 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Mon, 25 May 2020 16:21:04 -0700    

Click here for diff

The target failed, tested $PATH binaries, or tested a stale temporary  
installation.  Commit c66b438db62748000700c9b90b585e756dd54141 missed  
this.  Back-patch to 9.5 (all supported versions).  

M GNUmakefile.in

doc: suggest 1.1 as a random_page_cost value for SSDs

commit   : b75f73dc0cf792171cacdc536327807dbd496205    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 21 May 2020 20:28:38 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 21 May 2020 20:28:38 -0400    

Click here for diff

Reported-by: yigong hu  
  
Discussion: https://postgr.es/m/CAOxFffcourucFqSk+tZA13ErS3XRYkDy6EeaPff4AvHGiEEuug@mail.gmail.com  
  
Backpatch-through: 9.5  

M doc/src/sgml/config.sgml

doc: Simplify mention of unique indexes for NULL control

commit   : 00c51b365c90e3177a05026afda20f8aae7f997a    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Thu, 21 May 2020 19:49:30 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Thu, 21 May 2020 19:49:30 -0400    

Click here for diff

Discussion: https://postgr.es/m/2304.1586532634@sss.pgh.pa.us  
  
Backpatch-through: 9.5  

M doc/src/sgml/indices.sgml

Fix MSVC installations with multiple "configure" files detected

commit   : bb24af50d515651b950e153fdd25ddb46184a57b    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Thu, 21 May 2020 14:41:33 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Thu, 21 May 2020 14:41:33 +0900    

Click here for diff

When installing binaries and libraries using the MSVC installation  
routines, the operation gets done after moving to the root folder, whose  
location is detected by checking if "configure" exists two times in a  
row.  So, calling the installation script from src/tools/msvc/ with an  
extra "configure" file four levels up the root path of the code tree  
causes the execution to go further up, leading to a failure in finding  
the builds.  This commit fixes the issue by moving to the root folder of  
the code tree only once, when necessary.  
  
Author: Arnold Müller  
Reviewed-by: Daniel Gustafsson  
Discussion: https://postgr.es/m/16343-f638f67e7e52b86c@postgresql.org  
Backpatch-through: 9.5  

M src/tools/msvc/Install.pm

Doc: Fix description of pg_class.relreplident

commit   : 673582d21f30871d9b5d04449e6b2b7acde69209    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Wed, 20 May 2020 14:21:50 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Wed, 20 May 2020 14:21:50 +0900    

Click here for diff

The description missed a comma and lacked an explanation of what happens  
with REPLICA IDENTITY USING INDEX when the dependent index is dropped.  
  
Author: Marina Polyakova  
Reviewed-by: Daniel Gustafsson, Michael Paquier  
Discussion: https://postgr.es/m/ad1a0badc32658b1bbb07aa312346a1d@postgrespro.ru  
Backpatch-through: 9.5  

M doc/src/sgml/catalogs.sgml

Fix comment in slot.c.

commit   : 1567ed9b3adc66f00922a9dce06b108c2710d046    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Mon, 18 May 2020 08:16:45 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Mon, 18 May 2020 08:16:45 +0530    

Click here for diff

Reported-by: Sawada Masahiko  
Author: Sawada Masahiko  
Reviewed-by: Amit Kapila  
Backpatch-through: 9.5  
Discussion: https://postgr.es/m/CA+fd4k4Ws7M7YQ8PqSym5WB1y75dZeBTd1sZJUQdfe0KJQ-iSA@mail.gmail.com  

M src/backend/replication/slot.c

Fix assertion with relation using REPLICA IDENTITY FULL in subscriber

commit   : 70ae82b9b4b5871604ba4e98ebe0f32bef223200    
  
author   : Michael Paquier <michael@paquier.xyz>    
date     : Sat, 16 May 2020 18:16:37 +0900    
  
committer: Michael Paquier <michael@paquier.xyz>    
date     : Sat, 16 May 2020 18:16:37 +0900    

Click here for diff

In a logical replication subscriber, a table using REPLICA IDENTITY FULL  
which has a primary key would try to use the primary key's index  
available to scan for a tuple, but an assertion only assumed as correct  
the case of an index associated to REPLICA IDENTITY USING INDEX.  This  
commit corrects the assertion so as the use of a primary key index is a  
valid case.  
  
Reported-by: Dilip Kumar  
Analyzed-by: Dilip Kumar  
Author: Euler Taveira  
Reviewed-by: Michael Paquier, Masahiko Sawada  
Discussion: https://postgr.es/m/CAFiTN-u64S5bUiPL1q5kwpHNd0hRnf1OE-bzxNiOs5zo84i51w@mail.gmail.com  
Backpatch-through: 10  

M src/backend/executor/execReplication.c
M src/test/subscription/t/001_rep_changes.pl

Fix bogus initialization of replication origin shared memory state.

commit   : ee39a4b9e475348dd3de82781a54be82e63a3186    
  
author   : Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 15 May 2020 19:05:39 -0400    
  
committer: Tom Lane <tgl@sss.pgh.pa.us>    
date     : Fri, 15 May 2020 19:05:39 -0400    

Click here for diff

The previous coding zeroed out offsetof(ReplicationStateCtl, states)  
more bytes than it was entitled to, as a consequence of starting the  
zeroing from the wrong pointer (or, if you prefer, using the wrong  
calculation of how much to zero).  
  
It's unsurprising that this has not caused any reported problems,  
since it can be expected that the newly-allocated block is at the end  
of what we've used in shared memory, and we always make the shmem  
block substantially bigger than minimally necessary.  Nonetheless,  
this is wrong and it could bite us someday; plus it's a dangerous  
model for somebody to copy.  
  
This dates back to the introduction of this code (commit 5aa235042),  
so back-patch to all supported branches.  

M src/backend/replication/logical/origin.c

Avoid killing btree items that are already dead

commit   : 37b5c5fde46ad3081f02668846f4d125ca4f7992    
  
author   : Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 15 May 2020 16:50:34 -0400    
  
committer: Alvaro Herrera <alvherre@alvh.no-ip.org>    
date     : Fri, 15 May 2020 16:50:34 -0400    

Click here for diff

_bt_killitems marks btree items dead when a scan leaves the page where  
they live, but it does so with only share lock (to improve concurrency).  
This was historicall okay, since killing a dead item has no  
consequences.  However, with the advent of data checksums and  
wal_log_hints, this action incurs a WAL full-page-image record of the  
page.  Multiple concurrent processes would write the same page several  
times, leading to WAL bloat.  The probability of this happening can be  
reduced by only killing items if they're not already dead, so change the  
code to do that.  
  
The problem could eliminated completely by having _bt_killitems upgrade  
to exclusive lock upon seeing a killable item, but that would reduce  
concurrency so it's considered a cure worse than the disease.  
  
Backpatch all the way back to 9.5, since wal_log_hints was introduced in  
9.4.  
  
Author: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>  
Discussion: https://postgr.es/m/CA+fd4k6PeRj2CkzapWNrERkja5G0-6D-YQiKfbukJV+qZGFZ_Q@mail.gmail.com  

M src/backend/access/nbtree/nbtutils.c

docs: add xreflabel entries for autovacuum, SP-GiST, and TOAST

commit   : bc4a8b460079af2bc244087479684862d6794770    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 15 May 2020 12:38:40 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 15 May 2020 12:38:40 -0400    

Click here for diff

This is for use by the PG 13 release notes, but might be used for minor  
release notes in the future.  
  
Backpatch-through: 9.5  

M doc/src/sgml/maintenance.sgml
M doc/src/sgml/spgist.sgml
M doc/src/sgml/storage.sgml

doc: add missing xreflabels to the main docs (not refs)

commit   : 621455b78318d5fb2d2f4062d20c1af1f50bd1d7    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 15 May 2020 12:05:43 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 15 May 2020 12:05:43 -0400    

Click here for diff

Add missing xreflabels for index types, geqo, libpq, spi, server-side  
languages, ecpg, and vaacuumlo.  
  
Backpatch-through: 9.5  

M doc/src/sgml/ecpg.sgml
M doc/src/sgml/geqo.sgml
M doc/src/sgml/gin.sgml
M doc/src/sgml/gist.sgml
M doc/src/sgml/libpq.sgml
M doc/src/sgml/plperl.sgml
M doc/src/sgml/plpgsql.sgml
M doc/src/sgml/plpython.sgml
M doc/src/sgml/spi.sgml
M doc/src/sgml/vacuumlo.sgml

doc: remove extra blank line at the top of SGML files

commit   : a4def04df5fa1c01e38f6dd8941a07c60da01068    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 15 May 2020 09:55:43 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 15 May 2020 09:55:43 -0400    

Click here for diff

Backpatch-through: 9.5  

M doc/src/sgml/ref/copy.sgml

doc: make ref/*.sgml file header comment layout consistent

commit   : d9cbdec23fd63a8ac650ab174d5d33ab5fcc3bb4    
  
author   : Bruce Momjian <bruce@momjian.us>    
date     : Fri, 15 May 2020 08:52:24 -0400    
  
committer: Bruce Momjian <bruce@momjian.us>    
date     : Fri, 15 May 2020 08:52:24 -0400    

Click here for diff

M doc/src/sgml/ref/checkpoint.sgml
M doc/src/sgml/ref/create_cast.sgml
M doc/src/sgml/ref/create_collation.sgml
M doc/src/sgml/ref/create_conversion.sgml
M doc/src/sgml/ref/create_foreign_table.sgml
M doc/src/sgml/ref/create_function.sgml
M doc/src/sgml/ref/create_procedure.sgml
M doc/src/sgml/ref/create_transform.sgml
M doc/src/sgml/ref/drop_cast.sgml
M doc/src/sgml/ref/drop_collation.sgml
M doc/src/sgml/ref/drop_conversion.sgml
M doc/src/sgml/ref/drop_foreign_table.sgml
M doc/src/sgml/ref/drop_transform.sgml
M doc/src/sgml/ref/load.sgml
M doc/src/sgml/ref/pg_config-ref.sgml
M doc/src/sgml/ref/pg_restore.sgml
M doc/src/sgml/ref/pgarchivecleanup.sgml
M doc/src/sgml/ref/pgbench.sgml
M doc/src/sgml/ref/pgtestfsync.sgml
M doc/src/sgml/ref/pgtesttiming.sgml
M doc/src/sgml/ref/pgupgrade.sgml
M doc/src/sgml/ref/set_constraints.sgml
M doc/src/sgml/ref/set_session_auth.sgml
M doc/src/sgml/ref/set_transaction.sgml

Fix amcheck for page checks concurrent to replay of btree page deletion

commit   : b9a45d8dba4de6db14f03adf8f1a8ce51d43005b    
  
author   : Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 6 May 2020 15:35:27 +0300    
  
committer: Alexander Korotkov <akorotkov@postgresql.org>    
date     : Wed, 6 May 2020 15:35:27 +0300    

Click here for diff

amcheck expects at least hikey to always exist on leaf page even if it is  
deleted page.  But replica reinitializes page during replay of page deletion,  
causing deleted page to have no items.  Thus, replay of page deletion can  
cause an error in concurrent amcheck run.  
  
This commit relaxes amcheck expectation making it tolerate deleted page with  
no items.  
  
Reported-by: Konstantin Knizhnik  
Discussion: https://postgr.es/m/CAPpHfdt_OTyQpXaPJcWzV2N-LNeNJseNB-K_A66qG%3DL518VTFw%40mail.gmail.com  
Author: Alexander Korotkov  
Reviewed-by: Peter Geoghegan  
Backpatch-through: 11  

M contrib/amcheck/verify_nbtree.c

Fix the MSVC build for versions 2015 and later.

commit   : 1fbfc3d8a59a570db1e13e8a54b0774e7255ced0    
  
author   : Amit Kapila <akapila@postgresql.org>    
date     : Thu, 14 May 2020 09:39:04 +0530    
  
committer: Amit Kapila <akapila@postgresql.org>    
date     : Thu, 14 May 2020 09:39:04 +0530    

Click here for diff

Visual Studio 2015 and later versions should still be able to do the same  
as Visual Studio 2012, but the declaration of locale_name is missing in  
_locale_t, causing the code compilation to fail, hence this falls back  
instead on to enumerating all system locales by using EnumSystemLocalesEx  
to find the required locale name.  If the input argument is in Unix-style  
then we can get ISO Locale name directly by using GetLocaleInfoEx() with  
LCType as LOCALE_SNAME.  
  
In passing, change the documentation references of the now obsolete links.  
  
Note that this problem occurs only with NLS enabled builds.  
  
Author: Juan José Santamaría Flecha, Davinder Singh and Amit Kapila  
Reviewed-by: Ranier Vilela and Amit Kapila  
Backpatch-through: 9.5  
Discussion: https://postgr.es/m/CAHzhFSFoJEWezR96um4-rg5W6m2Rj9Ud2CNZvV4NWc9tXV7aXQ@mail.gmail.com  

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

Fix pg_recvlogical avoidance of superfluous Standby Status Update.

commit   : a267894529b260002cdb85cde9680529ae4ceeb4    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Wed, 13 May 2020 20:42:09 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Wed, 13 May 2020 20:42:09 -0700    

Click here for diff

The defect suppressed a Standby Status Update message when bytes flushed  
to disk had changed but bytes received had not changed.  If  
pg_recvlogical then exited with no intervening Standby Status Update,  
the next pg_recvlogical repeated already-flushed records.  The defect  
could also cause superfluous messages, which are functionally harmless.  
Back-patch to 9.5 (all supported versions).  
  
Discussion: https://postgr.es/m/20200502221647.GA3941274@rfd.leadboat.com  

M src/bin/pg_basebackup/pg_recvlogical.c

In successful pg_recvlogical, end PGRES_COPY_OUT cleanly.

commit   : 357012e17f3f7d47bd276d4441c28fbcd58a2c8b    
  
author   : Noah Misch <noah@leadboat.com>    
date     : Wed, 13 May 2020 20:42:09 -0700    
  
committer: Noah Misch <noah@leadboat.com>    
date     : Wed, 13 May 2020 20:42:09 -0700    

Click here for diff

pg_recvlogical merely called PQfinish(), so the backend sent messages  
after the disconnect.  When that caused EPIPE in internal_flush(),  
before a LogicalConfirmReceivedLocation(), the next pg_recvlogical would  
repeat already-acknowledged records.  Whether or not the defect causes  
EPIPE, post-disconnect messages could contain an ErrorResponse that the  
user should see.  One properly ends PGRES_COPY_OUT by repeating  
PQgetCopyData() until it returns a negative value.  Augment one of the  
tests to cover the case of WAL past --endpos.  Back-patch to v10, where  
commit 7c030783a5bd07cadffc2a1018bc33119a4c7505 first appeared.  Before  
that commit, pg_recvlogical never reached PGRES_COPY_OUT.  
  
Reported by Thomas Munro.  
  
Discussion: https://postgr.es/m/CAEepm=1MzM2Z_xNe4foGwZ1a+MO_2S9oYDq3M5D11=JDU_+0Nw@mail.gmail.com  

M src/bin/pg_basebackup/pg_recvlogical.c
M src/test/recovery/t/006_logical_decoding.pl