PostgreSQL Source Code: src/include/access/gist_private.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef GIST_PRIVATE_H

15#define GIST_PRIVATE_H

16

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39#define GIST_MAX_SPLIT_PAGES 75

40

41

42#define GIST_SHARE BUFFER_LOCK_SHARE

43#define GIST_EXCLUSIVE BUFFER_LOCK_EXCLUSIVE

44#define GIST_UNLOCK BUFFER_LOCK_UNLOCK

45

46typedef struct

47{

52

53#define BUFFER_PAGE_DATA_OFFSET MAXALIGN(offsetof(GISTNodeBufferPage, tupledata))

54

55#define PAGE_FREE_SPACE(nbp) (nbp->freespace)

56

57#define PAGE_IS_EMPTY(nbp) (nbp->freespace == BLCKSZ - BUFFER_PAGE_DATA_OFFSET)

58

59#define PAGE_NO_SPACE(nbp, itup) (PAGE_FREE_SPACE(nbp) < \

60 MAXALIGN(IndexTupleSize(itup)))

61

62

63

64

65

66

67

68

69

70

71

72

73

74

76{

79

82

84

85

95

96

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

119{

121 bool recheck;

124

126

128

129

131{

134 union

135 {

137

140

141

144

145#define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)

146

147#define SizeOfGISTSearchItem(n_distances) \

148 (offsetof(GISTSearchItem, distances) + \

149 sizeof(IndexOrderByDistance) * (n_distances))

150

151

152

153

155{

158

161 bool qual_ok;

162 bool firstCall;

163

164

166

167

169 int numKilled;

172

173

178

180

182

183

185{

187 int num;

189

190

192{

199

202

203

204

205

206

208{

209

213

214

215

216

217

219

220

221

222

223

224

226

227

229

230

233

234

236{

238

240

242

244

246

247 bool *spl_dontcare;

248

250

251typedef struct

252{

257

260

261

262#define GIST_ROOT_BLKNO 0

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285#define TUPLE_IS_VALID 0xffff

286#define TUPLE_IS_INVALID 0xfffe

287

288#define GistTupleIsInvalid(itup) ( ItemPointerGetOffsetNumber( &((itup)->t_tid) ) == TUPLE_IS_INVALID )

289#define GistTupleSetValid(itup) ItemPointerSetOffsetNumber( &((itup)->t_tid), TUPLE_IS_VALID )

290

291

292

293

294

295

296

297

298typedef struct

299{

302

305

306

308

309

311

314

315

316

317

318

319#define LEVEL_HAS_BUFFERS(nlevel, gfbb) \

320 ((nlevel) != 0 && (nlevel) % (gfbb)->levelStep == 0 && \

321 (nlevel) != (gfbb)->rootlevel)

322

323

324#define BUFFER_HALF_FILLED(nodeBuffer, gfbb) \

325 ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer / 2)

326

327

328

329

330

331

332#define BUFFER_OVERFLOWED(nodeBuffer, gfbb) \

333 ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer)

334

335

336

337

339{

340

342

344 long nFileBlocks;

345

346

347

348

350 int nFreeBlocks;

351 int freeBlocksLen;

352

353

355

356

358

359

360

361

362

363

366

367

370

371

372

373

374

378

379

382

383

385{

390

391

392

393

395{

396 int32 vl_len_;

397 int fillfactor;

400

401

406 bool indexUnchanged,

413 Size freespace,

416 bool is_build);

417

418

419typedef struct

420{

424

430 List **splitinfo,

431 bool markfollowright,

433 bool is_build);

434

437

438

442

445

449 Buffer leftchildbuf);

450

452 int ntodelete, TransactionId snapshotConflictHorizon,

454

458 Buffer leftchildbuf, bool markfollowright);

459

461

462

466

467

470 Oid opclassoid,

471 List *operators,

473

474

475

476#define GiSTPageSize \

477 ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) )

478

479#define GIST_MIN_FILLFACTOR 10

480#define GIST_DEFAULT_FILLFACTOR 90

481

485 bool *res, bool *isnull);

497

505 Relation r, const Datum *attdata, const bool *isnull, bool isleaf);

507 const Datum *attdata, const bool *isnull, bool isleaf, Datum *compatt);

508

512

517 bool l, bool isNull);

518

520 GISTENTRY *orig, bool isNullOrig,

523 Datum *attr, bool *isnull);

532 Datum *dst, bool *dstisnull);

533

535

536

540 void *callback_state);

543

544

548 int attno);

549

550

553

554

556 int maxLevel);

567 int level, Buffer buffer,

568 List *splitinfo);

570

571#endif

static bool validate(Port *port, const char *auth)

static Datum values[MAXATTR]

#define FLEXIBLE_ARRAY_MEMBER

bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)

SplitPageLayout * gistSplit(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate)

GISTSTATE * initGISTstate(Relation index)

void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, OffsetNumber o, GISTENTRY *attdata, bool *isnull)

bytea * gistoptions(Datum reloptions, bool validate)

void gistadjustmembers(Oid opfamilyoid, Oid opclassoid, List *operators, List *functions)

void gistPushItupToNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple itup)

bool gistinsert(Relation r, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, struct IndexInfo *indexInfo)

XLogRecPtr gistXLogAssignLSN(void)

void gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate, Relation heapRel, bool is_build)

struct SplitPageLayout SplitPageLayout

void gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate, Relation r, int level, Buffer buffer, List *splitinfo)

Buffer gistNewBuffer(Relation r, Relation heaprel)

bool gistproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)

GISTBuildBuffers * gistInitBuildBuffers(int pagesPerBuffer, int levelStep, int maxLevel)

