Re: Add check constraint bug - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Add check constraint bug
Date
Msg-id 10170.1031269978@sss.pgh.pa.us
Whole thread Raw
In response to Add check constraint bug  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Add check constraint bug  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> The following happens in latest CVS and a fresh database:
> create table test (a int);
> insert into test values (1);
> alter table test add column b text check (b <> '');

This bug's been there awhile I fear.  The failure occurs when
AlterTableAddColumn needs to add a check constraint AND the
new column causes AlterTableCreateToastTable to do its thing.

The reason there is a bug is that AlterTableCreateToastTable
gratuitously does a heap_mark4update, thereby selecting the un-updated
version of the pg_class tuple as its basis for modification (and
ignoring the HeapTupleSelfUpdated return code that warned that there
was a problem).

I've said before that I do not like heap_mark4update in catalog
manipulations, and here's a perfect example of why it's a bad idea.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: Add check constraint bug
Next
From: Gavin Sherry
Date:
Subject: Re: I am done