aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/index/indexam.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-07-15 22:48:19 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-07-15 22:48:19 +0000
commitc8076f09d2eb82a28f27f97230be470fffe7a1e0 (patch)
tree1e357e7e28313386f9d2e789d3905b37ce2d58f6 /src/backend/access/index/indexam.c
parent997439f59e1d487cb2bfa1384f6479fda0c4dd4c (diff)
downloadpostgresql-c8076f09d2eb82a28f27f97230be470fffe7a1e0.tar.gz
postgresql-c8076f09d2eb82a28f27f97230be470fffe7a1e0.zip
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in different AMs' ambuild routines has been moved out to a common routine in index.c; this means that all index types now do the right things about inserting recently-dead tuples, etc. (I also removed support for EXTEND INDEX in the ambuild routines, since that's about to go away anyway, and it cluttered the code a lot.) The retail indextuple deletion routines have been replaced by a "bulk delete" routine in which the indexscan is inside the access method. I haven't pushed this change as far as it should go yet, but it should allow considerable simplification of the internal bookkeeping for deletions. Also, add flag columns to pg_am to eliminate various hardcoded tests on AM OIDs, and remove unused pg_am columns. Fix rtree and gist index types to not attempt to store NULLs; before this, gist usually crashed, while rtree managed not to crash but computed wacko bounding boxes for NULL entries (which might have had something to do with the performance problems we've heard about occasionally). Add AtEOXact routines to hash, rtree, and gist, all of which have static state that needs to be reset after an error. We discovered this need long ago for btree, but missed the other guys. Oh, one more thing: concurrent VACUUM is now the default.
Diffstat (limited to 'src/backend/access/index/indexam.c')
-rw-r--r--src/backend/access/index/indexam.c60
1 files changed, 33 insertions, 27 deletions
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index adeccf5cc84..2b6be06168f 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.51 2001/06/22 19:16:21 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.52 2001/07/15 22:48:15 tgl Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relationId
@@ -18,23 +18,17 @@
* index_rescan - restart a scan of an index
* index_endscan - end a scan
* index_insert - insert an index tuple into a relation
- * index_delete - delete an item from an index relation
* index_markpos - mark a scan position
* index_restrpos - restore a scan position
* index_getnext - get the next tuple from a scan
- * ** index_fetch - retrieve tuple with tid
- * ** index_replace - replace a tuple
- * ** index_getattr - get an attribute from an index tuple
- * index_getprocid - get a support procedure id from the rel tuple
- *
- * IndexScanIsValid - check index scan
+ * index_bulk_delete - bulk deletion of index tuples
+ * index_cost_estimator - fetch amcostestimate procedure OID
+ * index_getprocid - get a support procedure OID
*
* NOTES
* This file contains the index_ routines which used
* to be a scattered collection of stuff in access/genam.
*
- * The ** routines: index_fetch, index_replace, and index_getattr
- * have not yet been implemented. They may not be needed.
*
* old comments
* Scans are implemented as follows:
@@ -211,23 +205,6 @@ index_insert(Relation relation,
}
/* ----------------
- * index_delete - delete an item from an index relation
- * ----------------
- */
-void
-index_delete(Relation relation, ItemPointer indexItem)
-{
- RegProcedure procedure;
-
- RELATION_CHECKS;
- GET_REL_PROCEDURE(delete, amdelete);
-
- OidFunctionCall2(procedure,
- PointerGetDatum(relation),
- PointerGetDatum(indexItem));
-}
-
-/* ----------------
* index_beginscan - start a scan of an index
* ----------------
*/
@@ -379,6 +356,35 @@ index_getnext(IndexScanDesc scan,
}
/* ----------------
+ * index_bulk_delete - do mass deletion of index entries
+ *
+ * callback routine tells whether a given main-heap tuple is
+ * to be deleted
+ *
+ * return value is an optional palloc'd struct of statistics
+ * ----------------
+ */
+IndexBulkDeleteResult *
+index_bulk_delete(Relation relation,
+ IndexBulkDeleteCallback callback,
+ void *callback_state)
+{
+ RegProcedure procedure;
+ IndexBulkDeleteResult *result;
+
+ RELATION_CHECKS;
+ GET_REL_PROCEDURE(bulk_delete, ambulkdelete);
+
+ result = (IndexBulkDeleteResult *)
+ DatumGetPointer(OidFunctionCall3(procedure,
+ PointerGetDatum(relation),
+ PointerGetDatum((Pointer) callback),
+ PointerGetDatum(callback_state)));
+
+ return result;
+}
+
+/* ----------------
* index_cost_estimator
*
* Fetch the amcostestimate procedure OID for an index.