diff --git a/go/test/endtoend/vtgate/queries/random/query_gen.go b/go/test/endtoend/vtgate/queries/random/query_gen.go index 69bf66903f3..d7791d8df08 100644 --- a/go/test/endtoend/vtgate/queries/random/query_gen.go +++ b/go/test/endtoend/vtgate/queries/random/query_gen.go @@ -292,7 +292,7 @@ func (sg *selectGenerator) randomSelect() { } // make sure we have at least one select expression - for isRandomExpr || len(sg.sel.SelectExprs) == 0 { + for isRandomExpr || len(sg.sel.SelectExprs.Exprs) == 0 { // TODO: if the random expression is an int literal, // TODO: and if the query is (potentially) an aggregate query, // TODO: then we must group by the random expression, @@ -395,7 +395,7 @@ func (sg *selectGenerator) createJoin(tables []tableT) { // returns 1-3 random expressions based on the last two elements of tables // tables should have at least two elements -func (sg *selectGenerator) createJoinPredicates(tables []tableT) sqlparser.Exprs { +func (sg *selectGenerator) createJoinPredicates(tables []tableT) []sqlparser.Expr { if len(tables) < 2 { log.Fatalf("tables has %d elements, needs at least 2", len(tables)) } @@ -427,7 +427,7 @@ func (sg *selectGenerator) createGroupBy(tables []tableT) (grouping []column) { // add to select if rand.IntN(2) < 1 { - sg.sel.SelectExprs = append(sg.sel.SelectExprs, newAliasedColumn(col, "")) + sg.sel.AddSelectExpr(newAliasedColumn(col, "")) grouping = append(grouping, col) } } @@ -437,13 +437,13 @@ func (sg *selectGenerator) createGroupBy(tables []tableT) (grouping []column) { // aliasGroupingColumns randomly aliases the grouping columns in the SelectExprs func (sg *selectGenerator) aliasGroupingColumns(grouping []column) []column { - if len(grouping) != len(sg.sel.SelectExprs) { - log.Fatalf("grouping (length: %d) and sg.sel.SelectExprs (length: %d) should have the same length at this point", len(grouping), len(sg.sel.SelectExprs)) + if len(grouping) != len(sg.sel.SelectExprs.Exprs) { + log.Fatalf("grouping (length: %d) and sg.sel.SelectExprs (length: %d) should have the same length at this point", len(grouping), len(sg.sel.SelectExprs.Exprs)) } for i := range grouping { if rand.IntN(2) < 1 { - if aliasedExpr, ok := sg.sel.SelectExprs[i].(*sqlparser.AliasedExpr); ok { + if aliasedExpr, ok := sg.sel.SelectExprs.Exprs[i].(*sqlparser.AliasedExpr); ok { alias := fmt.Sprintf("cgroup%d", i) aliasedExpr.SetAlias(alias) grouping[i].name = alias @@ -454,7 +454,7 @@ func (sg *selectGenerator) aliasGroupingColumns(grouping []column) []column { return grouping } -// returns the aggregation columns as three types: sqlparser.SelectExprs, []column +// returns the aggregation columns as three types: *sqlparser.SelectExprs, []column func (sg *selectGenerator) createAggregations(tables []tableT) (aggregates []column) { exprGenerators := slice.Map(tables, func(t tableT) sqlparser.ExprGenerator { return &t }) // add scalar subqueries @@ -485,7 +485,7 @@ func (sg *selectGenerator) createOrderBy() { } // randomly order on SelectExprs - for _, selExpr := range sg.sel.SelectExprs { + for _, selExpr := range sg.sel.SelectExprs.Exprs { if aliasedExpr, ok := selExpr.(*sqlparser.AliasedExpr); ok && rand.IntN(2) < 1 { literal, ok := aliasedExpr.Expr.(*sqlparser.Literal) isIntLiteral := ok && literal.Type == sqlparser.IntVal @@ -527,7 +527,7 @@ func (sg *selectGenerator) createHavingPredicates(grouping []column) { } // returns between minExprs and maxExprs random expressions using generators -func (sg *selectGenerator) createRandomExprs(minExprs, maxExprs int, generators ...sqlparser.ExprGenerator) (predicates sqlparser.Exprs) { +func (sg *selectGenerator) createRandomExprs(minExprs, maxExprs int, generators ...sqlparser.ExprGenerator) (predicates []sqlparser.Expr) { if minExprs > maxExprs { log.Fatalf("minExprs is greater than maxExprs; minExprs: %d, maxExprs: %d\n", minExprs, maxExprs) } else if maxExprs <= 0 { @@ -578,7 +578,7 @@ func (sg *selectGenerator) randomlyAlias(expr sqlparser.Expr, alias string) colu } else { col.name = alias } - sg.sel.SelectExprs = append(sg.sel.SelectExprs, sqlparser.NewAliasedExpr(expr, alias)) + sg.sel.AddSelectExpr(sqlparser.NewAliasedExpr(expr, alias)) return col } @@ -586,20 +586,20 @@ func (sg *selectGenerator) randomlyAlias(expr sqlparser.Expr, alias string) colu // matchNumCols makes sure sg.sel.SelectExprs and newTable both have the same number of cols: sg.genConfig.NumCols func (sg *selectGenerator) matchNumCols(tables []tableT, newTable tableT, canAggregate bool) tableT { // remove SelectExprs and newTable.cols randomly until there are sg.genConfig.NumCols amount - for len(sg.sel.SelectExprs) > sg.genConfig.NumCols && sg.genConfig.NumCols > 0 { + for len(sg.sel.SelectExprs.Exprs) > sg.genConfig.NumCols && sg.genConfig.NumCols > 0 { // select a random index and remove it from SelectExprs and newTable - idx := rand.IntN(len(sg.sel.SelectExprs)) + idx := rand.IntN(len(sg.sel.SelectExprs.Exprs)) - sg.sel.SelectExprs[idx] = sg.sel.SelectExprs[len(sg.sel.SelectExprs)-1] - sg.sel.SelectExprs = sg.sel.SelectExprs[:len(sg.sel.SelectExprs)-1] + sg.sel.SelectExprs.Exprs[idx] = sg.sel.SelectExprs.Exprs[len(sg.sel.SelectExprs.Exprs)-1] + sg.sel.SelectExprs.Exprs = sg.sel.SelectExprs.Exprs[:len(sg.sel.SelectExprs.Exprs)-1] newTable.cols[idx] = newTable.cols[len(newTable.cols)-1] newTable.cols = newTable.cols[:len(newTable.cols)-1] } // alternatively, add random expressions until there are sg.genConfig.NumCols amount - if sg.genConfig.NumCols > len(sg.sel.SelectExprs) { - diff := sg.genConfig.NumCols - len(sg.sel.SelectExprs) + if sg.genConfig.NumCols > len(sg.sel.SelectExprs.Exprs) { + diff := sg.genConfig.NumCols - len(sg.sel.SelectExprs.Exprs) exprs := sg.createRandomExprs(diff, diff, slice.Map(tables, func(t tableT) sqlparser.ExprGenerator { return &t })...) diff --git a/go/tools/astfmtgen/main.go b/go/tools/astfmtgen/main.go index 01383171a01..d1a8c6b3bb3 100644 --- a/go/tools/astfmtgen/main.go +++ b/go/tools/astfmtgen/main.go @@ -207,8 +207,6 @@ func (r *Rewriter) rewriteAstPrintf(cursor *astutil.Cursor, expr *ast.CallExpr) token := format[i] switch token { - case 'c': - cursor.InsertBefore(r.rewriteLiteral(callexpr.X, "WriteByte", expr.Args[2+fieldnum])) case 's': cursor.InsertBefore(r.rewriteLiteral(callexpr.X, "WriteString", expr.Args[2+fieldnum])) case 'l', 'r', 'v': @@ -249,6 +247,26 @@ func (r *Rewriter) rewriteAstPrintf(cursor *astutil.Cursor, expr *ast.CallExpr) Args: []ast.Expr{&ast.BasicLit{Value: `"%d"`, Kind: gotoken.STRING}, expr.Args[2+fieldnum]}, } cursor.InsertBefore(r.rewriteLiteral(callexpr.X, "WriteString", call)) + case 'n': // directive for slices of AST nodes checked at code generation time + inputExpr := expr.Args[2+fieldnum] + inputType := r.pkg.TypesInfo.Types[inputExpr].Type + sliceType, ok := inputType.(*types.Slice) + if !ok { + panic("'%n' directive requires a slice") + } + if types.Implements(sliceType.Elem(), r.astExpr) { + // Fast path: input is []Expr + call := &ast.CallExpr{ + Fun: &ast.SelectorExpr{ + X: callexpr.X, + Sel: &ast.Ident{Name: "formatExprs"}, + }, + Args: []ast.Expr{inputExpr}, + } + cursor.InsertBefore(&ast.ExprStmt{X: call}) + break + } + panic("slow path for `n` directive for slice of type other than Expr") default: panic(fmt.Sprintf("unsupported escape %q", token)) } @@ -259,3 +277,7 @@ func (r *Rewriter) rewriteAstPrintf(cursor *astutil.Cursor, expr *ast.CallExpr) cursor.Delete() return true } + +var noQualifier = func(p *types.Package) string { + return "" +} diff --git a/go/tools/asthelpergen/asthelpergen.go b/go/tools/asthelpergen/asthelpergen.go index 3f59fdb3ece..ebb015b7339 100644 --- a/go/tools/asthelpergen/asthelpergen.go +++ b/go/tools/asthelpergen/asthelpergen.go @@ -77,9 +77,6 @@ type ( } ) -// exprInterfacePath is the path of the sqlparser.Expr interface. -const exprInterfacePath = "vitess.io/vitess/go/vt/sqlparser.Expr" - func (gen *astHelperGen) iface() *types.Interface { return gen._iface } @@ -207,19 +204,13 @@ func GenerateASTHelpers(options *Options) (map[string]*jen.File, error) { return nil, err } - exprType, _ := findTypeObject(exprInterfacePath, scopes) - var exprInterface *types.Interface - if exprType != nil { - exprInterface = exprType.Type().(*types.Named).Underlying().(*types.Interface) - } - nt := tt.Type().(*types.Named) pName := nt.Obj().Pkg().Name() generator := newGenerator(loaded[0].Module, loaded[0].TypesSizes, nt, newEqualsGen(pName, &options.Equals), newCloneGen(pName, &options.Clone), newVisitGen(pName), - newRewriterGen(pName, types.TypeString(nt, noQualifier), exprInterface), + newRewriterGen(pName, types.TypeString(nt, noQualifier)), newCOWGen(pName, nt), ) diff --git a/go/tools/asthelpergen/asthelpergen_test.go b/go/tools/asthelpergen/asthelpergen_test.go index 19ac865575d..21774187abe 100644 --- a/go/tools/asthelpergen/asthelpergen_test.go +++ b/go/tools/asthelpergen/asthelpergen_test.go @@ -21,6 +21,8 @@ import ( "strings" "testing" + "vitess.io/vitess/go/tools/codegen" + "github.com/stretchr/testify/require" ) @@ -45,3 +47,20 @@ func TestFullGeneration(t *testing.T) { require.False(t, applyIdx == 0 && cloneIdx == 0, "file doesn't contain expected contents") } } + +func TestRecreateAllFiles(t *testing.T) { + // t.Skip("This test recreates all files in the integration directory. It should only be run when the ASTHelperGen code has changed.") + result, err := GenerateASTHelpers(&Options{ + Packages: []string{"./integration/..."}, + RootInterface: "vitess.io/vitess/go/tools/asthelpergen/integration.AST", + Clone: CloneOptions{ + Exclude: []string{"*NoCloneType"}, + }, + }) + require.NoError(t, err) + + for fullPath, file := range result { + err := codegen.SaveJenFile(fullPath, file) + require.NoError(t, err) + } +} diff --git a/go/tools/asthelpergen/integration/ast_rewrite.go b/go/tools/asthelpergen/integration/ast_rewrite.go index cf92b358862..74dc743a581 100644 --- a/go/tools/asthelpergen/integration/ast_rewrite.go +++ b/go/tools/asthelpergen/integration/ast_rewrite.go @@ -61,9 +61,8 @@ func (a *application) rewriteBytes(parent AST, node Bytes, replacer replacerFunc a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(Bytes) a.cur.revisit = false - return a.rewriteBytes(parent, node, replacer) + return a.rewriteAST(parent, a.cur.node, replacer) } if kontinue { return true @@ -86,7 +85,12 @@ func (a *application) rewriteInterfaceContainer(parent AST, node InterfaceContai a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -112,9 +116,8 @@ func (a *application) rewriteInterfaceSlice(parent AST, node InterfaceSlice, rep a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(InterfaceSlice) a.cur.revisit = false - return a.rewriteInterfaceSlice(parent, node, replacer) + return a.rewriteAST(parent, a.cur.node, replacer) } if kontinue { return true @@ -147,7 +150,12 @@ func (a *application) rewriteRefOfLeaf(parent AST, node *Leaf, replacer replacer a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -173,9 +181,8 @@ func (a *application) rewriteLeafSlice(parent AST, node LeafSlice, replacer repl a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(LeafSlice) a.cur.revisit = false - return a.rewriteLeafSlice(parent, node, replacer) + return a.rewriteAST(parent, a.cur.node, replacer) } if kontinue { return true @@ -208,7 +215,12 @@ func (a *application) rewriteRefOfNoCloneType(parent AST, node *NoCloneType, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -232,7 +244,12 @@ func (a *application) rewriteRefOfRefContainer(parent AST, node *RefContainer, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -264,7 +281,12 @@ func (a *application) rewriteRefOfRefSliceContainer(parent AST, node *RefSliceCo a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -304,7 +326,12 @@ func (a *application) rewriteRefOfSubImpl(parent AST, node *SubImpl, replacer re a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -328,7 +355,12 @@ func (a *application) rewriteValueContainer(parent AST, node ValueContainer, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -357,7 +389,12 @@ func (a *application) rewriteValueSliceContainer(parent AST, node ValueSliceCont a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -402,7 +439,12 @@ func (a *application) rewriteBasicType(parent AST, node BasicType, replacer repl a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -426,7 +468,12 @@ func (a *application) rewriteRefOfInterfaceContainer(parent AST, node *Interface a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -450,7 +497,12 @@ func (a *application) rewriteRefOfValueContainer(parent AST, node *ValueContaine a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -482,7 +534,12 @@ func (a *application) rewriteRefOfValueSliceContainer(parent AST, node *ValueSli a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteAST(parent, a.cur.node, replacer) + } + if kontinue { return true } } diff --git a/go/tools/asthelpergen/integration/integration_rewriter_test.go b/go/tools/asthelpergen/integration/integration_rewriter_test.go index c7822980cd4..af7483b5916 100644 --- a/go/tools/asthelpergen/integration/integration_rewriter_test.go +++ b/go/tools/asthelpergen/integration/integration_rewriter_test.go @@ -204,6 +204,46 @@ func TestRewriteAndRevisitInterfaceSlice(t *testing.T) { }) } +func TestRewriteAndRevisitRefContainer(t *testing.T) { + leaf1 := &Leaf{1} + leaf2 := &Leaf{2} + ast1 := &RefContainer{ + ASTType: leaf1, + ASTImplementationType: leaf2, + } + ast2 := &RefContainer{ + ASTType: leaf2, + ASTImplementationType: leaf1, + } + + tv := &rewriteTestVisitor{} + + a := false + _ = Rewrite(ast1, func(cursor *Cursor) bool { + tv.pre(cursor) + switch cursor.node.(type) { + case *RefContainer: + if a { + break + } + a = true + cursor.ReplaceAndRevisit(ast2) + } + return true + }, tv.post) + + tv.assertEquals(t, []step{ + Pre{ast1}, // when we visit ast, we want to replace and revisit, + // which means that we don't do a post on this node, or visit the children + Pre{ast2}, + Pre{leaf2}, + Post{leaf2}, + Pre{leaf1}, + Post{leaf1}, + Post{ast2}, + }) +} + func TestRewriteVisitRefContainerReplace(t *testing.T) { ast := &RefContainer{ ASTType: &RefContainer{NotASTType: 12}, @@ -361,29 +401,30 @@ func (tv *rewriteTestVisitor) assertEquals(t *testing.T, expected []step) { error := false expectedSize := len(expected) for i, step := range tv.walk { - if expectedSize <= i { - t.Errorf("❌️ - Expected less elements %v", tv.walk[i:]) - break - } else { - e := expected[i] - if reflect.DeepEqual(e, step) { - a := "✔️ - " + e.String() - if error { - fmt.Println(a) - } else { - lines = append(lines, a) - } + t.Run(fmt.Sprintf("step %d", i), func(t *testing.T) { + if expectedSize <= i { + t.Fatalf("❌️ - Expected less elements %v", tv.walk[i:]) } else { - if !error { - // first error we see. - error = true - for _, line := range lines { - fmt.Println(line) + e := expected[i] + if reflect.DeepEqual(e, step) { + a := "✔️ - " + e.String() + if error { + fmt.Println(a) + } else { + lines = append(lines, a) + } + } else { + if !error { + // first error we see. + error = true + for _, line := range lines { + fmt.Println(line) + } } + t.Fatalf("❌️ - Expected: %s Got: %s\n", e.String(), step.String()) } - t.Errorf("❌️ - Expected: %s Got: %s\n", e.String(), step.String()) } - } + }) } walkSize := len(tv.walk) if expectedSize > walkSize { diff --git a/go/tools/asthelpergen/integration/test_helpers.go b/go/tools/asthelpergen/integration/test_helpers.go index 67745f19687..9a0cd186c34 100644 --- a/go/tools/asthelpergen/integration/test_helpers.go +++ b/go/tools/asthelpergen/integration/test_helpers.go @@ -68,14 +68,6 @@ func (c *Cursor) Replace(newNode AST) { // When used, this will abort the visitation of the current node - no post or children visited, // and the new node visited. func (c *Cursor) ReplaceAndRevisit(newNode AST) { - switch newNode.(type) { - case InterfaceSlice: - default: - // We need to add support to the generated code for when to look at the revisit flag. At the moment it is only - // there for slices of AST implementations - panic("no support added for this type yet") - } - c.replacer(newNode, c.parent) c.node = newNode c.revisit = true diff --git a/go/tools/asthelpergen/rewrite_gen.go b/go/tools/asthelpergen/rewrite_gen.go index cc8b18a78e9..29ffcee3d5b 100644 --- a/go/tools/asthelpergen/rewrite_gen.go +++ b/go/tools/asthelpergen/rewrite_gen.go @@ -30,21 +30,18 @@ const ( type rewriteGen struct { ifaceName string file *jen.File - // exprInterface is used to store the sqlparser.Expr interface - exprInterface *types.Interface } var _ generator = (*rewriteGen)(nil) -func newRewriterGen(pkgname string, ifaceName string, exprInterface *types.Interface) *rewriteGen { +func newRewriterGen(pkgname string, ifaceName string) *rewriteGen { file := jen.NewFile(pkgname) file.HeaderComment(licenseFileHeader) file.HeaderComment("Code generated by ASTHelperGen. DO NOT EDIT.") return &rewriteGen{ - ifaceName: ifaceName, - file: file, - exprInterface: exprInterface, + ifaceName: ifaceName, + file: file, } } @@ -108,7 +105,7 @@ 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)} + stmts := []jen.Code{r.executePre()} stmts = append(stmts, fields...) stmts = append(stmts, executePost(len(fields) > 0)) stmts = append(stmts, returnTrue()) @@ -133,7 +130,7 @@ 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()) fields := r.rewriteAllStructFields(t, strct, spi, false) stmts = append(stmts, fields...) stmts = append(stmts, executePost(len(fields) > 0)) @@ -182,15 +179,12 @@ func (r *rewriteGen) sliceMethod(t types.Type, slice *types.Slice, spi generator jen.If(jen.Id("node == nil").Block(returnTrue())), } - typeString := types.TypeString(t, noQualifier) - preStmts := setupCursor() preStmts = append(preStmts, jen.Id("kontinue").Op(":=").Id("!a.pre(&a.cur)"), jen.If(jen.Id("a.cur.revisit").Block( - jen.Id("node").Op("=").Id("a.cur.node.("+typeString+")"), jen.Id("a.cur.revisit").Op("=").False(), - jen.Return(jen.Id("a.rewrite"+typeString+"(parent, node, replacer)")), + jen.Return(jen.Id("a.rewrite"+r.ifaceName+"(parent, a.cur.node, replacer)")), )), jen.If(jen.Id("kontinue").Block(jen.Return(jen.True()))), ) @@ -228,19 +222,17 @@ func setupCursor() []jen.Code { jen.Id("a.cur.node = node"), } } -func (r *rewriteGen) executePre(t types.Type) jen.Code { + +func (r *rewriteGen) executePre() jen.Code { curStmts := setupCursor() - if r.exprInterface != nil && types.Implements(t, r.exprInterface) { - curStmts = append(curStmts, jen.Id("kontinue").Op(":=").Id("!a.pre(&a.cur)"), - 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())) - } + name := fmt.Sprintf("a.rewrite%s(parent, a.cur.node, replacer)", r.ifaceName) + curStmts = append(curStmts, jen.Id("kontinue").Op(":=").Id("!a.pre(&a.cur)"), + jen.If(jen.Id("a.cur.revisit").Block( + jen.Id("a.cur.revisit").Op("=").False(), + jen.Return(jen.Id(name)), + )), + jen.If(jen.Id("kontinue").Block(jen.Return(jen.True()))), + ) return jen.If(jen.Id("a.pre!= nil").Block(curStmts...)) } @@ -264,7 +256,7 @@ func (r *rewriteGen) basicMethod(t types.Type, _ *types.Basic, spi generatorSPI) return nil } - stmts := []jen.Code{r.executePre(t), executePost(false), returnTrue()} + stmts := []jen.Code{r.executePre(), executePost(false), returnTrue()} r.rewriteFunc(t, stmts) return nil } diff --git a/go/vt/sqlparser/analyzer_test.go b/go/vt/sqlparser/analyzer_test.go index 0a2de52ef19..e60e10d08ca 100644 --- a/go/vt/sqlparser/analyzer_test.go +++ b/go/vt/sqlparser/analyzer_test.go @@ -195,7 +195,7 @@ func TestAndExpressions(t *testing.T) { } testcases := []struct { name string - expressions Exprs + expressions []Expr expectedOutput Expr }{ { @@ -204,7 +204,7 @@ func TestAndExpressions(t *testing.T) { expectedOutput: nil, }, { name: "two equal inputs", - expressions: Exprs{ + expressions: []Expr{ greaterThanExpr, equalExpr, equalExpr, @@ -216,7 +216,7 @@ func TestAndExpressions(t *testing.T) { }, { name: "two equal inputs", - expressions: Exprs{ + expressions: []Expr{ equalExpr, equalExpr, }, diff --git a/go/vt/sqlparser/ast.go b/go/vt/sqlparser/ast.go index e673b1ebf74..806784c27e8 100644 --- a/go/vt/sqlparser/ast.go +++ b/go/vt/sqlparser/ast.go @@ -75,7 +75,7 @@ type ( ColumnResults interface { GetColumnCount() int - GetColumns() SelectExprs + GetColumns() []SelectExpr } Withable interface { @@ -295,7 +295,7 @@ type ( With *With From []TableExpr Comments *ParsedComments - SelectExprs SelectExprs + SelectExprs *SelectExprs Where *Where GroupBy *GroupBy Having *Where @@ -645,7 +645,7 @@ type ( // CallProc represents a CALL statement CallProc struct { Name TableName - Params Exprs + Params []Expr } // LockType is an enum for Lock Types @@ -2039,8 +2039,9 @@ type ParsedComments struct { _directives *CommentDirectives } -// SelectExprs represents SELECT expressions. -type SelectExprs []SelectExpr +type SelectExprs struct { + Exprs []SelectExpr +} type ( // SelectExpr represents a SELECT expression. @@ -2209,7 +2210,7 @@ type ( // More information available here: https://dev.mysql.com/doc/refman/8.0/en/window-functions-usage.html WindowSpecification struct { Name IdentifierCI - PartitionClause Exprs + PartitionClause []Expr OrderClause OrderBy FrameClause *FrameClause } @@ -2400,7 +2401,7 @@ type ( ListArg string // ValTuple represents a tuple of actual values. - ValTuple Exprs + ValTuple []Expr // BinaryExpr represents a binary value expression. BinaryExpr struct { @@ -2455,7 +2456,7 @@ type ( FuncExpr struct { Qualifier IdentifierCS Name IdentifierCI - Exprs Exprs + Exprs []Expr } // ValuesFuncExpr represents a function call. @@ -2524,7 +2525,7 @@ type ( // IntervalFuncExpr represents an INTERVAL function expression IntervalFuncExpr struct { Expr Expr - Exprs Exprs + Exprs []Expr } // LocateExpr represents a LOCATE function expression @@ -2536,7 +2537,7 @@ type ( // CharExpr represents a CHAR function expression CharExpr struct { - Exprs Exprs + Exprs []Expr Charset string } @@ -2586,7 +2587,7 @@ type ( // JSONArrayExpr represents JSON_ARRAY() // More information on https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-array JSONArrayExpr struct { - Params Exprs + Params []Expr } // JSONObjectExpr represents JSON_OBJECT() @@ -2776,7 +2777,7 @@ type ( JSONValueMergeExpr struct { Type JSONValueMergeType JSONDoc Expr - JSONDocList Exprs + JSONDocList []Expr } // JSONValueModifierType is an enum to get types of TrimFunc. @@ -2787,7 +2788,7 @@ type ( // For more information, postVisit https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-remove JSONRemoveExpr struct { JSONDoc Expr - PathList Exprs + PathList []Expr } // JSONRemoveExpr represents the JSON_UNQUOTE() @@ -2804,27 +2805,27 @@ type ( // LineString represents LineString(POINT(x,y), POINT(x,y), ..) expression LineStringExpr struct { - PointParams Exprs + PointParams []Expr } // PolygonExpr represents Polygon(LineString(POINT(x,y), POINT(x,y), ..)) expressions PolygonExpr struct { - LinestringParams Exprs + LinestringParams []Expr } // MultiPoint represents a geometry collection for points MultiPointExpr struct { - PointParams Exprs + PointParams []Expr } // MultiPoint represents a geometry collection for linestrings MultiLinestringExpr struct { - LinestringParams Exprs + LinestringParams []Expr } // MultiPolygon represents a geometry collection for polygons MultiPolygonExpr struct { - PolygonParams Exprs + PolygonParams []Expr } // GeomFromWktType is an enum to get the types of wkt functions with possible values: GeometryFromText GeometryCollectionFromText PointFromText LineStringFromText PolygonFromText MultiPointFromText MultiPolygonFromText MultiLinestringFromText @@ -2935,9 +2936,9 @@ type ( AggrFunc interface { Expr GetArg() Expr - GetArgs() Exprs + GetArgs() []Expr SetArg(expr Expr) - SetArgs(exprs Exprs) error + SetArgs(exprs []Expr) error // AggrName returns the lower case string representing this aggregation function AggrName() string } @@ -2948,7 +2949,7 @@ type ( } Count struct { - Args Exprs + Args []Expr Distinct bool OverClause *OverClause } @@ -3061,7 +3062,7 @@ type ( // GroupConcatExpr represents a call to GROUP_CONCAT GroupConcatExpr struct { Distinct bool - Exprs Exprs + Exprs []Expr OrderBy OrderBy Separator string Limit *Limit @@ -3450,34 +3451,34 @@ func (av *AnyValue) GetArg() Expr { return av.Arg } func (jaa *JSONArrayAgg) GetArg() Expr { return jaa.Expr } func (joa *JSONObjectAgg) GetArg() Expr { return joa.Key } -func (sum *Sum) GetArgs() Exprs { return Exprs{sum.Arg} } -func (min *Min) GetArgs() Exprs { return Exprs{min.Arg} } -func (max *Max) GetArgs() Exprs { return Exprs{max.Arg} } -func (avg *Avg) GetArgs() Exprs { return Exprs{avg.Arg} } -func (*CountStar) GetArgs() Exprs { return nil } -func (count *Count) GetArgs() Exprs { return count.Args } -func (grpConcat *GroupConcatExpr) GetArgs() Exprs { return grpConcat.Exprs } -func (bAnd *BitAnd) GetArgs() Exprs { return Exprs{bAnd.Arg} } -func (bOr *BitOr) GetArgs() Exprs { return Exprs{bOr.Arg} } -func (bXor *BitXor) GetArgs() Exprs { return Exprs{bXor.Arg} } -func (std *Std) GetArgs() Exprs { return Exprs{std.Arg} } -func (stdD *StdDev) GetArgs() Exprs { return Exprs{stdD.Arg} } -func (stdP *StdPop) GetArgs() Exprs { return Exprs{stdP.Arg} } -func (stdS *StdSamp) GetArgs() Exprs { return Exprs{stdS.Arg} } -func (varP *VarPop) GetArgs() Exprs { return Exprs{varP.Arg} } -func (varS *VarSamp) GetArgs() Exprs { return Exprs{varS.Arg} } -func (variance *Variance) GetArgs() Exprs { return Exprs{variance.Arg} } -func (av *AnyValue) GetArgs() Exprs { return Exprs{av.Arg} } -func (jaa *JSONArrayAgg) GetArgs() Exprs { return Exprs{jaa.Expr} } -func (joa *JSONObjectAgg) GetArgs() Exprs { return Exprs{joa.Key, joa.Value} } +func (sum *Sum) GetArgs() []Expr { return []Expr{sum.Arg} } +func (min *Min) GetArgs() []Expr { return []Expr{min.Arg} } +func (max *Max) GetArgs() []Expr { return []Expr{max.Arg} } +func (avg *Avg) GetArgs() []Expr { return []Expr{avg.Arg} } +func (*CountStar) GetArgs() []Expr { return nil } +func (count *Count) GetArgs() []Expr { return count.Args } +func (grpConcat *GroupConcatExpr) GetArgs() []Expr { return grpConcat.Exprs } +func (bAnd *BitAnd) GetArgs() []Expr { return []Expr{bAnd.Arg} } +func (bOr *BitOr) GetArgs() []Expr { return []Expr{bOr.Arg} } +func (bXor *BitXor) GetArgs() []Expr { return []Expr{bXor.Arg} } +func (std *Std) GetArgs() []Expr { return []Expr{std.Arg} } +func (stdD *StdDev) GetArgs() []Expr { return []Expr{stdD.Arg} } +func (stdP *StdPop) GetArgs() []Expr { return []Expr{stdP.Arg} } +func (stdS *StdSamp) GetArgs() []Expr { return []Expr{stdS.Arg} } +func (varP *VarPop) GetArgs() []Expr { return []Expr{varP.Arg} } +func (varS *VarSamp) GetArgs() []Expr { return []Expr{varS.Arg} } +func (variance *Variance) GetArgs() []Expr { return []Expr{variance.Arg} } +func (av *AnyValue) GetArgs() []Expr { return []Expr{av.Arg} } +func (jaa *JSONArrayAgg) GetArgs() []Expr { return []Expr{jaa.Expr} } +func (joa *JSONObjectAgg) GetArgs() []Expr { return []Expr{joa.Key, joa.Value} } func (min *Min) SetArg(expr Expr) { min.Arg = expr } func (sum *Sum) SetArg(expr Expr) { sum.Arg = expr } func (max *Max) SetArg(expr Expr) { max.Arg = expr } func (avg *Avg) SetArg(expr Expr) { avg.Arg = expr } func (*CountStar) SetArg(expr Expr) {} -func (count *Count) SetArg(expr Expr) { count.Args = Exprs{expr} } -func (grpConcat *GroupConcatExpr) SetArg(expr Expr) { grpConcat.Exprs = Exprs{expr} } +func (count *Count) SetArg(expr Expr) { count.Args = []Expr{expr} } +func (grpConcat *GroupConcatExpr) SetArg(expr Expr) { grpConcat.Exprs = []Expr{expr} } func (bAnd *BitAnd) SetArg(expr Expr) { bAnd.Arg = expr } func (bOr *BitOr) SetArg(expr Expr) { bOr.Arg = expr } func (bXor *BitXor) SetArg(expr Expr) { bXor.Arg = expr } @@ -3492,24 +3493,26 @@ func (av *AnyValue) SetArg(expr Expr) { av.Arg = expr } func (jaa *JSONArrayAgg) SetArg(expr Expr) { jaa.Expr = expr } func (joa *JSONObjectAgg) SetArg(expr Expr) { joa.Key = expr } -func (min *Min) SetArgs(exprs Exprs) error { return setFuncArgs(min, exprs, "MIN") } -func (sum *Sum) SetArgs(exprs Exprs) error { return setFuncArgs(sum, exprs, "SUM") } -func (max *Max) SetArgs(exprs Exprs) error { return setFuncArgs(max, exprs, "MAX") } -func (avg *Avg) SetArgs(exprs Exprs) error { return setFuncArgs(avg, exprs, "AVG") } -func (*CountStar) SetArgs(Exprs) error { return nil } -func (bAnd *BitAnd) SetArgs(exprs Exprs) error { return setFuncArgs(bAnd, exprs, "BIT_AND") } -func (bOr *BitOr) SetArgs(exprs Exprs) error { return setFuncArgs(bOr, exprs, "BIT_OR") } -func (bXor *BitXor) SetArgs(exprs Exprs) error { return setFuncArgs(bXor, exprs, "BIT_XOR") } -func (std *Std) SetArgs(exprs Exprs) error { return setFuncArgs(std, exprs, "STD") } -func (stdD *StdDev) SetArgs(exprs Exprs) error { return setFuncArgs(stdD, exprs, "STDDEV") } -func (stdP *StdPop) SetArgs(exprs Exprs) error { return setFuncArgs(stdP, exprs, "STDDEV_POP") } -func (stdS *StdSamp) SetArgs(exprs Exprs) error { return setFuncArgs(stdS, exprs, "STDDEV_SAMP") } -func (varP *VarPop) SetArgs(exprs Exprs) error { return setFuncArgs(varP, exprs, "VAR_POP") } -func (varS *VarSamp) SetArgs(exprs Exprs) error { return setFuncArgs(varS, exprs, "VAR_SAMP") } -func (variance *Variance) SetArgs(exprs Exprs) error { return setFuncArgs(variance, exprs, "VARIANCE") } -func (av *AnyValue) SetArgs(exprs Exprs) error { return setFuncArgs(av, exprs, "ANY_VALUE") } -func (jaa *JSONArrayAgg) SetArgs(exprs Exprs) error { return setFuncArgs(jaa, exprs, "JSON_ARRAYARG") } -func (joa *JSONObjectAgg) SetArgs(exprs Exprs) error { +func (min *Min) SetArgs(exprs []Expr) error { return setFuncArgs(min, exprs, "MIN") } +func (sum *Sum) SetArgs(exprs []Expr) error { return setFuncArgs(sum, exprs, "SUM") } +func (max *Max) SetArgs(exprs []Expr) error { return setFuncArgs(max, exprs, "MAX") } +func (avg *Avg) SetArgs(exprs []Expr) error { return setFuncArgs(avg, exprs, "AVG") } +func (*CountStar) SetArgs([]Expr) error { return nil } +func (bAnd *BitAnd) SetArgs(exprs []Expr) error { return setFuncArgs(bAnd, exprs, "BIT_AND") } +func (bOr *BitOr) SetArgs(exprs []Expr) error { return setFuncArgs(bOr, exprs, "BIT_OR") } +func (bXor *BitXor) SetArgs(exprs []Expr) error { return setFuncArgs(bXor, exprs, "BIT_XOR") } +func (std *Std) SetArgs(exprs []Expr) error { return setFuncArgs(std, exprs, "STD") } +func (stdD *StdDev) SetArgs(exprs []Expr) error { return setFuncArgs(stdD, exprs, "STDDEV") } +func (stdP *StdPop) SetArgs(exprs []Expr) error { return setFuncArgs(stdP, exprs, "STDDEV_POP") } +func (stdS *StdSamp) SetArgs(exprs []Expr) error { return setFuncArgs(stdS, exprs, "STDDEV_SAMP") } +func (varP *VarPop) SetArgs(exprs []Expr) error { return setFuncArgs(varP, exprs, "VAR_POP") } +func (varS *VarSamp) SetArgs(exprs []Expr) error { return setFuncArgs(varS, exprs, "VAR_SAMP") } +func (variance *Variance) SetArgs(exprs []Expr) error { + return setFuncArgs(variance, exprs, "VARIANCE") +} +func (av *AnyValue) SetArgs(exprs []Expr) error { return setFuncArgs(av, exprs, "ANY_VALUE") } +func (jaa *JSONArrayAgg) SetArgs(exprs []Expr) error { return setFuncArgs(jaa, exprs, "JSON_ARRAYARG") } +func (joa *JSONObjectAgg) SetArgs(exprs []Expr) error { if len(exprs) != 2 { return vterrors.VT13001("JSONObjectAgg takes in 2 expressions") } @@ -3518,11 +3521,11 @@ func (joa *JSONObjectAgg) SetArgs(exprs Exprs) error { return nil } -func (count *Count) SetArgs(exprs Exprs) error { +func (count *Count) SetArgs(exprs []Expr) error { count.Args = exprs return nil } -func (grpConcat *GroupConcatExpr) SetArgs(exprs Exprs) error { +func (grpConcat *GroupConcatExpr) SetArgs(exprs []Expr) error { grpConcat.Exprs = exprs return nil } @@ -3564,7 +3567,9 @@ func (*JSONObjectAgg) AggrName() string { return "json_objectagg" } // Exprs represents a list of value expressions. // It's not a valid expression because it's not parenthesized. -type Exprs []Expr +type Exprs struct { + Exprs []Expr +} func (ValTuple) iColTuple() {} func (*Subquery) iColTuple() {} diff --git a/go/vt/sqlparser/ast_clone.go b/go/vt/sqlparser/ast_clone.go index 3c7f4fe5e6a..997485e086c 100644 --- a/go/vt/sqlparser/ast_clone.go +++ b/go/vt/sqlparser/ast_clone.go @@ -161,8 +161,8 @@ func CloneSQLNode(in SQLNode) SQLNode { return CloneRefOfExplainStmt(in) case *ExplainTab: return CloneRefOfExplainTab(in) - case Exprs: - return CloneExprs(in) + case *Exprs: + return CloneRefOfExprs(in) case *ExtractFuncExpr: return CloneRefOfExtractFuncExpr(in) case *ExtractValueExpr: @@ -435,8 +435,8 @@ func CloneSQLNode(in SQLNode) SQLNode { return CloneRefOfSavepoint(in) case *Select: return CloneRefOfSelect(in) - case SelectExprs: - return CloneSelectExprs(in) + case *SelectExprs: + return CloneRefOfSelectExprs(in) case *SelectInto: return CloneRefOfSelectInto(in) case *Set: @@ -887,7 +887,7 @@ func CloneRefOfCallProc(n *CallProc) *CallProc { } out := *n out.Name = CloneTableName(n.Name) - out.Params = CloneExprs(n.Params) + out.Params = CloneSliceOfExpr(n.Params) return &out } @@ -932,7 +932,7 @@ func CloneRefOfCharExpr(n *CharExpr) *CharExpr { return nil } out := *n - out.Exprs = CloneExprs(n.Exprs) + out.Exprs = CloneSliceOfExpr(n.Exprs) return &out } @@ -1091,7 +1091,7 @@ func CloneRefOfCount(n *Count) *Count { return nil } out := *n - out.Args = CloneExprs(n.Args) + out.Args = CloneSliceOfExpr(n.Args) out.OverClause = CloneRefOfOverClause(n.OverClause) return &out } @@ -1307,16 +1307,14 @@ func CloneRefOfExplainTab(n *ExplainTab) *ExplainTab { return &out } -// CloneExprs creates a deep clone of the input. -func CloneExprs(n Exprs) Exprs { +// CloneRefOfExprs creates a deep clone of the input. +func CloneRefOfExprs(n *Exprs) *Exprs { if n == nil { return nil } - res := make(Exprs, len(n)) - for i, x := range n { - res[i] = CloneExpr(x) - } - return res + out := *n + out.Exprs = CloneSliceOfExpr(n.Exprs) + return &out } // CloneRefOfExtractFuncExpr creates a deep clone of the input. @@ -1422,7 +1420,7 @@ func CloneRefOfFuncExpr(n *FuncExpr) *FuncExpr { out := *n out.Qualifier = CloneIdentifierCS(n.Qualifier) out.Name = CloneIdentifierCI(n.Name) - out.Exprs = CloneExprs(n.Exprs) + out.Exprs = CloneSliceOfExpr(n.Exprs) return &out } @@ -1569,7 +1567,7 @@ func CloneRefOfGroupConcatExpr(n *GroupConcatExpr) *GroupConcatExpr { return nil } out := *n - out.Exprs = CloneExprs(n.Exprs) + out.Exprs = CloneSliceOfExpr(n.Exprs) out.OrderBy = CloneOrderBy(n.OrderBy) out.Limit = CloneRefOfLimit(n.Limit) return &out @@ -1677,7 +1675,7 @@ func CloneRefOfIntervalFuncExpr(n *IntervalFuncExpr) *IntervalFuncExpr { } out := *n out.Expr = CloneExpr(n.Expr) - out.Exprs = CloneExprs(n.Exprs) + out.Exprs = CloneSliceOfExpr(n.Exprs) return &out } @@ -1718,7 +1716,7 @@ func CloneRefOfJSONArrayExpr(n *JSONArrayExpr) *JSONArrayExpr { return nil } out := *n - out.Params = CloneExprs(n.Params) + out.Params = CloneSliceOfExpr(n.Params) return &out } @@ -1850,7 +1848,7 @@ func CloneRefOfJSONRemoveExpr(n *JSONRemoveExpr) *JSONRemoveExpr { } out := *n out.JSONDoc = CloneExpr(n.JSONDoc) - out.PathList = CloneExprs(n.PathList) + out.PathList = CloneSliceOfExpr(n.PathList) return &out } @@ -1954,7 +1952,7 @@ func CloneRefOfJSONValueMergeExpr(n *JSONValueMergeExpr) *JSONValueMergeExpr { } out := *n out.JSONDoc = CloneExpr(n.JSONDoc) - out.JSONDocList = CloneExprs(n.JSONDocList) + out.JSONDocList = CloneSliceOfExpr(n.JSONDocList) return &out } @@ -2063,7 +2061,7 @@ func CloneRefOfLineStringExpr(n *LineStringExpr) *LineStringExpr { return nil } out := *n - out.PointParams = CloneExprs(n.PointParams) + out.PointParams = CloneSliceOfExpr(n.PointParams) return &out } @@ -2199,7 +2197,7 @@ func CloneRefOfMultiLinestringExpr(n *MultiLinestringExpr) *MultiLinestringExpr return nil } out := *n - out.LinestringParams = CloneExprs(n.LinestringParams) + out.LinestringParams = CloneSliceOfExpr(n.LinestringParams) return &out } @@ -2209,7 +2207,7 @@ func CloneRefOfMultiPointExpr(n *MultiPointExpr) *MultiPointExpr { return nil } out := *n - out.PointParams = CloneExprs(n.PointParams) + out.PointParams = CloneSliceOfExpr(n.PointParams) return &out } @@ -2219,7 +2217,7 @@ func CloneRefOfMultiPolygonExpr(n *MultiPolygonExpr) *MultiPolygonExpr { return nil } out := *n - out.PolygonParams = CloneExprs(n.PolygonParams) + out.PolygonParams = CloneSliceOfExpr(n.PolygonParams) return &out } @@ -2546,7 +2544,7 @@ func CloneRefOfPolygonExpr(n *PolygonExpr) *PolygonExpr { return nil } out := *n - out.LinestringParams = CloneExprs(n.LinestringParams) + out.LinestringParams = CloneSliceOfExpr(n.LinestringParams) return &out } @@ -2766,7 +2764,7 @@ func CloneRefOfSelect(n *Select) *Select { out.With = CloneRefOfWith(n.With) out.From = CloneSliceOfTableExpr(n.From) out.Comments = CloneRefOfParsedComments(n.Comments) - out.SelectExprs = CloneSelectExprs(n.SelectExprs) + out.SelectExprs = CloneRefOfSelectExprs(n.SelectExprs) out.Where = CloneRefOfWhere(n.Where) out.GroupBy = CloneRefOfGroupBy(n.GroupBy) out.Having = CloneRefOfWhere(n.Having) @@ -2777,16 +2775,14 @@ func CloneRefOfSelect(n *Select) *Select { return &out } -// CloneSelectExprs creates a deep clone of the input. -func CloneSelectExprs(n SelectExprs) SelectExprs { +// CloneRefOfSelectExprs creates a deep clone of the input. +func CloneRefOfSelectExprs(n *SelectExprs) *SelectExprs { if n == nil { return nil } - res := make(SelectExprs, len(n)) - for i, x := range n { - res[i] = CloneSelectExpr(x) - } - return res + out := *n + out.Exprs = CloneSliceOfSelectExpr(n.Exprs) + return &out } // CloneRefOfSelectInto creates a deep clone of the input. @@ -3466,7 +3462,7 @@ func CloneRefOfWindowSpecification(n *WindowSpecification) *WindowSpecification } out := *n out.Name = CloneIdentifierCI(n.Name) - out.PartitionClause = CloneExprs(n.PartitionClause) + out.PartitionClause = CloneSliceOfExpr(n.PartitionClause) out.OrderClause = CloneOrderBy(n.OrderClause) out.FrameClause = CloneRefOfFrameClause(n.FrameClause) return &out @@ -4418,6 +4414,18 @@ func CloneSliceOfTxAccessMode(n []TxAccessMode) []TxAccessMode { return res } +// CloneSliceOfExpr creates a deep clone of the input. +func CloneSliceOfExpr(n []Expr) []Expr { + if n == nil { + return nil + } + res := make([]Expr, len(n)) + for i, x := range n { + res[i] = CloneExpr(x) + } + return res +} + // CloneSliceOfRefOfWhen creates a deep clone of the input. func CloneSliceOfRefOfWhen(n []*When) []*When { if n == nil { @@ -4497,18 +4505,6 @@ func CloneSliceOfRefOfVariable(n []*Variable) []*Variable { return res } -// CloneSliceOfExpr creates a deep clone of the input. -func CloneSliceOfExpr(n []Expr) []Expr { - if n == nil { - return nil - } - res := make([]Expr, len(n)) - for i, x := range n { - res[i] = CloneExpr(x) - } - return res -} - // CloneRefOfIdentifierCI creates a deep clone of the input. func CloneRefOfIdentifierCI(n *IdentifierCI) *IdentifierCI { if n == nil { @@ -4680,6 +4676,18 @@ func CloneRefOfRootNode(n *RootNode) *RootNode { return &out } +// CloneSliceOfSelectExpr creates a deep clone of the input. +func CloneSliceOfSelectExpr(n []SelectExpr) []SelectExpr { + if n == nil { + return nil + } + res := make([]SelectExpr, len(n)) + for i, x := range n { + res[i] = CloneSelectExpr(x) + } + return res +} + // CloneRefOfTableName creates a deep clone of the input. func CloneRefOfTableName(n *TableName) *TableName { if n == nil { diff --git a/go/vt/sqlparser/ast_copy_on_rewrite.go b/go/vt/sqlparser/ast_copy_on_rewrite.go index f725dfc6803..46ce38ee29d 100644 --- a/go/vt/sqlparser/ast_copy_on_rewrite.go +++ b/go/vt/sqlparser/ast_copy_on_rewrite.go @@ -160,8 +160,8 @@ func (c *cow) copyOnRewriteSQLNode(n SQLNode, parent SQLNode) (out SQLNode, chan return c.copyOnRewriteRefOfExplainStmt(n, parent) case *ExplainTab: return c.copyOnRewriteRefOfExplainTab(n, parent) - case Exprs: - return c.copyOnRewriteExprs(n, parent) + case *Exprs: + return c.copyOnRewriteRefOfExprs(n, parent) case *ExtractFuncExpr: return c.copyOnRewriteRefOfExtractFuncExpr(n, parent) case *ExtractValueExpr: @@ -434,8 +434,8 @@ func (c *cow) copyOnRewriteSQLNode(n SQLNode, parent SQLNode) (out SQLNode, chan return c.copyOnRewriteRefOfSavepoint(n, parent) case *Select: return c.copyOnRewriteRefOfSelect(n, parent) - case SelectExprs: - return c.copyOnRewriteSelectExprs(n, parent) + case *SelectExprs: + return c.copyOnRewriteRefOfSelectExprs(n, parent) case *SelectInto: return c.copyOnRewriteRefOfSelectInto(n, parent) case *Set: @@ -1244,11 +1244,19 @@ func (c *cow) copyOnRewriteRefOfCallProc(n *CallProc, parent SQLNode) (out SQLNo out = n if c.pre == nil || c.pre(n, parent) { _Name, changedName := c.copyOnRewriteTableName(n.Name, n) - _Params, changedParams := c.copyOnRewriteExprs(n.Params, n) + var changedParams bool + _Params := make([]Expr, len(n.Params)) + for x, el := range n.Params { + this, changed := c.copyOnRewriteExpr(el, n) + _Params[x] = this.(Expr) + if changed { + changedParams = true + } + } if changedName || changedParams { res := *n res.Name, _ = _Name.(TableName) - res.Params, _ = _Params.(Exprs) + res.Params = _Params out = &res if c.cloned != nil { c.cloned(n, out) @@ -1351,10 +1359,18 @@ func (c *cow) copyOnRewriteRefOfCharExpr(n *CharExpr, parent SQLNode) (out SQLNo } out = n if c.pre == nil || c.pre(n, parent) { - _Exprs, changedExprs := c.copyOnRewriteExprs(n.Exprs, n) + var changedExprs bool + _Exprs := make([]Expr, len(n.Exprs)) + for x, el := range n.Exprs { + this, changed := c.copyOnRewriteExpr(el, n) + _Exprs[x] = this.(Expr) + if changed { + changedExprs = true + } + } if changedExprs { res := *n - res.Exprs, _ = _Exprs.(Exprs) + res.Exprs = _Exprs out = &res if c.cloned != nil { c.cloned(n, out) @@ -1658,11 +1674,19 @@ func (c *cow) copyOnRewriteRefOfCount(n *Count, parent SQLNode) (out SQLNode, ch } out = n if c.pre == nil || c.pre(n, parent) { - _Args, changedArgs := c.copyOnRewriteExprs(n.Args, n) + var changedArgs bool + _Args := make([]Expr, len(n.Args)) + for x, el := range n.Args { + this, changed := c.copyOnRewriteExpr(el, n) + _Args[x] = this.(Expr) + if changed { + changedArgs = true + } + } _OverClause, changedOverClause := c.copyOnRewriteRefOfOverClause(n.OverClause, n) if changedArgs || changedOverClause { res := *n - res.Args, _ = _Args.(Exprs) + res.Args = _Args res.OverClause, _ = _OverClause.(*OverClause) out = &res if c.cloned != nil { @@ -2134,22 +2158,29 @@ func (c *cow) copyOnRewriteRefOfExplainTab(n *ExplainTab, parent SQLNode) (out S } return } -func (c *cow) copyOnRewriteExprs(n Exprs, parent SQLNode) (out SQLNode, changed bool) { +func (c *cow) copyOnRewriteRefOfExprs(n *Exprs, parent SQLNode) (out SQLNode, changed bool) { if n == nil || c.cursor.stop { return n, false } out = n if c.pre == nil || c.pre(n, parent) { - res := make(Exprs, len(n)) - for x, el := range n { - this, change := c.copyOnRewriteExpr(el, n) - res[x] = this.(Expr) - if change { - changed = true + var changedExprs bool + _Exprs := make([]Expr, len(n.Exprs)) + for x, el := range n.Exprs { + this, changed := c.copyOnRewriteExpr(el, n) + _Exprs[x] = this.(Expr) + if changed { + changedExprs = true } } - if changed { - out = res + if changedExprs { + res := *n + res.Exprs = _Exprs + out = &res + if c.cloned != nil { + c.cloned(n, out) + } + changed = true } } if c.post != nil { @@ -2355,12 +2386,20 @@ func (c *cow) copyOnRewriteRefOfFuncExpr(n *FuncExpr, parent SQLNode) (out SQLNo if c.pre == nil || c.pre(n, parent) { _Qualifier, changedQualifier := c.copyOnRewriteIdentifierCS(n.Qualifier, n) _Name, changedName := c.copyOnRewriteIdentifierCI(n.Name, n) - _Exprs, changedExprs := c.copyOnRewriteExprs(n.Exprs, n) + var changedExprs bool + _Exprs := make([]Expr, len(n.Exprs)) + for x, el := range n.Exprs { + this, changed := c.copyOnRewriteExpr(el, n) + _Exprs[x] = this.(Expr) + if changed { + changedExprs = true + } + } if changedQualifier || changedName || changedExprs { res := *n res.Qualifier, _ = _Qualifier.(IdentifierCS) res.Name, _ = _Name.(IdentifierCI) - res.Exprs, _ = _Exprs.(Exprs) + res.Exprs = _Exprs out = &res if c.cloned != nil { c.cloned(n, out) @@ -2685,12 +2724,20 @@ func (c *cow) copyOnRewriteRefOfGroupConcatExpr(n *GroupConcatExpr, parent SQLNo } out = n if c.pre == nil || c.pre(n, parent) { - _Exprs, changedExprs := c.copyOnRewriteExprs(n.Exprs, n) + var changedExprs bool + _Exprs := make([]Expr, len(n.Exprs)) + for x, el := range n.Exprs { + this, changed := c.copyOnRewriteExpr(el, n) + _Exprs[x] = this.(Expr) + if changed { + changedExprs = true + } + } _OrderBy, changedOrderBy := c.copyOnRewriteOrderBy(n.OrderBy, n) _Limit, changedLimit := c.copyOnRewriteRefOfLimit(n.Limit, n) if changedExprs || changedOrderBy || changedLimit { res := *n - res.Exprs, _ = _Exprs.(Exprs) + res.Exprs = _Exprs res.OrderBy, _ = _OrderBy.(OrderBy) res.Limit, _ = _Limit.(*Limit) out = &res @@ -2915,11 +2962,19 @@ func (c *cow) copyOnRewriteRefOfIntervalFuncExpr(n *IntervalFuncExpr, parent SQL out = n if c.pre == nil || c.pre(n, parent) { _Expr, changedExpr := c.copyOnRewriteExpr(n.Expr, n) - _Exprs, changedExprs := c.copyOnRewriteExprs(n.Exprs, n) + var changedExprs bool + _Exprs := make([]Expr, len(n.Exprs)) + for x, el := range n.Exprs { + this, changed := c.copyOnRewriteExpr(el, n) + _Exprs[x] = this.(Expr) + if changed { + changedExprs = true + } + } if changedExpr || changedExprs { res := *n res.Expr, _ = _Expr.(Expr) - res.Exprs, _ = _Exprs.(Exprs) + res.Exprs = _Exprs out = &res if c.cloned != nil { c.cloned(n, out) @@ -3006,10 +3061,18 @@ func (c *cow) copyOnRewriteRefOfJSONArrayExpr(n *JSONArrayExpr, parent SQLNode) } out = n if c.pre == nil || c.pre(n, parent) { - _Params, changedParams := c.copyOnRewriteExprs(n.Params, n) + var changedParams bool + _Params := make([]Expr, len(n.Params)) + for x, el := range n.Params { + this, changed := c.copyOnRewriteExpr(el, n) + _Params[x] = this.(Expr) + if changed { + changedParams = true + } + } if changedParams { res := *n - res.Params, _ = _Params.(Exprs) + res.Params = _Params out = &res if c.cloned != nil { c.cloned(n, out) @@ -3325,11 +3388,19 @@ func (c *cow) copyOnRewriteRefOfJSONRemoveExpr(n *JSONRemoveExpr, parent SQLNode out = n if c.pre == nil || c.pre(n, parent) { _JSONDoc, changedJSONDoc := c.copyOnRewriteExpr(n.JSONDoc, n) - _PathList, changedPathList := c.copyOnRewriteExprs(n.PathList, n) + var changedPathList bool + _PathList := make([]Expr, len(n.PathList)) + for x, el := range n.PathList { + this, changed := c.copyOnRewriteExpr(el, n) + _PathList[x] = this.(Expr) + if changed { + changedPathList = true + } + } if changedJSONDoc || changedPathList { res := *n res.JSONDoc, _ = _JSONDoc.(Expr) - res.PathList, _ = _PathList.(Exprs) + res.PathList = _PathList out = &res if c.cloned != nil { c.cloned(n, out) @@ -3567,11 +3638,19 @@ func (c *cow) copyOnRewriteRefOfJSONValueMergeExpr(n *JSONValueMergeExpr, parent out = n if c.pre == nil || c.pre(n, parent) { _JSONDoc, changedJSONDoc := c.copyOnRewriteExpr(n.JSONDoc, n) - _JSONDocList, changedJSONDocList := c.copyOnRewriteExprs(n.JSONDocList, n) + var changedJSONDocList bool + _JSONDocList := make([]Expr, len(n.JSONDocList)) + for x, el := range n.JSONDocList { + this, changed := c.copyOnRewriteExpr(el, n) + _JSONDocList[x] = this.(Expr) + if changed { + changedJSONDocList = true + } + } if changedJSONDoc || changedJSONDocList { res := *n res.JSONDoc, _ = _JSONDoc.(Expr) - res.JSONDocList, _ = _JSONDocList.(Exprs) + res.JSONDocList = _JSONDocList out = &res if c.cloned != nil { c.cloned(n, out) @@ -3784,10 +3863,18 @@ func (c *cow) copyOnRewriteRefOfLineStringExpr(n *LineStringExpr, parent SQLNode } out = n if c.pre == nil || c.pre(n, parent) { - _PointParams, changedPointParams := c.copyOnRewriteExprs(n.PointParams, n) + var changedPointParams bool + _PointParams := make([]Expr, len(n.PointParams)) + for x, el := range n.PointParams { + this, changed := c.copyOnRewriteExpr(el, n) + _PointParams[x] = this.(Expr) + if changed { + changedPointParams = true + } + } if changedPointParams { res := *n - res.PointParams, _ = _PointParams.(Exprs) + res.PointParams = _PointParams out = &res if c.cloned != nil { c.cloned(n, out) @@ -4056,10 +4143,18 @@ func (c *cow) copyOnRewriteRefOfMultiLinestringExpr(n *MultiLinestringExpr, pare } out = n if c.pre == nil || c.pre(n, parent) { - _LinestringParams, changedLinestringParams := c.copyOnRewriteExprs(n.LinestringParams, n) + var changedLinestringParams bool + _LinestringParams := make([]Expr, len(n.LinestringParams)) + for x, el := range n.LinestringParams { + this, changed := c.copyOnRewriteExpr(el, n) + _LinestringParams[x] = this.(Expr) + if changed { + changedLinestringParams = true + } + } if changedLinestringParams { res := *n - res.LinestringParams, _ = _LinestringParams.(Exprs) + res.LinestringParams = _LinestringParams out = &res if c.cloned != nil { c.cloned(n, out) @@ -4078,10 +4173,18 @@ func (c *cow) copyOnRewriteRefOfMultiPointExpr(n *MultiPointExpr, parent SQLNode } out = n if c.pre == nil || c.pre(n, parent) { - _PointParams, changedPointParams := c.copyOnRewriteExprs(n.PointParams, n) + var changedPointParams bool + _PointParams := make([]Expr, len(n.PointParams)) + for x, el := range n.PointParams { + this, changed := c.copyOnRewriteExpr(el, n) + _PointParams[x] = this.(Expr) + if changed { + changedPointParams = true + } + } if changedPointParams { res := *n - res.PointParams, _ = _PointParams.(Exprs) + res.PointParams = _PointParams out = &res if c.cloned != nil { c.cloned(n, out) @@ -4100,10 +4203,18 @@ func (c *cow) copyOnRewriteRefOfMultiPolygonExpr(n *MultiPolygonExpr, parent SQL } out = n if c.pre == nil || c.pre(n, parent) { - _PolygonParams, changedPolygonParams := c.copyOnRewriteExprs(n.PolygonParams, n) + var changedPolygonParams bool + _PolygonParams := make([]Expr, len(n.PolygonParams)) + for x, el := range n.PolygonParams { + this, changed := c.copyOnRewriteExpr(el, n) + _PolygonParams[x] = this.(Expr) + if changed { + changedPolygonParams = true + } + } if changedPolygonParams { res := *n - res.PolygonParams, _ = _PolygonParams.(Exprs) + res.PolygonParams = _PolygonParams out = &res if c.cloned != nil { c.cloned(n, out) @@ -4772,10 +4883,18 @@ func (c *cow) copyOnRewriteRefOfPolygonExpr(n *PolygonExpr, parent SQLNode) (out } out = n if c.pre == nil || c.pre(n, parent) { - _LinestringParams, changedLinestringParams := c.copyOnRewriteExprs(n.LinestringParams, n) + var changedLinestringParams bool + _LinestringParams := make([]Expr, len(n.LinestringParams)) + for x, el := range n.LinestringParams { + this, changed := c.copyOnRewriteExpr(el, n) + _LinestringParams[x] = this.(Expr) + if changed { + changedLinestringParams = true + } + } if changedLinestringParams { res := *n - res.LinestringParams, _ = _LinestringParams.(Exprs) + res.LinestringParams = _LinestringParams out = &res if c.cloned != nil { c.cloned(n, out) @@ -5242,7 +5361,7 @@ func (c *cow) copyOnRewriteRefOfSelect(n *Select, parent SQLNode) (out SQLNode, } } _Comments, changedComments := c.copyOnRewriteRefOfParsedComments(n.Comments, n) - _SelectExprs, changedSelectExprs := c.copyOnRewriteSelectExprs(n.SelectExprs, n) + _SelectExprs, changedSelectExprs := c.copyOnRewriteRefOfSelectExprs(n.SelectExprs, n) _Where, changedWhere := c.copyOnRewriteRefOfWhere(n.Where, n) _GroupBy, changedGroupBy := c.copyOnRewriteRefOfGroupBy(n.GroupBy, n) _Having, changedHaving := c.copyOnRewriteRefOfWhere(n.Having, n) @@ -5255,7 +5374,7 @@ func (c *cow) copyOnRewriteRefOfSelect(n *Select, parent SQLNode) (out SQLNode, res.With, _ = _With.(*With) res.From = _From res.Comments, _ = _Comments.(*ParsedComments) - res.SelectExprs, _ = _SelectExprs.(SelectExprs) + res.SelectExprs, _ = _SelectExprs.(*SelectExprs) res.Where, _ = _Where.(*Where) res.GroupBy, _ = _GroupBy.(*GroupBy) res.Having, _ = _Having.(*Where) @@ -5275,22 +5394,29 @@ func (c *cow) copyOnRewriteRefOfSelect(n *Select, parent SQLNode) (out SQLNode, } return } -func (c *cow) copyOnRewriteSelectExprs(n SelectExprs, parent SQLNode) (out SQLNode, changed bool) { +func (c *cow) copyOnRewriteRefOfSelectExprs(n *SelectExprs, parent SQLNode) (out SQLNode, changed bool) { if n == nil || c.cursor.stop { return n, false } out = n if c.pre == nil || c.pre(n, parent) { - res := make(SelectExprs, len(n)) - for x, el := range n { - this, change := c.copyOnRewriteSelectExpr(el, n) - res[x] = this.(SelectExpr) - if change { - changed = true + var changedExprs bool + _Exprs := make([]SelectExpr, len(n.Exprs)) + for x, el := range n.Exprs { + this, changed := c.copyOnRewriteSelectExpr(el, n) + _Exprs[x] = this.(SelectExpr) + if changed { + changedExprs = true } } - if changed { - out = res + if changedExprs { + res := *n + res.Exprs = _Exprs + out = &res + if c.cloned != nil { + c.cloned(n, out) + } + changed = true } } if c.post != nil { @@ -6714,13 +6840,21 @@ func (c *cow) copyOnRewriteRefOfWindowSpecification(n *WindowSpecification, pare out = n if c.pre == nil || c.pre(n, parent) { _Name, changedName := c.copyOnRewriteIdentifierCI(n.Name, n) - _PartitionClause, changedPartitionClause := c.copyOnRewriteExprs(n.PartitionClause, n) + var changedPartitionClause bool + _PartitionClause := make([]Expr, len(n.PartitionClause)) + for x, el := range n.PartitionClause { + this, changed := c.copyOnRewriteExpr(el, n) + _PartitionClause[x] = this.(Expr) + if changed { + changedPartitionClause = true + } + } _OrderClause, changedOrderClause := c.copyOnRewriteOrderBy(n.OrderClause, n) _FrameClause, changedFrameClause := c.copyOnRewriteRefOfFrameClause(n.FrameClause, n) if changedName || changedPartitionClause || changedOrderClause || changedFrameClause { res := *n res.Name, _ = _Name.(IdentifierCI) - res.PartitionClause, _ = _PartitionClause.(Exprs) + res.PartitionClause = _PartitionClause res.OrderClause, _ = _OrderClause.(OrderBy) res.FrameClause, _ = _FrameClause.(*FrameClause) out = &res diff --git a/go/vt/sqlparser/ast_equals.go b/go/vt/sqlparser/ast_equals.go index 93f10376177..2795daab2c5 100644 --- a/go/vt/sqlparser/ast_equals.go +++ b/go/vt/sqlparser/ast_equals.go @@ -440,12 +440,12 @@ func (cmp *Comparator) SQLNode(inA, inB SQLNode) bool { return false } return cmp.RefOfExplainTab(a, b) - case Exprs: - b, ok := inB.(Exprs) + case *Exprs: + b, ok := inB.(*Exprs) if !ok { return false } - return cmp.Exprs(a, b) + return cmp.RefOfExprs(a, b) case *ExtractFuncExpr: b, ok := inB.(*ExtractFuncExpr) if !ok { @@ -1262,12 +1262,12 @@ func (cmp *Comparator) SQLNode(inA, inB SQLNode) bool { return false } return cmp.RefOfSelect(a, b) - case SelectExprs: - b, ok := inB.(SelectExprs) + case *SelectExprs: + b, ok := inB.(*SelectExprs) if !ok { return false } - return cmp.SelectExprs(a, b) + return cmp.RefOfSelectExprs(a, b) case *SelectInto: b, ok := inB.(*SelectInto) if !ok { @@ -2032,7 +2032,7 @@ func (cmp *Comparator) RefOfCallProc(a, b *CallProc) bool { return false } return cmp.TableName(a.Name, b.Name) && - cmp.Exprs(a.Params, b.Params) + cmp.SliceOfExpr(a.Params, b.Params) } // RefOfCaseExpr does deep equals between the two objects. @@ -2084,7 +2084,7 @@ func (cmp *Comparator) RefOfCharExpr(a, b *CharExpr) bool { return false } return a.Charset == b.Charset && - cmp.Exprs(a.Exprs, b.Exprs) + cmp.SliceOfExpr(a.Exprs, b.Exprs) } // RefOfCheckConstraintDefinition does deep equals between the two objects. @@ -2278,7 +2278,7 @@ func (cmp *Comparator) RefOfCount(a, b *Count) bool { return false } return a.Distinct == b.Distinct && - cmp.Exprs(a.Args, b.Args) && + cmp.SliceOfExpr(a.Args, b.Args) && cmp.RefOfOverClause(a.OverClause, b.OverClause) } @@ -2534,17 +2534,15 @@ func (cmp *Comparator) RefOfExplainTab(a, b *ExplainTab) bool { cmp.TableName(a.Table, b.Table) } -// Exprs does deep equals between the two objects. -func (cmp *Comparator) Exprs(a, b Exprs) bool { - if len(a) != len(b) { - return false +// RefOfExprs does deep equals between the two objects. +func (cmp *Comparator) RefOfExprs(a, b *Exprs) bool { + if a == b { + return true } - for i := 0; i < len(a); i++ { - if !cmp.Expr(a[i], b[i]) { - return false - } + if a == nil || b == nil { + return false } - return true + return cmp.SliceOfExpr(a.Exprs, b.Exprs) } // RefOfExtractFuncExpr does deep equals between the two objects. @@ -2671,7 +2669,7 @@ func (cmp *Comparator) RefOfFuncExpr(a, b *FuncExpr) bool { } return cmp.IdentifierCS(a.Qualifier, b.Qualifier) && cmp.IdentifierCI(a.Name, b.Name) && - cmp.Exprs(a.Exprs, b.Exprs) + cmp.SliceOfExpr(a.Exprs, b.Exprs) } // RefOfGTIDFuncExpr does deep equals between the two objects. @@ -2841,7 +2839,7 @@ func (cmp *Comparator) RefOfGroupConcatExpr(a, b *GroupConcatExpr) bool { } return a.Distinct == b.Distinct && a.Separator == b.Separator && - cmp.Exprs(a.Exprs, b.Exprs) && + cmp.SliceOfExpr(a.Exprs, b.Exprs) && cmp.OrderBy(a.OrderBy, b.OrderBy) && cmp.RefOfLimit(a.Limit, b.Limit) } @@ -2965,7 +2963,7 @@ func (cmp *Comparator) RefOfIntervalFuncExpr(a, b *IntervalFuncExpr) bool { return false } return cmp.Expr(a.Expr, b.Expr) && - cmp.Exprs(a.Exprs, b.Exprs) + cmp.SliceOfExpr(a.Exprs, b.Exprs) } // RefOfIntroducerExpr does deep equals between the two objects. @@ -3012,7 +3010,7 @@ func (cmp *Comparator) RefOfJSONArrayExpr(a, b *JSONArrayExpr) bool { if a == nil || b == nil { return false } - return cmp.Exprs(a.Params, b.Params) + return cmp.SliceOfExpr(a.Params, b.Params) } // RefOfJSONAttributesExpr does deep equals between the two objects. @@ -3157,7 +3155,7 @@ func (cmp *Comparator) RefOfJSONRemoveExpr(a, b *JSONRemoveExpr) bool { return false } return cmp.Expr(a.JSONDoc, b.JSONDoc) && - cmp.Exprs(a.PathList, b.PathList) + cmp.SliceOfExpr(a.PathList, b.PathList) } // RefOfJSONSchemaValidFuncExpr does deep equals between the two objects. @@ -3271,7 +3269,7 @@ func (cmp *Comparator) RefOfJSONValueMergeExpr(a, b *JSONValueMergeExpr) bool { } return a.Type == b.Type && cmp.Expr(a.JSONDoc, b.JSONDoc) && - cmp.Exprs(a.JSONDocList, b.JSONDocList) + cmp.SliceOfExpr(a.JSONDocList, b.JSONDocList) } // RefOfJSONValueModifierExpr does deep equals between the two objects. @@ -3397,7 +3395,7 @@ func (cmp *Comparator) RefOfLineStringExpr(a, b *LineStringExpr) bool { if a == nil || b == nil { return false } - return cmp.Exprs(a.PointParams, b.PointParams) + return cmp.SliceOfExpr(a.PointParams, b.PointParams) } // RefOfLinestrPropertyFuncExpr does deep equals between the two objects. @@ -3556,7 +3554,7 @@ func (cmp *Comparator) RefOfMultiLinestringExpr(a, b *MultiLinestringExpr) bool if a == nil || b == nil { return false } - return cmp.Exprs(a.LinestringParams, b.LinestringParams) + return cmp.SliceOfExpr(a.LinestringParams, b.LinestringParams) } // RefOfMultiPointExpr does deep equals between the two objects. @@ -3567,7 +3565,7 @@ func (cmp *Comparator) RefOfMultiPointExpr(a, b *MultiPointExpr) bool { if a == nil || b == nil { return false } - return cmp.Exprs(a.PointParams, b.PointParams) + return cmp.SliceOfExpr(a.PointParams, b.PointParams) } // RefOfMultiPolygonExpr does deep equals between the two objects. @@ -3578,7 +3576,7 @@ func (cmp *Comparator) RefOfMultiPolygonExpr(a, b *MultiPolygonExpr) bool { if a == nil || b == nil { return false } - return cmp.Exprs(a.PolygonParams, b.PolygonParams) + return cmp.SliceOfExpr(a.PolygonParams, b.PolygonParams) } // RefOfNTHValueExpr does deep equals between the two objects. @@ -3954,7 +3952,7 @@ func (cmp *Comparator) RefOfPolygonExpr(a, b *PolygonExpr) bool { if a == nil || b == nil { return false } - return cmp.Exprs(a.LinestringParams, b.LinestringParams) + return cmp.SliceOfExpr(a.LinestringParams, b.LinestringParams) } // RefOfPolygonPropertyFuncExpr does deep equals between the two objects. @@ -4208,7 +4206,7 @@ func (cmp *Comparator) RefOfSelect(a, b *Select) bool { cmp.RefOfWith(a.With, b.With) && cmp.SliceOfTableExpr(a.From, b.From) && cmp.RefOfParsedComments(a.Comments, b.Comments) && - cmp.SelectExprs(a.SelectExprs, b.SelectExprs) && + cmp.RefOfSelectExprs(a.SelectExprs, b.SelectExprs) && cmp.RefOfWhere(a.Where, b.Where) && cmp.RefOfGroupBy(a.GroupBy, b.GroupBy) && cmp.RefOfWhere(a.Having, b.Having) && @@ -4219,17 +4217,15 @@ func (cmp *Comparator) RefOfSelect(a, b *Select) bool { cmp.RefOfSelectInto(a.Into, b.Into) } -// SelectExprs does deep equals between the two objects. -func (cmp *Comparator) SelectExprs(a, b SelectExprs) bool { - if len(a) != len(b) { - return false +// RefOfSelectExprs does deep equals between the two objects. +func (cmp *Comparator) RefOfSelectExprs(a, b *SelectExprs) bool { + if a == b { + return true } - for i := 0; i < len(a); i++ { - if !cmp.SelectExpr(a[i], b[i]) { - return false - } + if a == nil || b == nil { + return false } - return true + return cmp.SliceOfSelectExpr(a.Exprs, b.Exprs) } // RefOfSelectInto does deep equals between the two objects. @@ -5006,7 +5002,7 @@ func (cmp *Comparator) RefOfWindowSpecification(a, b *WindowSpecification) bool return false } return cmp.IdentifierCI(a.Name, b.Name) && - cmp.Exprs(a.PartitionClause, b.PartitionClause) && + cmp.SliceOfExpr(a.PartitionClause, b.PartitionClause) && cmp.OrderBy(a.OrderClause, b.OrderClause) && cmp.RefOfFrameClause(a.FrameClause, b.FrameClause) } @@ -7328,6 +7324,19 @@ func (cmp *Comparator) SliceOfTxAccessMode(a, b []TxAccessMode) bool { return true } +// SliceOfExpr does deep equals between the two objects. +func (cmp *Comparator) SliceOfExpr(a, b []Expr) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !cmp.Expr(a[i], b[i]) { + return false + } + } + return true +} + // SliceOfRefOfWhen does deep equals between the two objects. func (cmp *Comparator) SliceOfRefOfWhen(a, b []*When) bool { if len(a) != len(b) { @@ -7423,19 +7432,6 @@ func (cmp *Comparator) SliceOfRefOfVariable(a, b []*Variable) bool { return true } -// SliceOfExpr does deep equals between the two objects. -func (cmp *Comparator) SliceOfExpr(a, b []Expr) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !cmp.Expr(a[i], b[i]) { - return false - } - } - return true -} - // RefOfIdentifierCI does deep equals between the two objects. func (cmp *Comparator) RefOfIdentifierCI(a, b *IdentifierCI) bool { if a == b { @@ -7626,6 +7622,19 @@ func (cmp *Comparator) RefOfRootNode(a, b *RootNode) bool { return cmp.SQLNode(a.SQLNode, b.SQLNode) } +// SliceOfSelectExpr does deep equals between the two objects. +func (cmp *Comparator) SliceOfSelectExpr(a, b []SelectExpr) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !cmp.SelectExpr(a[i], b[i]) { + return false + } + } + return true +} + // RefOfTableName does deep equals between the two objects. func (cmp *Comparator) RefOfTableName(a, b *TableName) bool { if a == b { diff --git a/go/vt/sqlparser/ast_format.go b/go/vt/sqlparser/ast_format.go index 37539c450b2..8939af71f51 100644 --- a/go/vt/sqlparser/ast_format.go +++ b/go/vt/sqlparser/ast_format.go @@ -1127,7 +1127,7 @@ func (node *DeallocateStmt) Format(buf *TrackedBuffer) { // Format formats the node. func (node *CallProc) Format(buf *TrackedBuffer) { - buf.astPrintf(node, "call %v(%v)", node.Name, node.Params) + buf.astPrintf(node, "call %v(%n)", node.Name, node.Params) } // Format formats the node. @@ -1155,9 +1155,9 @@ func (node *ParsedComments) Format(buf *TrackedBuffer) { } // Format formats the node. -func (node SelectExprs) Format(buf *TrackedBuffer) { +func (node *SelectExprs) Format(buf *TrackedBuffer) { var prefix string - for _, n := range node { + for _, n := range node.Exprs { buf.astPrintf(node, "%s%v", prefix, n) prefix = ", " } @@ -1312,9 +1312,9 @@ func (node *Where) Format(buf *TrackedBuffer) { } // Format formats the node. -func (node Exprs) Format(buf *TrackedBuffer) { +func (node *Exprs) Format(buf *TrackedBuffer) { var prefix string - for _, n := range node { + for _, n := range node.Exprs { buf.astPrintf(node, "%s%v", prefix, n) prefix = ", " } @@ -1499,7 +1499,13 @@ func (node *ColName) Format(buf *TrackedBuffer) { // Format formats the node. func (node ValTuple) Format(buf *TrackedBuffer) { - buf.astPrintf(node, "(%v)", Exprs(node)) + var prefix string + buf.WriteString("(") + for _, n := range node { + buf.astPrintf(node, "%s%v", prefix, n) + prefix = ", " + } + buf.WriteString(")") } // Format formats the node. @@ -1688,15 +1694,15 @@ func (node *FuncExpr) Format(buf *TrackedBuffer) { } else { buf.WriteString(funcName) } - buf.astPrintf(node, "(%v)", node.Exprs) + buf.astPrintf(node, "(%n)", node.Exprs) } // Format formats the node func (node *GroupConcatExpr) Format(buf *TrackedBuffer) { if node.Distinct { - buf.astPrintf(node, "group_concat(%s%v%v", DistinctStr, node.Exprs, node.OrderBy) + buf.astPrintf(node, "group_concat(%s%n%v", DistinctStr, node.Exprs, node.OrderBy) } else { - buf.astPrintf(node, "group_concat(%v%v", node.Exprs, node.OrderBy) + buf.astPrintf(node, "group_concat(%n%v", node.Exprs, node.OrderBy) } if node.Separator != "" { buf.astPrintf(node, " %s %#s", keywordStrings[SEPARATOR], node.Separator) @@ -1744,7 +1750,7 @@ func (node *WindowSpecification) Format(buf *TrackedBuffer) { buf.astPrintf(node, " %v", node.Name) } if node.PartitionClause != nil { - buf.astPrintf(node, " partition by %v", node.PartitionClause) + buf.astPrintf(node, " partition by %n", node.PartitionClause) } if node.OrderClause != nil { buf.astPrintf(node, "%v", node.OrderClause) @@ -1898,7 +1904,7 @@ func (node *InsertExpr) Format(buf *TrackedBuffer) { // Format formats the node. func (node *IntervalFuncExpr) Format(buf *TrackedBuffer) { - buf.astPrintf(node, "interval(%v, %v)", node.Expr, node.Exprs) + buf.astPrintf(node, "interval(%v, %n)", node.Expr, node.Exprs) } // Format formats the node. @@ -1912,7 +1918,7 @@ func (node *LocateExpr) Format(buf *TrackedBuffer) { // Format formats the node. func (node *CharExpr) Format(buf *TrackedBuffer) { - buf.astPrintf(node, "char(%v", node.Exprs) + buf.astPrintf(node, "char(%n", node.Exprs) if node.Charset != "" { buf.astPrintf(node, " using %#s", node.Charset) } @@ -2861,7 +2867,7 @@ func (node *Count) Format(buf *TrackedBuffer) { if node.Distinct { buf.literal(DistinctStr) } - buf.astPrintf(node, "%v)", node.Args) + buf.astPrintf(node, "%n)", node.Args) if node.OverClause != nil { buf.astPrintf(node, " %v", node.OverClause) } @@ -3032,12 +3038,12 @@ func (node *PointExpr) Format(buf *TrackedBuffer) { // Format formats the node. func (node *LineStringExpr) Format(buf *TrackedBuffer) { - buf.astPrintf(node, "linestring(%v)", node.PointParams) + buf.astPrintf(node, "linestring(%n)", node.PointParams) } // Format formats the node. func (node *PolygonExpr) Format(buf *TrackedBuffer) { - buf.astPrintf(node, "polygon(%v)", node.LinestringParams) + buf.astPrintf(node, "polygon(%n)", node.LinestringParams) } // Format formats the node. @@ -3051,17 +3057,17 @@ func (node *PurgeBinaryLogs) Format(buf *TrackedBuffer) { } func (node *MultiPolygonExpr) Format(buf *TrackedBuffer) { - buf.astPrintf(node, "multipolygon(%v)", node.PolygonParams) + buf.astPrintf(node, "multipolygon(%n)", node.PolygonParams) } // Format formats the node. func (node *MultiPointExpr) Format(buf *TrackedBuffer) { - buf.astPrintf(node, "multipoint(%v)", node.PointParams) + buf.astPrintf(node, "multipoint(%n)", node.PointParams) } // Format formats the node. func (node *MultiLinestringExpr) Format(buf *TrackedBuffer) { - buf.astPrintf(node, "multilinestring(%v)", node.LinestringParams) + buf.astPrintf(node, "multilinestring(%n)", node.LinestringParams) } // Format formats the node diff --git a/go/vt/sqlparser/ast_format_fast.go b/go/vt/sqlparser/ast_format_fast.go index 7a818faf0c0..2a6797871eb 100644 --- a/go/vt/sqlparser/ast_format_fast.go +++ b/go/vt/sqlparser/ast_format_fast.go @@ -1487,7 +1487,7 @@ func (node *CallProc) FormatFast(buf *TrackedBuffer) { buf.WriteString("call ") node.Name.FormatFast(buf) buf.WriteByte('(') - node.Params.FormatFast(buf) + buf.formatExprs(node.Params) buf.WriteByte(')') } @@ -1518,9 +1518,9 @@ func (node *ParsedComments) FormatFast(buf *TrackedBuffer) { } // FormatFast formats the node. -func (node SelectExprs) FormatFast(buf *TrackedBuffer) { +func (node *SelectExprs) FormatFast(buf *TrackedBuffer) { var prefix string - for _, n := range node { + for _, n := range node.Exprs { buf.WriteString(prefix) n.FormatFast(buf) prefix = ", " @@ -1704,9 +1704,9 @@ func (node *Where) FormatFast(buf *TrackedBuffer) { } // FormatFast formats the node. -func (node Exprs) FormatFast(buf *TrackedBuffer) { +func (node *Exprs) FormatFast(buf *TrackedBuffer) { var prefix string - for _, n := range node { + for _, n := range node.Exprs { buf.WriteString(prefix) n.FormatFast(buf) prefix = ", " @@ -1936,9 +1936,14 @@ func (node *ColName) FormatFast(buf *TrackedBuffer) { // FormatFast formats the node. func (node ValTuple) FormatFast(buf *TrackedBuffer) { - buf.WriteByte('(') - Exprs(node).FormatFast(buf) - buf.WriteByte(')') + var prefix string + buf.WriteString("(") + for _, n := range node { + buf.WriteString(prefix) + buf.printExpr(node, n, true) + prefix = ", " + } + buf.WriteString(")") } // FormatFast formats the node. @@ -2223,7 +2228,7 @@ func (node *FuncExpr) FormatFast(buf *TrackedBuffer) { buf.WriteString(funcName) } buf.WriteByte('(') - node.Exprs.FormatFast(buf) + buf.formatExprs(node.Exprs) buf.WriteByte(')') } @@ -2232,11 +2237,11 @@ func (node *GroupConcatExpr) FormatFast(buf *TrackedBuffer) { if node.Distinct { buf.WriteString("group_concat(") buf.WriteString(DistinctStr) - node.Exprs.FormatFast(buf) + buf.formatExprs(node.Exprs) node.OrderBy.FormatFast(buf) } else { buf.WriteString("group_concat(") - node.Exprs.FormatFast(buf) + buf.formatExprs(node.Exprs) node.OrderBy.FormatFast(buf) } if node.Separator != "" { @@ -2302,7 +2307,7 @@ func (node *WindowSpecification) FormatFast(buf *TrackedBuffer) { } if node.PartitionClause != nil { buf.WriteString(" partition by ") - node.PartitionClause.FormatFast(buf) + buf.formatExprs(node.PartitionClause) } if node.OrderClause != nil { node.OrderClause.FormatFast(buf) @@ -2519,7 +2524,7 @@ func (node *IntervalFuncExpr) FormatFast(buf *TrackedBuffer) { buf.WriteString("interval(") buf.printExpr(node, node.Expr, true) buf.WriteString(", ") - node.Exprs.FormatFast(buf) + buf.formatExprs(node.Exprs) buf.WriteByte(')') } @@ -2545,7 +2550,7 @@ func (node *LocateExpr) FormatFast(buf *TrackedBuffer) { // FormatFast formats the node. func (node *CharExpr) FormatFast(buf *TrackedBuffer) { buf.WriteString("char(") - node.Exprs.FormatFast(buf) + buf.formatExprs(node.Exprs) if node.Charset != "" { buf.WriteString(" using ") buf.WriteString(node.Charset) @@ -3760,7 +3765,7 @@ func (node *Count) FormatFast(buf *TrackedBuffer) { if node.Distinct { buf.WriteString(DistinctStr) } - node.Args.FormatFast(buf) + buf.formatExprs(node.Args) buf.WriteByte(')') if node.OverClause != nil { buf.WriteByte(' ') @@ -3984,14 +3989,14 @@ func (node *PointExpr) FormatFast(buf *TrackedBuffer) { // FormatFast formats the node. func (node *LineStringExpr) FormatFast(buf *TrackedBuffer) { buf.WriteString("linestring(") - node.PointParams.FormatFast(buf) + buf.formatExprs(node.PointParams) buf.WriteByte(')') } // FormatFast formats the node. func (node *PolygonExpr) FormatFast(buf *TrackedBuffer) { buf.WriteString("polygon(") - node.LinestringParams.FormatFast(buf) + buf.formatExprs(node.LinestringParams) buf.WriteByte(')') } @@ -4011,21 +4016,21 @@ func (node *PurgeBinaryLogs) FormatFast(buf *TrackedBuffer) { func (node *MultiPolygonExpr) FormatFast(buf *TrackedBuffer) { buf.WriteString("multipolygon(") - node.PolygonParams.FormatFast(buf) + buf.formatExprs(node.PolygonParams) buf.WriteByte(')') } // FormatFast formats the node. func (node *MultiPointExpr) FormatFast(buf *TrackedBuffer) { buf.WriteString("multipoint(") - node.PointParams.FormatFast(buf) + buf.formatExprs(node.PointParams) buf.WriteByte(')') } // FormatFast formats the node. func (node *MultiLinestringExpr) FormatFast(buf *TrackedBuffer) { buf.WriteString("multilinestring(") - node.LinestringParams.FormatFast(buf) + buf.formatExprs(node.LinestringParams) buf.WriteByte(')') } diff --git a/go/vt/sqlparser/ast_format_test.go b/go/vt/sqlparser/ast_format_test.go new file mode 100644 index 00000000000..5ea4e5e3d2f --- /dev/null +++ b/go/vt/sqlparser/ast_format_test.go @@ -0,0 +1,35 @@ +/* +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/assert" +) + +func TestColNamesInSlice(t *testing.T) { + c1 := NewColName("a1") + c2 := NewColName("a2") + exprs := []Expr{ + c1, + c2, + } + + result := SliceString(exprs) + assert.Equal(t, "a1, a2", result) +} diff --git a/go/vt/sqlparser/ast_funcs.go b/go/vt/sqlparser/ast_funcs.go index 2da783af3df..ba7648778e3 100644 --- a/go/vt/sqlparser/ast_funcs.go +++ b/go/vt/sqlparser/ast_funcs.go @@ -890,7 +890,7 @@ func NewLimitWithoutOffset(rowCount int) *Limit { // NewSelect is used to create a select statement func NewSelect( comments Comments, - exprs SelectExprs, + exprs *SelectExprs, selectOptions []string, into *SelectInto, from TableExprs, @@ -1195,8 +1195,25 @@ func compliantName(in string) string { return buf.String() } -func (node *Select) AddSelectExprs(selectExprs SelectExprs) { - node.SelectExprs = append(node.SelectExprs, selectExprs...) +func (node *Select) AddSelectExprs(selectExprs *SelectExprs) { + if node.SelectExprs == nil { + node.SelectExprs = &SelectExprs{} + } + node.SelectExprs.Exprs = append(node.SelectExprs.Exprs, selectExprs.Exprs...) +} + +func (node *Select) AddSelectExpr(expr SelectExpr) { + if node.SelectExprs == nil { + node.SelectExprs = &SelectExprs{} + } + node.SelectExprs.Exprs = append(node.SelectExprs.Exprs, expr) +} + +func (node *Select) SetSelectExprs(exprs ...SelectExpr) { + if node.SelectExprs == nil { + node.SelectExprs = &SelectExprs{} + } + node.SelectExprs.Exprs = exprs } // AddOrder adds an order by element @@ -1256,12 +1273,18 @@ func (node *Select) IsDistinct() bool { // GetColumnCount return SelectExprs count. func (node *Select) GetColumnCount() int { - return len(node.SelectExprs) + if node.SelectExprs == nil { + return 0 + } + return len(node.SelectExprs.Exprs) } // GetColumns gets the columns -func (node *Select) GetColumns() SelectExprs { - return node.SelectExprs +func (node *Select) GetColumns() []SelectExpr { + if node.SelectExprs == nil { + return nil + } + return node.SelectExprs.Exprs } // SetComments implements the Commented interface @@ -1362,7 +1385,7 @@ func (node *Union) GetLimit() *Limit { } // GetColumns gets the columns -func (node *Union) GetColumns() SelectExprs { +func (node *Union) GetColumns() []SelectExpr { return node.Left.GetColumns() } @@ -2354,7 +2377,7 @@ func ContainsAggregation(e SQLNode) bool { } // setFuncArgs sets the arguments for the aggregation function, while checking that there is only one argument -func setFuncArgs(aggr AggrFunc, exprs Exprs, name string) error { +func setFuncArgs(aggr AggrFunc, exprs []Expr, name string) error { if len(exprs) != 1 { return vterrors.VT03001(name) } @@ -2410,8 +2433,8 @@ func (ae *AliasedExpr) ColumnName() string { } // AllAggregation returns true if all the expressions contain aggregation -func (s SelectExprs) AllAggregation() bool { - for _, k := range s { +func (s *SelectExprs) AllAggregation() bool { + for _, k := range s.Exprs { if !ContainsAggregation(k) { return false } @@ -3070,14 +3093,27 @@ func (node *ValuesStatement) GetColumnCount() int { panic("no columns available") // TODO: we need a better solution than a panic } -func (node *ValuesStatement) GetColumns() (result SelectExprs) { +func (node *ValuesStatement) GetColumns() []SelectExpr { + var sel []SelectExpr columnCount := node.GetColumnCount() for i := range columnCount { - result = append(result, &AliasedExpr{Expr: NewColName(fmt.Sprintf("column_%d", i))}) + sel = append(sel, &AliasedExpr{Expr: NewColName(fmt.Sprintf("column_%d", i))}) } + _ = sel panic("no columns available") // TODO: we need a better solution than a panic } func (node *ValuesStatement) SetComments(comments Comments) {} func (node *ValuesStatement) GetParsedComments() *ParsedComments { return nil } + +func NewFuncExpr(name string, exprs ...Expr) *FuncExpr { + return &FuncExpr{ + Name: NewIdentifierCI(name), + Exprs: exprs, + } +} + +func NewExprs(exprs ...Expr) *Exprs { + return &Exprs{Exprs: exprs} +} diff --git a/go/vt/sqlparser/ast_rewrite.go b/go/vt/sqlparser/ast_rewrite.go index 690b381b082..a4cfeb4f01c 100644 --- a/go/vt/sqlparser/ast_rewrite.go +++ b/go/vt/sqlparser/ast_rewrite.go @@ -160,8 +160,8 @@ func (a *application) rewriteSQLNode(parent SQLNode, node SQLNode, replacer repl return a.rewriteRefOfExplainStmt(parent, node, replacer) case *ExplainTab: return a.rewriteRefOfExplainTab(parent, node, replacer) - case Exprs: - return a.rewriteExprs(parent, node, replacer) + case *Exprs: + return a.rewriteRefOfExprs(parent, node, replacer) case *ExtractFuncExpr: return a.rewriteRefOfExtractFuncExpr(parent, node, replacer) case *ExtractValueExpr: @@ -434,8 +434,8 @@ func (a *application) rewriteSQLNode(parent SQLNode, node SQLNode, replacer repl return a.rewriteRefOfSavepoint(parent, node, replacer) case *Select: return a.rewriteRefOfSelect(parent, node, replacer) - case SelectExprs: - return a.rewriteSelectExprs(parent, node, replacer) + case *SelectExprs: + return a.rewriteRefOfSelectExprs(parent, node, replacer) case *SelectInto: return a.rewriteRefOfSelectInto(parent, node, replacer) case *Set: @@ -577,7 +577,12 @@ func (a *application) rewriteRefOfAddColumns(parent SQLNode, node *AddColumns, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -613,7 +618,12 @@ func (a *application) rewriteRefOfAddConstraintDefinition(parent SQLNode, node * a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -640,7 +650,12 @@ func (a *application) rewriteRefOfAddIndexDefinition(parent SQLNode, node *AddIn a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -667,7 +682,12 @@ func (a *application) rewriteRefOfAliasedExpr(parent SQLNode, node *AliasedExpr, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -699,7 +719,12 @@ func (a *application) rewriteRefOfAliasedTableExpr(parent SQLNode, node *Aliased a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -746,7 +771,12 @@ func (a *application) rewriteRefOfAlterCharset(parent SQLNode, node *AlterCharse a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -770,7 +800,12 @@ func (a *application) rewriteRefOfAlterCheck(parent SQLNode, node *AlterCheck, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -797,7 +832,12 @@ func (a *application) rewriteRefOfAlterColumn(parent SQLNode, node *AlterColumn, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -829,7 +869,12 @@ func (a *application) rewriteRefOfAlterDatabase(parent SQLNode, node *AlterDatab a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -861,7 +906,12 @@ func (a *application) rewriteRefOfAlterIndex(parent SQLNode, node *AlterIndex, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -888,7 +938,12 @@ func (a *application) rewriteRefOfAlterMigration(parent SQLNode, node *AlterMigr a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -915,7 +970,12 @@ func (a *application) rewriteRefOfAlterTable(parent SQLNode, node *AlterTable, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -966,7 +1026,12 @@ func (a *application) rewriteRefOfAlterView(parent SQLNode, node *AlterView, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1013,7 +1078,12 @@ func (a *application) rewriteRefOfAlterVschema(parent SQLNode, node *AlterVschem a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1059,7 +1129,12 @@ func (a *application) rewriteRefOfAnalyze(parent SQLNode, node *Analyze, replace a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1089,7 +1164,7 @@ func (a *application) rewriteRefOfAndExpr(parent SQLNode, node *AndExpr, replace kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1126,7 +1201,7 @@ func (a *application) rewriteRefOfAnyValue(parent SQLNode, node *AnyValue, repla kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1158,7 +1233,7 @@ func (a *application) rewriteRefOfArgument(parent SQLNode, node *Argument, repla kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1187,7 +1262,7 @@ func (a *application) rewriteRefOfArgumentLessWindowExpr(parent SQLNode, node *A kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1219,7 +1294,7 @@ func (a *application) rewriteRefOfAssignmentExpr(parent SQLNode, node *Assignmen kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1253,7 +1328,12 @@ func (a *application) rewriteRefOfAutoIncSpec(parent SQLNode, node *AutoIncSpec, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1288,7 +1368,7 @@ func (a *application) rewriteRefOfAvg(parent SQLNode, node *Avg, replacer replac kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1322,7 +1402,12 @@ func (a *application) rewriteRefOfBegin(parent SQLNode, node *Begin, replacer re a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1349,7 +1434,7 @@ func (a *application) rewriteRefOfBetweenExpr(parent SQLNode, node *BetweenExpr, kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1391,7 +1476,7 @@ func (a *application) rewriteRefOfBinaryExpr(parent SQLNode, node *BinaryExpr, r kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1428,7 +1513,7 @@ func (a *application) rewriteRefOfBitAnd(parent SQLNode, node *BitAnd, replacer kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1465,7 +1550,7 @@ func (a *application) rewriteRefOfBitOr(parent SQLNode, node *BitOr, replacer re kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1502,7 +1587,7 @@ func (a *application) rewriteRefOfBitXor(parent SQLNode, node *BitXor, replacer kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1536,7 +1621,12 @@ func (a *application) rewriteRefOfCallProc(parent SQLNode, node *CallProc, repla a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1545,10 +1635,14 @@ func (a *application) rewriteRefOfCallProc(parent SQLNode, node *CallProc, repla }) { return false } - if !a.rewriteExprs(node, node.Params, func(newNode, parent SQLNode) { - parent.(*CallProc).Params = newNode.(Exprs) - }) { - return false + for x, el := range node.Params { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*CallProc).Params[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -1571,7 +1665,7 @@ func (a *application) rewriteRefOfCaseExpr(parent SQLNode, node *CaseExpr, repla kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1617,7 +1711,7 @@ func (a *application) rewriteRefOfCastExpr(parent SQLNode, node *CastExpr, repla kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1651,7 +1745,12 @@ func (a *application) rewriteRefOfChangeColumn(parent SQLNode, node *ChangeColum a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1691,16 +1790,20 @@ func (a *application) rewriteRefOfCharExpr(parent SQLNode, node *CharExpr, repla kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - if !a.rewriteExprs(node, node.Exprs, func(newNode, parent SQLNode) { - parent.(*CharExpr).Exprs = newNode.(Exprs) - }) { - return false + for x, el := range node.Exprs { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*CharExpr).Exprs[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -1720,7 +1823,12 @@ func (a *application) rewriteRefOfCheckConstraintDefinition(parent SQLNode, node a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1750,7 +1858,7 @@ func (a *application) rewriteRefOfColName(parent SQLNode, node *ColName, replace kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1787,7 +1895,7 @@ func (a *application) rewriteRefOfCollateExpr(parent SQLNode, node *CollateExpr, kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1816,7 +1924,12 @@ func (a *application) rewriteRefOfColumnDefinition(parent SQLNode, node *ColumnD a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1848,7 +1961,12 @@ func (a *application) rewriteRefOfColumnType(parent SQLNode, node *ColumnType, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1874,9 +1992,8 @@ func (a *application) rewriteColumns(parent SQLNode, node Columns, replacer repl a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(Columns) a.cur.revisit = false - return a.rewriteColumns(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -1909,7 +2026,12 @@ func (a *application) rewriteRefOfCommentOnly(parent SQLNode, node *CommentOnly, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1933,7 +2055,12 @@ func (a *application) rewriteRefOfCommit(parent SQLNode, node *Commit, replacer a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1957,7 +2084,12 @@ func (a *application) rewriteRefOfCommonTableExpr(parent SQLNode, node *CommonTa a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -1997,7 +2129,7 @@ func (a *application) rewriteRefOfComparisonExpr(parent SQLNode, node *Compariso kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -2036,7 +2168,12 @@ func (a *application) rewriteRefOfConstraintDefinition(parent SQLNode, node *Con a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2071,7 +2208,7 @@ func (a *application) rewriteRefOfConvertExpr(parent SQLNode, node *ConvertExpr, kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -2105,7 +2242,12 @@ func (a *application) rewriteRefOfConvertType(parent SQLNode, node *ConvertType, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2132,7 +2274,7 @@ func (a *application) rewriteRefOfConvertUsingExpr(parent SQLNode, node *Convert kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -2164,16 +2306,20 @@ func (a *application) rewriteRefOfCount(parent SQLNode, node *Count, replacer re kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - if !a.rewriteExprs(node, node.Args, func(newNode, parent SQLNode) { - parent.(*Count).Args = newNode.(Exprs) - }) { - return false + for x, el := range node.Args { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*Count).Args[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if !a.rewriteRefOfOverClause(node, node.OverClause, func(newNode, parent SQLNode) { parent.(*Count).OverClause = newNode.(*OverClause) @@ -2201,7 +2347,7 @@ func (a *application) rewriteRefOfCountStar(parent SQLNode, node *CountStar, rep kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -2230,7 +2376,12 @@ func (a *application) rewriteRefOfCreateDatabase(parent SQLNode, node *CreateDat a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2262,7 +2413,12 @@ func (a *application) rewriteRefOfCreateTable(parent SQLNode, node *CreateTable, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2304,7 +2460,12 @@ func (a *application) rewriteRefOfCreateView(parent SQLNode, node *CreateView, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2354,7 +2515,7 @@ func (a *application) rewriteRefOfCurTimeFuncExpr(parent SQLNode, node *CurTimeF kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -2383,7 +2544,12 @@ func (a *application) rewriteRefOfDeallocateStmt(parent SQLNode, node *Deallocat a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2418,7 +2584,7 @@ func (a *application) rewriteRefOfDefault(parent SQLNode, node *Default, replace kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -2444,7 +2610,12 @@ func (a *application) rewriteRefOfDefiner(parent SQLNode, node *Definer, replace a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2468,7 +2639,12 @@ func (a *application) rewriteRefOfDelete(parent SQLNode, node *Delete, replacer a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2534,7 +2710,12 @@ func (a *application) rewriteRefOfDerivedTable(parent SQLNode, node *DerivedTabl a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2561,7 +2742,12 @@ func (a *application) rewriteRefOfDropColumn(parent SQLNode, node *DropColumn, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2588,7 +2774,12 @@ func (a *application) rewriteRefOfDropDatabase(parent SQLNode, node *DropDatabas a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2620,7 +2811,12 @@ func (a *application) rewriteRefOfDropKey(parent SQLNode, node *DropKey, replace a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2647,7 +2843,12 @@ func (a *application) rewriteRefOfDropTable(parent SQLNode, node *DropTable, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2679,7 +2880,12 @@ func (a *application) rewriteRefOfDropView(parent SQLNode, node *DropView, repla a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2711,7 +2917,12 @@ func (a *application) rewriteRefOfExecuteStmt(parent SQLNode, node *ExecuteStmt, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2755,7 +2966,7 @@ func (a *application) rewriteRefOfExistsExpr(parent SQLNode, node *ExistsExpr, r kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -2784,7 +2995,12 @@ func (a *application) rewriteRefOfExplainStmt(parent SQLNode, node *ExplainStmt, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2816,7 +3032,12 @@ func (a *application) rewriteRefOfExplainTab(parent SQLNode, node *ExplainTab, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -2835,7 +3056,7 @@ func (a *application) rewriteRefOfExplainTab(parent SQLNode, node *ExplainTab, r } return true } -func (a *application) rewriteExprs(parent SQLNode, node Exprs, replacer replacerFunc) bool { +func (a *application) rewriteRefOfExprs(parent SQLNode, node *Exprs, replacer replacerFunc) bool { if node == nil { return true } @@ -2845,18 +3066,17 @@ func (a *application) rewriteExprs(parent SQLNode, node Exprs, replacer replacer a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(Exprs) a.cur.revisit = false - return a.rewriteExprs(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - for x, el := range node { + for x, el := range node.Exprs { if !a.rewriteExpr(node, el, func(idx int) replacerFunc { return func(newNode, parent SQLNode) { - parent.(Exprs)[idx] = newNode.(Expr) + parent.(*Exprs).Exprs[idx] = newNode.(Expr) } }(x)) { return false @@ -2883,7 +3103,7 @@ func (a *application) rewriteRefOfExtractFuncExpr(parent SQLNode, node *ExtractF kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -2915,7 +3135,7 @@ func (a *application) rewriteRefOfExtractValueExpr(parent SQLNode, node *Extract kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -2952,7 +3172,7 @@ func (a *application) rewriteRefOfFirstOrLastValueExpr(parent SQLNode, node *Fir kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -2991,7 +3211,12 @@ func (a *application) rewriteRefOfFlush(parent SQLNode, node *Flush, replacer re a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3018,7 +3243,12 @@ func (a *application) rewriteRefOfForce(parent SQLNode, node *Force, replacer re a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3042,7 +3272,12 @@ func (a *application) rewriteRefOfForeignKeyDefinition(parent SQLNode, node *For a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3079,7 +3314,12 @@ func (a *application) rewriteRefOfFrameClause(parent SQLNode, node *FrameClause, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3111,7 +3351,12 @@ func (a *application) rewriteRefOfFramePoint(parent SQLNode, node *FramePoint, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3138,7 +3383,12 @@ func (a *application) rewriteRefOfFromFirstLastClause(parent SQLNode, node *From a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3165,7 +3415,7 @@ func (a *application) rewriteRefOfFuncExpr(parent SQLNode, node *FuncExpr, repla kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3181,10 +3431,14 @@ func (a *application) rewriteRefOfFuncExpr(parent SQLNode, node *FuncExpr, repla }) { return false } - if !a.rewriteExprs(node, node.Exprs, func(newNode, parent SQLNode) { - parent.(*FuncExpr).Exprs = newNode.(Exprs) - }) { - return false + for x, el := range node.Exprs { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*FuncExpr).Exprs[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -3207,7 +3461,7 @@ func (a *application) rewriteRefOfGTIDFuncExpr(parent SQLNode, node *GTIDFuncExp kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3254,7 +3508,7 @@ func (a *application) rewriteRefOfGeoHashFromLatLongExpr(parent SQLNode, node *G kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3296,7 +3550,7 @@ func (a *application) rewriteRefOfGeoHashFromPointExpr(parent SQLNode, node *Geo kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3333,7 +3587,7 @@ func (a *application) rewriteRefOfGeoJSONFromGeomExpr(parent SQLNode, node *GeoJ kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3375,7 +3629,7 @@ func (a *application) rewriteRefOfGeomCollPropertyFuncExpr(parent SQLNode, node kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3412,7 +3666,7 @@ func (a *application) rewriteRefOfGeomFormatExpr(parent SQLNode, node *GeomForma kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3449,7 +3703,7 @@ func (a *application) rewriteRefOfGeomFromGeoHashExpr(parent SQLNode, node *Geom kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3486,7 +3740,7 @@ func (a *application) rewriteRefOfGeomFromGeoJSONExpr(parent SQLNode, node *Geom kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3528,7 +3782,7 @@ func (a *application) rewriteRefOfGeomFromTextExpr(parent SQLNode, node *GeomFro kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3570,7 +3824,7 @@ func (a *application) rewriteRefOfGeomFromWKBExpr(parent SQLNode, node *GeomFrom kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3612,7 +3866,7 @@ func (a *application) rewriteRefOfGeomPropertyFuncExpr(parent SQLNode, node *Geo kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3641,7 +3895,12 @@ func (a *application) rewriteRefOfGroupBy(parent SQLNode, node *GroupBy, replace a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3675,16 +3934,20 @@ func (a *application) rewriteRefOfGroupConcatExpr(parent SQLNode, node *GroupCon kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - if !a.rewriteExprs(node, node.Exprs, func(newNode, parent SQLNode) { - parent.(*GroupConcatExpr).Exprs = newNode.(Exprs) - }) { - return false + for x, el := range node.Exprs { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*GroupConcatExpr).Exprs[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if !a.rewriteOrderBy(node, node.OrderBy, func(newNode, parent SQLNode) { parent.(*GroupConcatExpr).OrderBy = newNode.(OrderBy) @@ -3711,7 +3974,12 @@ func (a *application) rewriteIdentifierCI(parent SQLNode, node IdentifierCI, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3732,7 +4000,12 @@ func (a *application) rewriteIdentifierCS(parent SQLNode, node IdentifierCS, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3756,7 +4029,12 @@ func (a *application) rewriteRefOfIndexDefinition(parent SQLNode, node *IndexDef a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3783,7 +4061,12 @@ func (a *application) rewriteRefOfIndexHint(parent SQLNode, node *IndexHint, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3816,9 +4099,8 @@ func (a *application) rewriteIndexHints(parent SQLNode, node IndexHints, replace a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(IndexHints) a.cur.revisit = false - return a.rewriteIndexHints(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3851,7 +4133,12 @@ func (a *application) rewriteRefOfIndexInfo(parent SQLNode, node *IndexInfo, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3883,7 +4170,12 @@ func (a *application) rewriteRefOfInsert(parent SQLNode, node *Insert, replacer a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -3943,7 +4235,7 @@ func (a *application) rewriteRefOfInsertExpr(parent SQLNode, node *InsertExpr, r kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -3990,7 +4282,7 @@ func (a *application) rewriteRefOfIntervalDateExpr(parent SQLNode, node *Interva kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4027,7 +4319,7 @@ func (a *application) rewriteRefOfIntervalFuncExpr(parent SQLNode, node *Interva kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4038,10 +4330,14 @@ func (a *application) rewriteRefOfIntervalFuncExpr(parent SQLNode, node *Interva }) { return false } - if !a.rewriteExprs(node, node.Exprs, func(newNode, parent SQLNode) { - parent.(*IntervalFuncExpr).Exprs = newNode.(Exprs) - }) { - return false + for x, el := range node.Exprs { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*IntervalFuncExpr).Exprs[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -4064,7 +4360,7 @@ func (a *application) rewriteRefOfIntroducerExpr(parent SQLNode, node *Introduce kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4096,7 +4392,7 @@ func (a *application) rewriteRefOfIsExpr(parent SQLNode, node *IsExpr, replacer kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4128,7 +4424,7 @@ func (a *application) rewriteRefOfJSONArrayAgg(parent SQLNode, node *JSONArrayAg kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4165,17 +4461,21 @@ func (a *application) rewriteRefOfJSONArrayExpr(parent SQLNode, node *JSONArrayE kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - if !a.rewriteExprs(node, node.Params, func(newNode, parent SQLNode) { - parent.(*JSONArrayExpr).Params = newNode.(Exprs) - }) { - return false - } + for x, el := range node.Params { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*JSONArrayExpr).Params[idx] = newNode.(Expr) + } + }(x)) { + return false + } + } if a.post != nil { a.cur.replacer = replacer a.cur.parent = parent @@ -4197,7 +4497,7 @@ func (a *application) rewriteRefOfJSONAttributesExpr(parent SQLNode, node *JSONA kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4234,7 +4534,7 @@ func (a *application) rewriteRefOfJSONContainsExpr(parent SQLNode, node *JSONCon kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4280,7 +4580,7 @@ func (a *application) rewriteRefOfJSONContainsPathExpr(parent SQLNode, node *JSO kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4326,7 +4626,7 @@ func (a *application) rewriteRefOfJSONExtractExpr(parent SQLNode, node *JSONExtr kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4367,7 +4667,7 @@ func (a *application) rewriteRefOfJSONKeysExpr(parent SQLNode, node *JSONKeysExp kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4404,7 +4704,7 @@ func (a *application) rewriteRefOfJSONObjectAgg(parent SQLNode, node *JSONObject kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4446,7 +4746,7 @@ func (a *application) rewriteRefOfJSONObjectExpr(parent SQLNode, node *JSONObjec kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4479,7 +4779,12 @@ func (a *application) rewriteRefOfJSONObjectParam(parent SQLNode, node *JSONObje a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -4514,7 +4819,7 @@ func (a *application) rewriteRefOfJSONOverlapsExpr(parent SQLNode, node *JSONOve kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4551,7 +4856,7 @@ func (a *application) rewriteRefOfJSONPrettyExpr(parent SQLNode, node *JSONPrett kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4583,7 +4888,7 @@ func (a *application) rewriteRefOfJSONQuoteExpr(parent SQLNode, node *JSONQuoteE kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4615,7 +4920,7 @@ func (a *application) rewriteRefOfJSONRemoveExpr(parent SQLNode, node *JSONRemov kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4626,10 +4931,14 @@ func (a *application) rewriteRefOfJSONRemoveExpr(parent SQLNode, node *JSONRemov }) { return false } - if !a.rewriteExprs(node, node.PathList, func(newNode, parent SQLNode) { - parent.(*JSONRemoveExpr).PathList = newNode.(Exprs) - }) { - return false + for x, el := range node.PathList { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*JSONRemoveExpr).PathList[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -4652,7 +4961,7 @@ func (a *application) rewriteRefOfJSONSchemaValidFuncExpr(parent SQLNode, node * kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4689,7 +4998,7 @@ func (a *application) rewriteRefOfJSONSchemaValidationReportFuncExpr(parent SQLN kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4726,7 +5035,7 @@ func (a *application) rewriteRefOfJSONSearchExpr(parent SQLNode, node *JSONSearc kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4782,7 +5091,7 @@ func (a *application) rewriteRefOfJSONStorageFreeExpr(parent SQLNode, node *JSON kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4814,7 +5123,7 @@ func (a *application) rewriteRefOfJSONStorageSizeExpr(parent SQLNode, node *JSON kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4843,7 +5152,12 @@ func (a *application) rewriteRefOfJSONTableExpr(parent SQLNode, node *JSONTableE a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -4892,7 +5206,7 @@ func (a *application) rewriteRefOfJSONUnquoteExpr(parent SQLNode, node *JSONUnqu kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4924,7 +5238,7 @@ func (a *application) rewriteRefOfJSONValueExpr(parent SQLNode, node *JSONValueE kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4976,7 +5290,7 @@ func (a *application) rewriteRefOfJSONValueMergeExpr(parent SQLNode, node *JSONV kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -4987,10 +5301,14 @@ func (a *application) rewriteRefOfJSONValueMergeExpr(parent SQLNode, node *JSONV }) { return false } - if !a.rewriteExprs(node, node.JSONDocList, func(newNode, parent SQLNode) { - parent.(*JSONValueMergeExpr).JSONDocList = newNode.(Exprs) - }) { - return false + for x, el := range node.JSONDocList { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*JSONValueMergeExpr).JSONDocList[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -5013,7 +5331,7 @@ func (a *application) rewriteRefOfJSONValueModifierExpr(parent SQLNode, node *JS kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5051,7 +5369,12 @@ func (a *application) rewriteRefOfJoinCondition(parent SQLNode, node *JoinCondit a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5083,7 +5406,12 @@ func (a *application) rewriteRefOfJoinTableExpr(parent SQLNode, node *JoinTableE a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5120,7 +5448,12 @@ func (a *application) rewriteRefOfJtColumnDefinition(parent SQLNode, node *JtCol a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5144,7 +5477,12 @@ func (a *application) rewriteRefOfJtOnResponse(parent SQLNode, node *JtOnRespons a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5171,7 +5509,12 @@ func (a *application) rewriteRefOfKeyState(parent SQLNode, node *KeyState, repla a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5195,7 +5538,12 @@ func (a *application) rewriteRefOfKill(parent SQLNode, node *Kill, replacer repl a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5222,7 +5570,7 @@ func (a *application) rewriteRefOfLagLeadExpr(parent SQLNode, node *LagLeadExpr, kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5271,7 +5619,12 @@ func (a *application) rewriteRefOfLimit(parent SQLNode, node *Limit, replacer re a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5306,16 +5659,20 @@ func (a *application) rewriteRefOfLineStringExpr(parent SQLNode, node *LineStrin kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - if !a.rewriteExprs(node, node.PointParams, func(newNode, parent SQLNode) { - parent.(*LineStringExpr).PointParams = newNode.(Exprs) - }) { - return false + for x, el := range node.PointParams { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*LineStringExpr).PointParams[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -5338,7 +5695,7 @@ func (a *application) rewriteRefOfLinestrPropertyFuncExpr(parent SQLNode, node * kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5375,7 +5732,7 @@ func (a *application) rewriteRefOfLiteral(parent SQLNode, node *Literal, replace kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5401,7 +5758,12 @@ func (a *application) rewriteRefOfLoad(parent SQLNode, node *Load, replacer repl a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5428,7 +5790,7 @@ func (a *application) rewriteRefOfLocateExpr(parent SQLNode, node *LocateExpr, r kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5467,7 +5829,12 @@ func (a *application) rewriteRefOfLockOption(parent SQLNode, node *LockOption, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5491,7 +5858,12 @@ func (a *application) rewriteRefOfLockTables(parent SQLNode, node *LockTables, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5518,7 +5890,7 @@ func (a *application) rewriteRefOfLockingFunc(parent SQLNode, node *LockingFunc, kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5555,7 +5927,7 @@ func (a *application) rewriteRefOfMatchExpr(parent SQLNode, node *MatchExpr, rep kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5596,7 +5968,7 @@ func (a *application) rewriteRefOfMax(parent SQLNode, node *Max, replacer replac kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5633,7 +6005,7 @@ func (a *application) rewriteRefOfMemberOfExpr(parent SQLNode, node *MemberOfExp kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5670,7 +6042,7 @@ func (a *application) rewriteRefOfMin(parent SQLNode, node *Min, replacer replac kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5704,7 +6076,12 @@ func (a *application) rewriteRefOfModifyColumn(parent SQLNode, node *ModifyColum a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5739,16 +6116,20 @@ func (a *application) rewriteRefOfMultiLinestringExpr(parent SQLNode, node *Mult kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - if !a.rewriteExprs(node, node.LinestringParams, func(newNode, parent SQLNode) { - parent.(*MultiLinestringExpr).LinestringParams = newNode.(Exprs) - }) { - return false + for x, el := range node.LinestringParams { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*MultiLinestringExpr).LinestringParams[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -5771,16 +6152,20 @@ func (a *application) rewriteRefOfMultiPointExpr(parent SQLNode, node *MultiPoin kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - if !a.rewriteExprs(node, node.PointParams, func(newNode, parent SQLNode) { - parent.(*MultiPointExpr).PointParams = newNode.(Exprs) - }) { - return false + for x, el := range node.PointParams { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*MultiPointExpr).PointParams[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -5803,16 +6188,20 @@ func (a *application) rewriteRefOfMultiPolygonExpr(parent SQLNode, node *MultiPo kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - if !a.rewriteExprs(node, node.PolygonParams, func(newNode, parent SQLNode) { - parent.(*MultiPolygonExpr).PolygonParams = newNode.(Exprs) - }) { - return false + for x, el := range node.PolygonParams { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*MultiPolygonExpr).PolygonParams[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -5835,7 +6224,7 @@ func (a *application) rewriteRefOfNTHValueExpr(parent SQLNode, node *NTHValueExp kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5887,7 +6276,7 @@ func (a *application) rewriteRefOfNamedWindow(parent SQLNode, node *NamedWindow, kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5918,9 +6307,8 @@ func (a *application) rewriteNamedWindows(parent SQLNode, node NamedWindows, rep a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(NamedWindows) a.cur.revisit = false - return a.rewriteNamedWindows(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -5953,7 +6341,12 @@ func (a *application) rewriteRefOfNextval(parent SQLNode, node *Nextval, replace a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -5983,7 +6376,7 @@ func (a *application) rewriteRefOfNotExpr(parent SQLNode, node *NotExpr, replace kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6015,7 +6408,7 @@ func (a *application) rewriteRefOfNtileExpr(parent SQLNode, node *NtileExpr, rep kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6049,7 +6442,12 @@ func (a *application) rewriteRefOfNullTreatmentClause(parent SQLNode, node *Null a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6076,7 +6474,7 @@ func (a *application) rewriteRefOfNullVal(parent SQLNode, node *NullVal, replace kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6105,7 +6503,7 @@ func (a *application) rewriteRefOfOffset(parent SQLNode, node *Offset, replacer kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6136,9 +6534,8 @@ func (a *application) rewriteOnDup(parent SQLNode, node OnDup, replacer replacer a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(OnDup) a.cur.revisit = false - return a.rewriteOnDup(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6171,7 +6568,12 @@ func (a *application) rewriteRefOfOptLike(parent SQLNode, node *OptLike, replace a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6201,7 +6603,7 @@ func (a *application) rewriteRefOfOrExpr(parent SQLNode, node *OrExpr, replacer kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6235,7 +6637,12 @@ func (a *application) rewriteRefOfOrder(parent SQLNode, node *Order, replacer re a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6264,9 +6671,8 @@ func (a *application) rewriteOrderBy(parent SQLNode, node OrderBy, replacer repl a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(OrderBy) a.cur.revisit = false - return a.rewriteOrderBy(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6299,7 +6705,12 @@ func (a *application) rewriteRefOfOrderByOption(parent SQLNode, node *OrderByOpt a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6326,7 +6737,12 @@ func (a *application) rewriteRefOfOtherAdmin(parent SQLNode, node *OtherAdmin, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6350,7 +6766,12 @@ func (a *application) rewriteRefOfOverClause(parent SQLNode, node *OverClause, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6382,7 +6803,12 @@ func (a *application) rewriteRefOfParenTableExpr(parent SQLNode, node *ParenTabl a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6409,7 +6835,12 @@ func (a *application) rewriteRefOfParsedComments(parent SQLNode, node *ParsedCom a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6433,7 +6864,12 @@ func (a *application) rewriteRefOfPartitionDefinition(parent SQLNode, node *Part a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6465,7 +6901,12 @@ func (a *application) rewriteRefOfPartitionDefinitionOptions(parent SQLNode, nod a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6517,7 +6958,12 @@ func (a *application) rewriteRefOfPartitionEngine(parent SQLNode, node *Partitio a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6541,7 +6987,12 @@ func (a *application) rewriteRefOfPartitionOption(parent SQLNode, node *Partitio a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6587,7 +7038,12 @@ func (a *application) rewriteRefOfPartitionSpec(parent SQLNode, node *PartitionS a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6633,7 +7089,12 @@ func (a *application) rewriteRefOfPartitionValueRange(parent SQLNode, node *Part a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6662,9 +7123,8 @@ func (a *application) rewritePartitions(parent SQLNode, node Partitions, replace a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(Partitions) a.cur.revisit = false - return a.rewritePartitions(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6700,7 +7160,7 @@ func (a *application) rewriteRefOfPerformanceSchemaFuncExpr(parent SQLNode, node kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6732,7 +7192,7 @@ func (a *application) rewriteRefOfPointExpr(parent SQLNode, node *PointExpr, rep kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6769,7 +7229,7 @@ func (a *application) rewriteRefOfPointPropertyFuncExpr(parent SQLNode, node *Po kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6806,16 +7266,20 @@ func (a *application) rewriteRefOfPolygonExpr(parent SQLNode, node *PolygonExpr, kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - if !a.rewriteExprs(node, node.LinestringParams, func(newNode, parent SQLNode) { - parent.(*PolygonExpr).LinestringParams = newNode.(Exprs) - }) { - return false + for x, el := range node.LinestringParams { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*PolygonExpr).LinestringParams[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if a.post != nil { a.cur.replacer = replacer @@ -6838,7 +7302,7 @@ func (a *application) rewriteRefOfPolygonPropertyFuncExpr(parent SQLNode, node * kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -6872,7 +7336,12 @@ func (a *application) rewriteRefOfPrepareStmt(parent SQLNode, node *PrepareStmt, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6909,7 +7378,12 @@ func (a *application) rewriteRefOfPurgeBinaryLogs(parent SQLNode, node *PurgeBin a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6933,7 +7407,12 @@ func (a *application) rewriteRefOfReferenceDefinition(parent SQLNode, node *Refe a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -6983,7 +7462,7 @@ func (a *application) rewriteRefOfRegexpInstrExpr(parent SQLNode, node *RegexpIn kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -7040,7 +7519,7 @@ func (a *application) rewriteRefOfRegexpLikeExpr(parent SQLNode, node *RegexpLik kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -7082,7 +7561,7 @@ func (a *application) rewriteRefOfRegexpReplaceExpr(parent SQLNode, node *Regexp kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -7139,7 +7618,7 @@ func (a *application) rewriteRefOfRegexpSubstrExpr(parent SQLNode, node *RegexpS kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -7188,7 +7667,12 @@ func (a *application) rewriteRefOfRelease(parent SQLNode, node *Release, replace a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7215,7 +7699,12 @@ func (a *application) rewriteRefOfRenameColumn(parent SQLNode, node *RenameColum a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7247,7 +7736,12 @@ func (a *application) rewriteRefOfRenameIndex(parent SQLNode, node *RenameIndex, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7279,7 +7773,12 @@ func (a *application) rewriteRefOfRenameTable(parent SQLNode, node *RenameTable, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7303,7 +7802,12 @@ func (a *application) rewriteRefOfRenameTableName(parent SQLNode, node *RenameTa a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7330,7 +7834,12 @@ func (a *application) rewriteRefOfRevertMigration(parent SQLNode, node *RevertMi a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7357,7 +7866,12 @@ func (a *application) rewriteRefOfRollback(parent SQLNode, node *Rollback, repla a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7378,7 +7892,12 @@ func (a *application) rewriteRootNode(parent SQLNode, node RootNode, replacer re a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7405,7 +7924,12 @@ func (a *application) rewriteRefOfRowAlias(parent SQLNode, node *RowAlias, repla a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7437,7 +7961,12 @@ func (a *application) rewriteRefOfSRollback(parent SQLNode, node *SRollback, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7464,7 +7993,12 @@ func (a *application) rewriteRefOfSavepoint(parent SQLNode, node *Savepoint, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7491,7 +8025,12 @@ func (a *application) rewriteRefOfSelect(parent SQLNode, node *Select, replacer a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7514,8 +8053,8 @@ func (a *application) rewriteRefOfSelect(parent SQLNode, node *Select, replacer }) { return false } - if !a.rewriteSelectExprs(node, node.SelectExprs, func(newNode, parent SQLNode) { - parent.(*Select).SelectExprs = newNode.(SelectExprs) + if !a.rewriteRefOfSelectExprs(node, node.SelectExprs, func(newNode, parent SQLNode) { + parent.(*Select).SelectExprs = newNode.(*SelectExprs) }) { return false } @@ -7564,7 +8103,7 @@ func (a *application) rewriteRefOfSelect(parent SQLNode, node *Select, replacer } return true } -func (a *application) rewriteSelectExprs(parent SQLNode, node SelectExprs, replacer replacerFunc) bool { +func (a *application) rewriteRefOfSelectExprs(parent SQLNode, node *SelectExprs, replacer replacerFunc) bool { if node == nil { return true } @@ -7574,18 +8113,17 @@ func (a *application) rewriteSelectExprs(parent SQLNode, node SelectExprs, repla a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(SelectExprs) a.cur.revisit = false - return a.rewriteSelectExprs(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true } } - for x, el := range node { + for x, el := range node.Exprs { if !a.rewriteSelectExpr(node, el, func(idx int) replacerFunc { return func(newNode, parent SQLNode) { - parent.(SelectExprs)[idx] = newNode.(SelectExpr) + parent.(*SelectExprs).Exprs[idx] = newNode.(SelectExpr) } }(x)) { return false @@ -7609,7 +8147,12 @@ func (a *application) rewriteRefOfSelectInto(parent SQLNode, node *SelectInto, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7633,7 +8176,12 @@ func (a *application) rewriteRefOfSet(parent SQLNode, node *Set, replacer replac a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7665,7 +8213,12 @@ func (a *application) rewriteRefOfSetExpr(parent SQLNode, node *SetExpr, replace a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7699,9 +8252,8 @@ func (a *application) rewriteSetExprs(parent SQLNode, node SetExprs, replacer re a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(SetExprs) a.cur.revisit = false - return a.rewriteSetExprs(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -7734,7 +8286,12 @@ func (a *application) rewriteRefOfShow(parent SQLNode, node *Show, replacer repl a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7761,7 +8318,12 @@ func (a *application) rewriteRefOfShowBasic(parent SQLNode, node *ShowBasic, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7798,7 +8360,12 @@ func (a *application) rewriteRefOfShowCreate(parent SQLNode, node *ShowCreate, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7825,7 +8392,12 @@ func (a *application) rewriteRefOfShowFilter(parent SQLNode, node *ShowFilter, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7852,7 +8424,12 @@ func (a *application) rewriteRefOfShowMigrationLogs(parent SQLNode, node *ShowMi a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7879,7 +8456,12 @@ func (a *application) rewriteRefOfShowOther(parent SQLNode, node *ShowOther, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7903,7 +8485,12 @@ func (a *application) rewriteRefOfShowThrottledApps(parent SQLNode, node *ShowTh a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7927,7 +8514,12 @@ func (a *application) rewriteRefOfShowThrottlerStatus(parent SQLNode, node *Show a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7951,7 +8543,12 @@ func (a *application) rewriteRefOfShowTransactionStatus(parent SQLNode, node *Sh a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -7975,7 +8572,12 @@ func (a *application) rewriteRefOfStarExpr(parent SQLNode, node *StarExpr, repla a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8005,7 +8607,7 @@ func (a *application) rewriteRefOfStd(parent SQLNode, node *Std, replacer replac kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8042,7 +8644,7 @@ func (a *application) rewriteRefOfStdDev(parent SQLNode, node *StdDev, replacer kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8079,7 +8681,7 @@ func (a *application) rewriteRefOfStdPop(parent SQLNode, node *StdPop, replacer kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8116,7 +8718,7 @@ func (a *application) rewriteRefOfStdSamp(parent SQLNode, node *StdSamp, replace kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8150,7 +8752,12 @@ func (a *application) rewriteRefOfStream(parent SQLNode, node *Stream, replacer a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8187,7 +8794,12 @@ func (a *application) rewriteRefOfSubPartition(parent SQLNode, node *SubPartitio a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8219,7 +8831,12 @@ func (a *application) rewriteRefOfSubPartitionDefinition(parent SQLNode, node *S a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8251,7 +8868,12 @@ func (a *application) rewriteRefOfSubPartitionDefinitionOptions(parent SQLNode, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8295,9 +8917,8 @@ func (a *application) rewriteSubPartitionDefinitions(parent SQLNode, node SubPar a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(SubPartitionDefinitions) a.cur.revisit = false - return a.rewriteSubPartitionDefinitions(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8333,7 +8954,7 @@ func (a *application) rewriteRefOfSubquery(parent SQLNode, node *Subquery, repla kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8365,7 +8986,7 @@ func (a *application) rewriteRefOfSubstrExpr(parent SQLNode, node *SubstrExpr, r kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8407,7 +9028,7 @@ func (a *application) rewriteRefOfSum(parent SQLNode, node *Sum, replacer replac kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8443,9 +9064,8 @@ func (a *application) rewriteTableExprs(parent SQLNode, node TableExprs, replace a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(TableExprs) a.cur.revisit = false - return a.rewriteTableExprs(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8475,7 +9095,12 @@ func (a *application) rewriteTableName(parent SQLNode, node TableName, replacer a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8509,9 +9134,8 @@ func (a *application) rewriteTableNames(parent SQLNode, node TableNames, replace a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(TableNames) a.cur.revisit = false - return a.rewriteTableNames(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8546,9 +9170,8 @@ func (a *application) rewriteTableOptions(parent SQLNode, node TableOptions, rep a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(TableOptions) a.cur.revisit = false - return a.rewriteTableOptions(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8574,7 +9197,12 @@ func (a *application) rewriteRefOfTableSpec(parent SQLNode, node *TableSpec, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8633,7 +9261,12 @@ func (a *application) rewriteRefOfTablespaceOperation(parent SQLNode, node *Tabl a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8660,7 +9293,7 @@ func (a *application) rewriteRefOfTimestampDiffExpr(parent SQLNode, node *Timest kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8697,7 +9330,7 @@ func (a *application) rewriteRefOfTrimFuncExpr(parent SQLNode, node *TrimFuncExp kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8731,7 +9364,12 @@ func (a *application) rewriteRefOfTruncateTable(parent SQLNode, node *TruncateTa a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8761,7 +9399,7 @@ func (a *application) rewriteRefOfUnaryExpr(parent SQLNode, node *UnaryExpr, rep kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8790,7 +9428,12 @@ func (a *application) rewriteRefOfUnion(parent SQLNode, node *Union, replacer re a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8842,7 +9485,12 @@ func (a *application) rewriteRefOfUnlockTables(parent SQLNode, node *UnlockTable a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8866,7 +9514,12 @@ func (a *application) rewriteRefOfUpdate(parent SQLNode, node *Update, replacer a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8927,7 +9580,12 @@ func (a *application) rewriteRefOfUpdateExpr(parent SQLNode, node *UpdateExpr, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -8961,9 +9619,8 @@ func (a *application) rewriteUpdateExprs(parent SQLNode, node UpdateExprs, repla a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(UpdateExprs) a.cur.revisit = false - return a.rewriteUpdateExprs(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -8999,7 +9656,7 @@ func (a *application) rewriteRefOfUpdateXMLExpr(parent SQLNode, node *UpdateXMLE kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -9038,7 +9695,12 @@ func (a *application) rewriteRefOfUse(parent SQLNode, node *Use, replacer replac a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9065,7 +9727,12 @@ func (a *application) rewriteRefOfVExplainStmt(parent SQLNode, node *VExplainStm a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9097,7 +9764,12 @@ func (a *application) rewriteRefOfVStream(parent SQLNode, node *VStream, replace a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9146,9 +9818,8 @@ func (a *application) rewriteValTuple(parent SQLNode, node ValTuple, replacer re a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(ValTuple) a.cur.revisit = false - return a.rewriteValTuple(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -9181,7 +9852,12 @@ func (a *application) rewriteRefOfValidation(parent SQLNode, node *Validation, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9207,9 +9883,8 @@ func (a *application) rewriteValues(parent SQLNode, node Values, replacer replac a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(Values) a.cur.revisit = false - return a.rewriteValues(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -9245,7 +9920,7 @@ func (a *application) rewriteRefOfValuesFuncExpr(parent SQLNode, node *ValuesFun kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -9274,7 +9949,12 @@ func (a *application) rewriteRefOfValuesStatement(parent SQLNode, node *ValuesSt a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9329,7 +10009,7 @@ func (a *application) rewriteRefOfVarPop(parent SQLNode, node *VarPop, replacer kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -9366,7 +10046,7 @@ func (a *application) rewriteRefOfVarSamp(parent SQLNode, node *VarSamp, replace kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -9403,7 +10083,7 @@ func (a *application) rewriteRefOfVariable(parent SQLNode, node *Variable, repla kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -9435,7 +10115,7 @@ func (a *application) rewriteRefOfVariance(parent SQLNode, node *Variance, repla kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -9466,7 +10146,12 @@ func (a *application) rewriteVindexParam(parent SQLNode, node VindexParam, repla a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9493,7 +10178,12 @@ func (a *application) rewriteRefOfVindexSpec(parent SQLNode, node *VindexSpec, r a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9537,7 +10227,7 @@ func (a *application) rewriteRefOfWeightStringFuncExpr(parent SQLNode, node *Wei kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -9571,7 +10261,12 @@ func (a *application) rewriteRefOfWhen(parent SQLNode, node *When, replacer repl a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9603,7 +10298,12 @@ func (a *application) rewriteRefOfWhere(parent SQLNode, node *Where, replacer re a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9630,7 +10330,12 @@ func (a *application) rewriteRefOfWindowDefinition(parent SQLNode, node *WindowD a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9664,9 +10369,8 @@ func (a *application) rewriteWindowDefinitions(parent SQLNode, node WindowDefini a.cur.node = node kontinue := !a.pre(&a.cur) if a.cur.revisit { - node = a.cur.node.(WindowDefinitions) a.cur.revisit = false - return a.rewriteWindowDefinitions(parent, node, replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -9699,7 +10403,12 @@ func (a *application) rewriteRefOfWindowSpecification(parent SQLNode, node *Wind a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9708,10 +10417,14 @@ func (a *application) rewriteRefOfWindowSpecification(parent SQLNode, node *Wind }) { return false } - if !a.rewriteExprs(node, node.PartitionClause, func(newNode, parent SQLNode) { - parent.(*WindowSpecification).PartitionClause = newNode.(Exprs) - }) { - return false + for x, el := range node.PartitionClause { + if !a.rewriteExpr(node, el, func(idx int) replacerFunc { + return func(newNode, parent SQLNode) { + parent.(*WindowSpecification).PartitionClause[idx] = newNode.(Expr) + } + }(x)) { + return false + } } if !a.rewriteOrderBy(node, node.OrderClause, func(newNode, parent SQLNode) { parent.(*WindowSpecification).OrderClause = newNode.(OrderBy) @@ -9741,7 +10454,12 @@ func (a *application) rewriteRefOfWith(parent SQLNode, node *With, replacer repl a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -9775,7 +10493,7 @@ func (a *application) rewriteRefOfXorExpr(parent SQLNode, node *XorExpr, replace kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -10630,7 +11348,12 @@ func (a *application) rewriteAlgorithmValue(parent SQLNode, node AlgorithmValue, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -10654,7 +11377,7 @@ func (a *application) rewriteBoolVal(parent SQLNode, node BoolVal, replacer repl kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -10680,7 +11403,7 @@ func (a *application) rewriteListArg(parent SQLNode, node ListArg, replacer repl kontinue := !a.pre(&a.cur) if a.cur.revisit { a.cur.revisit = false - return a.rewriteExpr(parent, a.cur.node.(Expr), replacer) + return a.rewriteSQLNode(parent, a.cur.node, replacer) } if kontinue { return true @@ -10703,7 +11426,12 @@ func (a *application) rewriteMatchAction(parent SQLNode, node MatchAction, repla a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -10724,7 +11452,12 @@ func (a *application) rewriteReferenceAction(parent SQLNode, node ReferenceActio a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -10748,7 +11481,12 @@ func (a *application) rewriteRefOfIdentifierCI(parent SQLNode, node *IdentifierC a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -10772,7 +11510,12 @@ func (a *application) rewriteRefOfIdentifierCS(parent SQLNode, node *IdentifierC a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -10796,7 +11539,12 @@ func (a *application) rewriteRefOfRootNode(parent SQLNode, node *RootNode, repla a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -10823,7 +11571,12 @@ func (a *application) rewriteRefOfTableName(parent SQLNode, node *TableName, rep a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } @@ -10855,7 +11608,12 @@ func (a *application) rewriteRefOfVindexParam(parent SQLNode, node *VindexParam, a.cur.replacer = replacer a.cur.parent = parent a.cur.node = node - if !a.pre(&a.cur) { + kontinue := !a.pre(&a.cur) + if a.cur.revisit { + a.cur.revisit = false + return a.rewriteSQLNode(parent, a.cur.node, replacer) + } + if kontinue { return true } } diff --git a/go/vt/sqlparser/ast_visit.go b/go/vt/sqlparser/ast_visit.go index a7fbbe02118..b8ece9e3ae3 100644 --- a/go/vt/sqlparser/ast_visit.go +++ b/go/vt/sqlparser/ast_visit.go @@ -160,8 +160,8 @@ func VisitSQLNode(in SQLNode, f Visit) error { return VisitRefOfExplainStmt(in, f) case *ExplainTab: return VisitRefOfExplainTab(in, f) - case Exprs: - return VisitExprs(in, f) + case *Exprs: + return VisitRefOfExprs(in, f) case *ExtractFuncExpr: return VisitRefOfExtractFuncExpr(in, f) case *ExtractValueExpr: @@ -434,8 +434,8 @@ func VisitSQLNode(in SQLNode, f Visit) error { return VisitRefOfSavepoint(in, f) case *Select: return VisitRefOfSelect(in, f) - case SelectExprs: - return VisitSelectExprs(in, f) + case *SelectExprs: + return VisitRefOfSelectExprs(in, f) case *SelectInto: return VisitRefOfSelectInto(in, f) case *Set: @@ -999,8 +999,10 @@ func VisitRefOfCallProc(in *CallProc, f Visit) error { if err := VisitTableName(in.Name, f); err != nil { return err } - if err := VisitExprs(in.Params, f); err != nil { - return err + for _, el := range in.Params { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -1064,8 +1066,10 @@ func VisitRefOfCharExpr(in *CharExpr, f Visit) error { if cont, err := f(in); err != nil || !cont { return err } - if err := VisitExprs(in.Exprs, f); err != nil { - return err + for _, el := range in.Exprs { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -1258,8 +1262,10 @@ func VisitRefOfCount(in *Count, f Visit) error { if cont, err := f(in); err != nil || !cont { return err } - if err := VisitExprs(in.Args, f); err != nil { - return err + for _, el := range in.Args { + if err := VisitExpr(el, f); err != nil { + return err + } } if err := VisitRefOfOverClause(in.OverClause, f); err != nil { return err @@ -1558,14 +1564,14 @@ func VisitRefOfExplainTab(in *ExplainTab, f Visit) error { } return nil } -func VisitExprs(in Exprs, f Visit) error { +func VisitRefOfExprs(in *Exprs, f Visit) error { if in == nil { return nil } if cont, err := f(in); err != nil || !cont { return err } - for _, el := range in { + for _, el := range in.Exprs { if err := VisitExpr(el, f); err != nil { return err } @@ -1705,8 +1711,10 @@ func VisitRefOfFuncExpr(in *FuncExpr, f Visit) error { if err := VisitIdentifierCI(in.Name, f); err != nil { return err } - if err := VisitExprs(in.Exprs, f); err != nil { - return err + for _, el := range in.Exprs { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -1914,8 +1922,10 @@ func VisitRefOfGroupConcatExpr(in *GroupConcatExpr, f Visit) error { if cont, err := f(in); err != nil || !cont { return err } - if err := VisitExprs(in.Exprs, f); err != nil { - return err + for _, el := range in.Exprs { + if err := VisitExpr(el, f); err != nil { + return err + } } if err := VisitOrderBy(in.OrderBy, f); err != nil { return err @@ -2068,8 +2078,10 @@ func VisitRefOfIntervalFuncExpr(in *IntervalFuncExpr, f Visit) error { if err := VisitExpr(in.Expr, f); err != nil { return err } - if err := VisitExprs(in.Exprs, f); err != nil { - return err + for _, el := range in.Exprs { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -2119,8 +2131,10 @@ func VisitRefOfJSONArrayExpr(in *JSONArrayExpr, f Visit) error { if cont, err := f(in); err != nil || !cont { return err } - if err := VisitExprs(in.Params, f); err != nil { - return err + for _, el := range in.Params { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -2307,8 +2321,10 @@ func VisitRefOfJSONRemoveExpr(in *JSONRemoveExpr, f Visit) error { if err := VisitExpr(in.JSONDoc, f); err != nil { return err } - if err := VisitExprs(in.PathList, f); err != nil { - return err + for _, el := range in.PathList { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -2461,8 +2477,10 @@ func VisitRefOfJSONValueMergeExpr(in *JSONValueMergeExpr, f Visit) error { if err := VisitExpr(in.JSONDoc, f); err != nil { return err } - if err := VisitExprs(in.JSONDocList, f); err != nil { - return err + for _, el := range in.JSONDocList { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -2601,8 +2619,10 @@ func VisitRefOfLineStringExpr(in *LineStringExpr, f Visit) error { if cont, err := f(in); err != nil || !cont { return err } - if err := VisitExprs(in.PointParams, f); err != nil { - return err + for _, el := range in.PointParams { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -2774,8 +2794,10 @@ func VisitRefOfMultiLinestringExpr(in *MultiLinestringExpr, f Visit) error { if cont, err := f(in); err != nil || !cont { return err } - if err := VisitExprs(in.LinestringParams, f); err != nil { - return err + for _, el := range in.LinestringParams { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -2786,8 +2808,10 @@ func VisitRefOfMultiPointExpr(in *MultiPointExpr, f Visit) error { if cont, err := f(in); err != nil || !cont { return err } - if err := VisitExprs(in.PointParams, f); err != nil { - return err + for _, el := range in.PointParams { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -2798,8 +2822,10 @@ func VisitRefOfMultiPolygonExpr(in *MultiPolygonExpr, f Visit) error { if cont, err := f(in); err != nil || !cont { return err } - if err := VisitExprs(in.PolygonParams, f); err != nil { - return err + for _, el := range in.PolygonParams { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -3218,8 +3244,10 @@ func VisitRefOfPolygonExpr(in *PolygonExpr, f Visit) error { if cont, err := f(in); err != nil || !cont { return err } - if err := VisitExprs(in.LinestringParams, f); err != nil { - return err + for _, el := range in.LinestringParams { + if err := VisitExpr(el, f); err != nil { + return err + } } return nil } @@ -3535,7 +3563,7 @@ func VisitRefOfSelect(in *Select, f Visit) error { if err := VisitRefOfParsedComments(in.Comments, f); err != nil { return err } - if err := VisitSelectExprs(in.SelectExprs, f); err != nil { + if err := VisitRefOfSelectExprs(in.SelectExprs, f); err != nil { return err } if err := VisitRefOfWhere(in.Where, f); err != nil { @@ -3561,14 +3589,14 @@ func VisitRefOfSelect(in *Select, f Visit) error { } return nil } -func VisitSelectExprs(in SelectExprs, f Visit) error { +func VisitRefOfSelectExprs(in *SelectExprs, f Visit) error { if in == nil { return nil } if cont, err := f(in); err != nil || !cont { return err } - for _, el := range in { + for _, el := range in.Exprs { if err := VisitSelectExpr(el, f); err != nil { return err } @@ -4476,8 +4504,10 @@ func VisitRefOfWindowSpecification(in *WindowSpecification, f Visit) error { if err := VisitIdentifierCI(in.Name, f); err != nil { return err } - if err := VisitExprs(in.PartitionClause, f); err != nil { - return err + for _, el := range in.PartitionClause { + if err := VisitExpr(el, f); err != nil { + return err + } } if err := VisitOrderBy(in.OrderClause, f); err != nil { return err diff --git a/go/vt/sqlparser/cached_size.go b/go/vt/sqlparser/cached_size.go index 7183ff18e28..4f17041bdbe 100644 --- a/go/vt/sqlparser/cached_size.go +++ b/go/vt/sqlparser/cached_size.go @@ -564,7 +564,7 @@ func (cached *CallProc) CachedSize(alloc bool) int64 { } // field Name vitess.io/vitess/go/vt/sqlparser.TableName size += cached.Name.CachedSize(false) - // field Params vitess.io/vitess/go/vt/sqlparser.Exprs + // field Params []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.Params)) * int64(16)) for _, elem := range cached.Params { @@ -640,7 +640,7 @@ func (cached *CharExpr) CachedSize(alloc bool) int64 { if alloc { size += int64(48) } - // field Exprs vitess.io/vitess/go/vt/sqlparser.Exprs + // field Exprs []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.Exprs)) * int64(16)) for _, elem := range cached.Exprs { @@ -979,7 +979,7 @@ func (cached *Count) CachedSize(alloc bool) int64 { if alloc { size += int64(48) } - // field Args vitess.io/vitess/go/vt/sqlparser.Exprs + // field Args []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.Args)) * int64(16)) for _, elem := range cached.Args { @@ -1341,22 +1341,6 @@ func (cached *ExplainTab) CachedSize(alloc bool) int64 { size += hack.RuntimeAllocSize(int64(len(cached.Wild))) return size } -func (cached *Exprs) CachedSize(alloc bool) int64 { - if cached == nil { - return int64(0) - } - size := int64(0) - if alloc { - size += int64(24) - } - size += hack.RuntimeAllocSize(int64(cap(*cached)) * int64(16)) - for _, elem := range *cached { - if cc, ok := elem.(cachedObject); ok { - size += cc.CachedSize(true) - } - } - return size -} func (cached *ExtractFuncExpr) CachedSize(alloc bool) int64 { if cached == nil { return int64(0) @@ -1494,7 +1478,7 @@ func (cached *FuncExpr) CachedSize(alloc bool) int64 { size += cached.Qualifier.CachedSize(false) // field Name vitess.io/vitess/go/vt/sqlparser.IdentifierCI size += cached.Name.CachedSize(false) - // field Exprs vitess.io/vitess/go/vt/sqlparser.Exprs + // field Exprs []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.Exprs)) * int64(16)) for _, elem := range cached.Exprs { @@ -1754,7 +1738,7 @@ func (cached *GroupConcatExpr) CachedSize(alloc bool) int64 { if alloc { size += int64(80) } - // field Exprs vitess.io/vitess/go/vt/sqlparser.Exprs + // field Exprs []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.Exprs)) * int64(16)) for _, elem := range cached.Exprs { @@ -2004,7 +1988,7 @@ func (cached *IntervalFuncExpr) CachedSize(alloc bool) int64 { if cc, ok := cached.Expr.(cachedObject); ok { size += cc.CachedSize(true) } - // field Exprs vitess.io/vitess/go/vt/sqlparser.Exprs + // field Exprs []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.Exprs)) * int64(16)) for _, elem := range cached.Exprs { @@ -2069,7 +2053,7 @@ func (cached *JSONArrayExpr) CachedSize(alloc bool) int64 { if alloc { size += int64(24) } - // field Params vitess.io/vitess/go/vt/sqlparser.Exprs + // field Params []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.Params)) * int64(16)) for _, elem := range cached.Params { @@ -2306,7 +2290,7 @@ func (cached *JSONRemoveExpr) CachedSize(alloc bool) int64 { if cc, ok := cached.JSONDoc.(cachedObject); ok { size += cc.CachedSize(true) } - // field PathList vitess.io/vitess/go/vt/sqlparser.Exprs + // field PathList []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.PathList)) * int64(16)) for _, elem := range cached.PathList { @@ -2493,7 +2477,7 @@ func (cached *JSONValueMergeExpr) CachedSize(alloc bool) int64 { if cc, ok := cached.JSONDoc.(cachedObject); ok { size += cc.CachedSize(true) } - // field JSONDocList vitess.io/vitess/go/vt/sqlparser.Exprs + // field JSONDocList []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.JSONDocList)) * int64(16)) for _, elem := range cached.JSONDocList { @@ -2725,7 +2709,7 @@ func (cached *LineStringExpr) CachedSize(alloc bool) int64 { if alloc { size += int64(24) } - // field PointParams vitess.io/vitess/go/vt/sqlparser.Exprs + // field PointParams []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.PointParams)) * int64(16)) for _, elem := range cached.PointParams { @@ -2937,7 +2921,7 @@ func (cached *MultiLinestringExpr) CachedSize(alloc bool) int64 { if alloc { size += int64(24) } - // field LinestringParams vitess.io/vitess/go/vt/sqlparser.Exprs + // field LinestringParams []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.LinestringParams)) * int64(16)) for _, elem := range cached.LinestringParams { @@ -2956,7 +2940,7 @@ func (cached *MultiPointExpr) CachedSize(alloc bool) int64 { if alloc { size += int64(24) } - // field PointParams vitess.io/vitess/go/vt/sqlparser.Exprs + // field PointParams []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.PointParams)) * int64(16)) for _, elem := range cached.PointParams { @@ -2975,7 +2959,7 @@ func (cached *MultiPolygonExpr) CachedSize(alloc bool) int64 { if alloc { size += int64(24) } - // field PolygonParams vitess.io/vitess/go/vt/sqlparser.Exprs + // field PolygonParams []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.PolygonParams)) * int64(16)) for _, elem := range cached.PolygonParams { @@ -3480,7 +3464,7 @@ func (cached *PolygonExpr) CachedSize(alloc bool) int64 { if alloc { size += int64(24) } - // field LinestringParams vitess.io/vitess/go/vt/sqlparser.Exprs + // field LinestringParams []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.LinestringParams)) * int64(16)) for _, elem := range cached.LinestringParams { @@ -3826,7 +3810,7 @@ func (cached *Select) CachedSize(alloc bool) int64 { } size := int64(0) if alloc { - size += int64(176) + size += int64(160) } // field Cache *bool size += hack.RuntimeAllocSize(int64(1)) @@ -3843,15 +3827,8 @@ func (cached *Select) CachedSize(alloc bool) int64 { } // field Comments *vitess.io/vitess/go/vt/sqlparser.ParsedComments size += cached.Comments.CachedSize(true) - // field SelectExprs vitess.io/vitess/go/vt/sqlparser.SelectExprs - { - size += hack.RuntimeAllocSize(int64(cap(cached.SelectExprs)) * int64(16)) - for _, elem := range cached.SelectExprs { - if cc, ok := elem.(cachedObject); ok { - size += cc.CachedSize(true) - } - } - } + // field SelectExprs *vitess.io/vitess/go/vt/sqlparser.SelectExprs + size += cached.SelectExprs.CachedSize(true) // field Where *vitess.io/vitess/go/vt/sqlparser.Where size += cached.Where.CachedSize(true) // field GroupBy *vitess.io/vitess/go/vt/sqlparser.GroupBy @@ -3886,10 +3863,13 @@ func (cached *SelectExprs) CachedSize(alloc bool) int64 { if alloc { size += int64(24) } - size += hack.RuntimeAllocSize(int64(cap(*cached)) * int64(16)) - for _, elem := range *cached { - if cc, ok := elem.(cachedObject); ok { - size += cc.CachedSize(true) + // field Exprs []vitess.io/vitess/go/vt/sqlparser.SelectExpr + { + size += hack.RuntimeAllocSize(int64(cap(cached.Exprs)) * int64(16)) + for _, elem := range cached.Exprs { + if cc, ok := elem.(cachedObject); ok { + size += cc.CachedSize(true) + } } } return size @@ -4990,7 +4970,7 @@ func (cached *WindowSpecification) CachedSize(alloc bool) int64 { } // field Name vitess.io/vitess/go/vt/sqlparser.IdentifierCI size += cached.Name.CachedSize(false) - // field PartitionClause vitess.io/vitess/go/vt/sqlparser.Exprs + // field PartitionClause []vitess.io/vitess/go/vt/sqlparser.Expr { size += hack.RuntimeAllocSize(int64(cap(cached.PartitionClause)) * int64(16)) for _, elem := range cached.PartitionClause { diff --git a/go/vt/sqlparser/normalizer.go b/go/vt/sqlparser/normalizer.go index fb3813b7019..dffb90d52b8 100644 --- a/go/vt/sqlparser/normalizer.go +++ b/go/vt/sqlparser/normalizer.go @@ -748,7 +748,7 @@ func (nz *normalizer) unnestSubQueries(cursor *Cursor, subquery *Subquery) { return } - if len(sel.SelectExprs) != 1 || + if len(sel.SelectExprs.Exprs) != 1 || len(sel.OrderBy) != 0 || sel.GroupBy != nil || len(sel.From) != 1 || @@ -766,7 +766,7 @@ func (nz *normalizer) unnestSubQueries(cursor *Cursor, subquery *Subquery) { if !ok || table.Name.String() != "dual" { return } - expr, ok := sel.SelectExprs[0].(*AliasedExpr) + expr, ok := sel.SelectExprs.Exprs[0].(*AliasedExpr) if !ok { return } @@ -810,8 +810,8 @@ func (nz *normalizer) existsRewrite(cursor *Cursor, node *ExistsExpr) { // Simplify the subquery by selecting a constant. // WHERE EXISTS(SELECT 1 FROM ...) - sel.SelectExprs = SelectExprs{ - &AliasedExpr{Expr: NewIntLiteral("1")}, + sel.SelectExprs = &SelectExprs{ + Exprs: []SelectExpr{&AliasedExpr{Expr: NewIntLiteral("1")}}, } sel.GroupBy = nil } diff --git a/go/vt/sqlparser/parsed_query_test.go b/go/vt/sqlparser/parsed_query_test.go index 26b9855b0f0..07ff0165982 100644 --- a/go/vt/sqlparser/parsed_query_test.go +++ b/go/vt/sqlparser/parsed_query_test.go @@ -296,8 +296,8 @@ func TestCastBindVars(t *testing.T) { } s := &Select{ - SelectExprs: SelectExprs{ - NewAliasedExpr(argument, ""), + SelectExprs: &SelectExprs{ + Exprs: []SelectExpr{NewAliasedExpr(argument, "")}, }, } diff --git a/go/vt/sqlparser/parser.go b/go/vt/sqlparser/parser.go index 8af0018db2a..c8850559cdc 100644 --- a/go/vt/sqlparser/parser.go +++ b/go/vt/sqlparser/parser.go @@ -144,7 +144,7 @@ func (p *Parser) ParseExpr(sql string) (Expr, error) { if err != nil { return nil, err } - aliasedExpr := stmt.(*Select).SelectExprs[0].(*AliasedExpr) + aliasedExpr := stmt.(*Select).SelectExprs.Exprs[0].(*AliasedExpr) return aliasedExpr.Expr, err } diff --git a/go/vt/sqlparser/precedence_test.go b/go/vt/sqlparser/precedence_test.go index 690e6df8647..8ea3fbe1446 100644 --- a/go/vt/sqlparser/precedence_test.go +++ b/go/vt/sqlparser/precedence_test.go @@ -84,7 +84,7 @@ func TestPlusStarPrecedence(t *testing.T) { t.Error(err) continue } - expr := readable(tree.(*Select).SelectExprs[0].(*AliasedExpr).Expr) + expr := readable(tree.(*Select).SelectExprs.Exprs[0].(*AliasedExpr).Expr) if expr != tcase.output { t.Errorf("Parse: \n%s, want: \n%s", expr, tcase.output) } diff --git a/go/vt/sqlparser/predicate_rewriting.go b/go/vt/sqlparser/predicate_rewriting.go index 234a2f4acd5..4dd4c09556d 100644 --- a/go/vt/sqlparser/predicate_rewriting.go +++ b/go/vt/sqlparser/predicate_rewriting.go @@ -213,7 +213,7 @@ func simplifyAnd(expr *AndExpr) (Expr, bool) { // And rewrite that to WHERE (a, b) IN ((1,11), (2,12), (3,13)) func ExtractINFromOR(expr *OrExpr) []Expr { var varNames []*ColName - var values []Exprs + var values [][]Expr orSlice := orToSlice(expr) for _, expr := range orSlice { andSlice := andToSlice(expr) diff --git a/go/vt/sqlparser/random_expr.go b/go/vt/sqlparser/random_expr.go index f5b394b36fe..b6038119663 100644 --- a/go/vt/sqlparser/random_expr.go +++ b/go/vt/sqlparser/random_expr.go @@ -246,7 +246,9 @@ func (g *Generator) randomAggregate(genConfig ExprGeneratorConfig) Expr { options := []exprF{ func() Expr { return &CountStar{} }, - func() Expr { return &Count{Args: Exprs{g.Expression(genConfig.anyTypeConfig())}, Distinct: isDistinct} }, + func() Expr { + return &Count{Args: []Expr{g.Expression(genConfig.anyTypeConfig())}, Distinct: isDistinct} + }, func() Expr { return &Sum{Arg: g.Expression(genConfig), Distinct: isDistinct} }, func() Expr { return &Min{Arg: g.Expression(genConfig), Distinct: isDistinct} }, func() Expr { return &Max{Arg: g.Expression(genConfig), Distinct: isDistinct} }, @@ -269,7 +271,7 @@ func (g *Generator) booleanExpr(genConfig ExprGeneratorConfig) Expr { func() Expr { return g.orExpr(genConfig) }, func() Expr { return g.comparison(genConfig.intTypeConfig()) }, func() Expr { return g.comparison(genConfig.stringTypeConfig()) }, - //func() Expr { return g.comparison(genConfig) }, // this is not accepted by the parser + // func() Expr { return g.comparison(genConfig) }, // this is not accepted by the parser func() Expr { return g.inExpr(genConfig) }, func() Expr { return g.existsExpr(genConfig) }, func() Expr { return g.between(genConfig.intTypeConfig()) }, @@ -374,7 +376,7 @@ func (g *Generator) randomBool(prob float32) bool { } func (g *Generator) intLiteral() Expr { - t := fmt.Sprintf("%d", rand.IntN(100)-rand.IntN(100)) //nolint SA4000 + t := fmt.Sprintf("%d", rand.IntN(100)-rand.IntN(100)) // nolint SA4000 return NewIntLiteral(t) } @@ -566,7 +568,7 @@ func (g *Generator) existsExpr(genConfig ExprGeneratorConfig) Expr { } else { // if g.subqueryExpr doesn't return a valid subquery, replace with // select 1 - selectExprs := SelectExprs{NewAliasedExpr(NewIntLiteral("1"), "")} + selectExprs := &SelectExprs{Exprs: []SelectExpr{NewAliasedExpr(NewIntLiteral("1"), "")}} from := TableExprs{NewAliasedTableExpr(NewTableName("dual"), "")} expr = NewExistsExpr(NewSubquery(NewSelect(nil, selectExprs, nil, nil, from, nil, nil, nil, nil))) } diff --git a/go/vt/sqlparser/rewriter_api.go b/go/vt/sqlparser/rewriter_api.go index cfcf75fa0f9..5dc4b30cc59 100644 --- a/go/vt/sqlparser/rewriter_api.go +++ b/go/vt/sqlparser/rewriter_api.go @@ -125,14 +125,6 @@ func (c *Cursor) ReplacerF() func(newNode SQLNode) { // When used, this will abort the visitation of the current node - no post or children visited, // and the new node visited. func (c *Cursor) ReplaceAndRevisit(newNode SQLNode) { - switch newNode.(type) { - case SelectExprs, Expr: - default: - // We need to add support to the generated code for when to look at the revisit flag. At the moment it is only - // there for slices of SQLNode implementations - panic("no support added for this type yet") - } - c.replacer(newNode, c.parent) c.node = newNode c.revisit = true diff --git a/go/vt/sqlparser/rewriter_test.go b/go/vt/sqlparser/rewriter_test.go index 628d6fbd0a4..b7d24406677 100644 --- a/go/vt/sqlparser/rewriter_test.go +++ b/go/vt/sqlparser/rewriter_test.go @@ -49,10 +49,10 @@ func TestReplaceWorksInLaterCalls(t *testing.T) { Rewrite(stmt, func(cursor *Cursor) bool { switch node := cursor.Node().(type) { case *Select: - node.SelectExprs[0] = &AliasedExpr{ + node.SelectExprs.Exprs[0] = &AliasedExpr{ Expr: NewStrLiteral("apa"), } - node.SelectExprs = append(node.SelectExprs, &AliasedExpr{ + node.SelectExprs.Exprs = append(node.SelectExprs.Exprs, &AliasedExpr{ Expr: NewStrLiteral("foobar"), }) case *StarExpr: @@ -73,8 +73,8 @@ func TestReplaceAndRevisitWorksInLaterCalls(t *testing.T) { count := 0 Rewrite(stmt, func(cursor *Cursor) bool { switch node := cursor.Node().(type) { - case SelectExprs: - if len(node) != 1 { + case *SelectExprs: + if len(node.Exprs) != 1 { return true } expr1 := &AliasedExpr{ @@ -83,7 +83,7 @@ func TestReplaceAndRevisitWorksInLaterCalls(t *testing.T) { expr2 := &AliasedExpr{ Expr: NewStrLiteral("foobar"), } - cursor.ReplaceAndRevisit(SelectExprs{expr1, expr2}) + cursor.ReplaceAndRevisit(&SelectExprs{Exprs: []SelectExpr{expr1, expr2}}) case *StarExpr: t.Errorf("should not have seen the star") case *Literal: diff --git a/go/vt/sqlparser/sql.go b/go/vt/sqlparser/sql.go index ff9bc5cb71f..ef2036265e6 100644 --- a/go/vt/sqlparser/sql.go +++ b/go/vt/sqlparser/sql.go @@ -7806,7 +7806,7 @@ var yyPgo = [...]int{ 139, 2744, 2725, 2716, 0, 1034, 125, 2688, 202, } -//line sql.y:8820 +//line sql.y:8822 type yySymType struct { union any empty struct{} @@ -7990,8 +7990,8 @@ func (st *yySymType) exprUnion() Expr { return v } -func (st *yySymType) exprsUnion() Exprs { - v, _ := st.union.(Exprs) +func (st *yySymType) exprsUnion() []Expr { + v, _ := st.union.([]Expr) return v } @@ -8320,8 +8320,8 @@ func (st *yySymType) selectExprUnion() SelectExpr { return v } -func (st *yySymType) selectExprsUnion() SelectExprs { - v, _ := st.union.(SelectExprs) +func (st *yySymType) selectExprsUnion() *SelectExprs { + v, _ := st.union.(*SelectExprs) return v } @@ -10564,7 +10564,7 @@ yydefault: var yyLOCAL TableStatement //line sql.y:837 { - yyLOCAL = NewSelect(Comments(yyDollar[2].strs), SelectExprs{&Nextval{Expr: yyDollar[5].exprUnion()}}, []string{yyDollar[3].str} /*options*/, nil, TableExprs{&AliasedTableExpr{Expr: yyDollar[7].tableName}}, nil /*where*/, nil /*groupBy*/, nil /*having*/, nil) + yyLOCAL = NewSelect(Comments(yyDollar[2].strs), &SelectExprs{Exprs: []SelectExpr{&Nextval{Expr: yyDollar[5].exprUnion()}}}, []string{yyDollar[3].str} /*options*/, nil, TableExprs{&AliasedTableExpr{Expr: yyDollar[7].tableName}}, nil /*where*/, nil /*groupBy*/, nil /*having*/, nil) } yyVAL.union = yyLOCAL case 65: @@ -17100,23 +17100,26 @@ yydefault: } case 929: yyDollar = yyS[yypt-1 : yypt+1] - var yyLOCAL SelectExprs + var yyLOCAL *SelectExprs //line sql.y:4937 { - yyLOCAL = SelectExprs{yyDollar[1].selectExprUnion()} + yyLOCAL = &SelectExprs{Exprs: []SelectExpr{yyDollar[1].selectExprUnion()}} } yyVAL.union = yyLOCAL case 930: yyDollar = yyS[yypt-3 : yypt+1] + var yyLOCAL *SelectExprs //line sql.y:4941 { - yySLICE := (*SelectExprs)(yyIaddr(yyVAL.union)) - *yySLICE = append(*yySLICE, yyDollar[3].selectExprUnion()) + res := yyDollar[1].selectExprsUnion() + res.Exprs = append(res.Exprs, yyDollar[3].selectExprUnion()) + yyLOCAL = res } + yyVAL.union = yyLOCAL case 931: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL SelectExpr -//line sql.y:4947 +//line sql.y:4949 { yyLOCAL = &StarExpr{} } @@ -17124,7 +17127,7 @@ yydefault: case 932: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL SelectExpr -//line sql.y:4951 +//line sql.y:4953 { yyLOCAL = &AliasedExpr{Expr: yyDollar[1].exprUnion(), As: yyDollar[2].identifierCI} } @@ -17132,7 +17135,7 @@ yydefault: case 933: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL SelectExpr -//line sql.y:4955 +//line sql.y:4957 { yyLOCAL = &StarExpr{TableName: TableName{Name: yyDollar[1].identifierCS}} } @@ -17140,39 +17143,39 @@ yydefault: case 934: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL SelectExpr -//line sql.y:4959 +//line sql.y:4961 { yyLOCAL = &StarExpr{TableName: TableName{Qualifier: yyDollar[1].identifierCS, Name: yyDollar[3].identifierCS}} } yyVAL.union = yyLOCAL case 935: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:4964 +//line sql.y:4966 { yyVAL.identifierCI = IdentifierCI{} } case 936: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:4968 +//line sql.y:4970 { yyVAL.identifierCI = yyDollar[1].identifierCI } case 937: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:4972 +//line sql.y:4974 { yyVAL.identifierCI = yyDollar[2].identifierCI } case 939: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:4979 +//line sql.y:4981 { yyVAL.identifierCI = NewIdentifierCI(string(yyDollar[1].str)) } case 940: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL TableExprs -//line sql.y:4984 +//line sql.y:4986 { yyLOCAL = TableExprs{&AliasedTableExpr{Expr: TableName{Name: NewIdentifierCS("dual")}}} } @@ -17180,7 +17183,7 @@ yydefault: case 941: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL TableExprs -//line sql.y:4988 +//line sql.y:4990 { yyLOCAL = yyDollar[1].tableExprsUnion() } @@ -17188,7 +17191,7 @@ yydefault: case 942: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL TableExprs -//line sql.y:4994 +//line sql.y:4996 { yyLOCAL = yyDollar[2].tableExprsUnion() } @@ -17196,14 +17199,14 @@ yydefault: case 943: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL TableExprs -//line sql.y:5000 +//line sql.y:5002 { yyLOCAL = TableExprs{yyDollar[1].tableExprUnion()} } yyVAL.union = yyLOCAL case 944: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5004 +//line sql.y:5006 { yySLICE := (*TableExprs)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].tableExprUnion()) @@ -17211,7 +17214,7 @@ yydefault: case 947: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL TableExpr -//line sql.y:5014 +//line sql.y:5016 { yyLOCAL = yyDollar[1].aliasedTableNameUnion() } @@ -17219,7 +17222,7 @@ yydefault: case 948: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL TableExpr -//line sql.y:5018 +//line sql.y:5020 { yyLOCAL = &AliasedTableExpr{Expr: yyDollar[1].derivedTableUnion(), As: yyDollar[3].identifierCS, Columns: yyDollar[4].columnsUnion()} } @@ -17227,7 +17230,7 @@ yydefault: case 949: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL TableExpr -//line sql.y:5022 +//line sql.y:5024 { yyLOCAL = &ParenTableExpr{Exprs: yyDollar[2].tableExprsUnion()} } @@ -17235,7 +17238,7 @@ yydefault: case 950: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL TableExpr -//line sql.y:5026 +//line sql.y:5028 { yyLOCAL = yyDollar[1].tableExprUnion() } @@ -17243,7 +17246,7 @@ yydefault: case 951: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *DerivedTable -//line sql.y:5032 +//line sql.y:5034 { yyLOCAL = &DerivedTable{Lateral: false, Select: yyDollar[1].tableStmtUnion()} } @@ -17251,7 +17254,7 @@ yydefault: case 952: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *DerivedTable -//line sql.y:5036 +//line sql.y:5038 { yyLOCAL = &DerivedTable{Lateral: true, Select: yyDollar[2].tableStmtUnion()} } @@ -17259,7 +17262,7 @@ yydefault: case 953: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL *AliasedTableExpr -//line sql.y:5042 +//line sql.y:5044 { yyLOCAL = &AliasedTableExpr{Expr: yyDollar[1].tableName, As: yyDollar[2].identifierCS, Hints: yyDollar[3].indexHintsUnion()} } @@ -17267,7 +17270,7 @@ yydefault: case 954: yyDollar = yyS[yypt-7 : yypt+1] var yyLOCAL *AliasedTableExpr -//line sql.y:5046 +//line sql.y:5048 { yyLOCAL = &AliasedTableExpr{Expr: yyDollar[1].tableName, Partitions: yyDollar[4].partitionsUnion(), As: yyDollar[6].identifierCS, Hints: yyDollar[7].indexHintsUnion()} } @@ -17275,7 +17278,7 @@ yydefault: case 955: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL Columns -//line sql.y:5051 +//line sql.y:5053 { yyLOCAL = nil } @@ -17283,7 +17286,7 @@ yydefault: case 956: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Columns -//line sql.y:5055 +//line sql.y:5057 { yyLOCAL = yyDollar[2].columnsUnion() } @@ -17291,7 +17294,7 @@ yydefault: case 957: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL Columns -//line sql.y:5060 +//line sql.y:5062 { yyLOCAL = nil } @@ -17299,7 +17302,7 @@ yydefault: case 958: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Columns -//line sql.y:5064 +//line sql.y:5066 { yyLOCAL = yyDollar[1].columnsUnion() } @@ -17307,14 +17310,14 @@ yydefault: case 959: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Columns -//line sql.y:5070 +//line sql.y:5072 { yyLOCAL = Columns{yyDollar[1].identifierCI} } yyVAL.union = yyLOCAL case 960: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5074 +//line sql.y:5076 { yySLICE := (*Columns)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].identifierCI) @@ -17322,14 +17325,14 @@ yydefault: case 961: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL []*Variable -//line sql.y:5080 +//line sql.y:5082 { yyLOCAL = []*Variable{yyDollar[1].variableUnion()} } yyVAL.union = yyLOCAL case 962: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5084 +//line sql.y:5086 { yySLICE := (*[]*Variable)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].variableUnion()) @@ -17337,7 +17340,7 @@ yydefault: case 963: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Columns -//line sql.y:5090 +//line sql.y:5092 { yyLOCAL = Columns{yyDollar[1].identifierCI} } @@ -17345,21 +17348,21 @@ yydefault: case 964: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Columns -//line sql.y:5094 +//line sql.y:5096 { yyLOCAL = Columns{NewIdentifierCI(string(yyDollar[1].str))} } yyVAL.union = yyLOCAL case 965: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5098 +//line sql.y:5100 { yySLICE := (*Columns)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].identifierCI) } case 966: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5102 +//line sql.y:5104 { yySLICE := (*Columns)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, NewIdentifierCI(string(yyDollar[3].str))) @@ -17367,14 +17370,14 @@ yydefault: case 967: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Partitions -//line sql.y:5108 +//line sql.y:5110 { yyLOCAL = Partitions{yyDollar[1].identifierCI} } yyVAL.union = yyLOCAL case 968: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5112 +//line sql.y:5114 { yySLICE := (*Partitions)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].identifierCI) @@ -17382,7 +17385,7 @@ yydefault: case 969: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL TableExpr -//line sql.y:5125 +//line sql.y:5127 { yyLOCAL = &JoinTableExpr{LeftExpr: yyDollar[1].tableExprUnion(), Join: yyDollar[2].joinTypeUnion(), RightExpr: yyDollar[3].tableExprUnion(), Condition: yyDollar[4].joinCondition} } @@ -17390,7 +17393,7 @@ yydefault: case 970: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL TableExpr -//line sql.y:5129 +//line sql.y:5131 { yyLOCAL = &JoinTableExpr{LeftExpr: yyDollar[1].tableExprUnion(), Join: yyDollar[2].joinTypeUnion(), RightExpr: yyDollar[3].tableExprUnion(), Condition: yyDollar[4].joinCondition} } @@ -17398,7 +17401,7 @@ yydefault: case 971: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL TableExpr -//line sql.y:5133 +//line sql.y:5135 { yyLOCAL = &JoinTableExpr{LeftExpr: yyDollar[1].tableExprUnion(), Join: yyDollar[2].joinTypeUnion(), RightExpr: yyDollar[3].tableExprUnion(), Condition: yyDollar[4].joinCondition} } @@ -17406,87 +17409,87 @@ yydefault: case 972: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL TableExpr -//line sql.y:5137 +//line sql.y:5139 { yyLOCAL = &JoinTableExpr{LeftExpr: yyDollar[1].tableExprUnion(), Join: yyDollar[2].joinTypeUnion(), RightExpr: yyDollar[3].tableExprUnion()} } yyVAL.union = yyLOCAL case 973: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:5143 +//line sql.y:5145 { yyVAL.joinCondition = &JoinCondition{On: yyDollar[2].exprUnion()} } case 974: yyDollar = yyS[yypt-4 : yypt+1] -//line sql.y:5145 +//line sql.y:5147 { yyVAL.joinCondition = &JoinCondition{Using: yyDollar[3].columnsUnion()} } case 975: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:5149 +//line sql.y:5151 { yyVAL.joinCondition = &JoinCondition{} } case 976: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5151 +//line sql.y:5153 { yyVAL.joinCondition = yyDollar[1].joinCondition } case 977: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:5155 +//line sql.y:5157 { yyVAL.joinCondition = &JoinCondition{} } case 978: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:5157 +//line sql.y:5159 { yyVAL.joinCondition = &JoinCondition{On: yyDollar[2].exprUnion()} } case 979: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:5160 +//line sql.y:5162 { yyVAL.empty = struct{}{} } case 980: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5162 +//line sql.y:5164 { yyVAL.empty = struct{}{} } case 981: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:5165 +//line sql.y:5167 { yyVAL.identifierCS = NewIdentifierCS("") } case 982: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5169 +//line sql.y:5171 { yyVAL.identifierCS = yyDollar[1].identifierCS } case 983: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:5173 +//line sql.y:5175 { yyVAL.identifierCS = yyDollar[2].identifierCS } case 985: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5180 +//line sql.y:5182 { yyVAL.identifierCS = NewIdentifierCS(string(yyDollar[1].str)) } case 986: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL JoinType -//line sql.y:5186 +//line sql.y:5188 { yyLOCAL = NormalJoinType } @@ -17494,7 +17497,7 @@ yydefault: case 987: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL JoinType -//line sql.y:5190 +//line sql.y:5192 { yyLOCAL = NormalJoinType } @@ -17502,7 +17505,7 @@ yydefault: case 988: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL JoinType -//line sql.y:5194 +//line sql.y:5196 { yyLOCAL = NormalJoinType } @@ -17510,7 +17513,7 @@ yydefault: case 989: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL JoinType -//line sql.y:5200 +//line sql.y:5202 { yyLOCAL = StraightJoinType } @@ -17518,7 +17521,7 @@ yydefault: case 990: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL JoinType -//line sql.y:5206 +//line sql.y:5208 { yyLOCAL = LeftJoinType } @@ -17526,7 +17529,7 @@ yydefault: case 991: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL JoinType -//line sql.y:5210 +//line sql.y:5212 { yyLOCAL = LeftJoinType } @@ -17534,7 +17537,7 @@ yydefault: case 992: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL JoinType -//line sql.y:5214 +//line sql.y:5216 { yyLOCAL = RightJoinType } @@ -17542,7 +17545,7 @@ yydefault: case 993: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL JoinType -//line sql.y:5218 +//line sql.y:5220 { yyLOCAL = RightJoinType } @@ -17550,7 +17553,7 @@ yydefault: case 994: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL JoinType -//line sql.y:5224 +//line sql.y:5226 { yyLOCAL = NaturalJoinType } @@ -17558,7 +17561,7 @@ yydefault: case 995: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL JoinType -//line sql.y:5228 +//line sql.y:5230 { if yyDollar[2].joinTypeUnion() == LeftJoinType { yyLOCAL = NaturalLeftJoinType @@ -17569,38 +17572,38 @@ yydefault: yyVAL.union = yyLOCAL case 996: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:5238 +//line sql.y:5240 { yyVAL.tableName = yyDollar[2].tableName } case 997: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5242 +//line sql.y:5244 { yyVAL.tableName = yyDollar[1].tableName } case 998: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5248 +//line sql.y:5250 { yyVAL.tableName = TableName{Name: yyDollar[1].identifierCS} } case 999: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5252 +//line sql.y:5254 { yyVAL.tableName = TableName{Qualifier: yyDollar[1].identifierCS, Name: yyDollar[3].identifierCS} } case 1000: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5258 +//line sql.y:5260 { yyVAL.tableName = TableName{Name: yyDollar[1].identifierCS} } case 1001: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL IndexHints -//line sql.y:5263 +//line sql.y:5265 { yyLOCAL = nil } @@ -17608,7 +17611,7 @@ yydefault: case 1002: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IndexHints -//line sql.y:5267 +//line sql.y:5269 { yyLOCAL = yyDollar[1].indexHintsUnion() } @@ -17616,14 +17619,14 @@ yydefault: case 1003: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IndexHints -//line sql.y:5273 +//line sql.y:5275 { yyLOCAL = IndexHints{yyDollar[1].indexHintUnion()} } yyVAL.union = yyLOCAL case 1004: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:5277 +//line sql.y:5279 { yySLICE := (*IndexHints)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[2].indexHintUnion()) @@ -17631,7 +17634,7 @@ yydefault: case 1005: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL *IndexHint -//line sql.y:5283 +//line sql.y:5285 { yyLOCAL = &IndexHint{Type: UseOp, ForType: yyDollar[3].indexHintForTypeUnion(), Indexes: yyDollar[5].columnsUnion()} } @@ -17639,7 +17642,7 @@ yydefault: case 1006: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *IndexHint -//line sql.y:5287 +//line sql.y:5289 { yyLOCAL = &IndexHint{Type: UseOp, ForType: yyDollar[3].indexHintForTypeUnion()} } @@ -17647,7 +17650,7 @@ yydefault: case 1007: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL *IndexHint -//line sql.y:5291 +//line sql.y:5293 { yyLOCAL = &IndexHint{Type: IgnoreOp, ForType: yyDollar[3].indexHintForTypeUnion(), Indexes: yyDollar[5].columnsUnion()} } @@ -17655,7 +17658,7 @@ yydefault: case 1008: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL *IndexHint -//line sql.y:5295 +//line sql.y:5297 { yyLOCAL = &IndexHint{Type: ForceOp, ForType: yyDollar[3].indexHintForTypeUnion(), Indexes: yyDollar[5].columnsUnion()} } @@ -17663,7 +17666,7 @@ yydefault: case 1009: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *IndexHint -//line sql.y:5299 +//line sql.y:5301 { yyLOCAL = &IndexHint{Type: UseVindexOp, Indexes: yyDollar[4].columnsUnion()} } @@ -17671,7 +17674,7 @@ yydefault: case 1010: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *IndexHint -//line sql.y:5303 +//line sql.y:5305 { yyLOCAL = &IndexHint{Type: IgnoreVindexOp, Indexes: yyDollar[4].columnsUnion()} } @@ -17679,7 +17682,7 @@ yydefault: case 1011: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL IndexHintForType -//line sql.y:5308 +//line sql.y:5310 { yyLOCAL = NoForType } @@ -17687,7 +17690,7 @@ yydefault: case 1012: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL IndexHintForType -//line sql.y:5312 +//line sql.y:5314 { yyLOCAL = JoinForType } @@ -17695,7 +17698,7 @@ yydefault: case 1013: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL IndexHintForType -//line sql.y:5316 +//line sql.y:5318 { yyLOCAL = OrderByForType } @@ -17703,7 +17706,7 @@ yydefault: case 1014: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL IndexHintForType -//line sql.y:5320 +//line sql.y:5322 { yyLOCAL = GroupByForType } @@ -17711,7 +17714,7 @@ yydefault: case 1015: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL Expr -//line sql.y:5326 +//line sql.y:5328 { yyLOCAL = nil } @@ -17719,7 +17722,7 @@ yydefault: case 1016: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:5330 +//line sql.y:5332 { yyLOCAL = yyDollar[2].exprUnion() } @@ -17727,7 +17730,7 @@ yydefault: case 1017: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5337 +//line sql.y:5339 { yyLOCAL = &OrExpr{Left: yyDollar[1].exprUnion(), Right: yyDollar[3].exprUnion()} } @@ -17735,7 +17738,7 @@ yydefault: case 1018: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5341 +//line sql.y:5343 { yyLOCAL = &XorExpr{Left: yyDollar[1].exprUnion(), Right: yyDollar[3].exprUnion()} } @@ -17743,7 +17746,7 @@ yydefault: case 1019: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5345 +//line sql.y:5347 { yyLOCAL = &AndExpr{Left: yyDollar[1].exprUnion(), Right: yyDollar[3].exprUnion()} } @@ -17751,7 +17754,7 @@ yydefault: case 1020: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:5349 +//line sql.y:5351 { yyLOCAL = &NotExpr{Expr: yyDollar[2].exprUnion()} } @@ -17759,7 +17762,7 @@ yydefault: case 1021: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5353 +//line sql.y:5355 { yyLOCAL = &IsExpr{Left: yyDollar[1].exprUnion(), Right: yyDollar[3].isExprOperatorUnion()} } @@ -17767,7 +17770,7 @@ yydefault: case 1022: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5357 +//line sql.y:5359 { yyLOCAL = yyDollar[1].exprUnion() } @@ -17775,7 +17778,7 @@ yydefault: case 1023: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5361 +//line sql.y:5363 { yyLOCAL = &AssignmentExpr{Left: yyDollar[1].variableUnion(), Right: yyDollar[3].exprUnion()} } @@ -17783,25 +17786,25 @@ yydefault: case 1024: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:5365 +//line sql.y:5367 { yyLOCAL = &MemberOfExpr{Value: yyDollar[1].exprUnion(), JSONArr: yyDollar[5].exprUnion()} } yyVAL.union = yyLOCAL case 1025: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5371 +//line sql.y:5373 { } case 1026: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5374 +//line sql.y:5376 { } case 1027: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5379 +//line sql.y:5381 { yyLOCAL = &IsExpr{Left: yyDollar[1].exprUnion(), Right: IsNullOp} } @@ -17809,7 +17812,7 @@ yydefault: case 1028: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:5383 +//line sql.y:5385 { yyLOCAL = &IsExpr{Left: yyDollar[1].exprUnion(), Right: IsNotNullOp} } @@ -17817,7 +17820,7 @@ yydefault: case 1029: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5387 +//line sql.y:5389 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: yyDollar[2].comparisonExprOperatorUnion(), Right: yyDollar[3].exprUnion()} } @@ -17825,7 +17828,7 @@ yydefault: case 1030: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:5391 +//line sql.y:5393 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: yyDollar[2].comparisonExprOperatorUnion(), Modifier: Any, Right: yyDollar[4].subqueryUnion()} } @@ -17833,7 +17836,7 @@ yydefault: case 1031: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:5395 +//line sql.y:5397 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: yyDollar[2].comparisonExprOperatorUnion(), Modifier: Any, Right: yyDollar[4].subqueryUnion()} } @@ -17841,7 +17844,7 @@ yydefault: case 1032: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:5399 +//line sql.y:5401 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: yyDollar[2].comparisonExprOperatorUnion(), Modifier: All, Right: yyDollar[4].subqueryUnion()} } @@ -17849,7 +17852,7 @@ yydefault: case 1033: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5403 +//line sql.y:5405 { yyLOCAL = yyDollar[1].exprUnion() } @@ -17857,7 +17860,7 @@ yydefault: case 1034: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5409 +//line sql.y:5411 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: InOp, Right: yyDollar[3].colTupleUnion()} } @@ -17865,7 +17868,7 @@ yydefault: case 1035: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:5413 +//line sql.y:5415 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: NotInOp, Right: yyDollar[4].colTupleUnion()} } @@ -17873,7 +17876,7 @@ yydefault: case 1036: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:5417 +//line sql.y:5419 { yyLOCAL = &BetweenExpr{Left: yyDollar[1].exprUnion(), IsBetween: true, From: yyDollar[3].exprUnion(), To: yyDollar[5].exprUnion()} } @@ -17881,7 +17884,7 @@ yydefault: case 1037: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:5421 +//line sql.y:5423 { yyLOCAL = &BetweenExpr{Left: yyDollar[1].exprUnion(), IsBetween: false, From: yyDollar[4].exprUnion(), To: yyDollar[6].exprUnion()} } @@ -17889,7 +17892,7 @@ yydefault: case 1038: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5425 +//line sql.y:5427 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: LikeOp, Right: yyDollar[3].exprUnion()} } @@ -17897,7 +17900,7 @@ yydefault: case 1039: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:5429 +//line sql.y:5431 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: NotLikeOp, Right: yyDollar[4].exprUnion()} } @@ -17905,7 +17908,7 @@ yydefault: case 1040: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:5433 +//line sql.y:5435 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: LikeOp, Right: yyDollar[3].exprUnion(), Escape: yyDollar[5].exprUnion()} } @@ -17913,7 +17916,7 @@ yydefault: case 1041: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:5437 +//line sql.y:5439 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: NotLikeOp, Right: yyDollar[4].exprUnion(), Escape: yyDollar[6].exprUnion()} } @@ -17921,7 +17924,7 @@ yydefault: case 1042: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5441 +//line sql.y:5443 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: RegexpOp, Right: yyDollar[3].exprUnion()} } @@ -17929,7 +17932,7 @@ yydefault: case 1043: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:5445 +//line sql.y:5447 { yyLOCAL = &ComparisonExpr{Left: yyDollar[1].exprUnion(), Operator: NotRegexpOp, Right: yyDollar[4].exprUnion()} } @@ -17937,25 +17940,25 @@ yydefault: case 1044: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5449 +//line sql.y:5451 { yyLOCAL = yyDollar[1].exprUnion() } yyVAL.union = yyLOCAL case 1045: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5455 +//line sql.y:5457 { } case 1046: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5458 +//line sql.y:5460 { } case 1047: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5464 +//line sql.y:5466 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: BitOrOp, Right: yyDollar[3].exprUnion()} } @@ -17963,7 +17966,7 @@ yydefault: case 1048: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5468 +//line sql.y:5470 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: BitAndOp, Right: yyDollar[3].exprUnion()} } @@ -17971,7 +17974,7 @@ yydefault: case 1049: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5472 +//line sql.y:5474 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: ShiftLeftOp, Right: yyDollar[3].exprUnion()} } @@ -17979,7 +17982,7 @@ yydefault: case 1050: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5476 +//line sql.y:5478 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: ShiftRightOp, Right: yyDollar[3].exprUnion()} } @@ -17987,7 +17990,7 @@ yydefault: case 1051: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5480 +//line sql.y:5482 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: PlusOp, Right: yyDollar[3].exprUnion()} } @@ -17995,7 +17998,7 @@ yydefault: case 1052: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5484 +//line sql.y:5486 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: MinusOp, Right: yyDollar[3].exprUnion()} } @@ -18003,7 +18006,7 @@ yydefault: case 1053: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:5488 +//line sql.y:5490 { yyLOCAL = &IntervalDateExpr{Syntax: IntervalDateExprBinaryAdd, Date: yyDollar[1].exprUnion(), Unit: yyDollar[5].intervalTypeUnion(), Interval: yyDollar[4].exprUnion()} } @@ -18011,7 +18014,7 @@ yydefault: case 1054: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:5492 +//line sql.y:5494 { yyLOCAL = &IntervalDateExpr{Syntax: IntervalDateExprBinarySub, Date: yyDollar[1].exprUnion(), Unit: yyDollar[5].intervalTypeUnion(), Interval: yyDollar[4].exprUnion()} } @@ -18019,7 +18022,7 @@ yydefault: case 1055: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5496 +//line sql.y:5498 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: MultOp, Right: yyDollar[3].exprUnion()} } @@ -18027,7 +18030,7 @@ yydefault: case 1056: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5500 +//line sql.y:5502 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: DivOp, Right: yyDollar[3].exprUnion()} } @@ -18035,7 +18038,7 @@ yydefault: case 1057: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5504 +//line sql.y:5506 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: ModOp, Right: yyDollar[3].exprUnion()} } @@ -18043,7 +18046,7 @@ yydefault: case 1058: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5508 +//line sql.y:5510 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: IntDivOp, Right: yyDollar[3].exprUnion()} } @@ -18051,7 +18054,7 @@ yydefault: case 1059: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5512 +//line sql.y:5514 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: ModOp, Right: yyDollar[3].exprUnion()} } @@ -18059,7 +18062,7 @@ yydefault: case 1060: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5516 +//line sql.y:5518 { yyLOCAL = &BinaryExpr{Left: yyDollar[1].exprUnion(), Operator: BitXorOp, Right: yyDollar[3].exprUnion()} } @@ -18067,7 +18070,7 @@ yydefault: case 1061: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5520 +//line sql.y:5522 { yyLOCAL = yyDollar[1].exprUnion() } @@ -18075,7 +18078,7 @@ yydefault: case 1062: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5526 +//line sql.y:5528 { yyLOCAL = yyDollar[1].exprUnion() } @@ -18083,7 +18086,7 @@ yydefault: case 1063: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5530 +//line sql.y:5532 { yyLOCAL = yyDollar[1].exprUnion() } @@ -18091,7 +18094,7 @@ yydefault: case 1064: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5534 +//line sql.y:5536 { yyLOCAL = yyDollar[1].exprUnion() } @@ -18099,7 +18102,7 @@ yydefault: case 1065: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5538 +//line sql.y:5540 { yyLOCAL = yyDollar[1].exprUnion() } @@ -18107,7 +18110,7 @@ yydefault: case 1066: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5542 +//line sql.y:5544 { yyLOCAL = &CollateExpr{Expr: yyDollar[1].exprUnion(), Collation: yyDollar[3].str} } @@ -18115,7 +18118,7 @@ yydefault: case 1067: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5546 +//line sql.y:5548 { yyLOCAL = yyDollar[1].exprUnion() } @@ -18123,7 +18126,7 @@ yydefault: case 1068: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5550 +//line sql.y:5552 { yyLOCAL = yyDollar[1].exprUnion() } @@ -18131,7 +18134,7 @@ yydefault: case 1069: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5554 +//line sql.y:5556 { yyLOCAL = yyDollar[1].variableUnion() } @@ -18139,7 +18142,7 @@ yydefault: case 1070: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:5558 +//line sql.y:5560 { yyLOCAL = yyDollar[2].exprUnion() // TODO: do we really want to ignore unary '+' before any kind of literals? } @@ -18147,7 +18150,7 @@ yydefault: case 1071: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:5562 +//line sql.y:5564 { yyLOCAL = &UnaryExpr{Operator: UMinusOp, Expr: yyDollar[2].exprUnion()} } @@ -18155,7 +18158,7 @@ yydefault: case 1072: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:5566 +//line sql.y:5568 { yyLOCAL = &UnaryExpr{Operator: TildaOp, Expr: yyDollar[2].exprUnion()} } @@ -18163,7 +18166,7 @@ yydefault: case 1073: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:5570 +//line sql.y:5572 { yyLOCAL = &UnaryExpr{Operator: BangOp, Expr: yyDollar[2].exprUnion()} } @@ -18171,7 +18174,7 @@ yydefault: case 1074: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5574 +//line sql.y:5576 { yyLOCAL = yyDollar[1].subqueryUnion() } @@ -18179,7 +18182,7 @@ yydefault: case 1075: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:5578 +//line sql.y:5580 { yyLOCAL = yyDollar[1].exprUnion() } @@ -18187,7 +18190,7 @@ yydefault: case 1076: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:5582 +//line sql.y:5584 { yyLOCAL = &ExistsExpr{Subquery: yyDollar[2].subqueryUnion()} } @@ -18195,7 +18198,7 @@ yydefault: case 1077: yyDollar = yyS[yypt-7 : yypt+1] var yyLOCAL Expr -//line sql.y:5586 +//line sql.y:5588 { yyLOCAL = &MatchExpr{Columns: yyDollar[2].colNamesUnion(), Expr: yyDollar[5].exprUnion(), Option: yyDollar[6].matchExprOptionUnion()} } @@ -18203,7 +18206,7 @@ yydefault: case 1078: yyDollar = yyS[yypt-7 : yypt+1] var yyLOCAL Expr -//line sql.y:5590 +//line sql.y:5592 { yyLOCAL = &CastExpr{Expr: yyDollar[3].exprUnion(), Type: yyDollar[5].convertTypeUnion(), Array: yyDollar[6].booleanUnion()} } @@ -18211,7 +18214,7 @@ yydefault: case 1079: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:5594 +//line sql.y:5596 { yyLOCAL = &ConvertExpr{Expr: yyDollar[3].exprUnion(), Type: yyDollar[5].convertTypeUnion()} } @@ -18219,7 +18222,7 @@ yydefault: case 1080: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:5598 +//line sql.y:5600 { yyLOCAL = &ConvertUsingExpr{Expr: yyDollar[3].exprUnion(), Type: yyDollar[5].str} } @@ -18227,7 +18230,7 @@ yydefault: case 1081: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:5602 +//line sql.y:5604 { // From: https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#operator_binary // To convert a string expression to a binary string, these constructs are equivalent: @@ -18239,7 +18242,7 @@ yydefault: case 1082: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:5610 +//line sql.y:5612 { yyLOCAL = &Default{ColName: yyDollar[2].str} } @@ -18247,7 +18250,7 @@ yydefault: case 1083: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:5614 +//line sql.y:5616 { yyLOCAL = &IntervalDateExpr{Syntax: IntervalDateExprBinaryAddLeft, Date: yyDollar[5].exprUnion(), Unit: yyDollar[3].intervalTypeUnion(), Interval: yyDollar[2].exprUnion()} } @@ -18255,7 +18258,7 @@ yydefault: case 1084: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:5618 +//line sql.y:5620 { yyLOCAL = &IntervalFuncExpr{Expr: yyDollar[3].exprUnion(), Exprs: yyDollar[5].exprsUnion()} } @@ -18263,7 +18266,7 @@ yydefault: case 1085: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5622 +//line sql.y:5624 { yyLOCAL = &JSONExtractExpr{JSONDoc: yyDollar[1].exprUnion(), PathList: []Expr{yyDollar[3].exprUnion()}} } @@ -18271,7 +18274,7 @@ yydefault: case 1086: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:5626 +//line sql.y:5628 { yyLOCAL = &JSONUnquoteExpr{JSONValue: &JSONExtractExpr{JSONDoc: yyDollar[1].exprUnion(), PathList: []Expr{yyDollar[3].exprUnion()}}} } @@ -18279,7 +18282,7 @@ yydefault: case 1087: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL []*ColName -//line sql.y:5632 +//line sql.y:5634 { yyLOCAL = yyDollar[1].colNamesUnion() } @@ -18287,7 +18290,7 @@ yydefault: case 1088: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL []*ColName -//line sql.y:5636 +//line sql.y:5638 { yyLOCAL = yyDollar[2].colNamesUnion() } @@ -18295,14 +18298,14 @@ yydefault: case 1089: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL []*ColName -//line sql.y:5642 +//line sql.y:5644 { yyLOCAL = []*ColName{yyDollar[1].colNameUnion()} } yyVAL.union = yyLOCAL case 1090: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5646 +//line sql.y:5648 { yySLICE := (*[]*ColName)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].colNameUnion()) @@ -18310,7 +18313,7 @@ yydefault: case 1091: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL TrimType -//line sql.y:5652 +//line sql.y:5654 { yyLOCAL = BothTrimType } @@ -18318,7 +18321,7 @@ yydefault: case 1092: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL TrimType -//line sql.y:5656 +//line sql.y:5658 { yyLOCAL = LeadingTrimType } @@ -18326,7 +18329,7 @@ yydefault: case 1093: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL TrimType -//line sql.y:5660 +//line sql.y:5662 { yyLOCAL = TrailingTrimType } @@ -18334,7 +18337,7 @@ yydefault: case 1094: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL FrameUnitType -//line sql.y:5666 +//line sql.y:5668 { yyLOCAL = FrameRowsType } @@ -18342,7 +18345,7 @@ yydefault: case 1095: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL FrameUnitType -//line sql.y:5670 +//line sql.y:5672 { yyLOCAL = FrameRangeType } @@ -18350,7 +18353,7 @@ yydefault: case 1096: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ArgumentLessWindowExprType -//line sql.y:5677 +//line sql.y:5679 { yyLOCAL = CumeDistExprType } @@ -18358,7 +18361,7 @@ yydefault: case 1097: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ArgumentLessWindowExprType -//line sql.y:5681 +//line sql.y:5683 { yyLOCAL = DenseRankExprType } @@ -18366,7 +18369,7 @@ yydefault: case 1098: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ArgumentLessWindowExprType -//line sql.y:5685 +//line sql.y:5687 { yyLOCAL = PercentRankExprType } @@ -18374,7 +18377,7 @@ yydefault: case 1099: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ArgumentLessWindowExprType -//line sql.y:5689 +//line sql.y:5691 { yyLOCAL = RankExprType } @@ -18382,7 +18385,7 @@ yydefault: case 1100: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ArgumentLessWindowExprType -//line sql.y:5693 +//line sql.y:5695 { yyLOCAL = RowNumberExprType } @@ -18390,7 +18393,7 @@ yydefault: case 1101: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *FramePoint -//line sql.y:5699 +//line sql.y:5701 { yyLOCAL = &FramePoint{Type: CurrentRowType} } @@ -18398,7 +18401,7 @@ yydefault: case 1102: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *FramePoint -//line sql.y:5703 +//line sql.y:5705 { yyLOCAL = &FramePoint{Type: UnboundedPrecedingType} } @@ -18406,7 +18409,7 @@ yydefault: case 1103: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *FramePoint -//line sql.y:5707 +//line sql.y:5709 { yyLOCAL = &FramePoint{Type: UnboundedFollowingType} } @@ -18414,7 +18417,7 @@ yydefault: case 1104: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *FramePoint -//line sql.y:5711 +//line sql.y:5713 { yyLOCAL = &FramePoint{Type: ExprPrecedingType, Expr: yyDollar[1].exprUnion()} } @@ -18422,7 +18425,7 @@ yydefault: case 1105: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL *FramePoint -//line sql.y:5715 +//line sql.y:5717 { yyLOCAL = &FramePoint{Type: ExprPrecedingType, Expr: yyDollar[2].exprUnion(), Unit: yyDollar[3].intervalTypeUnion()} } @@ -18430,7 +18433,7 @@ yydefault: case 1106: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *FramePoint -//line sql.y:5719 +//line sql.y:5721 { yyLOCAL = &FramePoint{Type: ExprFollowingType, Expr: yyDollar[1].exprUnion()} } @@ -18438,7 +18441,7 @@ yydefault: case 1107: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL *FramePoint -//line sql.y:5723 +//line sql.y:5725 { yyLOCAL = &FramePoint{Type: ExprFollowingType, Expr: yyDollar[2].exprUnion(), Unit: yyDollar[3].intervalTypeUnion()} } @@ -18446,7 +18449,7 @@ yydefault: case 1108: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL *FrameClause -//line sql.y:5728 +//line sql.y:5730 { yyLOCAL = nil } @@ -18454,7 +18457,7 @@ yydefault: case 1109: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *FrameClause -//line sql.y:5732 +//line sql.y:5734 { yyLOCAL = yyDollar[1].frameClauseUnion() } @@ -18462,7 +18465,7 @@ yydefault: case 1110: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *FrameClause -//line sql.y:5738 +//line sql.y:5740 { yyLOCAL = &FrameClause{Unit: yyDollar[1].frameUnitTypeUnion(), Start: yyDollar[2].framePointUnion()} } @@ -18470,43 +18473,43 @@ yydefault: case 1111: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *FrameClause -//line sql.y:5742 +//line sql.y:5744 { yyLOCAL = &FrameClause{Unit: yyDollar[1].frameUnitTypeUnion(), Start: yyDollar[3].framePointUnion(), End: yyDollar[5].framePointUnion()} } yyVAL.union = yyLOCAL case 1112: yyDollar = yyS[yypt-0 : yypt+1] - var yyLOCAL Exprs -//line sql.y:5747 + var yyLOCAL []Expr +//line sql.y:5749 { yyLOCAL = nil } yyVAL.union = yyLOCAL case 1113: yyDollar = yyS[yypt-3 : yypt+1] - var yyLOCAL Exprs -//line sql.y:5751 + var yyLOCAL []Expr +//line sql.y:5753 { yyLOCAL = yyDollar[3].exprsUnion() } yyVAL.union = yyLOCAL case 1114: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:5756 +//line sql.y:5758 { yyVAL.identifierCI = IdentifierCI{} } case 1115: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:5760 +//line sql.y:5762 { yyVAL.identifierCI = yyDollar[1].identifierCI } case 1116: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL *WindowSpecification -//line sql.y:5766 +//line sql.y:5768 { yyLOCAL = &WindowSpecification{Name: yyDollar[1].identifierCI, PartitionClause: yyDollar[2].exprsUnion(), OrderClause: yyDollar[3].orderByUnion(), FrameClause: yyDollar[4].frameClauseUnion()} } @@ -18514,7 +18517,7 @@ yydefault: case 1117: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL *OverClause -//line sql.y:5772 +//line sql.y:5774 { yyLOCAL = &OverClause{WindowSpec: yyDollar[3].windowSpecificationUnion()} } @@ -18522,7 +18525,7 @@ yydefault: case 1118: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *OverClause -//line sql.y:5776 +//line sql.y:5778 { yyLOCAL = &OverClause{WindowName: yyDollar[2].identifierCI} } @@ -18530,7 +18533,7 @@ yydefault: case 1119: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *OverClause -//line sql.y:5782 +//line sql.y:5784 { yyLOCAL = yyDollar[1].overClauseUnion() } @@ -18538,7 +18541,7 @@ yydefault: case 1120: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL *OverClause -//line sql.y:5786 +//line sql.y:5788 { yyLOCAL = nil } @@ -18546,7 +18549,7 @@ yydefault: case 1121: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL *NullTreatmentClause -//line sql.y:5791 +//line sql.y:5793 { yyLOCAL = nil } @@ -18554,7 +18557,7 @@ yydefault: case 1123: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *NullTreatmentClause -//line sql.y:5798 +//line sql.y:5800 { yyLOCAL = &NullTreatmentClause{yyDollar[1].nullTreatmentTypeUnion()} } @@ -18562,7 +18565,7 @@ yydefault: case 1124: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL NullTreatmentType -//line sql.y:5804 +//line sql.y:5806 { yyLOCAL = RespectNullsType } @@ -18570,7 +18573,7 @@ yydefault: case 1125: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL NullTreatmentType -//line sql.y:5808 +//line sql.y:5810 { yyLOCAL = IgnoreNullsType } @@ -18578,7 +18581,7 @@ yydefault: case 1126: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL FirstOrLastValueExprType -//line sql.y:5814 +//line sql.y:5816 { yyLOCAL = FirstValueExprType } @@ -18586,7 +18589,7 @@ yydefault: case 1127: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL FirstOrLastValueExprType -//line sql.y:5818 +//line sql.y:5820 { yyLOCAL = LastValueExprType } @@ -18594,7 +18597,7 @@ yydefault: case 1128: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL FromFirstLastType -//line sql.y:5824 +//line sql.y:5826 { yyLOCAL = FromFirstType } @@ -18602,7 +18605,7 @@ yydefault: case 1129: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL FromFirstLastType -//line sql.y:5828 +//line sql.y:5830 { yyLOCAL = FromLastType } @@ -18610,7 +18613,7 @@ yydefault: case 1130: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL *FromFirstLastClause -//line sql.y:5833 +//line sql.y:5835 { yyLOCAL = nil } @@ -18618,7 +18621,7 @@ yydefault: case 1132: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *FromFirstLastClause -//line sql.y:5840 +//line sql.y:5842 { yyLOCAL = &FromFirstLastClause{yyDollar[1].fromFirstLastTypeUnion()} } @@ -18626,7 +18629,7 @@ yydefault: case 1133: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL LagLeadExprType -//line sql.y:5846 +//line sql.y:5848 { yyLOCAL = LagExprType } @@ -18634,7 +18637,7 @@ yydefault: case 1134: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL LagLeadExprType -//line sql.y:5850 +//line sql.y:5852 { yyLOCAL = LeadExprType } @@ -18642,7 +18645,7 @@ yydefault: case 1135: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *WindowDefinition -//line sql.y:5856 +//line sql.y:5858 { yyLOCAL = &WindowDefinition{Name: yyDollar[1].identifierCI, WindowSpec: yyDollar[4].windowSpecificationUnion()} } @@ -18650,34 +18653,34 @@ yydefault: case 1136: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL WindowDefinitions -//line sql.y:5862 +//line sql.y:5864 { yyLOCAL = WindowDefinitions{yyDollar[1].windowDefinitionUnion()} } yyVAL.union = yyLOCAL case 1137: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5866 +//line sql.y:5868 { yySLICE := (*WindowDefinitions)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].windowDefinitionUnion()) } case 1138: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:5872 +//line sql.y:5874 { yyVAL.str = "" } case 1139: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5876 +//line sql.y:5878 { yyVAL.str = string(yyDollar[2].identifierCI.String()) } case 1140: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL BoolVal -//line sql.y:5882 +//line sql.y:5884 { yyLOCAL = BoolVal(true) } @@ -18685,7 +18688,7 @@ yydefault: case 1141: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL BoolVal -//line sql.y:5886 +//line sql.y:5888 { yyLOCAL = BoolVal(false) } @@ -18693,7 +18696,7 @@ yydefault: case 1142: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IsExprOperator -//line sql.y:5893 +//line sql.y:5895 { yyLOCAL = IsTrueOp } @@ -18701,7 +18704,7 @@ yydefault: case 1143: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL IsExprOperator -//line sql.y:5897 +//line sql.y:5899 { yyLOCAL = IsNotTrueOp } @@ -18709,7 +18712,7 @@ yydefault: case 1144: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IsExprOperator -//line sql.y:5901 +//line sql.y:5903 { yyLOCAL = IsFalseOp } @@ -18717,7 +18720,7 @@ yydefault: case 1145: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL IsExprOperator -//line sql.y:5905 +//line sql.y:5907 { yyLOCAL = IsNotFalseOp } @@ -18725,7 +18728,7 @@ yydefault: case 1146: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ComparisonExprOperator -//line sql.y:5911 +//line sql.y:5913 { yyLOCAL = yyDollar[1].comparisonExprOperatorUnion() } @@ -18733,7 +18736,7 @@ yydefault: case 1147: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ComparisonExprOperator -//line sql.y:5915 +//line sql.y:5917 { yyLOCAL = NullSafeEqualOp } @@ -18741,7 +18744,7 @@ yydefault: case 1148: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ComparisonExprOperator -//line sql.y:5921 +//line sql.y:5923 { yyLOCAL = EqualOp } @@ -18749,7 +18752,7 @@ yydefault: case 1149: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ComparisonExprOperator -//line sql.y:5925 +//line sql.y:5927 { yyLOCAL = LessThanOp } @@ -18757,7 +18760,7 @@ yydefault: case 1150: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ComparisonExprOperator -//line sql.y:5929 +//line sql.y:5931 { yyLOCAL = GreaterThanOp } @@ -18765,7 +18768,7 @@ yydefault: case 1151: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ComparisonExprOperator -//line sql.y:5933 +//line sql.y:5935 { yyLOCAL = LessEqualOp } @@ -18773,7 +18776,7 @@ yydefault: case 1152: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ComparisonExprOperator -//line sql.y:5937 +//line sql.y:5939 { yyLOCAL = GreaterEqualOp } @@ -18781,7 +18784,7 @@ yydefault: case 1153: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ComparisonExprOperator -//line sql.y:5941 +//line sql.y:5943 { yyLOCAL = NotEqualOp } @@ -18789,7 +18792,7 @@ yydefault: case 1154: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ColTuple -//line sql.y:5947 +//line sql.y:5949 { yyLOCAL = yyDollar[1].valTupleUnion() } @@ -18797,7 +18800,7 @@ yydefault: case 1155: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ColTuple -//line sql.y:5951 +//line sql.y:5953 { yyLOCAL = yyDollar[1].subqueryUnion() } @@ -18805,7 +18808,7 @@ yydefault: case 1156: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ColTuple -//line sql.y:5955 +//line sql.y:5957 { yyLOCAL = ListArg(yyDollar[1].str[2:]) markBindVariable(yylex, yyDollar[1].str[2:]) @@ -18814,30 +18817,30 @@ yydefault: case 1157: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *Subquery -//line sql.y:5962 +//line sql.y:5964 { yyLOCAL = &Subquery{yyDollar[1].tableStmtUnion()} } yyVAL.union = yyLOCAL case 1158: yyDollar = yyS[yypt-1 : yypt+1] - var yyLOCAL Exprs -//line sql.y:5968 + var yyLOCAL []Expr +//line sql.y:5970 { - yyLOCAL = Exprs{yyDollar[1].exprUnion()} + yyLOCAL = []Expr{yyDollar[1].exprUnion()} } yyVAL.union = yyLOCAL case 1159: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:5972 +//line sql.y:5974 { - yySLICE := (*Exprs)(yyIaddr(yyVAL.union)) + yySLICE := (*[]Expr)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].exprUnion()) } case 1160: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:5982 +//line sql.y:5984 { yyLOCAL = &FuncExpr{Name: yyDollar[1].identifierCI, Exprs: yyDollar[3].exprsUnion()} } @@ -18845,7 +18848,7 @@ yydefault: case 1161: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:5986 +//line sql.y:5988 { yyLOCAL = &FuncExpr{Qualifier: yyDollar[1].identifierCS, Name: yyDollar[3].identifierCI, Exprs: yyDollar[5].exprsUnion()} } @@ -18853,7 +18856,7 @@ yydefault: case 1162: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:5996 +//line sql.y:5998 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI("left"), Exprs: yyDollar[3].exprsUnion()} } @@ -18861,7 +18864,7 @@ yydefault: case 1163: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6000 +//line sql.y:6002 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI("right"), Exprs: yyDollar[3].exprsUnion()} } @@ -18869,7 +18872,7 @@ yydefault: case 1164: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6004 +//line sql.y:6006 { yyLOCAL = &SubstrExpr{Name: yyDollar[3].exprUnion(), From: yyDollar[5].exprUnion(), To: yyDollar[7].exprUnion()} } @@ -18877,7 +18880,7 @@ yydefault: case 1165: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6008 +//line sql.y:6010 { yyLOCAL = &SubstrExpr{Name: yyDollar[3].exprUnion(), From: yyDollar[5].exprUnion(), To: yyDollar[7].exprUnion()} } @@ -18885,7 +18888,7 @@ yydefault: case 1166: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6012 +//line sql.y:6014 { yyLOCAL = &SubstrExpr{Name: yyDollar[3].exprUnion(), From: yyDollar[5].exprUnion()} } @@ -18893,7 +18896,7 @@ yydefault: case 1167: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6016 +//line sql.y:6018 { yyLOCAL = &SubstrExpr{Name: yyDollar[3].exprUnion(), From: yyDollar[5].exprUnion(), To: yyDollar[7].exprUnion()} } @@ -18901,7 +18904,7 @@ yydefault: case 1168: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6020 +//line sql.y:6022 { yyLOCAL = &SubstrExpr{Name: yyDollar[3].exprUnion(), From: yyDollar[5].exprUnion()} } @@ -18909,7 +18912,7 @@ yydefault: case 1169: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6024 +//line sql.y:6026 { yyLOCAL = &CaseExpr{Expr: yyDollar[2].exprUnion(), Whens: yyDollar[3].whensUnion(), Else: yyDollar[4].exprUnion()} } @@ -18917,7 +18920,7 @@ yydefault: case 1170: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6028 +//line sql.y:6030 { yyLOCAL = &ValuesFuncExpr{Name: yyDollar[3].colNameUnion()} } @@ -18925,7 +18928,7 @@ yydefault: case 1171: yyDollar = yyS[yypt-10 : yypt+1] var yyLOCAL Expr -//line sql.y:6032 +//line sql.y:6034 { yyLOCAL = &InsertExpr{Str: yyDollar[3].exprUnion(), Pos: yyDollar[5].exprUnion(), Len: yyDollar[7].exprUnion(), NewStr: yyDollar[9].exprUnion()} } @@ -18933,7 +18936,7 @@ yydefault: case 1172: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:6036 +//line sql.y:6038 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI(yyDollar[1].str)} } @@ -18941,7 +18944,7 @@ yydefault: case 1173: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:6047 +//line sql.y:6049 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI("utc_date")} } @@ -18949,7 +18952,7 @@ yydefault: case 1174: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:6051 +//line sql.y:6053 { yyLOCAL = yyDollar[1].exprUnion() } @@ -18957,7 +18960,7 @@ yydefault: case 1175: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:6057 +//line sql.y:6059 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI("current_date")} } @@ -18965,7 +18968,7 @@ yydefault: case 1176: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:6061 +//line sql.y:6063 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI("curdate")} } @@ -18973,7 +18976,7 @@ yydefault: case 1177: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:6065 +//line sql.y:6067 { yyLOCAL = &CurTimeFuncExpr{Name: NewIdentifierCI("utc_time"), Fsp: yyDollar[2].integerUnion()} } @@ -18981,7 +18984,7 @@ yydefault: case 1178: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:6070 +//line sql.y:6072 { yyLOCAL = &CurTimeFuncExpr{Name: NewIdentifierCI("curtime"), Fsp: yyDollar[2].integerUnion()} } @@ -18989,7 +18992,7 @@ yydefault: case 1179: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:6075 +//line sql.y:6077 { yyLOCAL = &CurTimeFuncExpr{Name: NewIdentifierCI("current_time"), Fsp: yyDollar[2].integerUnion()} } @@ -18997,7 +19000,7 @@ yydefault: case 1180: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6079 +//line sql.y:6081 { yyLOCAL = &CountStar{OverClause: yyDollar[5].overClauseUnion()} } @@ -19005,7 +19008,7 @@ yydefault: case 1181: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6083 +//line sql.y:6085 { yyLOCAL = &Count{Distinct: yyDollar[3].booleanUnion(), Args: yyDollar[4].exprsUnion(), OverClause: yyDollar[6].overClauseUnion()} } @@ -19013,7 +19016,7 @@ yydefault: case 1182: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6087 +//line sql.y:6089 { yyLOCAL = &Max{Distinct: yyDollar[3].booleanUnion(), Arg: yyDollar[4].exprUnion(), OverClause: yyDollar[6].overClauseUnion()} } @@ -19021,7 +19024,7 @@ yydefault: case 1183: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6091 +//line sql.y:6093 { yyLOCAL = &Min{Distinct: yyDollar[3].booleanUnion(), Arg: yyDollar[4].exprUnion(), OverClause: yyDollar[6].overClauseUnion()} } @@ -19029,7 +19032,7 @@ yydefault: case 1184: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6095 +//line sql.y:6097 { yyLOCAL = &Sum{Distinct: yyDollar[3].booleanUnion(), Arg: yyDollar[4].exprUnion(), OverClause: yyDollar[6].overClauseUnion()} } @@ -19037,7 +19040,7 @@ yydefault: case 1185: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6099 +//line sql.y:6101 { yyLOCAL = &Avg{Distinct: yyDollar[3].booleanUnion(), Arg: yyDollar[4].exprUnion(), OverClause: yyDollar[6].overClauseUnion()} } @@ -19045,7 +19048,7 @@ yydefault: case 1186: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6103 +//line sql.y:6105 { yyLOCAL = &BitAnd{Arg: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19053,7 +19056,7 @@ yydefault: case 1187: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6107 +//line sql.y:6109 { yyLOCAL = &BitOr{Arg: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19061,7 +19064,7 @@ yydefault: case 1188: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6111 +//line sql.y:6113 { yyLOCAL = &BitXor{Arg: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19069,7 +19072,7 @@ yydefault: case 1189: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6115 +//line sql.y:6117 { yyLOCAL = &Std{Arg: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19077,7 +19080,7 @@ yydefault: case 1190: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6119 +//line sql.y:6121 { yyLOCAL = &StdDev{Arg: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19085,7 +19088,7 @@ yydefault: case 1191: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6123 +//line sql.y:6125 { yyLOCAL = &StdPop{Arg: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19093,7 +19096,7 @@ yydefault: case 1192: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6127 +//line sql.y:6129 { yyLOCAL = &StdSamp{Arg: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19101,7 +19104,7 @@ yydefault: case 1193: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6131 +//line sql.y:6133 { yyLOCAL = &VarPop{Arg: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19109,7 +19112,7 @@ yydefault: case 1194: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6135 +//line sql.y:6137 { yyLOCAL = &VarSamp{Arg: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19117,7 +19120,7 @@ yydefault: case 1195: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6139 +//line sql.y:6141 { yyLOCAL = &Variance{Arg: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19125,7 +19128,7 @@ yydefault: case 1196: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6143 +//line sql.y:6145 { yyLOCAL = &GroupConcatExpr{Distinct: yyDollar[3].booleanUnion(), Exprs: yyDollar[4].exprsUnion(), OrderBy: yyDollar[5].orderByUnion(), Separator: yyDollar[6].str, Limit: yyDollar[7].limitUnion()} } @@ -19133,7 +19136,7 @@ yydefault: case 1197: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6147 +//line sql.y:6149 { yyLOCAL = &AnyValue{Arg: yyDollar[3].exprUnion()} } @@ -19141,7 +19144,7 @@ yydefault: case 1198: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6151 +//line sql.y:6153 { yyLOCAL = &IntervalDateExpr{Syntax: IntervalDateExprTimestampadd, Date: yyDollar[7].exprUnion(), Interval: yyDollar[5].exprUnion(), Unit: yyDollar[3].intervalTypeUnion()} } @@ -19149,7 +19152,7 @@ yydefault: case 1199: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6155 +//line sql.y:6157 { yyLOCAL = &TimestampDiffExpr{Unit: yyDollar[3].intervalTypeUnion(), Expr1: yyDollar[5].exprUnion(), Expr2: yyDollar[7].exprUnion()} } @@ -19157,7 +19160,7 @@ yydefault: case 1200: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6159 +//line sql.y:6161 { yyLOCAL = &ExtractFuncExpr{IntervalType: yyDollar[3].intervalTypeUnion(), Expr: yyDollar[5].exprUnion()} } @@ -19165,7 +19168,7 @@ yydefault: case 1201: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6163 +//line sql.y:6165 { yyLOCAL = &WeightStringFuncExpr{Expr: yyDollar[3].exprUnion(), As: yyDollar[4].convertTypeUnion()} } @@ -19173,7 +19176,7 @@ yydefault: case 1202: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6167 +//line sql.y:6169 { yyLOCAL = &JSONPrettyExpr{JSONVal: yyDollar[3].exprUnion()} } @@ -19181,7 +19184,7 @@ yydefault: case 1203: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6171 +//line sql.y:6173 { yyLOCAL = &JSONStorageFreeExpr{JSONVal: yyDollar[3].exprUnion()} } @@ -19189,7 +19192,7 @@ yydefault: case 1204: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6175 +//line sql.y:6177 { yyLOCAL = &JSONStorageSizeExpr{JSONVal: yyDollar[3].exprUnion()} } @@ -19197,7 +19200,7 @@ yydefault: case 1205: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6179 +//line sql.y:6181 { yyLOCAL = &JSONArrayAgg{Expr: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -19205,7 +19208,7 @@ yydefault: case 1206: yyDollar = yyS[yypt-7 : yypt+1] var yyLOCAL Expr -//line sql.y:6183 +//line sql.y:6185 { yyLOCAL = &JSONObjectAgg{Key: yyDollar[3].exprUnion(), Value: yyDollar[5].exprUnion(), OverClause: yyDollar[7].overClauseUnion()} } @@ -19213,7 +19216,7 @@ yydefault: case 1207: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6187 +//line sql.y:6189 { yyLOCAL = &TrimFuncExpr{TrimFuncType: LTrimType, Type: LeadingTrimType, StringArg: yyDollar[3].exprUnion()} } @@ -19221,7 +19224,7 @@ yydefault: case 1208: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6191 +//line sql.y:6193 { yyLOCAL = &TrimFuncExpr{TrimFuncType: RTrimType, Type: TrailingTrimType, StringArg: yyDollar[3].exprUnion()} } @@ -19229,7 +19232,7 @@ yydefault: case 1209: yyDollar = yyS[yypt-7 : yypt+1] var yyLOCAL Expr -//line sql.y:6195 +//line sql.y:6197 { yyLOCAL = &TrimFuncExpr{Type: yyDollar[3].trimTypeUnion(), TrimArg: yyDollar[4].exprUnion(), StringArg: yyDollar[6].exprUnion()} } @@ -19237,7 +19240,7 @@ yydefault: case 1210: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6199 +//line sql.y:6201 { yyLOCAL = &TrimFuncExpr{StringArg: yyDollar[3].exprUnion()} } @@ -19245,7 +19248,7 @@ yydefault: case 1211: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6203 +//line sql.y:6205 { yyLOCAL = &CharExpr{Exprs: yyDollar[3].exprsUnion()} } @@ -19253,7 +19256,7 @@ yydefault: case 1212: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6207 +//line sql.y:6209 { yyLOCAL = &CharExpr{Exprs: yyDollar[3].exprsUnion(), Charset: yyDollar[5].str} } @@ -19261,7 +19264,7 @@ yydefault: case 1213: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6211 +//line sql.y:6213 { yyLOCAL = &TrimFuncExpr{TrimArg: yyDollar[3].exprUnion(), StringArg: yyDollar[5].exprUnion()} } @@ -19269,7 +19272,7 @@ yydefault: case 1214: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6215 +//line sql.y:6217 { yyLOCAL = &LocateExpr{SubStr: yyDollar[3].exprUnion(), Str: yyDollar[5].exprUnion()} } @@ -19277,7 +19280,7 @@ yydefault: case 1215: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6219 +//line sql.y:6221 { yyLOCAL = &LocateExpr{SubStr: yyDollar[3].exprUnion(), Str: yyDollar[5].exprUnion(), Pos: yyDollar[7].exprUnion()} } @@ -19285,7 +19288,7 @@ yydefault: case 1216: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6223 +//line sql.y:6225 { yyLOCAL = &LocateExpr{SubStr: yyDollar[3].exprUnion(), Str: yyDollar[5].exprUnion()} } @@ -19293,7 +19296,7 @@ yydefault: case 1217: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6227 +//line sql.y:6229 { yyLOCAL = &LockingFunc{Type: GetLock, Name: yyDollar[3].exprUnion(), Timeout: yyDollar[5].exprUnion()} } @@ -19301,7 +19304,7 @@ yydefault: case 1218: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6231 +//line sql.y:6233 { yyLOCAL = &LockingFunc{Type: IsFreeLock, Name: yyDollar[3].exprUnion()} } @@ -19309,7 +19312,7 @@ yydefault: case 1219: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6235 +//line sql.y:6237 { yyLOCAL = &LockingFunc{Type: IsUsedLock, Name: yyDollar[3].exprUnion()} } @@ -19317,7 +19320,7 @@ yydefault: case 1220: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:6239 +//line sql.y:6241 { yyLOCAL = &LockingFunc{Type: ReleaseAllLocks} } @@ -19325,7 +19328,7 @@ yydefault: case 1221: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6243 +//line sql.y:6245 { yyLOCAL = &LockingFunc{Type: ReleaseLock, Name: yyDollar[3].exprUnion()} } @@ -19333,7 +19336,7 @@ yydefault: case 1222: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6247 +//line sql.y:6249 { yyLOCAL = &JSONSchemaValidFuncExpr{Schema: yyDollar[3].exprUnion(), Document: yyDollar[5].exprUnion()} } @@ -19341,7 +19344,7 @@ yydefault: case 1223: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6251 +//line sql.y:6253 { yyLOCAL = &JSONSchemaValidationReportFuncExpr{Schema: yyDollar[3].exprUnion(), Document: yyDollar[5].exprUnion()} } @@ -19349,7 +19352,7 @@ yydefault: case 1224: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6255 +//line sql.y:6257 { yyLOCAL = &JSONArrayExpr{Params: yyDollar[3].exprsUnion()} } @@ -19357,7 +19360,7 @@ yydefault: case 1225: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6259 +//line sql.y:6261 { yyLOCAL = &GeomFormatExpr{FormatType: BinaryFormat, Geom: yyDollar[3].exprUnion()} } @@ -19365,7 +19368,7 @@ yydefault: case 1226: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6263 +//line sql.y:6265 { yyLOCAL = &GeomFormatExpr{FormatType: BinaryFormat, Geom: yyDollar[3].exprUnion(), AxisOrderOpt: yyDollar[5].exprUnion()} } @@ -19373,7 +19376,7 @@ yydefault: case 1227: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6267 +//line sql.y:6269 { yyLOCAL = &GeomFormatExpr{FormatType: TextFormat, Geom: yyDollar[3].exprUnion()} } @@ -19381,7 +19384,7 @@ yydefault: case 1228: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6271 +//line sql.y:6273 { yyLOCAL = &GeomFormatExpr{FormatType: TextFormat, Geom: yyDollar[3].exprUnion(), AxisOrderOpt: yyDollar[5].exprUnion()} } @@ -19389,7 +19392,7 @@ yydefault: case 1229: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6275 +//line sql.y:6277 { yyLOCAL = &GeomPropertyFuncExpr{Property: IsEmpty, Geom: yyDollar[3].exprUnion()} } @@ -19397,7 +19400,7 @@ yydefault: case 1230: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6279 +//line sql.y:6281 { yyLOCAL = &GeomPropertyFuncExpr{Property: IsSimple, Geom: yyDollar[3].exprUnion()} } @@ -19405,7 +19408,7 @@ yydefault: case 1231: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6283 +//line sql.y:6285 { yyLOCAL = &GeomPropertyFuncExpr{Property: Dimension, Geom: yyDollar[3].exprUnion()} } @@ -19413,7 +19416,7 @@ yydefault: case 1232: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6287 +//line sql.y:6289 { yyLOCAL = &GeomPropertyFuncExpr{Property: Envelope, Geom: yyDollar[3].exprUnion()} } @@ -19421,7 +19424,7 @@ yydefault: case 1233: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6291 +//line sql.y:6293 { yyLOCAL = &GeomPropertyFuncExpr{Property: GeometryType, Geom: yyDollar[3].exprUnion()} } @@ -19429,7 +19432,7 @@ yydefault: case 1234: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6295 +//line sql.y:6297 { yyLOCAL = &PointPropertyFuncExpr{Property: Latitude, Point: yyDollar[3].exprUnion()} } @@ -19437,7 +19440,7 @@ yydefault: case 1235: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6299 +//line sql.y:6301 { yyLOCAL = &PointPropertyFuncExpr{Property: Latitude, Point: yyDollar[3].exprUnion(), ValueToSet: yyDollar[5].exprUnion()} } @@ -19445,7 +19448,7 @@ yydefault: case 1236: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6303 +//line sql.y:6305 { yyLOCAL = &PointPropertyFuncExpr{Property: Longitude, Point: yyDollar[3].exprUnion()} } @@ -19453,7 +19456,7 @@ yydefault: case 1237: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6307 +//line sql.y:6309 { yyLOCAL = &PointPropertyFuncExpr{Property: Longitude, Point: yyDollar[3].exprUnion(), ValueToSet: yyDollar[5].exprUnion()} } @@ -19461,7 +19464,7 @@ yydefault: case 1238: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6311 +//line sql.y:6313 { yyLOCAL = &LinestrPropertyFuncExpr{Property: EndPoint, Linestring: yyDollar[3].exprUnion()} } @@ -19469,7 +19472,7 @@ yydefault: case 1239: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6315 +//line sql.y:6317 { yyLOCAL = &LinestrPropertyFuncExpr{Property: IsClosed, Linestring: yyDollar[3].exprUnion()} } @@ -19477,7 +19480,7 @@ yydefault: case 1240: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6319 +//line sql.y:6321 { yyLOCAL = &LinestrPropertyFuncExpr{Property: Length, Linestring: yyDollar[3].exprUnion()} } @@ -19485,7 +19488,7 @@ yydefault: case 1241: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6323 +//line sql.y:6325 { yyLOCAL = &LinestrPropertyFuncExpr{Property: Length, Linestring: yyDollar[3].exprUnion(), PropertyDefArg: yyDollar[5].exprUnion()} } @@ -19493,7 +19496,7 @@ yydefault: case 1242: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6327 +//line sql.y:6329 { yyLOCAL = &LinestrPropertyFuncExpr{Property: NumPoints, Linestring: yyDollar[3].exprUnion()} } @@ -19501,7 +19504,7 @@ yydefault: case 1243: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6331 +//line sql.y:6333 { yyLOCAL = &LinestrPropertyFuncExpr{Property: PointN, Linestring: yyDollar[3].exprUnion(), PropertyDefArg: yyDollar[5].exprUnion()} } @@ -19509,7 +19512,7 @@ yydefault: case 1244: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6335 +//line sql.y:6337 { yyLOCAL = &LinestrPropertyFuncExpr{Property: StartPoint, Linestring: yyDollar[3].exprUnion()} } @@ -19517,7 +19520,7 @@ yydefault: case 1245: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6339 +//line sql.y:6341 { yyLOCAL = &PointPropertyFuncExpr{Property: XCordinate, Point: yyDollar[3].exprUnion()} } @@ -19525,7 +19528,7 @@ yydefault: case 1246: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6343 +//line sql.y:6345 { yyLOCAL = &PointPropertyFuncExpr{Property: XCordinate, Point: yyDollar[3].exprUnion(), ValueToSet: yyDollar[5].exprUnion()} } @@ -19533,7 +19536,7 @@ yydefault: case 1247: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6347 +//line sql.y:6349 { yyLOCAL = &PointPropertyFuncExpr{Property: YCordinate, Point: yyDollar[3].exprUnion()} } @@ -19541,7 +19544,7 @@ yydefault: case 1248: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6351 +//line sql.y:6353 { yyLOCAL = &PointPropertyFuncExpr{Property: YCordinate, Point: yyDollar[3].exprUnion(), ValueToSet: yyDollar[5].exprUnion()} } @@ -19549,7 +19552,7 @@ yydefault: case 1249: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6355 +//line sql.y:6357 { yyLOCAL = &GeomFromTextExpr{Type: GeometryFromText, WktText: yyDollar[3].exprUnion()} } @@ -19557,7 +19560,7 @@ yydefault: case 1250: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6359 +//line sql.y:6361 { yyLOCAL = &GeomFromTextExpr{Type: GeometryFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19565,7 +19568,7 @@ yydefault: case 1251: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6363 +//line sql.y:6365 { yyLOCAL = &GeomFromTextExpr{Type: GeometryFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19573,7 +19576,7 @@ yydefault: case 1252: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6367 +//line sql.y:6369 { yyLOCAL = &GeomFromTextExpr{Type: GeometryCollectionFromText, WktText: yyDollar[3].exprUnion()} } @@ -19581,7 +19584,7 @@ yydefault: case 1253: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6371 +//line sql.y:6373 { yyLOCAL = &GeomFromTextExpr{Type: GeometryCollectionFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19589,7 +19592,7 @@ yydefault: case 1254: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6375 +//line sql.y:6377 { yyLOCAL = &GeomFromTextExpr{Type: GeometryCollectionFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19597,7 +19600,7 @@ yydefault: case 1255: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6379 +//line sql.y:6381 { yyLOCAL = &GeomFromTextExpr{Type: LineStringFromText, WktText: yyDollar[3].exprUnion()} } @@ -19605,7 +19608,7 @@ yydefault: case 1256: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6383 +//line sql.y:6385 { yyLOCAL = &GeomFromTextExpr{Type: LineStringFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19613,7 +19616,7 @@ yydefault: case 1257: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6387 +//line sql.y:6389 { yyLOCAL = &GeomFromTextExpr{Type: LineStringFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19621,7 +19624,7 @@ yydefault: case 1258: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6391 +//line sql.y:6393 { yyLOCAL = &GeomFromTextExpr{Type: MultiLinestringFromText, WktText: yyDollar[3].exprUnion()} } @@ -19629,7 +19632,7 @@ yydefault: case 1259: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6395 +//line sql.y:6397 { yyLOCAL = &GeomFromTextExpr{Type: MultiLinestringFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19637,7 +19640,7 @@ yydefault: case 1260: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6399 +//line sql.y:6401 { yyLOCAL = &GeomFromTextExpr{Type: MultiLinestringFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19645,7 +19648,7 @@ yydefault: case 1261: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6403 +//line sql.y:6405 { yyLOCAL = &GeomFromTextExpr{Type: MultiPointFromText, WktText: yyDollar[3].exprUnion()} } @@ -19653,7 +19656,7 @@ yydefault: case 1262: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6407 +//line sql.y:6409 { yyLOCAL = &GeomFromTextExpr{Type: MultiPointFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19661,7 +19664,7 @@ yydefault: case 1263: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6411 +//line sql.y:6413 { yyLOCAL = &GeomFromTextExpr{Type: MultiPointFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19669,7 +19672,7 @@ yydefault: case 1264: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6415 +//line sql.y:6417 { yyLOCAL = &GeomFromTextExpr{Type: MultiPolygonFromText, WktText: yyDollar[3].exprUnion()} } @@ -19677,7 +19680,7 @@ yydefault: case 1265: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6419 +//line sql.y:6421 { yyLOCAL = &GeomFromTextExpr{Type: MultiPolygonFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19685,7 +19688,7 @@ yydefault: case 1266: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6423 +//line sql.y:6425 { yyLOCAL = &GeomFromTextExpr{Type: MultiPolygonFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19693,7 +19696,7 @@ yydefault: case 1267: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6427 +//line sql.y:6429 { yyLOCAL = &GeomFromTextExpr{Type: PointFromText, WktText: yyDollar[3].exprUnion()} } @@ -19701,7 +19704,7 @@ yydefault: case 1268: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6431 +//line sql.y:6433 { yyLOCAL = &GeomFromTextExpr{Type: PointFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19709,7 +19712,7 @@ yydefault: case 1269: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6435 +//line sql.y:6437 { yyLOCAL = &GeomFromTextExpr{Type: PointFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19717,7 +19720,7 @@ yydefault: case 1270: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6439 +//line sql.y:6441 { yyLOCAL = &GeomFromTextExpr{Type: PolygonFromText, WktText: yyDollar[3].exprUnion()} } @@ -19725,7 +19728,7 @@ yydefault: case 1271: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6443 +//line sql.y:6445 { yyLOCAL = &GeomFromTextExpr{Type: PolygonFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19733,7 +19736,7 @@ yydefault: case 1272: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6447 +//line sql.y:6449 { yyLOCAL = &GeomFromTextExpr{Type: PolygonFromText, WktText: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19741,7 +19744,7 @@ yydefault: case 1273: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6451 +//line sql.y:6453 { yyLOCAL = &GeomFromWKBExpr{Type: GeometryFromWKB, WkbBlob: yyDollar[3].exprUnion()} } @@ -19749,7 +19752,7 @@ yydefault: case 1274: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6455 +//line sql.y:6457 { yyLOCAL = &GeomFromWKBExpr{Type: GeometryFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19757,7 +19760,7 @@ yydefault: case 1275: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6459 +//line sql.y:6461 { yyLOCAL = &GeomFromWKBExpr{Type: GeometryFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19765,7 +19768,7 @@ yydefault: case 1276: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6463 +//line sql.y:6465 { yyLOCAL = &GeomFromWKBExpr{Type: GeometryCollectionFromWKB, WkbBlob: yyDollar[3].exprUnion()} } @@ -19773,7 +19776,7 @@ yydefault: case 1277: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6467 +//line sql.y:6469 { yyLOCAL = &GeomFromWKBExpr{Type: GeometryCollectionFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19781,7 +19784,7 @@ yydefault: case 1278: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6471 +//line sql.y:6473 { yyLOCAL = &GeomFromWKBExpr{Type: GeometryCollectionFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19789,7 +19792,7 @@ yydefault: case 1279: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6475 +//line sql.y:6477 { yyLOCAL = &GeomFromWKBExpr{Type: LineStringFromWKB, WkbBlob: yyDollar[3].exprUnion()} } @@ -19797,7 +19800,7 @@ yydefault: case 1280: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6479 +//line sql.y:6481 { yyLOCAL = &GeomFromWKBExpr{Type: LineStringFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19805,7 +19808,7 @@ yydefault: case 1281: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6483 +//line sql.y:6485 { yyLOCAL = &GeomFromWKBExpr{Type: LineStringFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19813,7 +19816,7 @@ yydefault: case 1282: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6487 +//line sql.y:6489 { yyLOCAL = &GeomFromWKBExpr{Type: MultiLinestringFromWKB, WkbBlob: yyDollar[3].exprUnion()} } @@ -19821,7 +19824,7 @@ yydefault: case 1283: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6491 +//line sql.y:6493 { yyLOCAL = &GeomFromWKBExpr{Type: MultiLinestringFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19829,7 +19832,7 @@ yydefault: case 1284: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6495 +//line sql.y:6497 { yyLOCAL = &GeomFromWKBExpr{Type: MultiLinestringFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19837,7 +19840,7 @@ yydefault: case 1285: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6499 +//line sql.y:6501 { yyLOCAL = &GeomFromWKBExpr{Type: MultiPointFromWKB, WkbBlob: yyDollar[3].exprUnion()} } @@ -19845,7 +19848,7 @@ yydefault: case 1286: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6503 +//line sql.y:6505 { yyLOCAL = &GeomFromWKBExpr{Type: MultiPointFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19853,7 +19856,7 @@ yydefault: case 1287: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6507 +//line sql.y:6509 { yyLOCAL = &GeomFromWKBExpr{Type: MultiPointFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19861,7 +19864,7 @@ yydefault: case 1288: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6511 +//line sql.y:6513 { yyLOCAL = &GeomFromWKBExpr{Type: MultiPolygonFromWKB, WkbBlob: yyDollar[3].exprUnion()} } @@ -19869,7 +19872,7 @@ yydefault: case 1289: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6515 +//line sql.y:6517 { yyLOCAL = &GeomFromWKBExpr{Type: MultiPolygonFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19877,7 +19880,7 @@ yydefault: case 1290: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6519 +//line sql.y:6521 { yyLOCAL = &GeomFromWKBExpr{Type: MultiPolygonFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19885,7 +19888,7 @@ yydefault: case 1291: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6523 +//line sql.y:6525 { yyLOCAL = &GeomFromWKBExpr{Type: PointFromWKB, WkbBlob: yyDollar[3].exprUnion()} } @@ -19893,7 +19896,7 @@ yydefault: case 1292: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6527 +//line sql.y:6529 { yyLOCAL = &GeomFromWKBExpr{Type: PointFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19901,7 +19904,7 @@ yydefault: case 1293: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6531 +//line sql.y:6533 { yyLOCAL = &GeomFromWKBExpr{Type: PointFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19909,7 +19912,7 @@ yydefault: case 1294: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6535 +//line sql.y:6537 { yyLOCAL = &GeomFromWKBExpr{Type: PolygonFromWKB, WkbBlob: yyDollar[3].exprUnion()} } @@ -19917,7 +19920,7 @@ yydefault: case 1295: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6539 +//line sql.y:6541 { yyLOCAL = &GeomFromWKBExpr{Type: PolygonFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion()} } @@ -19925,7 +19928,7 @@ yydefault: case 1296: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6543 +//line sql.y:6545 { yyLOCAL = &GeomFromWKBExpr{Type: PolygonFromWKB, WkbBlob: yyDollar[3].exprUnion(), Srid: yyDollar[5].exprUnion(), AxisOrderOpt: yyDollar[7].exprUnion()} } @@ -19933,7 +19936,7 @@ yydefault: case 1297: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6547 +//line sql.y:6549 { yyLOCAL = &PolygonPropertyFuncExpr{Property: Area, Polygon: yyDollar[3].exprUnion()} } @@ -19941,7 +19944,7 @@ yydefault: case 1298: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6551 +//line sql.y:6553 { yyLOCAL = &PolygonPropertyFuncExpr{Property: Centroid, Polygon: yyDollar[3].exprUnion()} } @@ -19949,7 +19952,7 @@ yydefault: case 1299: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6555 +//line sql.y:6557 { yyLOCAL = &PolygonPropertyFuncExpr{Property: ExteriorRing, Polygon: yyDollar[3].exprUnion()} } @@ -19957,7 +19960,7 @@ yydefault: case 1300: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6559 +//line sql.y:6561 { yyLOCAL = &PolygonPropertyFuncExpr{Property: InteriorRingN, Polygon: yyDollar[3].exprUnion(), PropertyDefArg: yyDollar[5].exprUnion()} } @@ -19965,7 +19968,7 @@ yydefault: case 1301: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6563 +//line sql.y:6565 { yyLOCAL = &PolygonPropertyFuncExpr{Property: NumInteriorRings, Polygon: yyDollar[3].exprUnion()} } @@ -19973,7 +19976,7 @@ yydefault: case 1302: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6567 +//line sql.y:6569 { yyLOCAL = &GeomCollPropertyFuncExpr{Property: GeometryN, GeomColl: yyDollar[3].exprUnion(), PropertyDefArg: yyDollar[5].exprUnion()} } @@ -19981,7 +19984,7 @@ yydefault: case 1303: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6571 +//line sql.y:6573 { yyLOCAL = &GeomCollPropertyFuncExpr{Property: NumGeometries, GeomColl: yyDollar[3].exprUnion()} } @@ -19989,7 +19992,7 @@ yydefault: case 1304: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6575 +//line sql.y:6577 { yyLOCAL = &GeoHashFromLatLongExpr{Longitude: yyDollar[3].exprUnion(), Latitude: yyDollar[5].exprUnion(), MaxLength: yyDollar[7].exprUnion()} } @@ -19997,7 +20000,7 @@ yydefault: case 1305: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6579 +//line sql.y:6581 { yyLOCAL = &GeoHashFromPointExpr{Point: yyDollar[3].exprUnion(), MaxLength: yyDollar[5].exprUnion()} } @@ -20005,7 +20008,7 @@ yydefault: case 1306: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6583 +//line sql.y:6585 { yyLOCAL = &GeomFromGeoHashExpr{GeomType: LatitudeFromHash, GeoHash: yyDollar[3].exprUnion()} } @@ -20013,7 +20016,7 @@ yydefault: case 1307: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6587 +//line sql.y:6589 { yyLOCAL = &GeomFromGeoHashExpr{GeomType: LongitudeFromHash, GeoHash: yyDollar[3].exprUnion()} } @@ -20021,7 +20024,7 @@ yydefault: case 1308: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6591 +//line sql.y:6593 { yyLOCAL = &GeomFromGeoHashExpr{GeomType: PointFromHash, GeoHash: yyDollar[3].exprUnion(), SridOpt: yyDollar[5].exprUnion()} } @@ -20029,7 +20032,7 @@ yydefault: case 1309: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6595 +//line sql.y:6597 { yyLOCAL = &GeomFromGeoJSONExpr{GeoJSON: yyDollar[3].exprUnion()} } @@ -20037,7 +20040,7 @@ yydefault: case 1310: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6599 +//line sql.y:6601 { yyLOCAL = &GeomFromGeoJSONExpr{GeoJSON: yyDollar[3].exprUnion(), HigherDimHandlerOpt: yyDollar[5].exprUnion()} } @@ -20045,7 +20048,7 @@ yydefault: case 1311: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6603 +//line sql.y:6605 { yyLOCAL = &GeomFromGeoJSONExpr{GeoJSON: yyDollar[3].exprUnion(), HigherDimHandlerOpt: yyDollar[5].exprUnion(), Srid: yyDollar[7].exprUnion()} } @@ -20053,7 +20056,7 @@ yydefault: case 1312: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6607 +//line sql.y:6609 { yyLOCAL = &GeoJSONFromGeomExpr{Geom: yyDollar[3].exprUnion()} } @@ -20061,7 +20064,7 @@ yydefault: case 1313: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6611 +//line sql.y:6613 { yyLOCAL = &GeoJSONFromGeomExpr{Geom: yyDollar[3].exprUnion(), MaxDecimalDigits: yyDollar[5].exprUnion()} } @@ -20069,7 +20072,7 @@ yydefault: case 1314: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6615 +//line sql.y:6617 { yyLOCAL = &GeoJSONFromGeomExpr{Geom: yyDollar[3].exprUnion(), MaxDecimalDigits: yyDollar[5].exprUnion(), Bitmask: yyDollar[7].exprUnion()} } @@ -20077,7 +20080,7 @@ yydefault: case 1315: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6619 +//line sql.y:6621 { yyLOCAL = &JSONObjectExpr{Params: yyDollar[3].jsonObjectParamsUnion()} } @@ -20085,7 +20088,7 @@ yydefault: case 1316: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6623 +//line sql.y:6625 { yyLOCAL = &JSONQuoteExpr{StringArg: yyDollar[3].exprUnion()} } @@ -20093,7 +20096,7 @@ yydefault: case 1317: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6627 +//line sql.y:6629 { yyLOCAL = &JSONContainsExpr{Target: yyDollar[3].exprUnion(), Candidate: yyDollar[5].exprsUnion()[0], PathList: yyDollar[5].exprsUnion()[1:]} } @@ -20101,7 +20104,7 @@ yydefault: case 1318: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6631 +//line sql.y:6633 { yyLOCAL = &JSONContainsPathExpr{JSONDoc: yyDollar[3].exprUnion(), OneOrAll: yyDollar[5].exprUnion(), PathList: yyDollar[7].exprsUnion()} } @@ -20109,7 +20112,7 @@ yydefault: case 1319: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6635 +//line sql.y:6637 { yyLOCAL = &JSONExtractExpr{JSONDoc: yyDollar[3].exprUnion(), PathList: yyDollar[5].exprsUnion()} } @@ -20117,7 +20120,7 @@ yydefault: case 1320: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6639 +//line sql.y:6641 { yyLOCAL = &JSONKeysExpr{JSONDoc: yyDollar[3].exprUnion()} } @@ -20125,7 +20128,7 @@ yydefault: case 1321: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6643 +//line sql.y:6645 { yyLOCAL = &JSONKeysExpr{JSONDoc: yyDollar[3].exprUnion(), Path: yyDollar[5].exprUnion()} } @@ -20133,7 +20136,7 @@ yydefault: case 1322: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6647 +//line sql.y:6649 { yyLOCAL = &JSONOverlapsExpr{JSONDoc1: yyDollar[3].exprUnion(), JSONDoc2: yyDollar[5].exprUnion()} } @@ -20141,7 +20144,7 @@ yydefault: case 1323: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6651 +//line sql.y:6653 { yyLOCAL = &JSONSearchExpr{JSONDoc: yyDollar[3].exprUnion(), OneOrAll: yyDollar[5].exprUnion(), SearchStr: yyDollar[7].exprUnion()} } @@ -20149,7 +20152,7 @@ yydefault: case 1324: yyDollar = yyS[yypt-10 : yypt+1] var yyLOCAL Expr -//line sql.y:6655 +//line sql.y:6657 { yyLOCAL = &JSONSearchExpr{JSONDoc: yyDollar[3].exprUnion(), OneOrAll: yyDollar[5].exprUnion(), SearchStr: yyDollar[7].exprUnion(), EscapeChar: yyDollar[9].exprsUnion()[0], PathList: yyDollar[9].exprsUnion()[1:]} } @@ -20157,7 +20160,7 @@ yydefault: case 1325: yyDollar = yyS[yypt-7 : yypt+1] var yyLOCAL Expr -//line sql.y:6659 +//line sql.y:6661 { yyLOCAL = &JSONValueExpr{JSONDoc: yyDollar[3].exprUnion(), Path: yyDollar[5].exprUnion(), ReturningType: yyDollar[6].convertTypeUnion()} } @@ -20165,7 +20168,7 @@ yydefault: case 1326: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6663 +//line sql.y:6665 { yyLOCAL = &JSONValueExpr{JSONDoc: yyDollar[3].exprUnion(), Path: yyDollar[5].exprUnion(), ReturningType: yyDollar[6].convertTypeUnion(), EmptyOnResponse: yyDollar[7].jtOnResponseUnion()} } @@ -20173,7 +20176,7 @@ yydefault: case 1327: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6667 +//line sql.y:6669 { yyLOCAL = &JSONValueExpr{JSONDoc: yyDollar[3].exprUnion(), Path: yyDollar[5].exprUnion(), ReturningType: yyDollar[6].convertTypeUnion(), ErrorOnResponse: yyDollar[7].jtOnResponseUnion()} } @@ -20181,7 +20184,7 @@ yydefault: case 1328: yyDollar = yyS[yypt-9 : yypt+1] var yyLOCAL Expr -//line sql.y:6671 +//line sql.y:6673 { yyLOCAL = &JSONValueExpr{JSONDoc: yyDollar[3].exprUnion(), Path: yyDollar[5].exprUnion(), ReturningType: yyDollar[6].convertTypeUnion(), EmptyOnResponse: yyDollar[7].jtOnResponseUnion(), ErrorOnResponse: yyDollar[8].jtOnResponseUnion()} } @@ -20189,7 +20192,7 @@ yydefault: case 1329: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6675 +//line sql.y:6677 { yyLOCAL = &JSONAttributesExpr{Type: DepthAttributeType, JSONDoc: yyDollar[3].exprUnion()} } @@ -20197,7 +20200,7 @@ yydefault: case 1330: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6679 +//line sql.y:6681 { yyLOCAL = &JSONAttributesExpr{Type: ValidAttributeType, JSONDoc: yyDollar[3].exprUnion()} } @@ -20205,7 +20208,7 @@ yydefault: case 1331: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6683 +//line sql.y:6685 { yyLOCAL = &JSONAttributesExpr{Type: TypeAttributeType, JSONDoc: yyDollar[3].exprUnion()} } @@ -20213,7 +20216,7 @@ yydefault: case 1332: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6687 +//line sql.y:6689 { yyLOCAL = &JSONAttributesExpr{Type: LengthAttributeType, JSONDoc: yyDollar[3].exprUnion()} } @@ -20221,7 +20224,7 @@ yydefault: case 1333: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6691 +//line sql.y:6693 { yyLOCAL = &JSONAttributesExpr{Type: LengthAttributeType, JSONDoc: yyDollar[3].exprUnion(), Path: yyDollar[5].exprUnion()} } @@ -20229,7 +20232,7 @@ yydefault: case 1334: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6695 +//line sql.y:6697 { yyLOCAL = &JSONValueModifierExpr{Type: JSONArrayAppendType, JSONDoc: yyDollar[3].exprUnion(), Params: yyDollar[5].jsonObjectParamsUnion()} } @@ -20237,7 +20240,7 @@ yydefault: case 1335: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6699 +//line sql.y:6701 { yyLOCAL = &JSONValueModifierExpr{Type: JSONArrayInsertType, JSONDoc: yyDollar[3].exprUnion(), Params: yyDollar[5].jsonObjectParamsUnion()} } @@ -20245,7 +20248,7 @@ yydefault: case 1336: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6703 +//line sql.y:6705 { yyLOCAL = &JSONValueModifierExpr{Type: JSONInsertType, JSONDoc: yyDollar[3].exprUnion(), Params: yyDollar[5].jsonObjectParamsUnion()} } @@ -20253,7 +20256,7 @@ yydefault: case 1337: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6707 +//line sql.y:6709 { yyLOCAL = &JSONValueModifierExpr{Type: JSONReplaceType, JSONDoc: yyDollar[3].exprUnion(), Params: yyDollar[5].jsonObjectParamsUnion()} } @@ -20261,7 +20264,7 @@ yydefault: case 1338: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6711 +//line sql.y:6713 { yyLOCAL = &JSONValueModifierExpr{Type: JSONSetType, JSONDoc: yyDollar[3].exprUnion(), Params: yyDollar[5].jsonObjectParamsUnion()} } @@ -20269,7 +20272,7 @@ yydefault: case 1339: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6715 +//line sql.y:6717 { yyLOCAL = &JSONValueMergeExpr{Type: JSONMergeType, JSONDoc: yyDollar[3].exprUnion(), JSONDocList: yyDollar[5].exprsUnion()} } @@ -20277,7 +20280,7 @@ yydefault: case 1340: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6719 +//line sql.y:6721 { yyLOCAL = &JSONValueMergeExpr{Type: JSONMergePatchType, JSONDoc: yyDollar[3].exprUnion(), JSONDocList: yyDollar[5].exprsUnion()} } @@ -20285,7 +20288,7 @@ yydefault: case 1341: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6723 +//line sql.y:6725 { yyLOCAL = &JSONValueMergeExpr{Type: JSONMergePreserveType, JSONDoc: yyDollar[3].exprUnion(), JSONDocList: yyDollar[5].exprsUnion()} } @@ -20293,7 +20296,7 @@ yydefault: case 1342: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6727 +//line sql.y:6729 { yyLOCAL = &JSONRemoveExpr{JSONDoc: yyDollar[3].exprUnion(), PathList: yyDollar[5].exprsUnion()} } @@ -20301,7 +20304,7 @@ yydefault: case 1343: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6731 +//line sql.y:6733 { yyLOCAL = &JSONUnquoteExpr{JSONValue: yyDollar[3].exprUnion()} } @@ -20309,7 +20312,7 @@ yydefault: case 1344: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6735 +//line sql.y:6737 { yyLOCAL = &MultiPolygonExpr{PolygonParams: yyDollar[3].exprsUnion()} } @@ -20317,7 +20320,7 @@ yydefault: case 1345: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6739 +//line sql.y:6741 { yyLOCAL = &MultiPointExpr{PointParams: yyDollar[3].exprsUnion()} } @@ -20325,7 +20328,7 @@ yydefault: case 1346: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6743 +//line sql.y:6745 { yyLOCAL = &MultiLinestringExpr{LinestringParams: yyDollar[3].exprsUnion()} } @@ -20333,7 +20336,7 @@ yydefault: case 1347: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6747 +//line sql.y:6749 { yyLOCAL = &PolygonExpr{LinestringParams: yyDollar[3].exprsUnion()} } @@ -20341,7 +20344,7 @@ yydefault: case 1348: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6751 +//line sql.y:6753 { yyLOCAL = &LineStringExpr{PointParams: yyDollar[3].exprsUnion()} } @@ -20349,7 +20352,7 @@ yydefault: case 1349: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6755 +//line sql.y:6757 { yyLOCAL = &PointExpr{XCordinate: yyDollar[3].exprUnion(), YCordinate: yyDollar[5].exprUnion()} } @@ -20357,7 +20360,7 @@ yydefault: case 1350: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6759 +//line sql.y:6761 { yyLOCAL = &ArgumentLessWindowExpr{Type: yyDollar[1].argumentLessWindowExprTypeUnion(), OverClause: yyDollar[4].overClauseUnion()} } @@ -20365,7 +20368,7 @@ yydefault: case 1351: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6763 +//line sql.y:6765 { yyLOCAL = &FirstOrLastValueExpr{Type: yyDollar[1].firstOrLastValueExprTypeUnion(), Expr: yyDollar[3].exprUnion(), NullTreatmentClause: yyDollar[5].nullTreatmentClauseUnion(), OverClause: yyDollar[6].overClauseUnion()} } @@ -20373,7 +20376,7 @@ yydefault: case 1352: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Expr -//line sql.y:6767 +//line sql.y:6769 { yyLOCAL = &NtileExpr{N: yyDollar[3].exprUnion(), OverClause: yyDollar[5].overClauseUnion()} } @@ -20381,7 +20384,7 @@ yydefault: case 1353: yyDollar = yyS[yypt-9 : yypt+1] var yyLOCAL Expr -//line sql.y:6771 +//line sql.y:6773 { yyLOCAL = &NTHValueExpr{Expr: yyDollar[3].exprUnion(), N: yyDollar[5].exprUnion(), FromFirstLastClause: yyDollar[7].fromFirstLastClauseUnion(), NullTreatmentClause: yyDollar[8].nullTreatmentClauseUnion(), OverClause: yyDollar[9].overClauseUnion()} } @@ -20389,7 +20392,7 @@ yydefault: case 1354: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6775 +//line sql.y:6777 { yyLOCAL = &LagLeadExpr{Type: yyDollar[1].lagLeadExprTypeUnion(), Expr: yyDollar[3].exprUnion(), NullTreatmentClause: yyDollar[5].nullTreatmentClauseUnion(), OverClause: yyDollar[6].overClauseUnion()} } @@ -20397,7 +20400,7 @@ yydefault: case 1355: yyDollar = yyS[yypt-9 : yypt+1] var yyLOCAL Expr -//line sql.y:6779 +//line sql.y:6781 { yyLOCAL = &LagLeadExpr{Type: yyDollar[1].lagLeadExprTypeUnion(), Expr: yyDollar[3].exprUnion(), N: yyDollar[5].exprUnion(), Default: yyDollar[6].exprUnion(), NullTreatmentClause: yyDollar[8].nullTreatmentClauseUnion(), OverClause: yyDollar[9].overClauseUnion()} } @@ -20405,7 +20408,7 @@ yydefault: case 1356: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6783 +//line sql.y:6785 { yyLOCAL = &IntervalDateExpr{Syntax: IntervalDateExprAdddate, Date: yyDollar[3].exprUnion(), Interval: yyDollar[6].exprUnion(), Unit: yyDollar[7].intervalTypeUnion()} } @@ -20413,7 +20416,7 @@ yydefault: case 1357: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6787 +//line sql.y:6789 { yyLOCAL = &IntervalDateExpr{Syntax: IntervalDateExprAdddate, Date: yyDollar[3].exprUnion(), Interval: yyDollar[5].exprUnion(), Unit: IntervalNone} } @@ -20421,7 +20424,7 @@ yydefault: case 1358: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6791 +//line sql.y:6793 { yyLOCAL = &IntervalDateExpr{Syntax: IntervalDateExprDateAdd, Date: yyDollar[3].exprUnion(), Interval: yyDollar[6].exprUnion(), Unit: yyDollar[7].intervalTypeUnion()} } @@ -20429,7 +20432,7 @@ yydefault: case 1359: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6795 +//line sql.y:6797 { yyLOCAL = &IntervalDateExpr{Syntax: IntervalDateExprDateSub, Date: yyDollar[3].exprUnion(), Interval: yyDollar[6].exprUnion(), Unit: yyDollar[7].intervalTypeUnion()} } @@ -20437,7 +20440,7 @@ yydefault: case 1360: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6799 +//line sql.y:6801 { yyLOCAL = &IntervalDateExpr{Syntax: IntervalDateExprSubdate, Date: yyDollar[3].exprUnion(), Interval: yyDollar[6].exprUnion(), Unit: yyDollar[7].intervalTypeUnion()} } @@ -20445,7 +20448,7 @@ yydefault: case 1361: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6803 +//line sql.y:6805 { yyLOCAL = &IntervalDateExpr{Syntax: IntervalDateExprSubdate, Date: yyDollar[3].exprUnion(), Interval: yyDollar[5].exprUnion(), Unit: IntervalNone} } @@ -20453,7 +20456,7 @@ yydefault: case 1366: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:6813 +//line sql.y:6815 { yyLOCAL = yyDollar[1].exprUnion() } @@ -20461,7 +20464,7 @@ yydefault: case 1367: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:6817 +//line sql.y:6819 { yyLOCAL = NewIntLiteral(yyDollar[1].str) } @@ -20469,7 +20472,7 @@ yydefault: case 1368: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:6821 +//line sql.y:6823 { yyLOCAL = yyDollar[1].variableUnion() } @@ -20477,7 +20480,7 @@ yydefault: case 1369: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:6825 +//line sql.y:6827 { yyLOCAL = parseBindVariable(yylex, yyDollar[1].str[1:]) } @@ -20485,7 +20488,7 @@ yydefault: case 1370: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL Expr -//line sql.y:6830 +//line sql.y:6832 { yyLOCAL = nil } @@ -20493,7 +20496,7 @@ yydefault: case 1371: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:6834 +//line sql.y:6836 { yyLOCAL = yyDollar[2].exprUnion() } @@ -20501,7 +20504,7 @@ yydefault: case 1372: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6840 +//line sql.y:6842 { yyLOCAL = &RegexpInstrExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion()} } @@ -20509,7 +20512,7 @@ yydefault: case 1373: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6844 +//line sql.y:6846 { yyLOCAL = &RegexpInstrExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Position: yyDollar[7].exprUnion()} } @@ -20517,7 +20520,7 @@ yydefault: case 1374: yyDollar = yyS[yypt-10 : yypt+1] var yyLOCAL Expr -//line sql.y:6848 +//line sql.y:6850 { yyLOCAL = &RegexpInstrExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Position: yyDollar[7].exprUnion(), Occurrence: yyDollar[9].exprUnion()} } @@ -20525,7 +20528,7 @@ yydefault: case 1375: yyDollar = yyS[yypt-12 : yypt+1] var yyLOCAL Expr -//line sql.y:6852 +//line sql.y:6854 { yyLOCAL = &RegexpInstrExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Position: yyDollar[7].exprUnion(), Occurrence: yyDollar[9].exprUnion(), ReturnOption: yyDollar[11].exprUnion()} } @@ -20533,7 +20536,7 @@ yydefault: case 1376: yyDollar = yyS[yypt-14 : yypt+1] var yyLOCAL Expr -//line sql.y:6856 +//line sql.y:6858 { // Match type is kept expression as TRIM( ' m ') is accepted yyLOCAL = &RegexpInstrExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Position: yyDollar[7].exprUnion(), Occurrence: yyDollar[9].exprUnion(), ReturnOption: yyDollar[11].exprUnion(), MatchType: yyDollar[13].exprUnion()} @@ -20542,7 +20545,7 @@ yydefault: case 1377: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6861 +//line sql.y:6863 { yyLOCAL = &RegexpLikeExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion()} } @@ -20550,7 +20553,7 @@ yydefault: case 1378: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6865 +//line sql.y:6867 { yyLOCAL = &RegexpLikeExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), MatchType: yyDollar[7].exprUnion()} } @@ -20558,7 +20561,7 @@ yydefault: case 1379: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6869 +//line sql.y:6871 { yyLOCAL = &RegexpReplaceExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Repl: yyDollar[7].exprUnion()} } @@ -20566,7 +20569,7 @@ yydefault: case 1380: yyDollar = yyS[yypt-10 : yypt+1] var yyLOCAL Expr -//line sql.y:6873 +//line sql.y:6875 { yyLOCAL = &RegexpReplaceExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Repl: yyDollar[7].exprUnion(), Position: yyDollar[9].exprUnion()} } @@ -20574,7 +20577,7 @@ yydefault: case 1381: yyDollar = yyS[yypt-12 : yypt+1] var yyLOCAL Expr -//line sql.y:6877 +//line sql.y:6879 { yyLOCAL = &RegexpReplaceExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Repl: yyDollar[7].exprUnion(), Position: yyDollar[9].exprUnion(), Occurrence: yyDollar[11].exprUnion()} } @@ -20582,7 +20585,7 @@ yydefault: case 1382: yyDollar = yyS[yypt-14 : yypt+1] var yyLOCAL Expr -//line sql.y:6881 +//line sql.y:6883 { // Match type is kept expression as TRIM( ' m ') is accepted yyLOCAL = &RegexpReplaceExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Repl: yyDollar[7].exprUnion(), Position: yyDollar[9].exprUnion(), Occurrence: yyDollar[11].exprUnion(), MatchType: yyDollar[13].exprUnion()} @@ -20591,7 +20594,7 @@ yydefault: case 1383: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6886 +//line sql.y:6888 { yyLOCAL = &RegexpSubstrExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion()} } @@ -20599,7 +20602,7 @@ yydefault: case 1384: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6890 +//line sql.y:6892 { yyLOCAL = &RegexpSubstrExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Position: yyDollar[7].exprUnion()} } @@ -20607,7 +20610,7 @@ yydefault: case 1385: yyDollar = yyS[yypt-10 : yypt+1] var yyLOCAL Expr -//line sql.y:6894 +//line sql.y:6896 { yyLOCAL = &RegexpSubstrExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Position: yyDollar[7].exprUnion(), Occurrence: yyDollar[9].exprUnion()} } @@ -20615,7 +20618,7 @@ yydefault: case 1386: yyDollar = yyS[yypt-12 : yypt+1] var yyLOCAL Expr -//line sql.y:6898 +//line sql.y:6900 { // Match type is kept expression as TRIM( ' m ') is accepted yyLOCAL = &RegexpSubstrExpr{Expr: yyDollar[3].exprUnion(), Pattern: yyDollar[5].exprUnion(), Position: yyDollar[7].exprUnion(), Occurrence: yyDollar[9].exprUnion(), MatchType: yyDollar[11].exprUnion()} @@ -20624,7 +20627,7 @@ yydefault: case 1387: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6905 +//line sql.y:6907 { yyLOCAL = &ExtractValueExpr{Fragment: yyDollar[3].exprUnion(), XPathExpr: yyDollar[5].exprUnion()} } @@ -20632,7 +20635,7 @@ yydefault: case 1388: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6909 +//line sql.y:6911 { yyLOCAL = &UpdateXMLExpr{Target: yyDollar[3].exprUnion(), XPathExpr: yyDollar[5].exprUnion(), NewXML: yyDollar[7].exprUnion()} } @@ -20640,7 +20643,7 @@ yydefault: case 1389: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6915 +//line sql.y:6917 { yyLOCAL = &PerformanceSchemaFuncExpr{Type: FormatBytesType, Argument: yyDollar[3].exprUnion()} } @@ -20648,7 +20651,7 @@ yydefault: case 1390: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6919 +//line sql.y:6921 { yyLOCAL = &PerformanceSchemaFuncExpr{Type: FormatPicoTimeType, Argument: yyDollar[3].exprUnion()} } @@ -20656,7 +20659,7 @@ yydefault: case 1391: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Expr -//line sql.y:6923 +//line sql.y:6925 { yyLOCAL = &PerformanceSchemaFuncExpr{Type: PsCurrentThreadIDType} } @@ -20664,7 +20667,7 @@ yydefault: case 1392: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6927 +//line sql.y:6929 { yyLOCAL = &PerformanceSchemaFuncExpr{Type: PsThreadIDType, Argument: yyDollar[3].exprUnion()} } @@ -20672,7 +20675,7 @@ yydefault: case 1393: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6933 +//line sql.y:6935 { yyLOCAL = >IDFuncExpr{Type: GTIDSubsetType, Set1: yyDollar[3].exprUnion(), Set2: yyDollar[5].exprUnion()} } @@ -20680,7 +20683,7 @@ yydefault: case 1394: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6937 +//line sql.y:6939 { yyLOCAL = >IDFuncExpr{Type: GTIDSubtractType, Set1: yyDollar[3].exprUnion(), Set2: yyDollar[5].exprUnion()} } @@ -20688,7 +20691,7 @@ yydefault: case 1395: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6941 +//line sql.y:6943 { yyLOCAL = >IDFuncExpr{Type: WaitForExecutedGTIDSetType, Set1: yyDollar[3].exprUnion()} } @@ -20696,7 +20699,7 @@ yydefault: case 1396: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6945 +//line sql.y:6947 { yyLOCAL = >IDFuncExpr{Type: WaitForExecutedGTIDSetType, Set1: yyDollar[3].exprUnion(), Timeout: yyDollar[5].exprUnion()} } @@ -20704,7 +20707,7 @@ yydefault: case 1397: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:6949 +//line sql.y:6951 { yyLOCAL = >IDFuncExpr{Type: WaitUntilSQLThreadAfterGTIDSType, Set1: yyDollar[3].exprUnion()} } @@ -20712,7 +20715,7 @@ yydefault: case 1398: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL Expr -//line sql.y:6953 +//line sql.y:6955 { yyLOCAL = >IDFuncExpr{Type: WaitUntilSQLThreadAfterGTIDSType, Set1: yyDollar[3].exprUnion(), Timeout: yyDollar[5].exprUnion()} } @@ -20720,7 +20723,7 @@ yydefault: case 1399: yyDollar = yyS[yypt-8 : yypt+1] var yyLOCAL Expr -//line sql.y:6957 +//line sql.y:6959 { yyLOCAL = >IDFuncExpr{Type: WaitUntilSQLThreadAfterGTIDSType, Set1: yyDollar[3].exprUnion(), Timeout: yyDollar[5].exprUnion(), Channel: yyDollar[7].exprUnion()} } @@ -20728,7 +20731,7 @@ yydefault: case 1400: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:6962 +//line sql.y:6964 { yyLOCAL = nil } @@ -20736,7 +20739,7 @@ yydefault: case 1401: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:6966 +//line sql.y:6968 { yyLOCAL = yyDollar[2].convertTypeUnion() } @@ -20744,7 +20747,7 @@ yydefault: case 1402: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:6972 +//line sql.y:6974 { yyLOCAL = IntervalDayHour } @@ -20752,7 +20755,7 @@ yydefault: case 1403: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:6976 +//line sql.y:6978 { yyLOCAL = IntervalDayMicrosecond } @@ -20760,7 +20763,7 @@ yydefault: case 1404: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:6980 +//line sql.y:6982 { yyLOCAL = IntervalDayMinute } @@ -20768,7 +20771,7 @@ yydefault: case 1405: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:6984 +//line sql.y:6986 { yyLOCAL = IntervalDaySecond } @@ -20776,7 +20779,7 @@ yydefault: case 1406: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:6988 +//line sql.y:6990 { yyLOCAL = IntervalHourMicrosecond } @@ -20784,7 +20787,7 @@ yydefault: case 1407: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:6992 +//line sql.y:6994 { yyLOCAL = IntervalHourMinute } @@ -20792,7 +20795,7 @@ yydefault: case 1408: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:6996 +//line sql.y:6998 { yyLOCAL = IntervalHourSecond } @@ -20800,7 +20803,7 @@ yydefault: case 1409: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7000 +//line sql.y:7002 { yyLOCAL = IntervalMinuteMicrosecond } @@ -20808,7 +20811,7 @@ yydefault: case 1410: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7004 +//line sql.y:7006 { yyLOCAL = IntervalMinuteSecond } @@ -20816,7 +20819,7 @@ yydefault: case 1411: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7008 +//line sql.y:7010 { yyLOCAL = IntervalSecondMicrosecond } @@ -20824,7 +20827,7 @@ yydefault: case 1412: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7012 +//line sql.y:7014 { yyLOCAL = IntervalYearMonth } @@ -20832,7 +20835,7 @@ yydefault: case 1413: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7016 +//line sql.y:7018 { yyLOCAL = IntervalDay } @@ -20840,7 +20843,7 @@ yydefault: case 1414: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7020 +//line sql.y:7022 { yyLOCAL = IntervalWeek } @@ -20848,7 +20851,7 @@ yydefault: case 1415: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7024 +//line sql.y:7026 { yyLOCAL = IntervalHour } @@ -20856,7 +20859,7 @@ yydefault: case 1416: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7028 +//line sql.y:7030 { yyLOCAL = IntervalMinute } @@ -20864,7 +20867,7 @@ yydefault: case 1417: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7032 +//line sql.y:7034 { yyLOCAL = IntervalMonth } @@ -20872,7 +20875,7 @@ yydefault: case 1418: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7036 +//line sql.y:7038 { yyLOCAL = IntervalQuarter } @@ -20880,7 +20883,7 @@ yydefault: case 1419: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7040 +//line sql.y:7042 { yyLOCAL = IntervalSecond } @@ -20888,7 +20891,7 @@ yydefault: case 1420: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7044 +//line sql.y:7046 { yyLOCAL = IntervalMicrosecond } @@ -20896,7 +20899,7 @@ yydefault: case 1421: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7048 +//line sql.y:7050 { yyLOCAL = IntervalYear } @@ -20904,7 +20907,7 @@ yydefault: case 1422: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7054 +//line sql.y:7056 { yyLOCAL = IntervalDay } @@ -20912,7 +20915,7 @@ yydefault: case 1423: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7058 +//line sql.y:7060 { yyLOCAL = IntervalWeek } @@ -20920,7 +20923,7 @@ yydefault: case 1424: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7062 +//line sql.y:7064 { yyLOCAL = IntervalHour } @@ -20928,7 +20931,7 @@ yydefault: case 1425: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7066 +//line sql.y:7068 { yyLOCAL = IntervalMinute } @@ -20936,7 +20939,7 @@ yydefault: case 1426: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7070 +//line sql.y:7072 { yyLOCAL = IntervalMonth } @@ -20944,7 +20947,7 @@ yydefault: case 1427: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7074 +//line sql.y:7076 { yyLOCAL = IntervalQuarter } @@ -20952,7 +20955,7 @@ yydefault: case 1428: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7078 +//line sql.y:7080 { yyLOCAL = IntervalSecond } @@ -20960,7 +20963,7 @@ yydefault: case 1429: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7082 +//line sql.y:7084 { yyLOCAL = IntervalMicrosecond } @@ -20968,7 +20971,7 @@ yydefault: case 1430: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7086 +//line sql.y:7088 { yyLOCAL = IntervalYear } @@ -20976,7 +20979,7 @@ yydefault: case 1431: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7090 +//line sql.y:7092 { yyLOCAL = IntervalDay } @@ -20984,7 +20987,7 @@ yydefault: case 1432: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7094 +//line sql.y:7096 { yyLOCAL = IntervalWeek } @@ -20992,7 +20995,7 @@ yydefault: case 1433: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7098 +//line sql.y:7100 { yyLOCAL = IntervalHour } @@ -21000,7 +21003,7 @@ yydefault: case 1434: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7102 +//line sql.y:7104 { yyLOCAL = IntervalMinute } @@ -21008,7 +21011,7 @@ yydefault: case 1435: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7106 +//line sql.y:7108 { yyLOCAL = IntervalMonth } @@ -21016,7 +21019,7 @@ yydefault: case 1436: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7110 +//line sql.y:7112 { yyLOCAL = IntervalQuarter } @@ -21024,7 +21027,7 @@ yydefault: case 1437: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7114 +//line sql.y:7116 { yyLOCAL = IntervalSecond } @@ -21032,7 +21035,7 @@ yydefault: case 1438: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7118 +//line sql.y:7120 { yyLOCAL = IntervalMicrosecond } @@ -21040,7 +21043,7 @@ yydefault: case 1439: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL IntervalType -//line sql.y:7122 +//line sql.y:7124 { yyLOCAL = IntervalYear } @@ -21048,7 +21051,7 @@ yydefault: case 1442: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL int -//line sql.y:7132 +//line sql.y:7134 { yyLOCAL = 0 } @@ -21056,7 +21059,7 @@ yydefault: case 1443: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL int -//line sql.y:7136 +//line sql.y:7138 { yyLOCAL = 0 } @@ -21064,7 +21067,7 @@ yydefault: case 1444: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL int -//line sql.y:7140 +//line sql.y:7142 { yyLOCAL = convertStringToInt(yyDollar[2].str) } @@ -21072,7 +21075,7 @@ yydefault: case 1445: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:7150 +//line sql.y:7152 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI("if"), Exprs: yyDollar[3].exprsUnion()} } @@ -21080,7 +21083,7 @@ yydefault: case 1446: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:7154 +//line sql.y:7156 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI("database"), Exprs: yyDollar[3].exprsUnion()} } @@ -21088,7 +21091,7 @@ yydefault: case 1447: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:7158 +//line sql.y:7160 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI("schema"), Exprs: yyDollar[3].exprsUnion()} } @@ -21096,7 +21099,7 @@ yydefault: case 1448: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:7162 +//line sql.y:7164 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI("mod"), Exprs: yyDollar[3].exprsUnion()} } @@ -21104,7 +21107,7 @@ yydefault: case 1449: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Expr -//line sql.y:7166 +//line sql.y:7168 { yyLOCAL = &FuncExpr{Name: NewIdentifierCI("replace"), Exprs: yyDollar[3].exprsUnion()} } @@ -21112,7 +21115,7 @@ yydefault: case 1450: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL MatchExprOption -//line sql.y:7172 +//line sql.y:7174 { yyLOCAL = NoOption } @@ -21120,7 +21123,7 @@ yydefault: case 1451: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL MatchExprOption -//line sql.y:7176 +//line sql.y:7178 { yyLOCAL = BooleanModeOpt } @@ -21128,7 +21131,7 @@ yydefault: case 1452: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL MatchExprOption -//line sql.y:7180 +//line sql.y:7182 { yyLOCAL = NaturalLanguageModeOpt } @@ -21136,7 +21139,7 @@ yydefault: case 1453: yyDollar = yyS[yypt-7 : yypt+1] var yyLOCAL MatchExprOption -//line sql.y:7184 +//line sql.y:7186 { yyLOCAL = NaturalLanguageModeWithQueryExpansionOpt } @@ -21144,33 +21147,33 @@ yydefault: case 1454: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL MatchExprOption -//line sql.y:7188 +//line sql.y:7190 { yyLOCAL = QueryExpansionOpt } yyVAL.union = yyLOCAL case 1455: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7194 +//line sql.y:7196 { yyVAL.str = string(yyDollar[1].identifierCI.String()) } case 1456: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7198 +//line sql.y:7200 { yyVAL.str = string(yyDollar[1].str) } case 1457: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7202 +//line sql.y:7204 { yyVAL.str = string(yyDollar[1].str) } case 1458: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7208 +//line sql.y:7210 { yyLOCAL = nil } @@ -21178,7 +21181,7 @@ yydefault: case 1459: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7212 +//line sql.y:7214 { yyLOCAL = &ConvertType{Type: string(yyDollar[2].str), Length: ptr.Of(convertStringToInt(yyDollar[4].str))} } @@ -21186,7 +21189,7 @@ yydefault: case 1460: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7216 +//line sql.y:7218 { yyLOCAL = &ConvertType{Type: string(yyDollar[2].str), Length: ptr.Of(convertStringToInt(yyDollar[4].str))} } @@ -21194,7 +21197,7 @@ yydefault: case 1461: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7222 +//line sql.y:7224 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str), Length: yyDollar[2].intPtrUnion()} } @@ -21202,7 +21205,7 @@ yydefault: case 1462: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7226 +//line sql.y:7228 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str), Length: yyDollar[2].intPtrUnion(), Charset: yyDollar[3].columnCharset} } @@ -21210,7 +21213,7 @@ yydefault: case 1463: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7230 +//line sql.y:7232 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str)} } @@ -21218,7 +21221,7 @@ yydefault: case 1464: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7234 +//line sql.y:7236 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str), Length: yyDollar[2].intPtrUnion()} } @@ -21226,7 +21229,7 @@ yydefault: case 1465: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7238 +//line sql.y:7240 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str)} yyLOCAL.Length = yyDollar[2].LengthScaleOption.Length @@ -21236,7 +21239,7 @@ yydefault: case 1466: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7244 +//line sql.y:7246 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str)} } @@ -21244,7 +21247,7 @@ yydefault: case 1467: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7248 +//line sql.y:7250 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str), Length: yyDollar[2].intPtrUnion()} } @@ -21252,7 +21255,7 @@ yydefault: case 1468: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7252 +//line sql.y:7254 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str)} } @@ -21260,7 +21263,7 @@ yydefault: case 1469: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7256 +//line sql.y:7258 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str)} } @@ -21268,7 +21271,7 @@ yydefault: case 1470: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7260 +//line sql.y:7262 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str), Length: yyDollar[2].intPtrUnion()} } @@ -21276,7 +21279,7 @@ yydefault: case 1471: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7264 +//line sql.y:7266 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str)} } @@ -21284,7 +21287,7 @@ yydefault: case 1472: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7268 +//line sql.y:7270 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str)} } @@ -21292,7 +21295,7 @@ yydefault: case 1473: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7272 +//line sql.y:7274 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str), Length: yyDollar[2].intPtrUnion()} } @@ -21300,7 +21303,7 @@ yydefault: case 1474: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7276 +//line sql.y:7278 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str)} } @@ -21308,7 +21311,7 @@ yydefault: case 1475: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *ConvertType -//line sql.y:7280 +//line sql.y:7282 { yyLOCAL = &ConvertType{Type: string(yyDollar[1].str)} } @@ -21316,7 +21319,7 @@ yydefault: case 1476: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL bool -//line sql.y:7286 +//line sql.y:7288 { yyLOCAL = false } @@ -21324,7 +21327,7 @@ yydefault: case 1477: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL bool -//line sql.y:7290 +//line sql.y:7292 { yyLOCAL = true } @@ -21332,7 +21335,7 @@ yydefault: case 1478: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL Expr -//line sql.y:7295 +//line sql.y:7297 { yyLOCAL = nil } @@ -21340,34 +21343,34 @@ yydefault: case 1479: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:7299 +//line sql.y:7301 { yyLOCAL = yyDollar[1].exprUnion() } yyVAL.union = yyLOCAL case 1480: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7304 +//line sql.y:7306 { yyVAL.str = string("") } case 1481: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7308 +//line sql.y:7310 { yyVAL.str = encodeSQLString(yyDollar[2].str) } case 1482: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL []*When -//line sql.y:7314 +//line sql.y:7316 { yyLOCAL = []*When{yyDollar[1].whenUnion()} } yyVAL.union = yyLOCAL case 1483: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7318 +//line sql.y:7320 { yySLICE := (*[]*When)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[2].whenUnion()) @@ -21375,7 +21378,7 @@ yydefault: case 1484: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL *When -//line sql.y:7324 +//line sql.y:7326 { yyLOCAL = &When{Cond: yyDollar[2].exprUnion(), Val: yyDollar[4].exprUnion()} } @@ -21383,7 +21386,7 @@ yydefault: case 1485: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL Expr -//line sql.y:7329 +//line sql.y:7331 { yyLOCAL = nil } @@ -21391,7 +21394,7 @@ yydefault: case 1486: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:7333 +//line sql.y:7335 { yyLOCAL = yyDollar[2].exprUnion() } @@ -21399,7 +21402,7 @@ yydefault: case 1487: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *ColName -//line sql.y:7339 +//line sql.y:7341 { yyLOCAL = &ColName{Name: yyDollar[1].identifierCI} } @@ -21407,7 +21410,7 @@ yydefault: case 1488: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *ColName -//line sql.y:7343 +//line sql.y:7345 { yyLOCAL = &ColName{Name: NewIdentifierCI(string(yyDollar[1].str))} } @@ -21415,7 +21418,7 @@ yydefault: case 1489: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL *ColName -//line sql.y:7347 +//line sql.y:7349 { yyLOCAL = &ColName{Qualifier: TableName{Name: yyDollar[1].identifierCS}, Name: yyDollar[3].identifierCI} } @@ -21423,7 +21426,7 @@ yydefault: case 1490: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *ColName -//line sql.y:7351 +//line sql.y:7353 { yyLOCAL = &ColName{Qualifier: TableName{Qualifier: yyDollar[1].identifierCS, Name: yyDollar[3].identifierCS}, Name: yyDollar[5].identifierCI} } @@ -21431,7 +21434,7 @@ yydefault: case 1491: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:7357 +//line sql.y:7359 { yyLOCAL = yyDollar[1].colNameUnion() } @@ -21439,7 +21442,7 @@ yydefault: case 1492: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:7361 +//line sql.y:7363 { yyLOCAL = &Offset{V: convertStringToInt(yyDollar[1].str)} } @@ -21447,7 +21450,7 @@ yydefault: case 1493: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:7367 +//line sql.y:7369 { // TODO(sougou): Deprecate this construct. if yyDollar[1].identifierCI.Lowered() != "value" { @@ -21460,7 +21463,7 @@ yydefault: case 1494: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:7376 +//line sql.y:7378 { yyLOCAL = NewIntLiteral(yyDollar[1].str) } @@ -21468,7 +21471,7 @@ yydefault: case 1495: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:7380 +//line sql.y:7382 { yyLOCAL = parseBindVariable(yylex, yyDollar[1].str[1:]) } @@ -21476,7 +21479,7 @@ yydefault: case 1496: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL *GroupBy -//line sql.y:7385 +//line sql.y:7387 { yyLOCAL = nil } @@ -21484,7 +21487,7 @@ yydefault: case 1497: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL *GroupBy -//line sql.y:7389 +//line sql.y:7391 { yyLOCAL = &GroupBy{Exprs: yyDollar[3].exprsUnion(), WithRollup: yyDollar[4].booleanUnion()} } @@ -21492,7 +21495,7 @@ yydefault: case 1498: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL bool -//line sql.y:7394 +//line sql.y:7396 { yyLOCAL = false } @@ -21500,7 +21503,7 @@ yydefault: case 1499: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL bool -//line sql.y:7398 +//line sql.y:7400 { yyLOCAL = true } @@ -21508,7 +21511,7 @@ yydefault: case 1500: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL Expr -//line sql.y:7404 +//line sql.y:7406 { yyLOCAL = nil } @@ -21516,7 +21519,7 @@ yydefault: case 1501: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Expr -//line sql.y:7408 +//line sql.y:7410 { yyLOCAL = yyDollar[2].exprUnion() } @@ -21524,7 +21527,7 @@ yydefault: case 1502: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *NamedWindow -//line sql.y:7414 +//line sql.y:7416 { yyLOCAL = &NamedWindow{yyDollar[2].windowDefinitionsUnion()} } @@ -21532,14 +21535,14 @@ yydefault: case 1503: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL NamedWindows -//line sql.y:7420 +//line sql.y:7422 { yyLOCAL = NamedWindows{yyDollar[1].namedWindowUnion()} } yyVAL.union = yyLOCAL case 1504: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7424 +//line sql.y:7426 { yySLICE := (*NamedWindows)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].namedWindowUnion()) @@ -21547,7 +21550,7 @@ yydefault: case 1505: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL NamedWindows -//line sql.y:7429 +//line sql.y:7431 { yyLOCAL = nil } @@ -21555,7 +21558,7 @@ yydefault: case 1506: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL NamedWindows -//line sql.y:7433 +//line sql.y:7435 { yyLOCAL = yyDollar[1].namedWindowsUnion() } @@ -21563,7 +21566,7 @@ yydefault: case 1507: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL OrderBy -//line sql.y:7438 +//line sql.y:7440 { yyLOCAL = nil } @@ -21571,7 +21574,7 @@ yydefault: case 1508: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL OrderBy -//line sql.y:7442 +//line sql.y:7444 { yyLOCAL = yyDollar[1].orderByUnion() } @@ -21579,7 +21582,7 @@ yydefault: case 1509: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL OrderBy -//line sql.y:7448 +//line sql.y:7450 { yyLOCAL = yyDollar[3].orderByUnion() } @@ -21587,14 +21590,14 @@ yydefault: case 1510: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL OrderBy -//line sql.y:7454 +//line sql.y:7456 { yyLOCAL = OrderBy{yyDollar[1].orderUnion()} } yyVAL.union = yyLOCAL case 1511: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7458 +//line sql.y:7460 { yySLICE := (*OrderBy)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].orderUnion()) @@ -21602,7 +21605,7 @@ yydefault: case 1512: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *Order -//line sql.y:7464 +//line sql.y:7466 { yyLOCAL = &Order{Expr: yyDollar[1].exprUnion(), Direction: yyDollar[2].orderDirectionUnion()} } @@ -21610,7 +21613,7 @@ yydefault: case 1513: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL OrderDirection -//line sql.y:7469 +//line sql.y:7471 { yyLOCAL = AscOrder } @@ -21618,7 +21621,7 @@ yydefault: case 1514: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL OrderDirection -//line sql.y:7473 +//line sql.y:7475 { yyLOCAL = AscOrder } @@ -21626,7 +21629,7 @@ yydefault: case 1515: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL OrderDirection -//line sql.y:7477 +//line sql.y:7479 { yyLOCAL = DescOrder } @@ -21634,7 +21637,7 @@ yydefault: case 1516: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL *Limit -//line sql.y:7482 +//line sql.y:7484 { yyLOCAL = nil } @@ -21642,7 +21645,7 @@ yydefault: case 1517: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *Limit -//line sql.y:7486 +//line sql.y:7488 { yyLOCAL = yyDollar[1].limitUnion() } @@ -21650,7 +21653,7 @@ yydefault: case 1518: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *Limit -//line sql.y:7492 +//line sql.y:7494 { yyLOCAL = &Limit{Rowcount: yyDollar[2].exprUnion()} } @@ -21658,7 +21661,7 @@ yydefault: case 1519: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL *Limit -//line sql.y:7496 +//line sql.y:7498 { yyLOCAL = &Limit{Offset: yyDollar[2].exprUnion(), Rowcount: yyDollar[4].exprUnion()} } @@ -21666,7 +21669,7 @@ yydefault: case 1520: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL *Limit -//line sql.y:7500 +//line sql.y:7502 { yyLOCAL = &Limit{Offset: yyDollar[4].exprUnion(), Rowcount: yyDollar[2].exprUnion()} } @@ -21674,7 +21677,7 @@ yydefault: case 1521: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL []AlterOption -//line sql.y:7505 +//line sql.y:7507 { yyLOCAL = nil } @@ -21682,7 +21685,7 @@ yydefault: case 1522: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL []AlterOption -//line sql.y:7509 +//line sql.y:7511 { yyLOCAL = []AlterOption{yyDollar[1].alterOptionUnion(), yyDollar[2].alterOptionUnion()} } @@ -21690,7 +21693,7 @@ yydefault: case 1523: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL []AlterOption -//line sql.y:7513 +//line sql.y:7515 { yyLOCAL = []AlterOption{yyDollar[1].alterOptionUnion(), yyDollar[2].alterOptionUnion()} } @@ -21698,7 +21701,7 @@ yydefault: case 1524: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL []AlterOption -//line sql.y:7517 +//line sql.y:7519 { yyLOCAL = []AlterOption{yyDollar[1].alterOptionUnion()} } @@ -21706,7 +21709,7 @@ yydefault: case 1525: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL []AlterOption -//line sql.y:7521 +//line sql.y:7523 { yyLOCAL = []AlterOption{yyDollar[1].alterOptionUnion()} } @@ -21714,7 +21717,7 @@ yydefault: case 1526: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL AlterOption -//line sql.y:7528 +//line sql.y:7530 { yyLOCAL = &LockOption{Type: DefaultType} } @@ -21722,7 +21725,7 @@ yydefault: case 1527: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL AlterOption -//line sql.y:7532 +//line sql.y:7534 { yyLOCAL = &LockOption{Type: NoneType} } @@ -21730,7 +21733,7 @@ yydefault: case 1528: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL AlterOption -//line sql.y:7536 +//line sql.y:7538 { yyLOCAL = &LockOption{Type: SharedType} } @@ -21738,7 +21741,7 @@ yydefault: case 1529: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL AlterOption -//line sql.y:7540 +//line sql.y:7542 { yyLOCAL = &LockOption{Type: ExclusiveType} } @@ -21746,7 +21749,7 @@ yydefault: case 1530: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL AlterOption -//line sql.y:7546 +//line sql.y:7548 { yyLOCAL = AlgorithmValue(yyDollar[3].str) } @@ -21754,7 +21757,7 @@ yydefault: case 1531: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL AlterOption -//line sql.y:7550 +//line sql.y:7552 { yyLOCAL = AlgorithmValue(yyDollar[3].str) } @@ -21762,7 +21765,7 @@ yydefault: case 1532: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL AlterOption -//line sql.y:7554 +//line sql.y:7556 { yyLOCAL = AlgorithmValue(yyDollar[3].str) } @@ -21770,93 +21773,93 @@ yydefault: case 1533: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL AlterOption -//line sql.y:7558 +//line sql.y:7560 { yyLOCAL = AlgorithmValue(yyDollar[3].str) } yyVAL.union = yyLOCAL case 1534: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7563 +//line sql.y:7565 { yyVAL.str = "" } case 1535: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7567 +//line sql.y:7569 { yyVAL.str = string(yyDollar[3].str) } case 1536: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7571 +//line sql.y:7573 { yyVAL.str = string(yyDollar[3].str) } case 1537: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7575 +//line sql.y:7577 { yyVAL.str = string(yyDollar[3].str) } case 1538: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7580 +//line sql.y:7582 { yyVAL.str = "" } case 1539: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7584 +//line sql.y:7586 { yyVAL.str = yyDollar[3].str } case 1540: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7590 +//line sql.y:7592 { yyVAL.str = string(yyDollar[1].str) } case 1541: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7594 +//line sql.y:7596 { yyVAL.str = string(yyDollar[1].str) } case 1542: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7599 +//line sql.y:7601 { yyVAL.str = "" } case 1543: yyDollar = yyS[yypt-4 : yypt+1] -//line sql.y:7603 +//line sql.y:7605 { yyVAL.str = yyDollar[2].str } case 1544: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7608 +//line sql.y:7610 { yyVAL.str = "cascaded" } case 1545: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7612 +//line sql.y:7614 { yyVAL.str = string(yyDollar[1].str) } case 1546: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7616 +//line sql.y:7618 { yyVAL.str = string(yyDollar[1].str) } case 1547: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL *Definer -//line sql.y:7621 +//line sql.y:7623 { yyLOCAL = nil } @@ -21864,7 +21867,7 @@ yydefault: case 1548: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL *Definer -//line sql.y:7625 +//line sql.y:7627 { yyLOCAL = yyDollar[3].definerUnion() } @@ -21872,7 +21875,7 @@ yydefault: case 1549: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *Definer -//line sql.y:7631 +//line sql.y:7633 { yyLOCAL = &Definer{ Name: string(yyDollar[1].str), @@ -21882,7 +21885,7 @@ yydefault: case 1550: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL *Definer -//line sql.y:7637 +//line sql.y:7639 { yyLOCAL = &Definer{ Name: string(yyDollar[1].str), @@ -21892,7 +21895,7 @@ yydefault: case 1551: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *Definer -//line sql.y:7643 +//line sql.y:7645 { yyLOCAL = &Definer{ Name: yyDollar[1].str, @@ -21902,32 +21905,32 @@ yydefault: yyVAL.union = yyLOCAL case 1552: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7652 +//line sql.y:7654 { yyVAL.str = encodeSQLString(yyDollar[1].str) } case 1553: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7656 +//line sql.y:7658 { yyVAL.str = formatIdentifier(yyDollar[1].str) } case 1554: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7661 +//line sql.y:7663 { yyVAL.str = "" } case 1555: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7665 +//line sql.y:7667 { yyVAL.str = formatAddress(yyDollar[1].str) } case 1556: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Lock -//line sql.y:7671 +//line sql.y:7673 { yyLOCAL = ForUpdateLock } @@ -21935,7 +21938,7 @@ yydefault: case 1557: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Lock -//line sql.y:7675 +//line sql.y:7677 { yyLOCAL = ForUpdateLockNoWait } @@ -21943,7 +21946,7 @@ yydefault: case 1558: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Lock -//line sql.y:7679 +//line sql.y:7681 { yyLOCAL = ForUpdateLockSkipLocked } @@ -21951,7 +21954,7 @@ yydefault: case 1559: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL Lock -//line sql.y:7683 +//line sql.y:7685 { yyLOCAL = ForShareLock } @@ -21959,7 +21962,7 @@ yydefault: case 1560: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Lock -//line sql.y:7687 +//line sql.y:7689 { yyLOCAL = ForShareLockNoWait } @@ -21967,7 +21970,7 @@ yydefault: case 1561: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Lock -//line sql.y:7691 +//line sql.y:7693 { yyLOCAL = ForShareLockSkipLocked } @@ -21975,7 +21978,7 @@ yydefault: case 1562: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL Lock -//line sql.y:7695 +//line sql.y:7697 { yyLOCAL = ShareModeLock } @@ -21983,7 +21986,7 @@ yydefault: case 1563: yyDollar = yyS[yypt-9 : yypt+1] var yyLOCAL *SelectInto -//line sql.y:7701 +//line sql.y:7703 { yyLOCAL = &SelectInto{Type: IntoOutfileS3, FileName: encodeSQLString(yyDollar[4].str), Charset: yyDollar[5].columnCharset, FormatOption: yyDollar[6].str, ExportOption: yyDollar[7].str, Manifest: yyDollar[8].str, Overwrite: yyDollar[9].str} } @@ -21991,7 +21994,7 @@ yydefault: case 1564: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL *SelectInto -//line sql.y:7705 +//line sql.y:7707 { yyLOCAL = &SelectInto{Type: IntoDumpfile, FileName: encodeSQLString(yyDollar[3].str), Charset: ColumnCharset{}, FormatOption: "", ExportOption: "", Manifest: "", Overwrite: ""} } @@ -21999,177 +22002,177 @@ yydefault: case 1565: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *SelectInto -//line sql.y:7709 +//line sql.y:7711 { yyLOCAL = &SelectInto{Type: IntoOutfile, FileName: encodeSQLString(yyDollar[3].str), Charset: yyDollar[4].columnCharset, FormatOption: "", ExportOption: yyDollar[5].str, Manifest: "", Overwrite: ""} } yyVAL.union = yyLOCAL case 1566: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7714 +//line sql.y:7716 { yyVAL.str = "" } case 1567: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7718 +//line sql.y:7720 { yyVAL.str = " format csv" + yyDollar[3].str } case 1568: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7722 +//line sql.y:7724 { yyVAL.str = " format text" + yyDollar[3].str } case 1569: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7727 +//line sql.y:7729 { yyVAL.str = "" } case 1570: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7731 +//line sql.y:7733 { yyVAL.str = " header" } case 1571: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7736 +//line sql.y:7738 { yyVAL.str = "" } case 1572: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7740 +//line sql.y:7742 { yyVAL.str = " manifest on" } case 1573: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7744 +//line sql.y:7746 { yyVAL.str = " manifest off" } case 1574: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7749 +//line sql.y:7751 { yyVAL.str = "" } case 1575: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7753 +//line sql.y:7755 { yyVAL.str = " overwrite on" } case 1576: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7757 +//line sql.y:7759 { yyVAL.str = " overwrite off" } case 1577: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7763 +//line sql.y:7765 { yyVAL.str = yyDollar[1].str + yyDollar[2].str } case 1578: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7768 +//line sql.y:7770 { yyVAL.str = "" } case 1579: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7772 +//line sql.y:7774 { yyVAL.str = " lines" + yyDollar[2].str } case 1580: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7778 +//line sql.y:7780 { yyVAL.str = yyDollar[1].str } case 1581: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7782 +//line sql.y:7784 { yyVAL.str = yyDollar[1].str + yyDollar[2].str } case 1582: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7788 +//line sql.y:7790 { yyVAL.str = " starting by " + encodeSQLString(yyDollar[3].str) } case 1583: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7792 +//line sql.y:7794 { yyVAL.str = " terminated by " + encodeSQLString(yyDollar[3].str) } case 1584: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7797 +//line sql.y:7799 { yyVAL.str = "" } case 1585: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7801 +//line sql.y:7803 { yyVAL.str = " " + yyDollar[1].str + yyDollar[2].str } case 1586: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7807 +//line sql.y:7809 { yyVAL.str = yyDollar[1].str } case 1587: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7811 +//line sql.y:7813 { yyVAL.str = yyDollar[1].str + yyDollar[2].str } case 1588: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7817 +//line sql.y:7819 { yyVAL.str = " terminated by " + encodeSQLString(yyDollar[3].str) } case 1589: yyDollar = yyS[yypt-4 : yypt+1] -//line sql.y:7821 +//line sql.y:7823 { yyVAL.str = yyDollar[1].str + " enclosed by " + encodeSQLString(yyDollar[4].str) } case 1590: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7825 +//line sql.y:7827 { yyVAL.str = " escaped by " + encodeSQLString(yyDollar[3].str) } case 1591: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:7830 +//line sql.y:7832 { yyVAL.str = "" } case 1592: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:7834 +//line sql.y:7836 { yyVAL.str = " optionally" } case 1593: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL *Insert -//line sql.y:7847 +//line sql.y:7849 { yyLOCAL = &Insert{Rows: yyDollar[2].valuesUnion(), RowAlias: yyDollar[3].rowAliasUnion()} } @@ -22177,7 +22180,7 @@ yydefault: case 1594: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL *Insert -//line sql.y:7851 +//line sql.y:7853 { yyLOCAL = &Insert{Rows: yyDollar[1].tableStmtUnion()} } @@ -22185,7 +22188,7 @@ yydefault: case 1595: yyDollar = yyS[yypt-6 : yypt+1] var yyLOCAL *Insert -//line sql.y:7855 +//line sql.y:7857 { yyLOCAL = &Insert{Columns: yyDollar[2].columnsUnion(), Rows: yyDollar[5].valuesUnion(), RowAlias: yyDollar[6].rowAliasUnion()} } @@ -22193,7 +22196,7 @@ yydefault: case 1596: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *Insert -//line sql.y:7859 +//line sql.y:7861 { yyLOCAL = &Insert{Columns: []IdentifierCI{}, Rows: yyDollar[4].valuesUnion(), RowAlias: yyDollar[5].rowAliasUnion()} } @@ -22201,7 +22204,7 @@ yydefault: case 1597: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL *Insert -//line sql.y:7863 +//line sql.y:7865 { yyLOCAL = &Insert{Columns: yyDollar[2].columnsUnion(), Rows: yyDollar[4].tableStmtUnion()} } @@ -22209,7 +22212,7 @@ yydefault: case 1598: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Columns -//line sql.y:7869 +//line sql.y:7871 { yyLOCAL = Columns{yyDollar[1].identifierCI} } @@ -22217,21 +22220,21 @@ yydefault: case 1599: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Columns -//line sql.y:7873 +//line sql.y:7875 { yyLOCAL = Columns{yyDollar[3].identifierCI} } yyVAL.union = yyLOCAL case 1600: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7877 +//line sql.y:7879 { yySLICE := (*Columns)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].identifierCI) } case 1601: yyDollar = yyS[yypt-5 : yypt+1] -//line sql.y:7881 +//line sql.y:7883 { yySLICE := (*Columns)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[5].identifierCI) @@ -22239,7 +22242,7 @@ yydefault: case 1602: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL *RowAlias -//line sql.y:7886 +//line sql.y:7888 { yyLOCAL = nil } @@ -22247,7 +22250,7 @@ yydefault: case 1603: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *RowAlias -//line sql.y:7890 +//line sql.y:7892 { yyLOCAL = &RowAlias{TableName: yyDollar[2].identifierCS} } @@ -22255,7 +22258,7 @@ yydefault: case 1604: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL *RowAlias -//line sql.y:7894 +//line sql.y:7896 { yyLOCAL = &RowAlias{TableName: yyDollar[2].identifierCS, Columns: yyDollar[4].columnsUnion()} } @@ -22263,7 +22266,7 @@ yydefault: case 1605: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL UpdateExprs -//line sql.y:7899 +//line sql.y:7901 { yyLOCAL = nil } @@ -22271,7 +22274,7 @@ yydefault: case 1606: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL UpdateExprs -//line sql.y:7903 +//line sql.y:7905 { yyLOCAL = yyDollar[5].updateExprsUnion() } @@ -22279,14 +22282,14 @@ yydefault: case 1607: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Values -//line sql.y:7909 +//line sql.y:7911 { yyLOCAL = Values{yyDollar[1].valTupleUnion()} } yyVAL.union = yyLOCAL case 1608: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7913 +//line sql.y:7915 { yySLICE := (*Values)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].valTupleUnion()) @@ -22294,14 +22297,14 @@ yydefault: case 1609: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Values -//line sql.y:7919 +//line sql.y:7921 { yyLOCAL = Values{yyDollar[1].valTupleUnion()} } yyVAL.union = yyLOCAL case 1610: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7923 +//line sql.y:7925 { yySLICE := (*Values)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].valTupleUnion()) @@ -22309,7 +22312,7 @@ yydefault: case 1611: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ValTuple -//line sql.y:7929 +//line sql.y:7931 { yyLOCAL = yyDollar[1].valTupleUnion() } @@ -22317,7 +22320,7 @@ yydefault: case 1612: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL ValTuple -//line sql.y:7933 +//line sql.y:7935 { yyLOCAL = ValTuple{} } @@ -22325,7 +22328,7 @@ yydefault: case 1613: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL ValTuple -//line sql.y:7939 +//line sql.y:7941 { yyLOCAL = yyDollar[1].valTupleUnion() } @@ -22333,7 +22336,7 @@ yydefault: case 1614: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL ValTuple -//line sql.y:7943 +//line sql.y:7945 { yyLOCAL = ValTuple{} } @@ -22341,7 +22344,7 @@ yydefault: case 1615: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL ValTuple -//line sql.y:7949 +//line sql.y:7951 { yyLOCAL = ValTuple(yyDollar[2].exprsUnion()) } @@ -22349,7 +22352,7 @@ yydefault: case 1616: yyDollar = yyS[yypt-4 : yypt+1] var yyLOCAL ValTuple -//line sql.y:7955 +//line sql.y:7957 { yyLOCAL = ValTuple(yyDollar[3].exprsUnion()) } @@ -22357,7 +22360,7 @@ yydefault: case 1619: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:7965 +//line sql.y:7967 { if len(yyDollar[1].valTupleUnion()) == 1 { yyLOCAL = yyDollar[1].valTupleUnion()[0] @@ -22369,14 +22372,14 @@ yydefault: case 1620: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL UpdateExprs -//line sql.y:7975 +//line sql.y:7977 { yyLOCAL = UpdateExprs{yyDollar[1].updateExprUnion()} } yyVAL.union = yyLOCAL case 1621: yyDollar = yyS[yypt-3 : yypt+1] -//line sql.y:7979 +//line sql.y:7981 { yySLICE := (*UpdateExprs)(yyIaddr(yyVAL.union)) *yySLICE = append(*yySLICE, yyDollar[3].updateExprUnion()) @@ -22384,21 +22387,21 @@ yydefault: case 1622: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL *UpdateExpr -//line sql.y:7985 +//line sql.y:7987 { yyLOCAL = &UpdateExpr{Name: yyDollar[1].colNameUnion(), Expr: yyDollar[3].exprUnion()} } yyVAL.union = yyLOCAL case 1624: yyDollar = yyS[yypt-2 : yypt+1] -//line sql.y:7992 +//line sql.y:7994 { yyVAL.str = "charset" } case 1627: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:8002 +//line sql.y:8004 { yyLOCAL = NewStrLiteral(yyDollar[1].identifierCI.String()) } @@ -22406,7 +22409,7 @@ yydefault: case 1628: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:8006 +//line sql.y:8008 { yyLOCAL = NewStrLiteral(yyDollar[1].str) } @@ -22414,7 +22417,7 @@ yydefault: case 1629: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Expr -//line sql.y:8010 +//line sql.y:8012 { yyLOCAL = &Default{} } @@ -22422,7 +22425,7 @@ yydefault: case 1632: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL bool -//line sql.y:8019 +//line sql.y:8021 { yyLOCAL = false } @@ -22430,7 +22433,7 @@ yydefault: case 1633: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL bool -//line sql.y:8021 +//line sql.y:8023 { yyLOCAL = true } @@ -22438,7 +22441,7 @@ yydefault: case 1634: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL bool -//line sql.y:8024 +//line sql.y:8026 { yyLOCAL = false } @@ -22446,7 +22449,7 @@ yydefault: case 1635: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL bool -//line sql.y:8026 +//line sql.y:8028 { yyLOCAL = true } @@ -22454,7 +22457,7 @@ yydefault: case 1636: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL bool -//line sql.y:8029 +//line sql.y:8031 { yyLOCAL = false } @@ -22462,7 +22465,7 @@ yydefault: case 1637: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL bool -//line sql.y:8031 +//line sql.y:8033 { yyLOCAL = true } @@ -22470,7 +22473,7 @@ yydefault: case 1638: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL Ignore -//line sql.y:8034 +//line sql.y:8036 { yyLOCAL = false } @@ -22478,49 +22481,49 @@ yydefault: case 1639: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL Ignore -//line sql.y:8036 +//line sql.y:8038 { yyLOCAL = true } yyVAL.union = yyLOCAL case 1640: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:8039 +//line sql.y:8041 { yyVAL.empty = struct{}{} } case 1641: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8041 +//line sql.y:8043 { yyVAL.empty = struct{}{} } case 1642: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8043 +//line sql.y:8045 { yyVAL.empty = struct{}{} } case 1643: yyDollar = yyS[yypt-5 : yypt+1] var yyLOCAL Statement -//line sql.y:8047 +//line sql.y:8049 { yyLOCAL = &CallProc{Name: yyDollar[2].tableName, Params: yyDollar[4].exprsUnion()} } yyVAL.union = yyLOCAL case 1644: yyDollar = yyS[yypt-0 : yypt+1] - var yyLOCAL Exprs -//line sql.y:8052 + var yyLOCAL []Expr +//line sql.y:8054 { yyLOCAL = nil } yyVAL.union = yyLOCAL case 1645: yyDollar = yyS[yypt-1 : yypt+1] - var yyLOCAL Exprs -//line sql.y:8056 + var yyLOCAL []Expr +//line sql.y:8058 { yyLOCAL = yyDollar[1].exprsUnion() } @@ -22528,7 +22531,7 @@ yydefault: case 1646: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL []*IndexOption -//line sql.y:8061 +//line sql.y:8063 { yyLOCAL = nil } @@ -22536,7 +22539,7 @@ yydefault: case 1647: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL []*IndexOption -//line sql.y:8063 +//line sql.y:8065 { yyLOCAL = []*IndexOption{yyDollar[1].indexOptionUnion()} } @@ -22544,63 +22547,63 @@ yydefault: case 1648: yyDollar = yyS[yypt-2 : yypt+1] var yyLOCAL *IndexOption -//line sql.y:8067 +//line sql.y:8069 { yyLOCAL = &IndexOption{Name: string(yyDollar[1].str), String: string(yyDollar[2].identifierCI.String())} } yyVAL.union = yyLOCAL case 1649: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8073 +//line sql.y:8075 { yyVAL.identifierCI = yyDollar[1].identifierCI } case 1650: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8077 +//line sql.y:8079 { yyVAL.identifierCI = NewIdentifierCI(string(yyDollar[1].str)) } case 1652: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8084 +//line sql.y:8086 { yyVAL.identifierCI = NewIdentifierCI(string(yyDollar[1].str)) } case 1653: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8090 +//line sql.y:8092 { yyVAL.identifierCS = NewIdentifierCS(string(yyDollar[1].str)) } case 1654: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8094 +//line sql.y:8096 { yyVAL.identifierCS = NewIdentifierCS(string(yyDollar[1].str)) } case 1655: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:8100 +//line sql.y:8102 { yyVAL.identifierCS = NewIdentifierCS("") } case 1656: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8104 +//line sql.y:8106 { yyVAL.identifierCS = yyDollar[1].identifierCS } case 1658: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8111 +//line sql.y:8113 { yyVAL.identifierCS = NewIdentifierCS(string(yyDollar[1].str)) } case 1659: yyDollar = yyS[yypt-3 : yypt+1] var yyLOCAL Statement -//line sql.y:8117 +//line sql.y:8119 { yyLOCAL = &Kill{Type: yyDollar[2].killTypeUnion(), ProcesslistID: convertStringToUInt64(yyDollar[3].str)} } @@ -22608,7 +22611,7 @@ yydefault: case 1660: yyDollar = yyS[yypt-0 : yypt+1] var yyLOCAL KillType -//line sql.y:8123 +//line sql.y:8125 { yyLOCAL = ConnectionType } @@ -22616,7 +22619,7 @@ yydefault: case 1661: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL KillType -//line sql.y:8127 +//line sql.y:8129 { yyLOCAL = ConnectionType } @@ -22624,42 +22627,42 @@ yydefault: case 1662: yyDollar = yyS[yypt-1 : yypt+1] var yyLOCAL KillType -//line sql.y:8131 +//line sql.y:8133 { yyLOCAL = QueryType } yyVAL.union = yyLOCAL case 2298: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8795 +//line sql.y:8797 { } case 2299: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8800 +//line sql.y:8802 { } case 2300: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:8804 +//line sql.y:8806 { skipToEnd(yylex) } case 2301: yyDollar = yyS[yypt-0 : yypt+1] -//line sql.y:8809 +//line sql.y:8811 { skipToEnd(yylex) } case 2302: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8813 +//line sql.y:8815 { skipToEnd(yylex) } case 2303: yyDollar = yyS[yypt-1 : yypt+1] -//line sql.y:8817 +//line sql.y:8819 { skipToEnd(yylex) } diff --git a/go/vt/sqlparser/sql.y b/go/vt/sqlparser/sql.y index f1663a9a41c..5ecdeabe108 100644 --- a/go/vt/sqlparser/sql.y +++ b/go/vt/sqlparser/sql.y @@ -154,14 +154,14 @@ func markBindVariable(yylex yyLexer, bvar string) { partitions Partitions tableExprs TableExprs tableNames TableNames - exprs Exprs + exprs []Expr values Values valTuple ValTuple orderBy OrderBy updateExprs UpdateExprs setExprs SetExprs - selectExprs SelectExprs - tableOptions TableOptions + selectExprs *SelectExprs + tableOptions TableOptions starExpr StarExpr groupBy *GroupBy @@ -835,7 +835,7 @@ query_expression: } | SELECT comment_opt cache_opt NEXT num_val for_from table_name { - $$ = NewSelect(Comments($2), SelectExprs{&Nextval{Expr: $5}}, []string{$3}/*options*/, nil, TableExprs{&AliasedTableExpr{Expr: $7}}, nil/*where*/, nil/*groupBy*/, nil/*having*/, nil) + $$ = NewSelect(Comments($2), &SelectExprs{Exprs: []SelectExpr{&Nextval{Expr: $5}}}, []string{$3}/*options*/, nil, TableExprs{&AliasedTableExpr{Expr: $7}}, nil/*where*/, nil/*groupBy*/, nil/*having*/, nil) } query_expression_body: @@ -4935,11 +4935,13 @@ select_option: select_expression_list: select_expression { - $$ = SelectExprs{$1} + $$ = &SelectExprs{Exprs: []SelectExpr{$1}} } | select_expression_list ',' select_expression { - $$ = append($$, $3) + res := $1 + res.Exprs = append(res.Exprs, $3) + $$ = res } select_expression: @@ -5966,7 +5968,7 @@ subquery: expression_list: expression { - $$ = Exprs{$1} + $$ = []Expr{$1} } | expression_list ',' expression { diff --git a/go/vt/sqlparser/tracked_buffer.go b/go/vt/sqlparser/tracked_buffer.go index 48efe9547af..9ef0cfd1f93 100644 --- a/go/vt/sqlparser/tracked_buffer.go +++ b/go/vt/sqlparser/tracked_buffer.go @@ -18,8 +18,11 @@ package sqlparser import ( "fmt" + "reflect" "strconv" "strings" + + "vitess.io/vitess/go/slice" ) // NodeFormatter defines the signature of a custom node formatter @@ -174,15 +177,6 @@ func (buf *TrackedBuffer) astPrintf(currentNode SQLNode, format string, values . } switch format[i] { - case 'c': - switch v := values[fieldnum].(type) { - case byte: - buf.WriteByte(v) - case rune: - buf.WriteRune(v) - default: - panic(fmt.Sprintf("unexpected TrackedBuffer type %T", v)) - } case 's': switch v := values[fieldnum].(type) { case string: @@ -240,14 +234,61 @@ func (buf *TrackedBuffer) astPrintf(currentNode SQLNode, format string, values . } case 'a': buf.WriteArg("", values[fieldnum].(string)) + case 'n': + // used for printing slices of SQLNodes + value := values[fieldnum] + buf.formatNodes(value) default: - panic("unexpected") + panic("unexpected format: " + string(format[i-1:i+1])) } fieldnum++ i++ } } +func (buf *TrackedBuffer) formatExprs(exprs []Expr) { + var prefix string + for _, expr := range exprs { + buf.WriteString(prefix) + buf.formatter(expr) + prefix = ", " + } +} + +func (buf *TrackedBuffer) formatNodes(input any) { + switch nodes := input.(type) { + case []Expr: + buf.formatExprs(nodes) + return + } + + // SLOW PATH! Add specific cases above to avoid reflection. + + // Check if the input is a slice + val := reflect.ValueOf(input) + if val.Kind() != reflect.Slice { + // Handle the error or return if input is not a slice + panic("input is not a slice") + } + + // Iterate over the slice elements + for i := 0; i < val.Len(); i++ { + elem := val.Index(i).Interface() + + // Assert each element implements SQLNode + node, ok := elem.(SQLNode) + if !ok { + // Handle the error or skip non-SQLNode elements + panic("element does not implement SQLNode") + } + + // Now `node` is of type SQLNode + // You can call methods or use it as a SQLNode here + buf.Myprintf("%v", node) + } + +} + func getExpressionForParensEval(checkParens bool, value any) Expr { if checkParens { expr, isExpr := value.(Expr) @@ -388,3 +429,20 @@ func CanonicalString(node SQLNode) string { node.Format(buf) return buf.String() } + +func FormatSlice[T SQLNode](buf *TrackedBuffer, valueExprs []T) { + for _, expr := range valueExprs { + buf.Myprintf("%v", expr) + } +} + +func SliceString[T SQLNode](valueExprs []T) string { + return SliceStringWithSep(valueExprs, ", ") +} + +func SliceStringWithSep[T SQLNode](valueExprs []T, sep string) string { + exprs := slice.Map(valueExprs, func(expr T) string { + return String(expr) + }) + return strings.Join(exprs, sep) +} diff --git a/go/vt/vtctl/workflow/materializer.go b/go/vt/vtctl/workflow/materializer.go index 8cd99d384ee..3e827cbdb6a 100644 --- a/go/vt/vtctl/workflow/materializer.go +++ b/go/vt/vtctl/workflow/materializer.go @@ -233,7 +233,7 @@ func (mz *materializer) generateBinlogSources(ctx context.Context, targetShard * } mappedCols = append(mappedCols, colName) } - subExprs := make(sqlparser.Exprs, 0, len(mappedCols)+2) + subExprs := make([]sqlparser.Expr, 0, len(mappedCols)+2) for _, mappedCol := range mappedCols { subExprs = append(subExprs, mappedCol) } @@ -253,10 +253,7 @@ func (mz *materializer) generateBinlogSources(ctx context.Context, targetShard * subExprs = append(subExprs, sqlparser.NewStrLiteral(vindexName)) subExprs = append(subExprs, sqlparser.NewStrLiteral(key.KeyRangeString(targetShard.KeyRange))) - inKeyRange := &sqlparser.FuncExpr{ - Name: sqlparser.NewIdentifierCI("in_keyrange"), - Exprs: subExprs, - } + inKeyRange := sqlparser.NewFuncExpr("in_keyrange", subExprs...) addFilter(sel, inKeyRange) } if tenantClause != nil { diff --git a/go/vt/vtctl/workflow/stream_migrator.go b/go/vt/vtctl/workflow/stream_migrator.go index 7b4fe69074f..f73c3aa64de 100644 --- a/go/vt/vtctl/workflow/stream_migrator.go +++ b/go/vt/vtctl/workflow/stream_migrator.go @@ -1195,14 +1195,10 @@ func (sm *StreamMigrator) templatizeKeyRange(ctx context.Context, rule *binlogda // There was no in_keyrange expression. Create a new one. vtable := sm.ts.SourceKeyspaceSchema().Tables[rule.Match] - inkr := &sqlparser.FuncExpr{ - Name: sqlparser.NewIdentifierCI("in_keyrange"), - Exprs: sqlparser.Exprs{ - &sqlparser.ColName{Name: vtable.ColumnVindexes[0].Columns[0]}, - sqlparser.NewStrLiteral(vtable.ColumnVindexes[0].Type), - sqlparser.NewStrLiteral("{{.}}"), - }, - } + inkr := sqlparser.NewFuncExpr("in_keyrange", + sqlparser.NewColName(vtable.ColumnVindexes[0].Columns[0].String()), + sqlparser.NewStrLiteral(vtable.ColumnVindexes[0].Type), + sqlparser.NewStrLiteral("{{.}}")) sel.AddWhere(inkr) rule.Filter = sqlparser.String(statement) return nil diff --git a/go/vt/vtctl/workflow/utils.go b/go/vt/vtctl/workflow/utils.go index 571c40b474f..2f7f51ed206 100644 --- a/go/vt/vtctl/workflow/utils.go +++ b/go/vt/vtctl/workflow/utils.go @@ -293,7 +293,7 @@ func forAllShards(shards []*topo.ShardInfo, f func(*topo.ShardInfo) error) error } func matchColInSelect(col sqlparser.IdentifierCI, sel *sqlparser.Select) (*sqlparser.ColName, error) { - for _, selExpr := range sel.SelectExprs { + for _, selExpr := range sel.GetColumns() { switch selExpr := selExpr.(type) { case *sqlparser.StarExpr: return &sqlparser.ColName{Name: col}, nil diff --git a/go/vt/vtexplain/vtexplain_vttablet.go b/go/vt/vtexplain/vtexplain_vttablet.go index 94697c22e91..7918162192a 100644 --- a/go/vt/vtexplain/vtexplain_vttablet.go +++ b/go/vt/vtexplain/vtexplain_vttablet.go @@ -789,7 +789,7 @@ func (t *explainTablet) analyzeWhere(selStmt *sqlparser.Select, tableColumnMap m func (t *explainTablet) analyzeExpressions(selStmt *sqlparser.Select, tableColumnMap map[sqlparser.IdentifierCS]map[string]querypb.Type) ([]string, []querypb.Type) { colNames := make([]string, 0, 4) colTypes := make([]querypb.Type, 0, 4) - for _, node := range selStmt.SelectExprs { + for _, node := range selStmt.GetColumns() { switch node := node.(type) { case *sqlparser.AliasedExpr: colNames, colTypes = inferColTypeFromExpr(node.Expr, tableColumnMap, colNames, colTypes) diff --git a/go/vt/vtgate/engine/insert_test.go b/go/vt/vtgate/engine/insert_test.go index 2de95e5d186..118a2ab0458 100644 --- a/go/vt/vtgate/engine/insert_test.go +++ b/go/vt/vtgate/engine/insert_test.go @@ -340,6 +340,9 @@ func TestInsertShardWithONDuplicateKey(t *testing.T) { ks := vs.Keyspaces["sharded"] // A single row insert should be autocommitted + funcExpr := sqlparser.NewFuncExpr("if", sqlparser.NewComparisonExpr(sqlparser.InOp, &sqlparser.ValuesFuncExpr{Name: sqlparser.NewColName("col")}, sqlparser.ListArg("_id_1"), nil), + sqlparser.NewColName("col"), + &sqlparser.ValuesFuncExpr{Name: sqlparser.NewColName("col")}) ins := newInsert( InsertSharded, false, @@ -356,15 +359,8 @@ func TestInsertShardWithONDuplicateKey(t *testing.T) { {&sqlparser.Argument{Name: "_id_0", Type: sqltypes.Int64}}, }, sqlparser.OnDup{ - &sqlparser.UpdateExpr{Name: sqlparser.NewColName("suffix1"), Expr: &sqlparser.Argument{Name: "_id_0", Type: sqltypes.Int64}}, - &sqlparser.UpdateExpr{Name: sqlparser.NewColName("suffix2"), Expr: &sqlparser.FuncExpr{ - Name: sqlparser.NewIdentifierCI("if"), - Exprs: sqlparser.Exprs{ - sqlparser.NewComparisonExpr(sqlparser.InOp, &sqlparser.ValuesFuncExpr{Name: sqlparser.NewColName("col")}, sqlparser.ListArg("_id_1"), nil), - sqlparser.NewColName("col"), - &sqlparser.ValuesFuncExpr{Name: sqlparser.NewColName("col")}, - }, - }}}, + &sqlparser.UpdateExpr{Name: sqlparser.NewColName("suffix1"), Expr: sqlparser.NewTypedArgument("_id_0", sqltypes.Int64)}, + &sqlparser.UpdateExpr{Name: sqlparser.NewColName("suffix2"), Expr: funcExpr}}, ) vc := newDMLTestVCursor("-20", "20-") vc.shardForKsid = []string{"20-", "-20", "20-"} diff --git a/go/vt/vtgate/evalengine/expr_env_test.go b/go/vt/vtgate/evalengine/expr_env_test.go index f75cc6f1376..1206ac42f0a 100644 --- a/go/vt/vtgate/evalengine/expr_env_test.go +++ b/go/vt/vtgate/evalengine/expr_env_test.go @@ -42,7 +42,7 @@ func TestExpressionEnvTypeOf(t *testing.T) { Type: sqltypes.Unknown, Offset: 1, Original: &sqlparser.Count{ - Args: sqlparser.Exprs{ + Args: []sqlparser.Expr{ sqlparser.NewColName("l_discount"), }, }, diff --git a/go/vt/vtgate/evalengine/integration/fuzz_test.go b/go/vt/vtgate/evalengine/integration/fuzz_test.go index 7372d6fd731..a16f6164b35 100644 --- a/go/vt/vtgate/evalengine/integration/fuzz_test.go +++ b/go/vt/vtgate/evalengine/integration/fuzz_test.go @@ -137,7 +137,7 @@ func evaluateLocalEvalengine(env *evalengine.ExpressionEnv, query string, fields return evalengine.EvalResult{}, err } - astExpr := stmt.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr + astExpr := stmt.(*sqlparser.Select).SelectExprs.Exprs[0].(*sqlparser.AliasedExpr).Expr local, err := func() (expr evalengine.Expr, err error) { defer func() { if r := recover(); r != nil { @@ -239,7 +239,7 @@ func TestGenerateFuzzCases(t *testing.T) { t.Fatal(err) } - astExpr := stmt.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr + astExpr := stmt.(*sqlparser.Select).SelectExprs.Exprs[0].(*sqlparser.AliasedExpr).Expr if fail := compareWithMySQL(astExpr); fail != nil { failures = append(failures, fail) diff --git a/go/vt/vtgate/evalengine/mysql_test.go b/go/vt/vtgate/evalengine/mysql_test.go index 6434d7dcfbf..61bd6e3af1e 100644 --- a/go/vt/vtgate/evalengine/mysql_test.go +++ b/go/vt/vtgate/evalengine/mysql_test.go @@ -74,7 +74,7 @@ func convert(t *testing.T, query string, simplify bool) (Expr, error) { NoConstantFolding: !simplify, } - astExpr := stmt.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr + astExpr := stmt.(*sqlparser.Select).SelectExprs.Exprs[0].(*sqlparser.AliasedExpr).Expr converted, err := Translate(astExpr, cfg) if err == nil { if knownBadQuery(converted) { diff --git a/go/vt/vtgate/evalengine/translate_test.go b/go/vt/vtgate/evalengine/translate_test.go index 2bebae548e1..715b773398a 100644 --- a/go/vt/vtgate/evalengine/translate_test.go +++ b/go/vt/vtgate/evalengine/translate_test.go @@ -134,7 +134,7 @@ func TestTranslateSimplification(t *testing.T) { NoCompilation: true, } - astExpr := stmt.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr + astExpr := stmt.(*sqlparser.Select).SelectExprs.Exprs[0].(*sqlparser.AliasedExpr).Expr converted, err := Translate(astExpr, cfg) if err != nil { if tc.converted.err == "" { @@ -305,7 +305,7 @@ func TestEvaluate(t *testing.T) { // Given stmt, err := sqlparser.NewTestParser().Parse("select " + test.expression) require.NoError(t, err) - astExpr := stmt.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr + astExpr := stmt.(*sqlparser.Select).SelectExprs.Exprs[0].(*sqlparser.AliasedExpr).Expr sqltypesExpr, err := Translate(astExpr, &Config{ Collation: venv.CollationEnv().DefaultConnectionCharset(), Environment: venv, @@ -354,7 +354,7 @@ func TestEvaluateTuple(t *testing.T) { // Given stmt, err := sqlparser.NewTestParser().Parse("select " + test.expression) require.NoError(t, err) - astExpr := stmt.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr + astExpr := stmt.(*sqlparser.Select).SelectExprs.Exprs[0].(*sqlparser.AliasedExpr).Expr sqltypesExpr, err := Translate(astExpr, &Config{ Collation: venv.CollationEnv().DefaultConnectionCharset(), Environment: venv, @@ -395,7 +395,7 @@ func TestTranslationFailures(t *testing.T) { // Given stmt, err := sqlparser.NewTestParser().Parse("select " + testcase.expression) require.NoError(t, err) - astExpr := stmt.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr + astExpr := stmt.(*sqlparser.Select).SelectExprs.Exprs[0].(*sqlparser.AliasedExpr).Expr _, err = Translate(astExpr, &Config{ Collation: venv.CollationEnv().DefaultConnectionCharset(), Environment: venv, @@ -435,7 +435,7 @@ func TestCardinalityWithBindVariables(t *testing.T) { return err } - astExpr := stmt.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr + astExpr := stmt.(*sqlparser.Select).SelectExprs.Exprs[0].(*sqlparser.AliasedExpr).Expr _, err = Translate(astExpr, &Config{ Collation: venv.CollationEnv().DefaultConnectionCharset(), Environment: venv, diff --git a/go/vt/vtgate/planbuilder/ddl.go b/go/vt/vtgate/planbuilder/ddl.go index 1359da1c0a8..112d0280813 100644 --- a/go/vt/vtgate/planbuilder/ddl.go +++ b/go/vt/vtgate/planbuilder/ddl.go @@ -211,7 +211,7 @@ func buildCreateViewCommon( } // because we don't trust the schema tracker to have up-to-date info, we don't want to expand any SELECT * here - var expressions []sqlparser.SelectExprs + var expressions []*sqlparser.SelectExprs _ = sqlparser.VisitAllSelects(ddlSelect, func(p *sqlparser.Select, idx int) error { expressions = append(expressions, sqlparser.Clone(p.SelectExprs)) return nil @@ -252,7 +252,7 @@ func createViewEnabled(vschema plancontext.VSchema, reservedVars *sqlparser.Rese // views definition with `select *` should not be expanded as schema tracker might not be up-to-date // We copy the expressions and restore them after the planning context is created - var expressions []sqlparser.SelectExprs + var expressions []*sqlparser.SelectExprs _ = sqlparser.VisitAllSelects(ddlSelect, func(p *sqlparser.Select, idx int) error { expressions = append(expressions, sqlparser.Clone(p.SelectExprs)) return nil diff --git a/go/vt/vtgate/planbuilder/expression_converter_test.go b/go/vt/vtgate/planbuilder/expression_converter_test.go index c92cc184262..0204324e978 100644 --- a/go/vt/vtgate/planbuilder/expression_converter_test.go +++ b/go/vt/vtgate/planbuilder/expression_converter_test.go @@ -19,6 +19,8 @@ package planbuilder import ( "testing" + "vitess.io/vitess/go/slice" + "github.com/stretchr/testify/require" "vitess.io/vitess/go/vt/sqlparser" @@ -66,10 +68,8 @@ func TestConversion(t *testing.T) { } } -func extract(in sqlparser.SelectExprs) []sqlparser.Expr { - var result []sqlparser.Expr - for _, expr := range in { - result = append(result, expr.(*sqlparser.AliasedExpr).Expr) - } - return result +func extract(in *sqlparser.SelectExprs) []sqlparser.Expr { + return slice.Map(in.Exprs, func(i sqlparser.SelectExpr) sqlparser.Expr { + return i.(*sqlparser.AliasedExpr).Expr + }) } diff --git a/go/vt/vtgate/planbuilder/operator_transformers.go b/go/vt/vtgate/planbuilder/operator_transformers.go index 807912110df..1b3313b540a 100644 --- a/go/vt/vtgate/planbuilder/operator_transformers.go +++ b/go/vt/vtgate/planbuilder/operator_transformers.go @@ -689,9 +689,9 @@ func autoIncGenerate(gen *operators.Generate) *engine.Generate { return nil } selNext := &sqlparser.Select{ - From: []sqlparser.TableExpr{&sqlparser.AliasedTableExpr{Expr: gen.TableName}}, - SelectExprs: sqlparser.SelectExprs{&sqlparser.Nextval{Expr: &sqlparser.Argument{Name: "n", Type: sqltypes.Int64}}}, + From: []sqlparser.TableExpr{&sqlparser.AliasedTableExpr{Expr: gen.TableName}}, } + selNext.AddSelectExpr(&sqlparser.Nextval{Expr: &sqlparser.Argument{Name: "n", Type: sqltypes.Int64}}) return &engine.Generate{ Keyspace: gen.Keyspace, Query: sqlparser.String(selNext), diff --git a/go/vt/vtgate/planbuilder/operators/SQL_builder.go b/go/vt/vtgate/planbuilder/operators/SQL_builder.go index ca15b5c9134..0b8013a8737 100644 --- a/go/vt/vtgate/planbuilder/operators/SQL_builder.go +++ b/go/vt/vtgate/planbuilder/operators/SQL_builder.go @@ -163,7 +163,7 @@ func (qb *queryBuilder) setWithRollup() { func (qb *queryBuilder) addProjection(projection sqlparser.SelectExpr) { switch stmt := qb.stmt.(type) { case *sqlparser.Select: - stmt.SelectExprs = append(stmt.SelectExprs, projection) + stmt.AddSelectExpr(projection) return case *sqlparser.Union: if ae, ok := projection.(*sqlparser.AliasedExpr); ok { @@ -193,11 +193,12 @@ func (qb *queryBuilder) pushUnionInsideDerived() { }}, } firstSelect := getFirstSelect(selStmt) - sel.SelectExprs = unionSelects(firstSelect.SelectExprs) + sel.SetSelectExprs(unionSelects(firstSelect.GetColumns())...) qb.stmt = sel } -func unionSelects(exprs sqlparser.SelectExprs) (selectExprs sqlparser.SelectExprs) { +func unionSelects(exprs []sqlparser.SelectExpr) []sqlparser.SelectExpr { + var selectExprs []sqlparser.SelectExpr for _, col := range exprs { switch col := col.(type) { case *sqlparser.AliasedExpr: @@ -207,13 +208,13 @@ func unionSelects(exprs sqlparser.SelectExprs) (selectExprs sqlparser.SelectExpr selectExprs = append(selectExprs, col) } } - return + return selectExprs } func checkUnionColumnByName(column *sqlparser.ColName, sel sqlparser.TableStatement) { colName := column.Name.String() firstSelect := getFirstSelect(sel) - exprs := firstSelect.SelectExprs + exprs := firstSelect.GetColumns() offset := slices.IndexFunc(exprs, func(expr sqlparser.SelectExpr) bool { switch ae := expr.(type) { case *sqlparser.StarExpr: @@ -283,7 +284,9 @@ func (qb *queryBuilder) joinWith(other *queryBuilder, onCondition sqlparser.Expr if sel, isSel := stmt.(*sqlparser.Select); isSel { otherSel := otherStmt.(*sqlparser.Select) - sel.SelectExprs = append(sel.SelectExprs, otherSel.SelectExprs...) + for _, expr := range otherSel.GetColumns() { + sel.AddSelectExpr(expr) + } } qb.mergeWhereClauses(stmt, otherStmt) @@ -410,7 +413,7 @@ func stripDownQuery(from, to sqlparser.TableStatement) { toNode.Comments = node.Comments toNode.Limit = node.Limit toNode.SelectExprs = node.SelectExprs - for _, expr := range toNode.SelectExprs { + for _, expr := range toNode.SelectExprs.Exprs { removeKeyspaceFromSelectExpr(expr) } case *sqlparser.Union: @@ -599,8 +602,7 @@ func buildProjection(op *Projection, qb *queryBuilder) { } if !isSel { - cols := op.GetSelectExprs(qb.ctx) - for _, column := range cols { + for _, column := range op.GetSelectExprs(qb.ctx) { qb.addProjection(column) } } diff --git a/go/vt/vtgate/planbuilder/operators/aggregation_pushing.go b/go/vt/vtgate/planbuilder/operators/aggregation_pushing.go index ced81df147a..b11f49fe936 100644 --- a/go/vt/vtgate/planbuilder/operators/aggregation_pushing.go +++ b/go/vt/vtgate/planbuilder/operators/aggregation_pushing.go @@ -206,9 +206,9 @@ func pushAggregations(ctx *plancontext.PlanningContext, aggregator *Aggregator, } } -func checkIfWeCanPush(ctx *plancontext.PlanningContext, aggregator *Aggregator) (bool, sqlparser.Exprs) { +func checkIfWeCanPush(ctx *plancontext.PlanningContext, aggregator *Aggregator) (bool, []sqlparser.Expr) { canPush := true - var distinctExprs sqlparser.Exprs + var distinctExprs []sqlparser.Expr var differentExpr *sqlparser.AliasedExpr for _, aggr := range aggregator.Aggregations { @@ -574,13 +574,7 @@ outer: func coalesceFunc(e sqlparser.Expr) sqlparser.Expr { // `coalesce(e,1)` will return `e` if `e` is not `NULL`, otherwise it will return `1` - return &sqlparser.FuncExpr{ - Name: sqlparser.NewIdentifierCI("coalesce"), - Exprs: sqlparser.Exprs{ - e, - sqlparser.NewIntLiteral("1"), - }, - } + return sqlparser.NewFuncExpr("coalesce", e, sqlparser.NewIntLiteral("1")) } func initColReUse(size int) []int { diff --git a/go/vt/vtgate/planbuilder/operators/aggregator.go b/go/vt/vtgate/planbuilder/operators/aggregator.go index f353ee02d1e..1a96e81b66e 100644 --- a/go/vt/vtgate/planbuilder/operators/aggregator.go +++ b/go/vt/vtgate/planbuilder/operators/aggregator.go @@ -309,7 +309,7 @@ func (a *Aggregator) GetColumns(ctx *plancontext.PlanningContext) (res []*sqlpar return truncate(a, a.Columns) } -func (a *Aggregator) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (a *Aggregator) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return transformColumnsToSelectExprs(ctx, a) } @@ -400,10 +400,10 @@ func (a *Aggregator) planOffsets(ctx *plancontext.PlanningContext) Operator { return nil } -func (aggr Aggr) setPushColumn(exprs sqlparser.Exprs) { +func (aggr Aggr) setPushColumn(exprs []sqlparser.Expr) { if aggr.Func == nil { if len(exprs) > 1 { - panic(vterrors.VT13001(fmt.Sprintf("unexpected number of expression in an random aggregation: %s", sqlparser.String(exprs)))) + panic(vterrors.VT13001(fmt.Sprintf("unexpected number of expression in an random aggregation: %s", sqlparser.SliceString(exprs)))) } aggr.Original.Expr = exprs[0] return @@ -434,12 +434,12 @@ func (aggr Aggr) getPushColumn() sqlparser.Expr { } } -func (aggr Aggr) getPushColumnExprs() sqlparser.Exprs { +func (aggr Aggr) getPushColumnExprs() []sqlparser.Expr { switch aggr.OpCode { case opcode.AggregateAnyValue: - return sqlparser.Exprs{aggr.Original.Expr} + return []sqlparser.Expr{aggr.Original.Expr} case opcode.AggregateCountStar: - return sqlparser.Exprs{sqlparser.NewIntLiteral("1")} + return []sqlparser.Expr{sqlparser.NewIntLiteral("1")} case opcode.AggregateUDF: // AggregateUDFs can't be evaluated on the vtgate. So either we are able to push everything down, or we will have to fail the query. return nil diff --git a/go/vt/vtgate/planbuilder/operators/apply_join.go b/go/vt/vtgate/planbuilder/operators/apply_join.go index 80bf74708a8..2297227a22d 100644 --- a/go/vt/vtgate/planbuilder/operators/apply_join.go +++ b/go/vt/vtgate/planbuilder/operators/apply_join.go @@ -180,7 +180,7 @@ func (aj *ApplyJoin) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.A return cols } -func (aj *ApplyJoin) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (aj *ApplyJoin) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return transformColumnsToSelectExprs(ctx, aj) } @@ -414,7 +414,7 @@ func (aj *ApplyJoin) findOrAddColNameBindVarName(ctx *plancontext.PlanningContex return bvName } -func (aj *ApplyJoin) LHSColumnsNeeded(ctx *plancontext.PlanningContext) (needed sqlparser.Exprs) { +func (aj *ApplyJoin) LHSColumnsNeeded(ctx *plancontext.PlanningContext) (needed []sqlparser.Expr) { f := func(from BindVarExpr) sqlparser.Expr { return from.Expr } diff --git a/go/vt/vtgate/planbuilder/operators/ast_to_op.go b/go/vt/vtgate/planbuilder/operators/ast_to_op.go index 2e3781c94db..009f2c7c265 100644 --- a/go/vt/vtgate/planbuilder/operators/ast_to_op.go +++ b/go/vt/vtgate/planbuilder/operators/ast_to_op.go @@ -137,8 +137,8 @@ func findTablesContained(ctx *plancontext.PlanningContext, node sqlparser.SQLNod // comparisons between the inner and the outer side. // They can be used for merging the two parts of the query together type joinPredicateCollector struct { - predicates sqlparser.Exprs - remainingPredicates sqlparser.Exprs + predicates []sqlparser.Expr + remainingPredicates []sqlparser.Expr joinColumns []applyJoinColumn totalID, @@ -174,7 +174,7 @@ func createOperatorFromUnion(ctx *plancontext.PlanningContext, node *sqlparser.U rexprs := ctx.SemTable.SelectExprs(node.Right) unionCols := ctx.SemTable.SelectExprs(node) - union := newUnion([]Operator{opLHS, opRHS}, []sqlparser.SelectExprs{lexprs, rexprs}, unionCols, node.Distinct) + union := newUnion([]Operator{opLHS, opRHS}, [][]sqlparser.SelectExpr{lexprs, rexprs}, unionCols, node.Distinct) return newHorizon(union, node) } @@ -464,7 +464,7 @@ func createSelectionOp( lock sqlparser.Lock, ) Operator { selectionStmt := &sqlparser.Select{ - SelectExprs: selectExprs, + SelectExprs: &sqlparser.SelectExprs{Exprs: selectExprs}, From: tableExprs, Where: where, OrderBy: orderBy, diff --git a/go/vt/vtgate/planbuilder/operators/comments.go b/go/vt/vtgate/planbuilder/operators/comments.go index 9f0202c250a..445160e3d40 100644 --- a/go/vt/vtgate/planbuilder/operators/comments.go +++ b/go/vt/vtgate/planbuilder/operators/comments.go @@ -66,7 +66,7 @@ func (l *LockAndComment) GetColumns(ctx *plancontext.PlanningContext) []*sqlpars return l.Source.GetColumns(ctx) } -func (l *LockAndComment) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (l *LockAndComment) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return l.Source.GetSelectExprs(ctx) } diff --git a/go/vt/vtgate/planbuilder/operators/delete.go b/go/vt/vtgate/planbuilder/operators/delete.go index 23c909e0a04..b16f9b8aacf 100644 --- a/go/vt/vtgate/planbuilder/operators/delete.go +++ b/go/vt/vtgate/planbuilder/operators/delete.go @@ -136,7 +136,7 @@ func createDeleteWithInputOp(ctx *plancontext.PlanningContext, del *sqlparser.De dmls := slice.Map(delOps, func(from dmlOp) Operator { colsList = append(colsList, from.cols) for _, col := range from.cols { - selectStmt.SelectExprs = append(selectStmt.SelectExprs, aeWrap(col)) + selectStmt.AddSelectExpr(aeWrap(col)) } return from.op }) @@ -264,7 +264,7 @@ func createDeleteOperator(ctx *plancontext.PlanningContext, del *sqlparser.Delet } func generateOwnedVindexQuery(del *sqlparser.Delete, table TargetTable, ksidCols []sqlparser.IdentifierCI) *sqlparser.Select { - var selExprs sqlparser.SelectExprs + var selExprs []sqlparser.SelectExpr for _, col := range ksidCols { colName := makeColName(col, table, sqlparser.MultiTable(del.TableExprs)) selExprs = append(selExprs, aeWrap(colName)) @@ -275,12 +275,13 @@ func generateOwnedVindexQuery(del *sqlparser.Delete, table TargetTable, ksidCols selExprs = append(selExprs, aeWrap(colName)) } } - return &sqlparser.Select{ - SelectExprs: selExprs, - OrderBy: del.OrderBy, - Limit: del.Limit, - Lock: sqlparser.ForUpdateLock, + sel := &sqlparser.Select{ + OrderBy: del.OrderBy, + Limit: del.Limit, + Lock: sqlparser.ForUpdateLock, } + sel.SetSelectExprs(selExprs...) + return sel } func makeColName(col sqlparser.IdentifierCI, table TargetTable, isMultiTbl bool) *sqlparser.ColName { diff --git a/go/vt/vtgate/planbuilder/operators/distinct.go b/go/vt/vtgate/planbuilder/operators/distinct.go index 52221498eea..00c9512af58 100644 --- a/go/vt/vtgate/planbuilder/operators/distinct.go +++ b/go/vt/vtgate/planbuilder/operators/distinct.go @@ -100,7 +100,7 @@ func (d *Distinct) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.Ali return truncate(d, d.Source.GetColumns(ctx)) } -func (d *Distinct) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (d *Distinct) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return truncate(d, d.Source.GetSelectExprs(ctx)) } diff --git a/go/vt/vtgate/planbuilder/operators/filter.go b/go/vt/vtgate/planbuilder/operators/filter.go index d58d218908e..431461d4ab1 100644 --- a/go/vt/vtgate/planbuilder/operators/filter.go +++ b/go/vt/vtgate/planbuilder/operators/filter.go @@ -92,7 +92,7 @@ func (f *Filter) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.Alias return truncate(f, f.Source.GetColumns(ctx)) } -func (f *Filter) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (f *Filter) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return truncate(f, f.Source.GetSelectExprs(ctx)) } diff --git a/go/vt/vtgate/planbuilder/operators/hash_join.go b/go/vt/vtgate/planbuilder/operators/hash_join.go index 3761c4b87a6..f8724f5221b 100644 --- a/go/vt/vtgate/planbuilder/operators/hash_join.go +++ b/go/vt/vtgate/planbuilder/operators/hash_join.go @@ -196,7 +196,7 @@ func (hj *HashJoin) GetColumns(*plancontext.PlanningContext) []*sqlparser.Aliase }) } -func (hj *HashJoin) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (hj *HashJoin) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return transformColumnsToSelectExprs(ctx, hj) } diff --git a/go/vt/vtgate/planbuilder/operators/horizon.go b/go/vt/vtgate/planbuilder/operators/horizon.go index aa7737001d6..33070f5802b 100644 --- a/go/vt/vtgate/planbuilder/operators/horizon.go +++ b/go/vt/vtgate/planbuilder/operators/horizon.go @@ -148,7 +148,7 @@ func (h *Horizon) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, return -1 } - for idx, se := range getFirstSelect(h.Query).SelectExprs { + for idx, se := range getFirstSelect(h.Query).GetColumns() { ae, ok := se.(*sqlparser.AliasedExpr) if !ok { panic(vterrors.VT09015()) @@ -173,8 +173,8 @@ func (h *Horizon) GetColumns(ctx *plancontext.PlanningContext) (exprs []*sqlpars return exprs } -func (h *Horizon) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs { - return getFirstSelect(h.Query).SelectExprs +func (h *Horizon) GetSelectExprs(*plancontext.PlanningContext) []sqlparser.SelectExpr { + return getFirstSelect(h.Query).GetColumns() } func (h *Horizon) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy { diff --git a/go/vt/vtgate/planbuilder/operators/horizon_expanding.go b/go/vt/vtgate/planbuilder/operators/horizon_expanding.go index dad5ad3a91a..f60b7996714 100644 --- a/go/vt/vtgate/planbuilder/operators/horizon_expanding.go +++ b/go/vt/vtgate/planbuilder/operators/horizon_expanding.go @@ -235,7 +235,7 @@ func createProjectionWithAggr(ctx *plancontext.PlanningContext, qp *QueryProject func pullOutValueSubqueries(ctx *plancontext.PlanningContext, aggr Aggr, sqc *SubQueryBuilder, outerID semantics.TableSet) Aggr { exprs := aggr.getPushColumnExprs() - var newExprs sqlparser.Exprs + var newExprs []sqlparser.Expr for _, expr := range exprs { newExpr, subqs := sqc.pullOutValueSubqueries(ctx, expr, outerID, false) if newExpr != nil { @@ -344,7 +344,7 @@ func createProjectionWithoutAggr(ctx *plancontext.PlanningContext, qp *QueryProj } func newStarProjection(src Operator, qp *QueryProjection) *Projection { - cols := sqlparser.SelectExprs{} + var cols []sqlparser.SelectExpr for _, expr := range qp.SelectExprs { _ = sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) { diff --git a/go/vt/vtgate/planbuilder/operators/info_schema_planning.go b/go/vt/vtgate/planbuilder/operators/info_schema_planning.go index f8dc9b9d281..1e15237f30d 100644 --- a/go/vt/vtgate/planbuilder/operators/info_schema_planning.go +++ b/go/vt/vtgate/planbuilder/operators/info_schema_planning.go @@ -196,7 +196,7 @@ func tryMergeInfoSchemaRoutings(ctx *plancontext.PlanningContext, routingA, rout return m.merge(ctx, lhsRoute, rhsRoute, isrA) // if both sides have the same schema predicate, we can safely merge them - case sqlparser.Equals.Exprs(isrA.SysTableTableSchema, isrB.SysTableTableSchema): + case equalExprs(isrA.SysTableTableSchema, isrB.SysTableTableSchema): for k, expr := range isrB.SysTableTableName { isrA.SysTableTableName[k] = expr } @@ -208,6 +208,18 @@ func tryMergeInfoSchemaRoutings(ctx *plancontext.PlanningContext, routingA, rout } } +func equalExprs(a, b []sqlparser.Expr) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if !sqlparser.Equals.Expr(a[i], b[i]) { + return false + } + } + return true +} + var ( // these are filled in by the init() function below schemaColumns57 = map[string]any{} diff --git a/go/vt/vtgate/planbuilder/operators/insert.go b/go/vt/vtgate/planbuilder/operators/insert.go index f6d86d49ca2..dde07685ff0 100644 --- a/go/vt/vtgate/planbuilder/operators/insert.go +++ b/go/vt/vtgate/planbuilder/operators/insert.go @@ -266,7 +266,7 @@ func uniqKeyCompExpressions(vTbl *vindexes.BaseTable, ins *sqlparser.Insert, row type uIdx struct { Indexes [][]uComp - uniqKey sqlparser.Exprs + uniqKey []sqlparser.Expr } allIndexes := make([]uIdx, 0, noOfUniqKeys) @@ -470,7 +470,7 @@ func columnMismatch(gen *Generate, ins *sqlparser.Insert, sel sqlparser.TableSta if origColCount > sel.GetColumnCount() { sel := getFirstSelect(sel) var hasStarExpr bool - for _, sExpr := range sel.SelectExprs { + for _, sExpr := range sel.GetColumns() { if _, hasStarExpr = sExpr.(*sqlparser.StarExpr); hasStarExpr { break } diff --git a/go/vt/vtgate/planbuilder/operators/limit.go b/go/vt/vtgate/planbuilder/operators/limit.go index 4549b85fcda..0a0525562eb 100644 --- a/go/vt/vtgate/planbuilder/operators/limit.go +++ b/go/vt/vtgate/planbuilder/operators/limit.go @@ -69,7 +69,7 @@ func (l *Limit) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.Aliase return l.Source.GetColumns(ctx) } -func (l *Limit) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (l *Limit) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return l.Source.GetSelectExprs(ctx) } diff --git a/go/vt/vtgate/planbuilder/operators/mirror.go b/go/vt/vtgate/planbuilder/operators/mirror.go index 82a431af0a2..23448b3fad6 100644 --- a/go/vt/vtgate/planbuilder/operators/mirror.go +++ b/go/vt/vtgate/planbuilder/operators/mirror.go @@ -75,7 +75,7 @@ func (m *PercentBasedMirror) GetColumns(ctx *plancontext.PlanningContext) []*sql return m.Operator().GetColumns(ctx) } -func (m *PercentBasedMirror) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (m *PercentBasedMirror) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return m.Operator().GetSelectExprs(ctx) } diff --git a/go/vt/vtgate/planbuilder/operators/operator.go b/go/vt/vtgate/planbuilder/operators/operator.go index 42658e4c52e..6e9c10ab951 100644 --- a/go/vt/vtgate/planbuilder/operators/operator.go +++ b/go/vt/vtgate/planbuilder/operators/operator.go @@ -72,7 +72,7 @@ type ( FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr - GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs + GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr ShortDescription() string diff --git a/go/vt/vtgate/planbuilder/operators/ordering.go b/go/vt/vtgate/planbuilder/operators/ordering.go index 7e40b420f9e..367cb3c75b1 100644 --- a/go/vt/vtgate/planbuilder/operators/ordering.go +++ b/go/vt/vtgate/planbuilder/operators/ordering.go @@ -72,7 +72,7 @@ func (o *Ordering) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.Ali return truncate(o, o.Source.GetColumns(ctx)) } -func (o *Ordering) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (o *Ordering) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return truncate(o, o.Source.GetSelectExprs(ctx)) } diff --git a/go/vt/vtgate/planbuilder/operators/plan_query.go b/go/vt/vtgate/planbuilder/operators/plan_query.go index dc83c89c72c..1bb619e3503 100644 --- a/go/vt/vtgate/planbuilder/operators/plan_query.go +++ b/go/vt/vtgate/planbuilder/operators/plan_query.go @@ -147,7 +147,7 @@ func (noColumns) FindCol(*plancontext.PlanningContext, sqlparser.Expr, bool) int panic(vterrors.VT13001("noColumns operators have no column")) } -func (noColumns) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs { +func (noColumns) GetSelectExprs(*plancontext.PlanningContext) []sqlparser.SelectExpr { panic(vterrors.VT13001("noColumns operators have no column")) } @@ -192,7 +192,7 @@ func tryTruncateColumnsAt(op Operator, truncateAt int) bool { } } -func transformColumnsToSelectExprs(ctx *plancontext.PlanningContext, op Operator) sqlparser.SelectExprs { +func transformColumnsToSelectExprs(ctx *plancontext.PlanningContext, op Operator) []sqlparser.SelectExpr { columns := op.GetColumns(ctx) if trunc, ok := op.(columnTruncator); ok { count := trunc.getTruncateColumnCount() @@ -201,8 +201,7 @@ func transformColumnsToSelectExprs(ctx *plancontext.PlanningContext, op Operator } } - selExprs := slice.Map(columns, func(from *sqlparser.AliasedExpr) sqlparser.SelectExpr { + return slice.Map(columns, func(from *sqlparser.AliasedExpr) sqlparser.SelectExpr { return from }) - return selExprs } diff --git a/go/vt/vtgate/planbuilder/operators/projection.go b/go/vt/vtgate/planbuilder/operators/projection.go index e894ab433b4..0f59d445714 100644 --- a/go/vt/vtgate/planbuilder/operators/projection.go +++ b/go/vt/vtgate/planbuilder/operators/projection.go @@ -76,11 +76,11 @@ type ( // ProjCols is used to enable projections that are only valid if we can push them into a route, and we never need to ask it about offsets ProjCols interface { GetColumns() []*sqlparser.AliasedExpr - GetSelectExprs() sqlparser.SelectExprs + GetSelectExprs() []sqlparser.SelectExpr } // Used when there are stars in the expressions that we were unable to expand - StarProjections sqlparser.SelectExprs + StarProjections []sqlparser.SelectExpr // Used when we know all the columns AliasedProjections []*ProjExpr @@ -136,8 +136,8 @@ func (sp StarProjections) GetColumns() []*sqlparser.AliasedExpr { panic(vterrors.VT09015()) } -func (sp StarProjections) GetSelectExprs() sqlparser.SelectExprs { - return sqlparser.SelectExprs(sp) +func (sp StarProjections) GetSelectExprs() []sqlparser.SelectExpr { + return sp } func (ap AliasedProjections) GetColumns() []*sqlparser.AliasedExpr { @@ -146,7 +146,7 @@ func (ap AliasedProjections) GetColumns() []*sqlparser.AliasedExpr { }) } -func (ap AliasedProjections) GetSelectExprs() sqlparser.SelectExprs { +func (ap AliasedProjections) GetSelectExprs() []sqlparser.SelectExpr { return slice.Map(ap, func(from *ProjExpr) sqlparser.SelectExpr { return aeWrap(from.ColExpr) }) @@ -420,12 +420,12 @@ func (p *Projection) GetColumns(*plancontext.PlanningContext) []*sqlparser.Alias return p.Columns.GetColumns() } -func (p *Projection) GetSelectExprs(*plancontext.PlanningContext) sqlparser.SelectExprs { +func (p *Projection) GetSelectExprs(*plancontext.PlanningContext) []sqlparser.SelectExpr { switch cols := p.Columns.(type) { case StarProjections: - return sqlparser.SelectExprs(cols) + return cols case AliasedProjections: - var output sqlparser.SelectExprs + var output []sqlparser.SelectExpr for _, pe := range cols { ae := &sqlparser.AliasedExpr{Expr: pe.EvalExpr} if pe.Original.As.NotEmpty() { diff --git a/go/vt/vtgate/planbuilder/operators/query_planning.go b/go/vt/vtgate/planbuilder/operators/query_planning.go index db716966d47..f70392252c1 100644 --- a/go/vt/vtgate/planbuilder/operators/query_planning.go +++ b/go/vt/vtgate/planbuilder/operators/query_planning.go @@ -30,10 +30,10 @@ import ( ) func planQuery(ctx *plancontext.PlanningContext, root Operator) Operator { - var selExpr sqlparser.SelectExprs + var selExpr []sqlparser.SelectExpr if horizon, isHorizon := root.(*Horizon); isHorizon { sel := getFirstSelect(horizon.Query) - selExpr = sqlparser.Clone(sel.SelectExprs) + selExpr = sqlparser.Clone(sel.SelectExprs).Exprs } output := runPhases(ctx, root) @@ -805,7 +805,7 @@ func tryPushUnion(ctx *plancontext.PlanningContext, op *Union) (Operator, *Apply } var sources []Operator - var selects []sqlparser.SelectExprs + var selects [][]sqlparser.SelectExpr if op.distinct { sources, selects = mergeUnionInputInAnyOrder(ctx, op) @@ -829,7 +829,7 @@ func tryPushUnion(ctx *plancontext.PlanningContext, op *Union) (Operator, *Apply } // addTruncationOrProjectionToReturnOutput uses the original Horizon to make sure that the output columns line up with what the user asked for -func addTruncationOrProjectionToReturnOutput(ctx *plancontext.PlanningContext, selExprs sqlparser.SelectExprs, output Operator) Operator { +func addTruncationOrProjectionToReturnOutput(ctx *plancontext.PlanningContext, selExprs []sqlparser.SelectExpr, output Operator) Operator { if len(selExprs) == 0 { return output } @@ -843,7 +843,7 @@ func addTruncationOrProjectionToReturnOutput(ctx *plancontext.PlanningContext, s return createSimpleProjection(ctx, selExprs, output) } -func colNamesAlign(expected, actual sqlparser.SelectExprs) bool { +func colNamesAlign(expected, actual []sqlparser.SelectExpr) bool { if len(expected) > len(actual) { // if we expect more columns than we have, we can't align return false diff --git a/go/vt/vtgate/planbuilder/operators/queryprojection.go b/go/vt/vtgate/planbuilder/operators/queryprojection.go index c66bf757dd8..073e320fff1 100644 --- a/go/vt/vtgate/planbuilder/operators/queryprojection.go +++ b/go/vt/vtgate/planbuilder/operators/queryprojection.go @@ -176,7 +176,7 @@ func createQPFromSelect(ctx *plancontext.PlanningContext, sel *sqlparser.Select) } func (qp *QueryProjection) addSelectExpressions(ctx *plancontext.PlanningContext, sel *sqlparser.Select) { - for _, selExp := range sel.SelectExprs { + for _, selExp := range sel.GetColumns() { switch selExp := selExp.(type) { case *sqlparser.AliasedExpr: col := SelectExpr{ diff --git a/go/vt/vtgate/planbuilder/operators/recurse_cte.go b/go/vt/vtgate/planbuilder/operators/recurse_cte.go index 61474b663d6..cbd31897479 100644 --- a/go/vt/vtgate/planbuilder/operators/recurse_cte.go +++ b/go/vt/vtgate/planbuilder/operators/recurse_cte.go @@ -147,7 +147,7 @@ func (r *RecurseCTE) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.A return r.Seed().GetColumns(ctx) } -func (r *RecurseCTE) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (r *RecurseCTE) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return r.Seed().GetSelectExprs(ctx) } diff --git a/go/vt/vtgate/planbuilder/operators/route.go b/go/vt/vtgate/planbuilder/operators/route.go index 904d5085718..9aeafec2799 100644 --- a/go/vt/vtgate/planbuilder/operators/route.go +++ b/go/vt/vtgate/planbuilder/operators/route.go @@ -707,7 +707,7 @@ func (r *Route) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.Aliase return truncate(r, r.Source.GetColumns(ctx)) } -func (r *Route) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (r *Route) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return truncate(r, r.Source.GetSelectExprs(ctx)) } diff --git a/go/vt/vtgate/planbuilder/operators/sharded_routing.go b/go/vt/vtgate/planbuilder/operators/sharded_routing.go index 9ad567c71b1..0cc828a7ae2 100644 --- a/go/vt/vtgate/planbuilder/operators/sharded_routing.go +++ b/go/vt/vtgate/planbuilder/operators/sharded_routing.go @@ -665,10 +665,11 @@ func (tr *ShardedRouting) extraInfo() string { ) } + valueExprs := tr.Selected.ValueExprs return fmt.Sprintf( "Vindex[%s] Values[%s] Seen:[%s]", tr.Selected.FoundVindex.String(), - sqlparser.String(sqlparser.Exprs(tr.Selected.ValueExprs)), + sqlparser.SliceString(valueExprs), sqlparser.String(sqlparser.AndExpressions(tr.SeenPredicates...)), ) } diff --git a/go/vt/vtgate/planbuilder/operators/subquery.go b/go/vt/vtgate/planbuilder/operators/subquery.go index 9610a2b10c9..62b6e7a725e 100644 --- a/go/vt/vtgate/planbuilder/operators/subquery.go +++ b/go/vt/vtgate/planbuilder/operators/subquery.go @@ -38,7 +38,7 @@ type SubQuery struct { FilterType opcode.PulloutOpcode // Type of subquery filter. Original sqlparser.Expr // This is the expression we should use if we can merge the inner to the outer originalSubquery *sqlparser.Subquery // Subquery representation, e.g., (SELECT foo from user LIMIT 1). - Predicates sqlparser.Exprs // Predicates joining outer and inner queries. Empty for uncorrelated subqueries. + Predicates []sqlparser.Expr // Predicates joining outer and inner queries. Empty for uncorrelated subqueries. OuterPredicate sqlparser.Expr // This is the predicate that is using the subquery expression. It will not be empty for projections ArgName string // This is the name of the ColName or Argument used to replace the subquery TopLevel bool // will be false if the subquery is deeply nested @@ -125,7 +125,7 @@ func (sq *SubQuery) Clone(inputs []Operator) Operator { } klone.JoinColumns = slices.Clone(sq.JoinColumns) klone.Vars = maps.Clone(sq.Vars) - klone.Predicates = sqlparser.Clone(sq.Predicates) + klone.Predicates = slices.Clone(sq.Predicates) return &klone } @@ -195,7 +195,7 @@ func (sq *SubQuery) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.Al return sq.Outer.GetColumns(ctx) } -func (sq *SubQuery) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (sq *SubQuery) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return sq.Outer.GetSelectExprs(ctx) } diff --git a/go/vt/vtgate/planbuilder/operators/subquery_builder.go b/go/vt/vtgate/planbuilder/operators/subquery_builder.go index 6ec5ecdd7f3..cc7dc9afe69 100644 --- a/go/vt/vtgate/planbuilder/operators/subquery_builder.go +++ b/go/vt/vtgate/planbuilder/operators/subquery_builder.go @@ -116,7 +116,7 @@ func createSubqueryOp( // and extracts subqueries into operators func (sqb *SubQueryBuilder) inspectStatement(ctx *plancontext.PlanningContext, stmt sqlparser.TableStatement, -) (sqlparser.Exprs, []applyJoinColumn) { +) ([]sqlparser.Expr, []applyJoinColumn) { switch stmt := stmt.(type) { case *sqlparser.Select: return sqb.inspectSelect(ctx, stmt) @@ -134,7 +134,7 @@ func (sqb *SubQueryBuilder) inspectStatement(ctx *plancontext.PlanningContext, func (sqb *SubQueryBuilder) inspectSelect( ctx *plancontext.PlanningContext, sel *sqlparser.Select, -) (sqlparser.Exprs, []applyJoinColumn) { +) ([]sqlparser.Expr, []applyJoinColumn) { // first we need to go through all the places where one can find predicates // and search for subqueries newWhere, wherePreds, whereJoinCols := sqb.inspectWhere(ctx, sel.Where) @@ -191,7 +191,7 @@ func createSubquery( func (sqb *SubQueryBuilder) inspectWhere( ctx *plancontext.PlanningContext, in *sqlparser.Where, -) (*sqlparser.Where, sqlparser.Exprs, []applyJoinColumn) { +) (*sqlparser.Where, []sqlparser.Expr, []applyJoinColumn) { if in == nil { return nil, nil, nil } @@ -221,7 +221,7 @@ func (sqb *SubQueryBuilder) inspectWhere( func (sqb *SubQueryBuilder) inspectOnExpr( ctx *plancontext.PlanningContext, from []sqlparser.TableExpr, -) (newFrom []sqlparser.TableExpr, onPreds sqlparser.Exprs, onJoinCols []applyJoinColumn) { +) (newFrom []sqlparser.TableExpr, onPreds []sqlparser.Expr, onJoinCols []applyJoinColumn) { for _, tbl := range from { tbl := sqlparser.CopyOnRewrite(tbl, dontEnterSubqueries, func(cursor *sqlparser.CopyOnWriteCursor) { cond, ok := cursor.Node().(*sqlparser.JoinCondition) diff --git a/go/vt/vtgate/planbuilder/operators/subquery_container.go b/go/vt/vtgate/planbuilder/operators/subquery_container.go index 3f5c3eed254..396dc1b3b62 100644 --- a/go/vt/vtgate/planbuilder/operators/subquery_container.go +++ b/go/vt/vtgate/planbuilder/operators/subquery_container.go @@ -91,7 +91,7 @@ func (sqc *SubQueryContainer) GetColumns(ctx *plancontext.PlanningContext) []*sq return sqc.Outer.GetColumns(ctx) } -func (sqc *SubQueryContainer) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (sqc *SubQueryContainer) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return sqc.Outer.GetSelectExprs(ctx) } diff --git a/go/vt/vtgate/planbuilder/operators/table.go b/go/vt/vtgate/planbuilder/operators/table.go index 473459d6864..2cc561497f7 100644 --- a/go/vt/vtgate/planbuilder/operators/table.go +++ b/go/vt/vtgate/planbuilder/operators/table.go @@ -91,7 +91,7 @@ func (to *Table) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedEx return slice.Map(to.Columns, colNameToExpr) } -func (to *Table) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (to *Table) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return transformColumnsToSelectExprs(ctx, to) } diff --git a/go/vt/vtgate/planbuilder/operators/union.go b/go/vt/vtgate/planbuilder/operators/union.go index 1c692c9f38e..4539569fdc0 100644 --- a/go/vt/vtgate/planbuilder/operators/union.go +++ b/go/vt/vtgate/planbuilder/operators/union.go @@ -30,14 +30,14 @@ type Union struct { Sources []Operator // These are the select expressions coming from each source - Selects []sqlparser.SelectExprs + Selects [][]sqlparser.SelectExpr distinct bool - unionColumns sqlparser.SelectExprs + unionColumns []sqlparser.SelectExpr unionColumnsAsAlisedExprs []*sqlparser.AliasedExpr } -func newUnion(srcs []Operator, sourceSelects []sqlparser.SelectExprs, columns sqlparser.SelectExprs, distinct bool) *Union { +func newUnion(srcs []Operator, sourceSelects [][]sqlparser.SelectExpr, columns []sqlparser.SelectExpr, distinct bool) *Union { if columns == nil { panic("rt") } @@ -95,7 +95,7 @@ can be found on the same offset. The names of the RHS are discarded. func (u *Union) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator { offsets := make(map[string]int) sel := u.GetSelectFor(0) - for i, selectExpr := range sel.SelectExprs { + for i, selectExpr := range sel.GetColumns() { ae, ok := selectExpr.(*sqlparser.AliasedExpr) if !ok { panic(vterrors.VT12001("pushing predicates on UNION where the first SELECT contains * or NEXT")) @@ -133,7 +133,7 @@ func (u *Union) predicatePerSource(expr sqlparser.Expr, offsets map[string]int) } sel := u.GetSelectFor(i) - ae, ok := sel.SelectExprs[idx].(*sqlparser.AliasedExpr) + ae, ok := sel.GetColumns()[idx].(*sqlparser.AliasedExpr) if !ok { panic(vterrors.VT09015()) } @@ -269,7 +269,7 @@ func (u *Union) GetColumns(ctx *plancontext.PlanningContext) (result []*sqlparse return u.unionColumnsAsAlisedExprs } -func (u *Union) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (u *Union) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { // if any of the inputs has more columns that we expect, we want to show on top of UNION, so the results can // be truncated to the expected result columns and nothing else for _, src := range u.Sources { diff --git a/go/vt/vtgate/planbuilder/operators/union_merging.go b/go/vt/vtgate/planbuilder/operators/union_merging.go index 6173b59e0dc..b38cc4e9561 100644 --- a/go/vt/vtgate/planbuilder/operators/union_merging.go +++ b/go/vt/vtgate/planbuilder/operators/union_merging.go @@ -25,7 +25,7 @@ import ( // mergeUnionInputInAnyOrder merges sources the sources of the union in any order // can be used for UNION DISTINCT -func mergeUnionInputInAnyOrder(ctx *plancontext.PlanningContext, op *Union) ([]Operator, []sqlparser.SelectExprs) { +func mergeUnionInputInAnyOrder(ctx *plancontext.PlanningContext, op *Union) ([]Operator, [][]sqlparser.SelectExpr) { sources := op.Sources selects := op.Selects @@ -57,7 +57,7 @@ func mergeUnionInputInAnyOrder(ctx *plancontext.PlanningContext, op *Union) ([]O } var newSources []Operator - var newSelects []sqlparser.SelectExprs + var newSelects [][]sqlparser.SelectExpr for i, source := range sources { if keep[i] || i <= idx { newSources = append(newSources, source) @@ -72,7 +72,7 @@ func mergeUnionInputInAnyOrder(ctx *plancontext.PlanningContext, op *Union) ([]O return sources, selects } -func mergeUnionInputsInOrder(ctx *plancontext.PlanningContext, op *Union) ([]Operator, []sqlparser.SelectExprs) { +func mergeUnionInputsInOrder(ctx *plancontext.PlanningContext, op *Union) ([]Operator, [][]sqlparser.SelectExpr) { sources := op.Sources selects := op.Selects for { @@ -105,9 +105,9 @@ func mergeUnionInputsInOrder(ctx *plancontext.PlanningContext, op *Union) ([]Ope func mergeUnionInputs( ctx *plancontext.PlanningContext, lhs, rhs Operator, - lhsExprs, rhsExprs sqlparser.SelectExprs, + lhsExprs, rhsExprs []sqlparser.SelectExpr, distinct bool, -) (Operator, sqlparser.SelectExprs) { +) (Operator, []sqlparser.SelectExpr) { lhsRoute, rhsRoute, routingA, routingB, a, b, sameKeyspace := prepareInputRoutes(ctx, lhs, rhs) if lhsRoute == nil { return nil, nil @@ -138,9 +138,9 @@ func mergeUnionInputs( func tryMergeUnionShardedRouting( ctx *plancontext.PlanningContext, routeA, routeB *Route, - exprsA, exprsB sqlparser.SelectExprs, + exprsA, exprsB []sqlparser.SelectExpr, distinct bool, -) (Operator, sqlparser.SelectExprs) { +) (Operator, []sqlparser.SelectExpr) { tblA := routeA.Routing.(*ShardedRouting) tblB := routeB.Routing.(*ShardedRouting) @@ -172,13 +172,13 @@ func tryMergeUnionShardedRouting( func createMergedUnion( ctx *plancontext.PlanningContext, lhsRoute, rhsRoute *Route, - lhsExprs, rhsExprs sqlparser.SelectExprs, + lhsExprs, rhsExprs []sqlparser.SelectExpr, distinct bool, - routing Routing) (Operator, sqlparser.SelectExprs) { + routing Routing) (Operator, []sqlparser.SelectExpr) { // if there are `*` on either side, or a different number of SelectExpr items, // we give up aligning the expressions and trust that we can push everything down - cols := make(sqlparser.SelectExprs, len(lhsExprs)) + cols := make([]sqlparser.SelectExpr, len(lhsExprs)) noDeps := len(lhsExprs) != len(rhsExprs) for idx, col := range lhsExprs { lae, ok := col.(*sqlparser.AliasedExpr) @@ -219,7 +219,8 @@ func createMergedUnion( ctx.SemTable.Recursive[col] = deps } - union := newUnion([]Operator{lhsRoute.Source, rhsRoute.Source}, []sqlparser.SelectExprs{lhsExprs, rhsExprs}, cols, distinct) + exprs := [][]sqlparser.SelectExpr{lhsExprs, rhsExprs} + union := newUnion([]Operator{lhsRoute.Source, rhsRoute.Source}, exprs, cols, distinct) selectExprs := unionSelects(lhsExprs) return &Route{ unaryOperator: newUnaryOp(union), @@ -241,7 +242,7 @@ func compactUnion(u *Union) *ApplyResult { } var newSources []Operator - var newSelects []sqlparser.SelectExprs + var newSelects [][]sqlparser.SelectExpr merged := false for idx, source := range u.Sources { diff --git a/go/vt/vtgate/planbuilder/operators/update.go b/go/vt/vtgate/planbuilder/operators/update.go index 0fa0d10d9c7..759500a8dc8 100644 --- a/go/vt/vtgate/planbuilder/operators/update.go +++ b/go/vt/vtgate/planbuilder/operators/update.go @@ -186,7 +186,7 @@ func createUpdateWithInputOp(ctx *plancontext.PlanningContext, upd *sqlparser.Up colsList = append(colsList, from.cols) uList = append(uList, from.updList) for _, col := range from.cols { - selectStmt.SelectExprs = append(selectStmt.SelectExprs, aeWrap(col)) + selectStmt.AddSelectExpr(aeWrap(col)) } return from.op }) @@ -889,7 +889,7 @@ func createFkVerifyOpForParentFKForUpdate(ctx *plancontext.PlanningContext, upda whereCond = &sqlparser.AndExpr{Left: whereCond, Right: prefixColNames(ctx, childTbl, updStmt.Where.Expr)} } return createSelectionOp(ctx, - sqlparser.SelectExprs{sqlparser.NewAliasedExpr(sqlparser.NewIntLiteral("1"), "")}, + []sqlparser.SelectExpr{sqlparser.NewAliasedExpr(sqlparser.NewIntLiteral("1"), "")}, []sqlparser.TableExpr{ sqlparser.NewJoinTableExpr( childTblExpr, @@ -973,7 +973,7 @@ func createFkVerifyOpForChildFKForUpdate(ctx *plancontext.PlanningContext, updat } return createSelectionOp(ctx, - sqlparser.SelectExprs{sqlparser.NewAliasedExpr(sqlparser.NewIntLiteral("1"), "")}, + []sqlparser.SelectExpr{sqlparser.NewAliasedExpr(sqlparser.NewIntLiteral("1"), "")}, []sqlparser.TableExpr{ sqlparser.NewJoinTableExpr( parentTblExpr, @@ -1056,7 +1056,7 @@ func buildChangedVindexesValues( } // Checks done, let's actually add the expressions and the vindex map - selExprs = append(selExprs, aeWrap(sqlparser.AndExpressions(compExprs...))) + selExprs.Exprs = append(selExprs.Exprs, aeWrap(sqlparser.AndExpressions(compExprs...))) changedVindexes[vindex.Name] = &engine.VindexValues{ EvalExprMap: vindexValueMap, Offset: offset, @@ -1076,16 +1076,16 @@ func buildChangedVindexesValues( return changedVindexes, ovq, subQueriesArgOnChangedVindex } -func initialQuery(ksidCols []sqlparser.IdentifierCI, table *vindexes.BaseTable) (sqlparser.SelectExprs, int) { - var selExprs sqlparser.SelectExprs +func initialQuery(ksidCols []sqlparser.IdentifierCI, table *vindexes.BaseTable) (*sqlparser.SelectExprs, int) { + selExprs := new(sqlparser.SelectExprs) offset := 0 for _, col := range ksidCols { - selExprs = append(selExprs, aeWrap(sqlparser.NewColName(col.String()))) + selExprs.Exprs = append(selExprs.Exprs, aeWrap(sqlparser.NewColName(col.String()))) offset++ } for _, cv := range table.Owned { for _, column := range cv.Columns { - selExprs = append(selExprs, aeWrap(sqlparser.NewColName(column.String()))) + selExprs.Exprs = append(selExprs.Exprs, aeWrap(sqlparser.NewColName(column.String()))) offset++ } } diff --git a/go/vt/vtgate/planbuilder/operators/utils_test.go b/go/vt/vtgate/planbuilder/operators/utils_test.go index 035a273e964..babf6c91afb 100644 --- a/go/vt/vtgate/planbuilder/operators/utils_test.go +++ b/go/vt/vtgate/planbuilder/operators/utils_test.go @@ -73,8 +73,7 @@ func (f *fakeOp) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.Alias panic("implement me") } -func (f *fakeOp) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { - // TODO implement me +func (f *fakeOp) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { panic("implement me") } diff --git a/go/vt/vtgate/planbuilder/operators/vindex.go b/go/vt/vtgate/planbuilder/operators/vindex.go index cb0719b815f..753cf5cb3cd 100644 --- a/go/vt/vtgate/planbuilder/operators/vindex.go +++ b/go/vt/vtgate/planbuilder/operators/vindex.go @@ -100,7 +100,7 @@ func (v *Vindex) GetColumns(*plancontext.PlanningContext) []*sqlparser.AliasedEx return slice.Map(v.Columns, colNameToExpr) } -func (v *Vindex) GetSelectExprs(ctx *plancontext.PlanningContext) sqlparser.SelectExprs { +func (v *Vindex) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { return transformColumnsToSelectExprs(ctx, v) } diff --git a/go/vt/vtgate/planbuilder/plan_test.go b/go/vt/vtgate/planbuilder/plan_test.go index 8a8d55279a6..b1731561dd4 100644 --- a/go/vt/vtgate/planbuilder/plan_test.go +++ b/go/vt/vtgate/planbuilder/plan_test.go @@ -229,17 +229,16 @@ func (s *planTestSuite) setFks(vschema *vindexes.VSchema) { _ = vschema.AddForeignKey("unsharded_fk_allow", "u_multicol_tbl2", createFkDefinition([]string{"cola", "colb"}, "u_multicol_tbl1", []string{"cola", "colb"}, sqlparser.SetNull, sqlparser.SetNull)) _ = vschema.AddForeignKey("unsharded_fk_allow", "u_multicol_tbl3", createFkDefinition([]string{"cola", "colb"}, "u_multicol_tbl2", []string{"cola", "colb"}, sqlparser.Cascade, sqlparser.Cascade)) - _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", sqlparser.Exprs{sqlparser.NewColName("col9")}) - _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", sqlparser.Exprs{&sqlparser.BinaryExpr{Operator: sqlparser.MultOp, Left: sqlparser.NewColName("col9"), Right: sqlparser.NewColName("foo")}}) - _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", sqlparser.Exprs{sqlparser.NewColName("col9"), sqlparser.NewColName("foo")}) - _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", sqlparser.Exprs{sqlparser.NewColName("foo"), sqlparser.NewColName("bar")}) - _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", sqlparser.Exprs{sqlparser.NewColName("bar"), sqlparser.NewColName("col9")}) - _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl8", sqlparser.Exprs{sqlparser.NewColName("col8")}) + _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", []sqlparser.Expr{sqlparser.NewColName("col9")}) + _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", []sqlparser.Expr{&sqlparser.BinaryExpr{Operator: sqlparser.MultOp, Left: sqlparser.NewColName("col9"), Right: sqlparser.NewColName("foo")}}) + _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", []sqlparser.Expr{sqlparser.NewColName("col9"), sqlparser.NewColName("foo")}) + _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", []sqlparser.Expr{sqlparser.NewColName("foo"), sqlparser.NewColName("bar")}) + _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl9", []sqlparser.Expr{sqlparser.NewColName("bar"), sqlparser.NewColName("col9")}) + _ = vschema.AddUniqueKey("unsharded_fk_allow", "u_tbl8", []sqlparser.Expr{sqlparser.NewColName("col8")}) s.addPKs(vschema, "unsharded_fk_allow", []string{"u_tbl1", "u_tbl2", "u_tbl3", "u_tbl4", "u_tbl5", "u_tbl6", "u_tbl7", "u_tbl8", "u_tbl9", "u_tbl10", "u_tbl11", "u_multicol_tbl1", "u_multicol_tbl2", "u_multicol_tbl3"}) } - } func (s *planTestSuite) addPKs(vschema *vindexes.VSchema, ks string, tbls []string) { diff --git a/go/vt/vtgate/planbuilder/planner_test.go b/go/vt/vtgate/planbuilder/planner_test.go index bd4c520510c..7cb66e3d101 100644 --- a/go/vt/vtgate/planbuilder/planner_test.go +++ b/go/vt/vtgate/planbuilder/planner_test.go @@ -85,5 +85,5 @@ func TestBindingSubquery(t *testing.T) { } func extractExpr(in *sqlparser.Select, idx int) sqlparser.Expr { - return in.SelectExprs[idx].(*sqlparser.AliasedExpr).Expr + return in.SelectExprs.Exprs[idx].(*sqlparser.AliasedExpr).Expr } diff --git a/go/vt/vtgate/planbuilder/route.go b/go/vt/vtgate/planbuilder/route.go index e320df14416..74a13284e81 100644 --- a/go/vt/vtgate/planbuilder/route.go +++ b/go/vt/vtgate/planbuilder/route.go @@ -73,12 +73,8 @@ func prepareTheAST(sel sqlparser.SelectStatement) { _ = sqlparser.Walk(func(node sqlparser.SQLNode) (bool, error) { switch node := node.(type) { case *sqlparser.Select: - if len(node.SelectExprs) == 0 { - node.SelectExprs = []sqlparser.SelectExpr{ - &sqlparser.AliasedExpr{ - Expr: sqlparser.NewIntLiteral("1"), - }, - } + if node.GetColumnCount() == 0 { + node.AddSelectExpr(&sqlparser.AliasedExpr{Expr: sqlparser.NewIntLiteral("1")}) } case *sqlparser.ComparisonExpr: // 42 = colName -> colName = 42 diff --git a/go/vt/vtgate/planbuilder/select.go b/go/vt/vtgate/planbuilder/select.go index 409343f2760..d7fbf59ac13 100644 --- a/go/vt/vtgate/planbuilder/select.go +++ b/go/vt/vtgate/planbuilder/select.go @@ -139,19 +139,20 @@ func buildSQLCalcFoundRowsPlan( sel2.OrderBy = nil sel2.Limit = nil - countStartExpr := []sqlparser.SelectExpr{&sqlparser.AliasedExpr{ - Expr: &sqlparser.CountStar{}, - }} + countStar := &sqlparser.AliasedExpr{Expr: &sqlparser.CountStar{}} + selectExprs := &sqlparser.SelectExprs{ + Exprs: []sqlparser.SelectExpr{countStar}, + } if sel2.GroupBy == nil && sel2.Having == nil { // if there is no grouping, we can use the same query and // just replace the SELECT sub-clause to have a single count(*) - sel2.SelectExprs = countStartExpr + sel2.SetSelectExprs(countStar) } else { // when there is grouping, we have to move the original query into a derived table. // select id, sum(12) from user group by id => // select count(*) from (select id, sum(12) from user group by id) t sel3 := &sqlparser.Select{ - SelectExprs: countStartExpr, + SelectExprs: selectExprs, From: []sqlparser.TableExpr{ &sqlparser.AliasedTableExpr{ Expr: &sqlparser.DerivedTable{Select: sel2}, @@ -292,10 +293,12 @@ func handleDualSelects(sel *sqlparser.Select, vschema plancontext.VSchema) (engi return nil, nil } - exprs := make([]evalengine.Expr, len(sel.SelectExprs)) - cols := make([]string, len(sel.SelectExprs)) + columns := sel.GetColumns() + size := len(columns) + exprs := make([]evalengine.Expr, size) + cols := make([]string, size) var lockFunctions []*engine.LockFunc - for i, e := range sel.SelectExprs { + for i, e := range columns { expr, ok := e.(*sqlparser.AliasedExpr) if !ok { return nil, nil diff --git a/go/vt/vtgate/planbuilder/system_variables.go b/go/vt/vtgate/planbuilder/system_variables.go index 8ef968a2ac8..e4713e877de 100644 --- a/go/vt/vtgate/planbuilder/system_variables.go +++ b/go/vt/vtgate/planbuilder/system_variables.go @@ -60,7 +60,7 @@ func (pc *sysvarPlanCache) parseAndBuildDefaultValue(sysvar sysvars.SystemVariab panic(fmt.Sprintf("bug in set plan init - default value for %s not parsable: %s", sysvar.Name, sysvar.Default)) } sel := stmt.(*sqlparser.Select) - aliasedExpr := sel.SelectExprs[0].(*sqlparser.AliasedExpr) + aliasedExpr := sel.GetColumns()[0].(*sqlparser.AliasedExpr) def, err := evalengine.Translate(aliasedExpr.Expr, &evalengine.Config{ Collation: pc.env.CollationEnv().DefaultConnectionCharset(), Environment: pc.env, diff --git a/go/vt/vtgate/semantics/analyzer.go b/go/vt/vtgate/semantics/analyzer.go index c4e7dc55866..46de35323ad 100644 --- a/go/vt/vtgate/semantics/analyzer.go +++ b/go/vt/vtgate/semantics/analyzer.go @@ -149,7 +149,7 @@ func (a *analyzer) newSemTable( Direct: ExprDependencies{}, ColumnEqualities: map[columnName][]sqlparser.Expr{}, ExpandedColumns: map[sqlparser.TableName][]*sqlparser.ColName{}, - columns: map[*sqlparser.Union]sqlparser.SelectExprs{}, + columns: map[*sqlparser.Union][]sqlparser.SelectExpr{}, StatementIDs: a.scoper.statementIDs, QuerySignature: a.sig, childForeignKeysInvolved: map[TableSet][]vindexes.ChildFKInfo{}, @@ -159,7 +159,7 @@ func (a *analyzer) newSemTable( }, nil } - columns := map[*sqlparser.Union]sqlparser.SelectExprs{} + columns := map[*sqlparser.Union][]sqlparser.SelectExpr{} for union, info := range a.tables.unionInfo { columns[union] = info.exprs } @@ -275,7 +275,7 @@ func (a *analyzer) analyzeUp(cursor *sqlparser.Cursor) bool { return a.shouldContinue() } -func containsStar(s sqlparser.SelectExprs) bool { +func containsStar(s []sqlparser.SelectExpr) bool { for _, expr := range s { _, isStar := expr.(*sqlparser.StarExpr) if isStar { @@ -306,8 +306,10 @@ func checkUnionColumns(union *sqlparser.Union) error { return nil } - if len(secondProj) != len(firstProj) { - return &UnionColumnsDoNotMatchError{FirstProj: len(firstProj), SecondProj: len(secondProj)} + secondSize := len(secondProj) + firstSize := len(firstProj) + if secondSize != firstSize { + return &UnionColumnsDoNotMatchError{FirstProj: firstSize, SecondProj: secondSize} } return nil @@ -318,14 +320,14 @@ errors that happen when we are evaluating SELECT expressions are saved until we if we can merge everything into a single route or not */ func (a *analyzer) enterProjection(cursor *sqlparser.Cursor) { - _, ok := cursor.Node().(sqlparser.SelectExprs) + _, ok := cursor.Node().(*sqlparser.SelectExprs) if ok && isParentSelect(cursor) { a.inProjection++ } } func (a *analyzer) leaveProjection(cursor *sqlparser.Cursor) { - _, ok := cursor.Node().(sqlparser.SelectExprs) + _, ok := cursor.Node().(*sqlparser.SelectExprs) if ok && isParentSelect(cursor) { a.inProjection-- } diff --git a/go/vt/vtgate/semantics/analyzer_test.go b/go/vt/vtgate/semantics/analyzer_test.go index c7f24e6c73c..72b9ad83eb4 100644 --- a/go/vt/vtgate/semantics/analyzer_test.go +++ b/go/vt/vtgate/semantics/analyzer_test.go @@ -41,7 +41,7 @@ var ( ) func extract(in *sqlparser.Select, idx int) sqlparser.Expr { - return in.SelectExprs[idx].(*sqlparser.AliasedExpr).Expr + return in.SelectExprs.Exprs[idx].(*sqlparser.AliasedExpr).Expr } func TestBindingSingleTablePositive(t *testing.T) { @@ -575,7 +575,7 @@ func TestScopeForSubqueries(t *testing.T) { sel, _ := stmt.(*sqlparser.Select) // extract the first expression from the subquery (which should be the second expression in the outer query) - sel2 := sel.SelectExprs[1].(*sqlparser.AliasedExpr).Expr.(*sqlparser.Subquery).Select.(*sqlparser.Select) + sel2 := extract(sel, 1).(*sqlparser.Subquery).Select.(*sqlparser.Select) exp := extract(sel2, 0) s1 := semTable.RecursiveDeps(exp) require.NoError(t, semTable.NotSingleRouteErr) @@ -1458,7 +1458,7 @@ func TestScopingSubQueryJoinClause(t *testing.T) { require.NoError(t, err) require.NoError(t, st.NotUnshardedErr) - tb := st.DirectDeps(parse.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr.(*sqlparser.Subquery).Select.(*sqlparser.Select).From[0].(*sqlparser.JoinTableExpr).Condition.On) + tb := st.DirectDeps(extract(parse.(*sqlparser.Select), 0).(*sqlparser.Subquery).Select.(*sqlparser.Select).From[0].(*sqlparser.JoinTableExpr).Condition.On) require.Equal(t, 3, tb.NumberOfTables()) } diff --git a/go/vt/vtgate/semantics/binder.go b/go/vt/vtgate/semantics/binder.go index 78148f4bb1f..b59b50159b7 100644 --- a/go/vt/vtgate/semantics/binder.go +++ b/go/vt/vtgate/semantics/binder.go @@ -365,7 +365,7 @@ func (b *binder) resolveColumnInHaving(colName *sqlparser.ColName, current *scop // searchInSelectExpressions searches for the ColName among the SELECT and GROUP BY expressions // It used dependency information to match the columns func (b *binder) searchInSelectExpressions(colName *sqlparser.ColName, deps dependency, stmt *sqlparser.Select) dependency { - for _, selectExpr := range stmt.SelectExprs { + for _, selectExpr := range stmt.GetColumns() { ae, ok := selectExpr.(*sqlparser.AliasedExpr) if !ok { continue diff --git a/go/vt/vtgate/semantics/check_invalid.go b/go/vt/vtgate/semantics/check_invalid.go index 6509f5f5ee8..e2519208caa 100644 --- a/go/vt/vtgate/semantics/check_invalid.go +++ b/go/vt/vtgate/semantics/check_invalid.go @@ -163,8 +163,8 @@ func (a *analyzer) checkSelect(cursor *sqlparser.Cursor, node *sqlparser.Select) } errMsg := "INTO" nextVal := false - if len(node.SelectExprs) == 1 { - if _, isNextVal := node.SelectExprs[0].(*sqlparser.Nextval); isNextVal { + if node.GetColumnCount() == 1 { + if _, isNextVal := node.GetColumns()[0].(*sqlparser.Nextval); isNextVal { nextVal = true errMsg = "NEXT" } diff --git a/go/vt/vtgate/semantics/derived_table.go b/go/vt/vtgate/semantics/derived_table.go index 676679d2fa9..8a456ad7c5c 100644 --- a/go/vt/vtgate/semantics/derived_table.go +++ b/go/vt/vtgate/semantics/derived_table.go @@ -43,13 +43,13 @@ type unionInfo struct { isAuthoritative bool recursive []TableSet types []evalengine.Type - exprs sqlparser.SelectExprs + exprs []sqlparser.SelectExpr } var _ TableInfo = (*DerivedTable)(nil) func createDerivedTableForExpressions( - expressions sqlparser.SelectExprs, + expressions []sqlparser.SelectExpr, cols sqlparser.Columns, tables []TableInfo, org originable, diff --git a/go/vt/vtgate/semantics/early_rewriter.go b/go/vt/vtgate/semantics/early_rewriter.go index 64426e25748..a76164c2745 100644 --- a/go/vt/vtgate/semantics/early_rewriter.go +++ b/go/vt/vtgate/semantics/early_rewriter.go @@ -45,7 +45,7 @@ type earlyRewriter struct { func (r *earlyRewriter) down(cursor *sqlparser.Cursor) error { switch node := cursor.Node().(type) { - case sqlparser.SelectExprs: + case *sqlparser.SelectExprs: return r.handleSelectExprs(cursor, node) case *sqlparser.NotExpr: rewriteNotExpr(cursor, node) @@ -225,7 +225,7 @@ func (r *earlyRewriter) handleHavingClause(node *sqlparser.Where, parent sqlpars } // handleSelectExprs expands * in SELECT expressions. -func (r *earlyRewriter) handleSelectExprs(cursor *sqlparser.Cursor, node sqlparser.SelectExprs) error { +func (r *earlyRewriter) handleSelectExprs(cursor *sqlparser.Cursor, node *sqlparser.SelectExprs) error { _, isSel := cursor.Parent().(*sqlparser.Select) if !isSel { return nil @@ -732,7 +732,7 @@ func (r *earlyRewriter) getAliasMap(sel *sqlparser.Select) (aliases map[string]e return } aliases = map[string]exprContainer{} - for _, e := range sel.SelectExprs { + for _, e := range sel.GetColumns() { ae, ok := e.(*sqlparser.AliasedExpr) if !ok { continue @@ -776,7 +776,7 @@ func (r *earlyRewriter) rewriteOrderByLiteral(node *sqlparser.Literal) (expr sql return nil, false, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "error invalid statement type, expect Select, got: %T", scope.stmt) } - if num < 1 || num > len(stmt.SelectExprs) { + if num < 1 || num > stmt.GetColumnCount() { return nil, false, &ColumnNotFoundClauseError{ Column: fmt.Sprintf("%d", num), Clause: r.clause, @@ -785,13 +785,13 @@ func (r *earlyRewriter) rewriteOrderByLiteral(node *sqlparser.Literal) (expr sql // We loop like this instead of directly accessing the offset, to make sure there are no unexpanded `*` before for i := 0; i < num; i++ { - if _, ok := stmt.SelectExprs[i].(*sqlparser.AliasedExpr); !ok { - return nil, false, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "cannot use column offsets in %s when using `%s`", r.clause, sqlparser.String(stmt.SelectExprs[i])) + if _, ok := stmt.GetColumns()[i].(*sqlparser.AliasedExpr); !ok { + return nil, false, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "cannot use column offsets in %s when using `%s`", r.clause, sqlparser.String(stmt.GetColumns()[i])) } } colOffset := num - 1 - aliasedExpr, ok := stmt.SelectExprs[colOffset].(*sqlparser.AliasedExpr) + aliasedExpr, ok := stmt.GetColumns()[colOffset].(*sqlparser.AliasedExpr) if !ok { return nil, false, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "don't know how to handle %s", sqlparser.String(node)) } @@ -831,18 +831,18 @@ func (r *earlyRewriter) rewriteGroupByExpr(node *sqlparser.Literal) (sqlparser.E return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "error invalid statement type, expect Select, got: %T", scope.stmt) } - if num < 1 || num > len(stmt.SelectExprs) { + if num < 1 || num > stmt.GetColumnCount() { return nil, vterrors.NewErrorf(vtrpcpb.Code_INVALID_ARGUMENT, vterrors.BadFieldError, "Unknown column '%d' in '%s'", num, r.clause) } // We loop like this instead of directly accessing the offset, to make sure there are no unexpanded `*` before for i := 0; i < num; i++ { - if _, ok := stmt.SelectExprs[i].(*sqlparser.AliasedExpr); !ok { - return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "cannot use column offsets in %s when using `%s`", r.clause, sqlparser.String(stmt.SelectExprs[i])) + if _, ok := stmt.GetColumns()[i].(*sqlparser.AliasedExpr); !ok { + return nil, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "cannot use column offsets in %s when using `%s`", r.clause, sqlparser.String(stmt.GetColumns()[i])) } } - aliasedExpr, ok := stmt.SelectExprs[num-1].(*sqlparser.AliasedExpr) + aliasedExpr, ok := stmt.GetColumns()[num-1].(*sqlparser.AliasedExpr) if !ok { return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "don't know how to handle %s", sqlparser.String(node)) } @@ -876,14 +876,14 @@ func handleComparisonExpr(cursor *sqlparser.Cursor, node *sqlparser.ComparisonEx return nil } -func (r *earlyRewriter) expandStar(cursor *sqlparser.Cursor, node sqlparser.SelectExprs) error { +func (r *earlyRewriter) expandStar(cursor *sqlparser.Cursor, node *sqlparser.SelectExprs) error { currentScope := r.scoper.currentScope() - var selExprs sqlparser.SelectExprs + selExprs := new(sqlparser.SelectExprs) changed := false - for _, selectExpr := range node { + for _, selectExpr := range node.Exprs { starExpr, isStarExpr := selectExpr.(*sqlparser.StarExpr) if !isStarExpr { - selExprs = append(selExprs, selectExpr) + selExprs.Exprs = append(selExprs.Exprs, selectExpr) continue } starExpanded, colNames, err := r.expandTableColumns(starExpr, currentScope.tables, r.binder.usingJoinInfo, r.scoper.org) @@ -891,10 +891,10 @@ func (r *earlyRewriter) expandStar(cursor *sqlparser.Cursor, node sqlparser.Sele return err } if !starExpanded || colNames == nil { - selExprs = append(selExprs, selectExpr) + selExprs.Exprs = append(selExprs.Exprs, selectExpr) continue } - selExprs = append(selExprs, colNames...) + selExprs.Exprs = append(selExprs.Exprs, colNames.Exprs...) changed = true } if changed { @@ -1065,11 +1065,11 @@ func (r *earlyRewriter) expandTableColumns( tables []TableInfo, joinUsing map[TableSet]map[string]TableSet, org originable, -) (bool, sqlparser.SelectExprs, error) { +) (bool, *sqlparser.SelectExprs, error) { unknownTbl := true starExpanded := true state := &expanderState{ - colNames: []sqlparser.SelectExpr{}, + colNames: &sqlparser.SelectExprs{}, needsQualifier: len(tables) > 1, joinUsing: joinUsing, org: org, @@ -1155,7 +1155,7 @@ outer: type expanderState struct { needsQualifier bool - colNames sqlparser.SelectExprs + colNames *sqlparser.SelectExprs joinUsing map[TableSet]map[string]TableSet org originable expandedColumns map[sqlparser.TableName][]*sqlparser.ColName @@ -1171,7 +1171,7 @@ func (e *expanderState) addColumn(col ColumnInfo, tbl TableInfo, tblName sqlpars } else { colName = sqlparser.NewColName(col.Name) } - e.colNames = append(e.colNames, &sqlparser.AliasedExpr{Expr: colName, As: alias}) + e.colNames.Exprs = append(e.colNames.Exprs, &sqlparser.AliasedExpr{Expr: colName, As: alias}) e.storeExpandInfo(tbl, tblName, colName) } diff --git a/go/vt/vtgate/semantics/early_rewriter_test.go b/go/vt/vtgate/semantics/early_rewriter_test.go index 29da6ab51ee..074deb39f64 100644 --- a/go/vt/vtgate/semantics/early_rewriter_test.go +++ b/go/vt/vtgate/semantics/early_rewriter_test.go @@ -790,16 +790,17 @@ func TestSemTableDependenciesAfterExpandStar(t *testing.T) { semTable, err := Analyze(selectStatement, "", schemaInfo) require.NoError(t, err) assert.Equal(t, tcase.expSQL, sqlparser.String(selectStatement)) + exprs := selectStatement.GetColumns() if tcase.otherTbl != -1 { assert.NotEqual(t, - semTable.RecursiveDeps(selectStatement.SelectExprs[tcase.otherTbl].(*sqlparser.AliasedExpr).Expr), - semTable.RecursiveDeps(selectStatement.SelectExprs[tcase.expandedCol].(*sqlparser.AliasedExpr).Expr), + semTable.RecursiveDeps(exprs[tcase.otherTbl].(*sqlparser.AliasedExpr).Expr), + semTable.RecursiveDeps(exprs[tcase.expandedCol].(*sqlparser.AliasedExpr).Expr), ) } if tcase.sameTbl != -1 { assert.Equal(t, - semTable.RecursiveDeps(selectStatement.SelectExprs[tcase.sameTbl].(*sqlparser.AliasedExpr).Expr), - semTable.RecursiveDeps(selectStatement.SelectExprs[tcase.expandedCol].(*sqlparser.AliasedExpr).Expr), + semTable.RecursiveDeps(exprs[tcase.sameTbl].(*sqlparser.AliasedExpr).Expr), + semTable.RecursiveDeps(exprs[tcase.expandedCol].(*sqlparser.AliasedExpr).Expr), ) } }) diff --git a/go/vt/vtgate/semantics/real_table.go b/go/vt/vtgate/semantics/real_table.go index 55dd25a5064..3c6e8a5e56d 100644 --- a/go/vt/vtgate/semantics/real_table.go +++ b/go/vt/vtgate/semantics/real_table.go @@ -151,7 +151,7 @@ func (r *RealTable) authoritative() bool { } } -func extractSelectExprsFromCTE(selectExprs sqlparser.SelectExprs) []ColumnInfo { +func extractSelectExprsFromCTE(selectExprs []sqlparser.SelectExpr) []ColumnInfo { var ci []ColumnInfo for _, expr := range selectExprs { ae, ok := expr.(*sqlparser.AliasedExpr) @@ -166,7 +166,7 @@ func extractSelectExprsFromCTE(selectExprs sqlparser.SelectExprs) []ColumnInfo { return ci } -func extractColumnsFromCTE(columns sqlparser.Columns, selectExprs sqlparser.SelectExprs) []ColumnInfo { +func extractColumnsFromCTE(columns sqlparser.Columns, selectExprs []sqlparser.SelectExpr) []ColumnInfo { if len(columns) == 0 { return nil } @@ -181,7 +181,7 @@ func extractColumnsFromCTE(columns sqlparser.Columns, selectExprs sqlparser.Sele }) } -// GetExpr implements the TableInfo interface +// GetAliasedTableExpr implements the TableInfo interface func (r *RealTable) GetAliasedTableExpr() *sqlparser.AliasedTableExpr { return r.ASTNode } diff --git a/go/vt/vtgate/semantics/scoper.go b/go/vt/vtgate/semantics/scoper.go index e6df3c3a5b0..3ca950b94da 100644 --- a/go/vt/vtgate/semantics/scoper.go +++ b/go/vt/vtgate/semantics/scoper.go @@ -76,8 +76,8 @@ func (s *scoper) down(cursor *sqlparser.Cursor) error { s.pushUnionScope(node) case sqlparser.TableExpr: s.enterJoinScope(cursor) - case sqlparser.SelectExprs: - s.copySelectExprs(cursor, node) + case *sqlparser.SelectExprs: + s.copySelectExprs(cursor, node.Exprs) case sqlparser.OrderBy: return s.addColumnInfoForOrderBy(cursor, node) case *sqlparser.GroupBy: @@ -152,7 +152,7 @@ func (s *scoper) addColumnInfoForOrderBy(cursor *sqlparser.Cursor, node sqlparse return nil } -func (s *scoper) copySelectExprs(cursor *sqlparser.Cursor, node sqlparser.SelectExprs) { +func (s *scoper) copySelectExprs(cursor *sqlparser.Cursor, node []sqlparser.SelectExpr) { sel, parentIsSelect := cursor.Parent().(*sqlparser.Select) if !parentIsSelect { return diff --git a/go/vt/vtgate/semantics/semantic_table.go b/go/vt/vtgate/semantics/semantic_table.go index 0227ee04137..6a88046e2a2 100644 --- a/go/vt/vtgate/semantics/semantic_table.go +++ b/go/vt/vtgate/semantics/semantic_table.go @@ -140,7 +140,7 @@ type ( // The columns were added because of the use of `*` in the query ExpandedColumns map[sqlparser.TableName][]*sqlparser.ColName - columns map[*sqlparser.Union]sqlparser.SelectExprs + columns map[*sqlparser.Union][]sqlparser.SelectExpr comparator *sqlparser.Comparator @@ -493,10 +493,10 @@ func (st *SemTable) ForeignKeysPresent() bool { return false } -func (st *SemTable) SelectExprs(sel sqlparser.TableStatement) sqlparser.SelectExprs { +func (st *SemTable) SelectExprs(sel sqlparser.TableStatement) []sqlparser.SelectExpr { switch sel := sel.(type) { case *sqlparser.Select: - return sel.SelectExprs + return sel.GetColumns() case *sqlparser.Union: exprs, found := st.columns[sel] if found { @@ -512,8 +512,9 @@ func (st *SemTable) SelectExprs(sel sqlparser.TableStatement) sqlparser.SelectEx panic(fmt.Sprintf("BUG: unexpected select statement type %T", sel)) } -func getColumnNames(exprs sqlparser.SelectExprs) (expanded bool, selectExprs sqlparser.SelectExprs) { - expanded = true +func getColumnNames(exprs []sqlparser.SelectExpr) (bool, []sqlparser.SelectExpr) { + var selectExprs []sqlparser.SelectExpr + expanded := true for _, col := range exprs { switch col := col.(type) { case *sqlparser.AliasedExpr: @@ -524,7 +525,7 @@ func getColumnNames(exprs sqlparser.SelectExprs) (expanded bool, selectExprs sql expanded = false } } - return + return expanded, selectExprs } // CopySemanticInfo copies all semantic information we have about this SQLNode so that it also applies to the `to` node @@ -571,7 +572,7 @@ func EmptySemTable() *SemTable { Recursive: map[sqlparser.Expr]TableSet{}, Direct: map[sqlparser.Expr]TableSet{}, ColumnEqualities: map[columnName][]sqlparser.Expr{}, - columns: map[*sqlparser.Union]sqlparser.SelectExprs{}, + columns: map[*sqlparser.Union][]sqlparser.SelectExpr{}, ExprTypes: make(map[sqlparser.Expr]evalengine.Type), } } @@ -658,9 +659,9 @@ func (st *SemTable) TableInfoForExpr(expr sqlparser.Expr) (TableInfo, error) { } // AddExprs adds new select exprs to the SemTable. -func (st *SemTable) AddExprs(tbl *sqlparser.AliasedTableExpr, cols sqlparser.SelectExprs) { +func (st *SemTable) AddExprs(tbl *sqlparser.AliasedTableExpr, cols *sqlparser.SelectExprs) { tableSet := st.TableSetFor(tbl) - for _, col := range cols { + for _, col := range cols.Exprs { st.Recursive[col.(*sqlparser.AliasedExpr).Expr] = tableSet } } @@ -757,7 +758,7 @@ func (st *SemTable) CopyExprInfo(src, dest sqlparser.Expr) { var columnNotSupportedErr = vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "column access not supported here") // ColumnLookup implements the TranslationLookup interface -func (st *SemTable) ColumnLookup(col *sqlparser.ColName) (int, error) { +func (st *SemTable) ColumnLookup(*sqlparser.ColName) (int, error) { return 0, columnNotSupportedErr } diff --git a/go/vt/vtgate/semantics/semantic_table_test.go b/go/vt/vtgate/semantics/semantic_table_test.go index 19f586d6190..3400b196fac 100644 --- a/go/vt/vtgate/semantics/semantic_table_test.go +++ b/go/vt/vtgate/semantics/semantic_table_test.go @@ -50,7 +50,7 @@ func TestBindingAndExprEquality(t *testing.T) { require.NoError(t, err) st, err := Analyze(parse, "db", fakeSchemaInfoTest()) require.NoError(t, err) - exprs := parse.(*sqlparser.Select).SelectExprs + exprs := parse.(*sqlparser.Select).GetColumns() a := exprs[0].(*sqlparser.AliasedExpr).Expr b := exprs[1].(*sqlparser.AliasedExpr).Expr assert.Equal(t, st.EqualsExpr(a, b), test.equal) diff --git a/go/vt/vtgate/semantics/table_collector.go b/go/vt/vtgate/semantics/table_collector.go index e35165f600d..d2740afaee9 100644 --- a/go/vt/vtgate/semantics/table_collector.go +++ b/go/vt/vtgate/semantics/table_collector.go @@ -174,7 +174,7 @@ func (tc *tableCollector) visitUnion(union *sqlparser.Union) error { collations := tc.org.collationEnv() err = sqlparser.VisitAllSelects(union, func(s *sqlparser.Select, idx int) error { - for i, expr := range s.SelectExprs { + for i, expr := range s.GetColumns() { ae, ok := expr.(*sqlparser.AliasedExpr) if !ok { continue @@ -450,11 +450,11 @@ func (tc *tableCollector) addSelectDerivedTable( alias sqlparser.IdentifierCS, ) error { tables := tc.scoper.wScope[sel] - size := len(sel.SelectExprs) + size := sel.GetColumnCount() deps := make([]TableSet, size) types := make([]evalengine.Type, size) expanded := true - for i, expr := range sel.SelectExprs { + for i, expr := range sel.GetColumns() { ae, ok := expr.(*sqlparser.AliasedExpr) if !ok { expanded = false @@ -463,7 +463,7 @@ func (tc *tableCollector) addSelectDerivedTable( _, deps[i], types[i] = tc.org.depsForExpr(ae.Expr) } - tableInfo := createDerivedTableForExpressions(sel.SelectExprs, columns, tables.tables, tc.org, expanded, deps, types) + tableInfo := createDerivedTableForExpressions(sel.GetColumns(), columns, tables.tables, tc.org, expanded, deps, types) if err := tableInfo.checkForDuplicates(); err != nil { return err } diff --git a/go/vt/vtgate/semantics/typer_test.go b/go/vt/vtgate/semantics/typer_test.go index 1ec642b8168..bfb8cb1119e 100644 --- a/go/vt/vtgate/semantics/typer_test.go +++ b/go/vt/vtgate/semantics/typer_test.go @@ -50,7 +50,8 @@ func TestNormalizerAndSemanticAnalysisIntegration(t *testing.T) { st, err := Analyze(out.AST, "d", fakeSchemaInfo()) require.NoError(t, err) - bv := out.AST.(*sqlparser.Select).SelectExprs[0].(*sqlparser.AliasedExpr).Expr.(*sqlparser.Argument) + + bv := extract(out.AST.(*sqlparser.Select), 0).(*sqlparser.Argument) typ, found := st.ExprTypes[bv] require.True(t, found, "bindvar was not typed") require.Equal(t, test.typ, typ.Type().String()) diff --git a/go/vt/vtgate/semantics/vtable.go b/go/vt/vtgate/semantics/vtable.go index 94dc74cdf34..610bfa76db8 100644 --- a/go/vt/vtgate/semantics/vtable.go +++ b/go/vt/vtgate/semantics/vtable.go @@ -133,7 +133,7 @@ func (v *vTableInfo) getExprFor(s string) (sqlparser.Expr, error) { return nil, vterrors.VT03022(s, "field list") } -func createVTableInfoForExpressions(expressions sqlparser.SelectExprs, tables []TableInfo, org originable) *vTableInfo { +func createVTableInfoForExpressions(expressions []sqlparser.SelectExpr, tables []TableInfo, org originable) *vTableInfo { cols, colNames, ts, isAuthoritative := selectExprsToInfos(expressions, tables, org) return &vTableInfo{ columnNames: colNames, @@ -144,7 +144,7 @@ func createVTableInfoForExpressions(expressions sqlparser.SelectExprs, tables [] } func selectExprsToInfos( - expressions sqlparser.SelectExprs, + expressions []sqlparser.SelectExpr, tables []TableInfo, org originable, ) (cols []sqlparser.Expr, colNames []string, ts TableSet, isAuthoritative bool) { diff --git a/go/vt/vtgate/simplifier/expression_simplifier.go b/go/vt/vtgate/simplifier/expression_simplifier.go index b64402cfaac..8395fb26d17 100644 --- a/go/vt/vtgate/simplifier/expression_simplifier.go +++ b/go/vt/vtgate/simplifier/expression_simplifier.go @@ -29,7 +29,7 @@ type CheckF = func(sqlparser.Expr) bool func SimplifyExpr(in sqlparser.Expr, test CheckF) sqlparser.Expr { // since we can't rewrite the top level, wrap the expr in an Exprs object - smallestKnown := sqlparser.Exprs{sqlparser.Clone(in)} + smallestKnown := sqlparser.NewExprs(sqlparser.Clone(in)) alwaysVisit := func(node, parent sqlparser.SQLNode) bool { return true @@ -42,7 +42,7 @@ func SimplifyExpr(in sqlparser.Expr, test CheckF) sqlparser.Expr { for expr != nil { cursor.Replace(expr) - valid := test(smallestKnown[0]) + valid := test(smallestKnown.Exprs[0]) if valid { break // we will still continue trying to simplify other expressions at this level } else { @@ -59,12 +59,13 @@ func SimplifyExpr(in sqlparser.Expr, test CheckF) sqlparser.Expr { for { prevSmallest := sqlparser.Clone(smallestKnown) sqlparser.SafeRewrite(smallestKnown, alwaysVisit, up) - if sqlparser.Equals.Exprs(prevSmallest, smallestKnown) { + _ = prevSmallest + if sqlparser.Equals.RefOfExprs(prevSmallest, smallestKnown) { break } } - return smallestKnown[0] + return smallestKnown.Exprs[0] } type shrinker struct { diff --git a/go/vt/vtgate/simplifier/simplifier.go b/go/vt/vtgate/simplifier/simplifier.go index c15e2ea58d1..e37ee616be3 100644 --- a/go/vt/vtgate/simplifier/simplifier.go +++ b/go/vt/vtgate/simplifier/simplifier.go @@ -281,7 +281,7 @@ func removeTable(clone sqlparser.TableStatement, searchedTS semantics.TableSet, simplified = removeTableinJoinTableExpr(node, searchedTS, semTable, cursor, simplified) case *sqlparser.Where: simplified = removeTableinWhere(node, shouldKeepExpr, simplified) - case sqlparser.SelectExprs: + case *sqlparser.SelectExprs: simplified = removeTableinSelectExprs(node, cursor, shouldKeepExpr, simplified) case *sqlparser.GroupBy: simplified = removeTableInGroupBy(node, cursor, shouldKeepExpr, simplified) @@ -352,14 +352,14 @@ func removeTableinWhere(node *sqlparser.Where, shouldKeepExpr func(sqlparser.Exp return simplified } -func removeTableinSelectExprs(node sqlparser.SelectExprs, cursor *sqlparser.Cursor, shouldKeepExpr func(sqlparser.Expr) bool, simplified bool) bool { +func removeTableinSelectExprs(node *sqlparser.SelectExprs, cursor *sqlparser.Cursor, shouldKeepExpr func(sqlparser.Expr) bool, simplified bool) bool { _, isSel := cursor.Parent().(*sqlparser.Select) if !isSel { return simplified } - var newExprs sqlparser.SelectExprs - for _, ae := range node { + var newExprs []sqlparser.SelectExpr + for _, ae := range node.Exprs { expr, ok := ae.(*sqlparser.AliasedExpr) if !ok { newExprs = append(newExprs, ae) @@ -371,7 +371,8 @@ func removeTableinSelectExprs(node sqlparser.SelectExprs, cursor *sqlparser.Curs simplified = true } } - cursor.Replace(newExprs) + + cursor.Replace(&sqlparser.SelectExprs{Exprs: newExprs}) return simplified } @@ -435,7 +436,7 @@ func visitAllExpressionsInAST(clone sqlparser.TableStatement, visit func(express } up := func(cursor *sqlparser.Cursor) bool { switch node := cursor.Node().(type) { - case sqlparser.SelectExprs: + case *sqlparser.SelectExprs: return visitSelectExprs(node, cursor, visit) case *sqlparser.Where: return visitWhere(node, visit) @@ -455,13 +456,13 @@ func visitAllExpressionsInAST(clone sqlparser.TableStatement, visit func(express sqlparser.SafeRewrite(clone, alwaysVisitChildren, up) } -func visitSelectExprs(node sqlparser.SelectExprs, cursor *sqlparser.Cursor, visit func(expressionCursor) bool) bool { +func visitSelectExprs(node *sqlparser.SelectExprs, cursor *sqlparser.Cursor, visit func(expressionCursor) bool) bool { _, isSel := cursor.Parent().(*sqlparser.Select) if !isSel { return true } - for idx := 0; idx < len(node); idx++ { - ae := node[idx] + for idx := 0; idx < len(node.Exprs); idx++ { + ae := node.Exprs[idx] expr, ok := ae.(*sqlparser.AliasedExpr) if !ok { continue @@ -480,25 +481,23 @@ func visitSelectExprs(node sqlparser.SelectExprs, cursor *sqlparser.Cursor, visi if removed { panic("can't remove twice, silly") } - if len(node) == 1 { + if len(node.Exprs) == 1 { // can't remove the last expressions - we'd end up with an empty SELECT clause return false } - withoutElement := append(node[:idx], node[idx+1:]...) - cursor.Replace(withoutElement) - node = withoutElement + withoutElement := append(node.Exprs[:idx], node.Exprs[idx+1:]...) + node.Exprs = withoutElement removed = true return true }, /*restore*/ func() { if removed { - front := make(sqlparser.SelectExprs, idx) - copy(front, node[:idx]) - back := make(sqlparser.SelectExprs, len(node)-idx) - copy(back, node[idx:]) + front := make([]sqlparser.SelectExpr, idx) + copy(front, node.Exprs[:idx]) + back := make([]sqlparser.SelectExpr, len(node.Exprs)-idx) + copy(back, node.Exprs[idx:]) frontWithRestoredExpr := append(front, ae) - node = append(frontWithRestoredExpr, back...) - cursor.Replace(node) + node.Exprs = append(frontWithRestoredExpr, back...) removed = false return } diff --git a/go/vt/vtgate/vindexes/foreign_keys.go b/go/vt/vtgate/vindexes/foreign_keys.go index e9f8c986d10..46399b6576c 100644 --- a/go/vt/vtgate/vindexes/foreign_keys.go +++ b/go/vt/vtgate/vindexes/foreign_keys.go @@ -162,7 +162,7 @@ func (vschema *VSchema) AddPrimaryKey(ksname, tblName string, cols []string) err } // AddUniqueKey is for testing only. -func (vschema *VSchema) AddUniqueKey(ksname, tblName string, exprs sqlparser.Exprs) error { +func (vschema *VSchema) AddUniqueKey(ksname, tblName string, exprs []sqlparser.Expr) error { ks, ok := vschema.Keyspaces[ksname] if !ok { return fmt.Errorf("keyspace %s not found in vschema", ksname) diff --git a/go/vt/vtgate/vindexes/vschema.go b/go/vt/vtgate/vindexes/vschema.go index 5499200768b..686c3edcb4e 100644 --- a/go/vt/vtgate/vindexes/vschema.go +++ b/go/vt/vtgate/vindexes/vschema.go @@ -154,8 +154,8 @@ type BaseTable struct { // index can be columns or expression. // For Primary key, functional indexes are not allowed, therefore it will only be columns. // MySQL error message: ERROR 3756 (HY000): The primary key cannot be a functional index - PrimaryKey sqlparser.Columns `json:"primary_key,omitempty"` - UniqueKeys []sqlparser.Exprs `json:"unique_keys,omitempty"` + PrimaryKey sqlparser.Columns `json:"primary_key,omitempty"` + UniqueKeys [][]sqlparser.Expr `json:"unique_keys,omitempty"` } // GetTableName gets the sqlparser.TableName for the vindex Table. diff --git a/go/vt/vtgate/vschema_manager.go b/go/vt/vtgate/vschema_manager.go index 7a1c5ee1d24..0fb5904f133 100644 --- a/go/vt/vtgate/vschema_manager.go +++ b/go/vt/vtgate/vschema_manager.go @@ -270,7 +270,7 @@ func (vm *VSchemaManager) updateTableInfo(vschema *vindexes.VSchema, ks *vindexe rTbl.PrimaryKey = append(rTbl.PrimaryKey, idxCol.Column) } case sqlparser.IndexTypeUnique: - var uniqueKey sqlparser.Exprs + var uniqueKey []sqlparser.Expr for _, idxCol := range idxDef.Columns { if idxCol.Expression == nil { uniqueKey = append(uniqueKey, sqlparser.NewColName(idxCol.Column.String())) diff --git a/go/vt/vtgate/vschema_manager_test.go b/go/vt/vtgate/vschema_manager_test.go index 42515d59788..9dae4f1fc5a 100644 --- a/go/vt/vtgate/vschema_manager_test.go +++ b/go/vt/vtgate/vschema_manager_test.go @@ -90,7 +90,7 @@ func TestVSchemaUpdate(t *testing.T) { Keyspace: ks, ColumnListAuthoritative: true, PrimaryKey: sqlparser.Columns{sqlparser.NewIdentifierCI("a")}, - UniqueKeys: []sqlparser.Exprs{ + UniqueKeys: [][]sqlparser.Expr{ {sqlparser.NewColName("b")}, {sqlparser.NewColName("c"), sqlparser.NewColName("d")}, }, @@ -100,7 +100,7 @@ func TestVSchemaUpdate(t *testing.T) { Keyspace: ks, ColumnListAuthoritative: true, PrimaryKey: sqlparser.Columns{sqlparser.NewIdentifierCI("a")}, - UniqueKeys: []sqlparser.Exprs{ + UniqueKeys: [][]sqlparser.Expr{ {&sqlparser.BinaryExpr{Operator: sqlparser.DivOp, Left: sqlparser.NewColName("b"), Right: sqlparser.NewIntLiteral("2")}}, {sqlparser.NewColName("c"), &sqlparser.BinaryExpr{Operator: sqlparser.PlusOp, Left: sqlparser.NewColName("d"), Right: sqlparser.NewColName("e")}}, }, @@ -524,16 +524,20 @@ func TestVSchemaViewsUpdate(t *testing.T) { vs = vschema vs.ResetCreated() } + + s1 := &sqlparser.Select{ + From: sqlparser.TableExprs{sqlparser.NewAliasedTableExpr(sqlparser.NewTableName("t1"), "")}, + } + s2 := &sqlparser.Select{ + From: sqlparser.TableExprs{sqlparser.NewAliasedTableExpr(sqlparser.NewTableName("t2"), "")}, + } + s1.AddSelectExpr(sqlparser.NewAliasedExpr(sqlparser.NewIntLiteral("1"), "")) + s2.AddSelectExpr(sqlparser.NewAliasedExpr(sqlparser.NewIntLiteral("2"), "")) vm.schema = &fakeSchema{v: map[string]sqlparser.TableStatement{ - "v1": &sqlparser.Select{ - From: sqlparser.TableExprs{sqlparser.NewAliasedTableExpr(sqlparser.NewTableName("t1"), "")}, - SelectExprs: sqlparser.SelectExprs{sqlparser.NewAliasedExpr(sqlparser.NewIntLiteral("1"), "")}, - }, - "v2": &sqlparser.Select{ - From: sqlparser.TableExprs{sqlparser.NewAliasedTableExpr(sqlparser.NewTableName("t2"), "")}, - SelectExprs: sqlparser.SelectExprs{sqlparser.NewAliasedExpr(sqlparser.NewIntLiteral("2"), "")}, - }, + "v1": s1, + "v2": s2, }} + vm.VSchemaUpdate(&vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "ks": {Sharded: true}, diff --git a/go/vt/vttablet/tabletmanager/vdiff/report.go b/go/vt/vttablet/tabletmanager/vdiff/report.go index b53288b3019..5c7a2593558 100644 --- a/go/vt/vttablet/tabletmanager/vdiff/report.go +++ b/go/vt/vttablet/tabletmanager/vdiff/report.go @@ -81,7 +81,7 @@ func (td *tableDiffer) genRowDiff(queryStmt string, row []sqltypes.Value, opts * addVal := func(index int, truncateAt int) { buf := sqlparser.NewTrackedBuffer(nil) - sel.SelectExprs[index].Format(buf) + sel.SelectExprs.Exprs[index].Format(buf) col := buf.String() // Let's truncate if it's really worth it to avoid losing // value for a few chars. @@ -106,7 +106,7 @@ func (td *tableDiffer) genRowDiff(queryStmt string, row []sqltypes.Value, opts * } truncateAt := int(opts.GetRowDiffColumnTruncateAt()) - for i := range sel.SelectExprs { + for i := range sel.SelectExprs.Exprs { if _, pk := pks[i]; !pk { addVal(i, truncateAt) } @@ -121,7 +121,7 @@ func (td *tableDiffer) genDebugQueryDiff(sel *sqlparser.Select, row []sqltypes.V if onlyPks { for i, pkI := range td.tablePlan.selectPks { - pk := sel.SelectExprs[pkI] + pk := sel.GetColumns()[pkI] pk.Format(buf) if i != len(td.tablePlan.selectPks)-1 { buf.Myprintf(", ") @@ -134,7 +134,7 @@ func (td *tableDiffer) genDebugQueryDiff(sel *sqlparser.Select, row []sqltypes.V buf.Myprintf(sqlparser.ToString(sel.From)) buf.Myprintf(" where ") for i, pkI := range td.tablePlan.selectPks { - sel.SelectExprs[pkI].Format(buf) + sel.SelectExprs.Exprs[pkI].Format(buf) buf.Myprintf("=") row[pkI].EncodeSQL(buf) if i != len(td.tablePlan.selectPks)-1 { diff --git a/go/vt/vttablet/tabletmanager/vdiff/table_differ.go b/go/vt/vttablet/tabletmanager/vdiff/table_differ.go index 1ebeab8ed8d..1904a8e97a5 100644 --- a/go/vt/vttablet/tabletmanager/vdiff/table_differ.go +++ b/go/vt/vttablet/tabletmanager/vdiff/table_differ.go @@ -863,12 +863,12 @@ func (td *tableDiffer) lastPKFromRow(row []sqltypes.Value) *tabletmanagerdatapb. // VReplication workflow would have converted the datetime columns expecting the // source to have been in the SourceTimeZone and target in TargetTimeZone. We need // to do the reverse conversion in VDiff before the comparison. -func (td *tableDiffer) adjustForSourceTimeZone(targetSelectExprs sqlparser.SelectExprs, fields map[string]querypb.Type) sqlparser.SelectExprs { +func (td *tableDiffer) adjustForSourceTimeZone(targetSelectExprs []sqlparser.SelectExpr, fields map[string]querypb.Type) []sqlparser.SelectExpr { if td.wd.ct.sourceTimeZone == "" { return targetSelectExprs } log.Infof("source time zone specified: %s", td.wd.ct.sourceTimeZone) - var newSelectExprs sqlparser.SelectExprs + var newSelectExprs []sqlparser.SelectExpr var modified bool for _, expr := range targetSelectExprs { converted := false @@ -879,14 +879,11 @@ func (td *tableDiffer) adjustForSourceTimeZone(targetSelectExprs sqlparser.Selec colName := colAs.Name.Lowered() fieldType := fields[colName] if fieldType == querypb.Type_DATETIME { - convertTZFuncExpr = &sqlparser.FuncExpr{ - Name: sqlparser.NewIdentifierCI("convert_tz"), - Exprs: sqlparser.Exprs{ - selExpr.Expr, - sqlparser.NewStrLiteral(td.wd.ct.targetTimeZone), - sqlparser.NewStrLiteral(td.wd.ct.sourceTimeZone), - }, - } + convertTZFuncExpr = sqlparser.NewFuncExpr("convert_tz", + selExpr.Expr, + sqlparser.NewStrLiteral(td.wd.ct.targetTimeZone), + sqlparser.NewStrLiteral(td.wd.ct.sourceTimeZone), + ) log.Infof("converting datetime column %s using convert_tz()", colName) newSelectExprs = append(newSelectExprs, &sqlparser.AliasedExpr{Expr: convertTZFuncExpr, As: colAs.Name}) converted = true diff --git a/go/vt/vttablet/tabletmanager/vdiff/table_plan.go b/go/vt/vttablet/tabletmanager/vdiff/table_plan.go index b5ea384d864..49f2713b58a 100644 --- a/go/vt/vttablet/tabletmanager/vdiff/table_plan.go +++ b/go/vt/vttablet/tabletmanager/vdiff/table_plan.go @@ -87,14 +87,14 @@ func (td *tableDiffer) buildTablePlan(dbClient binlogplayer.DBClient, dbName str targetSelect := &sqlparser.Select{} // Aggregates is the list of Aggregate functions, if any. var aggregates []*engine.AggregateParams - for _, selExpr := range sel.SelectExprs { + for _, selExpr := range sel.GetColumns() { switch selExpr := selExpr.(type) { case *sqlparser.StarExpr: // If it's a '*' expression, expand column list from the schema. for _, fld := range tp.table.Fields { aliased := &sqlparser.AliasedExpr{Expr: &sqlparser.ColName{Name: sqlparser.NewIdentifierCI(fld.Name)}} - sourceSelect.SelectExprs = append(sourceSelect.SelectExprs, aliased) - targetSelect.SelectExprs = append(targetSelect.SelectExprs, aliased) + sourceSelect.AddSelectExpr(aliased) + targetSelect.AddSelectExpr(aliased) } case *sqlparser.AliasedExpr: var targetCol *sqlparser.ColName @@ -108,8 +108,8 @@ func (td *tableDiffer) buildTablePlan(dbClient binlogplayer.DBClient, dbName str targetCol = &sqlparser.ColName{Name: selExpr.As} } // If the input was "select a as b", then source will use "a" and target will use "b". - sourceSelect.SelectExprs = append(sourceSelect.SelectExprs, selExpr) - targetSelect.SelectExprs = append(targetSelect.SelectExprs, &sqlparser.AliasedExpr{Expr: targetCol}) + sourceSelect.AddSelectExpr(selExpr) + targetSelect.AddSelectExpr(&sqlparser.AliasedExpr{Expr: targetCol}) // Check if it's an aggregate expression if expr, ok := selExpr.Expr.(sqlparser.AggrFunc); ok { @@ -121,7 +121,7 @@ func (td *tableDiffer) buildTablePlan(dbClient binlogplayer.DBClient, dbName str // but will need to be revisited when we add such support to vreplication aggregates = append(aggregates, engine.NewAggregateParam( /*opcode*/ opcode.AggregateSum, - /*offset*/ len(sourceSelect.SelectExprs)-1, + /*offset*/ sourceSelect.GetColumnCount()-1, /*alias*/ "", collationEnv), ) } @@ -135,12 +135,12 @@ func (td *tableDiffer) buildTablePlan(dbClient binlogplayer.DBClient, dbName str fields[strings.ToLower(field.Name)] = field.Type } - targetSelect.SelectExprs = td.adjustForSourceTimeZone(targetSelect.SelectExprs, fields) + targetSelect.SetSelectExprs(td.adjustForSourceTimeZone(targetSelect.GetColumns(), fields)...) // Start with adding all columns for comparison. - tp.compareCols = make([]compareColInfo, len(sourceSelect.SelectExprs)) + tp.compareCols = make([]compareColInfo, sourceSelect.GetColumnCount()) for i := range tp.compareCols { tp.compareCols[i].colIndex = i - colname, err := getColumnNameForSelectExpr(targetSelect.SelectExprs[i]) + colname, err := getColumnNameForSelectExpr(targetSelect.GetColumns()[i]) if err != nil { return nil, err } @@ -215,7 +215,7 @@ func (tp *tablePlan) findPKs(dbClient binlogplayer.DBClient, targetSelect *sqlpa var orderby sqlparser.OrderBy for _, pk := range tp.table.PrimaryKeyColumns { found := false - for i, selExpr := range targetSelect.SelectExprs { + for i, selExpr := range targetSelect.SelectExprs.Exprs { expr := selExpr.(*sqlparser.AliasedExpr).Expr colname := "" switch ct := expr.(type) { diff --git a/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go b/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go index b8a86b94de5..5c2b0f21dc5 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go +++ b/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go @@ -234,10 +234,10 @@ func buildTablePlan(tableName string, rule *binlogdatapb.Rule, colInfos []*Colum Match: fromTable, } - if expr, ok := sel.SelectExprs[0].(*sqlparser.StarExpr); ok { + if expr, ok := sel.SelectExprs.Exprs[0].(*sqlparser.StarExpr); ok { // If it's a "select *", we return a partial plan, and complete // it when we get back field info from the stream. - if len(sel.SelectExprs) != 1 { + if len(sel.SelectExprs.Exprs) != 1 { return nil, planError(fmt.Errorf("unsupported mix of '*' and columns"), sqlparser.String(sel)) } if !expr.TableName.IsEmpty() { @@ -272,7 +272,7 @@ func buildTablePlan(tableName string, rule *binlogdatapb.Rule, colInfos []*Colum workflowConfig: workflowConfig, } - if err := tpb.analyzeExprs(sel.SelectExprs); err != nil { + if err := tpb.analyzeExprs(sel.SelectExprs.Exprs); err != nil { return nil, planError(err, sqlparser.String(sel)) } // It's possible that the target table does not materialize all @@ -309,11 +309,9 @@ func buildTablePlan(tableName string, rule *binlogdatapb.Rule, colInfos []*Colum // if there are no columns being selected the select expression can be empty, so we "select 1" so we have a valid // select to get a row back - if len(tpb.sendSelect.SelectExprs) == 0 { - tpb.sendSelect.SelectExprs = sqlparser.SelectExprs([]sqlparser.SelectExpr{ - &sqlparser.AliasedExpr{ - Expr: sqlparser.NewIntLiteral("1"), - }, + if tpb.sendSelect.SelectExprs == nil || len(tpb.sendSelect.SelectExprs.Exprs) == 0 { + tpb.sendSelect.AddSelectExpr(&sqlparser.AliasedExpr{ + Expr: sqlparser.NewIntLiteral("1"), }) } commentsList := []string{} @@ -413,7 +411,7 @@ func analyzeSelectFrom(query string, parser *sqlparser.Parser) (sel *sqlparser.S return sel, fromTable.String(), nil } -func (tpb *tablePlanBuilder) analyzeExprs(selExprs sqlparser.SelectExprs) error { +func (tpb *tablePlanBuilder) analyzeExprs(selExprs []sqlparser.SelectExpr) error { for _, selExpr := range selExprs { cexpr, err := tpb.analyzeExpr(selExpr) if err != nil { @@ -468,7 +466,7 @@ func (tpb *tablePlanBuilder) analyzeExpr(selExpr sqlparser.SelectExpr) (*colExpr } cexpr.expr = expr cexpr.operation = opExpr - tpb.sendSelect.SelectExprs = append(tpb.sendSelect.SelectExprs, &sqlparser.AliasedExpr{Expr: selExpr, As: as}) + tpb.sendSelect.AddSelectExpr(&sqlparser.AliasedExpr{Expr: selExpr, As: as}) cexpr.references[as.String()] = true return cexpr, nil } @@ -478,7 +476,8 @@ func (tpb *tablePlanBuilder) analyzeExpr(selExpr sqlparser.SelectExpr) (*colExpr if len(expr.Exprs) != 0 { return nil, fmt.Errorf("unsupported multiple keyspace_id expressions: %v", sqlparser.String(expr)) } - tpb.sendSelect.SelectExprs = append(tpb.sendSelect.SelectExprs, &sqlparser.AliasedExpr{Expr: aliased.Expr}) + + tpb.sendSelect.AddSelectExpr(&sqlparser.AliasedExpr{Expr: aliased.Expr}) // The vstreamer responds with "keyspace_id" as the field name for this request. cexpr.expr = &sqlparser.ColName{Name: sqlparser.NewIdentifierCI("keyspace_id")} return cexpr, nil @@ -538,7 +537,7 @@ func (tpb *tablePlanBuilder) analyzeExpr(selExpr sqlparser.SelectExpr) (*colExpr // addCol adds the specified column to the send query // if it's not already present. func (tpb *tablePlanBuilder) addCol(ident sqlparser.IdentifierCI) { - tpb.sendSelect.SelectExprs = append(tpb.sendSelect.SelectExprs, &sqlparser.AliasedExpr{ + tpb.sendSelect.AddSelectExpr(&sqlparser.AliasedExpr{ Expr: &sqlparser.ColName{Name: ident}, }) } diff --git a/go/vt/vttablet/tabletserver/planbuilder/builder.go b/go/vt/vttablet/tabletserver/planbuilder/builder.go index 6df89f7caf8..f1a6e89416c 100644 --- a/go/vt/vttablet/tabletserver/planbuilder/builder.go +++ b/go/vt/vttablet/tabletserver/planbuilder/builder.go @@ -44,7 +44,7 @@ func analyzeSelect(env *vtenv.Environment, sel *sqlparser.Select, tables map[str } // Check if it's a NEXT VALUE statement. - if nextVal, ok := sel.SelectExprs[0].(*sqlparser.Nextval); ok { + if nextVal, ok := sel.GetColumns()[0].(*sqlparser.Nextval); ok { if plan.Table == nil || plan.Table.Type != schema.Sequence { return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "%s is not a sequence", sqlparser.ToString(sel.From)) } diff --git a/go/vt/vttablet/tabletserver/planbuilder/permission.go b/go/vt/vttablet/tabletserver/planbuilder/permission.go index 1949d6ce739..03f926e0679 100644 --- a/go/vt/vttablet/tabletserver/planbuilder/permission.go +++ b/go/vt/vttablet/tabletserver/planbuilder/permission.go @@ -38,7 +38,7 @@ func BuildPermissions(stmt sqlparser.Statement) []Permission { switch node := stmt.(type) { case *sqlparser.Select: role := tableacl.READER - if _, ok := node.SelectExprs[0].(*sqlparser.Nextval); ok { + if _, ok := node.GetColumns()[0].(*sqlparser.Nextval); ok { role = tableacl.WRITER } permissions = buildSubqueryPermissions(node, role, permissions) diff --git a/go/vt/vttablet/tabletserver/vstreamer/planbuilder.go b/go/vt/vttablet/tabletserver/vstreamer/planbuilder.go index e5115afe6d3..1293efa3112 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/planbuilder.go +++ b/go/vt/vttablet/tabletserver/vstreamer/planbuilder.go @@ -465,7 +465,7 @@ func buildTablePlan(env *vtenv.Environment, ti *Table, vschema *localVSchema, qu log.Errorf("%s", err.Error()) return nil, err } - if err := plan.analyzeExprs(vschema, sel.SelectExprs); err != nil { + if err := plan.analyzeExprs(vschema, sel.GetColumns()); err != nil { log.Errorf("%s", err.Error()) return nil, err } @@ -670,7 +670,7 @@ func splitAndExpression(filters []sqlparser.Expr, node sqlparser.Expr) []sqlpars return append(filters, node) } -func (plan *Plan) analyzeExprs(vschema *localVSchema, selExprs sqlparser.SelectExprs) error { +func (plan *Plan) analyzeExprs(vschema *localVSchema, selExprs []sqlparser.SelectExpr) error { if _, ok := selExprs[0].(*sqlparser.StarExpr); !ok { for _, expr := range selExprs { cExpr, err := plan.analyzeExpr(vschema, expr) @@ -681,7 +681,7 @@ func (plan *Plan) analyzeExprs(vschema *localVSchema, selExprs sqlparser.SelectE } } else { if len(selExprs) != 1 { - return fmt.Errorf("unsupported: %v", sqlparser.String(selExprs)) + return fmt.Errorf("unsupported: %v", sqlparser.SliceString(selExprs)) } plan.ColExprs = make([]ColExpr, len(plan.Table.Fields)) for i, col := range plan.Table.Fields { @@ -838,7 +838,7 @@ func (plan *Plan) analyzeExpr(vschema *localVSchema, selExpr sqlparser.SelectExp // analyzeInKeyRange allows the following constructs: "in_keyrange('-80')", // "in_keyrange(col, 'hash', '-80')", "in_keyrange(col, 'local_vindex', '-80')", or // "in_keyrange(col, 'ks.external_vindex', '-80')". -func (plan *Plan) analyzeInKeyRange(vschema *localVSchema, exprs sqlparser.Exprs) error { +func (plan *Plan) analyzeInKeyRange(vschema *localVSchema, exprs []sqlparser.Expr) error { var colnames []sqlparser.IdentifierCI var krExpr sqlparser.Expr whereFilter := Filter{ @@ -879,7 +879,7 @@ func (plan *Plan) analyzeInKeyRange(vschema *localVSchema, exprs sqlparser.Exprs krExpr = exprs[len(exprs)-1] default: - return vterrors.Errorf(vtrpcpb.Code_INTERNAL, "[BUG] unexpected in_keyrange parameters: %v", sqlparser.String(exprs)) + return vterrors.Errorf(vtrpcpb.Code_INTERNAL, "[BUG] unexpected in_keyrange parameters: %v", sqlparser.SliceString(exprs)) } var err error whereFilter.VindexColumns, err = buildVindexColumns(plan.Table, colnames) diff --git a/go/vt/wrangler/materializer.go b/go/vt/wrangler/materializer.go index 27aaa6935be..2bf2ec824ee 100644 --- a/go/vt/wrangler/materializer.go +++ b/go/vt/wrangler/materializer.go @@ -1393,7 +1393,7 @@ func (mz *materializer) generateInserts(ctx context.Context, sourceShards []*top } mappedCols = append(mappedCols, colName) } - subExprs := make(sqlparser.Exprs, 0, len(mappedCols)+2) + subExprs := make([]sqlparser.Expr, 0, len(mappedCols)+2) for _, mappedCol := range mappedCols { subExprs = append(subExprs, mappedCol) } @@ -1412,10 +1412,7 @@ func (mz *materializer) generateInserts(ctx context.Context, sourceShards []*top } subExprs = append(subExprs, sqlparser.NewStrLiteral(vindexName)) subExprs = append(subExprs, sqlparser.NewStrLiteral("{{.keyrange}}")) - inKeyRange := &sqlparser.FuncExpr{ - Name: sqlparser.NewIdentifierCI("in_keyrange"), - Exprs: subExprs, - } + inKeyRange := sqlparser.NewFuncExpr("in_keyrange", subExprs...) if sel.Where != nil { sel.Where = &sqlparser.Where{ Type: sqlparser.WhereClause, @@ -1489,7 +1486,7 @@ func (mz *materializer) getWorkflowSubType() (binlogdatapb.VReplicationWorkflowS } func matchColInSelect(col sqlparser.IdentifierCI, sel *sqlparser.Select) (*sqlparser.ColName, error) { - for _, selExpr := range sel.SelectExprs { + for _, selExpr := range sel.GetColumns() { switch selExpr := selExpr.(type) { case *sqlparser.StarExpr: return &sqlparser.ColName{Name: col}, nil diff --git a/go/vt/wrangler/vdiff.go b/go/vt/wrangler/vdiff.go index 9991b5bd633..7c45bc2aeac 100644 --- a/go/vt/wrangler/vdiff.go +++ b/go/vt/wrangler/vdiff.go @@ -503,7 +503,7 @@ func findPKs(env *vtenv.Environment, table *tabletmanagerdatapb.TableDefinition, var orderby sqlparser.OrderBy for _, pk := range table.PrimaryKeyColumns { found := false - for i, selExpr := range targetSelect.SelectExprs { + for i, selExpr := range targetSelect.GetColumns() { expr := selExpr.(*sqlparser.AliasedExpr).Expr colname := "" switch ct := expr.(type) { @@ -603,12 +603,12 @@ func getColumnCollations(venv *vtenv.Environment, table *tabletmanagerdatapb.Tab // If SourceTimeZone is defined in the BinlogSource, the VReplication workflow would have converted the datetime // columns expecting the source to have been in the SourceTimeZone and target in TargetTimeZone. We need to do the reverse // conversion in VDiff before comparing to the source -func (df *vdiff) adjustForSourceTimeZone(targetSelectExprs sqlparser.SelectExprs, fields map[string]querypb.Type) sqlparser.SelectExprs { +func (df *vdiff) adjustForSourceTimeZone(targetSelectExprs []sqlparser.SelectExpr, fields map[string]querypb.Type) []sqlparser.SelectExpr { if df.sourceTimeZone == "" { return targetSelectExprs } log.Infof("source time zone specified: %s", df.sourceTimeZone) - var newSelectExprs sqlparser.SelectExprs + var newSelectExprs []sqlparser.SelectExpr var modified bool for _, expr := range targetSelectExprs { converted := false @@ -619,14 +619,10 @@ func (df *vdiff) adjustForSourceTimeZone(targetSelectExprs sqlparser.SelectExprs colName := colAs.Name.Lowered() fieldType := fields[colName] if fieldType == querypb.Type_DATETIME { - convertTZFuncExpr = &sqlparser.FuncExpr{ - Name: sqlparser.NewIdentifierCI("convert_tz"), - Exprs: sqlparser.Exprs{ - colAs, - sqlparser.NewStrLiteral(df.targetTimeZone), - sqlparser.NewStrLiteral(df.sourceTimeZone), - }, - } + convertTZFuncExpr = sqlparser.NewFuncExpr("convert_tz", + colAs, + sqlparser.NewStrLiteral(df.targetTimeZone), + sqlparser.NewStrLiteral(df.sourceTimeZone)) log.Infof("converting datetime column %s using convert_tz()", colName) newSelectExprs = append(newSelectExprs, &sqlparser.AliasedExpr{Expr: convertTZFuncExpr, As: colAs.Name}) converted = true @@ -679,14 +675,14 @@ func (df *vdiff) buildTablePlan(table *tabletmanagerdatapb.TableDefinition, quer targetSelect := &sqlparser.Select{} // aggregates contains the list if Aggregate functions, if any. var aggregates []*engine.AggregateParams - for _, selExpr := range sel.SelectExprs { + for _, selExpr := range sel.GetColumns() { switch selExpr := selExpr.(type) { case *sqlparser.StarExpr: // If it's a '*' expression, expand column list from the schema. for _, fld := range table.Fields { aliased := &sqlparser.AliasedExpr{Expr: &sqlparser.ColName{Name: sqlparser.NewIdentifierCI(fld.Name)}} - sourceSelect.SelectExprs = append(sourceSelect.SelectExprs, aliased) - targetSelect.SelectExprs = append(targetSelect.SelectExprs, aliased) + sourceSelect.AddSelectExpr(aliased) + targetSelect.AddSelectExpr(aliased) } case *sqlparser.AliasedExpr: var targetCol *sqlparser.ColName @@ -700,8 +696,8 @@ func (df *vdiff) buildTablePlan(table *tabletmanagerdatapb.TableDefinition, quer targetCol = &sqlparser.ColName{Name: selExpr.As} } // If the input was "select a as b", then source will use "a" and target will use "b". - sourceSelect.SelectExprs = append(sourceSelect.SelectExprs, selExpr) - targetSelect.SelectExprs = append(targetSelect.SelectExprs, &sqlparser.AliasedExpr{Expr: targetCol}) + sourceSelect.AddSelectExpr(selExpr) + targetSelect.AddSelectExpr(&sqlparser.AliasedExpr{Expr: targetCol}) // Check if it's an aggregate expression if expr, ok := selExpr.Expr.(sqlparser.AggrFunc); ok { @@ -713,7 +709,7 @@ func (df *vdiff) buildTablePlan(table *tabletmanagerdatapb.TableDefinition, quer // but will need to be revisited when we add such support to vreplication aggregates = append(aggregates, engine.NewAggregateParam( /*opcode*/ opcode.AggregateSum, - /*offset*/ len(sourceSelect.SelectExprs)-1, + /*offset*/ sourceSelect.GetColumnCount()-1, /*alias*/ "", df.env.CollationEnv())) } } @@ -727,12 +723,12 @@ func (df *vdiff) buildTablePlan(table *tabletmanagerdatapb.TableDefinition, quer fields[strings.ToLower(field.Name)] = field.Type } - targetSelect.SelectExprs = df.adjustForSourceTimeZone(targetSelect.SelectExprs, fields) + targetSelect.SelectExprs.Exprs = df.adjustForSourceTimeZone(targetSelect.SelectExprs.Exprs, fields) // Start with adding all columns for comparison. - td.compareCols = make([]compareColInfo, len(sourceSelect.SelectExprs)) + td.compareCols = make([]compareColInfo, sourceSelect.GetColumnCount()) for i := range td.compareCols { td.compareCols[i].colIndex = i - colname, err := getColumnNameForSelectExpr(targetSelect.SelectExprs[i]) + colname, err := getColumnNameForSelectExpr(targetSelect.GetColumns()[i]) if err != nil { return nil, err } @@ -1357,16 +1353,16 @@ func (td *tableDiffer) genRowDiff(queryStmt string, row []sqltypes.Value, debug, if onlyPks { for _, pkI := range td.selectPks { buf := sqlparser.NewTrackedBuffer(nil) - sel.SelectExprs[pkI].Format(buf) + sel.SelectExprs.Exprs[pkI].Format(buf) col := buf.String() drp.Row[col] = row[pkI] } return drp, nil } - for i := range sel.SelectExprs { + for i := range sel.SelectExprs.Exprs { buf := sqlparser.NewTrackedBuffer(nil) - sel.SelectExprs[i].Format(buf) + sel.SelectExprs.Exprs[i].Format(buf) col := buf.String() drp.Row[col] = row[i] } @@ -1380,7 +1376,7 @@ func (td *tableDiffer) genDebugQueryDiff(sel *sqlparser.Select, row []sqltypes.V if onlyPks { for i, pkI := range td.selectPks { - pk := sel.SelectExprs[pkI] + pk := sel.GetColumns()[pkI] pk.Format(buf) if i != len(td.selectPks)-1 { buf.Myprintf(", ") @@ -1393,7 +1389,7 @@ func (td *tableDiffer) genDebugQueryDiff(sel *sqlparser.Select, row []sqltypes.V buf.Myprintf(sqlparser.ToString(sel.From)) buf.Myprintf(" where ") for i, pkI := range td.selectPks { - sel.SelectExprs[pkI].Format(buf) + sel.SelectExprs.Exprs[pkI].Format(buf) buf.Myprintf("=") row[pkI].EncodeSQL(buf) if i != len(td.selectPks)-1 { diff --git a/go/vt/wrangler/vdiff_test.go b/go/vt/wrangler/vdiff_test.go index 44c3a22a336..4bbaed35c3f 100644 --- a/go/vt/wrangler/vdiff_test.go +++ b/go/vt/wrangler/vdiff_test.go @@ -1071,11 +1071,10 @@ func TestVDiffFindPKs(t *testing.T) { Schema: "create table t1(c1 bigint, c2 bigint, primary key(c1))", }, targetSelect: &sqlparser.Select{ - SelectExprs: sqlparser.SelectExprs{ - &sqlparser.AliasedExpr{Expr: &sqlparser.ColName{Name: sqlparser.NewIdentifierCI("c1")}}, - &sqlparser.AliasedExpr{Expr: &sqlparser.ColName{Name: sqlparser.NewIdentifierCI("c2")}}, - }, - }, + SelectExprs: &sqlparser.SelectExprs{ + Exprs: []sqlparser.SelectExpr{ + &sqlparser.AliasedExpr{Expr: &sqlparser.ColName{Name: sqlparser.NewIdentifierCI("c1")}}, + &sqlparser.AliasedExpr{Expr: &sqlparser.ColName{Name: sqlparser.NewIdentifierCI("c2")}}}}}, tdIn: &tableDiffer{ compareCols: []compareColInfo{{0, collations.Unknown, nil, false}, {1, collations.Unknown, nil, false}}, comparePKs: []compareColInfo{}, @@ -1097,12 +1096,12 @@ func TestVDiffFindPKs(t *testing.T) { Schema: "create table t1(c1 bigint, c2 bigint, c3 varchar(50), c4 bigint, primary key(c1, c4))", }, targetSelect: &sqlparser.Select{ - SelectExprs: sqlparser.SelectExprs{ - &sqlparser.AliasedExpr{Expr: &sqlparser.ColName{Name: sqlparser.NewIdentifierCI("c1")}}, - &sqlparser.AliasedExpr{Expr: &sqlparser.ColName{Name: sqlparser.NewIdentifierCI("c2")}}, - &sqlparser.AliasedExpr{Expr: &sqlparser.FuncExpr{Name: sqlparser.NewIdentifierCI("c3")}}, - &sqlparser.AliasedExpr{Expr: &sqlparser.ColName{Name: sqlparser.NewIdentifierCI("c4")}}, - }, + SelectExprs: &sqlparser.SelectExprs{ + Exprs: []sqlparser.SelectExpr{ + &sqlparser.AliasedExpr{Expr: sqlparser.NewColName("c1")}, + &sqlparser.AliasedExpr{Expr: sqlparser.NewColName("c2")}, + &sqlparser.AliasedExpr{Expr: sqlparser.NewFuncExpr("c3")}, + &sqlparser.AliasedExpr{Expr: sqlparser.NewColName("c4")}}}, }, tdIn: &tableDiffer{ compareCols: []compareColInfo{{0, collations.Unknown, nil, false}, {1, collations.Unknown, nil, false}, {2, collations.Unknown, nil, false}, {3, collations.Unknown, nil, false}},