On 2020-Jun-03, Amit Langote wrote: > Are you saying that the planner should take into account the state of > the cursor specified in WHERE CURRENT OF to determine which of the > tables to scan for the UPDATE? Note that neither partition pruning > nor constraint exclusion know that CurrentOfExpr can possibly allow to > exclude children of the UPDATE target.
I think from a user POV this is pretty obvious. The user doesn't really care that there are partitions that were pruned, because obviously UPDATE WHERE CURRENT OF cannot refer to a tuple in those partitions. > > I am possibly shooting in dark, but this puzzles me. And it looks like > > we can cause wrong rows to be updated in non-partition inheritance > > where the ctids match? > > I don't think that hazard exists, because the table OID is matched > before the TID. It sounds like CURRENT OF should somehow inform pruning that the partition OID is to be matched as well. I don't know offhand if this is easily implementable, though. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services