Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d4e3615
progress
Oct 24, 2024
3e5cfc3
Merge branch 'main' into james/update
Oct 25, 2024
bd4b1a1
[ga-format-pr] Run ./format_repo.sh to fix formatting
jycor Oct 25, 2024
973bb30
format
Oct 25, 2024
f5b3d05
removing now unused code
Oct 25, 2024
1ba8eb3
regen plans
Oct 25, 2024
9814e26
[ga-format-pr] Run ./format_repo.sh to fix formatting
jycor Oct 25, 2024
473f514
triggers
Oct 28, 2024
b9d200a
qFlags
Oct 28, 2024
b637a3f
Merge branch 'main' into james/update
Oct 28, 2024
391ad72
merge
Oct 28, 2024
355ce12
merge
Oct 28, 2024
62633c3
progress
Oct 28, 2024
34e3d7e
[ga-format-pr] Run ./format_repo.sh to fix formatting
jycor Oct 28, 2024
b124b42
Merge branch 'main' into james/update
Oct 29, 2024
3cefd2c
more progress
Oct 29, 2024
bdc846f
[ga-format-pr] Run ./format_repo.sh to fix formatting
jycor Oct 30, 2024
4329119
moved rowupdateaccumulator
Oct 30, 2024
12b09ce
remove rowupdateaccumulator node
Oct 30, 2024
8e74d39
formatting
Oct 30, 2024
0f6e539
[ga-format-pr] Run ./format_repo.sh to fix formatting
jycor Oct 30, 2024
506cb90
tidying up
Oct 30, 2024
dbc9769
formatting
Oct 30, 2024
352c368
fix server engine test
Oct 31, 2024
0f14692
fix
Oct 31, 2024
c505db7
more fixes
Oct 31, 2024
8103742
Merge branch 'main' into james/update
Oct 31, 2024
6ce11ad
remove error
Oct 31, 2024
3894c87
move finalize to rowexec
Oct 31, 2024
fa99f5b
[ga-format-pr] Run ./format_repo.sh to fix formatting
jycor Oct 31, 2024
1cef4d6
custom iterator
Nov 1, 2024
0c5a323
mutable
Nov 1, 2024
0365f1d
tidying up
Nov 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,24 @@ func (e *Engine) QueryWithBindings(ctx *sql.Context, query string, parsed sqlpar
if err2 != nil {
return nil, nil, nil, errors.Wrap(err, "unable to clear autocommit transaction: "+err2.Error())
}
return nil, nil, nil, err
}

var schema sql.Schema
iter, schema = rowexec.FinalizeIters(ctx, analyzed, qFlags, iter)
if err != nil {
clearAutocommitErr := clearAutocommitTransaction(ctx)
if clearAutocommitErr != nil {
return nil, nil, nil, errors.Wrap(err, "unable to clear autocommit transaction: "+clearAutocommitErr.Error())
}
return nil, nil, nil, err
}

iter = finalizeIters(ctx, analyzed, qFlags, iter)
if schema == nil {
schema = analyzed.Schema()
}

return analyzed.Schema(), iter, qFlags, nil
return schema, iter, qFlags, nil
}

// PrepQueryPlanForExecution prepares a query plan for execution and returns the result schema with a row iterator to
Expand Down Expand Up @@ -478,13 +489,24 @@ func (e *Engine) PrepQueryPlanForExecution(ctx *sql.Context, _ string, plan sql.
if err2 != nil {
return nil, nil, nil, errors.Wrap(err, "unable to clear autocommit transaction: "+err2.Error())
}
return nil, nil, nil, err
}

var schema sql.Schema
iter, schema = rowexec.FinalizeIters(ctx, plan, qFlags, iter)
if err != nil {
clearAutocommitErr := clearAutocommitTransaction(ctx)
if clearAutocommitErr != nil {
return nil, nil, nil, errors.Wrap(err, "unable to clear autocommit transaction: "+clearAutocommitErr.Error())
}
return nil, nil, nil, err
}

iter = finalizeIters(ctx, plan, qFlags, iter)
if schema == nil {
schema = plan.Schema()
}

return plan.Schema(), iter, qFlags, nil
return schema, iter, qFlags, nil
}

// BoundQueryPlan returns query plan for the given statement with the given bindings applied
Expand Down Expand Up @@ -830,7 +852,7 @@ func (e *Engine) executeEvent(ctx *sql.Context, dbName, createEventStatement, us
return err
}

iter = finalizeIters(ctx, definitionNode, nil, iter)
iter, _ = rowexec.FinalizeIters(ctx, definitionNode, nil, iter)

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

return createEventNode, nil
}

// finalizeIters applies the final transformations on sql.RowIter before execution.
func finalizeIters(ctx *sql.Context, analyzed sql.Node, qFlags *sql.QueryFlags, iter sql.RowIter) sql.RowIter {
iter = rowexec.AddTriggerRollbackIter(ctx, qFlags, iter)
iter = rowexec.AddTransactionCommittingIter(qFlags, iter)
iter = plan.AddTrackedRowIter(ctx, analyzed, iter)
iter = rowexec.AddExpressionCloser(analyzed, iter)
return iter
}
3 changes: 2 additions & 1 deletion engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ func TestTrackProcess(t *testing.T) {
require.True(ok)

iter, err := rowexec.DefaultBuilder.Build(ctx, result, nil)
iter = finalizeIters(ctx, result, nil, iter)
require.NoError(err)
iter, _ = rowexec.FinalizeIters(ctx, result, nil, iter)
require.NoError(err)
_, err = sql.RowIterToRows(ctx, iter)
require.NoError(err)
Expand Down
4 changes: 2 additions & 2 deletions enginetest/enginetests.go
Original file line number Diff line number Diff line change
Expand Up @@ -1710,12 +1710,12 @@ func TestInsertScriptsPrepared(t *testing.T, harness Harness) {
func TestGeneratedColumns(t *testing.T, harness Harness) {
harness.Setup(setup.MydbData)
for _, script := range queries.GeneratedColumnTests {
TestScriptPrepared(t, harness, script)
TestScript(t, harness, script)
}
for _, script := range queries.BrokenGeneratedColumnTests {
t.Run(script.Name, func(t *testing.T) {
t.Skip(script.Name)
TestScriptPrepared(t, harness, script)
TestScript(t, harness, script)
})
}
}
Expand Down
114 changes: 54 additions & 60 deletions enginetest/queries/generated_column_plans.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading