@@ -80,6 +80,10 @@ class FilterIterator final : public RowIterator {
80
80
m_source->SetNullRowFlag (is_null_row);
81
81
}
82
82
83
+ void StartPSIBatchMode () override { m_source->StartPSIBatchMode (); }
84
+ void EndPSIBatchModeIfStarted () override {
85
+ m_source->EndPSIBatchModeIfStarted ();
86
+ }
83
87
void UnlockRow () override { m_source->UnlockRow (); }
84
88
85
89
std::vector<Child> children () const override ;
@@ -133,6 +137,10 @@ class LimitOffsetIterator final : public RowIterator {
133
137
m_source->SetNullRowFlag (is_null_row);
134
138
}
135
139
140
+ void StartPSIBatchMode () override { m_source->StartPSIBatchMode (); }
141
+ void EndPSIBatchModeIfStarted () override {
142
+ m_source->EndPSIBatchModeIfStarted ();
143
+ }
136
144
void UnlockRow () override { m_source->UnlockRow (); }
137
145
138
146
std::vector<Child> children () const override {
@@ -217,7 +225,17 @@ class AggregateIterator final : public RowIterator {
217
225
void SetNullRowFlag (bool is_null_row) override {
218
226
m_source->SetNullRowFlag (is_null_row);
219
227
}
220
- void UnlockRow () override ;
228
+
229
+ void StartPSIBatchMode () override { m_source->StartPSIBatchMode (); }
230
+ void EndPSIBatchModeIfStarted () override {
231
+ m_source->EndPSIBatchModeIfStarted ();
232
+ }
233
+ void UnlockRow () override {
234
+ // Most likely, HAVING failed. Ideally, we'd like to backtrack and
235
+ // unlock all rows that went into this aggregate, but we can't do that,
236
+ // and we also can't unlock the _current_ row, since that belongs to a
237
+ // different group. Thus, do nothing.
238
+ }
221
239
222
240
std::vector<Child> children () const override {
223
241
return std::vector<Child>{{m_source.get (), " " }};
@@ -351,7 +369,14 @@ class PrecomputedAggregateIterator final : public RowIterator {
351
369
void SetNullRowFlag (bool is_null_row) override {
352
370
m_source->SetNullRowFlag (is_null_row);
353
371
}
354
- void UnlockRow () override ;
372
+
373
+ void StartPSIBatchMode () override { m_source->StartPSIBatchMode (); }
374
+ void EndPSIBatchModeIfStarted () override {
375
+ m_source->EndPSIBatchModeIfStarted ();
376
+ }
377
+ void UnlockRow () override {
378
+ // See AggregateIterator::UnlockRow().
379
+ }
355
380
356
381
std::vector<Child> children () const override {
357
382
return std::vector<Child>{{m_source.get (), " " }};
@@ -424,6 +449,11 @@ class NestedLoopIterator final : public RowIterator {
424
449
m_source_inner->SetNullRowFlag (is_null_row);
425
450
}
426
451
452
+ void EndPSIBatchModeIfStarted () override {
453
+ m_source_outer->EndPSIBatchModeIfStarted ();
454
+ m_source_inner->EndPSIBatchModeIfStarted ();
455
+ }
456
+
427
457
void UnlockRow () override {
428
458
// Since we don't know which condition that caused the row to be rejected,
429
459
// we can't know whether we could also unlock the outer row
@@ -666,6 +696,9 @@ class MaterializeIterator final : public TableRowIterator {
666
696
m_table_iterator->SetNullRowFlag (is_null_row);
667
697
}
668
698
699
+ void StartPSIBatchMode () override { m_table_iterator->StartPSIBatchMode (); }
700
+ void EndPSIBatchModeIfStarted () override ;
701
+
669
702
// The temporary table is private to us, so there's no need to worry about
670
703
// locks to other transactions.
671
704
void UnlockRow () override {}
@@ -772,6 +805,12 @@ class StreamingIterator final : public TableRowIterator {
772
805
return std::vector<Child>{{m_subquery_iterator.get (), " " }};
773
806
}
774
807
808
+ void StartPSIBatchMode () override {
809
+ m_subquery_iterator->StartPSIBatchMode ();
810
+ }
811
+ void EndPSIBatchModeIfStarted () override {
812
+ m_subquery_iterator->EndPSIBatchModeIfStarted ();
813
+ }
775
814
void UnlockRow () override { m_subquery_iterator->UnlockRow (); }
776
815
777
816
private:
@@ -799,6 +838,10 @@ class TemptableAggregateIterator final : public TableRowIterator {
799
838
void SetNullRowFlag (bool is_null_row) override {
800
839
m_table_iterator->SetNullRowFlag (is_null_row);
801
840
}
841
+ void EndPSIBatchModeIfStarted () override {
842
+ m_table_iterator->EndPSIBatchModeIfStarted ();
843
+ m_subquery_iterator->EndPSIBatchModeIfStarted ();
844
+ }
802
845
void UnlockRow () override {}
803
846
std::vector<std::string> DebugString () const override ;
804
847
@@ -845,6 +888,11 @@ class MaterializedTableFunctionIterator final : public TableRowIterator {
845
888
m_table_iterator->SetNullRowFlag (is_null_row);
846
889
}
847
890
891
+ void StartPSIBatchMode () override { m_table_iterator->StartPSIBatchMode (); }
892
+ void EndPSIBatchModeIfStarted () override {
893
+ m_table_iterator->EndPSIBatchModeIfStarted ();
894
+ }
895
+
848
896
// The temporary table is private to us, so there's no need to worry about
849
897
// locks to other transactions.
850
898
void UnlockRow () override {}
@@ -891,6 +939,9 @@ class WeedoutIterator final : public RowIterator {
891
939
m_source->SetNullRowFlag (is_null_row);
892
940
}
893
941
942
+ void EndPSIBatchModeIfStarted () override {
943
+ m_source->EndPSIBatchModeIfStarted ();
944
+ }
894
945
void UnlockRow () override { m_source->UnlockRow (); }
895
946
896
947
private:
@@ -925,6 +976,10 @@ class RemoveDuplicatesIterator final : public RowIterator {
925
976
m_source->SetNullRowFlag (is_null_row);
926
977
}
927
978
979
+ void StartPSIBatchMode () override { m_source->StartPSIBatchMode (); }
980
+ void EndPSIBatchModeIfStarted () override {
981
+ m_source->EndPSIBatchModeIfStarted ();
982
+ }
928
983
void UnlockRow () override { m_source->UnlockRow (); }
929
984
930
985
private:
@@ -983,6 +1038,11 @@ class NestedLoopSemiJoinWithDuplicateRemovalIterator final
983
1038
m_source_inner->SetNullRowFlag (is_null_row);
984
1039
}
985
1040
1041
+ void EndPSIBatchModeIfStarted () override {
1042
+ m_source_outer->EndPSIBatchModeIfStarted ();
1043
+ m_source_inner->EndPSIBatchModeIfStarted ();
1044
+ }
1045
+
986
1046
void UnlockRow () override {
987
1047
m_source_outer->UnlockRow ();
988
1048
m_source_inner->UnlockRow ();
@@ -1030,6 +1090,11 @@ class WindowingIterator final : public RowIterator {
1030
1090
m_source->SetNullRowFlag (is_null_row);
1031
1091
}
1032
1092
1093
+ void StartPSIBatchMode () override { m_source->StartPSIBatchMode (); }
1094
+ void EndPSIBatchModeIfStarted () override {
1095
+ m_source->EndPSIBatchModeIfStarted ();
1096
+ }
1097
+
1033
1098
void UnlockRow () override {
1034
1099
// There's nothing we can do here.
1035
1100
}
@@ -1079,6 +1144,11 @@ class BufferingWindowingIterator final : public RowIterator {
1079
1144
m_source->SetNullRowFlag (is_null_row);
1080
1145
}
1081
1146
1147
+ void StartPSIBatchMode () override { m_source->StartPSIBatchMode (); }
1148
+ void EndPSIBatchModeIfStarted () override {
1149
+ m_source->EndPSIBatchModeIfStarted ();
1150
+ }
1151
+
1082
1152
void UnlockRow () override {
1083
1153
// There's nothing we can do here.
1084
1154
}
@@ -1148,6 +1218,11 @@ class MaterializeInformationSchemaTableIterator final : public RowIterator {
1148
1218
m_table_iterator->SetNullRowFlag (is_null_row);
1149
1219
}
1150
1220
1221
+ void StartPSIBatchMode () override { m_table_iterator->StartPSIBatchMode (); }
1222
+ void EndPSIBatchModeIfStarted () override {
1223
+ m_table_iterator->EndPSIBatchModeIfStarted ();
1224
+ }
1225
+
1151
1226
// The temporary table is private to us, so there's no need to worry about
1152
1227
// locks to other transactions.
1153
1228
void UnlockRow () override {}
@@ -1175,12 +1250,16 @@ class AppendIterator final : public RowIterator {
1175
1250
std::vector<std::string> DebugString () const override { return {" Append" }; }
1176
1251
std::vector<Child> children () const override ;
1177
1252
1253
+ void StartPSIBatchMode () override ;
1254
+ void EndPSIBatchModeIfStarted () override ;
1255
+
1178
1256
void SetNullRowFlag (bool is_null_row) override ;
1179
1257
void UnlockRow () override ;
1180
1258
1181
1259
private:
1182
1260
std::vector<unique_ptr_destroy_only<RowIterator>> m_sub_iterators;
1183
1261
size_t m_current_iterator_index = 0 ;
1262
+ bool m_pfs_batch_mode_enabled = false ;
1184
1263
};
1185
1264
1186
1265
#endif // SQL_COMPOSITE_ITERATORS_INCLUDED
0 commit comments