postgresql/contrib
Andres Freund 17126e0892 Fix potential assertion failure when reindexing a pg_class index.
When reindexing individual indexes on pg_class it was possible to
either trigger an assertion failure:
TRAP: FailedAssertion("!(!ReindexIsProcessingIndex(((index)->rd_id)))

That's because reindex_index() called SetReindexProcessing() - which
enables an asserts ensuring no index insertions happen into the index
- before calling RelationSetNewRelfilenode(). That not correct for
indexes on pg_class, because RelationSetNewRelfilenode() updates the
relevant pg_class row, which needs to update the indexes.

The are two reasons this wasn't noticed earlier. Firstly the bug
doesn't trigger when reindexing all of pg_class, as reindex_relation
has code "hiding" all yet-to-be-reindexed indexes. Secondly, the bug
only triggers when the the update to pg_class doesn't turn out to be a
HOT update - otherwise there's no index insertion to trigger the
bug. Most of the time there's enough space, making this bug hard to
trigger.

To fix, move RelationSetNewRelfilenode() to before the
SetReindexProcessing() (and, together with some other code, to outside
of the PG_TRY()).

To make sure the error checking intended by SetReindexProcessing() is
more robust, modify CatalogIndexInsert() to check
ReindexIsProcessingIndex() even when the update is a HOT update.

Also add a few regression tests for REINDEXing of system catalogs.

The last two improvements would have prevented some of the issues
fixed in 5c1560606d from being introduced in the first place.

Reported-By: Michael Paquier
Diagnosed-By: Tom Lane and Andres Freund
Author: Andres Freund
Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/20190418011430.GA19133@paquier.xyz
Backpatch: 9.4-, the bug is present in all branches
2019-04-29 19:42:58 -07:00
..
adminpack adminpack: Revoke EXECUTE on pg_logfile_rotate() 2018-05-07 10:10:45 -04:00
auth_delay Update copyright for 2016 2016-01-02 14:19:48 -05:00
auto_explain Allow auto_explain.log_min_duration to go up to INT_MAX. 2018-02-23 14:39:20 -05:00
bloom Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:13 -04:00
btree_gin Make contrib regression tests safe for Danish locale. 2016-07-21 16:52:35 -04:00
btree_gist Improve stability of recently-added regression test case. 2018-10-16 12:01:19 -04:00
chkpass Avoid returning undefined bytes in chkpass_in(). 2015-02-14 12:20:56 -05:00
citext Repair damage done by citext--1.1--1.2.sql. 2016-07-26 15:32:57 -04:00
cube Enforce cube dimension limit in all cube construction functions 2018-08-31 20:22:39 +03:00
dblink Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
dict_int Update copyright for 2016 2016-01-02 13:33:40 -05:00
dict_xsyn Update copyright for 2016 2016-01-02 13:33:40 -05:00
earthdistance Fix earthdistance test suite function name typo. 2018-07-29 12:02:10 -07:00
file_fdw Ensure that foreign scans with lateral refs are planned correctly. 2019-02-07 13:11:16 -05:00
fuzzystrmatch Update fuzzystrmatch extension for parallel query. 2016-06-07 11:26:41 -04:00
hstore Fix hstore hash function for empty hstores upgraded from 8.4. 2018-11-24 21:17:09 +00:00
hstore_plperl Still further rethinking of build changes for macOS Mojave. 2018-10-18 14:55:23 -04:00
hstore_plpython Fix volatile vs. pointer confusion 2019-03-15 08:39:00 +01:00
intagg Schema-qualify some references to regprocedure. 2016-06-10 10:41:58 -04:00
intarray Avoid crashes in contrib/intarray gist__int_ops (bug #15518) 2018-11-24 08:39:55 +00:00
isn Fix typos in comments. 2017-02-06 11:34:15 +02:00
lo Update lo extension for parallel query. 2016-06-07 11:26:42 -04:00
ltree Allow btree comparison functions to return INT_MIN. 2018-10-05 16:01:30 -04:00
ltree_plpython Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
oid2name Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
pageinspect Fix tuple_data_split() to not open a relation without any lock. 2018-10-01 11:51:07 -04:00
passwordcheck Update copyright for 2016 2016-01-02 13:33:40 -05:00
pg_buffercache pg_buffercache: Allow huge allocations. 2016-09-15 09:30:37 -04:00
pg_freespacemap Update pg_freespacemap extension for parallel query. 2016-06-09 17:18:16 -04:00
pg_prewarm Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:13 -04:00
pg_standby Fix new warnings from GCC 7 2017-05-16 08:52:39 -04:00
pg_stat_statements Fix typos in comments. 2017-02-06 11:34:15 +02:00
pg_trgm Rework word_similarity documentation, make it close to actual algorithm. 2018-03-21 14:37:51 +03:00
pg_visibility Fix bugs in contrib/pg_visibility. 2016-10-01 16:32:55 -04:00
pgcrypto Fix misc typos in comments. 2019-01-23 13:46:44 +02:00
pgrowlocks Fix handling of multixacts predating pg_upgrade 2016-06-24 18:29:28 -04:00
pgstattuple Minor fixes in contrib installation scripts. 2016-06-14 10:47:06 -04:00
postgres_fdw Ensure that foreign scans with lateral refs are planned correctly. 2019-02-07 13:11:16 -05:00
seg Fix typos in comments. 2017-02-06 11:34:15 +02:00
sepgsql Silence compiler warning in sepgsql 2017-04-06 14:24:41 -07:00
spi Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
sslinfo Support OpenSSL 1.1.0. 2016-09-15 12:55:38 +03:00
start-scripts Provide modern examples of how to auto-start Postgres on macOS. 2017-11-17 12:47:21 -05:00
tablefunc Widen query numbers-of-tuples-processed counters to uint64. 2016-03-12 16:05:29 -05:00
tcn Revert CREATE INDEX ... INCLUDING ... 2016-04-08 21:52:13 +03:00
test_decoding Fix potential assertion failure when reindexing a pg_class index. 2019-04-29 19:42:58 -07:00
tsearch2 Fix typos in comments. 2017-02-06 11:34:15 +02:00
tsm_system_rows Update copyright for 2016 2016-01-02 13:33:40 -05:00
tsm_system_time Update copyright for 2016 2016-01-02 13:33:40 -05:00
unaccent Make contrib/unaccent's unaccent() function work when not in search path. 2018-09-06 10:49:45 -04:00
uuid-ossp Give a useful error message if uuid-ossp is built without preconfiguration. 2016-12-22 11:19:13 -05:00
vacuumlo Avoid double-free in vacuumlo error path. 2019-03-24 15:13:21 -04:00
xml2 Fix typos in comments. 2017-02-06 11:34:15 +02:00
Makefile Bloom index contrib module 2016-04-01 16:42:24 +03:00
README Rename 'gmake' to 'make' in docs and recommended commands 2014-02-12 17:29:19 -05:00
contrib-global.mk Respect TEMP_CONFIG when pg_regress_check and friends are called 2016-02-27 12:28:21 -05:00

README

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly
because they address a limited audience or are too experimental to be
part of the main source tree.  This does not preclude their
usefulness.

User documentation for each module appears in the main SGML
documentation.

When building from the source distribution, these modules are not
built automatically, unless you build the "world" target.  You can
also build and install them all by running "make all" and "make
install" in this directory; or to build and install just one selected
module, do the same in that module's subdirectory.

Some directories supply new user-defined functions, operators, or
types.  To make use of one of these modules, after you have installed
the code you need to register the new SQL objects in the database
system by executing a CREATE EXTENSION command.  In a fresh database,
you can simply do

    CREATE EXTENSION module_name;

See the PostgreSQL documentation for more information about this
procedure.