Re: on placeholder entries in view rule action query's range table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: on placeholder entries in view rule action query's range table
Date: 2023-04-05 20:05:02
Message-ID: 2060563.1680725102@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Amit Langote <amitlangote09(at)gmail(dot)com> 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-04-05 20:16:24 Re: monitoring usage count distribution
Previous Message Robert Haas 2023-04-05 19:58:28 Re: Should vacuum process config file reload more often