Rearrange the implementation of index-only scans.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: a0185461dd94c8d31d8d55a7f2839b0d2f172ab9
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2011-10-11T18:21:30Z
Releases: 9.2.0
Rearrange the implementation of index-only scans.

This commit changes index-only scans so that data is read directly from the
index tuple without first generating a faux heap tuple.  The only immediate
benefit is that indexes on system columns (such as OID) can be used in
index-only scans, but this is necessary infrastructure if we are ever to
support index-only scans on expression indexes.  The executor is now ready
for that, though the planner still needs substantial work to recognize
the possibility.

To do this, Vars in index-only plan nodes have to refer to index columns
not heap columns.  I introduced a new special varno, INDEX_VAR, to mark
such Vars to avoid confusion.  (In passing, this commit renames the two
existing special varnos to OUTER_VAR and INNER_VAR.)  This allows
ruleutils.c to handle them with logic similar to what we use for subplan
reference Vars.

Since index-only scans are now fundamentally different from regular
indexscans so far as their expression subtrees are concerned, I also chose
to change them to have their own plan node type (and hence, their own
executor source file).

Files

PathChange+/−
src/backend/commands/explain.c modified +79 −40
src/backend/commands/trigger.c modified +4 −4
src/backend/executor/execAmi.c modified +20 −1
src/backend/executor/execCurrent.c modified +1 −0
src/backend/executor/execProcnode.c modified +14 −0
src/backend/executor/execQual.c modified +16 −8
src/backend/executor/execScan.c modified +8 −1
src/backend/executor/execUtils.c modified +8 −4
src/backend/executor/Makefile modified +2 −1
src/backend/executor/nodeAgg.c modified +2 −2
src/backend/executor/nodeBitmapIndexscan.c modified +0 −1
src/backend/executor/nodeHash.c modified +2 −2
src/backend/executor/nodeIndexonlyscan.c added +542 −0
src/backend/executor/nodeIndexscan.c modified +17 −125
src/backend/executor/nodeNestloop.c modified +2 −2
src/backend/nodes/copyfuncs.c modified +28 −1
src/backend/nodes/outfuncs.c modified +19 −3
src/backend/nodes/print.c modified +6 −2
src/backend/optimizer/path/indxpath.c modified +11 −12
src/backend/optimizer/path/pathkeys.c modified +10 −58
src/backend/optimizer/plan/createplan.c modified +101 −37
src/backend/optimizer/plan/setrefs.c modified +107 −31
src/backend/optimizer/plan/subselect.c modified +12 −0
src/backend/optimizer/util/pathnode.c modified +1 −2
src/backend/optimizer/util/plancat.c modified +71 −0
src/backend/utils/adt/ruleutils.c modified +106 −53
src/backend/utils/adt/tid.c modified +1 −1
src/include/executor/nodeIndexonlyscan.h added +26 −0
src/include/executor/nodeIndexscan.h modified +5 −2
src/include/nodes/execnodes.h modified +34 −2
src/include/nodes/nodes.h modified +2 −0
src/include/nodes/plannodes.h modified +30 −8
src/include/nodes/primnodes.h modified +10 −6
src/include/nodes/relation.h modified +16 −11