diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-27 23:53:05 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-27 23:53:05 +0000 |
commit | bf3dbb5881e9b886ee9fe84bca2153c698eea885 (patch) | |
tree | eaaf385364adebc2489c72f30e533f5fe60748ec /src/backend/access/rtree/rtget.c | |
parent | 351519affcffb636de68c4872521c9ac22faa228 (diff) | |
download | postgresql-bf3dbb5881e9b886ee9fe84bca2153c698eea885.tar.gz postgresql-bf3dbb5881e9b886ee9fe84bca2153c698eea885.zip |
First steps towards index scans with heap access decoupled from index
access: define new index access method functions 'amgetmulti' that can
fetch multiple TIDs per call. (The functions exist but are totally
untested as yet.) Since I was modifying pg_am anyway, remove the
no-longer-needed 'rel' parameter from amcostestimate functions, and
also remove the vestigial amowner column that was creating useless
work for Alvaro's shared-object-dependencies project.
Initdb forced due to changes in pg_am.
Diffstat (limited to 'src/backend/access/rtree/rtget.c')
-rw-r--r-- | src/backend/access/rtree/rtget.c | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/src/backend/access/rtree/rtget.c b/src/backend/access/rtree/rtget.c index 31963e81a06..e076d5a989c 100644 --- a/src/backend/access/rtree/rtget.c +++ b/src/backend/access/rtree/rtget.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/rtree/rtget.c,v 1.34 2005/01/18 23:25:43 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/access/rtree/rtget.c,v 1.35 2005/03/27 23:53:02 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -29,15 +29,13 @@ rtgettuple(PG_FUNCTION_ARGS) { IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0); ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1); + RTreeScanOpaque so = (RTreeScanOpaque) s->opaque; Page page; OffsetNumber offnum; - RTreeScanOpaque so; - - so = (RTreeScanOpaque) s->opaque; /* * If we've already produced a tuple and the executor has informed - * us that it should be marked "killed", do so know. + * us that it should be marked "killed", do so now. */ if (s->kill_prior_tuple && ItemPointerIsValid(&(s->currentItemData))) { @@ -57,7 +55,7 @@ rtgettuple(PG_FUNCTION_ARGS) { bool res = rtnext(s, dir); - if (res == true && s->ignore_killed_tuples) + if (res && s->ignore_killed_tuples) { offnum = ItemPointerGetOffsetNumber(&(s->currentItemData)); page = BufferGetPage(so->curbuf); @@ -69,6 +67,42 @@ rtgettuple(PG_FUNCTION_ARGS) } } +Datum +rtgetmulti(PG_FUNCTION_ARGS) +{ + IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0); + ItemPointer tids = (ItemPointer) PG_GETARG_POINTER(1); + int32 max_tids = PG_GETARG_INT32(2); + int32 *returned_tids = (int32 *) PG_GETARG_POINTER(3); + RTreeScanOpaque so = (RTreeScanOpaque) s->opaque; + bool res = true; + int32 ntids = 0; + + /* XXX generic implementation: loop around guts of rtgettuple */ + while (ntids < max_tids) + { + res = rtnext(s, ForwardScanDirection); + if (res && s->ignore_killed_tuples) + { + Page page; + OffsetNumber offnum; + + offnum = ItemPointerGetOffsetNumber(&(s->currentItemData)); + page = BufferGetPage(so->curbuf); + if (ItemIdDeleted(PageGetItemId(page, offnum))) + continue; + } + + if (!res) + break; + tids[ntids] = s->xs_ctup.t_self; + ntids++; + } + + *returned_tids = ntids; + PG_RETURN_BOOL(res); +} + static bool rtnext(IndexScanDesc s, ScanDirection dir) { |