Skip to content

Commit 90c2189

Browse files
author
James Cor
committed
how about this?
1 parent c1974a0 commit 90c2189

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

sql/analyzer/fix_exec_indexes.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func assignExecIndexes(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Sc
3232
if !scope.IsEmpty() {
3333
// triggers
3434
s.triggerScope = true
35+
s.insertSourceScope = scope.InInsertSource
3536
s.addSchema(scope.Schema())
3637
s = s.push()
3738
}
@@ -605,8 +606,6 @@ func (s *idxScope) visitSelf(n sql.Node) error {
605606
case *plan.GroupBy, *plan.Window:
606607
if s.inTrigger() && s.inInsertSource() {
607608
for _, e := range proj.Expressions() {
608-
// default nodes can't see lateral join nodes, unless we're in lateral
609-
// join and lateral scopes are promoted to parent status
610609
s.expressions = append(s.expressions, fixExprToScope(e, s.childScopes...))
611610
}
612611
return nil
@@ -772,10 +771,7 @@ func fixExprToScope(e sql.Expression, scopes ...*idxScope) sql.Expression {
772771
// don't have the destination schema, and column references in default values are determined in the build phase)
773772

774773
idx, _ := newScope.getIdxId(e.Id(), e.String())
775-
if e.String() == "ref_tbl.id" {
776-
print()
777-
}
778-
if e.String() == "new.id" {
774+
if e.String() == "modeldisambig.id_modelinfo" && e.Index() == 1 {
779775
print()
780776
}
781777
if idx >= 0 {

sql/analyzer/inserts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func resolveInsertRows(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Sc
6767
// scope = &plan.Scope{}
6868
// }
6969
//}
70+
scope.InInsertSource = true // TODO: use a setter?
7071
source, _, err = a.analyzeWithSelector(ctx, insert.Source, scope, SelectAllBatches, newInsertSourceSelector(sel), qFlags)
7172
if err != nil {
7273
return nil, transform.SameTree, err

sql/plan/scope.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ type Scope struct {
4444
inLateralJoin bool
4545
joinSiblings []sql.Node
4646
JoinTrees []string
47+
48+
InInsertSource bool
4749
}
4850

4951
func (s *Scope) SetJoin(b bool) {

0 commit comments

Comments
 (0)