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

From Stephan Szabo
Subject Re: Add check constraint bug
Date
Msg-id 20020905154338.N72711-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Add check constraint bug  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Add check constraint bug  ("scott.marlowe" <scott.marlowe@ihs.com>)
List pgsql-hackers
On Thu, 5 Sep 2002, Peter Eisentraut wrote:

> 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 <> '');
> alter table test add check (a > 0);
> alter table test add check (a <> 1);
>
> After the last command I get
>
> ERROR:  CheckConstraintFetch: unexpected record found for rel test
>
> and then the table seems to be wedged because any access to it will get
> the same error.


I don't have reasonable access to the machine at home for code purposes,
but it looks to me that the add column line is the one that's causing
the bug.  It's inserting a check constraint but not upping relchecks
which seems to work because it's zero and therefore doesn't even look, but
the add check is incrementing the count and inserting its constraint which
makes 2 real constraints and relchecks=1 which causes the error.

This is probably also why it forgets about the check constraint below
since relchecks is 0, but I didn't look.

Note that:
create table test(a int check (a>3));
alter table test add column b text check(b<>'');
select * from test;

will error.




pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: Inheritance
Next
From: Hannu Krosing
Date:
Subject: Re: beta1 packaged