Re: pg_dump and CHECK constraints - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: pg_dump and CHECK constraints
Date
Msg-id 200402121636.i1CGaL800622@candle.pha.pa.us
Whole thread Raw
In response to pg_dump and CHECK constraints  (Curt Sampson <cjs@cynic.net>)
List pgsql-hackers
Curt Sampson wrote:
> 
> I notice that pg_dump is still dumping CHECK constraints with the table,
> rather than at the very end, as it does with all the other constraints.
> As discussed in bug report #787, at
> 
>     http://archives.postgresql.org/pgsql-bugs/2002-09/msg00278.php
> 
> this breaks your restore if your CHECK constraint uses a user-defined
> function.
> 
>     1. Does anybody have any plans to fix this in the very near future?
> 
>     2. If not, is there something that makes it particularly hard to
>     fix? I notice, Tom, that in your reply to that bug report you
>     intimated that this wasn't an easy fix, but I don't see why CHECK
>     constraints couldn't be added at the end of the dump, just as all
>     the other constraints are. Presumably, your message being late 2002,
>     this was before pg_dump was modified to re-order stuff?
> 
>     3. If we created a patch for this at my work, would it be accepted?
> 
> I dunno...this looks really easy to me....

Please check CVS.  I think Tom did some big work on dependency dumping. 
If I do:test=> CREATE FUNCTION func(INT) returns bool AS 'SELECT TRUE'test->  LANGUAGE 'SQL';CREATE FUNCTIONtest=>
CREATETABLE yy (x INT CHECK (func(x) = TRUE));CREATE TABLEtest=> INSERT INTO yy VALUES (1);INSERT 17576 1
 

and in pg_dump output I see:---- Name: func(integer); Type: FUNCTION; Schema: public; Owner: postgres--CREATE FUNCTION
func(integer)RETURNS boolean    AS 'select true'    LANGUAGE sql;---- Name: yy; Type: TABLE; Schema: public; Owner:
postgres--CREATETABLE yy (    x integer,    CONSTRAINT yy_x CHECK ((func(x) = true))) WITH OIDS;
 
so this might be fixed in CVS already.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: Idea about better configuration options for sort memory
Next
From: Bruce Momjian
Date:
Subject: Re: implemented missing bitSetBit() and bitGetBit()