Re: search_plan_tree(): handling of non-leaf CustomScanState nodes causes segfault
Zhihong Yu <zyu@yugabyte.com>
From: Zhihong Yu <zyu@yugabyte.com>
To: David Geier <david@swarm64.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2021-01-18T18:08:32Z
Lists: pgsql-hackers
Hi, + * Custom scan nodes can be leaf nodes or inner nodes and therfore need special treatment. The special treatment applies to inner nodes. The above should be better phrased to clarify. Cheers On Mon, Jan 18, 2021 at 2:43 AM David Geier <david@swarm64.com> wrote: > Hi hackers, > > While working with cursors that reference plans with CustomScanStates > nodes, I encountered a segfault which originates from > search_plan_tree(). The query plan is the result of a simple SELECT > statement into which I inject a Custom Scan node at the root to do some > post-processing before returning rows. This plan is referenced by a > second plan with a Tid Scan which originates from a query of the form > DELETE FROM foo WHERE CURRENT OF my_cursor; > > search_plan_tree() assumes that > CustomScanState::ScanState::ss_currentRelation is never NULL. In my > understanding that only holds for CustomScanState nodes which are at the > bottom of the plan and actually read from a relation. CustomScanState > nodes which are not at the bottom don't have ss_currentRelation set. I > believe for such nodes, instead search_plan_tree() should recurse into > CustomScanState::custom_ps. > > I attached a patch. Any thoughts? > > Best regards, > David > Swarm64 > >
Commits
-
Remove faulty support for MergeAppend plan with WHERE CURRENT OF.
- 0ab177bec1c5 9.5.25 landed
- fe8edbb8267a 9.6.21 landed
- fac54bd5e216 10.16 landed
- 794562d0770a 11.11 landed
- 6253159965d5 12.6 landed
- 188cd4f440ed 13.2 landed
- a0efda88a679 14.0 landed
-
Avoid crash with WHERE CURRENT OF and a custom scan plan.
- 33a46993f15a 9.5.25 landed
- ffbf1746354a 9.6.21 landed
- 5cd94de777e0 10.16 landed
- de622e677cfd 11.11 landed
- ba80489c66cf 12.6 landed
- f0f53195b51a 13.2 landed
- 60661bbf2dca 14.0 landed