Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iPSf4-00053S-Ko for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Oct 2019 14:39:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iPSf3-0008D6-0E for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Oct 2019 14:39:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iPSf2-0008Ch-LJ for pgsql-bugs@lists.postgresql.org; Tue, 29 Oct 2019 14:39:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iPSew-0006R7-3y for pgsql-bugs@lists.postgresql.org; Tue, 29 Oct 2019 14:39:51 +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 x9TEdhnP013341; Tue, 29 Oct 2019 10:39:43 -0400 From: Tom Lane To: Pavel Popov cc: pgsql-bugs@lists.postgresql.org Subject: Re: Backup/restore problem In-reply-to: References: Comments: In-reply-to Pavel Popov message dated "Tue, 29 Oct 2019 10:14:45 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13339.1572359983.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 29 Oct 2019 10:39:43 -0400 Message-ID: <13340.1572359983@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Pavel Popov writes: > The problem occurs when we make backup of a db on server version 11 or 1= 2 > and restore on the same server version. When we restore on server versio= n > 12 a backup made on server version 9.6 this problem DOES NOT occur. I think it would happen if you tried to dump/restore with a *current* 9.6 release. The problem looks to be that this function is not safe against search_path changes: > CREATE FUNCTION chk_f_part_pricetar(_customer integer, _pricetar integer= ) > RETURNS boolean > LANGUAGE plpgsql > AS $$ > BEGIN > RETURN EXISTS(SELECT * FROM customers c JOIN nom.firms f ON c.invoiced= _by =3D f.id > JOIN prices.pricetar t ON f.id= =3D t.firm > WHERE c.id =3D _customer AND t.id =3D _pricetar) OR _pri= cetar IS NULL; > END;$$; and recent releases of pg_dump insist on running the script with a restrictive search_path for security reasons. It might be enough to schema-qualify the function's reference to "customers", although a safer solution would be to attach a "SET search_path" clause to the function to enforce the search path it's expecting. regards, tom lane