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 1ipydm-0008HF-QX for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Jan 2020 18:04:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ipydl-0002Ao-Kh for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Jan 2020 18:04:09 +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 1ipydl-00029w-9Q for pgsql-bugs@lists.postgresql.org; Fri, 10 Jan 2020 18:04:09 +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 1ipydj-00045s-3u for pgsql-bugs@lists.postgresql.org; Fri, 10 Jan 2020 18:04:08 +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 00AI45Xn012605; Fri, 10 Jan 2020 13:04:05 -0500 From: Tom Lane To: wagner.engel@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16202: Cannot restore database that has materialized view using crosstab (tablefunc) In-reply-to: <16202-b6b345c9d2819409@postgresql.org> References: <16202-b6b345c9d2819409@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 10 Jan 2020 17:38:05 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12603.1578679445.1@sss.pgh.pa.us> Date: Fri, 10 Jan 2020 13:04:05 -0500 Message-ID: <12604.1578679445@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > If I build a materizalized view that uses the crosstab() function, a > dump/restore cycle will not restore the database. > CREATE VIEW v AS > SELECT * FROM crosstab ( > 'SELECT id FROM t as t1', > 'SELECT id FROM t as t2' > ) ct (a integer, b integer); This view is unsafe because it doesn't schema-qualify its reference to table t. It will fail if run with a restrictive search_path, which is what pg_dump does for security reasons. An ordinary view reference to "t" would be all right, because the system understands what that is and can adjust the schema qualification; but here you've just got a string that happens to contain "t" in it. regards, tom lane