Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 4103190656A for ; Sat, 19 Nov 2011 04:45:27 -0400 (AST) Received: from news.hub.org ([200.46.204.72]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RRgY9-0002o5-Ui for pgsql-bugs@postgresql.org; Sat, 19 Nov 2011 08:45:27 +0000 Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id pAJ8jCvh051264 for ; Sat, 19 Nov 2011 04:45:12 -0400 (AST) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id pAJ8OBYm033336 for pgsql-bugs@postgresql.org; Sat, 19 Nov 2011 04:24:11 -0400 (AST) (envelope-from news) From: lindebg X-Newsgroups: pgsql.bugs Subject: Re: BUG #6299: pg_dump, pg_dumpall - Problem with the order of backup functions Date: Sat, 19 Nov 2011 09:24:11 +0100 Organization: Hub.Org Networking Services Lines: 134 Message-ID: <4EC767AB.4090005@gmail.com> References: <201111172054.pAHKsFc7052692@wwwmaster.postgresql.org> <15140.1321576938@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org To: Tom Lane User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11 In-Reply-To: <15140.1321576938@sss.pgh.pa.us> To: pgsql-bugs@postgresql.org X-Archive-Number: 201111/145 X-Sequence-Number: 31740 On 11/19/2011 12:19 AM, lindebg@gmail.com wrote: > Thanks, in this case works :-) However, this does not solve all cases. > Unlikely, but possible to create, cyclic case can not be restored: > Another example with more functions: $ psql create database test; \connect test create function fn1(param1 int) returns int as $$ select $1 $$ language sql immutable; create function fn2(param1 int default fn1(8)) returns int as $$ select $1 $$ language sql immutable; create function fn3(param1 int default fn2(5)) returns int as $$ select $1 $$ language sql immutable; create or replace function fn1(param1 int default fn3(3)) returns int as $$ select $1 $$ language sql immutable; \df List of functions Schema | Name | Result data type | Argument data types | Type --------+------+------------------+-------------------------------+-------- public | fn1 | integer | param1 integer DEFAULT fn3(3) | normal public | fn2 | integer | param1 integer DEFAULT fn1(8) | normal public | fn3 | integer | param1 integer DEFAULT fn2(5) | normal (3 rows) \q $ pg_dump -F c test > test.backup pg_dump: [sorter] WARNING: could not resolve dependency loop among these items: pg_dump: [sorter] FUNCTION fn2 (ID 173 OID 16403) pg_dump: [sorter] FUNCTION fn1 (ID 175 OID 16402) pg_dump: [sorter] FUNCTION fn3 (ID 174 OID 16404) $ psql -c "drop database test" $ psql -c "create database test" $ pg_restore -d test test.backup pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Error from TOC entry 173; 1255 16403 FUNCTION fn2(integer) postgres pg_restore: [archiver (db)] could not execute query: ERROR: function fn1(integer) does not exist LINE 1: CREATE FUNCTION fn2(param1 integer DEFAULT fn1(8)) RETURNS i... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. Command was: CREATE FUNCTION fn2(param1 integer DEFAULT fn1(8)) RETURNS integer LANGUAGE sql IMMUTABLE AS $_$ select $1 $_$; pg_restore: [archiver (db)] could not execute query: ERROR: function public.fn2(integer) does not exist Command was: ALTER FUNCTION public.fn2(param1 integer) OWNER TO postgres; pg_restore: [archiver (db)] Error from TOC entry 174; 1255 16404 FUNCTION fn3(integer) postgres pg_restore: [archiver (db)] could not execute query: ERROR: function fn2(integer) does not exist LINE 1: CREATE FUNCTION fn3(param1 integer DEFAULT fn2(5)) RETURNS i... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. Command was: CREATE FUNCTION fn3(param1 integer DEFAULT fn2(5)) RETURNS integer LANGUAGE sql IMMUTABLE AS $_$ select $1 $_$; pg_restore: [archiver (db)] could not execute query: ERROR: function public.fn3(integer) does not exist Command was: ALTER FUNCTION public.fn3(param1 integer) OWNER TO postgres; pg_restore: [archiver (db)] Error from TOC entry 175; 1255 16402 FUNCTION fn1(integer) postgres pg_restore: [archiver (db)] could not execute query: ERROR: function fn3(integer) does not exist LINE 1: CREATE FUNCTION fn1(param1 integer DEFAULT fn3(3)) RETURNS i... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. Command was: CREATE FUNCTION fn1(param1 integer DEFAULT fn3(3)) RETURNS integer LANGUAGE sql IMMUTABLE AS $_$ select $1 $_$; pg_restore: [archiver (db)] could not execute query: ERROR: function public.fn1(integer) does not exist Command was: ALTER FUNCTION public.fn1(param1 integer) OWNER TO postgres; WARNING: errors ignored on restore: 6 $ psql test \df List of functions Schema | Name | Result data type | Argument data types | Type --------+------+------------------+---------------------+------ (0 rows)