Re: BUG #11638: Transaction safety fails when constraints are dropped and analyze is done

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, cg(at)osss(dot)net, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #11638: Transaction safety fails when constraints are dropped and analyze is done
Date: 2014-10-28 23:28:05
Message-ID: 20972.1414538885@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> I think that a better answer is to continue to do this update
> nontransactionally, but to not let the code clear relhasindex etc
> if we're inside a transaction block. It is certainly safe to put
> off clearing those flags if we're not sure that we're seeing a
> committed state of the table's schema.

Attached is a proposed patch to do it that way. I borrowed Michael's
test case.

> An interesting question is whether it is ever possible for this function
> to be told to *set* relhasindex when it was clear (or likewise for the
> other flags). Offhand I would say that that should never happen, because
> certainly neither VACUUM nor ANALYZE should be creating indexes etc.
> Should we make it throw an error if that happens, or just go ahead and
> apply the update, assuming that it's correcting somehow-corrupted data?

After looking more closely, the existing precedent for the other similar
fields is just to make sure the code only clears the flags, never sets
them, so I think relhasindex should be treated the same.

regards, tom lane

Attachment Content-Type Size
fix-bug-11638.patch text/x-diff 7.6 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2014-10-28 23:52:56 Re: BUG #11638: Transaction safety fails when constraints are dropped and analyze is done
Previous Message Adrian Klaver 2014-10-28 19:58:29 Re: Need guidance on regression.diffs