BUG #14825: enum type: unsafe use?

balazs@obiserver.hu

From: balazs@obiserver.hu
To: pgsql-bugs@postgresql.org
Cc: balazs@obiserver.hu
Date: 2017-09-22T18:59:04Z
Lists: pgsql-bugs, pgsql-hackers
The following bug has been logged on the website:

Bug reference:      14825
Logged by:          Balazs Szilfai
Email address:      balazs@obiserver.hu
PostgreSQL version: 10beta4
Operating system:   Debian Linux
Description:        

Hi,

version: 10rc1

testdb=# begin;
BEGIN
testdb=# create type enumtype as enum ('v1', 'v2');
CREATE TYPE
testdb=# create table testtable (enumcolumn enumtype not null default
'v1');
CREATE TABLE

Everything it's OK! :)

If enum type have "owner to":

testdb=# begin;
BEGIN
testdb=# create type enumtype as enum ('v1', 'v2');
CREATE TYPE
testdb=# alter type enumtype owner to testrole;
ALTER TYPE
testdb=# create table testtable (enumcolumn enumtype not null default
'v1');
ERROR:  unsafe use of new value "v1" of enum type enumtype
HINT:  New enum values must be committed before they can be used.

Is this unsafe?

Balazs


Commits

  1. Revert to 9.6 treatment of ALTER TYPE enumtype ADD VALUE.

  2. Remove heuristic same-transaction test from check_safe_enum_use().

  3. Use a blacklist to distinguish original from add-on enum values.

  4. Add support for coordinating record typmods among parallel workers.