Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32fcfcd

Browse files
committed
Fix oversight in recent changes to enable the 'physical tlist'
optimization for subquery and function scan nodes: we can't just do it unconditionally, we still have to check whether there is any need for a whole-row Var. I had been thinking that these node types couldn't have any system columns, which is true, but that loop is also checking for attno zero, ie, whole-row Var. Fix comment to not be so misleading. Per test case from Richard Huxton.
1 parent b33a732 commit 32fcfcd

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/backend/optimizer/plan/createplan.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.201 2005/10/15 02:49:20 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.202 2005/10/19 17:31:20 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -308,17 +308,13 @@ use_physical_tlist(RelOptInfo *rel)
308308
int i;
309309

310310
/*
311-
* OK for subquery and function scans; otherwise, can't do it for anything
312-
* except real relations.
311+
* We can do this for real relation scans, subquery scans, and function
312+
* scans (but not for, eg, joins).
313313
*/
314-
if (rel->rtekind != RTE_RELATION)
315-
{
316-
if (rel->rtekind == RTE_SUBQUERY)
317-
return true;
318-
if (rel->rtekind == RTE_FUNCTION)
319-
return true;
314+
if (rel->rtekind != RTE_RELATION &&
315+
rel->rtekind != RTE_SUBQUERY &&
316+
rel->rtekind != RTE_FUNCTION)
320317
return false;
321-
}
322318

323319
/*
324320
* Can't do it with inheritance cases either (mainly because Append
@@ -328,15 +324,16 @@ use_physical_tlist(RelOptInfo *rel)
328324
return false;
329325

330326
/*
331-
* Can't do it if any system columns are requested, either. (This could
332-
* possibly be fixed but would take some fragile assumptions in setrefs.c,
333-
* I think.)
327+
* Can't do it if any system columns or whole-row Vars are requested,
328+
* either. (This could possibly be fixed but would take some fragile
329+
* assumptions in setrefs.c, I think.)
334330
*/
335331
for (i = rel->min_attr; i <= 0; i++)
336332
{
337333
if (!bms_is_empty(rel->attr_needed[i - rel->min_attr]))
338334
return false;
339335
}
336+
340337
return true;
341338
}
342339

0 commit comments

Comments
 (0)