diff --git a/go/tools/asthelpergen/rewrite_gen.go b/go/tools/asthelpergen/rewrite_gen.go index cc8b18a78e9..ca31e249c90 100644 --- a/go/tools/asthelpergen/rewrite_gen.go +++ b/go/tools/asthelpergen/rewrite_gen.go @@ -108,9 +108,11 @@ func (r *rewriteGen) structMethod(t types.Type, strct *types.Struct, spi generat } fields := r.rewriteAllStructFields(t, strct, spi, true) - stmts := []jen.Code{r.executePre(t)} + var stmts []jen.Code + + stmts = append(stmts, r.executePre(t)...) stmts = append(stmts, fields...) - stmts = append(stmts, executePost(len(fields) > 0)) + stmts = append(stmts, executePost(len(fields) > 0)...) stmts = append(stmts, returnTrue()) r.rewriteFunc(t, stmts) @@ -133,10 +135,10 @@ func (r *rewriteGen) ptrToStructMethod(t types.Type, strct *types.Struct, spi ge return nil } */ - stmts = append(stmts, r.executePre(t)) + stmts = append(stmts, r.executePre(t)...) fields := r.rewriteAllStructFields(t, strct, spi, false) stmts = append(stmts, fields...) - stmts = append(stmts, executePost(len(fields) > 0)) + stmts = append(stmts, executePost(len(fields) > 0)...) stmts = append(stmts, returnTrue()) r.rewriteFunc(t, stmts) @@ -180,6 +182,7 @@ func (r *rewriteGen) sliceMethod(t types.Type, slice *types.Slice, spi generator */ stmts := []jen.Code{ jen.If(jen.Id("node == nil").Block(returnTrue())), + jen.Var().Id("onLeave").Func().Params(jen.Id("SQLNode")), } typeString := types.TypeString(t, noQualifier) @@ -187,6 +190,7 @@ func (r *rewriteGen) sliceMethod(t types.Type, slice *types.Slice, spi generator preStmts := setupCursor() preStmts = append(preStmts, jen.Id("kontinue").Op(":=").Id("!a.pre(&a.cur)"), + saveAndResetOnLeave(), jen.If(jen.Id("a.cur.revisit").Block( jen.Id("node").Op("=").Id("a.cur.node.("+typeString+")"), jen.Id("a.cur.revisit").Op("=").False(), @@ -214,7 +218,7 @@ func (r *rewriteGen) sliceMethod(t types.Type, slice *types.Slice, spi generator Block(r.rewriteChildSlice(t, slice.Elem(), "notUsed", jen.Id("el"), jen.Index(jen.Id("idx")), false))) } - stmts = append(stmts, executePost(haveChildren)) + stmts = append(stmts, executePost(haveChildren)...) stmts = append(stmts, returnTrue()) r.rewriteFunc(t, stmts) @@ -228,23 +232,33 @@ func setupCursor() []jen.Code { jen.Id("a.cur.node = node"), } } -func (r *rewriteGen) executePre(t types.Type) jen.Code { + +func (r *rewriteGen) executePre(t types.Type) []jen.Code { curStmts := setupCursor() + curStmts = append(curStmts, + jen.Id("kontinue").Op(":=").Id("!a.pre(&a.cur)"), + saveAndResetOnLeave()) + if r.exprInterface != nil && types.Implements(t, r.exprInterface) { - curStmts = append(curStmts, jen.Id("kontinue").Op(":=").Id("!a.pre(&a.cur)"), + curStmts = append(curStmts, + // if this is an expressions and we should revisit it, we do so jen.If(jen.Id("a.cur.revisit").Block( jen.Id("a.cur.revisit").Op("=").False(), jen.Return(jen.Id("a.rewriteExpr(parent, a.cur.node.(Expr), replacer)")), )), - jen.If(jen.Id("kontinue").Block(jen.Return(jen.True()))), ) - } else { - curStmts = append(curStmts, jen.If(jen.Id("!a.pre(&a.cur)")).Block(returnTrue())) } - return jen.If(jen.Id("a.pre!= nil").Block(curStmts...)) + + curStmts = append(curStmts, jen.If(jen.Id("kontinue").Block(jen.Return(jen.True())))) + code := []jen.Code{ + jen.Var().Id("onLeave").Func().Params(jen.Id("SQLNode")), + jen.If(jen.Id("a.pre != nil").Block(curStmts...)), + } + + return code } -func executePost(seenChildren bool) jen.Code { +func executePost(seenChildren bool) []jen.Code { var curStmts []jen.Code if seenChildren { // if we have visited children, we have to write to the cursor fields @@ -256,15 +270,21 @@ func executePost(seenChildren bool) jen.Code { curStmts = append(curStmts, jen.If(jen.Id("!a.post(&a.cur)")).Block(returnFalse())) - return jen.If(jen.Id("a.post != nil")).Block(curStmts...) + return []jen.Code{ + jen.If(jen.Id("onLeave").Op("!=").Nil()).Block( + jen.Id("onLeave").Call(jen.Id("node")), + ), + jen.If(jen.Id("a.post != nil")).Block(curStmts...), + } } func (r *rewriteGen) basicMethod(t types.Type, _ *types.Basic, spi generatorSPI) error { if !shouldAdd(t, spi.iface()) { return nil } - - stmts := []jen.Code{r.executePre(t), executePost(false), returnTrue()} + stmts := r.executePre(t) + stmts = append(stmts, executePost(false)...) + stmts = append(stmts, returnTrue()) r.rewriteFunc(t, stmts) return nil } @@ -412,3 +432,7 @@ func returnTrue() jen.Code { func returnFalse() jen.Code { return jen.Return(jen.False()) } + +func saveAndResetOnLeave() jen.Code { + return jen.List(jen.Id("onLeave"), jen.Id("a.cur.onLeave")).Op("=").List(jen.Id("a.cur.onLeave"), jen.Nil()) +} diff --git a/go/vt/sqlparser/ast_rewrite.go b/go/vt/sqlparser/ast_rewrite.go index 690b381b082..0846fac34bd 100644 --- a/go/vt/sqlparser/ast_rewrite.go +++ b/go/vt/sqlparser/ast_rewrite.go @@ -573,11 +573,14 @@ func (a *application) rewriteRefOfAddColumns(parent SQLNode, node *AddColumns, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -595,6 +598,9 @@ func (a *application) rewriteRefOfAddColumns(parent SQLNode, node *AddColumns, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -609,11 +615,14 @@ func (a *application) rewriteRefOfAddConstraintDefinition(parent SQLNode, node * if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -622,6 +631,9 @@ func (a *application) rewriteRefOfAddConstraintDefinition(parent SQLNode, node * }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -636,11 +648,14 @@ func (a *application) rewriteRefOfAddIndexDefinition(parent SQLNode, node *AddIn if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -649,6 +664,9 @@ func (a *application) rewriteRefOfAddIndexDefinition(parent SQLNode, node *AddIn }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -663,11 +681,14 @@ func (a *application) rewriteRefOfAliasedExpr(parent SQLNode, node *AliasedExpr, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -681,6 +702,9 @@ func (a *application) rewriteRefOfAliasedExpr(parent SQLNode, node *AliasedExpr, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -695,11 +719,14 @@ func (a *application) rewriteRefOfAliasedTableExpr(parent SQLNode, node *Aliased if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -728,6 +755,9 @@ func (a *application) rewriteRefOfAliasedTableExpr(parent SQLNode, node *Aliased }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -742,14 +772,20 @@ func (a *application) rewriteRefOfAlterCharset(parent SQLNode, node *AlterCharse if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -766,11 +802,14 @@ func (a *application) rewriteRefOfAlterCheck(parent SQLNode, node *AlterCheck, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -779,6 +818,9 @@ func (a *application) rewriteRefOfAlterCheck(parent SQLNode, node *AlterCheck, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -793,11 +835,14 @@ func (a *application) rewriteRefOfAlterColumn(parent SQLNode, node *AlterColumn, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -811,6 +856,9 @@ func (a *application) rewriteRefOfAlterColumn(parent SQLNode, node *AlterColumn, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -825,11 +873,14 @@ func (a *application) rewriteRefOfAlterDatabase(parent SQLNode, node *AlterDatab if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -843,6 +894,9 @@ func (a *application) rewriteRefOfAlterDatabase(parent SQLNode, node *AlterDatab }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -857,11 +911,14 @@ func (a *application) rewriteRefOfAlterIndex(parent SQLNode, node *AlterIndex, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -870,6 +927,9 @@ func (a *application) rewriteRefOfAlterIndex(parent SQLNode, node *AlterIndex, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -884,11 +944,14 @@ func (a *application) rewriteRefOfAlterMigration(parent SQLNode, node *AlterMigr if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -897,6 +960,9 @@ func (a *application) rewriteRefOfAlterMigration(parent SQLNode, node *AlterMigr }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -911,11 +977,14 @@ func (a *application) rewriteRefOfAlterTable(parent SQLNode, node *AlterTable, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -948,6 +1017,9 @@ func (a *application) rewriteRefOfAlterTable(parent SQLNode, node *AlterTable, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -962,11 +1034,14 @@ func (a *application) rewriteRefOfAlterView(parent SQLNode, node *AlterView, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -995,6 +1070,9 @@ func (a *application) rewriteRefOfAlterView(parent SQLNode, node *AlterView, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1009,11 +1087,14 @@ func (a *application) rewriteRefOfAlterVschema(parent SQLNode, node *AlterVschem if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -1041,6 +1122,9 @@ func (a *application) rewriteRefOfAlterVschema(parent SQLNode, node *AlterVschem }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1055,11 +1139,14 @@ func (a *application) rewriteRefOfAnalyze(parent SQLNode, node *Analyze, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -1068,6 +1155,9 @@ func (a *application) rewriteRefOfAnalyze(parent SQLNode, node *Analyze, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1082,11 +1172,13 @@ func (a *application) rewriteRefOfAndExpr(parent SQLNode, node *AndExpr, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1105,6 +1197,9 @@ func (a *application) rewriteRefOfAndExpr(parent SQLNode, node *AndExpr, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1119,11 +1214,13 @@ func (a *application) rewriteRefOfAnyValue(parent SQLNode, node *AnyValue, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1137,6 +1234,9 @@ func (a *application) rewriteRefOfAnyValue(parent SQLNode, node *AnyValue, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1151,11 +1251,13 @@ func (a *application) rewriteRefOfArgument(parent SQLNode, node *Argument, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1164,6 +1266,9 @@ func (a *application) rewriteRefOfArgument(parent SQLNode, node *Argument, repla return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -1180,11 +1285,13 @@ func (a *application) rewriteRefOfArgumentLessWindowExpr(parent SQLNode, node *A if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1198,6 +1305,9 @@ func (a *application) rewriteRefOfArgumentLessWindowExpr(parent SQLNode, node *A }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1212,11 +1322,13 @@ func (a *application) rewriteRefOfAssignmentExpr(parent SQLNode, node *Assignmen if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1235,6 +1347,9 @@ func (a *application) rewriteRefOfAssignmentExpr(parent SQLNode, node *Assignmen }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1249,11 +1364,14 @@ func (a *application) rewriteRefOfAutoIncSpec(parent SQLNode, node *AutoIncSpec, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -1267,6 +1385,9 @@ func (a *application) rewriteRefOfAutoIncSpec(parent SQLNode, node *AutoIncSpec, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1281,11 +1402,13 @@ func (a *application) rewriteRefOfAvg(parent SQLNode, node *Avg, replacer replac if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1304,6 +1427,9 @@ func (a *application) rewriteRefOfAvg(parent SQLNode, node *Avg, replacer replac }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1318,14 +1444,20 @@ func (a *application) rewriteRefOfBegin(parent SQLNode, node *Begin, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -1342,11 +1474,13 @@ func (a *application) rewriteRefOfBetweenExpr(parent SQLNode, node *BetweenExpr, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1370,6 +1504,9 @@ func (a *application) rewriteRefOfBetweenExpr(parent SQLNode, node *BetweenExpr, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1384,11 +1521,13 @@ func (a *application) rewriteRefOfBinaryExpr(parent SQLNode, node *BinaryExpr, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1407,6 +1546,9 @@ func (a *application) rewriteRefOfBinaryExpr(parent SQLNode, node *BinaryExpr, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1421,11 +1563,13 @@ func (a *application) rewriteRefOfBitAnd(parent SQLNode, node *BitAnd, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1444,6 +1588,9 @@ func (a *application) rewriteRefOfBitAnd(parent SQLNode, node *BitAnd, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1458,11 +1605,13 @@ func (a *application) rewriteRefOfBitOr(parent SQLNode, node *BitOr, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1481,6 +1630,9 @@ func (a *application) rewriteRefOfBitOr(parent SQLNode, node *BitOr, replacer re }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1495,11 +1647,13 @@ func (a *application) rewriteRefOfBitXor(parent SQLNode, node *BitXor, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1518,6 +1672,9 @@ func (a *application) rewriteRefOfBitXor(parent SQLNode, node *BitXor, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1532,11 +1689,14 @@ func (a *application) rewriteRefOfCallProc(parent SQLNode, node *CallProc, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -1550,6 +1710,9 @@ func (a *application) rewriteRefOfCallProc(parent SQLNode, node *CallProc, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1564,11 +1727,13 @@ func (a *application) rewriteRefOfCaseExpr(parent SQLNode, node *CaseExpr, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1596,6 +1761,9 @@ func (a *application) rewriteRefOfCaseExpr(parent SQLNode, node *CaseExpr, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1610,11 +1778,13 @@ func (a *application) rewriteRefOfCastExpr(parent SQLNode, node *CastExpr, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1633,6 +1803,9 @@ func (a *application) rewriteRefOfCastExpr(parent SQLNode, node *CastExpr, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1647,11 +1820,14 @@ func (a *application) rewriteRefOfChangeColumn(parent SQLNode, node *ChangeColum if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -1670,6 +1846,9 @@ func (a *application) rewriteRefOfChangeColumn(parent SQLNode, node *ChangeColum }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1684,11 +1863,13 @@ func (a *application) rewriteRefOfCharExpr(parent SQLNode, node *CharExpr, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1702,6 +1883,9 @@ func (a *application) rewriteRefOfCharExpr(parent SQLNode, node *CharExpr, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1716,11 +1900,14 @@ func (a *application) rewriteRefOfCheckConstraintDefinition(parent SQLNode, node if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -1729,6 +1916,9 @@ func (a *application) rewriteRefOfCheckConstraintDefinition(parent SQLNode, node }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1743,11 +1933,13 @@ func (a *application) rewriteRefOfColName(parent SQLNode, node *ColName, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1766,6 +1958,9 @@ func (a *application) rewriteRefOfColName(parent SQLNode, node *ColName, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1780,11 +1975,13 @@ func (a *application) rewriteRefOfCollateExpr(parent SQLNode, node *CollateExpr, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -1798,6 +1995,9 @@ func (a *application) rewriteRefOfCollateExpr(parent SQLNode, node *CollateExpr, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1812,11 +2012,14 @@ func (a *application) rewriteRefOfColumnDefinition(parent SQLNode, node *ColumnD if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -1830,6 +2033,9 @@ func (a *application) rewriteRefOfColumnDefinition(parent SQLNode, node *ColumnD }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1844,14 +2050,20 @@ func (a *application) rewriteRefOfColumnType(parent SQLNode, node *ColumnType, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -1868,11 +2080,13 @@ func (a *application) rewriteColumns(parent SQLNode, node Columns, replacer repl if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(Columns) a.cur.revisit = false @@ -1891,6 +2105,9 @@ func (a *application) rewriteColumns(parent SQLNode, node Columns, replacer repl return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1905,14 +2122,20 @@ func (a *application) rewriteRefOfCommentOnly(parent SQLNode, node *CommentOnly, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -1929,14 +2152,20 @@ func (a *application) rewriteRefOfCommit(parent SQLNode, node *Commit, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -1953,11 +2182,14 @@ func (a *application) rewriteRefOfCommonTableExpr(parent SQLNode, node *CommonTa if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -1976,6 +2208,9 @@ func (a *application) rewriteRefOfCommonTableExpr(parent SQLNode, node *CommonTa }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -1990,11 +2225,13 @@ func (a *application) rewriteRefOfComparisonExpr(parent SQLNode, node *Compariso if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2018,6 +2255,9 @@ func (a *application) rewriteRefOfComparisonExpr(parent SQLNode, node *Compariso }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2032,11 +2272,14 @@ func (a *application) rewriteRefOfConstraintDefinition(parent SQLNode, node *Con if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2050,6 +2293,9 @@ func (a *application) rewriteRefOfConstraintDefinition(parent SQLNode, node *Con }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2064,11 +2310,13 @@ func (a *application) rewriteRefOfConvertExpr(parent SQLNode, node *ConvertExpr, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2087,6 +2335,9 @@ func (a *application) rewriteRefOfConvertExpr(parent SQLNode, node *ConvertExpr, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2101,14 +2352,20 @@ func (a *application) rewriteRefOfConvertType(parent SQLNode, node *ConvertType, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -2125,11 +2382,13 @@ func (a *application) rewriteRefOfConvertUsingExpr(parent SQLNode, node *Convert if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2143,6 +2402,9 @@ func (a *application) rewriteRefOfConvertUsingExpr(parent SQLNode, node *Convert }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2157,11 +2419,13 @@ func (a *application) rewriteRefOfCount(parent SQLNode, node *Count, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2180,6 +2444,9 @@ func (a *application) rewriteRefOfCount(parent SQLNode, node *Count, replacer re }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2194,11 +2461,13 @@ func (a *application) rewriteRefOfCountStar(parent SQLNode, node *CountStar, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2212,6 +2481,9 @@ func (a *application) rewriteRefOfCountStar(parent SQLNode, node *CountStar, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2226,11 +2498,14 @@ func (a *application) rewriteRefOfCreateDatabase(parent SQLNode, node *CreateDat if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2244,6 +2519,9 @@ func (a *application) rewriteRefOfCreateDatabase(parent SQLNode, node *CreateDat }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2258,11 +2536,14 @@ func (a *application) rewriteRefOfCreateTable(parent SQLNode, node *CreateTable, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2286,6 +2567,9 @@ func (a *application) rewriteRefOfCreateTable(parent SQLNode, node *CreateTable, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2300,11 +2584,14 @@ func (a *application) rewriteRefOfCreateView(parent SQLNode, node *CreateView, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2333,6 +2620,9 @@ func (a *application) rewriteRefOfCreateView(parent SQLNode, node *CreateView, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2347,11 +2637,13 @@ func (a *application) rewriteRefOfCurTimeFuncExpr(parent SQLNode, node *CurTimeF if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2365,6 +2657,9 @@ func (a *application) rewriteRefOfCurTimeFuncExpr(parent SQLNode, node *CurTimeF }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2379,11 +2674,14 @@ func (a *application) rewriteRefOfDeallocateStmt(parent SQLNode, node *Deallocat if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2397,6 +2695,9 @@ func (a *application) rewriteRefOfDeallocateStmt(parent SQLNode, node *Deallocat }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2411,11 +2712,13 @@ func (a *application) rewriteRefOfDefault(parent SQLNode, node *Default, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2424,6 +2727,9 @@ func (a *application) rewriteRefOfDefault(parent SQLNode, node *Default, replace return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -2440,14 +2746,20 @@ func (a *application) rewriteRefOfDefiner(parent SQLNode, node *Definer, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -2464,11 +2776,14 @@ func (a *application) rewriteRefOfDelete(parent SQLNode, node *Delete, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2516,6 +2831,9 @@ func (a *application) rewriteRefOfDelete(parent SQLNode, node *Delete, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2530,11 +2848,14 @@ func (a *application) rewriteRefOfDerivedTable(parent SQLNode, node *DerivedTabl if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2543,6 +2864,9 @@ func (a *application) rewriteRefOfDerivedTable(parent SQLNode, node *DerivedTabl }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2557,11 +2881,14 @@ func (a *application) rewriteRefOfDropColumn(parent SQLNode, node *DropColumn, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2570,6 +2897,9 @@ func (a *application) rewriteRefOfDropColumn(parent SQLNode, node *DropColumn, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2584,11 +2914,14 @@ func (a *application) rewriteRefOfDropDatabase(parent SQLNode, node *DropDatabas if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2602,6 +2935,9 @@ func (a *application) rewriteRefOfDropDatabase(parent SQLNode, node *DropDatabas }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2616,11 +2952,14 @@ func (a *application) rewriteRefOfDropKey(parent SQLNode, node *DropKey, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2629,6 +2968,9 @@ func (a *application) rewriteRefOfDropKey(parent SQLNode, node *DropKey, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2643,11 +2985,14 @@ func (a *application) rewriteRefOfDropTable(parent SQLNode, node *DropTable, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2661,6 +3006,9 @@ func (a *application) rewriteRefOfDropTable(parent SQLNode, node *DropTable, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2675,11 +3023,14 @@ func (a *application) rewriteRefOfDropView(parent SQLNode, node *DropView, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2693,6 +3044,9 @@ func (a *application) rewriteRefOfDropView(parent SQLNode, node *DropView, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2707,11 +3061,14 @@ func (a *application) rewriteRefOfExecuteStmt(parent SQLNode, node *ExecuteStmt, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2734,6 +3091,9 @@ func (a *application) rewriteRefOfExecuteStmt(parent SQLNode, node *ExecuteStmt, return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2748,11 +3108,13 @@ func (a *application) rewriteRefOfExistsExpr(parent SQLNode, node *ExistsExpr, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2766,6 +3128,9 @@ func (a *application) rewriteRefOfExistsExpr(parent SQLNode, node *ExistsExpr, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2780,11 +3145,14 @@ func (a *application) rewriteRefOfExplainStmt(parent SQLNode, node *ExplainStmt, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2798,6 +3166,9 @@ func (a *application) rewriteRefOfExplainStmt(parent SQLNode, node *ExplainStmt, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2812,11 +3183,14 @@ func (a *application) rewriteRefOfExplainTab(parent SQLNode, node *ExplainTab, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -2825,6 +3199,9 @@ func (a *application) rewriteRefOfExplainTab(parent SQLNode, node *ExplainTab, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2839,11 +3216,13 @@ func (a *application) rewriteExprs(parent SQLNode, node Exprs, replacer replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(Exprs) a.cur.revisit = false @@ -2862,6 +3241,9 @@ func (a *application) rewriteExprs(parent SQLNode, node Exprs, replacer replacer return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2876,11 +3258,13 @@ func (a *application) rewriteRefOfExtractFuncExpr(parent SQLNode, node *ExtractF if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2894,6 +3278,9 @@ func (a *application) rewriteRefOfExtractFuncExpr(parent SQLNode, node *ExtractF }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2908,11 +3295,13 @@ func (a *application) rewriteRefOfExtractValueExpr(parent SQLNode, node *Extract if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2931,6 +3320,9 @@ func (a *application) rewriteRefOfExtractValueExpr(parent SQLNode, node *Extract }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2945,11 +3337,13 @@ func (a *application) rewriteRefOfFirstOrLastValueExpr(parent SQLNode, node *Fir if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -2973,6 +3367,9 @@ func (a *application) rewriteRefOfFirstOrLastValueExpr(parent SQLNode, node *Fir }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -2987,11 +3384,14 @@ func (a *application) rewriteRefOfFlush(parent SQLNode, node *Flush, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -3000,6 +3400,9 @@ func (a *application) rewriteRefOfFlush(parent SQLNode, node *Flush, replacer re }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3014,14 +3417,20 @@ func (a *application) rewriteRefOfForce(parent SQLNode, node *Force, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -3038,11 +3447,14 @@ func (a *application) rewriteRefOfForeignKeyDefinition(parent SQLNode, node *For if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -3061,6 +3473,9 @@ func (a *application) rewriteRefOfForeignKeyDefinition(parent SQLNode, node *For }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3075,11 +3490,14 @@ func (a *application) rewriteRefOfFrameClause(parent SQLNode, node *FrameClause, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -3093,6 +3511,9 @@ func (a *application) rewriteRefOfFrameClause(parent SQLNode, node *FrameClause, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3107,11 +3528,14 @@ func (a *application) rewriteRefOfFramePoint(parent SQLNode, node *FramePoint, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -3120,6 +3544,9 @@ func (a *application) rewriteRefOfFramePoint(parent SQLNode, node *FramePoint, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3134,14 +3561,20 @@ func (a *application) rewriteRefOfFromFirstLastClause(parent SQLNode, node *From if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -3158,11 +3591,13 @@ func (a *application) rewriteRefOfFuncExpr(parent SQLNode, node *FuncExpr, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3186,6 +3621,9 @@ func (a *application) rewriteRefOfFuncExpr(parent SQLNode, node *FuncExpr, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3200,11 +3638,13 @@ func (a *application) rewriteRefOfGTIDFuncExpr(parent SQLNode, node *GTIDFuncExp if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3233,6 +3673,9 @@ func (a *application) rewriteRefOfGTIDFuncExpr(parent SQLNode, node *GTIDFuncExp }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3247,11 +3690,13 @@ func (a *application) rewriteRefOfGeoHashFromLatLongExpr(parent SQLNode, node *G if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3275,6 +3720,9 @@ func (a *application) rewriteRefOfGeoHashFromLatLongExpr(parent SQLNode, node *G }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3289,11 +3737,13 @@ func (a *application) rewriteRefOfGeoHashFromPointExpr(parent SQLNode, node *Geo if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3312,6 +3762,9 @@ func (a *application) rewriteRefOfGeoHashFromPointExpr(parent SQLNode, node *Geo }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3326,11 +3779,13 @@ func (a *application) rewriteRefOfGeoJSONFromGeomExpr(parent SQLNode, node *GeoJ if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3354,6 +3809,9 @@ func (a *application) rewriteRefOfGeoJSONFromGeomExpr(parent SQLNode, node *GeoJ }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3368,11 +3826,13 @@ func (a *application) rewriteRefOfGeomCollPropertyFuncExpr(parent SQLNode, node if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3391,6 +3851,9 @@ func (a *application) rewriteRefOfGeomCollPropertyFuncExpr(parent SQLNode, node }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3405,11 +3868,13 @@ func (a *application) rewriteRefOfGeomFormatExpr(parent SQLNode, node *GeomForma if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3428,6 +3893,9 @@ func (a *application) rewriteRefOfGeomFormatExpr(parent SQLNode, node *GeomForma }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3442,11 +3910,13 @@ func (a *application) rewriteRefOfGeomFromGeoHashExpr(parent SQLNode, node *Geom if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3465,6 +3935,9 @@ func (a *application) rewriteRefOfGeomFromGeoHashExpr(parent SQLNode, node *Geom }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3479,11 +3952,13 @@ func (a *application) rewriteRefOfGeomFromGeoJSONExpr(parent SQLNode, node *Geom if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3507,6 +3982,9 @@ func (a *application) rewriteRefOfGeomFromGeoJSONExpr(parent SQLNode, node *Geom }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3521,11 +3999,13 @@ func (a *application) rewriteRefOfGeomFromTextExpr(parent SQLNode, node *GeomFro if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3549,6 +4029,9 @@ func (a *application) rewriteRefOfGeomFromTextExpr(parent SQLNode, node *GeomFro }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3563,11 +4046,13 @@ func (a *application) rewriteRefOfGeomFromWKBExpr(parent SQLNode, node *GeomFrom if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3591,6 +4076,9 @@ func (a *application) rewriteRefOfGeomFromWKBExpr(parent SQLNode, node *GeomFrom }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3605,11 +4093,13 @@ func (a *application) rewriteRefOfGeomPropertyFuncExpr(parent SQLNode, node *Geo if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3623,6 +4113,9 @@ func (a *application) rewriteRefOfGeomPropertyFuncExpr(parent SQLNode, node *Geo }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3637,11 +4130,14 @@ func (a *application) rewriteRefOfGroupBy(parent SQLNode, node *GroupBy, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -3654,6 +4150,9 @@ func (a *application) rewriteRefOfGroupBy(parent SQLNode, node *GroupBy, replace return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3668,11 +4167,13 @@ func (a *application) rewriteRefOfGroupConcatExpr(parent SQLNode, node *GroupCon if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3696,6 +4197,9 @@ func (a *application) rewriteRefOfGroupConcatExpr(parent SQLNode, node *GroupCon }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3707,14 +4211,20 @@ func (a *application) rewriteRefOfGroupConcatExpr(parent SQLNode, node *GroupCon return true } func (a *application) rewriteIdentifierCI(parent SQLNode, node IdentifierCI, replacer replacerFunc) bool { + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -3728,14 +4238,20 @@ func (a *application) rewriteIdentifierCI(parent SQLNode, node IdentifierCI, rep return true } func (a *application) rewriteIdentifierCS(parent SQLNode, node IdentifierCS, replacer replacerFunc) bool { + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -3752,11 +4268,14 @@ func (a *application) rewriteRefOfIndexDefinition(parent SQLNode, node *IndexDef if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -3765,6 +4284,9 @@ func (a *application) rewriteRefOfIndexDefinition(parent SQLNode, node *IndexDef }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3779,11 +4301,14 @@ func (a *application) rewriteRefOfIndexHint(parent SQLNode, node *IndexHint, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -3796,6 +4321,9 @@ func (a *application) rewriteRefOfIndexHint(parent SQLNode, node *IndexHint, rep return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3810,11 +4338,13 @@ func (a *application) rewriteIndexHints(parent SQLNode, node IndexHints, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(IndexHints) a.cur.revisit = false @@ -3833,6 +4363,9 @@ func (a *application) rewriteIndexHints(parent SQLNode, node IndexHints, replace return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3847,11 +4380,14 @@ func (a *application) rewriteRefOfIndexInfo(parent SQLNode, node *IndexInfo, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -3865,6 +4401,9 @@ func (a *application) rewriteRefOfIndexInfo(parent SQLNode, node *IndexInfo, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3879,11 +4418,14 @@ func (a *application) rewriteRefOfInsert(parent SQLNode, node *Insert, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -3922,6 +4464,9 @@ func (a *application) rewriteRefOfInsert(parent SQLNode, node *Insert, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3936,11 +4481,13 @@ func (a *application) rewriteRefOfInsertExpr(parent SQLNode, node *InsertExpr, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -3969,6 +4516,9 @@ func (a *application) rewriteRefOfInsertExpr(parent SQLNode, node *InsertExpr, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -3983,11 +4533,13 @@ func (a *application) rewriteRefOfIntervalDateExpr(parent SQLNode, node *Interva if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4006,6 +4558,9 @@ func (a *application) rewriteRefOfIntervalDateExpr(parent SQLNode, node *Interva }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4020,11 +4575,13 @@ func (a *application) rewriteRefOfIntervalFuncExpr(parent SQLNode, node *Interva if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4043,6 +4600,9 @@ func (a *application) rewriteRefOfIntervalFuncExpr(parent SQLNode, node *Interva }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4057,11 +4617,13 @@ func (a *application) rewriteRefOfIntroducerExpr(parent SQLNode, node *Introduce if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4075,6 +4637,9 @@ func (a *application) rewriteRefOfIntroducerExpr(parent SQLNode, node *Introduce }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4089,11 +4654,13 @@ func (a *application) rewriteRefOfIsExpr(parent SQLNode, node *IsExpr, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4107,6 +4674,9 @@ func (a *application) rewriteRefOfIsExpr(parent SQLNode, node *IsExpr, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4121,11 +4691,13 @@ func (a *application) rewriteRefOfJSONArrayAgg(parent SQLNode, node *JSONArrayAg if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4144,6 +4716,9 @@ func (a *application) rewriteRefOfJSONArrayAgg(parent SQLNode, node *JSONArrayAg }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4158,11 +4733,13 @@ func (a *application) rewriteRefOfJSONArrayExpr(parent SQLNode, node *JSONArrayE if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4176,6 +4753,9 @@ func (a *application) rewriteRefOfJSONArrayExpr(parent SQLNode, node *JSONArrayE }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4190,11 +4770,13 @@ func (a *application) rewriteRefOfJSONAttributesExpr(parent SQLNode, node *JSONA if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4213,6 +4795,9 @@ func (a *application) rewriteRefOfJSONAttributesExpr(parent SQLNode, node *JSONA }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4227,11 +4812,13 @@ func (a *application) rewriteRefOfJSONContainsExpr(parent SQLNode, node *JSONCon if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4259,6 +4846,9 @@ func (a *application) rewriteRefOfJSONContainsExpr(parent SQLNode, node *JSONCon return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4273,11 +4863,13 @@ func (a *application) rewriteRefOfJSONContainsPathExpr(parent SQLNode, node *JSO if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4305,6 +4897,9 @@ func (a *application) rewriteRefOfJSONContainsPathExpr(parent SQLNode, node *JSO return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4319,11 +4914,13 @@ func (a *application) rewriteRefOfJSONExtractExpr(parent SQLNode, node *JSONExtr if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4346,6 +4943,9 @@ func (a *application) rewriteRefOfJSONExtractExpr(parent SQLNode, node *JSONExtr return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4360,11 +4960,13 @@ func (a *application) rewriteRefOfJSONKeysExpr(parent SQLNode, node *JSONKeysExp if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4383,6 +4985,9 @@ func (a *application) rewriteRefOfJSONKeysExpr(parent SQLNode, node *JSONKeysExp }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4397,11 +5002,13 @@ func (a *application) rewriteRefOfJSONObjectAgg(parent SQLNode, node *JSONObject if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4425,6 +5032,9 @@ func (a *application) rewriteRefOfJSONObjectAgg(parent SQLNode, node *JSONObject }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4439,11 +5049,13 @@ func (a *application) rewriteRefOfJSONObjectExpr(parent SQLNode, node *JSONObjec if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4461,6 +5073,9 @@ func (a *application) rewriteRefOfJSONObjectExpr(parent SQLNode, node *JSONObjec return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4475,11 +5090,14 @@ func (a *application) rewriteRefOfJSONObjectParam(parent SQLNode, node *JSONObje if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -4493,6 +5111,9 @@ func (a *application) rewriteRefOfJSONObjectParam(parent SQLNode, node *JSONObje }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4507,11 +5128,13 @@ func (a *application) rewriteRefOfJSONOverlapsExpr(parent SQLNode, node *JSONOve if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4530,6 +5153,9 @@ func (a *application) rewriteRefOfJSONOverlapsExpr(parent SQLNode, node *JSONOve }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4544,11 +5170,13 @@ func (a *application) rewriteRefOfJSONPrettyExpr(parent SQLNode, node *JSONPrett if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4562,6 +5190,9 @@ func (a *application) rewriteRefOfJSONPrettyExpr(parent SQLNode, node *JSONPrett }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4576,11 +5207,13 @@ func (a *application) rewriteRefOfJSONQuoteExpr(parent SQLNode, node *JSONQuoteE if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4594,6 +5227,9 @@ func (a *application) rewriteRefOfJSONQuoteExpr(parent SQLNode, node *JSONQuoteE }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4608,11 +5244,13 @@ func (a *application) rewriteRefOfJSONRemoveExpr(parent SQLNode, node *JSONRemov if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4631,6 +5269,9 @@ func (a *application) rewriteRefOfJSONRemoveExpr(parent SQLNode, node *JSONRemov }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4645,11 +5286,13 @@ func (a *application) rewriteRefOfJSONSchemaValidFuncExpr(parent SQLNode, node * if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4668,6 +5311,9 @@ func (a *application) rewriteRefOfJSONSchemaValidFuncExpr(parent SQLNode, node * }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4682,11 +5328,13 @@ func (a *application) rewriteRefOfJSONSchemaValidationReportFuncExpr(parent SQLN if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4705,6 +5353,9 @@ func (a *application) rewriteRefOfJSONSchemaValidationReportFuncExpr(parent SQLN }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4719,11 +5370,13 @@ func (a *application) rewriteRefOfJSONSearchExpr(parent SQLNode, node *JSONSearc if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4761,6 +5414,9 @@ func (a *application) rewriteRefOfJSONSearchExpr(parent SQLNode, node *JSONSearc return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4775,11 +5431,13 @@ func (a *application) rewriteRefOfJSONStorageFreeExpr(parent SQLNode, node *JSON if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4793,6 +5451,9 @@ func (a *application) rewriteRefOfJSONStorageFreeExpr(parent SQLNode, node *JSON }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4807,11 +5468,13 @@ func (a *application) rewriteRefOfJSONStorageSizeExpr(parent SQLNode, node *JSON if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4825,6 +5488,9 @@ func (a *application) rewriteRefOfJSONStorageSizeExpr(parent SQLNode, node *JSON }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4839,11 +5505,14 @@ func (a *application) rewriteRefOfJSONTableExpr(parent SQLNode, node *JSONTableE if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -4871,6 +5540,9 @@ func (a *application) rewriteRefOfJSONTableExpr(parent SQLNode, node *JSONTableE return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4885,11 +5557,13 @@ func (a *application) rewriteRefOfJSONUnquoteExpr(parent SQLNode, node *JSONUnqu if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4903,6 +5577,9 @@ func (a *application) rewriteRefOfJSONUnquoteExpr(parent SQLNode, node *JSONUnqu }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4917,11 +5594,13 @@ func (a *application) rewriteRefOfJSONValueExpr(parent SQLNode, node *JSONValueE if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4955,6 +5634,9 @@ func (a *application) rewriteRefOfJSONValueExpr(parent SQLNode, node *JSONValueE }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4969,11 +5651,13 @@ func (a *application) rewriteRefOfJSONValueMergeExpr(parent SQLNode, node *JSONV if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -4992,6 +5676,9 @@ func (a *application) rewriteRefOfJSONValueMergeExpr(parent SQLNode, node *JSONV }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5006,11 +5693,13 @@ func (a *application) rewriteRefOfJSONValueModifierExpr(parent SQLNode, node *JS if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5033,6 +5722,9 @@ func (a *application) rewriteRefOfJSONValueModifierExpr(parent SQLNode, node *JS return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5047,11 +5739,14 @@ func (a *application) rewriteRefOfJoinCondition(parent SQLNode, node *JoinCondit if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -5065,6 +5760,9 @@ func (a *application) rewriteRefOfJoinCondition(parent SQLNode, node *JoinCondit }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5079,11 +5777,14 @@ func (a *application) rewriteRefOfJoinTableExpr(parent SQLNode, node *JoinTableE if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -5102,6 +5803,9 @@ func (a *application) rewriteRefOfJoinTableExpr(parent SQLNode, node *JoinTableE }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5116,14 +5820,20 @@ func (a *application) rewriteRefOfJtColumnDefinition(parent SQLNode, node *JtCol if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -5140,11 +5850,14 @@ func (a *application) rewriteRefOfJtOnResponse(parent SQLNode, node *JtOnRespons if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -5153,6 +5866,9 @@ func (a *application) rewriteRefOfJtOnResponse(parent SQLNode, node *JtOnRespons }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5167,14 +5883,20 @@ func (a *application) rewriteRefOfKeyState(parent SQLNode, node *KeyState, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -5191,14 +5913,20 @@ func (a *application) rewriteRefOfKill(parent SQLNode, node *Kill, replacer repl if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -5215,11 +5943,13 @@ func (a *application) rewriteRefOfLagLeadExpr(parent SQLNode, node *LagLeadExpr, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5253,6 +5983,9 @@ func (a *application) rewriteRefOfLagLeadExpr(parent SQLNode, node *LagLeadExpr, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5267,11 +6000,14 @@ func (a *application) rewriteRefOfLimit(parent SQLNode, node *Limit, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -5285,6 +6021,9 @@ func (a *application) rewriteRefOfLimit(parent SQLNode, node *Limit, replacer re }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5299,11 +6038,13 @@ func (a *application) rewriteRefOfLineStringExpr(parent SQLNode, node *LineStrin if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5317,6 +6058,9 @@ func (a *application) rewriteRefOfLineStringExpr(parent SQLNode, node *LineStrin }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5331,11 +6075,13 @@ func (a *application) rewriteRefOfLinestrPropertyFuncExpr(parent SQLNode, node * if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5354,6 +6100,9 @@ func (a *application) rewriteRefOfLinestrPropertyFuncExpr(parent SQLNode, node * }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5368,11 +6117,13 @@ func (a *application) rewriteRefOfLiteral(parent SQLNode, node *Literal, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5381,6 +6132,9 @@ func (a *application) rewriteRefOfLiteral(parent SQLNode, node *Literal, replace return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -5397,14 +6151,20 @@ func (a *application) rewriteRefOfLoad(parent SQLNode, node *Load, replacer repl if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -5421,11 +6181,13 @@ func (a *application) rewriteRefOfLocateExpr(parent SQLNode, node *LocateExpr, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5449,6 +6211,9 @@ func (a *application) rewriteRefOfLocateExpr(parent SQLNode, node *LocateExpr, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5463,14 +6228,20 @@ func (a *application) rewriteRefOfLockOption(parent SQLNode, node *LockOption, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -5487,14 +6258,20 @@ func (a *application) rewriteRefOfLockTables(parent SQLNode, node *LockTables, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -5511,11 +6288,13 @@ func (a *application) rewriteRefOfLockingFunc(parent SQLNode, node *LockingFunc, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5534,6 +6313,9 @@ func (a *application) rewriteRefOfLockingFunc(parent SQLNode, node *LockingFunc, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5548,11 +6330,13 @@ func (a *application) rewriteRefOfMatchExpr(parent SQLNode, node *MatchExpr, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5575,6 +6359,9 @@ func (a *application) rewriteRefOfMatchExpr(parent SQLNode, node *MatchExpr, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5589,11 +6376,13 @@ func (a *application) rewriteRefOfMax(parent SQLNode, node *Max, replacer replac if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5612,6 +6401,9 @@ func (a *application) rewriteRefOfMax(parent SQLNode, node *Max, replacer replac }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5626,11 +6418,13 @@ func (a *application) rewriteRefOfMemberOfExpr(parent SQLNode, node *MemberOfExp if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5649,6 +6443,9 @@ func (a *application) rewriteRefOfMemberOfExpr(parent SQLNode, node *MemberOfExp }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5663,11 +6460,13 @@ func (a *application) rewriteRefOfMin(parent SQLNode, node *Min, replacer replac if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5686,6 +6485,9 @@ func (a *application) rewriteRefOfMin(parent SQLNode, node *Min, replacer replac }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5700,11 +6502,14 @@ func (a *application) rewriteRefOfModifyColumn(parent SQLNode, node *ModifyColum if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -5718,6 +6523,9 @@ func (a *application) rewriteRefOfModifyColumn(parent SQLNode, node *ModifyColum }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5732,11 +6540,13 @@ func (a *application) rewriteRefOfMultiLinestringExpr(parent SQLNode, node *Mult if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5750,6 +6560,9 @@ func (a *application) rewriteRefOfMultiLinestringExpr(parent SQLNode, node *Mult }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5764,11 +6577,13 @@ func (a *application) rewriteRefOfMultiPointExpr(parent SQLNode, node *MultiPoin if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5782,6 +6597,9 @@ func (a *application) rewriteRefOfMultiPointExpr(parent SQLNode, node *MultiPoin }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5796,11 +6614,13 @@ func (a *application) rewriteRefOfMultiPolygonExpr(parent SQLNode, node *MultiPo if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5814,6 +6634,9 @@ func (a *application) rewriteRefOfMultiPolygonExpr(parent SQLNode, node *MultiPo }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5828,11 +6651,13 @@ func (a *application) rewriteRefOfNTHValueExpr(parent SQLNode, node *NTHValueExp if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5866,6 +6691,9 @@ func (a *application) rewriteRefOfNTHValueExpr(parent SQLNode, node *NTHValueExp }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5880,11 +6708,13 @@ func (a *application) rewriteRefOfNamedWindow(parent SQLNode, node *NamedWindow, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5898,6 +6728,9 @@ func (a *application) rewriteRefOfNamedWindow(parent SQLNode, node *NamedWindow, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5912,11 +6745,13 @@ func (a *application) rewriteNamedWindows(parent SQLNode, node NamedWindows, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(NamedWindows) a.cur.revisit = false @@ -5935,6 +6770,9 @@ func (a *application) rewriteNamedWindows(parent SQLNode, node NamedWindows, rep return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5949,11 +6787,14 @@ func (a *application) rewriteRefOfNextval(parent SQLNode, node *Nextval, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -5962,6 +6803,9 @@ func (a *application) rewriteRefOfNextval(parent SQLNode, node *Nextval, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -5976,11 +6820,13 @@ func (a *application) rewriteRefOfNotExpr(parent SQLNode, node *NotExpr, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -5994,6 +6840,9 @@ func (a *application) rewriteRefOfNotExpr(parent SQLNode, node *NotExpr, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6008,11 +6857,13 @@ func (a *application) rewriteRefOfNtileExpr(parent SQLNode, node *NtileExpr, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -6031,6 +6882,9 @@ func (a *application) rewriteRefOfNtileExpr(parent SQLNode, node *NtileExpr, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6045,14 +6899,20 @@ func (a *application) rewriteRefOfNullTreatmentClause(parent SQLNode, node *Null if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -6069,11 +6929,13 @@ func (a *application) rewriteRefOfNullVal(parent SQLNode, node *NullVal, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -6082,6 +6944,9 @@ func (a *application) rewriteRefOfNullVal(parent SQLNode, node *NullVal, replace return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -6098,11 +6963,13 @@ func (a *application) rewriteRefOfOffset(parent SQLNode, node *Offset, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -6116,6 +6983,9 @@ func (a *application) rewriteRefOfOffset(parent SQLNode, node *Offset, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6130,11 +7000,13 @@ func (a *application) rewriteOnDup(parent SQLNode, node OnDup, replacer replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(OnDup) a.cur.revisit = false @@ -6153,6 +7025,9 @@ func (a *application) rewriteOnDup(parent SQLNode, node OnDup, replacer replacer return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6167,11 +7042,14 @@ func (a *application) rewriteRefOfOptLike(parent SQLNode, node *OptLike, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6180,6 +7058,9 @@ func (a *application) rewriteRefOfOptLike(parent SQLNode, node *OptLike, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6194,11 +7075,13 @@ func (a *application) rewriteRefOfOrExpr(parent SQLNode, node *OrExpr, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -6217,6 +7100,9 @@ func (a *application) rewriteRefOfOrExpr(parent SQLNode, node *OrExpr, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6231,11 +7117,14 @@ func (a *application) rewriteRefOfOrder(parent SQLNode, node *Order, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6244,6 +7133,9 @@ func (a *application) rewriteRefOfOrder(parent SQLNode, node *Order, replacer re }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6258,11 +7150,13 @@ func (a *application) rewriteOrderBy(parent SQLNode, node OrderBy, replacer repl if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(OrderBy) a.cur.revisit = false @@ -6281,6 +7175,9 @@ func (a *application) rewriteOrderBy(parent SQLNode, node OrderBy, replacer repl return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6295,11 +7192,14 @@ func (a *application) rewriteRefOfOrderByOption(parent SQLNode, node *OrderByOpt if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6308,6 +7208,9 @@ func (a *application) rewriteRefOfOrderByOption(parent SQLNode, node *OrderByOpt }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6322,14 +7225,20 @@ func (a *application) rewriteRefOfOtherAdmin(parent SQLNode, node *OtherAdmin, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -6346,11 +7255,14 @@ func (a *application) rewriteRefOfOverClause(parent SQLNode, node *OverClause, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6364,6 +7276,9 @@ func (a *application) rewriteRefOfOverClause(parent SQLNode, node *OverClause, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6378,11 +7293,14 @@ func (a *application) rewriteRefOfParenTableExpr(parent SQLNode, node *ParenTabl if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6391,6 +7309,9 @@ func (a *application) rewriteRefOfParenTableExpr(parent SQLNode, node *ParenTabl }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6405,14 +7326,20 @@ func (a *application) rewriteRefOfParsedComments(parent SQLNode, node *ParsedCom if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -6429,11 +7356,14 @@ func (a *application) rewriteRefOfPartitionDefinition(parent SQLNode, node *Part if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6447,6 +7377,9 @@ func (a *application) rewriteRefOfPartitionDefinition(parent SQLNode, node *Part }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6461,11 +7394,14 @@ func (a *application) rewriteRefOfPartitionDefinitionOptions(parent SQLNode, nod if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6499,6 +7435,9 @@ func (a *application) rewriteRefOfPartitionDefinitionOptions(parent SQLNode, nod }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6513,14 +7452,20 @@ func (a *application) rewriteRefOfPartitionEngine(parent SQLNode, node *Partitio if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -6537,11 +7482,14 @@ func (a *application) rewriteRefOfPartitionOption(parent SQLNode, node *Partitio if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6569,6 +7517,9 @@ func (a *application) rewriteRefOfPartitionOption(parent SQLNode, node *Partitio return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6583,11 +7534,14 @@ func (a *application) rewriteRefOfPartitionSpec(parent SQLNode, node *PartitionS if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6615,6 +7569,9 @@ func (a *application) rewriteRefOfPartitionSpec(parent SQLNode, node *PartitionS return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6629,11 +7586,14 @@ func (a *application) rewriteRefOfPartitionValueRange(parent SQLNode, node *Part if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6642,6 +7602,9 @@ func (a *application) rewriteRefOfPartitionValueRange(parent SQLNode, node *Part }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6656,11 +7619,13 @@ func (a *application) rewritePartitions(parent SQLNode, node Partitions, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(Partitions) a.cur.revisit = false @@ -6679,6 +7644,9 @@ func (a *application) rewritePartitions(parent SQLNode, node Partitions, replace return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6693,11 +7661,13 @@ func (a *application) rewriteRefOfPerformanceSchemaFuncExpr(parent SQLNode, node if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -6711,6 +7681,9 @@ func (a *application) rewriteRefOfPerformanceSchemaFuncExpr(parent SQLNode, node }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6725,11 +7698,13 @@ func (a *application) rewriteRefOfPointExpr(parent SQLNode, node *PointExpr, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -6748,6 +7723,9 @@ func (a *application) rewriteRefOfPointExpr(parent SQLNode, node *PointExpr, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6762,11 +7740,13 @@ func (a *application) rewriteRefOfPointPropertyFuncExpr(parent SQLNode, node *Po if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -6785,6 +7765,9 @@ func (a *application) rewriteRefOfPointPropertyFuncExpr(parent SQLNode, node *Po }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6799,11 +7782,13 @@ func (a *application) rewriteRefOfPolygonExpr(parent SQLNode, node *PolygonExpr, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -6817,6 +7802,9 @@ func (a *application) rewriteRefOfPolygonExpr(parent SQLNode, node *PolygonExpr, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6831,11 +7819,13 @@ func (a *application) rewriteRefOfPolygonPropertyFuncExpr(parent SQLNode, node * if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -6854,6 +7844,9 @@ func (a *application) rewriteRefOfPolygonPropertyFuncExpr(parent SQLNode, node * }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6868,11 +7861,14 @@ func (a *application) rewriteRefOfPrepareStmt(parent SQLNode, node *PrepareStmt, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6891,6 +7887,9 @@ func (a *application) rewriteRefOfPrepareStmt(parent SQLNode, node *PrepareStmt, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6905,14 +7904,20 @@ func (a *application) rewriteRefOfPurgeBinaryLogs(parent SQLNode, node *PurgeBin if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -6929,11 +7934,14 @@ func (a *application) rewriteRefOfReferenceDefinition(parent SQLNode, node *Refe if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -6962,6 +7970,9 @@ func (a *application) rewriteRefOfReferenceDefinition(parent SQLNode, node *Refe }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -6976,11 +7987,13 @@ func (a *application) rewriteRefOfRegexpInstrExpr(parent SQLNode, node *RegexpIn if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -7019,6 +8032,9 @@ func (a *application) rewriteRefOfRegexpInstrExpr(parent SQLNode, node *RegexpIn }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7033,11 +8049,13 @@ func (a *application) rewriteRefOfRegexpLikeExpr(parent SQLNode, node *RegexpLik if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -7061,6 +8079,9 @@ func (a *application) rewriteRefOfRegexpLikeExpr(parent SQLNode, node *RegexpLik }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7075,11 +8096,13 @@ func (a *application) rewriteRefOfRegexpReplaceExpr(parent SQLNode, node *Regexp if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -7118,6 +8141,9 @@ func (a *application) rewriteRefOfRegexpReplaceExpr(parent SQLNode, node *Regexp }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7132,11 +8158,13 @@ func (a *application) rewriteRefOfRegexpSubstrExpr(parent SQLNode, node *RegexpS if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -7170,6 +8198,9 @@ func (a *application) rewriteRefOfRegexpSubstrExpr(parent SQLNode, node *RegexpS }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7184,11 +8215,14 @@ func (a *application) rewriteRefOfRelease(parent SQLNode, node *Release, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7197,6 +8231,9 @@ func (a *application) rewriteRefOfRelease(parent SQLNode, node *Release, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7211,11 +8248,14 @@ func (a *application) rewriteRefOfRenameColumn(parent SQLNode, node *RenameColum if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7229,6 +8269,9 @@ func (a *application) rewriteRefOfRenameColumn(parent SQLNode, node *RenameColum }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7243,11 +8286,14 @@ func (a *application) rewriteRefOfRenameIndex(parent SQLNode, node *RenameIndex, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7261,6 +8307,9 @@ func (a *application) rewriteRefOfRenameIndex(parent SQLNode, node *RenameIndex, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7275,14 +8324,20 @@ func (a *application) rewriteRefOfRenameTable(parent SQLNode, node *RenameTable, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -7299,11 +8354,14 @@ func (a *application) rewriteRefOfRenameTableName(parent SQLNode, node *RenameTa if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7312,6 +8370,9 @@ func (a *application) rewriteRefOfRenameTableName(parent SQLNode, node *RenameTa }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7326,11 +8387,14 @@ func (a *application) rewriteRefOfRevertMigration(parent SQLNode, node *RevertMi if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7339,6 +8403,9 @@ func (a *application) rewriteRefOfRevertMigration(parent SQLNode, node *RevertMi }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7353,14 +8420,20 @@ func (a *application) rewriteRefOfRollback(parent SQLNode, node *Rollback, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -7374,11 +8447,14 @@ func (a *application) rewriteRefOfRollback(parent SQLNode, node *Rollback, repla return true } func (a *application) rewriteRootNode(parent SQLNode, node RootNode, replacer replacerFunc) bool { + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7387,6 +8463,9 @@ func (a *application) rewriteRootNode(parent SQLNode, node RootNode, replacer re }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7401,11 +8480,14 @@ func (a *application) rewriteRefOfRowAlias(parent SQLNode, node *RowAlias, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7419,6 +8501,9 @@ func (a *application) rewriteRefOfRowAlias(parent SQLNode, node *RowAlias, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7433,11 +8518,14 @@ func (a *application) rewriteRefOfSRollback(parent SQLNode, node *SRollback, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7446,6 +8534,9 @@ func (a *application) rewriteRefOfSRollback(parent SQLNode, node *SRollback, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7460,11 +8551,14 @@ func (a *application) rewriteRefOfSavepoint(parent SQLNode, node *Savepoint, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7473,6 +8567,9 @@ func (a *application) rewriteRefOfSavepoint(parent SQLNode, node *Savepoint, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7487,11 +8584,14 @@ func (a *application) rewriteRefOfSelect(parent SQLNode, node *Select, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7554,6 +8654,9 @@ func (a *application) rewriteRefOfSelect(parent SQLNode, node *Select, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7568,11 +8671,13 @@ func (a *application) rewriteSelectExprs(parent SQLNode, node SelectExprs, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(SelectExprs) a.cur.revisit = false @@ -7591,6 +8696,9 @@ func (a *application) rewriteSelectExprs(parent SQLNode, node SelectExprs, repla return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7605,14 +8713,20 @@ func (a *application) rewriteRefOfSelectInto(parent SQLNode, node *SelectInto, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -7629,11 +8743,14 @@ func (a *application) rewriteRefOfSet(parent SQLNode, node *Set, replacer replac if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7647,6 +8764,9 @@ func (a *application) rewriteRefOfSet(parent SQLNode, node *Set, replacer replac }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7661,11 +8781,14 @@ func (a *application) rewriteRefOfSetExpr(parent SQLNode, node *SetExpr, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7679,6 +8802,9 @@ func (a *application) rewriteRefOfSetExpr(parent SQLNode, node *SetExpr, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7693,11 +8819,13 @@ func (a *application) rewriteSetExprs(parent SQLNode, node SetExprs, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(SetExprs) a.cur.revisit = false @@ -7716,6 +8844,9 @@ func (a *application) rewriteSetExprs(parent SQLNode, node SetExprs, replacer re return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7730,11 +8861,14 @@ func (a *application) rewriteRefOfShow(parent SQLNode, node *Show, replacer repl if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7743,6 +8877,9 @@ func (a *application) rewriteRefOfShow(parent SQLNode, node *Show, replacer repl }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7757,11 +8894,14 @@ func (a *application) rewriteRefOfShowBasic(parent SQLNode, node *ShowBasic, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7780,6 +8920,9 @@ func (a *application) rewriteRefOfShowBasic(parent SQLNode, node *ShowBasic, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7794,11 +8937,14 @@ func (a *application) rewriteRefOfShowCreate(parent SQLNode, node *ShowCreate, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7807,6 +8953,9 @@ func (a *application) rewriteRefOfShowCreate(parent SQLNode, node *ShowCreate, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7821,11 +8970,14 @@ func (a *application) rewriteRefOfShowFilter(parent SQLNode, node *ShowFilter, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7834,6 +8986,9 @@ func (a *application) rewriteRefOfShowFilter(parent SQLNode, node *ShowFilter, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7848,11 +9003,14 @@ func (a *application) rewriteRefOfShowMigrationLogs(parent SQLNode, node *ShowMi if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7861,6 +9019,9 @@ func (a *application) rewriteRefOfShowMigrationLogs(parent SQLNode, node *ShowMi }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7875,14 +9036,20 @@ func (a *application) rewriteRefOfShowOther(parent SQLNode, node *ShowOther, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -7899,14 +9066,20 @@ func (a *application) rewriteRefOfShowThrottledApps(parent SQLNode, node *ShowTh if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -7923,14 +9096,20 @@ func (a *application) rewriteRefOfShowThrottlerStatus(parent SQLNode, node *Show if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -7947,14 +9126,20 @@ func (a *application) rewriteRefOfShowTransactionStatus(parent SQLNode, node *Sh if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -7971,11 +9156,14 @@ func (a *application) rewriteRefOfStarExpr(parent SQLNode, node *StarExpr, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -7984,6 +9172,9 @@ func (a *application) rewriteRefOfStarExpr(parent SQLNode, node *StarExpr, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -7998,11 +9189,13 @@ func (a *application) rewriteRefOfStd(parent SQLNode, node *Std, replacer replac if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -8021,6 +9214,9 @@ func (a *application) rewriteRefOfStd(parent SQLNode, node *Std, replacer replac }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8035,11 +9231,13 @@ func (a *application) rewriteRefOfStdDev(parent SQLNode, node *StdDev, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -8058,6 +9256,9 @@ func (a *application) rewriteRefOfStdDev(parent SQLNode, node *StdDev, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8072,11 +9273,13 @@ func (a *application) rewriteRefOfStdPop(parent SQLNode, node *StdPop, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -8095,6 +9298,9 @@ func (a *application) rewriteRefOfStdPop(parent SQLNode, node *StdPop, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8109,11 +9315,13 @@ func (a *application) rewriteRefOfStdSamp(parent SQLNode, node *StdSamp, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -8132,6 +9340,9 @@ func (a *application) rewriteRefOfStdSamp(parent SQLNode, node *StdSamp, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8146,11 +9357,14 @@ func (a *application) rewriteRefOfStream(parent SQLNode, node *Stream, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -8169,6 +9383,9 @@ func (a *application) rewriteRefOfStream(parent SQLNode, node *Stream, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8183,11 +9400,14 @@ func (a *application) rewriteRefOfSubPartition(parent SQLNode, node *SubPartitio if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -8201,6 +9421,9 @@ func (a *application) rewriteRefOfSubPartition(parent SQLNode, node *SubPartitio }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8215,11 +9438,14 @@ func (a *application) rewriteRefOfSubPartitionDefinition(parent SQLNode, node *S if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -8233,6 +9459,9 @@ func (a *application) rewriteRefOfSubPartitionDefinition(parent SQLNode, node *S }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8247,11 +9476,14 @@ func (a *application) rewriteRefOfSubPartitionDefinitionOptions(parent SQLNode, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -8275,6 +9507,9 @@ func (a *application) rewriteRefOfSubPartitionDefinitionOptions(parent SQLNode, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8289,11 +9524,13 @@ func (a *application) rewriteSubPartitionDefinitions(parent SQLNode, node SubPar if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(SubPartitionDefinitions) a.cur.revisit = false @@ -8312,6 +9549,9 @@ func (a *application) rewriteSubPartitionDefinitions(parent SQLNode, node SubPar return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8326,11 +9566,13 @@ func (a *application) rewriteRefOfSubquery(parent SQLNode, node *Subquery, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -8344,6 +9586,9 @@ func (a *application) rewriteRefOfSubquery(parent SQLNode, node *Subquery, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8358,11 +9603,13 @@ func (a *application) rewriteRefOfSubstrExpr(parent SQLNode, node *SubstrExpr, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -8386,6 +9633,9 @@ func (a *application) rewriteRefOfSubstrExpr(parent SQLNode, node *SubstrExpr, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8400,11 +9650,13 @@ func (a *application) rewriteRefOfSum(parent SQLNode, node *Sum, replacer replac if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -8423,6 +9675,9 @@ func (a *application) rewriteRefOfSum(parent SQLNode, node *Sum, replacer replac }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8437,11 +9692,13 @@ func (a *application) rewriteTableExprs(parent SQLNode, node TableExprs, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(TableExprs) a.cur.revisit = false @@ -8460,6 +9717,9 @@ func (a *application) rewriteTableExprs(parent SQLNode, node TableExprs, replace return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8471,11 +9731,14 @@ func (a *application) rewriteTableExprs(parent SQLNode, node TableExprs, replace return true } func (a *application) rewriteTableName(parent SQLNode, node TableName, replacer replacerFunc) bool { + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -8489,6 +9752,9 @@ func (a *application) rewriteTableName(parent SQLNode, node TableName, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8503,11 +9769,13 @@ func (a *application) rewriteTableNames(parent SQLNode, node TableNames, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(TableNames) a.cur.revisit = false @@ -8526,6 +9794,9 @@ func (a *application) rewriteTableNames(parent SQLNode, node TableNames, replace return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8540,11 +9811,13 @@ func (a *application) rewriteTableOptions(parent SQLNode, node TableOptions, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(TableOptions) a.cur.revisit = false @@ -8554,6 +9827,9 @@ func (a *application) rewriteTableOptions(parent SQLNode, node TableOptions, rep return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -8570,11 +9846,14 @@ func (a *application) rewriteRefOfTableSpec(parent SQLNode, node *TableSpec, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -8615,6 +9894,9 @@ func (a *application) rewriteRefOfTableSpec(parent SQLNode, node *TableSpec, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8629,14 +9911,20 @@ func (a *application) rewriteRefOfTablespaceOperation(parent SQLNode, node *Tabl if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -8653,11 +9941,13 @@ func (a *application) rewriteRefOfTimestampDiffExpr(parent SQLNode, node *Timest if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -8676,6 +9966,9 @@ func (a *application) rewriteRefOfTimestampDiffExpr(parent SQLNode, node *Timest }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8690,11 +9983,13 @@ func (a *application) rewriteRefOfTrimFuncExpr(parent SQLNode, node *TrimFuncExp if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -8713,6 +10008,9 @@ func (a *application) rewriteRefOfTrimFuncExpr(parent SQLNode, node *TrimFuncExp }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8727,11 +10025,14 @@ func (a *application) rewriteRefOfTruncateTable(parent SQLNode, node *TruncateTa if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -8740,6 +10041,9 @@ func (a *application) rewriteRefOfTruncateTable(parent SQLNode, node *TruncateTa }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8754,11 +10058,13 @@ func (a *application) rewriteRefOfUnaryExpr(parent SQLNode, node *UnaryExpr, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -8772,6 +10078,9 @@ func (a *application) rewriteRefOfUnaryExpr(parent SQLNode, node *UnaryExpr, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8786,11 +10095,14 @@ func (a *application) rewriteRefOfUnion(parent SQLNode, node *Union, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -8824,6 +10136,9 @@ func (a *application) rewriteRefOfUnion(parent SQLNode, node *Union, replacer re }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8838,14 +10153,20 @@ func (a *application) rewriteRefOfUnlockTables(parent SQLNode, node *UnlockTable if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -8862,11 +10183,14 @@ func (a *application) rewriteRefOfUpdate(parent SQLNode, node *Update, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -8909,6 +10233,9 @@ func (a *application) rewriteRefOfUpdate(parent SQLNode, node *Update, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8923,11 +10250,14 @@ func (a *application) rewriteRefOfUpdateExpr(parent SQLNode, node *UpdateExpr, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -8941,6 +10271,9 @@ func (a *application) rewriteRefOfUpdateExpr(parent SQLNode, node *UpdateExpr, r }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8955,11 +10288,13 @@ func (a *application) rewriteUpdateExprs(parent SQLNode, node UpdateExprs, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(UpdateExprs) a.cur.revisit = false @@ -8978,6 +10313,9 @@ func (a *application) rewriteUpdateExprs(parent SQLNode, node UpdateExprs, repla return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -8992,11 +10330,13 @@ func (a *application) rewriteRefOfUpdateXMLExpr(parent SQLNode, node *UpdateXMLE if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -9020,6 +10360,9 @@ func (a *application) rewriteRefOfUpdateXMLExpr(parent SQLNode, node *UpdateXMLE }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9034,11 +10377,14 @@ func (a *application) rewriteRefOfUse(parent SQLNode, node *Use, replacer replac if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9047,6 +10393,9 @@ func (a *application) rewriteRefOfUse(parent SQLNode, node *Use, replacer replac }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9061,11 +10410,14 @@ func (a *application) rewriteRefOfVExplainStmt(parent SQLNode, node *VExplainStm if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9079,6 +10431,9 @@ func (a *application) rewriteRefOfVExplainStmt(parent SQLNode, node *VExplainStm }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9093,11 +10448,14 @@ func (a *application) rewriteRefOfVStream(parent SQLNode, node *VStream, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9126,6 +10484,9 @@ func (a *application) rewriteRefOfVStream(parent SQLNode, node *VStream, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9140,11 +10501,13 @@ func (a *application) rewriteValTuple(parent SQLNode, node ValTuple, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(ValTuple) a.cur.revisit = false @@ -9163,6 +10526,9 @@ func (a *application) rewriteValTuple(parent SQLNode, node ValTuple, replacer re return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9177,14 +10543,20 @@ func (a *application) rewriteRefOfValidation(parent SQLNode, node *Validation, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -9201,11 +10573,13 @@ func (a *application) rewriteValues(parent SQLNode, node Values, replacer replac if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(Values) a.cur.revisit = false @@ -9224,6 +10598,9 @@ func (a *application) rewriteValues(parent SQLNode, node Values, replacer replac return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9238,11 +10615,13 @@ func (a *application) rewriteRefOfValuesFuncExpr(parent SQLNode, node *ValuesFun if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -9256,6 +10635,9 @@ func (a *application) rewriteRefOfValuesFuncExpr(parent SQLNode, node *ValuesFun }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9270,11 +10652,14 @@ func (a *application) rewriteRefOfValuesStatement(parent SQLNode, node *ValuesSt if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9308,6 +10693,9 @@ func (a *application) rewriteRefOfValuesStatement(parent SQLNode, node *ValuesSt }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9322,11 +10710,13 @@ func (a *application) rewriteRefOfVarPop(parent SQLNode, node *VarPop, replacer if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -9345,6 +10735,9 @@ func (a *application) rewriteRefOfVarPop(parent SQLNode, node *VarPop, replacer }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9359,11 +10752,13 @@ func (a *application) rewriteRefOfVarSamp(parent SQLNode, node *VarSamp, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -9382,6 +10777,9 @@ func (a *application) rewriteRefOfVarSamp(parent SQLNode, node *VarSamp, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9396,11 +10794,13 @@ func (a *application) rewriteRefOfVariable(parent SQLNode, node *Variable, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -9414,6 +10814,9 @@ func (a *application) rewriteRefOfVariable(parent SQLNode, node *Variable, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9428,11 +10831,13 @@ func (a *application) rewriteRefOfVariance(parent SQLNode, node *Variance, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -9451,6 +10856,9 @@ func (a *application) rewriteRefOfVariance(parent SQLNode, node *Variance, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9462,11 +10870,14 @@ func (a *application) rewriteRefOfVariance(parent SQLNode, node *Variance, repla return true } func (a *application) rewriteVindexParam(parent SQLNode, node VindexParam, replacer replacerFunc) bool { + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9475,6 +10886,9 @@ func (a *application) rewriteVindexParam(parent SQLNode, node VindexParam, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9489,11 +10903,14 @@ func (a *application) rewriteRefOfVindexSpec(parent SQLNode, node *VindexSpec, r if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9516,6 +10933,9 @@ func (a *application) rewriteRefOfVindexSpec(parent SQLNode, node *VindexSpec, r return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9530,11 +10950,13 @@ func (a *application) rewriteRefOfWeightStringFuncExpr(parent SQLNode, node *Wei if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -9553,6 +10975,9 @@ func (a *application) rewriteRefOfWeightStringFuncExpr(parent SQLNode, node *Wei }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9567,11 +10992,14 @@ func (a *application) rewriteRefOfWhen(parent SQLNode, node *When, replacer repl if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9585,6 +11013,9 @@ func (a *application) rewriteRefOfWhen(parent SQLNode, node *When, replacer repl }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9599,11 +11030,14 @@ func (a *application) rewriteRefOfWhere(parent SQLNode, node *Where, replacer re if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9612,6 +11046,9 @@ func (a *application) rewriteRefOfWhere(parent SQLNode, node *Where, replacer re }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9626,11 +11063,14 @@ func (a *application) rewriteRefOfWindowDefinition(parent SQLNode, node *WindowD if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9644,6 +11084,9 @@ func (a *application) rewriteRefOfWindowDefinition(parent SQLNode, node *WindowD }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9658,11 +11101,13 @@ func (a *application) rewriteWindowDefinitions(parent SQLNode, node WindowDefini if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { node = a.cur.node.(WindowDefinitions) a.cur.revisit = false @@ -9681,6 +11126,9 @@ func (a *application) rewriteWindowDefinitions(parent SQLNode, node WindowDefini return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9695,11 +11143,14 @@ func (a *application) rewriteRefOfWindowSpecification(parent SQLNode, node *Wind if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9723,6 +11174,9 @@ func (a *application) rewriteRefOfWindowSpecification(parent SQLNode, node *Wind }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9737,11 +11191,14 @@ func (a *application) rewriteRefOfWith(parent SQLNode, node *With, replacer repl if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -9754,6 +11211,9 @@ func (a *application) rewriteRefOfWith(parent SQLNode, node *With, replacer repl return false } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -9768,11 +11228,13 @@ func (a *application) rewriteRefOfXorExpr(parent SQLNode, node *XorExpr, replace if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -9791,6 +11253,9 @@ func (a *application) rewriteRefOfXorExpr(parent SQLNode, node *XorExpr, replace }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -10626,14 +12091,20 @@ func (a *application) rewriteTableStatement(parent SQLNode, node TableStatement, } } func (a *application) rewriteAlgorithmValue(parent SQLNode, node AlgorithmValue, replacer replacerFunc) bool { + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -10647,11 +12118,13 @@ func (a *application) rewriteAlgorithmValue(parent SQLNode, node AlgorithmValue, return true } func (a *application) rewriteBoolVal(parent SQLNode, node BoolVal, replacer replacerFunc) bool { + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -10660,6 +12133,9 @@ func (a *application) rewriteBoolVal(parent SQLNode, node BoolVal, replacer repl return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -10673,11 +12149,13 @@ func (a *application) rewriteBoolVal(parent SQLNode, node BoolVal, replacer repl return true } func (a *application) rewriteListArg(parent SQLNode, node ListArg, replacer replacerFunc) bool { + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil if a.cur.revisit { a.cur.revisit = false return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) @@ -10686,6 +12164,9 @@ func (a *application) rewriteListArg(parent SQLNode, node ListArg, replacer repl return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -10699,14 +12180,20 @@ func (a *application) rewriteListArg(parent SQLNode, node ListArg, replacer repl return true } func (a *application) rewriteMatchAction(parent SQLNode, node MatchAction, replacer replacerFunc) bool { + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -10720,14 +12207,20 @@ func (a *application) rewriteMatchAction(parent SQLNode, node MatchAction, repla return true } func (a *application) rewriteReferenceAction(parent SQLNode, node ReferenceAction, replacer replacerFunc) bool { + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -10744,14 +12237,20 @@ func (a *application) rewriteRefOfIdentifierCI(parent SQLNode, node *IdentifierC if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -10768,14 +12267,20 @@ func (a *application) rewriteRefOfIdentifierCS(parent SQLNode, node *IdentifierC if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } + if onLeave != nil { + onLeave(node) + } if a.post != nil { if a.pre == nil { a.cur.replacer = replacer @@ -10792,11 +12297,14 @@ func (a *application) rewriteRefOfRootNode(parent SQLNode, node *RootNode, repla if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -10805,6 +12313,9 @@ func (a *application) rewriteRefOfRootNode(parent SQLNode, node *RootNode, repla }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -10819,11 +12330,14 @@ func (a *application) rewriteRefOfTableName(parent SQLNode, node *TableName, rep if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -10837,6 +12351,9 @@ func (a *application) rewriteRefOfTableName(parent SQLNode, node *TableName, rep }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -10851,11 +12368,14 @@ func (a *application) rewriteRefOfVindexParam(parent SQLNode, node *VindexParam, if node == nil { return true } + var onLeave func(SQLNode) if a.pre != nil { a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + onLeave, a.cur.onLeave = a.cur.onLeave, nil + if kontinue { return true } } @@ -10864,6 +12384,9 @@ func (a *application) rewriteRefOfVindexParam(parent SQLNode, node *VindexParam, }) { return false } + if onLeave != nil { + onLeave(node) + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent diff --git a/go/vt/sqlparser/ast_rewrite_test.go b/go/vt/sqlparser/ast_rewrite_test.go new file mode 100644 index 00000000000..4fd0b6fef50 --- /dev/null +++ b/go/vt/sqlparser/ast_rewrite_test.go @@ -0,0 +1,41 @@ +/* +Copyright 2025 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package sqlparser + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestOnLeaveFunctionality(t *testing.T) { + ast, err := NewTestParser().Parse("select * from test_table where a = 1") + require.NoError(t, err) + + var stack []SQLNode + + Rewrite(ast, func(cursor *Cursor) bool { + stack = append(stack, cursor.Node()) + cursor.OnLeave(func(node SQLNode) { + // pop the last element from the stack + last := stack[len(stack)-1] + stack = stack[:len(stack)-1] + require.Equal(t, last, node) + }) + return true + }, nil) +} diff --git a/go/vt/sqlparser/rewriter_api.go b/go/vt/sqlparser/rewriter_api.go index cfcf75fa0f9..6d3a9ecac8a 100644 --- a/go/vt/sqlparser/rewriter_api.go +++ b/go/vt/sqlparser/rewriter_api.go @@ -94,6 +94,7 @@ type Cursor struct { parent SQLNode replacer replacerFunc node SQLNode + onLeave func(SQLNode) // marks that the node has been replaced, and the new node should be visited revisit bool @@ -138,6 +139,11 @@ func (c *Cursor) ReplaceAndRevisit(newNode SQLNode) { c.revisit = true } +// OnLeave registers a function to be called when the cursor leaves the current node, but before the Post visitor is called. +func (c *Cursor) OnLeave(onLeave func(SQLNode)) { + c.onLeave = onLeave +} + type replacerFunc func(newNode, parent SQLNode) // application carries all the shared data so we can pass it around cheaply.