pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Use a blacklist to distinguish original from add-on enum values.
Date: Tue, 26 Sep 2017 17:15:05 +0000
Message-ID: <E1dwtRp-0005Y7-Px@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


view thread (2+ messages)

Message-ID: <E1dwtRp-0005Y7-Px@gemulon.postgresql.org>
Permalink:  ../E1dwtRp-0005Y7-Px@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1dwtRp-0005Y7-Px@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Use a blacklist to distinguish original from add-on enum values.
  In-Reply-To: <E1dwtRp-0005Y7-Px@gemulon.postgresql.org>
  References: <E1dwtRp-0005Y7-Px@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox