diff options
Diffstat (limited to 'src/backend/optimizer/plan/createplan.c')
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index f0bcff72cbc..1fe1ff73490 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -877,6 +877,22 @@ use_physical_tlist(PlannerInfo *root, Path *path, int flags) } /* + * For an index-only scan, the "physical tlist" is the index's indextlist. + * We can only return that without a projection if all the index's columns + * are returnable. + */ + if (path->pathtype == T_IndexOnlyScan) + { + IndexOptInfo *indexinfo = ((IndexPath *) path)->indexinfo; + + for (i = 0; i < indexinfo->ncolumns; i++) + { + if (!indexinfo->canreturn[i]) + return false; + } + } + + /* * Also, can't do it if CP_LABEL_TLIST is specified and path is requested * to emit any sort/group columns that are not simple Vars. (If they are * simple Vars, they should appear in the physical tlist, and |