OSDN Git Service

Update copyrights to 2003.
[pg-rex/syncrep.git] / src / include / access / genam.h
1 /*-------------------------------------------------------------------------
2  *
3  * genam.h
4  *        POSTGRES generalized index access method definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: genam.h,v 1.42 2003/08/04 02:40:10 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef GENAM_H
15 #define GENAM_H
16
17 #include "access/itup.h"
18 #include "access/relscan.h"
19 #include "access/sdir.h"
20 #include "nodes/primnodes.h"
21
22
23 /*
24  * Struct for statistics returned by bulk-delete operation
25  *
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.
31  */
32 typedef struct IndexBulkDeleteResult
33 {
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;
40
41 /* Typedef for callback function to determine if a tuple is bulk-deletable */
42 typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
43
44 /* Struct for additional arguments passed to vacuum-cleanup operation */
45 typedef struct IndexVacuumCleanupInfo
46 {
47         bool            vacuum_full;    /* VACUUM FULL (we have exclusive lock) */
48         int                     message_level;  /* ereport level for progress messages */
49 }       IndexVacuumCleanupInfo;
50
51 /* Struct for heap-or-index scans of system tables */
52 typedef struct SysScanDescData
53 {
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 */
58 } SysScanDescData;
59
60 typedef SysScanDescData *SysScanDesc;
61
62
63 /*
64  * generalized index_ interface routines (in indexam.c)
65  */
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);
75
76 extern IndexScanDesc index_beginscan(Relation heapRelation,
77                                 Relation indexRelation,
78                                 Snapshot snapshot,
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);
87
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,
96                                 uint16 procnum);
97 extern struct FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum,
98                                   uint16 procnum);
99
100 /*
101  * index access method support routines (in genam.c)
102  */
103 extern IndexScanDesc RelationGetIndexScan(Relation indexRelation,
104                                          int nkeys, ScanKey key);
105 extern void IndexScanEnd(IndexScanDesc scan);
106
107 /*
108  * heap-or-index access to system catalogs (in genam.c)
109  */
110 extern SysScanDesc systable_beginscan(Relation heapRelation,
111                                    const char *indexRelname,
112                                    bool indexOK,
113                                    Snapshot snapshot,
114                                    int nkeys, ScanKey key);
115 extern HeapTuple systable_getnext(SysScanDesc sysscan);
116 extern void systable_endscan(SysScanDesc sysscan);
117
118 #endif   /* GENAM_H */