pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Use a blacklist to distinguish original from add-on enum values.
2+ messages / 1 participants
[nested] [flat]

* pgsql: Use a blacklist to distinguish original from add-on enum values.
@ 2017-09-26 17:15  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2017-09-26 17:15 UTC (permalink / raw)
  To: 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
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/175774d2932d969875b0709ec5f400ba19000c99

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


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Use a blacklist to distinguish original from add-on enum values.
@ 2017-09-26 17:15  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2017-09-26 17:15 UTC (permalink / raw)
  To: 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


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2017-09-26 17:15 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-09-26 17:15 pgsql: Use a blacklist to distinguish original from add-on enum values. Tom Lane <tgl@sss.pgh.pa.us>
2017-09-26 17:15 pgsql: Use a blacklist to distinguish original from add-on enum values. Tom Lane <tgl@sss.pgh.pa.us>

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