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 1q7sRw-00025W-Jb for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Jun 2023 06:51:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q7sRs-00032J-QM for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Jun 2023 06:51:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q7sRs-0002zF-GR for pgsql-hackers@lists.postgresql.org; Sat, 10 Jun 2023 06:51:44 +0000 Received: from mail.thelabyrinth.net ([45.56.70.56]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q7sRm-001DJE-I1 for pgsql-hackers@postgresql.org; Sat, 10 Jun 2023 06:51:42 +0000 Received: from [10.5.0.2] (unknown [87.249.138.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dsteele) by mail.thelabyrinth.net (Postfix) with ESMTPSA id DA30A5465C; Sat, 10 Jun 2023 06:51:36 +0000 (UTC) Message-ID: Date: Sat, 10 Jun 2023 09:51:34 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.1 Subject: Re: Views no longer in rangeTabls? To: Tom Lane Cc: Amit Langote , Pg Hackers References: <3953179e-9540-e5d1-a743-4bef368785b0@pgmasters.net> <462cd5de-3ade-989b-0798-7e1cab562991@pgmasters.net> <470644.1686327286@sss.pgh.pa.us> Content-Language: en-US From: David Steele In-Reply-To: <470644.1686327286@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/9/23 19:14, Tom Lane wrote: > 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(). Good to have confirmation of that, thanks! >> 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. Yeah, that's a good trick. Even so, I wonder why relkind is not set when relid is set? Regards, -David