Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id DC823B5D8C5 for ; Tue, 27 Sep 2011 07:12:09 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 29923-08 for ; Tue, 27 Sep 2011 10:12:02 +0000 (UTC) X-Greylist: delayed 00:05:27.316883 by SQLgrey-1.8.0-rc2 Received: from mail2a.alliedtesting.com (unknown [80.249.134.186]) by mail.postgresql.org (Postfix) with ESMTP id 0D2ADB5D803 for ; Tue, 27 Sep 2011 07:12:02 -0300 (ADT) Received: from mail2a.alliedtesting.com ([192.168.66.21]) by mail2a.alliedtesting.com ([192.168.66.21]) with mapi; Tue, 27 Sep 2011 14:06:24 +0400 From: To: Date: Tue, 27 Sep 2011 14:06:23 +0400 Subject: Problems with ENUM type manipulation in 9.1 Thread-Topic: Problems with ENUM type manipulation in 9.1 Thread-Index: Acx8/KXe9MIusLQAQQqFODcWbW6klg== Message-ID: <29F36C7C98AB09499B1A209D48EAA615B7653DBC8A@mail2a.alliedtesting.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.107 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RDNS_NONE=0.793 X-Spam-Level: X-Archive-Number: 201109/198 X-Sequence-Number: 31215 Hello, I've encountered some problems with the updated ENUM in PosgreSQL 9.1: 1. We can use ALTER TYPE to add enum values, but there is no matching comma= nd to remove values, which makes this an incomplete solution. 2. "ALTER TYPE ... ADD cannot be executed from a function or multi-command = string" (or from a transaction block), which makes it quite useless for our= purposes. We update our databases using SQL patches. Patches are applied= in a single transaction, so that any failure during execution causes the e= ntire patch to be rolled back. This command cannot be made part of such a p= atch. Even if that wasn't an issue, we would still have a problem, because = the command cannot be used in a DO block. Why would we want to do that? In = order to check first what values are already in the ENUM, lest we attempt t= o add an existing value. 3. In earlier PostgreSQL versions we used custom procedures (based on proce= dures developed by Dmitry Koterov http://en.dklab.ru/lib/dklab_postgresql_e= num/) to add and delete ENUM values. These procedures manipulate pg_enum ta= ble directly. I've updated them to take into account the new column in pg_e= num that was added in 9.1. However, although adding enums this way seems to= work (new values appear in the pg_enum table), attempting to use these new= enums results in errors, such as this: "enum value 41983 not found in cac= he for enum [...]". Is it possible to reset this cache after altering the p= g_enum table? Thanks, Dmitry Dmitry Epstein | Developer =20 Allied Testing T + 7 495 544 48 69 Ext 417 www.alliedtesting.com We Deliver Quality.