Skip site navigation (1) Skip section navigation (2)

CHECK constraint (true) causes dumps with parse errors

From: Szűcs Gábor <surrano(at)gmail(dot)com>
To: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: CHECK constraint (true) causes dumps with parse errors
Date: 2005-05-20 08:03:35
Message-ID: 428D99D7.6030800@gmail.com (view raw or flat)
Thread:
Lists: 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)


Responses

pgsql-bugs by date

Next:From: Neil ConwayDate: 2005-05-20 08:22:21
Subject: Re: CHECK constraint (true) causes dumps with parse errors
Previous:From: Michael FuhrDate: 2005-05-19 22:33:05
Subject: Re: BUG #1675: very slow work

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group