PostgreSQL Source Code: src/backend/access/gist/gistget.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

16

27

28

29

30

31

32

33

34

35

36

37static void

39{

45 int i;

46 bool killedsomething = false;

47

51

54 return;

55

59

60

61

62

63

64

66 {

68 so->numKilled = 0;

69 return;

70 }

71

73

74

75

76

77

79 {

83 killedsomething = true;

84 }

85

86 if (killedsomething)

87 {

90 }

91

93

94

95

96

97

99}

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124static bool

129 bool *recheck_p,

130 bool *recheck_distances_p)

131{

138

139 *recheck_p = false;

140 *recheck_distances_p = false;

141

142

143

144

145

146

148 {

149 int i;

150

152 elog(ERROR, "invalid GiST tuple found on leaf page");

154 {

157 }

158 return true;

159 }

160

161

162 while (keySize > 0)

163 {

165 bool isNull;

166

168 key->sk_attno,

169 giststate->leafTupdesc,

170 &isNull);

171

173 {

174

175

176

177

178

179

181 {

183 return false;

184 }

185 else

186 {

188 if (isNull)

189 return false;

190 }

191 }

192 else if (isNull)

193 {

194 return false;

195 }

196 else

197 {

199 bool recheck;

201

203 datum, r, page, offset,

204 false, isNull);

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219 recheck = true;

220

222 key->sk_collation,

224 key->sk_argument,

228

230 return false;

231 *recheck_p |= recheck;

232 }

233

235 keySize--;

236 }

237

238

242 while (keySize > 0)

243 {

245 bool isNull;

246

248 key->sk_attno,

249 giststate->leafTupdesc,

250 &isNull);

251

253 {

254

255 distance_p->value = 0.0;

256 distance_p->isnull = true;

257 }

258 else

259 {

261 bool recheck;

263

265 datum, r, page, offset,

266 false, isNull);

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284 recheck = false;

286 key->sk_collation,

288 key->sk_argument,

292 *recheck_distances_p |= recheck;

294 distance_p->isnull = false;

295 }

296

298 distance_p++;

299 keySize--;

300 }

301

302 return true;

303}

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327static void

330{

340

342

349

350

351

352

353

354

355

360 {

361

363

364

365 Assert(myDistances != NULL);

366

368

369

371 item->blkno = opaque->rightlink;

373

374

375 memcpy(item->distances, myDistances,

377

379

381 }

382

383

384

385

386

387

388

389

390

392 {

394 return;

395 }

396

398 scan->xs_hitup = NULL;

401

402

403

404

405

406

408

409

410

411

414 {

417 bool match;

418 bool recheck;

419 bool recheck_distances;

420

421

422

423

424

426 continue;

427

429

430

431

432

433

435

437 &recheck, &recheck_distances);

438

441

442

443 if (!match)

444 continue;

445

447 {

448

449

450

451

453 (*ntids)++;

454 }

456 {

457

458

459

463

464

465

466

467

469 {

474 }

476 }

477 else

478 {

479

480

481

482

483

486

488

489

491

493 {

494

499

500

501

502

505 }

506 else

507 {

508

510

511

512

513

514

515

517 }

518

519

521 sizeof(item->distances[0]) * nOrderBys);

522

524

526 }

527 }

528

530}

531

532

533

534

535

536

539{

541

543 {

545 }

546 else

547 {

548

549 item = NULL;

550 }

551

552

553 return item;

554}

555

556

557

558

559static bool

561{

563 bool res = false;

564

566 {

567

570 }

571

572 do

573 {

575

576 if (!item)

577 break;

578

580 {

581

584

588

589

592 res = true;

593 }

594 else

595 {

596

598

600 }

601

603 } while (!res);

604

605 return res;

606}

607

608

609

610

611bool

