Skip to content

Commit 3894c87

Browse files
author
James Cor
committed
move finalize to rowexec
1 parent 6ce11ad commit 3894c87

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

engine.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ func (e *Engine) QueryWithBindings(ctx *sql.Context, query string, parsed sqlpar
447447
}
448448

449449
var schema sql.Schema
450-
iter, schema = finalizeIters(ctx, analyzed, qFlags, iter)
450+
iter, schema = rowexec.FinalizeIters(ctx, analyzed, qFlags, iter)
451451
if err != nil {
452452
clearAutocommitErr := clearAutocommitTransaction(ctx)
453453
if clearAutocommitErr != nil {
@@ -493,7 +493,7 @@ func (e *Engine) PrepQueryPlanForExecution(ctx *sql.Context, _ string, plan sql.
493493
}
494494

495495
var schema sql.Schema
496-
iter, schema = finalizeIters(ctx, plan, qFlags, iter)
496+
iter, schema = rowexec.FinalizeIters(ctx, plan, qFlags, iter)
497497
if err != nil {
498498
clearAutocommitErr := clearAutocommitTransaction(ctx)
499499
if clearAutocommitErr != nil {
@@ -852,7 +852,7 @@ func (e *Engine) executeEvent(ctx *sql.Context, dbName, createEventStatement, us
852852
return err
853853
}
854854

855-
iter, _ = finalizeIters(ctx, definitionNode, nil, iter)
855+
iter, _ = rowexec.FinalizeIters(ctx, definitionNode, nil, iter)
856856

857857
// Drain the iterate to execute the event body/definition
858858
// NOTE: No row data is returned for an event; we just need to execute the statements
@@ -885,14 +885,3 @@ func findCreateEventNode(planTree sql.Node) (*plan.CreateEvent, error) {
885885

886886
return createEventNode, nil
887887
}
888-
889-
// finalizeIters applies the final transformations on sql.RowIter before execution.
890-
func finalizeIters(ctx *sql.Context, analyzed sql.Node, qFlags *sql.QueryFlags, iter sql.RowIter) (sql.RowIter, sql.Schema) {
891-
var sch sql.Schema
892-
iter, sch = rowexec.AddAccumulatorIter(ctx, iter)
893-
iter = rowexec.AddTriggerRollbackIter(ctx, qFlags, iter)
894-
iter = rowexec.AddTransactionCommittingIter(qFlags, iter)
895-
iter = plan.AddTrackedRowIter(ctx, analyzed, iter)
896-
iter = rowexec.AddExpressionCloser(analyzed, iter)
897-
return iter, sch
898-
}

engine_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func TestTrackProcess(t *testing.T) {
232232

233233
iter, err := rowexec.DefaultBuilder.Build(ctx, result, nil)
234234
require.NoError(err)
235-
iter, _ = finalizeIters(ctx, result, nil, iter)
235+
iter, _ = rowexec.FinalizeIters(ctx, result, nil, iter)
236236
require.NoError(err)
237237
_, err = sql.RowIterToRows(ctx, iter)
238238
require.NoError(err)

sql/rowexec/builder.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
package rowexec
1616

1717
import (
18-
"runtime/trace"
18+
"github.com/dolthub/go-mysql-server/sql/plan"
19+
"runtime/trace"
1920

2021
"github.com/dolthub/go-mysql-server/sql"
2122
)
@@ -42,3 +43,14 @@ func (b *BaseBuilder) Build(ctx *sql.Context, n sql.Node, r sql.Row) (sql.RowIte
4243
func NewOverrideBuilder(override sql.NodeExecBuilder) sql.NodeExecBuilder {
4344
return &BaseBuilder{override: override}
4445
}
46+
47+
// FinalizeIters applies the final transformations on sql.RowIter before execution.
48+
func FinalizeIters(ctx *sql.Context, analyzed sql.Node, qFlags *sql.QueryFlags, iter sql.RowIter) (sql.RowIter, sql.Schema) {
49+
var sch sql.Schema
50+
iter, sch = AddAccumulatorIter(ctx, iter)
51+
iter = AddTriggerRollbackIter(ctx, qFlags, iter)
52+
iter = AddTransactionCommittingIter(qFlags, iter)
53+
iter = plan.AddTrackedRowIter(ctx, analyzed, iter)
54+
iter = AddExpressionCloser(analyzed, iter)
55+
return iter, sch
56+
}

0 commit comments

Comments
 (0)