Skip to content

Commit 12b09ce

Browse files
author
James Cor
committed
remove rowupdateaccumulator node
1 parent 4329119 commit 12b09ce

File tree

11 files changed

+25
-314
lines changed

11 files changed

+25
-314
lines changed

enginetest/memory_engine_test.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,24 +197,12 @@ func TestSingleQueryPrepared(t *testing.T) {
197197

198198
// Convenience test for debugging a single query. Unskip and set to the desired query.
199199
func TestSingleScript(t *testing.T) {
200-
//t.Skip()
200+
t.Skip()
201201
var scripts = []queries.ScriptTest{
202202
{
203-
Name: "test script",
204-
SetUpScript: []string{
205-
"create table t (i int primary key);",
206-
"create procedure p() begin insert into t values (1); end;",
207-
},
208-
Assertions: []queries.ScriptTestAssertion{
209-
{
210-
Query: "call p();",
211-
Expected: []sql.Row{},
212-
},
213-
//{
214-
// Query: "update t join (values row(1), row(2)) t2 (j) on t.i = t2.j set t.i = 10;",
215-
// Expected: []sql.Row{},
216-
//},
217-
},
203+
Name: "test script",
204+
SetUpScript: []string{},
205+
Assertions: []queries.ScriptTestAssertion{},
218206
},
219207
}
220208

sql/analyzer/apply_foreign_keys.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -190,22 +190,6 @@ func applyForeignKeysToNodes(ctx *sql.Context, a *Analyzer, n sql.Node, cache *f
190190
}
191191
return newNode, transform.NewTree, nil
192192
}
193-
case *plan.RowUpdateAccumulator:
194-
children := n.Children()
195-
newChildren := make([]sql.Node, len(children))
196-
treeIdentity := transform.SameTree
197-
for i, child := range children {
198-
newIdentity := transform.SameTree
199-
newChildren[i], newIdentity, err = applyForeignKeysToNodes(ctx, a, child, cache)
200-
if err != nil {
201-
return nil, transform.SameTree, err
202-
}
203-
if newIdentity == transform.NewTree {
204-
treeIdentity = transform.NewTree
205-
}
206-
}
207-
nn, err := n.WithChildren(newChildren...)
208-
return nn, treeIdentity, err
209193
default:
210194
return n, transform.SameTree, nil
211195
}

sql/analyzer/apply_update_accumulators.go

Lines changed: 0 additions & 78 deletions
This file was deleted.

sql/analyzer/rule_ids.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ const (
6666
applyProceduresId // applyProcedures
6767
assignRoutinesId // assignRoutines
6868
modifyUpdateExprsForJoinId // modifyUpdateExprsForJoin
69-
applyUpdateAccumulatorsId // applyUpdateAccumulators
7069
applyForeignKeysId // applyForeignKeys
7170

7271
// validate

sql/analyzer/ruleid_string.go

Lines changed: 17 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sql/analyzer/rules.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func init() {
2121
{resolveInsertRowsId, resolveInsertRows},
2222
{applyTriggersId, applyTriggers},
2323
{applyProceduresId, applyProcedures},
24-
{applyUpdateAccumulatorsId, applyUpdateAccumulators},
2524
{inlineSubqueryAliasRefsId, inlineSubqueryAliasRefs},
2625
{cacheSubqueryAliasesInJoinsId, cacheSubqueryAliasesInJoins},
2726
{BacktickDefaulColumnValueNamesId, backtickDefaultColumnValueNames},

sql/analyzer/triggers.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,6 @@ func getUpdateJoinSource(n sql.Node) *plan.UpdateSource {
423423
// getTriggerLogic analyzes and returns the Node representing the trigger body for the trigger given, applied to the
424424
// plan node given, which must be an insert, update, or delete.
425425
func getTriggerLogic(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope, trigger *plan.CreateTrigger, qFlags *sql.QueryFlags) (sql.Node, error) {
426-
// For trigger body analysis, we don't want any row update accumulators applied to insert / update / delete
427-
// statements, we need the raw output from them.
428-
var noRowUpdateAccumulators RuleSelector
429-
noRowUpdateAccumulators = func(id RuleId) bool {
430-
return DefaultRuleSelector(id) && id != applyUpdateAccumulatorsId
431-
}
432-
433426
// For the reference to the row in the trigger table, we use the scope mechanism. This is a little strange because
434427
// scopes for subqueries work with the child schemas of a scope node, but we don't have such a node here. Instead we
435428
// fabricate one with the right properties (its child schema matches the table schema, with the right aliased name)
@@ -444,7 +437,7 @@ func getTriggerLogic(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scop
444437
plan.NewTableAlias("new", trigger.Table),
445438
)
446439
s := (*plan.Scope)(nil).NewScope(scopeNode).WithMemos(scope.Memo(n).MemoNodes()).WithProcedureCache(scope.ProcedureCache())
447-
triggerLogic, _, err = a.analyzeWithSelector(ctx, trigger.Body, s, SelectAllBatches, noRowUpdateAccumulators, qFlags)
440+
triggerLogic, _, err = a.analyzeWithSelector(ctx, trigger.Body, s, SelectAllBatches, DefaultRuleSelector, qFlags)
448441
case sqlparser.UpdateStr:
449442
var scopeNode *plan.Project
450443
if updateSrc := getUpdateJoinSource(n); updateSrc == nil {
@@ -467,15 +460,15 @@ func getTriggerLogic(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scop
467460
}
468461
// Triggers are wrapped in prepend nodes, which means that the parent scope is included
469462
s := (*plan.Scope)(nil).NewScope(scopeNode).WithMemos(scope.Memo(n).MemoNodes()).WithProcedureCache(scope.ProcedureCache())
470-
triggerLogic, _, err = a.analyzeWithSelector(ctx, trigger.Body, s, SelectAllBatches, noRowUpdateAccumulators, qFlags)
463+
triggerLogic, _, err = a.analyzeWithSelector(ctx, trigger.Body, s, SelectAllBatches, DefaultRuleSelector, qFlags)
471464
case sqlparser.DeleteStr:
472465
scopeNode := plan.NewProject(
473466
[]sql.Expression{expression.NewStar()},
474467
plan.NewTableAlias("old", trigger.Table),
475468
)
476469
// Triggers are wrapped in prepend nodes, which means that the parent scope is included
477470
s := scope.NewScope(scopeNode)
478-
triggerLogic, _, err = a.analyzeWithSelector(ctx, trigger.Body, s, SelectAllBatches, noRowUpdateAccumulators, qFlags)
471+
triggerLogic, _, err = a.analyzeWithSelector(ctx, trigger.Body, s, SelectAllBatches, DefaultRuleSelector, qFlags)
479472
}
480473

481474
return triggerLogic, err

sql/plan/row_update_accumulator.go

Lines changed: 0 additions & 91 deletions
This file was deleted.

sql/plan/table_copier.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ func (tc *TableCopier) ProcessCreateTable(ctx *sql.Context, b sql.NodeExecBuilde
7474
// TODO: Improve parsing for CREATE TABLE SELECT to allow for IGNORE/REPLACE and custom specs
7575
ii := NewInsertInto(tc.db, NewResolvedTable(table, tc.db, nil), tc.Source, tc.options.replace, nil, nil, tc.options.ignore)
7676

77-
// Wrap the insert into a row update accumulator
78-
roa := NewRowUpdateAccumulator(ii, UpdateTypeInsert)
79-
80-
return b.Build(ctx, roa, row)
77+
return b.Build(ctx, ii, row)
8178
}
8279

8380
// createTableSelectCanBeCopied determines whether the newly created table's data can just be copied from the Source table

0 commit comments

Comments
 (0)