[COMMITTERS] pgsql: Use a blacklist to distinguish original from add-on enumvalues. - Mailing list pgsql-committers

From Tom Lane
Subject [COMMITTERS] pgsql: Use a blacklist to distinguish original from add-on enumvalues.
Date
Msg-id E1dwtRp-0005Y7-Px@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Use a blacklist to distinguish original from add-on enum values.

Commit 15bc038f9 allowed ALTER TYPE ADD VALUE to be executed inside
transaction blocks, by disallowing the use of the added value later
in the same transaction, except under limited circumstances.  However,
the test for "limited circumstances" was heuristic and could reject
references to enum values that were created during CREATE TYPE AS ENUM,
not just later.  This breaks the use-case of restoring pg_dump scripts
in a single transaction, as reported in bug #14825 from Balazs Szilfai.

We can improve this by keeping a "blacklist" table of enum value OIDs
created by ALTER TYPE ADD VALUE during the current transaction.  Any
visible-but-uncommitted value whose OID is not in the blacklist must
have been created by CREATE TYPE AS ENUM, and can be used safely
because it could not have a lifespan shorter than its parent enum type.

This change also removes the restriction that a renamed enum value
can't be used before being committed (unless it was on the blacklist).

Andrew Dunstan, with cosmetic improvements by me.
Back-patch to v10.

Discussion: https://postgr.es/m/20170922185904.1448.16585@wrigleys.postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1635e80d30b16df98aebead12f2b82f17efd9bc8

Modified Files
--------------
doc/src/sgml/ref/alter_type.sgml   |  2 --
src/backend/access/transam/xact.c  |  4 +++
src/backend/catalog/pg_enum.c      | 64 ++++++++++++++++++++++++++++++++++++++
src/backend/utils/adt/enum.c       |  9 ++++++
src/include/catalog/pg_enum.h      |  2 ++
src/test/regress/expected/enum.out | 21 +++++++++++++
src/test/regress/sql/enum.sql      | 13 ++++++++
7 files changed, 113 insertions(+), 2 deletions(-)


--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: [COMMITTERS] pgsql: Sort pg_basebackup options better
Next
From: Tom Lane
Date:
Subject: [COMMITTERS] pgsql: Fix failure-to-read-man-page in commit 899bd785c.