Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCoPr-0002Ma-Rm for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Jun 2016 13:30:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bCoPr-0000Sp-E1 for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Jun 2016 13:30:03 +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 1bCoPq-0000ST-RR for pgsql-bugs@postgresql.org; Tue, 14 Jun 2016 13:30:02 +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 1bCoPi-0004dR-VR for pgsql-bugs@postgresql.org; Tue, 14 Jun 2016 13:30:02 +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 u5EDToab022634; Tue, 14 Jun 2016 09:29:50 -0400 From: Tom Lane To: Michael Paquier cc: marian.krucina@gmail.com, PostgreSQL mailing lists Subject: Re: BUG #13907: Restore materialized view throw permission denied In-reply-to: References: <20160202161407.2778.24659@wrigleys.postgresql.org> Comments: In-reply-to Michael Paquier message dated "Tue, 14 Jun 2016 16:16:58 +0900" Date: Tue, 14 Jun 2016 09:29:50 -0400 Message-ID: <22633.1465910990@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) 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 Michael Paquier writes: > This is one of those issues where it would be cool to only plan and > execute the query creating the materialized view query with NO DATA > without planning and executing it first, and do the actual planning > and execution at the first refresh. A similar problem was discussed > here: > https://www.postgresql.org/message-id/flat/20160115175546.2968.6033%40wrigleys.postgresql.org#20160115175546.2968.6033@wrigleys.postgresql.org > Thought I don't think that it is that straight-forward, the relation > defined using a CTAS uses column information directly derived from the > query planned, so the fix would be to extract the necessary > information for those columns: collation, column name, type OID and > typemod without the need of the existing routines. I think you want to be looking at the way that CREATE VIEW accomplishes the same task. See DefineView and DefineVirtualRelation. It might be worth refactoring those a bit to allow code sharing. 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