pg_dump + function/table hierarchy - Mailing list pgsql-hackers

From Kovacs Zoltan Sandor
Subject pg_dump + function/table hierarchy
Date
Msg-id Pine.LNX.4.05.10007292116340.11253-100000@pc10.radnoti-szeged.sulinet.hu
Whole thread Raw
List pgsql-hackers
Unfortunately I managed to create a problematic database. The problem
occurs if I execute pg_dump and then try to reload the database. Details:

My only definitions in this database are:

> create function x(int4) returns bool as 'select $1 > 10;' language 'sql';
> create table y(z int4 check(x(z)));

Then, after pg_dump I got the next dump:

\connect - postgres
CREATE TABLE "y" ("z" int4,CONSTRAINT "y_z" CHECK (x(z))
);
CREATE FUNCTION "x" (int4 ) RETURNS bool AS 'select $1 > 10;' LANGUAGE 'SQL';
COPY "y" FROM stdin;
\.

Then, loading this dump back into the dropped and recreated database, I
got error messages, because the FUNCTION "x" is not created before the
TABLE "y".

The problem doesn't seems to be solved too easily. In fact, it is not a
good solution that FUNCTIONs are dumped before the TABLEs, because
the 'SQL' FUNCTIONs use the TABLEs in general (and the parser tries to
detect the SQL query). What to do? We need to store some kind of hierarchy
between table and function definitions, and after that could we say
something about the regenerating order. Of course, it needs at least one
new table among the system tables and needs pg_dump to be a bit more
complicated.

Regards,
Zoltan

------------------------------------------------------------------------------
KOVACS, Zoltan                              tip@pc10.radnoti-szeged.sulinet.hu



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Anyone care about type "filename" ?
Next
From: Tom Lane
Date:
Subject: Hmm, should ACL[] be toastable?