struct GISTSearchHeapItem GISTSearchHeapItem

XLogRecPtr gistXLogSplit(bool page_is_leaf, SplitPageLayout *dist, BlockNumber origrlink, GistNSN orignsn, Buffer leftchildbuf, bool markfollowright)

bool gistPageRecyclable(Page page)

void gistMakeUnionKey(GISTSTATE *giststate, int attno, GISTENTRY *entry1, bool isnull1, GISTENTRY *entry2, bool isnull2, Datum *dst, bool *dstisnull)

XLogRecPtr gistXLogPageDelete(Buffer buffer, FullTransactionId xid, Buffer parentBuffer, OffsetNumber downlinkOffset)

IndexBulkDeleteResult * gistvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)

XLogRecPtr gistXLogDelete(Buffer buffer, OffsetNumber *todelete, int ntodelete, TransactionId snapshotConflictHorizon, Relation heaprel)

bool gistvalidate(Oid opclassoid)

bool gistgettuple(IndexScanDesc scan, ScanDirection dir)

void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, Datum *attr, bool *isnull)

bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace)

bool gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, Buffer buffer, IndexTuple *itup, int ntup, OffsetNumber oldoffnum, BlockNumber *newblkno, Buffer leftchildbuf, List **splitinfo, bool markfollowright, Relation heapRel, bool is_build)

HeapTuple gistFetchTuple(GISTSTATE *giststate, Relation r, IndexTuple tuple)

bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)

int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)

void gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)

void gistbuildempty(Relation index)

@ GIST_OPTION_BUFFERING_OFF

@ GIST_OPTION_BUFFERING_AUTO

@ GIST_OPTION_BUFFERING_ON

void gistFreeBuildBuffers(GISTBuildBuffers *gfbb)

IndexTuple gistFormTuple(GISTSTATE *giststate, Relation r, const Datum *attdata, const bool *isnull, bool isleaf)

struct GISTSearchItem GISTSearchItem

IndexTuple * gistextractpage(Page page, int *len)

struct GISTScanOpaqueData GISTScanOpaqueData

void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, bool l, bool isNull)

GISTScanOpaqueData * GISTScanOpaque

bool gistfitpage(IndexTuple *itvec, int len)

IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate)

OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE *giststate)

IndexBuildResult * gistbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)

MemoryContext createTempGistContext(void)

void gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate, GistSplitVector *v, int attno)

struct GISTInsertStack GISTInsertStack

XLogRecPtr gistGetFakeLSN(Relation rel)

struct GISTSTATE GISTSTATE

void gistCompressValues(GISTSTATE *giststate, Relation r, const Datum *attdata, const bool *isnull, bool isleaf, Datum *compatt)

void gistXLogPageReuse(Relation rel, Relation heaprel, BlockNumber blkno, FullTransactionId deleteXid)

IndexTuple * gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)

bool gistcanreturn(Relation index, int attno)

XLogRecPtr gistXLogUpdate(Buffer buffer, OffsetNumber *todelete, int ntodelete, IndexTuple *itup, int ituplen, Buffer leftchildbuf)

void freeGISTstate(GISTSTATE *giststate)

bool gistPopItupFromNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple *itup)

IndexBulkDeleteResult * gistbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)

struct GistSplitVector GistSplitVector

void gistinitpage(Page page, uint32 f)

GISTNodeBuffer * gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate, BlockNumber nodeBlocknum, int level)

void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb)

struct GiSTOptions GiSTOptions

IndexTuple gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)

void GISTInitBuffer(Buffer b, uint32 f)

struct gistxlogPage gistxlogPage

void gistcheckpage(Relation rel, Buffer buf)

IndexTupleData * gistfillitupvec(IndexTuple *vec, int veclen, int *memlen)

float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *orig, bool isNullOrig, GISTENTRY *add, bool isNullAdd)

struct GISTBuildBuffers GISTBuildBuffers

struct IndexTupleData IndexTupleData

static const struct fns functions

GISTNodeBuffer ** loadedBuffers

List * bufferEmptyingQueue

OffsetNumber downlinkoffnum

struct GISTInsertStack * parent

GISTNodeBufferPage * pageBuffer

FmgrInfo fetchFn[INDEX_MAX_KEYS]

FmgrInfo penaltyFn[INDEX_MAX_KEYS]

Oid supportCollation[INDEX_MAX_KEYS]

FmgrInfo distanceFn[INDEX_MAX_KEYS]

FmgrInfo consistentFn[INDEX_MAX_KEYS]

FmgrInfo decompressFn[INDEX_MAX_KEYS]

FmgrInfo compressFn[INDEX_MAX_KEYS]

FmgrInfo equalFn[INDEX_MAX_KEYS]

FmgrInfo unionFn[INDEX_MAX_KEYS]

FmgrInfo picksplitFn[INDEX_MAX_KEYS]

OffsetNumber * killedItems

GISTSearchHeapItem pageData[BLCKSZ/sizeof(IndexTupleData)]

IndexOrderByDistance * distances

MemoryContext pageDataCxt

IndexOrderByDistance distances[FLEXIBLE_ARRAY_MEMBER]

union GISTSearchItem::@45 data

GistOptBufferingMode buffering_mode

GIST_SPLITVEC splitVector

Datum spl_lattr[INDEX_MAX_KEYS]

bool spl_lisnull[INDEX_MAX_KEYS]

Datum spl_rattr[INDEX_MAX_KEYS]

bool spl_risnull[INDEX_MAX_KEYS]

struct SplitPageLayout * next

static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)