pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Relax transactional restrictions on ALTER TYPE ... ADD VALUE. 2+ messages / 2 participants [nested] [flat]
* pgsql: Relax transactional restrictions on ALTER TYPE ... ADD VALUE. @ 2016-09-05 17:00 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2016-09-05 17:00 UTC (permalink / raw) To: pgsql-committers Relax transactional restrictions on ALTER TYPE ... ADD VALUE. 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. Andrew Dunstan and Tom Lane Discussion: <4075.1459088427@sss.pgh.pa.us> Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/15bc038f9bcd1a9af3f625caffafc7c20322202d Modified Files -------------- doc/src/sgml/ref/alter_type.sgml | 6 ++- src/backend/commands/typecmds.c | 21 +------- src/backend/tcop/utility.c | 2 +- src/backend/utils/adt/enum.c | 104 +++++++++++++++++++++++++++++++++++++ src/backend/utils/errcodes.txt | 1 + src/include/commands/typecmds.h | 2 +- src/test/regress/expected/enum.out | 65 +++++++++++++++++++---- src/test/regress/sql/enum.sql | 30 ++++++++--- 8 files changed, 191 insertions(+), 40 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: Relax transactional restrictions on ALTER TYPE ... ADD VALUE (re @ 2018-10-08 23:53 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Thomas Munro @ 2018-10-08 23:53 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/212fab9926b2f0f04b0187568e7124b70e8deee5 Modified Files -------------- doc/src/sgml/ref/alter_type.sgml | 5 +- src/backend/access/transam/parallel.c | 20 ++++- src/backend/access/transam/xact.c | 4 + src/backend/catalog/pg_enum.c | 139 ++++++++++++++++++++++++++++++++++ src/backend/commands/typecmds.c | 29 +------ src/backend/tcop/utility.c | 2 +- src/backend/utils/adt/enum.c | 90 ++++++++++++++++++++++ src/backend/utils/errcodes.txt | 1 + src/include/catalog/pg_enum.h | 5 ++ src/include/commands/typecmds.h | 2 +- src/test/regress/expected/enum.out | 78 ++++++++++++++++--- src/test/regress/sql/enum.sql | 42 +++++++--- 12 files changed, 367 insertions(+), 50 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-10-08 23:53 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-09-05 17:00 pgsql: Relax transactional restrictions on ALTER TYPE ... ADD VALUE. Tom Lane <tgl@sss.pgh.pa.us> 2018-10-08 23:53 pgsql: Relax transactional restrictions on ALTER TYPE ... ADD VALUE (re Thomas Munro <tmunro@postgresql.org>
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