1 /*-------------------------------------------------------------------------
4 * POSTGRES generalized index access method definitions.
7 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $PostgreSQL: pgsql/src/include/access/genam.h,v 1.57 2006/02/11 23:31:34 tgl 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 * Note: pages_removed is the amount by which the index physically shrank,
33 * if any (ie the change in its total size on disk). pages_deleted and
34 * pages_free refer to free space within the index file.
36 typedef struct IndexBulkDeleteResult
38 BlockNumber num_pages; /* pages remaining in index */
39 BlockNumber pages_removed; /* # removed by bulk-delete operation */
40 double num_index_tuples; /* tuples remaining */
41 double tuples_removed; /* # removed by bulk-delete operation */
42 BlockNumber pages_deleted; /* # unused pages in index */
43 BlockNumber pages_free; /* # pages available for reuse */
44 } IndexBulkDeleteResult;
46 /* Typedef for callback function to determine if a tuple is bulk-deletable */
47 typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
49 /* Struct for additional arguments passed to vacuum-cleanup operation */
50 typedef struct IndexVacuumCleanupInfo
52 bool vacuum_full; /* VACUUM FULL (we have exclusive lock) */
53 int message_level; /* ereport level for progress messages */
54 double num_heap_tuples; /* tuples remaining in heap */
55 } IndexVacuumCleanupInfo;
57 /* Struct for heap-or-index scans of system tables */
58 typedef struct SysScanDescData
60 Relation heap_rel; /* catalog being scanned */
61 Relation irel; /* NULL if doing heap scan */
62 HeapScanDesc scan; /* only valid in heap-scan case */
63 IndexScanDesc iscan; /* only valid in index-scan case */
66 typedef SysScanDescData *SysScanDesc;
70 * generalized index_ interface routines (in indexam.c)
72 extern Relation index_open(Oid relationId);
73 extern Relation index_openrv(const RangeVar *relation);
74 extern void index_close(Relation relation);
75 extern bool index_insert(Relation indexRelation,
76 Datum *values, bool *isnull,
77 ItemPointer heap_t_ctid,
78 Relation heapRelation,
79 bool check_uniqueness);
81 extern IndexScanDesc index_beginscan(Relation heapRelation,
82 Relation indexRelation,
85 int nkeys, ScanKey key);
86 extern IndexScanDesc index_beginscan_multi(Relation indexRelation,
89 int nkeys, ScanKey key);
90 extern void index_rescan(IndexScanDesc scan, ScanKey key);
91 extern void index_endscan(IndexScanDesc scan);
92 extern void index_markpos(IndexScanDesc scan);
93 extern void index_restrpos(IndexScanDesc scan);
94 extern HeapTuple index_getnext(IndexScanDesc scan, ScanDirection direction);
95 extern bool index_getnext_indexitem(IndexScanDesc scan,
96 ScanDirection direction);
97 extern bool index_getmulti(IndexScanDesc scan,
98 ItemPointer tids, int32 max_tids,
99 int32 *returned_tids);
101 extern IndexBulkDeleteResult *index_bulk_delete(Relation indexRelation,
102 IndexBulkDeleteCallback callback,
103 void *callback_state);
104 extern IndexBulkDeleteResult *index_vacuum_cleanup(Relation indexRelation,
105 IndexVacuumCleanupInfo *info,
106 IndexBulkDeleteResult *stats);
107 extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum,
109 extern FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum,
113 * index access method support routines (in genam.c)
115 extern IndexScanDesc RelationGetIndexScan(Relation indexRelation,
116 int nkeys, ScanKey key);
117 extern void IndexScanEnd(IndexScanDesc scan);
120 * heap-or-index access to system catalogs (in genam.c)
122 extern SysScanDesc systable_beginscan(Relation heapRelation,
126 int nkeys, ScanKey key);
127 extern HeapTuple systable_getnext(SysScanDesc sysscan);
128 extern void systable_endscan(SysScanDesc sysscan);