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 1pk9NX-0002mh-43 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Apr 2023 20:05:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pk9NW-0003uB-0v for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Apr 2023 20:05:10 +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 1pk9NV-0003u2-No for pgsql-hackers@lists.postgresql.org; Wed, 05 Apr 2023 20:05:09 +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 1pk9NS-0016th-VG for pgsql-hackers@lists.postgresql.org; Wed, 05 Apr 2023 20:05:09 +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 335K52fZ2060564; Wed, 5 Apr 2023 16:05:02 -0400 From: Tom Lane To: Amit Langote cc: vignesh C , Alvaro Herrera , PostgreSQL Hackers Subject: Re: on placeholder entries in view rule action query's range table In-reply-to: <2016650.1680719613@sss.pgh.pa.us> References: <20221208091245.k2bgz7one53dulef@alvherre.pgsql> <3684848.1673211536@sss.pgh.pa.us> <782120.1673485582@sss.pgh.pa.us> <2016650.1680719613@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Wed, 05 Apr 2023 14:33:33 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2060562.1680725102.1@sss.pgh.pa.us> Date: Wed, 05 Apr 2023 16:05:02 -0400 Message-ID: <2060563.1680725102@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > Amit Langote writes: >> While thinking about query view locking in context of [1], I realized >> that we have missed also fixing AcquirePlannerLocks() / >> ScanQueryForLocks() to consider that an RTE_SUBQUERY rte may belong to >> a view, which must be locked the same as RTE_RELATION entries. > I think you're right about that, because AcquirePlannerLocks is supposed > to reacquire whatever locks parsing+rewriting would have gotten. After poking at this a bit more, I'm not sure there is any observable bug, because we still notice the view change in AcquireExecutorLocks and loop back to re-plan after that. It still seems like a good idea to notice such changes sooner not later to reduce wasted work, so I went ahead and pushed the patch. The only way it'd be a live bug is if the planner actually fails because it's working with a stale view definition. I tried to make it fail by adjusting the view to no longer use an underlying table and then dropping that table ... but AcquirePlannerLocks still detected that, because of course it recurses and locks the table reference it finds in the view subquery. Maybe you could make a failure case involving dropping a user-defined function instead, but I thought that was getting pretty far afield, so I didn't pursue it. regards, tom lane