mirror of
https://github.com/postgres/postgres.git
synced 2025-09-11 00:12:06 +03:00
Support renaming an existing value of an enum type.
Not much to be said about this patch: it does what it says on the tin. In passing, rename AlterEnumStmt.skipIfExists to skipIfNewValExists to clarify what it actually does. In the discussion of this patch we considered supporting other similar options, such as IF EXISTS on the type as a whole or IF NOT EXISTS on the target name. This patch doesn't actually add any such feature, but it might happen later. Dagfinn Ilmari Mannsåker, reviewed by Emre Hasegeli Discussion: <CAO=2mx6uvgPaPDf-rHqG8=1MZnGyVDMQeh8zS4euRyyg4D35OQ@mail.gmail.com>
This commit is contained in:
@@ -257,6 +257,17 @@ CREATE TYPE bogus AS ENUM('good', 'bad', 'ugly');
|
||||
CREATE TABLE enumtest_bogus_child(parent bogus REFERENCES enumtest_parent);
|
||||
DROP TYPE bogus;
|
||||
|
||||
-- check renaming a value
|
||||
ALTER TYPE rainbow RENAME VALUE 'red' TO 'crimson';
|
||||
SELECT enumlabel, enumsortorder
|
||||
FROM pg_enum
|
||||
WHERE enumtypid = 'rainbow'::regtype
|
||||
ORDER BY 2;
|
||||
-- check that renaming a non-existent value fails
|
||||
ALTER TYPE rainbow RENAME VALUE 'red' TO 'crimson';
|
||||
-- check that renaming to an existent value fails
|
||||
ALTER TYPE rainbow RENAME VALUE 'blue' TO 'green';
|
||||
|
||||
--
|
||||
-- check transactional behaviour of ALTER TYPE ... ADD VALUE
|
||||
--
|
||||
|
Reference in New Issue
Block a user