Re: BUG #11524: Unable to add value to ENUM when having AUTOCOMMIT disabled in psql

From: "Tomas Vondra" <tv(at)fuzzy(dot)cz>
To: feikesteenbergen(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #11524: Unable to add value to ENUM when having AUTOCOMMIT disabled in psql
Date: 2014-09-30 11:02:02
Message-ID: 4330b13cec2a6288d0de2a5be1c7aa96.squirrel@2.emaily.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

Dne 30 Září 2014, 12:43, feikesteenbergen(at)gmail(dot)com napsal(a):
> The following bug has been logged on the website:
>
> Bug reference: 11524
> Logged by: Feike Steenbergen
> Email address: feikesteenbergen(at)gmail(dot)com
> PostgreSQL version: 9.4beta2
> Operating system: Debian
> Description:
>
> If I want to add a value to an ENUM type, I cannot do so when having
> AUTOCOMMIT enabled.
>
> To reproduce:
> \set ECHO queries
> CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
> ALTER TYPE mood ADD VALUE 'autocommit enabled';
> \set AUTOCOMMIT OFF
> ALTER TYPE mood ADD VALUE 'autocommit disabled';
>
>
> Output:
> CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
> CREATE TYPE
> ALTER TYPE mood ADD VALUE 'autocommit enabled';
> ALTER TYPE
> ALTER TYPE mood ADD VALUE 'autocommit disabled';
> psql:autocommit_enum.sql:5: ERROR: ALTER TYPE ... ADD cannot run inside a
> transaction block
>
> I have this issue on 9.1 - 9.5. (This issue does not occur on 9.0 as
> adding
> "ADD VALUE" was added in 9.1).

I don't understand why you think this is a bug? By disabling autocommit,
psql essentially adds a BEGIN before the ALTER TABLE, wrapping it in a
transaction block [1]. And ADD VALUE can't run in a transaction block,
which is a known limitation as explained in [2].

While this is unfortunate and maybe annoying, it's not a bug.

regards
Tomas

[1] http://www.postgresql.org/docs/9.1/static/app-psql.html
[2] http://www.postgresql.org/docs/9.1/static/sql-altertype.html

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Feike Steenbergen 2014-09-30 12:05:16 Re: BUG #11524: Unable to add value to ENUM when having AUTOCOMMIT disabled in psql
Previous Message feikesteenbergen 2014-09-30 10:43:30 BUG #11524: Unable to add value to ENUM when having AUTOCOMMIT disabled in psql