diff options
Diffstat (limited to 'src/backend/access')
| -rw-r--r-- | src/backend/access/index/indexam.c | 22 | ||||
| -rw-r--r-- | src/backend/access/nbtree/nbtree.c | 11 | ||||
| -rw-r--r-- | src/backend/access/spgist/spgscan.c | 7 |
3 files changed, 40 insertions, 0 deletions
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 6d423a7d68..e5fb518389 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -26,6 +26,7 @@ * index_getbitmap - get all tuples from a scan * index_bulk_delete - bulk deletion of index tuples * index_vacuum_cleanup - post-deletion cleanup of an index + * index_can_return - does index support index-only scans? * index_getprocid - get a support procedure OID * index_getprocinfo - get a support procedure's lookup info * @@ -712,6 +713,27 @@ index_vacuum_cleanup(IndexVacuumInfo *info, } /* ---------------- + * index_can_return - does index support index-only scans? + * ---------------- + */ +bool +index_can_return(Relation indexRelation) +{ + FmgrInfo *procedure; + + RELATION_CHECKS; + + /* amcanreturn is optional; assume FALSE if not provided by AM */ + if (!RegProcedureIsValid(indexRelation->rd_am->amcanreturn)) + return false; + + GET_REL_PROCEDURE(amcanreturn); + + return DatumGetBool(FunctionCall1(procedure, + PointerGetDatum(indexRelation))); +} + +/* ---------------- * index_getprocid * * Index access methods typically require support routines that are diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index f3a1d256a0..13c0552517 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -1091,3 +1091,14 @@ restart: goto restart; } } + +/* + * btcanreturn() -- Check whether btree indexes support index-only scans. + * + * btrees always do, so this is trivial. + */ +Datum +btcanreturn(PG_FUNCTION_ARGS) +{ + PG_RETURN_BOOL(true); +} diff --git a/src/backend/access/spgist/spgscan.c b/src/backend/access/spgist/spgscan.c index ac30964968..748265ecba 100644 --- a/src/backend/access/spgist/spgscan.c +++ b/src/backend/access/spgist/spgscan.c @@ -559,3 +559,10 @@ spggettuple(PG_FUNCTION_ARGS) PG_RETURN_BOOL(false); } + +Datum +spgcanreturn(PG_FUNCTION_ARGS) +{ + /* Not implemented yet */ + PG_RETURN_BOOL(false); +} |
