PostgreSQL Source Code: src/backend/executor/nodeAppend.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
59
67
68
70{
72 int pa_next_plan;
73
74
75
76
77
78
79
81};
82
83#define INVALID_SUBPLAN_INDEX -1
84#define EVENT_BUFFER_SIZE 16
85
96
97
98
99
100
101
102
103
104
105
106
107
110{
116 int nplans;
117 int nasyncplans;
118 int firstvalid;
119 int i,
120 j;
121
122
124
125
126
127
128 appendstate->ps.plan = (Plan *) node;
129 appendstate->ps.state = estate;
131
132
135 appendstate->as_begun = false;
136
137
139 {
141
142
143
144
145
146
151 &validsubplans);
154
155
156
157
158
159
161 {
164 }
165 }
166 else
167 {
169
170
171
172
173
179 }
180
183
184
185
186
187
188
189
190 j = 0;
191 asyncplans = NULL;
192 nasyncplans = 0;
193 firstvalid = nplans;
194 i = -1;
196 {
198
199
200
201
202
203
205 {
207 nasyncplans++;
208 }
209
210
211
212
214 firstvalid = j;
215
216 appendplanstates[j++] = ExecInitNode(initNode, estate, eflags);
217 }
218
220 appendstate->appendplans = appendplanstates;
222
223
224
225
226
227
228
229
230
231
233 if (appendops != NULL)
234 {
236 }
237 else
238 {
240
243 }
244
245
255
256 if (nasyncplans > 0)
257 {
260
261 i = -1;
263 {
265
268 areq->requestee = appendplanstates[i];
273
275 }
276
279
282 }
283
284
285
286
287
289
290
292
293 return appendstate;
294}
295
296
297
298
299
300
301
304{
307
308
309
310
311
313 {
316
317
320
321
324
325
326
327
328
331
335
336
338 }
339
340 for (;;)
341 {
343
345
346
347
348
350 {
352 return result;
355 }
356
357
358
359
362
363
364
365
367
369 {
370
371
372
373
374
375 return result;
376 }
377
378
379
380
381
382
385
386
389 }
390}
391
392
393
394
395
396
397
398
399
400void
402{
404 int nplans;
405 int i;
406
407
408
409
412
413
414
415
416 for (i = 0; i < nplans; i++)
418}
419
420void
422{
424 int i;
425
426
427
428
429
430
434 {
440 }
441
443 {
445
446
447
448
449
452
453
454
455
456
457 if (subnode->chgParam == NULL)
459 }
460
461
462 if (nasyncplans > 0)
463 {
464 i = -1;
466 {
468
472 }
473
478 }
479
480
484}
485
486
487
488
489
490
491
492
493
494
495
496
497
498void
501{
505
508}
509
510
511
512
513
514
515
516
517void
520{
522
527
530}
531
532
533
534
535
536
537
538void
540{
542
545}
546
547
548
549
550
551
552
553
554void
556{
559}
560
561
562
563
564
565
566
567
568static bool
570{
572 int nextplan;
573
574
576
577
579 return false;
580
581
582
583
584
585
586
587
589 {
591 {
592
594 }
596 {
600 }
601
602 whichplan = -1;
603 }
604
605
606 Assert(whichplan >= -1 && whichplan <= node->as_nplans);
607
610 else
612
613 if (nextplan < 0)
614 {
615
618 return false;
619 }
620
622
623 return true;
624}
625
626
627
628
629
630
631
632
633
634static bool
636{
638
639
641
642
644
646
648 {
649
651 }
652 else
653 {
654
656
657
658
659
660
661
663 {
667
668
669
670
671
673 }
674 }
675
676
678 {
680 {
684 return false;
685 }
686
687
688
689
690
692 }
693
694
697
699
700 return true;
701}
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716static bool
718{
720
721
723
724
726
728
729
732
733
734
735
736
737
739 {
743
745 }
746
747
749 {
751 return false;
752 }
753
754
756
757
759 {
760 int nextplan;
761
764 if (nextplan >= 0)
765 {
766
768 }
770 {
771
772
773
774
778 nextplan < 0 ? node->as_whichplan : nextplan;
779 }
780 else
781 {
782
783
784
785
787 }
788
790 {
791
794 return false;
795 }
796 }
797
798
802
803
804
805
806
808 {
811
812 if (nextplan >= 0)
814 else
815 {
816
817
818
819
820
822 }
823 }
824
825
828
830
831 return true;
832}
833
834
835
836
837
838
839
840
841
842static void
844{
845 int i;
846
847
849
850
852
853
855 return;
856
857
859 {
862 }
863}
864
865
866
867
868
869
870
871
872
873
874
875
876static void
878{
879 int i;
880
881
883
884
886
887
889
890
892 {
896
898 }
899
900
903
904
906 return;
907
908
909 i = -1;
911 {
913
916
917
919 }
920}
921
922
923
924
925
926
927
928static bool
930{
931 *result = NULL;
932
933
935
936
938 return true;
939
941 {
943
944
946
947
949 return true;
950
951
953 break;
954 }
955
956
957
958
959
960
962 {
965 return true;
966 }
967
968 return false;
969}
970
971
972
973
974
975
976
977static bool
979{
981 int i;
982
983
985 {
987 return false;
988 }
989
990
991
992
993
995 {
998 return true;
999 }
1000
1001
1004 i = -1;
1006 {
1008
1009
1011 }
1013
1014
1016 {
1019 return true;
1020 }
1021
1022 return false;
1023}
1024
1025
1026
1027
1028
1029
1030
1031static void
1033{
1035 long timeout = node->as_syncdone ? -1 : 0;
1037 int noccurred;
1038 int i;
1039
1040
1042
1046 NULL, NULL);
1047
1048
1049 i = -1;
1051 {
1053
1056 }
1057
1058
1059
1060
1061
1063 {
1066 return;
1067 }
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1083
1084
1087
1088
1089
1090
1091
1093 nevents, WAIT_EVENT_APPEND_READY);
1096 if (noccurred == 0)
1097 return;
1098
1099
1100 for (i = 0; i < noccurred; i++)
1101 {
1103
1104
1105
1106
1107
1109 {
1111
1113 {
1114
1115
1116
1117
1118
1120
1121
1123 }
1124 }
1125
1126
1128 {
1131 }
1132 }
1133}
1134
1135
1136
1137
1138
1139
1140
1141void
1143{
1146
1147
1149
1150
1152 {
1153
1155 return;
1156 }
1157
1158
1160 {
1161
1164 return;
1165 }
1166
1167
1170
1171
1172
1173
1174
1177}
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187static void
1189{
1191
1194
1195
1197 {
1200 return;
1201 }
1202
1203
1205 {
1207 return;
1208 }
1209
1210
1213
1214
1216 valid_asyncplans);
1217
1218
1220}
int bms_prev_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
int bms_next_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_del_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_add_range(Bitmapset *a, int lower, int upper)
void bms_free(Bitmapset *a)
int bms_num_members(const Bitmapset *a)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
#define FLEXIBLE_ARRAY_MEMBER
void ExecReScan(PlanState *node)
void ExecAsyncRequest(AsyncRequest *areq)
void ExecAsyncConfigureWait(AsyncRequest *areq)
void ExecAsyncNotify(AsyncRequest *areq)
PartitionPruneState * ExecInitPartitionExecPruning(PlanState *planstate, int n_total_subplans, int part_prune_index, Bitmapset *relids, Bitmapset **initially_valid_subplans)
Bitmapset * ExecFindMatchingSubPlans(PartitionPruneState *prunestate, bool initial_prune, Bitmapset **validsubplan_rtis)
void ExecEndNode(PlanState *node)
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
const TupleTableSlotOps TTSOpsVirtual
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
const TupleTableSlotOps * ExecGetCommonSlotOps(PlanState **planstates, int nplans)
void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
static TupleTableSlot * ExecProcNode(PlanState *node)
Assert(PointerIsAligned(start, uint64))
if(TABLE==NULL||TABLE_index==NULL)
void ResetLatch(Latch *latch)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void LWLockInitialize(LWLock *lock, int tranche_id)
@ LWTRANCHE_PARALLEL_APPEND
void * palloc0(Size size)
#define CHECK_FOR_INTERRUPTS()
void ExecEndAppend(AppendState *node)
static void ExecAppendAsyncBegin(AppendState *node)
static void ExecAppendAsyncEventWait(AppendState *node)
void ExecReScanAppend(AppendState *node)
static void classify_matching_subplans(AppendState *node)
static void mark_invalid_subplans_as_finished(AppendState *node)
static TupleTableSlot * ExecAppend(PlanState *pstate)
static bool ExecAppendAsyncRequest(AppendState *node, TupleTableSlot **result)
static bool choose_next_subplan_for_leader(AppendState *node)
static bool choose_next_subplan_for_worker(AppendState *node)
void ExecAppendReInitializeDSM(AppendState *node, ParallelContext *pcxt)
#define INVALID_SUBPLAN_INDEX
void ExecAsyncAppendResponse(AsyncRequest *areq)
#define EVENT_BUFFER_SIZE
AppendState * ExecInitAppend(Append *node, EState *estate, int eflags)
static bool choose_next_subplan_locally(AppendState *node)
void ExecAppendInitializeWorker(AppendState *node, ParallelWorkerContext *pwcxt)
void ExecAppendInitializeDSM(AppendState *node, ParallelContext *pcxt)
void ExecAppendEstimate(AppendState *node, ParallelContext *pcxt)
static bool ExecAppendAsyncGetNext(AppendState *node, TupleTableSlot **result)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
static int list_length(const List *l)
static void * list_nth(const List *list, int n)
ResourceOwner CurrentResourceOwner
#define ScanDirectionIsForward(direction)
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)
Size add_size(Size s1, Size s2)
struct PartitionPruneState * as_prune_state
Bitmapset * as_valid_asyncplans
Bitmapset * as_needrequest
AsyncRequest ** as_asyncrequests
Bitmapset * as_asyncplans
struct WaitEventSet * as_eventset
bool(* choose_next_subplan)(AppendState *)
int as_first_partial_plan
ParallelAppendState * as_pstate
Bitmapset * as_valid_subplans
TupleTableSlot ** as_asyncresults
bool as_valid_subplans_identified
struct PlanState * requestor
struct PlanState * requestee
ScanDirection es_direction
struct EPQState * es_epq_active
bool pa_finished[FLEXIBLE_ARRAY_MEMBER]
shm_toc_estimator estimator
TupleTableSlot * ps_ResultTupleSlot
ProjectionInfo * ps_ProjInfo
ExecProcNodeMtd ExecProcNode
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
int GetNumRegisteredWaitEvents(WaitEventSet *set)
int AddWaitEventToSet(WaitEventSet *set, uint32 events, pgsocket fd, Latch *latch, void *user_data)
int WaitEventSetWait(WaitEventSet *set, long timeout, WaitEvent *occurred_events, int nevents, uint32 wait_event_info)
void FreeWaitEventSet(WaitEventSet *set)
WaitEventSet * CreateWaitEventSet(ResourceOwner resowner, int nevents)
#define WL_SOCKET_READABLE
#define WL_EXIT_ON_PM_DEATH