1 /*-------------------------------------------------------------------------
4 * POSTGRES generalized index access method definitions.
7 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: genam.h,v 1.42 2003/08/04 02:40:10 momjian Exp $
12 *-------------------------------------------------------------------------
17 #include "access/itup.h"
18 #include "access/relscan.h"
19 #include "access/sdir.h"
20 #include "nodes/primnodes.h"
24 * Struct for statistics returned by bulk-delete operation
26 * This is now also passed to the index AM's vacuum-cleanup operation,
27 * if it has one, which can modify the results as needed. Note that
28 * an index AM could choose to have bulk-delete return a larger struct
29 * of which this is just the first field; this provides a way for bulk-delete
30 * to communicate additional private data to vacuum-cleanup.
32 typedef struct IndexBulkDeleteResult
34 BlockNumber num_pages; /* pages remaining in index */
35 double num_index_tuples; /* tuples remaining */
36 double tuples_removed; /* # removed by bulk-delete operation */
37 BlockNumber pages_deleted; /* # unused pages in index */
38 BlockNumber pages_free; /* # pages available for reuse */
39 } IndexBulkDeleteResult;
41 /* Typedef for callback function to determine if a tuple is bulk-deletable */
42 typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
44 /* Struct for additional arguments passed to vacuum-cleanup operation */
45 typedef struct IndexVacuumCleanupInfo
47 bool vacuum_full; /* VACUUM FULL (we have exclusive lock) */
48 int message_level; /* ereport level for progress messages */
49 } IndexVacuumCleanupInfo;
51 /* Struct for heap-or-index scans of system tables */
52 typedef struct SysScanDescData
54 Relation heap_rel; /* catalog being scanned */
55 Relation irel; /* NULL if doing heap scan */
56 HeapScanDesc scan; /* only valid in heap-scan case */
57 IndexScanDesc iscan; /* only valid in index-scan case */
60 typedef SysScanDescData *SysScanDesc;
64 * generalized index_ interface routines (in indexam.c)
66 extern Relation index_open(Oid relationId);
67 extern Relation index_openrv(const RangeVar *relation);
68 extern Relation index_openr(const char *sysRelationName);
69 extern void index_close(Relation relation);
70 extern InsertIndexResult index_insert(Relation indexRelation,
71 Datum *datums, char *nulls,
72 ItemPointer heap_t_ctid,
73 Relation heapRelation,
74 bool check_uniqueness);
76 extern IndexScanDesc index_beginscan(Relation heapRelation,
77 Relation indexRelation,
79 int nkeys, ScanKey key);
80 extern void index_rescan(IndexScanDesc scan, ScanKey key);
81 extern void index_endscan(IndexScanDesc scan);
82 extern void index_markpos(IndexScanDesc scan);
83 extern void index_restrpos(IndexScanDesc scan);
84 extern HeapTuple index_getnext(IndexScanDesc scan, ScanDirection direction);
85 extern bool index_getnext_indexitem(IndexScanDesc scan,
86 ScanDirection direction);
88 extern IndexBulkDeleteResult *index_bulk_delete(Relation indexRelation,
89 IndexBulkDeleteCallback callback,
90 void *callback_state);
91 extern IndexBulkDeleteResult *index_vacuum_cleanup(Relation indexRelation,
92 IndexVacuumCleanupInfo * info,
93 IndexBulkDeleteResult *stats);
94 extern RegProcedure index_cost_estimator(Relation indexRelation);
95 extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum,
97 extern struct FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum,
101 * index access method support routines (in genam.c)
103 extern IndexScanDesc RelationGetIndexScan(Relation indexRelation,
104 int nkeys, ScanKey key);
105 extern void IndexScanEnd(IndexScanDesc scan);
108 * heap-or-index access to system catalogs (in genam.c)
110 extern SysScanDesc systable_beginscan(Relation heapRelation,
111 const char *indexRelname,
114 int nkeys, ScanKey key);
115 extern HeapTuple systable_getnext(SysScanDesc sysscan);
116 extern void systable_endscan(SysScanDesc sysscan);