Skip to content

Commit dc2d5d6

Browse files
committed
clean up
1 parent 95929b1 commit dc2d5d6

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

enginetest/queries/update_queries.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,6 @@ var UpdateScriptTests = []ScriptTest{
554554
SET a.x = 101, b.y = 201;`,
555555
},
556556
{
557-
// TODO: UPDATE ... JOIN does not properly apply triggers when multiple tables are being updated,
558-
// and will currently only apply triggers from one of the tables.
559-
Skip: true,
560557
Query: "SELECT * FROM logbook ORDER BY entry;",
561558
Expected: []sql.Row{
562559
{"a updated"},

sql/analyzer/triggers.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,25 +364,16 @@ func applyTrigger(ctx *sql.Context, a *Analyzer, originalNode, n sql.Node, scope
364364
}
365365

366366
canApplyTriggerExecutor := func(c transform.Context) bool {
367+
// Don't double-apply trigger executors to the bodies of triggers. To avoid this, don't apply the trigger if the
368+
// parent is a trigger body.
367369
if _, ok := c.Parent.(*plan.TriggerExecutor); ok {
368-
if c.ChildNum == 1 {
370+
if c.ChildNum == 1 { // Right child is the trigger execution logic
369371
return false
370372
}
371373
}
372374
return true
373375
}
374376
return transform.NodeWithCtx(n, canApplyTriggerExecutor, func(c transform.Context) (sql.Node, transform.TreeIdentity, error) {
375-
// Don't double-apply trigger executors to the bodies of triggers. To avoid this, don't apply the trigger if the
376-
// parent is a trigger body.
377-
// TODO: this won't work for BEGIN END blocks, stored procedures, etc. For those, we need to examine all ancestors,
378-
// not just the immediate parent. Alternately, we could do something like not walk all children of some node types
379-
// (probably better).
380-
if _, ok := c.Parent.(*plan.TriggerExecutor); ok {
381-
if c.ChildNum == 1 { // Right child is the trigger execution logic
382-
return c.Node, transform.SameTree, nil
383-
}
384-
}
385-
386377
switch n := c.Node.(type) {
387378
case *plan.InsertInto:
388379
qFlags.Set(sql.QFlagTrigger)

0 commit comments

Comments
 (0)