]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix assorted bugs in CREATE INDEX CONCURRENTLY.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 29 Nov 2012 19:50:31 +0000 (14:50 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 29 Nov 2012 19:51:46 +0000 (14:51 -0500)
commit1da5bef3174170a6768bea6621afcbf72dd02a87
tree568b1fd5efbc0a4f53df09222cd9bcad81372ad1
parent381c3b8f4cba2d7d30d7010c28b06c076093876f
Fix assorted bugs in CREATE INDEX CONCURRENTLY.

This patch changes CREATE INDEX CONCURRENTLY so that the pg_index
flag changes it makes without exclusive lock on the index are made via
heap_inplace_update() rather than a normal transactional update.  The
latter is not very safe because moving the pg_index tuple could result in
concurrent SnapshotNow scans finding it twice or not at all, thus possibly
resulting in index corruption.

In addition, fix various places in the code that ought to check to make
sure that the indexes they are manipulating are valid and/or ready as
appropriate.  These represent bugs that have existed since 8.2, since
a failed CREATE INDEX CONCURRENTLY could leave a corrupt or invalid
index behind, and we ought not try to do anything that might fail with
such an index.

Also fix RelationReloadIndexInfo to ensure it copies all the pg_index
columns that are allowed to change after initial creation.  Previously we
could have been left with stale values of some fields in an index relcache
entry.  It's not clear whether this actually had any user-visible
consequences, but it's at least a bug waiting to happen.

This is a subset of a patch already applied in 9.2 and HEAD.  Back-patch
into all earlier supported branches.

Tom Lane and Andres Freund
12 files changed:
src/backend/access/heap/README.HOT
src/backend/catalog/index.c
src/backend/commands/cluster.c
src/backend/commands/indexcmds.c
src/backend/commands/tablecmds.c
src/backend/commands/vacuum.c
src/backend/executor/execUtils.c
src/backend/optimizer/util/plancat.c
src/backend/parser/parse_utilcmd.c
src/backend/utils/cache/relcache.c
src/include/catalog/index.h
src/include/catalog/pg_index.h