CHECK constraint (true) causes dumps with parse errors - Mailing list pgsql-bugs

From Szűcs Gábor
Subject CHECK constraint (true) causes dumps with parse errors
Date
Msg-id 428D99D7.6030800@gmail.com
Whole thread Raw
Responses Re: CHECK constraint (true) causes dumps with parse errors  (Neil Conway <neilc@samurai.com>)
List pgsql-bugs
Dear Gurus,

Version: 7.3.3, 7.4.8

I don't know for sure, but something like this happened when dumping our
server from 7.3 to 7.4. Actually, it seems to be a problem in 7.4 (maybe
also in 7.3, but unlikely -- see below, "our original way").

# create table foo (bar int, constraint foobar check (true or bar=1));
CREATE TABLE
# \d foo      Table "public.foo" Column |  Type   | Modifiers
--------+---------+----------- bar    | integer |
Check constraints:    "foobar" CHECK (true OR bar = 1)

# drop table foo;
DROP TABLE
# create table foo (bar int, constraint foobar check (true));
CREATE TABLE
# \d foo      Table "public.foo" Column |  Type   | Modifiers
--------+---------+----------- bar    | integer |
Check constraints:    "foobar" CHECK ()

Yours,
--
G.

---------------- our original way we found the problem:
-- original create command:
CREATE TABLE foo (    bar int,    CONSTRAINT foobar CHECK (true or bar=1)
);

-- 7.3 dump:
CREATE TABLE foo (    bar int,    CONSTRAINT foobar CHECK (true)
);

-- fed to 7.4, then \d
...
Check constraints:    "foobar" CHECK ()
-- note the empty parentheses!

-- mirroring the database caused:
ERROR:  syntax error at or near ")" at character xxx

-- recreated table (actually, readded constraint) to 7.4, then \d
...
Check constraints:    "foobar" CHECK (true OR bar=1)



pgsql-bugs by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: BUG #1675: very slow work
Next
From: Neil Conway
Date:
Subject: Re: CHECK constraint (true) causes dumps with parse errors