pgsql: Improve error message for duplicate labels when creating an enum
От | Tom Lane |
---|---|
Тема | pgsql: Improve error message for duplicate labels when creating an enum |
Дата | |
Msg-id | E1utVA0-000Bo3-0K@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
Improve error message for duplicate labels when creating an enum type. Previously, duplicate labels in CREATE TYPE AS ENUM were caught by the unique index on pg_enum, resulting in a generic error message. While this was evidently intentional, it's not terribly user-friendly, nor consistent with the ALTER TYPE cases which take more care with such errors. This patch adds an explicit check to produce a more user-friendly and descriptive error message. A potential objection to this implementation is that it adds O(N^2) work to the creation operation. However, quick testing finds that that's pretty negligible below 1000 enum labels, and tolerable even at 10000. So it doesn't really seem worth being smarter. Author: Yugo Nagata <nagata@sraoss.co.jp> Reviewed-by: Rahila Syed <rahilasyed90@gmail.com> Reviewed-by: Jim Jones <jim.jones@uni-muenster.de> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20250704000402.37e605ab0c59c300965a17ee@sraoss.co.jp Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/1b1960c8c9e81171efabdd9e3393b4eec1ffc477 Modified Files -------------- src/backend/catalog/pg_enum.c | 25 +++++++++++++++++++------ src/test/regress/expected/enum.out | 3 +++ src/test/regress/sql/enum.sql | 3 +++ 3 files changed, 25 insertions(+), 6 deletions(-)
В списке pgsql-committers по дате отправления: