00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef GENAM_H
00015 #define GENAM_H
00016
00017 #include "access/sdir.h"
00018 #include "access/skey.h"
00019 #include "nodes/tidbitmap.h"
00020 #include "storage/lock.h"
00021 #include "utils/relcache.h"
00022 #include "utils/snapshot.h"
00023
00024
00025
00026
00027 typedef struct IndexBuildResult
00028 {
00029 double heap_tuples;
00030 double index_tuples;
00031 } IndexBuildResult;
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 typedef struct IndexVacuumInfo
00042 {
00043 Relation index;
00044 bool analyze_only;
00045 bool estimated_count;
00046 int message_level;
00047 double num_heap_tuples;
00048 BufferAccessStrategy strategy;
00049 } IndexVacuumInfo;
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 typedef struct IndexBulkDeleteResult
00069 {
00070 BlockNumber num_pages;
00071 BlockNumber pages_removed;
00072 bool estimated_count;
00073 double num_index_tuples;
00074 double tuples_removed;
00075 BlockNumber pages_deleted;
00076 BlockNumber pages_free;
00077 } IndexBulkDeleteResult;
00078
00079
00080 typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
00081
00082
00083 typedef struct IndexScanDescData *IndexScanDesc;
00084 typedef struct SysScanDescData *SysScanDesc;
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 typedef enum IndexUniqueCheck
00107 {
00108 UNIQUE_CHECK_NO,
00109 UNIQUE_CHECK_YES,
00110 UNIQUE_CHECK_PARTIAL,
00111 UNIQUE_CHECK_EXISTING
00112 } IndexUniqueCheck;
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 #define IndexScanIsValid(scan) PointerIsValid(scan)
00124
00125 extern Relation index_open(Oid relationId, LOCKMODE lockmode);
00126 extern void index_close(Relation relation, LOCKMODE lockmode);
00127
00128 extern bool index_insert(Relation indexRelation,
00129 Datum *values, bool *isnull,
00130 ItemPointer heap_t_ctid,
00131 Relation heapRelation,
00132 IndexUniqueCheck checkUnique);
00133
00134 extern IndexScanDesc index_beginscan(Relation heapRelation,
00135 Relation indexRelation,
00136 Snapshot snapshot,
00137 int nkeys, int norderbys);
00138 extern IndexScanDesc index_beginscan_bitmap(Relation indexRelation,
00139 Snapshot snapshot,
00140 int nkeys);
00141 extern void index_rescan(IndexScanDesc scan,
00142 ScanKey keys, int nkeys,
00143 ScanKey orderbys, int norderbys);
00144 extern void index_endscan(IndexScanDesc scan);
00145 extern void index_markpos(IndexScanDesc scan);
00146 extern void index_restrpos(IndexScanDesc scan);
00147 extern ItemPointer index_getnext_tid(IndexScanDesc scan,
00148 ScanDirection direction);
00149 extern HeapTuple index_fetch_heap(IndexScanDesc scan);
00150 extern HeapTuple index_getnext(IndexScanDesc scan, ScanDirection direction);
00151 extern int64 index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap);
00152
00153 extern IndexBulkDeleteResult *index_bulk_delete(IndexVacuumInfo *info,
00154 IndexBulkDeleteResult *stats,
00155 IndexBulkDeleteCallback callback,
00156 void *callback_state);
00157 extern IndexBulkDeleteResult *index_vacuum_cleanup(IndexVacuumInfo *info,
00158 IndexBulkDeleteResult *stats);
00159 extern bool index_can_return(Relation indexRelation);
00160 extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum,
00161 uint16 procnum);
00162 extern FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum,
00163 uint16 procnum);
00164
00165
00166
00167
00168 extern IndexScanDesc RelationGetIndexScan(Relation indexRelation,
00169 int nkeys, int norderbys);
00170 extern void IndexScanEnd(IndexScanDesc scan);
00171 extern char *BuildIndexValueDescription(Relation indexRelation,
00172 Datum *values, bool *isnull);
00173
00174
00175
00176
00177 extern SysScanDesc systable_beginscan(Relation heapRelation,
00178 Oid indexId,
00179 bool indexOK,
00180 Snapshot snapshot,
00181 int nkeys, ScanKey key);
00182 extern HeapTuple systable_getnext(SysScanDesc sysscan);
00183 extern bool systable_recheck_tuple(SysScanDesc sysscan, HeapTuple tup);
00184 extern void systable_endscan(SysScanDesc sysscan);
00185 extern SysScanDesc systable_beginscan_ordered(Relation heapRelation,
00186 Relation indexRelation,
00187 Snapshot snapshot,
00188 int nkeys, ScanKey key);
00189 extern HeapTuple systable_getnext_ordered(SysScanDesc sysscan,
00190 ScanDirection direction);
00191 extern void systable_endscan_ordered(SysScanDesc sysscan);
00192
00193 #endif