Re: Add check constraint bug

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add check constraint bug
Date: 2002-09-05 22:49:40
Message-ID: 20020905154338.N72711-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message scott.marlowe 2002-09-05 22:57:32 Re: Add check constraint bug
Previous Message Greg Copeland 2002-09-05 22:19:32 Re: Inheritance