Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit33a4699

Browse files
committed
Avoid crash with WHERE CURRENT OF and a custom scan plan.
execCurrent.c's search_plan_tree() assumed that ForeignScanStatesand CustomScanStates necessarily have a valid ss_currentRelation.This is demonstrably untrue for postgres_fdw's remote join andremote aggregation plans, and non-leaf custom scans might not havean identifiable scan relation either. Avoid crashing by ignoringsuch nodes when the field is null.This solution will lead to errors like 'cursor "foo" is not asimply updatable scan of table "bar"' in cases where maybe wecould have allowed WHERE CURRENT OF to work. That's not an issuefor postgres_fdw's usages, since joins or aggregations would renderWHERE CURRENT OF invalid anyway. But an otherwise-transparentupper level custom scan node might find this annoying. When and ifsomeone cares to expend work on such a scenario, we could invent acustom-scan-provider callback to determine what's safe.Report and patch by David Geier, commentary by me. It's been likethis for awhile, so back-patch to all supported branches.Discussion:https://postgr.es/m/0253344d-9bdd-11c4-7f0d-d88c02cd7991@swarm64.com
1 parentc424c75 commit33a4699

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎src/backend/executor/execCurrent.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,12 @@ search_plan_tree(PlanState *node, Oid table_oid,
314314
switch (nodeTag(node))
315315
{
316316
/*
317-
* Relation scan nodes can all be treated alike
317+
* Relation scan nodes can all be treated alike. Note that
318+
* ForeignScan and CustomScan might not have a currentRelation, in
319+
* which case we just ignore them. (We dare not descend to any
320+
* child plan nodes they might have, since we do not know the
321+
* relationship of such a node's current output tuple to the
322+
* children's current outputs.)
318323
*/
319324
caseT_SeqScanState:
320325
caseT_SampleScanState:
@@ -327,7 +332,8 @@ search_plan_tree(PlanState *node, Oid table_oid,
327332
{
328333
ScanState*sstate= (ScanState*)node;
329334

330-
if (RelationGetRelid(sstate->ss_currentRelation)==table_oid)
335+
if (sstate->ss_currentRelation&&
336+
RelationGetRelid(sstate->ss_currentRelation)==table_oid)
331337
result=sstate;
332338
break;
333339
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp