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

Commit1f91c8c

Browse files
committed
Avoid planner crash/Assert failure with joins to unflattened subqueries.
examine_simple_variable supposed that any RTE_SUBQUERY rel it gets pointedat must have been planned already. However, this isn't a safe assumptionbecause we must do selectivity estimation while generating indexscan paths,and that code might look at join clauses involving a rel that the loop inset_base_rel_sizes() hasn't reached yet. The simplest fix is to play dumbin such a situation, that is give up trying to extract any stats for theVar. This could possibly be improved by making a separate pass over theRTE list to plan each unflattened subquery before we start the mainplanning work --- but that would be pretty invasive and it doesn't seemworth it, for now at least. (We couldn't just break set_base_rel_sizes()into two loops: the prescan would need to handle all subquery rels in thequery, not only those in the current join subproblem.)This bug was introduced in commit1cb108e,although I think that subsequent changes may have exposed it more than itwas originally. Per bug #7580 from Maxim Boguk.
1 parentfe3b5eb commit1f91c8c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎src/backend/utils/adt/selfuncs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4518,8 +4518,10 @@ examine_simple_variable(PlannerInfo *root, Var *var,
45184518
*/
45194519
rel=find_base_rel(root,var->varno);
45204520

4521-
/* Subquery should have been planned already */
4522-
Assert(rel->subroot&&IsA(rel->subroot,PlannerInfo));
4521+
/* If the subquery hasn't been planned yet, we have to punt */
4522+
if (rel->subroot==NULL)
4523+
return;
4524+
Assert(IsA(rel->subroot,PlannerInfo));
45234525

45244526
/*
45254527
* Switch our attention to the subquery as mangled by the planner. It

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp