Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XvDQl-0003X3-5o for pgsql-bugs@arkaria.postgresql.org; Sun, 30 Nov 2014 22:57:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XvDQk-0001hL-Hm for pgsql-bugs@arkaria.postgresql.org; Sun, 30 Nov 2014 22:57:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XvCSs-0005ol-A9 for pgsql-bugs@postgresql.org; Sun, 30 Nov 2014 21:55:34 +0000 Received: from mail-wg0-f47.google.com ([74.125.82.47]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XvCSo-0004Lv-DJ for pgsql-bugs@postgresql.org; Sun, 30 Nov 2014 21:55:32 +0000 Received: by mail-wg0-f47.google.com with SMTP id n12so12663971wgh.20 for ; Sun, 30 Nov 2014 13:55:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:to:cc:subject:references:date :mime-version:content-transfer-encoding:from:organization:message-id :in-reply-to:user-agent; bh=flHUoZwsN3WP9lzqKg2Gm9pVadNAnpNJnhD9OBah9JA=; b=QwVX3bEjzaEiHbs7V17fR7Oilub2ycwvLIewqklyW+l51hgproWIWSO3K26VfvqbCE sroC85x3tRHucpU0GC0tJFj3MoJgQvfmZwE7eBHYxzGJfiiHUIa4yCKtIWM7gxY9wRTM eG98YBKqGI/25zgaPikRZI/1Mr00ytJ8ttIeN4U/LPYOwf7v8lEnnph1xYe1fvoyS4aJ Tz6QBcFZLnkV6/H9iNaC4YM/cKlzXRedTZqXAl56hGjWiDPH1Z0R2qPKuC+a8+uJ8ADG c9cO1DJBlkl8bVcIZE8rRGhFLhOxpYBRSVg3KFrO08jT2viqCeq2sBAjkhT+CSu2q0ZG KpnQ== X-Gm-Message-State: ALoCoQlPxOg+buTHi8JNeVRCFVbFqpRvWz3xMn6w3IewwYYvTYEczzGJipkbGrSBIJhZj9JsRqpz X-Received: by 10.180.79.169 with SMTP id k9mr80404657wix.34.1417384528776; Sun, 30 Nov 2014 13:55:28 -0800 (PST) Received: from gracie (ip-89-103-130-98.net.upcbroadband.cz. [89.103.130.98]) by mx.google.com with ESMTPSA id u9sm24919609wjy.37.2014.11.30.13.55.28 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 30 Nov 2014 13:55:28 -0800 (PST) Content-Type: text/plain; charset=iso-8859-2; format=flowed; delsp=yes To: "Tom Lane" Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #12106: pg_dump does not resolve circular dependency References: <20141130153705.5731.4615@wrigleys.postgresql.org> <9283.1417365074@sss.pgh.pa.us> Date: Sun, 30 Nov 2014 22:55:28 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable From: =?iso-8859-2?B?T25k+GVqIEJvdWRh?= Organization: Edookit Message-ID: In-Reply-To: <9283.1417365074@sss.pgh.pa.us> User-Agent: Opera Mail/12.17 (Win32) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Sun, 30 Nov 2014 17:31:14 +0100, Tom Lane wrote: > bouda@edookit.com writes: >> A function may reference itself via default values of some of its=20=20 >> arguments. >> It is rather tricky to create one, but it is possible: > > Unless you can demonstrate a credible use-case for this, I don't think > it's worth adding complexity to pg_dump for. > > regards, tom lane I admin I have no real world use case for the mentioned situation,=20=20 although I think it should be documented as a pg_dump limitation, at least. I suggest adding a new section called Limitations on the pg_dump=20=20 documentation page, which would list all currently known limitations.=20=20 Looking at the object attributes and their possible dependencies on other= =20=20 objects, I found these cases not handled by pg_dump (i.e., resulting in an= =20=20 erroneous dump): 1) Function argument default referring to other objects, causing a=20=20 circular dependency (even referring to the function itself) - this is the= =20=20 originally reported one. 2) Domain default calling a function - which therefore must return that=20= =20 domain type. E.g., CREATE DOMAIN dom AS INT; CREATE FUNCTION get_default_dom() RETURNS dom AS $$ SELECT 42::dom; $$ LANGUAGE sql; ALTER DOMAIN dom SET DEFAULT get_default_dom(); For these, pg_dump emits CREATE FUNCTION first, then CREATE DOMAIN. The=20= =20 CREATE FUNCTION fails as the domain has not been created yet. Worse, it=20= =20 even emits no warnings - the pg_dump output looks entirely clear. 3) View referring to itself (or other view which in turn refers to the=20=20 first one...). E.g., CREATE VIEW selfview (o) AS SELECT NULL::regclass; CREATE OR REPLACE VIEW selfview (o) AS SELECT 'selfview'::regclass; Here, pg_dump emits CREATE VIEW selfview AS SELECT 'selfview'::regclass AS= =20=20 o; - which fails (ERROR: relation "selfview" does not exist). Similarly=20= =20 to 2), no warnings are given, i.e., one finds out only when actually=20=20 trying to restore the dump. Generally, any object may be referenced by expressions like=20=20 'seq'::regclass within: - table column defaults - domain defaults - function argument defaults - view definitions Any of them may result in a circular dependency which pg_dump is unable to= =20=20 cut. I am aware of the fact all these cases might look silly (except for case=20= =20 2), maybe), but still - mentioning them in the docs might help. In addition, it would be nice if pg_dump could at least detect the=20=20 circular dependency in cases 2) and 3) and issue a warning, similarly to=20= =20 case 1). Ond=F8ej Bouda P.S. Sorry for not coming out with a patch right away - I am a newbie=20=20 here... --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs