Skip to content

Commit 1cef4d6

Browse files
author
James Cor
committed
custom iterator
1 parent fa99f5b commit 1cef4d6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

sql/rowexec/dml_iters.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,10 @@ func getRowHandler(clientFoundRowsToggled bool, iter sql.RowIter) accumulatorRow
565565

566566
func AddAccumulatorIter(ctx *sql.Context, iter sql.RowIter) (sql.RowIter, sql.Schema) {
567567
switch i := iter.(type) {
568+
case sql.CustomRowIter:
569+
childIter := i.GetChildIter()
570+
childIter, sch := AddAccumulatorIter(ctx, childIter)
571+
return i.SetChildIter(childIter), sch
568572
case *callIter:
569573
childIter, sch := AddAccumulatorIter(ctx, i.innerIter)
570574
i.innerIter = childIter

sql/rows.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,11 @@ func (i *sliceRowIter) Close(*Context) error {
201201
i.rows = nil
202202
return nil
203203
}
204+
205+
// CustomRowIter is an extension of RowIter for integrators that wrap RowIters.
206+
// It allows for analysis rules to inspect the underlying RowIters.
207+
type CustomRowIter interface {
208+
RowIter
209+
GetChildIter() RowIter
210+
SetChildIter(childIter RowIter) RowIter
211+
}

0 commit comments

Comments
 (0)