Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GIST_H
00017 #define GIST_H
00018
00019 #include "access/xlog.h"
00020 #include "access/xlogdefs.h"
00021 #include "storage/block.h"
00022 #include "storage/bufpage.h"
00023 #include "utils/relcache.h"
00024
00025
00026
00027
00028 #define GIST_CONSISTENT_PROC 1
00029 #define GIST_UNION_PROC 2
00030 #define GIST_COMPRESS_PROC 3
00031 #define GIST_DECOMPRESS_PROC 4
00032 #define GIST_PENALTY_PROC 5
00033 #define GIST_PICKSPLIT_PROC 6
00034 #define GIST_EQUAL_PROC 7
00035 #define GIST_DISTANCE_PROC 8
00036 #define GISTNProcs 8
00037
00038
00039
00040
00041
00042 #define RTLeftStrategyNumber 1
00043 #define RTOverLeftStrategyNumber 2
00044 #define RTOverlapStrategyNumber 3
00045 #define RTOverRightStrategyNumber 4
00046 #define RTRightStrategyNumber 5
00047 #define RTSameStrategyNumber 6
00048 #define RTContainsStrategyNumber 7
00049 #define RTContainedByStrategyNumber 8
00050 #define RTOverBelowStrategyNumber 9
00051 #define RTBelowStrategyNumber 10
00052 #define RTAboveStrategyNumber 11
00053 #define RTOverAboveStrategyNumber 12
00054 #define RTOldContainsStrategyNumber 13
00055 #define RTOldContainedByStrategyNumber 14
00056 #define RTKNNSearchStrategyNumber 15
00057
00058
00059
00060
00061 #define F_LEAF (1 << 0)
00062 #define F_DELETED (1 << 1)
00063 #define F_TUPLES_DELETED (1 << 2)
00064 #define F_FOLLOW_RIGHT (1 << 3)
00065
00066 typedef XLogRecPtr GistNSN;
00067
00068
00069
00070
00071 typedef PageXLogRecPtr PageGistNSN;
00072
00073 typedef struct GISTPageOpaqueData
00074 {
00075 PageGistNSN nsn;
00076 BlockNumber rightlink;
00077 uint16 flags;
00078 uint16 gist_page_id;
00079 } GISTPageOpaqueData;
00080
00081 typedef GISTPageOpaqueData *GISTPageOpaque;
00082
00083
00084
00085
00086
00087
00088
00089 #define GIST_PAGE_ID 0xFF81
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 typedef struct GIST_SPLITVEC
00119 {
00120 OffsetNumber *spl_left;
00121 int spl_nleft;
00122 Datum spl_ldatum;
00123 bool spl_ldatum_exists;
00124
00125 OffsetNumber *spl_right;
00126 int spl_nright;
00127 Datum spl_rdatum;
00128 bool spl_rdatum_exists;
00129 } GIST_SPLITVEC;
00130
00131
00132
00133
00134
00135
00136 typedef struct GISTENTRY
00137 {
00138 Datum key;
00139 Relation rel;
00140 Page page;
00141 OffsetNumber offset;
00142 bool leafkey;
00143 } GISTENTRY;
00144
00145 #define GistPageGetOpaque(page) ( (GISTPageOpaque) PageGetSpecialPointer(page) )
00146
00147 #define GistPageIsLeaf(page) ( GistPageGetOpaque(page)->flags & F_LEAF)
00148 #define GIST_LEAF(entry) (GistPageIsLeaf((entry)->page))
00149 #define GistPageSetLeaf(page) ( GistPageGetOpaque(page)->flags |= F_LEAF)
00150 #define GistPageSetNonLeaf(page) ( GistPageGetOpaque(page)->flags &= ~F_LEAF)
00151
00152 #define GistPageIsDeleted(page) ( GistPageGetOpaque(page)->flags & F_DELETED)
00153 #define GistPageSetDeleted(page) ( GistPageGetOpaque(page)->flags |= F_DELETED)
00154 #define GistPageSetNonDeleted(page) ( GistPageGetOpaque(page)->flags &= ~F_DELETED)
00155
00156 #define GistTuplesDeleted(page) ( GistPageGetOpaque(page)->flags & F_TUPLES_DELETED)
00157 #define GistMarkTuplesDeleted(page) ( GistPageGetOpaque(page)->flags |= F_TUPLES_DELETED)
00158 #define GistClearTuplesDeleted(page) ( GistPageGetOpaque(page)->flags &= ~F_TUPLES_DELETED)
00159
00160 #define GistFollowRight(page) ( GistPageGetOpaque(page)->flags & F_FOLLOW_RIGHT)
00161 #define GistMarkFollowRight(page) ( GistPageGetOpaque(page)->flags |= F_FOLLOW_RIGHT)
00162 #define GistClearFollowRight(page) ( GistPageGetOpaque(page)->flags &= ~F_FOLLOW_RIGHT)
00163
00164 #define GistPageGetNSN(page) ( PageXLogRecPtrGet(GistPageGetOpaque(page)->nsn))
00165 #define GistPageSetNSN(page, val) ( PageXLogRecPtrSet(GistPageGetOpaque(page)->nsn, val))
00166
00167
00168
00169
00170
00171 typedef struct
00172 {
00173 int32 n;
00174 GISTENTRY vector[FLEXIBLE_ARRAY_MEMBER];
00175 } GistEntryVector;
00176
00177 #define GEVHDRSZ (offsetof(GistEntryVector, vector))
00178
00179
00180
00181
00182 #define gistentryinit(e, k, r, pg, o, l) \
00183 do { (e).key = (k); (e).rel = (r); (e).page = (pg); \
00184 (e).offset = (o); (e).leafkey = (l); } while (0)
00185
00186 #endif