PostgreSQL Source Code: src/backend/executor/nodeIndexonlyscan.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
32
47
48
52
53
54
55
56
57
58
59
62{
69
70
71
72
74
75
76
77
78
84
85 if (scandesc == NULL)
86 {
87
88
89
90
91
98
100
101
102
105
106
107
108
109
116 }
117
118
119
120
122 {
123 bool tuple_from_heap = false;
124
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
164 {
165
166
167
170 continue;
171
173
174
175
176
177
178
179
181 elog(ERROR, "non-MVCC snapshots are not supported in index-only scans");
182
183
184
185
186
187
188
189
190 tuple_from_heap = true;
191 }
192
193
194
195
196
197
198
200 {
201
202
203
204
205
209 }
210 else if (scandesc->xs_itup)
212 else
213 elog(ERROR, "no data returned for index-only scan");
214
215
216
217
219 {
222 {
223
225 continue;
226 }
227 }
228
229
230
231
232
233
234
235
236
239 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
240 errmsg("lossy distance functions are not supported in index-only scans")));
241
242
243
244
245
246 if (!tuple_from_heap)
250
251 return slot;
252 }
253
254
255
256
257
259}
260
261
262
263
264
265
266
267
268static void
271{
272
273
274
275
276
277
278
280
283
284
285
286
287
288
289
290
292 {
294
295 for (int idx = 0; idx < attcount; idx++)
296 {
299
300
302 continue;
303
304
307
308
311 }
312 }
313
315}
316
317
318
319
320
321
322
323
324
325static bool
327{
328 elog(ERROR, "EvalPlanQual recheck is not supported in index-only scans");
329 return false;
330}
331
332
333
334
335
338{
340
341
342
343
346
350}
351
352
353
354
355
356
357
358
359
360
361
362
363void
365{
366
367
368
369
370
371
372
374 {
376
381 }
383
384
389
391}
392
393
394
395
396
397
398void
400{
403
404
405
406
409
410
412 {
415 }
416
417
418
419
420
421
423 {
425
426 Assert(ParallelWorkerNumber <= node->ioss_SharedInfo->num_workers);
428
429
430
431
432
433
434
436 }
437
438
439
440
441 if (indexScanDesc)
443 if (indexRelationDesc)
445}
446
447
448
449
450
451
452
453
454void
456{
459
460 if (epqstate != NULL)
461 {
462
463
464
465
466
467
468
469
470
472
473 Assert(scanrelid > 0);
474 if (epqstate->relsubs_slot[scanrelid - 1] != NULL ||
476 {
477
479 elog(ERROR, "unexpected ExecIndexOnlyMarkPos call in EPQ recheck");
480 return;
481 }
482 }
483
485}
486
487
488
489
490
491void
493{
496
498 {
499
501
502 Assert(scanrelid > 0);
503 if (epqstate->relsubs_slot[scanrelid - 1] != NULL ||
505 {
506
508 elog(ERROR, "unexpected ExecIndexOnlyRestrPos call in EPQ recheck");
509 return;
510 }
511 }
512
514}
515
516
517
518
519
520
521
522
523
524
525
526
529{
535 int indnkeyatts;
536 int namecount;
537
538
539
540
543 indexstate->ss.ps.state = estate;
545
546
547
548
549
550
552
553
554
555
557
560
561
562
563
564
565
566
567
571
572
573
574
575
580
581
582
583
584
587
588
589
590
591
592
593
598
599
600
601
602
603
605 return indexstate;
606
607
611
612
613
614
618
619
620
621
623 indexRelation,
625 false,
630 NULL,
631 NULL);
632
633
634
635
637 indexRelation,
639 true,
644 NULL,
645 NULL);
646
647
648
649
650
651
652
654 {
656
660 }
661 else
662 {
664 }
665
667 indnkeyatts = indexRelation->rd_index->indnkeyatts;
668 namecount = 0;
669
670
671
672
673
674
675
676
677
678
679
680
682 {
685 namecount++;
686 }
687
688 if (namecount > 0)
689 {
690 int idx = 0;
691
692
693
694
695
698
700 {
704 }
705 }
706
708
709
710
711
712 return indexstate;
713}
714
715
716
717
718
719
720
721
722
723
724
725
726
727void
730{
734
735 if (!instrument && !parallel_aware)
736 {
737
738 return;
739 }
740
745 instrument, parallel_aware,
749}
750
751
752
753
754
755
756
757void
760{
765
766 if (!instrument && !parallel_aware)
767 {
768
769 return;
770 }
771
776 instrument, parallel_aware, pcxt->nworkers,
779
780 if (!parallel_aware)
781 {
782
783 return;
784 }
785
792 piscan);
795
796
797
798
799
804}
805
806
807
808
809
810
811
812void
815{
818}
819
820
821
822
823
824
825
826void
829{
833
834 if (!instrument && !parallel_aware)
835 {
836
837 return;
838 }
839
841
842 if (instrument)
845
846 if (!parallel_aware)
847 {
848
849 return;
850 }
851
858 piscan);
860
861
862
863
864
869}
870
871
872
873
874
875
876
877void
879{
881 size_t size;
882
883 if (SharedInfo == NULL)
884 return;
885
886
891}
Datum idx(PG_FUNCTION_ARGS)
void ReleaseBuffer(Buffer buffer)
#define OffsetToPointer(base, offset)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void ExecReScan(PlanState *node)
ExprState * ExecInitQual(List *qual, PlanState *parent)
void ExecAssignScanProjectionInfoWithVarno(ScanState *node, int varno)
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
void ExecScanReScan(ScanState *node)
const TupleTableSlotOps TTSOpsVirtual
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
TupleTableSlot * ExecAllocTableSlot(List **tupleTable, TupleDesc desc, const TupleTableSlotOps *tts_ops)
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
void ExecInitResultTypeTL(PlanState *planstate)
TupleDesc ExecTypeFromTL(List *targetList)
void ExecForceStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
#define InstrCountTuples2(node, delta)
#define InstrCountFiltered2(node, delta)
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
#define ResetExprContext(econtext)
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
static bool ExecQualAndReset(ExprState *state, ExprContext *econtext)
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
#define EXEC_FLAG_EXPLAIN_ONLY
struct IndexScanInstrumentation IndexScanInstrumentation
Assert(PointerIsAligned(start, uint64))
#define IsParallelWorker()
void index_parallelscan_initialize(Relation heapRelation, Relation indexRelation, Snapshot snapshot, bool instrument, bool parallel_aware, int nworkers, SharedIndexScanInstrumentation **sharedinfo, ParallelIndexScanDesc target)
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, IndexScanInstrumentation *instrument, int nkeys, int norderbys, ParallelIndexScanDesc pscan)
void index_restrpos(IndexScanDesc scan)
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, IndexScanInstrumentation *instrument, int nkeys, int norderbys)
void index_close(Relation relation, LOCKMODE lockmode)
ItemPointer index_getnext_tid(IndexScanDesc scan, ScanDirection direction)
bool index_fetch_heap(IndexScanDesc scan, TupleTableSlot *slot)
void index_markpos(IndexScanDesc scan)
void index_endscan(IndexScanDesc scan)
Size index_parallelscan_estimate(Relation indexRelation, int nkeys, int norderbys, Snapshot snapshot, bool instrument, bool parallel_aware, int nworkers)
Relation index_open(Oid relationId, LOCKMODE lockmode)
void index_parallelrescan(IndexScanDesc scan)
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
void index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor, Datum *values, bool *isnull)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
void * MemoryContextAlloc(MemoryContext context, Size size)
#define CHECK_FOR_INTERRUPTS()
void namestrcpy(Name name, const char *str)
void ExecEndIndexOnlyScan(IndexOnlyScanState *node)
static TupleTableSlot * IndexOnlyNext(IndexOnlyScanState *node)
static void StoreIndexTuple(IndexOnlyScanState *node, TupleTableSlot *slot, IndexTuple itup, TupleDesc itupdesc)
void ExecIndexOnlyScanEstimate(IndexOnlyScanState *node, ParallelContext *pcxt)
void ExecReScanIndexOnlyScan(IndexOnlyScanState *node)
void ExecIndexOnlyScanRetrieveInstrumentation(IndexOnlyScanState *node)
void ExecIndexOnlyRestrPos(IndexOnlyScanState *node)
void ExecIndexOnlyScanInitializeWorker(IndexOnlyScanState *node, ParallelWorkerContext *pwcxt)
static TupleTableSlot * ExecIndexOnlyScan(PlanState *pstate)
static bool IndexOnlyRecheck(IndexOnlyScanState *node, TupleTableSlot *slot)
IndexOnlyScanState * ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
void ExecIndexOnlyMarkPos(IndexOnlyScanState *node)
void ExecIndexOnlyScanReInitializeDSM(IndexOnlyScanState *node, ParallelContext *pcxt)
void ExecIndexOnlyScanInitializeDSM(IndexOnlyScanState *node, ParallelContext *pcxt)
void ExecIndexBuildScanKeys(PlanState *planstate, Relation index, List *quals, bool isorderby, ScanKey *scanKeys, int *numScanKeys, IndexRuntimeKeyInfo **runtimeKeys, int *numRuntimeKeys, IndexArrayKeyInfo **arrayKeys, int *numArrayKeys)
void ExecIndexEvalRuntimeKeys(ExprContext *econtext, IndexRuntimeKeyInfo *runtimeKeys, int numRuntimeKeys)
#define castNode(_type_, nodeptr)
static char * DatumGetCString(Datum X)
static Datum NameGetDatum(const NameData *X)
void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
#define RelationGetDescr(relation)
#define ScanDirectionCombine(a, b)
void * shm_toc_allocate(shm_toc *toc, Size nbytes)
void shm_toc_insert(shm_toc *toc, uint64 key, void *address)
void * shm_toc_lookup(shm_toc *toc, uint64 key, bool noError)
#define shm_toc_estimate_chunk(e, sz)
#define shm_toc_estimate_keys(e, cnt)
ExecAuxRowMark ** relsubs_rowmark
TupleTableSlot ** relsubs_slot
ScanDirection es_direction
struct EPQState * es_epq_active
MemoryContext ecxt_per_tuple_memory
TupleTableSlot * ecxt_scantuple
SharedIndexScanInstrumentation * ioss_SharedInfo
TupleTableSlot * ioss_TableSlot
bool ioss_RuntimeKeysReady
int ioss_NameCStringCount
struct ScanKeyData * ioss_ScanKeys
struct ScanKeyData * ioss_OrderByKeys
struct IndexScanDescData * ioss_ScanDesc
ExprContext * ioss_RuntimeContext
AttrNumber * ioss_NameCStringAttNums
Relation ioss_RelationDesc
IndexScanInstrumentation ioss_Instrument
IndexRuntimeKeyInfo * ioss_RuntimeKeys
struct TupleDescData * xs_hitupdesc
struct TupleDescData * xs_itupdesc
shm_toc_estimator estimator
Instrumentation * instrument
ExprContext * ps_ExprContext
ExecProcNodeMtd ExecProcNode
Relation ss_currentRelation
TupleTableSlot * ss_ScanTupleSlot
struct TableScanDescData * ss_currentScanDesc
TupleDesc tts_tupleDescriptor
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
#define VM_ALL_VISIBLE(r, b, v)