Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cmNL9-00081W-35 for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Mar 2017 16:24:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cmNL8-0006xH-HX for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Mar 2017 16:24:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cmNKR-0004vr-2T for pgsql-bugs@postgresql.org; Fri, 10 Mar 2017 16:23:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cmNKN-0001T7-Uh for pgsql-bugs@postgresql.org; Fri, 10 Mar 2017 16:23:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v2AGNYMT014282; Fri, 10 Mar 2017 11:23:35 -0500 From: Tom Lane To: milos.urbanek@email.cz cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14587: Foreign constraint with newline blows up pg_restore catalogue In-reply-to: <20170310155318.1425.30483@wrigleys.postgresql.org> References: <20170310155318.1425.30483@wrigleys.postgresql.org> Comments: In-reply-to milos.urbanek@email.cz message dated "Fri, 10 Mar 2017 15:53:18 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14280.1489163014.1@sss.pgh.pa.us> Date: Fri, 10 Mar 2017 11:23:34 -0500 Message-ID: <14281.1489163014@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 milos.urbanek@email.cz writes: > As repoted in https://trac.osgeo.org/postgis/ticket/3727 > If there is some newline in e.g. foreign key contraint, the second command > below fails: > pg_restore -l test.backup > test.backup.lst > pg_restore -L test.backup.lst > test2.out Hm. As of a year or two back, we sanitize object names in the comments printed in the restore script, eg after d1=# create table p (f1 int primary key); CREATE TABLE d1=# create table f (f1 int); CREATE TABLE d1=# alter table f add constraint "weird d1"# name" foreign key (f1) references p; ALTER TABLE the dump output will look like -- -- Name: f weird name; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY f ADD CONSTRAINT "weird name" FOREIGN KEY (f1) REFERENCES p(f1); However, pg_restore -l didn't get the memo: ; ; Selected TOC Entries: ; 2991; 1262 46745 DATABASE - d1 postgres 3; 2615 2200 SCHEMA - public postgres 2992; 0 0 COMMENT - SCHEMA public postgres 1; 3079 13112 EXTENSION - plpgsql 2993; 0 0 COMMENT - EXTENSION plpgsql 195; 1259 46751 TABLE public f postgres 194; 1259 46746 TABLE public p postgres 2986; 0 46751 TABLE DATA public f postgres 2985; 0 46746 TABLE DATA public p postgres 2862; 2606 46750 CONSTRAINT public p p_pkey postgres 2863; 2606 46754 FK CONSTRAINT public f weird name postgres and in turn that breaks -L for such cases. I think we need to transpose the sanitization to also happen in these code paths. Perhaps this should have been treated as a security issue, but the cat's out of the bag now. I think automated workflows involving -l are pretty rare anyway. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs