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

dump/reload

From: Brett McCormick <brett(at)work(dot)chicken(dot)org>
To: pgsql-hackers(at)hub(dot)org
Subject: dump/reload
Date: 1998-06-03 01:25:37
Message-ID: 13684.42513.788012.96339@web0.speakeasy.org (view raw or flat)
Thread:
Lists: pgsql-hackers
they don't always work, in the case of a table with an attribute that
calls a function for its default value.

postgres=> create function foo() returns int4 as 'select 1' language 'sql';
CREATE
postgres=> create table a (b int4 default foo());
CREATE

% pg_dump postgres > tmpfile
% cat tmpfile
\connect - postgres
CREATE TABLE a (b int4 DEFAULT foo ( ));
\connect - postgres
CREATE FUNCTION foo ( ) RETURNS int4 AS 'select 1' LANGUAGE 'SQL';
COPY a FROM stdin;
\.
% destroydb
% createdb
% psql < tmpfile

which of course doesn't work, because it tries to create the table before
the function, which fails.

then it spits out the help message because it can't understand \.

this happens every time I dump/reload my db

not a super easy fix, because sql functions can depend on tables to be
created as well as table depending on functions.  are circular
references possible?  doesn't seem like they would be.

so pg_dump would have to figure out what order to put the
table/function creation in.  perhaps having ppl manually re-ordering
the dump output (and documenting this accordingly!) is the best way.

Responses

pgsql-hackers by date

Next:From: Roland RobertsDate: 1998-06-03 02:17:42
Subject: Re: [HACKERS] regular expressions from hell
Previous:From: Bruce MomjianDate: 1998-06-02 21:52:17
Subject: Re: [HACKERS] Re: [INTERFACES] ODBC is slow with M$-Access Report

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