Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q7elJ-0003fR-Kk for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Jun 2023 16:14:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q7elI-00071G-EQ for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Jun 2023 16:14:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q7elI-000717-4Y for pgsql-hackers@lists.postgresql.org; Fri, 09 Jun 2023 16:14:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q7elF-001FLs-Le for pgsql-hackers@postgresql.org; Fri, 09 Jun 2023 16:14:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 359GEkZB470645; Fri, 9 Jun 2023 12:14:46 -0400 From: Tom Lane To: David Steele cc: Amit Langote , Pg Hackers Subject: Re: Views no longer in rangeTabls? In-reply-to: <462cd5de-3ade-989b-0798-7e1cab562991@pgmasters.net> References: <3953179e-9540-e5d1-a743-4bef368785b0@pgmasters.net> <462cd5de-3ade-989b-0798-7e1cab562991@pgmasters.net> Comments: In-reply-to David Steele message dated "Fri, 09 Jun 2023 17:46:48 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <470643.1686327286.1@sss.pgh.pa.us> Date: Fri, 09 Jun 2023 12:14:46 -0400 Message-ID: <470644.1686327286@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Steele writes: > Thank you, this was very helpful. I am able to get the expected result > now with: > /* We only care about tables/views and can ignore subqueries, etc. */ > if (!(rte->rtekind == RTE_RELATION || > (rte->rtekind == RTE_SUBQUERY && OidIsValid(rte->relid)))) > continue; Right, that matches places like add_rtes_to_flat_rtable(). > One thing, though, rte->relkind is not set for views, so I still need to > call get_rel_relkind(rte->relid). Not a big deal, but do you think it > would make sense to set rte->relkind for views? If you see "rte->rtekind == RTE_SUBQUERY && OidIsValid(rte->relid)", it's dead certain that relid refers to a view, so you could just wire in that knowledge. regards, tom lane