]> granicus.if.org Git - postgresql/commit
Relax transactional restrictions on ALTER TYPE ... ADD VALUE (redux).
authorThomas Munro <tmunro@postgresql.org>
Mon, 8 Oct 2018 23:51:01 +0000 (12:51 +1300)
committerThomas Munro <tmunro@postgresql.org>
Mon, 8 Oct 2018 23:51:01 +0000 (12:51 +1300)
commit212fab9926b2f0f04b0187568e7124b70e8deee5
tree4ba239ec3e6f37b86474b915876407549de96eb1
parent7767aadd94cd252a12fa00f6122ad4dd10455791
Relax transactional restrictions on ALTER TYPE ... ADD VALUE (redux).

Originally committed as 15bc038f (plus some follow-ups), this was
reverted in 28e07270 due to a problem discovered in parallel
workers.  This new version corrects that problem by sending the
list of uncommitted enum values to parallel workers.

Here follows the original commit message describing the change:

To prevent possibly breaking indexes on enum columns, we must keep
uncommitted enum values from getting stored in tables, unless we
can be sure that any such column is new in the current transaction.

Formerly, we enforced this by disallowing ALTER TYPE ... ADD VALUE
from being executed at all in a transaction block, unless the target
enum type had been created in the current transaction.  This patch
removes that restriction, and instead insists that an uncommitted enum
value can't be referenced unless it belongs to an enum type created
in the same transaction as the value.  Per discussion, this should be
a bit less onerous.  It does require each function that could possibly
return a new enum value to SQL operations to check this restriction,
but there aren't so many of those that this seems unmaintainable.

Author: Andrew Dunstan and Tom Lane, with parallel query fix by Thomas Munro
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/CAEepm%3D0Ei7g6PaNTbcmAh9tCRahQrk%3Dr5ZWLD-jr7hXweYX3yg%40mail.gmail.com
Discussion: https://postgr.es/m/4075.1459088427%40sss.pgh.pa.us
12 files changed:
doc/src/sgml/ref/alter_type.sgml
src/backend/access/transam/parallel.c
src/backend/access/transam/xact.c
src/backend/catalog/pg_enum.c
src/backend/commands/typecmds.c
src/backend/tcop/utility.c
src/backend/utils/adt/enum.c
src/backend/utils/errcodes.txt
src/include/catalog/pg_enum.h
src/include/commands/typecmds.h
src/test/regress/expected/enum.out
src/test/regress/sql/enum.sql