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 1q8zqT-0005AQ-6w for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jun 2023 08:57:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q8zqR-0003B1-V1 for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jun 2023 08:57:43 +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 1q8zqR-00037j-L5 for pgsql-hackers@lists.postgresql.org; Tue, 13 Jun 2023 08:57:43 +0000 Received: from mail.thelabyrinth.net ([45.56.70.56]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q8zqO-0026Df-UB for pgsql-hackers@postgresql.org; Tue, 13 Jun 2023 08:57:42 +0000 Received: from [10.5.0.2] (unknown [45.15.176.46]) (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 6D6E754677; Tue, 13 Jun 2023 08:57:38 +0000 (UTC) Message-ID: <2b53d137-1448-44cb-11fd-11319cfcb4da@pgmasters.net> Date: Tue, 13 Jun 2023 10:57:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: Views no longer in rangeTabls? Content-Language: en-US To: Amit Langote Cc: Tom Lane , Julien Rouhaud , Pg Hackers References: <3953179e-9540-e5d1-a743-4bef368785b0@pgmasters.net> <462cd5de-3ade-989b-0798-7e1cab562991@pgmasters.net> <470644.1686327286@sss.pgh.pa.us> <625519.1686401807@sss.pgh.pa.us> <20230610131857.cqrsm6pwq3k47yuv@jrouhaud> <629054.1686403658@sss.pgh.pa.us> <7232d0e1-36af-bf3f-e784-6b5576bae627@pgmasters.net> From: David Steele In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/13/23 10:27, Amit Langote wrote: > On Tue, Jun 13, 2023 at 4:44 PM David Steele wrote: > >> I decided to go with the following because I think it >> is easier to read: >> >> /* We only care about tables/views and can ignore subqueries, etc. */ >> if (!(rte->rtekind == RTE_RELATION || >> (rte->rtekind == RTE_SUBQUERY && rte->relkind == RELKIND_VIEW))) >> continue; > > It didn't occur to me so far to mention it but this could be replaced with: > > if (rte->perminfoindex != 0) > > and turn that condition into an Assert instead, like the loop over > range table in ExecCheckPermissions() does. Hmmm, that might work, and save us a filter on rte->perminfoindex later on (to filter out table partitions). Thanks for the tip! >>> I considered adding Assert(relkind == RELKIND_VIEW) in all places that >>> have the "rte->rtekind == RTE_SUBQUERY && OidIsValid(rte->relid)" >>> condition, but that seemed like an overkill, so only added one in the >>> #ifdef USE_ASSERT_CHECKING block in ExecCheckPermissions() that >>> f75cec4fff877 added. >> >> This seems like a good place for the assert. > > I added a comment above this Assert. > > I'd like to push this tomorrow barring objections. +1 for the new comment. Regards, -David