613{

615

617 elog(ERROR, "GiST only supports forward scan direction");

618

620 return false;

621

623 {

624

626

630

636

639 gistScanPage(scan, &fakeItem, NULL, NULL, NULL);

640 }

641

643 {

644

646 }

647 else

648 {

649

650 for (;;)

651 {

653 {

655 {

656

658 {

661

665

667 }

671 }

672

675

676

679

681

682 return true;

683 }

684

685

686

687

688

692 {

693

695 {

698

702

704 }

708 }

709

710 do

711 {

713

716

718

719 if (!item)

720 return false;

721

723

724

726

727

728

729

730

731

732

734

737 }

738 }

739}

740

741

742

743

746{

750

752 return 0;

753

757

758

763

765 memset(&fakeItem.data.parentlsn, 0, sizeof(GistNSN));

766 gistScanPage(scan, &fakeItem, NULL, tbm, &ntids);

767

768

769

770

771

772 for (;;)

773 {

775

776 if (!item)

777 break;

778

780

782

784 }

785

786 return ntids;

787}

788

789

790

791

792

793

794

795

796bool

798{

802 return true;

803 else

804 return false;

805}

#define InvalidBlockNumber

BlockNumber BufferGetBlockNumber(Buffer buffer)

XLogRecPtr BufferGetLSNAtomic(Buffer buffer)

void UnlockReleaseBuffer(Buffer buffer)

void LockBuffer(Buffer buffer, int mode)

void MarkBufferDirtyHint(Buffer buffer, bool buffer_std)

Buffer ReadBuffer(Relation reln, BlockNumber blockNum)

static Page BufferGetPage(Buffer buffer)

static bool BufferIsValid(Buffer bufnum)

static Item PageGetItem(const PageData *page, const ItemIdData *itemId)

static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)

static OffsetNumber PageGetMaxOffsetNumber(const PageData *page)

#define OidIsValid(objectId)

static float8 get_float8_infinity(void)

Datum FunctionCall5Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5)

#define GIST_COMPRESS_PROC

#define GistPageIsLeaf(page)

#define GistFollowRight(page)

#define GistPageIsDeleted(page)

#define GistPageGetOpaque(page)

#define GistMarkPageHasGarbage(page)

#define GistPageGetNSN(page)

GISTScanOpaqueData * GISTScanOpaque

#define SizeOfGISTSearchItem(n_distances)

#define GistTupleIsInvalid(itup)

#define GISTSearchItemIsHeap(item)

static bool getNextNearest(IndexScanDesc scan)

static GISTSearchItem * getNextGISTSearchItem(GISTScanOpaque so)

static bool gistindex_keytest(IndexScanDesc scan, IndexTuple tuple, Page page, OffsetNumber offset, bool *recheck_p, bool *recheck_distances_p)

bool gistgettuple(IndexScanDesc scan, ScanDirection dir)

int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)

bool gistcanreturn(Relation index, int attno)

static void gistScanPage(IndexScanDesc scan, GISTSearchItem *pageItem, IndexOrderByDistance *myDistances, TIDBitmap *tbm, int64 *ntids)

static void gistkillitems(IndexScanDesc scan)

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

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

void gistcheckpage(Relation rel, Buffer buf)

Assert(PointerIsAligned(start, uint64))

RegProcedure index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum)

void index_store_float8_orderby_distances(IndexScanDesc scan, Oid *orderByTypes, IndexOrderByDistance *distances, bool recheckOrderBy)

if(TABLE==NULL||TABLE_index==NULL)

#define ItemIdMarkDead(itemId)

#define ItemIdIsDead(itemId)

static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)

IndexTupleData * IndexTuple

static Datum index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)

#define MaxIndexTuplesPerPage

void MemoryContextReset(MemoryContext context)

void pfree(void *pointer)

#define CHECK_FOR_INTERRUPTS()

#define OffsetNumberNext(offsetNumber)

#define FirstOffsetNumber

void pairingheap_add(pairingheap *heap, pairingheap_node *node)

pairingheap_node * pairingheap_remove_first(pairingheap *heap)

#define pairingheap_is_empty(h)

static MemoryContext MemoryContextSwitchTo(MemoryContext context)

#define pgstat_count_index_scan(rel)

static bool DatumGetBool(Datum X)

static Datum PointerGetDatum(const void *X)

static Datum Int16GetDatum(int16 X)

static float8 DatumGetFloat8(Datum X)

static Datum ObjectIdGetDatum(Oid X)

void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)

#define IndexRelationGetNumberOfKeyAttributes(relation)

OffsetNumber * killedItems

GISTSearchHeapItem pageData[BLCKSZ/sizeof(IndexTupleData)]

IndexOrderByDistance * distances

MemoryContext pageDataCxt

IndexOrderByDistance distances[FLEXIBLE_ARRAY_MEMBER]

union GISTSearchItem::@45 data

struct ScanKeyData * keyData

struct ScanKeyData * orderByData

bool ignore_killed_tuples

struct IndexScanInstrumentation * instrument

ItemPointerData xs_heaptid

struct SnapshotData * xs_snapshot

void tbm_add_tuples(TIDBitmap *tbm, const ItemPointer tids, int ntids, bool recheck)

#define XLogRecPtrIsInvalid(r)