pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Kupershmidt <schmiddy@gmail.com>
Cc: Alvaro Herrera <alvherre@commandprompt.com>
Cc: depstein <depstein@alliedtesting.com>
Cc: mmoncure <mmoncure@gmail.com>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: Problems with ENUM type manipulation in 9.1
Date: Wed, 28 Sep 2011 12:50:12 -0400
Message-ID: <4738.1317228612@sss.pgh.pa.us> (raw)
In-Reply-To: <CAK3UJRF3r69tXQaLxPQq-TPL_CZekbxX0nboKxsac1biXsZupg@mail.gmail.com>
References: <29F36C7C98AB09499B1A209D48EAA615B7653DBC8A@mail2a.alliedtesting.com>
	<CAHyXU0ydWtuQWe7uPZae8X125RcOLGHO7vNUzOoMF=_SMYFzTg@mail.gmail.com>
	<29F36C7C98AB09499B1A209D48EAA615B7653DBCAB@mail2a.alliedtesting.com>
	<1317220852-sup-4032@alvh.no-ip.org>
	<CAK3UJRF3r69tXQaLxPQq-TPL_CZekbxX0nboKxsac1biXsZupg@mail.gmail.com>

Josh Kupershmidt <schmiddy@gmail.com> writes:
>> Excerpts from depstein's message of miƩ sep 28 07:21:17 -0300 2011:
>>> Anyway, the procedure that we used (based on
>>> http://en.dklab.ru/lib/dklab_postgresql_enum/) does the necessary
>>> checks before removing enum values.

> Not exactly; that code is rife with race conditions. For instance, how
> does the "Check data references" loop ensure that previously-checked
> tables don't get a new row containing the forbidden enum_elem before
> the function is finished?

It's worse than that: even if you have in fact deleted all occurrences
of a specific enum OID from the tables, that OID might still be lurking
in a btree index on an enum column.  If you delete the pg_enum entry,
and the OID is odd (meaning that the pg_enum entry must be consulted to
find out how to sort it), you just broke that index.

You might think you could get out of that by VACUUM'ing to ensure that
dead index entries get cleaned out, but that is not good enough.  The
problem OID could have gotten copied into a btree page boundary value or
non-leaf-page entry.  If that happens, the OID will most likely never
disappear from the index, short of a REINDEX; and this is also the worst
case for index corruption, since we must be able to compare other OID
values to the non-leaf-page entry to figure out which leaf page to
descend to in searches.

In short, the reason why this type of code hasn't been adopted into core
is that it doesn't work.

			regards, tom lane



view thread (11+ messages)  latest in thread

Message-ID: <4738.1317228612@sss.pgh.pa.us>
Permalink:  ../4738.1317228612@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4738.1317228612@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, schmiddy@gmail.com, alvherre@commandprompt.com, depstein@alliedtesting.com, mmoncure@gmail.com
  Subject: Re: Problems with ENUM type manipulation in 9.1
  In-Reply-To: <4738.1317228612@sss.pgh.pa.us>
  References: <29F36C7C98AB09499B1A209D48EAA615B7653DBC8A@mail2a.alliedtesting.com> <CAHyXU0ydWtuQWe7uPZae8X125RcOLGHO7vNUzOoMF=_SMYFzTg@mail.gmail.com> <29F36C7C98AB09499B1A209D48EAA615B7653DBCAB@mail2a.alliedtesting.com> <1317220852-sup-4032@alvh.no-ip.org> <CAK3UJRF3r69tXQaLxPQq-TPL_CZekbxX0nboKxsac1biXsZupg@mail.gmail.com> <4738.1317228612@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox