From f1fd2320bd3e8788168315c6a8d375ebc19bef1b Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 12 Mar 2021 14:10:56 +0530 Subject: [PATCH 01/13] initial commit for deep equals ast generator Signed-off-by: Harshit Gangal --- go/tools/asthelpergen/asthelpergen.go | 46 ++------ go/tools/asthelpergen/asthelpergen_test.go | 2 +- go/tools/asthelpergen/clone_gen.go | 9 +- go/tools/asthelpergen/equals_gen.go | 111 ++++++++++++++++++++ go/tools/asthelpergen/integration/clone.go | 6 +- go/tools/asthelpergen/integration/equals.go | 40 +++++++ go/tools/asthelpergen/main/main.go | 39 +++++++ go/tools/asthelpergen/rewriter_gen.go | 2 +- 8 files changed, 209 insertions(+), 46 deletions(-) create mode 100644 go/tools/asthelpergen/equals_gen.go create mode 100644 go/tools/asthelpergen/integration/equals.go create mode 100644 go/tools/asthelpergen/main/main.go diff --git a/go/tools/asthelpergen/asthelpergen.go b/go/tools/asthelpergen/asthelpergen.go index e1bfdf385bb..d0c10b3b029 100644 --- a/go/tools/asthelpergen/asthelpergen.go +++ b/go/tools/asthelpergen/asthelpergen.go @@ -14,15 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package asthelpergen import ( "bytes" - "flag" "fmt" "go/types" "io/ioutil" - "log" "path" "strings" @@ -170,48 +168,19 @@ func (gen *astHelperGen) GenerateCode() (map[string]*jen.File, error) { return result, nil } -type typePaths []string +// TypePaths are the packages +type TypePaths []string -func (t *typePaths) String() string { +func (t *TypePaths) String() string { return fmt.Sprintf("%v", *t) } -func (t *typePaths) Set(path string) error { +// Set adds the package path +func (t *TypePaths) Set(path string) error { *t = append(*t, path) return nil } -func main() { - var patterns typePaths - var generate, except string - var verify bool - - flag.Var(&patterns, "in", "Go packages to load the generator") - flag.StringVar(&generate, "iface", "", "Root interface generate rewriter for") - flag.BoolVar(&verify, "verify", false, "ensure that the generated files are correct") - flag.StringVar(&except, "except", "", "don't deep clone these types") - flag.Parse() - - result, err := GenerateASTHelpers(patterns, generate, except) - if err != nil { - log.Fatal(err) - } - - if verify { - for _, err := range VerifyFilesOnDisk(result) { - log.Fatal(err) - } - log.Printf("%d files OK", len(result)) - } else { - for fullPath, file := range result { - if err := file.Save(fullPath); err != nil { - log.Fatalf("failed to save file to '%s': %v", fullPath, err) - } - log.Printf("saved '%s'", fullPath) - } - } -} - // VerifyFilesOnDisk compares the generated results from the codegen against the files that // currently exist on disk and returns any mismatches func VerifyFilesOnDisk(result map[string]*jen.File) (errors []error) { @@ -279,8 +248,9 @@ func GenerateASTHelpers(packagePatterns []string, rootIface, exceptCloneType str } rewriter := newRewriterGen(interestingType, nt.Obj().Name()) clone := newCloneGen(iface, scope, exceptCloneType) + equals := newEqualsGen() - generator := newGenerator(loaded[0].Module, loaded[0].TypesSizes, nt, rewriter, clone) + generator := newGenerator(loaded[0].Module, loaded[0].TypesSizes, nt, rewriter, clone, equals) it, err := generator.GenerateCode() if err != nil { return nil, err diff --git a/go/tools/asthelpergen/asthelpergen_test.go b/go/tools/asthelpergen/asthelpergen_test.go index 30dc2eb61a5..16372b13d75 100644 --- a/go/tools/asthelpergen/asthelpergen_test.go +++ b/go/tools/asthelpergen/asthelpergen_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package asthelpergen import ( "fmt" diff --git a/go/tools/asthelpergen/clone_gen.go b/go/tools/asthelpergen/clone_gen.go index 066a4c82923..1cf269efdea 100644 --- a/go/tools/asthelpergen/clone_gen.go +++ b/go/tools/asthelpergen/clone_gen.go @@ -14,13 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package asthelpergen import ( "fmt" "go/types" - - "vitess.io/vitess/go/vt/log" + "log" "github.com/dave/jennifer/jen" ) @@ -161,7 +160,7 @@ func (c *cloneGen) makeInterfaceCloneMethod(t types.Type, iface *types.Interface } default: - log.Errorf("unexpected type encountered: %s", typeString) + log.Fatalf("unexpected type encountered: %s", typeString) } return nil @@ -221,7 +220,7 @@ func (c *cloneGen) createFile(pkgName string) (string, *jen.File) { continue } - log.Errorf("don't know how to handle %s %T", typeName, underlying) + log.Fatalf("don't know how to handle %s %T", typeName, underlying) } for _, method := range c.methods { diff --git a/go/tools/asthelpergen/equals_gen.go b/go/tools/asthelpergen/equals_gen.go new file mode 100644 index 00000000000..0bd8126640c --- /dev/null +++ b/go/tools/asthelpergen/equals_gen.go @@ -0,0 +1,111 @@ +package asthelpergen + +import ( + "go/types" + "log" + + "github.com/dave/jennifer/jen" +) + +type equalsGen struct { + todo []types.Type + methods []jen.Code +} + +var _ generator = (*equalsGen)(nil) + +func newEqualsGen() *equalsGen { + return &equalsGen{} +} + +func (e *equalsGen) visitStruct(t types.Type, stroct *types.Struct) error { + return nil +} + +func (e *equalsGen) visitSlice(t types.Type, slice *types.Slice) error { + return nil +} + +func (e *equalsGen) visitInterface(t types.Type, iface *types.Interface) error { + e.todo = append(e.todo, t) + return nil +} + +func (e *equalsGen) createFile(pkgName string) (string, *jen.File) { + out := jen.NewFile(pkgName) + out.HeaderComment(licenseFileHeader) + out.HeaderComment("Code generated by ASTHelperGen. DO NOT EDIT.") + + alreadyDone := map[string]bool{} + for len(e.todo) > 0 { + t := e.todo[0] + underlying := t.Underlying() + typeName := printableTypeName(t) + e.todo = e.todo[1:] + + if alreadyDone[typeName] { + continue + } + + if e.tryInterface(underlying, t) { + alreadyDone[typeName] = true + continue + } + + log.Fatalf("don't know how to handle %s %T", typeName, underlying) + } + + for _, method := range e.methods { + out.Add(method) + } + + return "equals.go", out +} + +func (e *equalsGen) tryInterface(underlying, t types.Type) bool { + iface, ok := underlying.(*types.Interface) + if !ok { + return false + } + + err := e.makeInterfaceEqualsMethod(t, iface) + if err != nil { + log.Fatalf("%v", err) + } + return true +} + +const equalsName = "Equals" + +func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interface) error { + + /* + func EqualsAST(a, b *AST) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return false + } + */ + typeString := types.TypeString(t, noQualifier) + typeName := printableTypeName(t) + + stmts := []jen.Code{ + jen.If(jen.Id("a == b")).Block(jen.Return(jen.True())), + jen.If(jen.Id("a == nil").Op("||").Id("b == nil")).Block(jen.Return(jen.False())), + jen.Return(jen.False()), + } + + funcName := equalsName + typeName + funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("a"), jen.Id("b")).Id(typeString)).Bool().Block(stmts...) + e.addFunc(funcName, funcDecl) + + return nil +} + +func (e *equalsGen) addFunc(name string, code jen.Code) { + e.methods = append(e.methods, jen.Comment(name+" does deep equals."), code) +} diff --git a/go/tools/asthelpergen/integration/clone.go b/go/tools/asthelpergen/integration/clone.go index 84d1c2b7537..71171554ece 100644 --- a/go/tools/asthelpergen/integration/clone.go +++ b/go/tools/asthelpergen/integration/clone.go @@ -108,7 +108,11 @@ func CloneLeafSlice(n LeafSlice) LeafSlice { // CloneRefOfNoCloneType creates a deep clone of the input. func CloneRefOfNoCloneType(n *NoCloneType) *NoCloneType { - return n + if n == nil { + return nil + } + out := *n + return &out } // CloneRefOfRefContainer creates a deep clone of the input. diff --git a/go/tools/asthelpergen/integration/equals.go b/go/tools/asthelpergen/integration/equals.go new file mode 100644 index 00000000000..5d3f1035468 --- /dev/null +++ b/go/tools/asthelpergen/integration/equals.go @@ -0,0 +1,40 @@ +/* +Copyright 2021 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. +*/ +// Code generated by ASTHelperGen. DO NOT EDIT. + +package integration + +// EqualsAST does deep equals. +func EqualsAST(a, b AST) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return false +} + +// EqualsSubIface does deep equals. +func EqualsSubIface(a, b SubIface) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return false +} diff --git a/go/tools/asthelpergen/main/main.go b/go/tools/asthelpergen/main/main.go new file mode 100644 index 00000000000..9225aa7615d --- /dev/null +++ b/go/tools/asthelpergen/main/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "flag" + "log" + + . "vitess.io/vitess/go/tools/asthelpergen" +) + +func main() { + var patterns TypePaths + var generate, except string + var verify bool + + flag.Var(&patterns, "in", "Go packages to load the generator") + flag.StringVar(&generate, "iface", "", "Root interface generate rewriter for") + flag.BoolVar(&verify, "verify", false, "ensure that the generated files are correct") + flag.StringVar(&except, "except", "", "don't deep clone these types") + flag.Parse() + + result, err := GenerateASTHelpers(patterns, generate, except) + if err != nil { + log.Fatal(err) + } + + if verify { + for _, err := range VerifyFilesOnDisk(result) { + log.Fatal(err) + } + log.Printf("%d files OK", len(result)) + } else { + for fullPath, file := range result { + if err := file.Save(fullPath); err != nil { + log.Fatalf("failed to save file to '%s': %v", fullPath, err) + } + log.Printf("saved '%s'", fullPath) + } + } +} diff --git a/go/tools/asthelpergen/rewriter_gen.go b/go/tools/asthelpergen/rewriter_gen.go index 54a0ca8e093..b7bedbe5cc8 100644 --- a/go/tools/asthelpergen/rewriter_gen.go +++ b/go/tools/asthelpergen/rewriter_gen.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package asthelpergen import ( "go/types" From 36c1edfbbf26132d87c41bfe8d6ff11fb5d1c313 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Fri, 12 Mar 2021 10:24:45 +0100 Subject: [PATCH 02/13] added unit tests Signed-off-by: Andres Taylor --- .../integration/integration_equals_test.go | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 go/tools/asthelpergen/integration/integration_equals_test.go diff --git a/go/tools/asthelpergen/integration/integration_equals_test.go b/go/tools/asthelpergen/integration/integration_equals_test.go new file mode 100644 index 00000000000..60ced8cdbfb --- /dev/null +++ b/go/tools/asthelpergen/integration/integration_equals_test.go @@ -0,0 +1,65 @@ +/* +Copyright 2021 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 integration + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestEquals(t *testing.T) { + for idxA, objA := range createObjs() { + for idxB, objB := range createObjs() { + t.Run(fmt.Sprintf("%s == %s", name(objA), name(objB)), func(t *testing.T) { + if idxA == idxB { + require.True(t, EqualsAST(objA, objB)) + } else { + require.False(t, EqualsAST(objA, objB)) + } + }) + } + } +} + +func createObjs() []AST { + return []AST{ + nil, + &Leaf{1}, + &Leaf{2}, + &RefContainer{ASTType: &Leaf{1}, ASTImplementationType: &Leaf{2}}, + ValueContainer{ASTType: ValueContainer{ASTType: &Leaf{1}, ASTImplementationType: &Leaf{2}}}, + &RefSliceContainer{ASTElements: []AST{&Leaf{1}, &Leaf{2}}, ASTImplementationElements: []*Leaf{{3}, {4}}}, + ValueSliceContainer{ASTElements: []AST{&Leaf{1}, &Leaf{2}}, ASTImplementationElements: []*Leaf{{3}, {4}}}, + InterfaceSlice{ + &RefContainer{ + ASTType: &RefContainer{NotASTType: 12}, + ASTImplementationType: &Leaf{2}, + }, + &Leaf{2}, + &Leaf{3}, + }, + } +} + +func name(a AST) string { + if a == nil { + return "nil" + } + return a.String() +} From 627125e2b27ff7116d1b878475d55cb72c6da186 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 12 Mar 2021 15:41:19 +0530 Subject: [PATCH 03/13] deep equals of interface Signed-off-by: Harshit Gangal --- Makefile | 2 +- go/tools/asthelpergen/asthelpergen.go | 2 +- go/tools/asthelpergen/equals_gen.go | 50 ++++++++-- go/tools/asthelpergen/integration/equals.go | 100 ++++++++++++++++++-- misc/git/hooks/visitorgen | 2 +- 5 files changed, 141 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index f90016290ff..cecb52b0e21 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ parser: make -C go/vt/sqlparser visitor: - go run ./go/tools/asthelpergen -in ./go/vt/sqlparser -iface vitess.io/vitess/go/vt/sqlparser.SQLNode -except "*ColName" + go run ./go/tools/asthelpergen/main -in ./go/vt/sqlparser -iface vitess.io/vitess/go/vt/sqlparser.SQLNode -except "*ColName" sizegen: go run go/tools/sizegen/sizegen.go \ diff --git a/go/tools/asthelpergen/asthelpergen.go b/go/tools/asthelpergen/asthelpergen.go index d0c10b3b029..3f66298d72d 100644 --- a/go/tools/asthelpergen/asthelpergen.go +++ b/go/tools/asthelpergen/asthelpergen.go @@ -248,7 +248,7 @@ func GenerateASTHelpers(packagePatterns []string, rootIface, exceptCloneType str } rewriter := newRewriterGen(interestingType, nt.Obj().Name()) clone := newCloneGen(iface, scope, exceptCloneType) - equals := newEqualsGen() + equals := newEqualsGen(scope) generator := newGenerator(loaded[0].Module, loaded[0].TypesSizes, nt, rewriter, clone, equals) it, err := generator.GenerateCode() diff --git a/go/tools/asthelpergen/equals_gen.go b/go/tools/asthelpergen/equals_gen.go index 0bd8126640c..df7951d92d1 100644 --- a/go/tools/asthelpergen/equals_gen.go +++ b/go/tools/asthelpergen/equals_gen.go @@ -10,12 +10,15 @@ import ( type equalsGen struct { todo []types.Type methods []jen.Code + scope *types.Scope } var _ generator = (*equalsGen)(nil) -func newEqualsGen() *equalsGen { - return &equalsGen{} +func newEqualsGen(scope *types.Scope) *equalsGen { + return &equalsGen{ + scope: scope, + } } func (e *equalsGen) visitStruct(t types.Type, stroct *types.Struct) error { @@ -87,6 +90,14 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa if a == nil || b == nil { return false } + switch a := inA.(type) { + case *SubImpl: + b, ok := inB.(*SubImpl) + if !ok { + return false + } + return EqualsSubImpl(a, b) + } return false } */ @@ -94,13 +105,40 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa typeName := printableTypeName(t) stmts := []jen.Code{ - jen.If(jen.Id("a == b")).Block(jen.Return(jen.True())), - jen.If(jen.Id("a == nil").Op("||").Id("b == nil")).Block(jen.Return(jen.False())), - jen.Return(jen.False()), + jen.If(jen.Id("inA == inB")).Block(jen.Return(jen.True())), + jen.If(jen.Id("inA == nil").Op("||").Id("inB == nil")).Block(jen.Return(jen.False())), } + var cases []jen.Code + _ = findImplementations(e.scope, iface, func(t types.Type) error { + if _, ok := t.Underlying().(*types.Interface); ok { + return nil + } + typeString := types.TypeString(t, noQualifier) + caseBlock := jen.Case(jen.Id(typeString)).Block( + jen.Id("b, ok := inB.").Call(jen.Id(typeString)), + jen.If(jen.Id("!ok")).Block(jen.Return(jen.False())), + jen.Return(jen.Id(equalsName+printableTypeName(t)).Call(jen.Id("a, b"))), + ) + cases = append(cases, caseBlock) + e.todo = append(e.todo, t) + return nil + }) + + cases = append(cases, + jen.Default().Block( + jen.Comment("this should never happen"), + jen.Return(jen.False()), + )) + + stmts = append(stmts, jen.Switch(jen.Id("a := inA.(type)").Block( + cases..., + ))) + + stmts = append(stmts, jen.Return(jen.False())) + funcName := equalsName + typeName - funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("a"), jen.Id("b")).Id(typeString)).Bool().Block(stmts...) + funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("inA"), jen.Id("inB")).Id(typeString)).Bool().Block(stmts...) e.addFunc(funcName, funcDecl) return nil diff --git a/go/tools/asthelpergen/integration/equals.go b/go/tools/asthelpergen/integration/equals.go index 5d3f1035468..5d8220aab25 100644 --- a/go/tools/asthelpergen/integration/equals.go +++ b/go/tools/asthelpergen/integration/equals.go @@ -18,22 +18,110 @@ limitations under the License. package integration // EqualsAST does deep equals. -func EqualsAST(a, b AST) bool { - if a == b { +func EqualsAST(inA, inB AST) bool { + if inA == inB { return true } - if a == nil || b == nil { + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case BasicType: + b, ok := inB.(BasicType) + if !ok { + return false + } + return EqualsBasicType(a, b) + case Bytes: + b, ok := inB.(Bytes) + if !ok { + return false + } + return EqualsBytes(a, b) + case InterfaceContainer: + b, ok := inB.(InterfaceContainer) + if !ok { + return false + } + return EqualsInterfaceContainer(a, b) + case InterfaceSlice: + b, ok := inB.(InterfaceSlice) + if !ok { + return false + } + return EqualsInterfaceSlice(a, b) + case *Leaf: + b, ok := inB.(*Leaf) + if !ok { + return false + } + return EqualsRefOfLeaf(a, b) + case LeafSlice: + b, ok := inB.(LeafSlice) + if !ok { + return false + } + return EqualsLeafSlice(a, b) + case *NoCloneType: + b, ok := inB.(*NoCloneType) + if !ok { + return false + } + return EqualsRefOfNoCloneType(a, b) + case *RefContainer: + b, ok := inB.(*RefContainer) + if !ok { + return false + } + return EqualsRefOfRefContainer(a, b) + case *RefSliceContainer: + b, ok := inB.(*RefSliceContainer) + if !ok { + return false + } + return EqualsRefOfRefSliceContainer(a, b) + case *SubImpl: + b, ok := inB.(*SubImpl) + if !ok { + return false + } + return EqualsRefOfSubImpl(a, b) + case ValueContainer: + b, ok := inB.(ValueContainer) + if !ok { + return false + } + return EqualsValueContainer(a, b) + case ValueSliceContainer: + b, ok := inB.(ValueSliceContainer) + if !ok { + return false + } + return EqualsValueSliceContainer(a, b) + default: + // this should never happen return false } return false } // EqualsSubIface does deep equals. -func EqualsSubIface(a, b SubIface) bool { - if a == b { +func EqualsSubIface(inA, inB SubIface) bool { + if inA == inB { return true } - if a == nil || b == nil { + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *SubImpl: + b, ok := inB.(*SubImpl) + if !ok { + return false + } + return EqualsRefOfSubImpl(a, b) + default: + // this should never happen return false } return false diff --git a/misc/git/hooks/visitorgen b/misc/git/hooks/visitorgen index 3ac99cb0a07..cd8a9ac547d 100755 --- a/misc/git/hooks/visitorgen +++ b/misc/git/hooks/visitorgen @@ -15,4 +15,4 @@ # this script, which should run before committing code, makes sure that the visitor is re-generated when the ast changes -go run ./go/tools/asthelpergen -in ./go/vt/sqlparser -verify=true -iface vitess.io/vitess/go/vt/sqlparser.SQLNode -except "*ColName" \ No newline at end of file +go run ./go/tools/asthelpergen/main -in ./go/vt/sqlparser -verify=true -iface vitess.io/vitess/go/vt/sqlparser.SQLNode -except "*ColName" \ No newline at end of file From 4d457ea3ef954571e8c3df884f5287ff9c6ef006 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 12 Mar 2021 16:34:35 +0530 Subject: [PATCH 04/13] deep equals for struct type Signed-off-by: Harshit Gangal --- go/tools/asthelpergen/clone_gen.go | 8 +- go/tools/asthelpergen/equals_gen.go | 88 +++++++++++++++++++-- go/tools/asthelpergen/integration/equals.go | 15 ++++ 3 files changed, 101 insertions(+), 10 deletions(-) diff --git a/go/tools/asthelpergen/clone_gen.go b/go/tools/asthelpergen/clone_gen.go index 1cf269efdea..8899f6c5040 100644 --- a/go/tools/asthelpergen/clone_gen.go +++ b/go/tools/asthelpergen/clone_gen.go @@ -80,10 +80,10 @@ func (c *cloneGen) readValueOfType(t types.Type, expr jen.Code) jen.Code { } func (c *cloneGen) makeStructCloneMethod(t types.Type) error { - receiveType := types.TypeString(t, noQualifier) - funcName := "Clone" + printableTypeName(t) + typeString := types.TypeString(t, noQualifier) + funcName := cloneName + printableTypeName(t) c.addFunc(funcName, - jen.Func().Id(funcName).Call(jen.Id("n").Id(receiveType)).Id(receiveType).Block( + jen.Func().Id(funcName).Call(jen.Id("n").Id(typeString)).Id(typeString).Block( jen.Return(jen.Op("*").Add(c.readValueOfType(types.NewPointer(t), jen.Op("&").Id("n")))), )) return nil @@ -247,7 +247,7 @@ func (c *cloneGen) tryStruct(underlying, t types.Type) bool { err := c.makeStructCloneMethod(t) if err != nil { - panic(err) // todo + log.Fatalf("%v", err) } return true } diff --git a/go/tools/asthelpergen/equals_gen.go b/go/tools/asthelpergen/equals_gen.go index df7951d92d1..0f9e16e3473 100644 --- a/go/tools/asthelpergen/equals_gen.go +++ b/go/tools/asthelpergen/equals_gen.go @@ -50,12 +50,13 @@ func (e *equalsGen) createFile(pkgName string) (string, *jen.File) { continue } - if e.tryInterface(underlying, t) { + if e.tryInterface(underlying, t) || + e.tryStruct(underlying, t) { alreadyDone[typeName] = true continue } - log.Fatalf("don't know how to handle %s %T", typeName, underlying) + log.Printf("don't know how to handle %s %T", typeName, underlying) } for _, method := range e.methods { @@ -101,9 +102,6 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa return false } */ - typeString := types.TypeString(t, noQualifier) - typeName := printableTypeName(t) - stmts := []jen.Code{ jen.If(jen.Id("inA == inB")).Block(jen.Return(jen.True())), jen.If(jen.Id("inA == nil").Op("||").Id("inB == nil")).Block(jen.Return(jen.False())), @@ -137,7 +135,8 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa stmts = append(stmts, jen.Return(jen.False())) - funcName := equalsName + typeName + typeString := types.TypeString(t, noQualifier) + funcName := equalsName + printableTypeName(t) funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("inA"), jen.Id("inB")).Id(typeString)).Bool().Block(stmts...) e.addFunc(funcName, funcDecl) @@ -147,3 +146,80 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa func (e *equalsGen) addFunc(name string, code jen.Code) { e.methods = append(e.methods, jen.Comment(name+" does deep equals."), code) } + +func (e *equalsGen) tryStruct(underlying, t types.Type) bool { + stroct, ok := underlying.(*types.Struct) + if !ok { + return false + } + + err := e.makeStructEqualsMethod(t, stroct) + if err != nil { + log.Fatalf("%v", err) + } + return true +} + +func (e *equalsGen) makeStructEqualsMethod(t types.Type, stroct *types.Struct) error { + /* + func EqualsRefOfRefContainer(inA *RefContainer, inB *RefContainer) bool { + if inA == inB { + return true + } + return EqualsRefOfLeaf(inA.ASTImplementationType, inB.ASTImplementationType) && + EqualsAST(inA.ASTType, inB.ASTType) && inA.NotASTType == inB.NotASTType + } + + */ + + typeString := types.TypeString(t, noQualifier) + typeName := printableTypeName(t) + + var basicsPred []*jen.Statement + var others []*jen.Statement + for i := 0; i < stroct.NumFields(); i++ { + field := stroct.Field(i) + _, ok := field.Type().(*types.Basic) + if ok { + basicsPred = append(basicsPred, jen.Id("inA").Dot(field.Name()).Op("==").Id("inB").Dot(field.Name())) + continue + } + if field.Type().Underlying().String() == "interface{}" { + // we can safely ignore this, we do not want ast to contain interface{} types. + continue + } + others = append(others, jen.Id(equalsName+printableTypeName(field.Type())).Call(jen.Id("inA").Dot(field.Name()), jen.Id("inB").Dot(field.Name()))) + } + + var ret *jen.Statement + for _, pred := range basicsPred { + if ret == nil { + ret = pred + } else { + ret = ret.Op("&&").Add(pred) + } + } + + for _, pred := range others { + if ret == nil { + ret = pred + } else { + ret = ret.Op("&&").Add(pred) + } + } + + var stmt jen.Code + + if ret == nil { + stmt = jen.Return(jen.True()) + } else { + stmt = jen.Return(ret) + } + + funcName := equalsName + typeName + funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("inA"), jen.Id("inB")).Id(typeString)).Bool(). + Block(stmt) + e.addFunc(funcName, funcDecl) + + return nil +} diff --git a/go/tools/asthelpergen/integration/equals.go b/go/tools/asthelpergen/integration/equals.go index 5d8220aab25..2fcefc3e7db 100644 --- a/go/tools/asthelpergen/integration/equals.go +++ b/go/tools/asthelpergen/integration/equals.go @@ -126,3 +126,18 @@ func EqualsSubIface(inA, inB SubIface) bool { } return false } + +// EqualsInterfaceContainer does deep equals. +func EqualsInterfaceContainer(inA, inB InterfaceContainer) bool { + return true +} + +// EqualsValueContainer does deep equals. +func EqualsValueContainer(inA, inB ValueContainer) bool { + return inA.NotASTType == inB.NotASTType && EqualsAST(inA.ASTType, inB.ASTType) && EqualsRefOfLeaf(inA.ASTImplementationType, inB.ASTImplementationType) +} + +// EqualsValueSliceContainer does deep equals. +func EqualsValueSliceContainer(inA, inB ValueSliceContainer) bool { + return EqualsSliceOfAST(inA.ASTElements, inB.ASTElements) && EqualsSliceOfint(inA.NotASTElements, inB.NotASTElements) && EqualsSliceOfRefOfLeaf(inA.ASTImplementationElements, inB.ASTImplementationElements) +} From cc105d731ecfea98cda65ea491c0707403b06929 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 12 Mar 2021 16:47:04 +0530 Subject: [PATCH 05/13] add new line to predicated in return statement Signed-off-by: Harshit Gangal --- go/tools/asthelpergen/equals_gen.go | 4 ++-- go/tools/asthelpergen/integration/equals.go | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/go/tools/asthelpergen/equals_gen.go b/go/tools/asthelpergen/equals_gen.go index 0f9e16e3473..8a3ee45ce44 100644 --- a/go/tools/asthelpergen/equals_gen.go +++ b/go/tools/asthelpergen/equals_gen.go @@ -196,7 +196,7 @@ func (e *equalsGen) makeStructEqualsMethod(t types.Type, stroct *types.Struct) e if ret == nil { ret = pred } else { - ret = ret.Op("&&").Add(pred) + ret = ret.Op("&&").Line().Add(pred) } } @@ -204,7 +204,7 @@ func (e *equalsGen) makeStructEqualsMethod(t types.Type, stroct *types.Struct) e if ret == nil { ret = pred } else { - ret = ret.Op("&&").Add(pred) + ret = ret.Op("&&").Line().Add(pred) } } diff --git a/go/tools/asthelpergen/integration/equals.go b/go/tools/asthelpergen/integration/equals.go index 2fcefc3e7db..4879098e622 100644 --- a/go/tools/asthelpergen/integration/equals.go +++ b/go/tools/asthelpergen/integration/equals.go @@ -134,10 +134,14 @@ func EqualsInterfaceContainer(inA, inB InterfaceContainer) bool { // EqualsValueContainer does deep equals. func EqualsValueContainer(inA, inB ValueContainer) bool { - return inA.NotASTType == inB.NotASTType && EqualsAST(inA.ASTType, inB.ASTType) && EqualsRefOfLeaf(inA.ASTImplementationType, inB.ASTImplementationType) + return inA.NotASTType == inB.NotASTType && + EqualsAST(inA.ASTType, inB.ASTType) && + EqualsRefOfLeaf(inA.ASTImplementationType, inB.ASTImplementationType) } // EqualsValueSliceContainer does deep equals. func EqualsValueSliceContainer(inA, inB ValueSliceContainer) bool { - return EqualsSliceOfAST(inA.ASTElements, inB.ASTElements) && EqualsSliceOfint(inA.NotASTElements, inB.NotASTElements) && EqualsSliceOfRefOfLeaf(inA.ASTImplementationElements, inB.ASTImplementationElements) + return EqualsSliceOfAST(inA.ASTElements, inB.ASTElements) && + EqualsSliceOfint(inA.NotASTElements, inB.NotASTElements) && + EqualsSliceOfRefOfLeaf(inA.ASTImplementationElements, inB.ASTImplementationElements) } From 4a699a53ed357372a51f262f08dcd922470b409b Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 12 Mar 2021 19:03:24 +0530 Subject: [PATCH 06/13] deep equals of struct and some code refactor Signed-off-by: Harshit Gangal --- go/tools/asthelpergen/clone_gen.go | 2 +- go/tools/asthelpergen/equals_gen.go | 84 +++++++++++++++++---- go/tools/asthelpergen/integration/equals.go | 80 +++++++++++++++++++- 3 files changed, 151 insertions(+), 15 deletions(-) diff --git a/go/tools/asthelpergen/clone_gen.go b/go/tools/asthelpergen/clone_gen.go index 8899f6c5040..cd9004a8193 100644 --- a/go/tools/asthelpergen/clone_gen.go +++ b/go/tools/asthelpergen/clone_gen.go @@ -335,7 +335,7 @@ func (c *cloneGen) trySlice(underlying, t types.Type) bool { err := c.makeSliceCloneMethod(t, slice) if err != nil { - panic(err) // todo + log.Fatalf("%v", err) } return true } diff --git a/go/tools/asthelpergen/equals_gen.go b/go/tools/asthelpergen/equals_gen.go index 8a3ee45ce44..86d07a8fd4f 100644 --- a/go/tools/asthelpergen/equals_gen.go +++ b/go/tools/asthelpergen/equals_gen.go @@ -51,7 +51,8 @@ func (e *equalsGen) createFile(pkgName string) (string, *jen.File) { } if e.tryInterface(underlying, t) || - e.tryStruct(underlying, t) { + e.tryStruct(underlying, t) || + e.trySlice(underlying, t) { alreadyDone[typeName] = true continue } @@ -116,10 +117,9 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa caseBlock := jen.Case(jen.Id(typeString)).Block( jen.Id("b, ok := inB.").Call(jen.Id(typeString)), jen.If(jen.Id("!ok")).Block(jen.Return(jen.False())), - jen.Return(jen.Id(equalsName+printableTypeName(t)).Call(jen.Id("a, b"))), + jen.Return(e.compareValueType(t, jen.Id("a"), jen.Id("b"), true)), ) cases = append(cases, caseBlock) - e.todo = append(e.todo, t) return nil }) @@ -143,6 +143,23 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa return nil } +func (e *equalsGen) compareValueType(t types.Type, a, b *jen.Statement, eq bool) *jen.Statement { + switch t.Underlying().(type) { + case *types.Basic: + if eq { + return a.Op("==").Add(b) + } + return a.Op("!=").Add(b) + } + + e.todo = append(e.todo, t) + var neg = "!" + if eq { + neg = "" + } + return jen.Id(neg+equalsName+printableTypeName(t)).Call(a, b) +} + func (e *equalsGen) addFunc(name string, code jen.Code) { e.methods = append(e.methods, jen.Comment(name+" does deep equals."), code) } @@ -172,23 +189,22 @@ func (e *equalsGen) makeStructEqualsMethod(t types.Type, stroct *types.Struct) e */ - typeString := types.TypeString(t, noQualifier) - typeName := printableTypeName(t) - var basicsPred []*jen.Statement var others []*jen.Statement for i := 0; i < stroct.NumFields(); i++ { field := stroct.Field(i) - _, ok := field.Type().(*types.Basic) - if ok { - basicsPred = append(basicsPred, jen.Id("inA").Dot(field.Name()).Op("==").Id("inB").Dot(field.Name())) - continue - } if field.Type().Underlying().String() == "interface{}" { // we can safely ignore this, we do not want ast to contain interface{} types. continue } - others = append(others, jen.Id(equalsName+printableTypeName(field.Type())).Call(jen.Id("inA").Dot(field.Name()), jen.Id("inB").Dot(field.Name()))) + fieldA := jen.Id("inA").Dot(field.Name()) + fieldB := jen.Id("inB").Dot(field.Name()) + pred := e.compareValueType(field.Type(), fieldA, fieldB, true) + if _, ok := field.Type().(*types.Basic); ok { + basicsPred = append(basicsPred, pred) + continue + } + others = append(others, pred) } var ret *jen.Statement @@ -216,10 +232,52 @@ func (e *equalsGen) makeStructEqualsMethod(t types.Type, stroct *types.Struct) e stmt = jen.Return(ret) } - funcName := equalsName + typeName + typeString := types.TypeString(t, noQualifier) + funcName := equalsName + printableTypeName(t) funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("inA"), jen.Id("inB")).Id(typeString)).Bool(). Block(stmt) e.addFunc(funcName, funcDecl) return nil } + +func (e *equalsGen) trySlice(underlying, t types.Type) bool { + slice, ok := underlying.(*types.Slice) + if !ok { + return false + } + + err := e.makeSliceEqualsMethod(t, slice) + if err != nil { + log.Fatalf("%v", err) + } + return true +} + +func (e *equalsGen) makeSliceEqualsMethod(t types.Type, slice *types.Slice) error { + /* + func EqualsSliceOfRefOfLeaf(inA, inB []*Leaf) bool { + if len(inA) != len(inB) { + return false + } + for i := 0; i < len(inA); i++ { + if !EqualsRefOfLeaf(inA[i], inB[i]) { + return false + } + } + return false + } + */ + + stmts := []jen.Code{jen.If(jen.Id("len(inA) != len(inB)")).Block(jen.Return(jen.False())), + jen.For(jen.Id("i := 0; i < len(inA); i++")).Block( + jen.If(e.compareValueType(slice.Elem(), jen.Id("inA[i]"), jen.Id("inB[i]"), false)).Block(jen.Return(jen.False()))), + jen.Return(jen.True()), + } + + typeString := types.TypeString(t, noQualifier) + funcName := equalsName + printableTypeName(t) + funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("inA"), jen.Id("inB")).Id(typeString)).Bool().Block(stmts...) + e.addFunc(funcName, funcDecl) + return nil +} diff --git a/go/tools/asthelpergen/integration/equals.go b/go/tools/asthelpergen/integration/equals.go index 4879098e622..31b64872957 100644 --- a/go/tools/asthelpergen/integration/equals.go +++ b/go/tools/asthelpergen/integration/equals.go @@ -31,7 +31,7 @@ func EqualsAST(inA, inB AST) bool { if !ok { return false } - return EqualsBasicType(a, b) + return a == b case Bytes: b, ok := inB.(Bytes) if !ok { @@ -127,11 +127,50 @@ func EqualsSubIface(inA, inB SubIface) bool { return false } +// EqualsBytes does deep equals. +func EqualsBytes(inA, inB Bytes) bool { + if len(inA) != len(inB) { + return false + } + for i := 0; i < len(inA); i++ { + if inA[i] != inB[i] { + return false + } + } + return true +} + // EqualsInterfaceContainer does deep equals. func EqualsInterfaceContainer(inA, inB InterfaceContainer) bool { return true } +// EqualsInterfaceSlice does deep equals. +func EqualsInterfaceSlice(inA, inB InterfaceSlice) bool { + if len(inA) != len(inB) { + return false + } + for i := 0; i < len(inA); i++ { + if !EqualsAST(inA[i], inB[i]) { + return false + } + } + return true +} + +// EqualsLeafSlice does deep equals. +func EqualsLeafSlice(inA, inB LeafSlice) bool { + if len(inA) != len(inB) { + return false + } + for i := 0; i < len(inA); i++ { + if !EqualsRefOfLeaf(inA[i], inB[i]) { + return false + } + } + return true +} + // EqualsValueContainer does deep equals. func EqualsValueContainer(inA, inB ValueContainer) bool { return inA.NotASTType == inB.NotASTType && @@ -145,3 +184,42 @@ func EqualsValueSliceContainer(inA, inB ValueSliceContainer) bool { EqualsSliceOfint(inA.NotASTElements, inB.NotASTElements) && EqualsSliceOfRefOfLeaf(inA.ASTImplementationElements, inB.ASTImplementationElements) } + +// EqualsSliceOfAST does deep equals. +func EqualsSliceOfAST(inA, inB []AST) bool { + if len(inA) != len(inB) { + return false + } + for i := 0; i < len(inA); i++ { + if !EqualsAST(inA[i], inB[i]) { + return false + } + } + return true +} + +// EqualsSliceOfint does deep equals. +func EqualsSliceOfint(inA, inB []int) bool { + if len(inA) != len(inB) { + return false + } + for i := 0; i < len(inA); i++ { + if inA[i] != inB[i] { + return false + } + } + return true +} + +// EqualsSliceOfRefOfLeaf does deep equals. +func EqualsSliceOfRefOfLeaf(inA, inB []*Leaf) bool { + if len(inA) != len(inB) { + return false + } + for i := 0; i < len(inA); i++ { + if !EqualsRefOfLeaf(inA[i], inB[i]) { + return false + } + } + return true +} From 58e73d301573f58f74a7b4d5e8a148ec1a63056d Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Fri, 12 Mar 2021 15:12:21 +0100 Subject: [PATCH 07/13] all types covered Signed-off-by: Andres Taylor --- go/tools/asthelpergen/clone_gen.go | 2 +- go/tools/asthelpergen/equals_gen.go | 80 +++++++++----- go/tools/asthelpergen/integration/equals.go | 115 ++++++++++++++------ 3 files changed, 136 insertions(+), 61 deletions(-) diff --git a/go/tools/asthelpergen/clone_gen.go b/go/tools/asthelpergen/clone_gen.go index cd9004a8193..2ddd905adbb 100644 --- a/go/tools/asthelpergen/clone_gen.go +++ b/go/tools/asthelpergen/clone_gen.go @@ -271,7 +271,7 @@ func (c *cloneGen) tryPtr(underlying, t types.Type) bool { func (c *cloneGen) makePtrToStructCloneMethod(t types.Type, strct *types.Struct) { receiveType := types.TypeString(t, noQualifier) - funcName := "Clone" + printableTypeName(t) + funcName := cloneName + printableTypeName(t) //func CloneRefOfType(n *Type) *Type funcDeclaration := jen.Func().Id(funcName).Call(jen.Id("n").Id(receiveType)).Id(receiveType) diff --git a/go/tools/asthelpergen/equals_gen.go b/go/tools/asthelpergen/equals_gen.go index 86d07a8fd4f..686353339e2 100644 --- a/go/tools/asthelpergen/equals_gen.go +++ b/go/tools/asthelpergen/equals_gen.go @@ -52,7 +52,8 @@ func (e *equalsGen) createFile(pkgName string) (string, *jen.File) { if e.tryInterface(underlying, t) || e.tryStruct(underlying, t) || - e.trySlice(underlying, t) { + e.trySlice(underlying, t) || + e.tryPtr(underlying, t) { alreadyDone[typeName] = true continue } @@ -85,11 +86,11 @@ const equalsName = "Equals" func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interface) error { /* - func EqualsAST(a, b *AST) bool { - if a == b { + func EqualsAST(inA, inB AST) bool { + if inA == inB { return true } - if a == nil || b == nil { + if inA == nil || inB8 == nil { return false } switch a := inA.(type) { @@ -179,16 +180,23 @@ func (e *equalsGen) tryStruct(underlying, t types.Type) bool { func (e *equalsGen) makeStructEqualsMethod(t types.Type, stroct *types.Struct) error { /* - func EqualsRefOfRefContainer(inA *RefContainer, inB *RefContainer) bool { - if inA == inB { - return true - } + func EqualsRefOfRefContainer(inA RefContainer, inB RefContainer) bool { return EqualsRefOfLeaf(inA.ASTImplementationType, inB.ASTImplementationType) && EqualsAST(inA.ASTType, inB.ASTType) && inA.NotASTType == inB.NotASTType } */ + typeString := types.TypeString(t, noQualifier) + funcName := equalsName + printableTypeName(t) + funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("a"), jen.Id("b")).Id(typeString)).Bool(). + Block(jen.Return(e.compareAllStructFields(stroct))) + e.addFunc(funcName, funcDecl) + + return nil +} + +func (e *equalsGen) compareAllStructFields(stroct *types.Struct) jen.Code { var basicsPred []*jen.Statement var others []*jen.Statement for i := 0; i < stroct.NumFields(); i++ { @@ -197,8 +205,8 @@ func (e *equalsGen) makeStructEqualsMethod(t types.Type, stroct *types.Struct) e // we can safely ignore this, we do not want ast to contain interface{} types. continue } - fieldA := jen.Id("inA").Dot(field.Name()) - fieldB := jen.Id("inB").Dot(field.Name()) + fieldA := jen.Id("a").Dot(field.Name()) + fieldB := jen.Id("b").Dot(field.Name()) pred := e.compareValueType(field.Type(), fieldA, fieldB, true) if _, ok := field.Type().(*types.Basic); ok { basicsPred = append(basicsPred, pred) @@ -224,21 +232,39 @@ func (e *equalsGen) makeStructEqualsMethod(t types.Type, stroct *types.Struct) e } } - var stmt jen.Code - if ret == nil { - stmt = jen.Return(jen.True()) - } else { - stmt = jen.Return(ret) + return jen.True() } + return ret +} +func (e *equalsGen) tryPtr(underlying, t types.Type) bool { + ptr, ok := underlying.(*types.Pointer) + if !ok { + return false + } + + if strct, isStruct := ptr.Elem().Underlying().(*types.Struct); isStruct { + e.makePtrToStructCloneMethod(t, strct) + return true + } + + return false +} + +func (e *equalsGen) makePtrToStructCloneMethod(t types.Type, strct *types.Struct) { typeString := types.TypeString(t, noQualifier) funcName := equalsName + printableTypeName(t) - funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("inA"), jen.Id("inB")).Id(typeString)).Bool(). - Block(stmt) - e.addFunc(funcName, funcDecl) - return nil + //func EqualsRefOfType(a,b *Type) *Type + funcDeclaration := jen.Func().Id(funcName).Call(jen.Id("a"), jen.Id("b").Id(typeString)).Bool() + stmts := []jen.Code{ + jen.If(jen.Id("a == b")).Block(jen.Return(jen.True())), + jen.If(jen.Id("a == nil").Op("||").Id("b == nil")).Block(jen.Return(jen.False())), + jen.Return(e.compareAllStructFields(strct)), + } + + e.methods = append(e.methods, funcDeclaration.Block(stmts...)) } func (e *equalsGen) trySlice(underlying, t types.Type) bool { @@ -256,12 +282,12 @@ func (e *equalsGen) trySlice(underlying, t types.Type) bool { func (e *equalsGen) makeSliceEqualsMethod(t types.Type, slice *types.Slice) error { /* - func EqualsSliceOfRefOfLeaf(inA, inB []*Leaf) bool { - if len(inA) != len(inB) { + func EqualsSliceOfRefOfLeaf(a, b []*Leaf) bool { + if len(a) != len(b) { return false } - for i := 0; i < len(inA); i++ { - if !EqualsRefOfLeaf(inA[i], inB[i]) { + for i := 0; i < len(a); i++ { + if !EqualsRefOfLeaf(a[i], b[i]) { return false } } @@ -269,15 +295,15 @@ func (e *equalsGen) makeSliceEqualsMethod(t types.Type, slice *types.Slice) erro } */ - stmts := []jen.Code{jen.If(jen.Id("len(inA) != len(inB)")).Block(jen.Return(jen.False())), - jen.For(jen.Id("i := 0; i < len(inA); i++")).Block( - jen.If(e.compareValueType(slice.Elem(), jen.Id("inA[i]"), jen.Id("inB[i]"), false)).Block(jen.Return(jen.False()))), + stmts := []jen.Code{jen.If(jen.Id("len(a) != len(b)")).Block(jen.Return(jen.False())), + jen.For(jen.Id("i := 0; i < len(a); i++")).Block( + jen.If(e.compareValueType(slice.Elem(), jen.Id("a[i]"), jen.Id("b[i]"), false)).Block(jen.Return(jen.False()))), jen.Return(jen.True()), } typeString := types.TypeString(t, noQualifier) funcName := equalsName + printableTypeName(t) - funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("inA"), jen.Id("inB")).Id(typeString)).Bool().Block(stmts...) + funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("a"), jen.Id("b")).Id(typeString)).Bool().Block(stmts...) e.addFunc(funcName, funcDecl) return nil } diff --git a/go/tools/asthelpergen/integration/equals.go b/go/tools/asthelpergen/integration/equals.go index 31b64872957..d14610e8ca9 100644 --- a/go/tools/asthelpergen/integration/equals.go +++ b/go/tools/asthelpergen/integration/equals.go @@ -128,12 +128,12 @@ func EqualsSubIface(inA, inB SubIface) bool { } // EqualsBytes does deep equals. -func EqualsBytes(inA, inB Bytes) bool { - if len(inA) != len(inB) { +func EqualsBytes(a, b Bytes) bool { + if len(a) != len(b) { return false } - for i := 0; i < len(inA); i++ { - if inA[i] != inB[i] { + for i := 0; i < len(a); i++ { + if a[i] != b[i] { return false } } @@ -141,57 +141,106 @@ func EqualsBytes(inA, inB Bytes) bool { } // EqualsInterfaceContainer does deep equals. -func EqualsInterfaceContainer(inA, inB InterfaceContainer) bool { +func EqualsInterfaceContainer(a, b InterfaceContainer) bool { return true } // EqualsInterfaceSlice does deep equals. -func EqualsInterfaceSlice(inA, inB InterfaceSlice) bool { - if len(inA) != len(inB) { +func EqualsInterfaceSlice(a, b InterfaceSlice) bool { + if len(a) != len(b) { return false } - for i := 0; i < len(inA); i++ { - if !EqualsAST(inA[i], inB[i]) { + for i := 0; i < len(a); i++ { + if !EqualsAST(a[i], b[i]) { return false } } return true } +func EqualsRefOfLeaf(a, b *Leaf) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.v == b.v +} // EqualsLeafSlice does deep equals. -func EqualsLeafSlice(inA, inB LeafSlice) bool { - if len(inA) != len(inB) { +func EqualsLeafSlice(a, b LeafSlice) bool { + if len(a) != len(b) { return false } - for i := 0; i < len(inA); i++ { - if !EqualsRefOfLeaf(inA[i], inB[i]) { + for i := 0; i < len(a); i++ { + if !EqualsRefOfLeaf(a[i], b[i]) { return false } } return true } +func EqualsRefOfNoCloneType(a, b *NoCloneType) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.v == b.v +} +func EqualsRefOfRefContainer(a, b *RefContainer) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.NotASTType == b.NotASTType && + EqualsAST(a.ASTType, b.ASTType) && + EqualsRefOfLeaf(a.ASTImplementationType, b.ASTImplementationType) +} +func EqualsRefOfRefSliceContainer(a, b *RefSliceContainer) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSliceOfAST(a.ASTElements, b.ASTElements) && + EqualsSliceOfint(a.NotASTElements, b.NotASTElements) && + EqualsSliceOfRefOfLeaf(a.ASTImplementationElements, b.ASTImplementationElements) +} +func EqualsRefOfSubImpl(a, b *SubImpl) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSubIface(a.inner, b.inner) +} // EqualsValueContainer does deep equals. -func EqualsValueContainer(inA, inB ValueContainer) bool { - return inA.NotASTType == inB.NotASTType && - EqualsAST(inA.ASTType, inB.ASTType) && - EqualsRefOfLeaf(inA.ASTImplementationType, inB.ASTImplementationType) +func EqualsValueContainer(a, b ValueContainer) bool { + return a.NotASTType == b.NotASTType && + EqualsAST(a.ASTType, b.ASTType) && + EqualsRefOfLeaf(a.ASTImplementationType, b.ASTImplementationType) } // EqualsValueSliceContainer does deep equals. -func EqualsValueSliceContainer(inA, inB ValueSliceContainer) bool { - return EqualsSliceOfAST(inA.ASTElements, inB.ASTElements) && - EqualsSliceOfint(inA.NotASTElements, inB.NotASTElements) && - EqualsSliceOfRefOfLeaf(inA.ASTImplementationElements, inB.ASTImplementationElements) +func EqualsValueSliceContainer(a, b ValueSliceContainer) bool { + return EqualsSliceOfAST(a.ASTElements, b.ASTElements) && + EqualsSliceOfint(a.NotASTElements, b.NotASTElements) && + EqualsSliceOfRefOfLeaf(a.ASTImplementationElements, b.ASTImplementationElements) } // EqualsSliceOfAST does deep equals. -func EqualsSliceOfAST(inA, inB []AST) bool { - if len(inA) != len(inB) { +func EqualsSliceOfAST(a, b []AST) bool { + if len(a) != len(b) { return false } - for i := 0; i < len(inA); i++ { - if !EqualsAST(inA[i], inB[i]) { + for i := 0; i < len(a); i++ { + if !EqualsAST(a[i], b[i]) { return false } } @@ -199,12 +248,12 @@ func EqualsSliceOfAST(inA, inB []AST) bool { } // EqualsSliceOfint does deep equals. -func EqualsSliceOfint(inA, inB []int) bool { - if len(inA) != len(inB) { +func EqualsSliceOfint(a, b []int) bool { + if len(a) != len(b) { return false } - for i := 0; i < len(inA); i++ { - if inA[i] != inB[i] { + for i := 0; i < len(a); i++ { + if a[i] != b[i] { return false } } @@ -212,12 +261,12 @@ func EqualsSliceOfint(inA, inB []int) bool { } // EqualsSliceOfRefOfLeaf does deep equals. -func EqualsSliceOfRefOfLeaf(inA, inB []*Leaf) bool { - if len(inA) != len(inB) { +func EqualsSliceOfRefOfLeaf(a, b []*Leaf) bool { + if len(a) != len(b) { return false } - for i := 0; i < len(inA); i++ { - if !EqualsRefOfLeaf(inA[i], inB[i]) { + for i := 0; i < len(a); i++ { + if !EqualsRefOfLeaf(a[i], b[i]) { return false } } From 36f7e0870704a5f37496366e28e3ca4bd4e867b6 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Fri, 12 Mar 2021 15:16:27 +0100 Subject: [PATCH 08/13] make interface comparisons safe Signed-off-by: Andres Taylor --- go/tools/asthelpergen/equals_gen.go | 2 +- go/tools/asthelpergen/integration/equals.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go/tools/asthelpergen/equals_gen.go b/go/tools/asthelpergen/equals_gen.go index 686353339e2..50a21484620 100644 --- a/go/tools/asthelpergen/equals_gen.go +++ b/go/tools/asthelpergen/equals_gen.go @@ -105,7 +105,7 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa } */ stmts := []jen.Code{ - jen.If(jen.Id("inA == inB")).Block(jen.Return(jen.True())), + jen.If(jen.Id("inA == nil").Op("&&").Id("inB == nil")).Block(jen.Return(jen.True())), jen.If(jen.Id("inA == nil").Op("||").Id("inB == nil")).Block(jen.Return(jen.False())), } diff --git a/go/tools/asthelpergen/integration/equals.go b/go/tools/asthelpergen/integration/equals.go index d14610e8ca9..97482eafcf9 100644 --- a/go/tools/asthelpergen/integration/equals.go +++ b/go/tools/asthelpergen/integration/equals.go @@ -19,7 +19,7 @@ package integration // EqualsAST does deep equals. func EqualsAST(inA, inB AST) bool { - if inA == inB { + if inA == nil && inB == nil { return true } if inA == nil || inB == nil { @@ -107,7 +107,7 @@ func EqualsAST(inA, inB AST) bool { // EqualsSubIface does deep equals. func EqualsSubIface(inA, inB SubIface) bool { - if inA == inB { + if inA == nil && inB == nil { return true } if inA == nil || inB == nil { From bee4387318396b52793c12f86a4bab0af8dd1ddf Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Fri, 12 Mar 2021 17:27:03 +0100 Subject: [PATCH 09/13] support ptr to basic types, and a little cleanup Signed-off-by: Andres Taylor --- go/tools/asthelpergen/clone_gen.go | 3 +- go/tools/asthelpergen/equals_gen.go | 42 +++++++++++++++---- go/tools/asthelpergen/integration/clone.go | 18 ++++++-- go/tools/asthelpergen/integration/equals.go | 34 +++++++++++---- .../integration/integration_equals_test.go | 5 +++ go/tools/asthelpergen/integration/types.go | 1 + 6 files changed, 84 insertions(+), 19 deletions(-) diff --git a/go/tools/asthelpergen/clone_gen.go b/go/tools/asthelpergen/clone_gen.go index 2ddd905adbb..f2930edbd5a 100644 --- a/go/tools/asthelpergen/clone_gen.go +++ b/go/tools/asthelpergen/clone_gen.go @@ -20,6 +20,7 @@ import ( "fmt" "go/types" "log" + "strings" "github.com/dave/jennifer/jen" ) @@ -350,7 +351,7 @@ func printableTypeName(t types.Type) string { case *types.Named: return t.Obj().Name() case *types.Basic: - return t.Name() + return strings.Title(t.Name()) case *types.Interface: return t.String() default: diff --git a/go/tools/asthelpergen/equals_gen.go b/go/tools/asthelpergen/equals_gen.go index 50a21484620..a7d6fbb1dab 100644 --- a/go/tools/asthelpergen/equals_gen.go +++ b/go/tools/asthelpergen/equals_gen.go @@ -134,8 +134,6 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa cases..., ))) - stmts = append(stmts, jen.Return(jen.False())) - typeString := types.TypeString(t, noQualifier) funcName := equalsName + printableTypeName(t) funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("inA"), jen.Id("inB")).Id(typeString)).Bool().Block(stmts...) @@ -201,7 +199,7 @@ func (e *equalsGen) compareAllStructFields(stroct *types.Struct) jen.Code { var others []*jen.Statement for i := 0; i < stroct.NumFields(); i++ { field := stroct.Field(i) - if field.Type().Underlying().String() == "interface{}" { + if field.Type().Underlying().String() == "interface{}" || field.Name() == "_" { // we can safely ignore this, we do not want ast to contain interface{} types. continue } @@ -244,15 +242,21 @@ func (e *equalsGen) tryPtr(underlying, t types.Type) bool { return false } - if strct, isStruct := ptr.Elem().Underlying().(*types.Struct); isStruct { - e.makePtrToStructCloneMethod(t, strct) + ptrToType := ptr.Elem().Underlying() + + switch ptrToType := ptrToType.(type) { + case *types.Struct: + e.makePtrToStructEqualsMethod(t, ptrToType) + return true + case *types.Basic: + e.makePtrToBasicEqualsMethod(t) return true } return false } -func (e *equalsGen) makePtrToStructCloneMethod(t types.Type, strct *types.Struct) { +func (e *equalsGen) makePtrToStructEqualsMethod(t types.Type, strct *types.Struct) { typeString := types.TypeString(t, noQualifier) funcName := equalsName + printableTypeName(t) @@ -264,7 +268,31 @@ func (e *equalsGen) makePtrToStructCloneMethod(t types.Type, strct *types.Struct jen.Return(e.compareAllStructFields(strct)), } - e.methods = append(e.methods, funcDeclaration.Block(stmts...)) + e.addFunc(funcName, funcDeclaration.Block(stmts...)) +} +func (e *equalsGen) makePtrToBasicEqualsMethod(t types.Type) { + /* + func EqualsRefOfBool(a, b *bool) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return *a == *b + } + */ + typeString := types.TypeString(t, noQualifier) + funcName := equalsName + printableTypeName(t) + + //func EqualsRefOfType(a,b *Type) *Type + funcDeclaration := jen.Func().Id(funcName).Call(jen.Id("a"), jen.Id("b").Id(typeString)).Bool() + stmts := []jen.Code{ + jen.If(jen.Id("a == b")).Block(jen.Return(jen.True())), + jen.If(jen.Id("a == nil").Op("||").Id("b == nil")).Block(jen.Return(jen.False())), + jen.Return(jen.Id("*a == *b")), + } + e.addFunc(funcName, funcDeclaration.Block(stmts...)) } func (e *equalsGen) trySlice(underlying, t types.Type) bool { diff --git a/go/tools/asthelpergen/integration/clone.go b/go/tools/asthelpergen/integration/clone.go index 71171554ece..14254598dcd 100644 --- a/go/tools/asthelpergen/integration/clone.go +++ b/go/tools/asthelpergen/integration/clone.go @@ -133,7 +133,7 @@ func CloneRefOfRefSliceContainer(n *RefSliceContainer) *RefSliceContainer { } out := *n out.ASTElements = CloneSliceOfAST(n.ASTElements) - out.NotASTElements = CloneSliceOfint(n.NotASTElements) + out.NotASTElements = CloneSliceOfInt(n.NotASTElements) out.ASTImplementationElements = CloneSliceOfRefOfLeaf(n.ASTImplementationElements) return &out } @@ -145,6 +145,7 @@ func CloneRefOfSubImpl(n *SubImpl) *SubImpl { } out := *n out.inner = CloneSubIface(n.inner) + out.field = CloneRefOfBool(n.field) return &out } @@ -177,8 +178,8 @@ func CloneSliceOfAST(n []AST) []AST { return res } -// CloneSliceOfint creates a deep clone of the input. -func CloneSliceOfint(n []int) []int { +// CloneSliceOfInt creates a deep clone of the input. +func CloneSliceOfInt(n []int) []int { res := make([]int, 0, len(n)) copy(res, n) return res @@ -193,6 +194,15 @@ func CloneSliceOfRefOfLeaf(n []*Leaf) []*Leaf { return res } +// CloneRefOfBool creates a deep clone of the input. +func CloneRefOfBool(n *bool) *bool { + if n == nil { + return nil + } + out := *n + return &out +} + // CloneRefOfValueContainer creates a deep clone of the input. func CloneRefOfValueContainer(n *ValueContainer) *ValueContainer { if n == nil { @@ -211,7 +221,7 @@ func CloneRefOfValueSliceContainer(n *ValueSliceContainer) *ValueSliceContainer } out := *n out.ASTElements = CloneSliceOfAST(n.ASTElements) - out.NotASTElements = CloneSliceOfint(n.NotASTElements) + out.NotASTElements = CloneSliceOfInt(n.NotASTElements) out.ASTImplementationElements = CloneSliceOfRefOfLeaf(n.ASTImplementationElements) return &out } diff --git a/go/tools/asthelpergen/integration/equals.go b/go/tools/asthelpergen/integration/equals.go index 97482eafcf9..be4ef803ef4 100644 --- a/go/tools/asthelpergen/integration/equals.go +++ b/go/tools/asthelpergen/integration/equals.go @@ -102,7 +102,6 @@ func EqualsAST(inA, inB AST) bool { // this should never happen return false } - return false } // EqualsSubIface does deep equals. @@ -124,7 +123,6 @@ func EqualsSubIface(inA, inB SubIface) bool { // this should never happen return false } - return false } // EqualsBytes does deep equals. @@ -157,6 +155,8 @@ func EqualsInterfaceSlice(a, b InterfaceSlice) bool { } return true } + +// EqualsRefOfLeaf does deep equals. func EqualsRefOfLeaf(a, b *Leaf) bool { if a == b { return true @@ -179,6 +179,8 @@ func EqualsLeafSlice(a, b LeafSlice) bool { } return true } + +// EqualsRefOfNoCloneType does deep equals. func EqualsRefOfNoCloneType(a, b *NoCloneType) bool { if a == b { return true @@ -188,6 +190,8 @@ func EqualsRefOfNoCloneType(a, b *NoCloneType) bool { } return a.v == b.v } + +// EqualsRefOfRefContainer does deep equals. func EqualsRefOfRefContainer(a, b *RefContainer) bool { if a == b { return true @@ -199,6 +203,8 @@ func EqualsRefOfRefContainer(a, b *RefContainer) bool { EqualsAST(a.ASTType, b.ASTType) && EqualsRefOfLeaf(a.ASTImplementationType, b.ASTImplementationType) } + +// EqualsRefOfRefSliceContainer does deep equals. func EqualsRefOfRefSliceContainer(a, b *RefSliceContainer) bool { if a == b { return true @@ -207,9 +213,11 @@ func EqualsRefOfRefSliceContainer(a, b *RefSliceContainer) bool { return false } return EqualsSliceOfAST(a.ASTElements, b.ASTElements) && - EqualsSliceOfint(a.NotASTElements, b.NotASTElements) && + EqualsSliceOfInt(a.NotASTElements, b.NotASTElements) && EqualsSliceOfRefOfLeaf(a.ASTImplementationElements, b.ASTImplementationElements) } + +// EqualsRefOfSubImpl does deep equals. func EqualsRefOfSubImpl(a, b *SubImpl) bool { if a == b { return true @@ -217,7 +225,8 @@ func EqualsRefOfSubImpl(a, b *SubImpl) bool { if a == nil || b == nil { return false } - return EqualsSubIface(a.inner, b.inner) + return EqualsSubIface(a.inner, b.inner) && + EqualsRefOfBool(a.field, b.field) } // EqualsValueContainer does deep equals. @@ -230,7 +239,7 @@ func EqualsValueContainer(a, b ValueContainer) bool { // EqualsValueSliceContainer does deep equals. func EqualsValueSliceContainer(a, b ValueSliceContainer) bool { return EqualsSliceOfAST(a.ASTElements, b.ASTElements) && - EqualsSliceOfint(a.NotASTElements, b.NotASTElements) && + EqualsSliceOfInt(a.NotASTElements, b.NotASTElements) && EqualsSliceOfRefOfLeaf(a.ASTImplementationElements, b.ASTImplementationElements) } @@ -247,8 +256,8 @@ func EqualsSliceOfAST(a, b []AST) bool { return true } -// EqualsSliceOfint does deep equals. -func EqualsSliceOfint(a, b []int) bool { +// EqualsSliceOfInt does deep equals. +func EqualsSliceOfInt(a, b []int) bool { if len(a) != len(b) { return false } @@ -272,3 +281,14 @@ func EqualsSliceOfRefOfLeaf(a, b []*Leaf) bool { } return true } + +// EqualsRefOfBool does deep equals. +func EqualsRefOfBool(a, b *bool) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return *a == *b +} diff --git a/go/tools/asthelpergen/integration/integration_equals_test.go b/go/tools/asthelpergen/integration/integration_equals_test.go index 60ced8cdbfb..df3316cfe17 100644 --- a/go/tools/asthelpergen/integration/integration_equals_test.go +++ b/go/tools/asthelpergen/integration/integration_equals_test.go @@ -38,6 +38,7 @@ func TestEquals(t *testing.T) { } func createObjs() []AST { + t := true return []AST{ nil, &Leaf{1}, @@ -54,6 +55,10 @@ func createObjs() []AST { &Leaf{2}, &Leaf{3}, }, + &SubImpl{ + inner: &SubImpl{}, + field: &t, + }, } } diff --git a/go/tools/asthelpergen/integration/types.go b/go/tools/asthelpergen/integration/types.go index 1a89d78c3a2..5d902873c05 100644 --- a/go/tools/asthelpergen/integration/types.go +++ b/go/tools/asthelpergen/integration/types.go @@ -148,6 +148,7 @@ type SubIface interface { type SubImpl struct { inner SubIface + field *bool } func (r *SubImpl) String() string { From af3a62cf324eabc31141efccb081ca4447f04463 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Fri, 12 Mar 2021 17:28:58 +0100 Subject: [PATCH 10/13] produced the new clone and equals for the AST Signed-off-by: Andres Taylor --- go/vt/sqlparser/clone.go | 14 +- go/vt/sqlparser/equals.go | 3956 +++++++++++++++++++++++++++++++++++++ 2 files changed, 3963 insertions(+), 7 deletions(-) create mode 100644 go/vt/sqlparser/equals.go diff --git a/go/vt/sqlparser/clone.go b/go/vt/sqlparser/clone.go index 26cd8c8b712..a0743ca4f50 100644 --- a/go/vt/sqlparser/clone.go +++ b/go/vt/sqlparser/clone.go @@ -1406,7 +1406,7 @@ func CloneRefOfSelect(n *Select) *Select { return nil } out := *n - out.Cache = CloneRefOfbool(n.Cache) + out.Cache = CloneRefOfBool(n.Cache) out.Comments = CloneComments(n.Comments) out.SelectExprs = CloneSelectExprs(n.SelectExprs) out.From = CloneTableExprs(n.From) @@ -1534,7 +1534,7 @@ func CloneRefOfColumnType(n *ColumnType) *ColumnType { out.Options = CloneRefOfColumnTypeOptions(n.Options) out.Length = CloneRefOfLiteral(n.Length) out.Scale = CloneRefOfLiteral(n.Scale) - out.EnumValues = CloneSliceOfstring(n.EnumValues) + out.EnumValues = CloneSliceOfString(n.EnumValues) return &out } @@ -1625,7 +1625,7 @@ func CloneRefOfFlush(n *Flush) *Flush { return nil } out := *n - out.FlushOptions = CloneSliceOfstring(n.FlushOptions) + out.FlushOptions = CloneSliceOfString(n.FlushOptions) out.TableNames = CloneTableNames(n.TableNames) return &out } @@ -2232,8 +2232,8 @@ func CloneSliceOfRefOfWhen(n []*When) []*When { return res } -// CloneRefOfbool creates a deep clone of the input. -func CloneRefOfbool(n *bool) *bool { +// CloneRefOfBool creates a deep clone of the input. +func CloneRefOfBool(n *bool) *bool { if n == nil { return nil } @@ -2285,8 +2285,8 @@ func CloneRefOfColumnTypeOptions(n *ColumnTypeOptions) *ColumnTypeOptions { return &out } -// CloneSliceOfstring creates a deep clone of the input. -func CloneSliceOfstring(n []string) []string { +// CloneSliceOfString creates a deep clone of the input. +func CloneSliceOfString(n []string) []string { res := make([]string, 0, len(n)) copy(res, n) return res diff --git a/go/vt/sqlparser/equals.go b/go/vt/sqlparser/equals.go new file mode 100644 index 00000000000..b8b172cf3dd --- /dev/null +++ b/go/vt/sqlparser/equals.go @@ -0,0 +1,3956 @@ +/* +Copyright 2021 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. +*/ +// Code generated by ASTHelperGen. DO NOT EDIT. + +package sqlparser + +// EqualsAlterOption does deep equals. +func EqualsAlterOption(inA, inB AlterOption) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AddColumns: + b, ok := inB.(*AddColumns) + if !ok { + return false + } + return EqualsRefOfAddColumns(a, b) + case *AddConstraintDefinition: + b, ok := inB.(*AddConstraintDefinition) + if !ok { + return false + } + return EqualsRefOfAddConstraintDefinition(a, b) + case *AddIndexDefinition: + b, ok := inB.(*AddIndexDefinition) + if !ok { + return false + } + return EqualsRefOfAddIndexDefinition(a, b) + case AlgorithmValue: + b, ok := inB.(AlgorithmValue) + if !ok { + return false + } + return a == b + case *AlterCharset: + b, ok := inB.(*AlterCharset) + if !ok { + return false + } + return EqualsRefOfAlterCharset(a, b) + case *AlterColumn: + b, ok := inB.(*AlterColumn) + if !ok { + return false + } + return EqualsRefOfAlterColumn(a, b) + case *ChangeColumn: + b, ok := inB.(*ChangeColumn) + if !ok { + return false + } + return EqualsRefOfChangeColumn(a, b) + case *DropColumn: + b, ok := inB.(*DropColumn) + if !ok { + return false + } + return EqualsRefOfDropColumn(a, b) + case *DropKey: + b, ok := inB.(*DropKey) + if !ok { + return false + } + return EqualsRefOfDropKey(a, b) + case *Force: + b, ok := inB.(*Force) + if !ok { + return false + } + return EqualsRefOfForce(a, b) + case *KeyState: + b, ok := inB.(*KeyState) + if !ok { + return false + } + return EqualsRefOfKeyState(a, b) + case *LockOption: + b, ok := inB.(*LockOption) + if !ok { + return false + } + return EqualsRefOfLockOption(a, b) + case *ModifyColumn: + b, ok := inB.(*ModifyColumn) + if !ok { + return false + } + return EqualsRefOfModifyColumn(a, b) + case *OrderByOption: + b, ok := inB.(*OrderByOption) + if !ok { + return false + } + return EqualsRefOfOrderByOption(a, b) + case *RenameIndex: + b, ok := inB.(*RenameIndex) + if !ok { + return false + } + return EqualsRefOfRenameIndex(a, b) + case *RenameTableName: + b, ok := inB.(*RenameTableName) + if !ok { + return false + } + return EqualsRefOfRenameTableName(a, b) + case TableOptions: + b, ok := inB.(TableOptions) + if !ok { + return false + } + return EqualsTableOptions(a, b) + case *TablespaceOperation: + b, ok := inB.(*TablespaceOperation) + if !ok { + return false + } + return EqualsRefOfTablespaceOperation(a, b) + case *Validation: + b, ok := inB.(*Validation) + if !ok { + return false + } + return EqualsRefOfValidation(a, b) + default: + // this should never happen + return false + } +} + +// EqualsCharacteristic does deep equals. +func EqualsCharacteristic(inA, inB Characteristic) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case AccessMode: + b, ok := inB.(AccessMode) + if !ok { + return false + } + return a == b + case IsolationLevel: + b, ok := inB.(IsolationLevel) + if !ok { + return false + } + return a == b + default: + // this should never happen + return false + } +} + +// EqualsColTuple does deep equals. +func EqualsColTuple(inA, inB ColTuple) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case ListArg: + b, ok := inB.(ListArg) + if !ok { + return false + } + return EqualsListArg(a, b) + case *Subquery: + b, ok := inB.(*Subquery) + if !ok { + return false + } + return EqualsRefOfSubquery(a, b) + case ValTuple: + b, ok := inB.(ValTuple) + if !ok { + return false + } + return EqualsValTuple(a, b) + default: + // this should never happen + return false + } +} + +// EqualsConstraintInfo does deep equals. +func EqualsConstraintInfo(inA, inB ConstraintInfo) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *CheckConstraintDefinition: + b, ok := inB.(*CheckConstraintDefinition) + if !ok { + return false + } + return EqualsRefOfCheckConstraintDefinition(a, b) + case *ForeignKeyDefinition: + b, ok := inB.(*ForeignKeyDefinition) + if !ok { + return false + } + return EqualsRefOfForeignKeyDefinition(a, b) + default: + // this should never happen + return false + } +} + +// EqualsDBDDLStatement does deep equals. +func EqualsDBDDLStatement(inA, inB DBDDLStatement) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AlterDatabase: + b, ok := inB.(*AlterDatabase) + if !ok { + return false + } + return EqualsRefOfAlterDatabase(a, b) + case *CreateDatabase: + b, ok := inB.(*CreateDatabase) + if !ok { + return false + } + return EqualsRefOfCreateDatabase(a, b) + case *DropDatabase: + b, ok := inB.(*DropDatabase) + if !ok { + return false + } + return EqualsRefOfDropDatabase(a, b) + default: + // this should never happen + return false + } +} + +// EqualsDDLStatement does deep equals. +func EqualsDDLStatement(inA, inB DDLStatement) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AlterTable: + b, ok := inB.(*AlterTable) + if !ok { + return false + } + return EqualsRefOfAlterTable(a, b) + case *AlterView: + b, ok := inB.(*AlterView) + if !ok { + return false + } + return EqualsRefOfAlterView(a, b) + case *CreateTable: + b, ok := inB.(*CreateTable) + if !ok { + return false + } + return EqualsRefOfCreateTable(a, b) + case *CreateView: + b, ok := inB.(*CreateView) + if !ok { + return false + } + return EqualsRefOfCreateView(a, b) + case *DropTable: + b, ok := inB.(*DropTable) + if !ok { + return false + } + return EqualsRefOfDropTable(a, b) + case *DropView: + b, ok := inB.(*DropView) + if !ok { + return false + } + return EqualsRefOfDropView(a, b) + case *RenameTable: + b, ok := inB.(*RenameTable) + if !ok { + return false + } + return EqualsRefOfRenameTable(a, b) + case *TruncateTable: + b, ok := inB.(*TruncateTable) + if !ok { + return false + } + return EqualsRefOfTruncateTable(a, b) + default: + // this should never happen + return false + } +} + +// EqualsExplain does deep equals. +func EqualsExplain(inA, inB Explain) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *ExplainStmt: + b, ok := inB.(*ExplainStmt) + if !ok { + return false + } + return EqualsRefOfExplainStmt(a, b) + case *ExplainTab: + b, ok := inB.(*ExplainTab) + if !ok { + return false + } + return EqualsRefOfExplainTab(a, b) + default: + // this should never happen + return false + } +} + +// EqualsExpr does deep equals. +func EqualsExpr(inA, inB Expr) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AndExpr: + b, ok := inB.(*AndExpr) + if !ok { + return false + } + return EqualsRefOfAndExpr(a, b) + case Argument: + b, ok := inB.(Argument) + if !ok { + return false + } + return a == b + case *BinaryExpr: + b, ok := inB.(*BinaryExpr) + if !ok { + return false + } + return EqualsRefOfBinaryExpr(a, b) + case BoolVal: + b, ok := inB.(BoolVal) + if !ok { + return false + } + return a == b + case *CaseExpr: + b, ok := inB.(*CaseExpr) + if !ok { + return false + } + return EqualsRefOfCaseExpr(a, b) + case *ColName: + b, ok := inB.(*ColName) + if !ok { + return false + } + return EqualsRefOfColName(a, b) + case *CollateExpr: + b, ok := inB.(*CollateExpr) + if !ok { + return false + } + return EqualsRefOfCollateExpr(a, b) + case *ComparisonExpr: + b, ok := inB.(*ComparisonExpr) + if !ok { + return false + } + return EqualsRefOfComparisonExpr(a, b) + case *ConvertExpr: + b, ok := inB.(*ConvertExpr) + if !ok { + return false + } + return EqualsRefOfConvertExpr(a, b) + case *ConvertUsingExpr: + b, ok := inB.(*ConvertUsingExpr) + if !ok { + return false + } + return EqualsRefOfConvertUsingExpr(a, b) + case *CurTimeFuncExpr: + b, ok := inB.(*CurTimeFuncExpr) + if !ok { + return false + } + return EqualsRefOfCurTimeFuncExpr(a, b) + case *Default: + b, ok := inB.(*Default) + if !ok { + return false + } + return EqualsRefOfDefault(a, b) + case *ExistsExpr: + b, ok := inB.(*ExistsExpr) + if !ok { + return false + } + return EqualsRefOfExistsExpr(a, b) + case *FuncExpr: + b, ok := inB.(*FuncExpr) + if !ok { + return false + } + return EqualsRefOfFuncExpr(a, b) + case *GroupConcatExpr: + b, ok := inB.(*GroupConcatExpr) + if !ok { + return false + } + return EqualsRefOfGroupConcatExpr(a, b) + case *IntervalExpr: + b, ok := inB.(*IntervalExpr) + if !ok { + return false + } + return EqualsRefOfIntervalExpr(a, b) + case *IsExpr: + b, ok := inB.(*IsExpr) + if !ok { + return false + } + return EqualsRefOfIsExpr(a, b) + case ListArg: + b, ok := inB.(ListArg) + if !ok { + return false + } + return EqualsListArg(a, b) + case *Literal: + b, ok := inB.(*Literal) + if !ok { + return false + } + return EqualsRefOfLiteral(a, b) + case *MatchExpr: + b, ok := inB.(*MatchExpr) + if !ok { + return false + } + return EqualsRefOfMatchExpr(a, b) + case *NotExpr: + b, ok := inB.(*NotExpr) + if !ok { + return false + } + return EqualsRefOfNotExpr(a, b) + case *NullVal: + b, ok := inB.(*NullVal) + if !ok { + return false + } + return EqualsRefOfNullVal(a, b) + case *OrExpr: + b, ok := inB.(*OrExpr) + if !ok { + return false + } + return EqualsRefOfOrExpr(a, b) + case *RangeCond: + b, ok := inB.(*RangeCond) + if !ok { + return false + } + return EqualsRefOfRangeCond(a, b) + case *Subquery: + b, ok := inB.(*Subquery) + if !ok { + return false + } + return EqualsRefOfSubquery(a, b) + case *SubstrExpr: + b, ok := inB.(*SubstrExpr) + if !ok { + return false + } + return EqualsRefOfSubstrExpr(a, b) + case *TimestampFuncExpr: + b, ok := inB.(*TimestampFuncExpr) + if !ok { + return false + } + return EqualsRefOfTimestampFuncExpr(a, b) + case *UnaryExpr: + b, ok := inB.(*UnaryExpr) + if !ok { + return false + } + return EqualsRefOfUnaryExpr(a, b) + case ValTuple: + b, ok := inB.(ValTuple) + if !ok { + return false + } + return EqualsValTuple(a, b) + case *ValuesFuncExpr: + b, ok := inB.(*ValuesFuncExpr) + if !ok { + return false + } + return EqualsRefOfValuesFuncExpr(a, b) + case *XorExpr: + b, ok := inB.(*XorExpr) + if !ok { + return false + } + return EqualsRefOfXorExpr(a, b) + default: + // this should never happen + return false + } +} + +// EqualsInsertRows does deep equals. +func EqualsInsertRows(inA, inB InsertRows) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *ParenSelect: + b, ok := inB.(*ParenSelect) + if !ok { + return false + } + return EqualsRefOfParenSelect(a, b) + case *Select: + b, ok := inB.(*Select) + if !ok { + return false + } + return EqualsRefOfSelect(a, b) + case *Union: + b, ok := inB.(*Union) + if !ok { + return false + } + return EqualsRefOfUnion(a, b) + case Values: + b, ok := inB.(Values) + if !ok { + return false + } + return EqualsValues(a, b) + default: + // this should never happen + return false + } +} + +// EqualsSQLNode does deep equals. +func EqualsSQLNode(inA, inB SQLNode) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case AccessMode: + b, ok := inB.(AccessMode) + if !ok { + return false + } + return a == b + case *AddColumns: + b, ok := inB.(*AddColumns) + if !ok { + return false + } + return EqualsRefOfAddColumns(a, b) + case *AddConstraintDefinition: + b, ok := inB.(*AddConstraintDefinition) + if !ok { + return false + } + return EqualsRefOfAddConstraintDefinition(a, b) + case *AddIndexDefinition: + b, ok := inB.(*AddIndexDefinition) + if !ok { + return false + } + return EqualsRefOfAddIndexDefinition(a, b) + case AlgorithmValue: + b, ok := inB.(AlgorithmValue) + if !ok { + return false + } + return a == b + case *AliasedExpr: + b, ok := inB.(*AliasedExpr) + if !ok { + return false + } + return EqualsRefOfAliasedExpr(a, b) + case *AliasedTableExpr: + b, ok := inB.(*AliasedTableExpr) + if !ok { + return false + } + return EqualsRefOfAliasedTableExpr(a, b) + case *AlterCharset: + b, ok := inB.(*AlterCharset) + if !ok { + return false + } + return EqualsRefOfAlterCharset(a, b) + case *AlterColumn: + b, ok := inB.(*AlterColumn) + if !ok { + return false + } + return EqualsRefOfAlterColumn(a, b) + case *AlterDatabase: + b, ok := inB.(*AlterDatabase) + if !ok { + return false + } + return EqualsRefOfAlterDatabase(a, b) + case *AlterTable: + b, ok := inB.(*AlterTable) + if !ok { + return false + } + return EqualsRefOfAlterTable(a, b) + case *AlterView: + b, ok := inB.(*AlterView) + if !ok { + return false + } + return EqualsRefOfAlterView(a, b) + case *AlterVschema: + b, ok := inB.(*AlterVschema) + if !ok { + return false + } + return EqualsRefOfAlterVschema(a, b) + case *AndExpr: + b, ok := inB.(*AndExpr) + if !ok { + return false + } + return EqualsRefOfAndExpr(a, b) + case Argument: + b, ok := inB.(Argument) + if !ok { + return false + } + return a == b + case *AutoIncSpec: + b, ok := inB.(*AutoIncSpec) + if !ok { + return false + } + return EqualsRefOfAutoIncSpec(a, b) + case *Begin: + b, ok := inB.(*Begin) + if !ok { + return false + } + return EqualsRefOfBegin(a, b) + case *BinaryExpr: + b, ok := inB.(*BinaryExpr) + if !ok { + return false + } + return EqualsRefOfBinaryExpr(a, b) + case BoolVal: + b, ok := inB.(BoolVal) + if !ok { + return false + } + return a == b + case *CallProc: + b, ok := inB.(*CallProc) + if !ok { + return false + } + return EqualsRefOfCallProc(a, b) + case *CaseExpr: + b, ok := inB.(*CaseExpr) + if !ok { + return false + } + return EqualsRefOfCaseExpr(a, b) + case *ChangeColumn: + b, ok := inB.(*ChangeColumn) + if !ok { + return false + } + return EqualsRefOfChangeColumn(a, b) + case *CheckConstraintDefinition: + b, ok := inB.(*CheckConstraintDefinition) + if !ok { + return false + } + return EqualsRefOfCheckConstraintDefinition(a, b) + case ColIdent: + b, ok := inB.(ColIdent) + if !ok { + return false + } + return EqualsColIdent(a, b) + case *ColName: + b, ok := inB.(*ColName) + if !ok { + return false + } + return EqualsRefOfColName(a, b) + case *CollateExpr: + b, ok := inB.(*CollateExpr) + if !ok { + return false + } + return EqualsRefOfCollateExpr(a, b) + case *ColumnDefinition: + b, ok := inB.(*ColumnDefinition) + if !ok { + return false + } + return EqualsRefOfColumnDefinition(a, b) + case *ColumnType: + b, ok := inB.(*ColumnType) + if !ok { + return false + } + return EqualsRefOfColumnType(a, b) + case Columns: + b, ok := inB.(Columns) + if !ok { + return false + } + return EqualsColumns(a, b) + case Comments: + b, ok := inB.(Comments) + if !ok { + return false + } + return EqualsComments(a, b) + case *Commit: + b, ok := inB.(*Commit) + if !ok { + return false + } + return EqualsRefOfCommit(a, b) + case *ComparisonExpr: + b, ok := inB.(*ComparisonExpr) + if !ok { + return false + } + return EqualsRefOfComparisonExpr(a, b) + case *ConstraintDefinition: + b, ok := inB.(*ConstraintDefinition) + if !ok { + return false + } + return EqualsRefOfConstraintDefinition(a, b) + case *ConvertExpr: + b, ok := inB.(*ConvertExpr) + if !ok { + return false + } + return EqualsRefOfConvertExpr(a, b) + case *ConvertType: + b, ok := inB.(*ConvertType) + if !ok { + return false + } + return EqualsRefOfConvertType(a, b) + case *ConvertUsingExpr: + b, ok := inB.(*ConvertUsingExpr) + if !ok { + return false + } + return EqualsRefOfConvertUsingExpr(a, b) + case *CreateDatabase: + b, ok := inB.(*CreateDatabase) + if !ok { + return false + } + return EqualsRefOfCreateDatabase(a, b) + case *CreateTable: + b, ok := inB.(*CreateTable) + if !ok { + return false + } + return EqualsRefOfCreateTable(a, b) + case *CreateView: + b, ok := inB.(*CreateView) + if !ok { + return false + } + return EqualsRefOfCreateView(a, b) + case *CurTimeFuncExpr: + b, ok := inB.(*CurTimeFuncExpr) + if !ok { + return false + } + return EqualsRefOfCurTimeFuncExpr(a, b) + case *Default: + b, ok := inB.(*Default) + if !ok { + return false + } + return EqualsRefOfDefault(a, b) + case *Delete: + b, ok := inB.(*Delete) + if !ok { + return false + } + return EqualsRefOfDelete(a, b) + case *DerivedTable: + b, ok := inB.(*DerivedTable) + if !ok { + return false + } + return EqualsRefOfDerivedTable(a, b) + case *DropColumn: + b, ok := inB.(*DropColumn) + if !ok { + return false + } + return EqualsRefOfDropColumn(a, b) + case *DropDatabase: + b, ok := inB.(*DropDatabase) + if !ok { + return false + } + return EqualsRefOfDropDatabase(a, b) + case *DropKey: + b, ok := inB.(*DropKey) + if !ok { + return false + } + return EqualsRefOfDropKey(a, b) + case *DropTable: + b, ok := inB.(*DropTable) + if !ok { + return false + } + return EqualsRefOfDropTable(a, b) + case *DropView: + b, ok := inB.(*DropView) + if !ok { + return false + } + return EqualsRefOfDropView(a, b) + case *ExistsExpr: + b, ok := inB.(*ExistsExpr) + if !ok { + return false + } + return EqualsRefOfExistsExpr(a, b) + case *ExplainStmt: + b, ok := inB.(*ExplainStmt) + if !ok { + return false + } + return EqualsRefOfExplainStmt(a, b) + case *ExplainTab: + b, ok := inB.(*ExplainTab) + if !ok { + return false + } + return EqualsRefOfExplainTab(a, b) + case Exprs: + b, ok := inB.(Exprs) + if !ok { + return false + } + return EqualsExprs(a, b) + case *Flush: + b, ok := inB.(*Flush) + if !ok { + return false + } + return EqualsRefOfFlush(a, b) + case *Force: + b, ok := inB.(*Force) + if !ok { + return false + } + return EqualsRefOfForce(a, b) + case *ForeignKeyDefinition: + b, ok := inB.(*ForeignKeyDefinition) + if !ok { + return false + } + return EqualsRefOfForeignKeyDefinition(a, b) + case *FuncExpr: + b, ok := inB.(*FuncExpr) + if !ok { + return false + } + return EqualsRefOfFuncExpr(a, b) + case GroupBy: + b, ok := inB.(GroupBy) + if !ok { + return false + } + return EqualsGroupBy(a, b) + case *GroupConcatExpr: + b, ok := inB.(*GroupConcatExpr) + if !ok { + return false + } + return EqualsRefOfGroupConcatExpr(a, b) + case *IndexDefinition: + b, ok := inB.(*IndexDefinition) + if !ok { + return false + } + return EqualsRefOfIndexDefinition(a, b) + case *IndexHints: + b, ok := inB.(*IndexHints) + if !ok { + return false + } + return EqualsRefOfIndexHints(a, b) + case *IndexInfo: + b, ok := inB.(*IndexInfo) + if !ok { + return false + } + return EqualsRefOfIndexInfo(a, b) + case *Insert: + b, ok := inB.(*Insert) + if !ok { + return false + } + return EqualsRefOfInsert(a, b) + case *IntervalExpr: + b, ok := inB.(*IntervalExpr) + if !ok { + return false + } + return EqualsRefOfIntervalExpr(a, b) + case *IsExpr: + b, ok := inB.(*IsExpr) + if !ok { + return false + } + return EqualsRefOfIsExpr(a, b) + case IsolationLevel: + b, ok := inB.(IsolationLevel) + if !ok { + return false + } + return a == b + case JoinCondition: + b, ok := inB.(JoinCondition) + if !ok { + return false + } + return EqualsJoinCondition(a, b) + case *JoinTableExpr: + b, ok := inB.(*JoinTableExpr) + if !ok { + return false + } + return EqualsRefOfJoinTableExpr(a, b) + case *KeyState: + b, ok := inB.(*KeyState) + if !ok { + return false + } + return EqualsRefOfKeyState(a, b) + case *Limit: + b, ok := inB.(*Limit) + if !ok { + return false + } + return EqualsRefOfLimit(a, b) + case ListArg: + b, ok := inB.(ListArg) + if !ok { + return false + } + return EqualsListArg(a, b) + case *Literal: + b, ok := inB.(*Literal) + if !ok { + return false + } + return EqualsRefOfLiteral(a, b) + case *Load: + b, ok := inB.(*Load) + if !ok { + return false + } + return EqualsRefOfLoad(a, b) + case *LockOption: + b, ok := inB.(*LockOption) + if !ok { + return false + } + return EqualsRefOfLockOption(a, b) + case *LockTables: + b, ok := inB.(*LockTables) + if !ok { + return false + } + return EqualsRefOfLockTables(a, b) + case *MatchExpr: + b, ok := inB.(*MatchExpr) + if !ok { + return false + } + return EqualsRefOfMatchExpr(a, b) + case *ModifyColumn: + b, ok := inB.(*ModifyColumn) + if !ok { + return false + } + return EqualsRefOfModifyColumn(a, b) + case *Nextval: + b, ok := inB.(*Nextval) + if !ok { + return false + } + return EqualsRefOfNextval(a, b) + case *NotExpr: + b, ok := inB.(*NotExpr) + if !ok { + return false + } + return EqualsRefOfNotExpr(a, b) + case *NullVal: + b, ok := inB.(*NullVal) + if !ok { + return false + } + return EqualsRefOfNullVal(a, b) + case OnDup: + b, ok := inB.(OnDup) + if !ok { + return false + } + return EqualsOnDup(a, b) + case *OptLike: + b, ok := inB.(*OptLike) + if !ok { + return false + } + return EqualsRefOfOptLike(a, b) + case *OrExpr: + b, ok := inB.(*OrExpr) + if !ok { + return false + } + return EqualsRefOfOrExpr(a, b) + case *Order: + b, ok := inB.(*Order) + if !ok { + return false + } + return EqualsRefOfOrder(a, b) + case OrderBy: + b, ok := inB.(OrderBy) + if !ok { + return false + } + return EqualsOrderBy(a, b) + case *OrderByOption: + b, ok := inB.(*OrderByOption) + if !ok { + return false + } + return EqualsRefOfOrderByOption(a, b) + case *OtherAdmin: + b, ok := inB.(*OtherAdmin) + if !ok { + return false + } + return EqualsRefOfOtherAdmin(a, b) + case *OtherRead: + b, ok := inB.(*OtherRead) + if !ok { + return false + } + return EqualsRefOfOtherRead(a, b) + case *ParenSelect: + b, ok := inB.(*ParenSelect) + if !ok { + return false + } + return EqualsRefOfParenSelect(a, b) + case *ParenTableExpr: + b, ok := inB.(*ParenTableExpr) + if !ok { + return false + } + return EqualsRefOfParenTableExpr(a, b) + case *PartitionDefinition: + b, ok := inB.(*PartitionDefinition) + if !ok { + return false + } + return EqualsRefOfPartitionDefinition(a, b) + case *PartitionSpec: + b, ok := inB.(*PartitionSpec) + if !ok { + return false + } + return EqualsRefOfPartitionSpec(a, b) + case Partitions: + b, ok := inB.(Partitions) + if !ok { + return false + } + return EqualsPartitions(a, b) + case *RangeCond: + b, ok := inB.(*RangeCond) + if !ok { + return false + } + return EqualsRefOfRangeCond(a, b) + case ReferenceAction: + b, ok := inB.(ReferenceAction) + if !ok { + return false + } + return a == b + case *Release: + b, ok := inB.(*Release) + if !ok { + return false + } + return EqualsRefOfRelease(a, b) + case *RenameIndex: + b, ok := inB.(*RenameIndex) + if !ok { + return false + } + return EqualsRefOfRenameIndex(a, b) + case *RenameTable: + b, ok := inB.(*RenameTable) + if !ok { + return false + } + return EqualsRefOfRenameTable(a, b) + case *RenameTableName: + b, ok := inB.(*RenameTableName) + if !ok { + return false + } + return EqualsRefOfRenameTableName(a, b) + case *Rollback: + b, ok := inB.(*Rollback) + if !ok { + return false + } + return EqualsRefOfRollback(a, b) + case *SRollback: + b, ok := inB.(*SRollback) + if !ok { + return false + } + return EqualsRefOfSRollback(a, b) + case *Savepoint: + b, ok := inB.(*Savepoint) + if !ok { + return false + } + return EqualsRefOfSavepoint(a, b) + case *Select: + b, ok := inB.(*Select) + if !ok { + return false + } + return EqualsRefOfSelect(a, b) + case SelectExprs: + b, ok := inB.(SelectExprs) + if !ok { + return false + } + return EqualsSelectExprs(a, b) + case *SelectInto: + b, ok := inB.(*SelectInto) + if !ok { + return false + } + return EqualsRefOfSelectInto(a, b) + case *Set: + b, ok := inB.(*Set) + if !ok { + return false + } + return EqualsRefOfSet(a, b) + case *SetExpr: + b, ok := inB.(*SetExpr) + if !ok { + return false + } + return EqualsRefOfSetExpr(a, b) + case SetExprs: + b, ok := inB.(SetExprs) + if !ok { + return false + } + return EqualsSetExprs(a, b) + case *SetTransaction: + b, ok := inB.(*SetTransaction) + if !ok { + return false + } + return EqualsRefOfSetTransaction(a, b) + case *Show: + b, ok := inB.(*Show) + if !ok { + return false + } + return EqualsRefOfShow(a, b) + case *ShowBasic: + b, ok := inB.(*ShowBasic) + if !ok { + return false + } + return EqualsRefOfShowBasic(a, b) + case *ShowCreate: + b, ok := inB.(*ShowCreate) + if !ok { + return false + } + return EqualsRefOfShowCreate(a, b) + case *ShowFilter: + b, ok := inB.(*ShowFilter) + if !ok { + return false + } + return EqualsRefOfShowFilter(a, b) + case *ShowLegacy: + b, ok := inB.(*ShowLegacy) + if !ok { + return false + } + return EqualsRefOfShowLegacy(a, b) + case *StarExpr: + b, ok := inB.(*StarExpr) + if !ok { + return false + } + return EqualsRefOfStarExpr(a, b) + case *Stream: + b, ok := inB.(*Stream) + if !ok { + return false + } + return EqualsRefOfStream(a, b) + case *Subquery: + b, ok := inB.(*Subquery) + if !ok { + return false + } + return EqualsRefOfSubquery(a, b) + case *SubstrExpr: + b, ok := inB.(*SubstrExpr) + if !ok { + return false + } + return EqualsRefOfSubstrExpr(a, b) + case TableExprs: + b, ok := inB.(TableExprs) + if !ok { + return false + } + return EqualsTableExprs(a, b) + case TableIdent: + b, ok := inB.(TableIdent) + if !ok { + return false + } + return EqualsTableIdent(a, b) + case TableName: + b, ok := inB.(TableName) + if !ok { + return false + } + return EqualsTableName(a, b) + case TableNames: + b, ok := inB.(TableNames) + if !ok { + return false + } + return EqualsTableNames(a, b) + case TableOptions: + b, ok := inB.(TableOptions) + if !ok { + return false + } + return EqualsTableOptions(a, b) + case *TableSpec: + b, ok := inB.(*TableSpec) + if !ok { + return false + } + return EqualsRefOfTableSpec(a, b) + case *TablespaceOperation: + b, ok := inB.(*TablespaceOperation) + if !ok { + return false + } + return EqualsRefOfTablespaceOperation(a, b) + case *TimestampFuncExpr: + b, ok := inB.(*TimestampFuncExpr) + if !ok { + return false + } + return EqualsRefOfTimestampFuncExpr(a, b) + case *TruncateTable: + b, ok := inB.(*TruncateTable) + if !ok { + return false + } + return EqualsRefOfTruncateTable(a, b) + case *UnaryExpr: + b, ok := inB.(*UnaryExpr) + if !ok { + return false + } + return EqualsRefOfUnaryExpr(a, b) + case *Union: + b, ok := inB.(*Union) + if !ok { + return false + } + return EqualsRefOfUnion(a, b) + case *UnionSelect: + b, ok := inB.(*UnionSelect) + if !ok { + return false + } + return EqualsRefOfUnionSelect(a, b) + case *UnlockTables: + b, ok := inB.(*UnlockTables) + if !ok { + return false + } + return EqualsRefOfUnlockTables(a, b) + case *Update: + b, ok := inB.(*Update) + if !ok { + return false + } + return EqualsRefOfUpdate(a, b) + case *UpdateExpr: + b, ok := inB.(*UpdateExpr) + if !ok { + return false + } + return EqualsRefOfUpdateExpr(a, b) + case UpdateExprs: + b, ok := inB.(UpdateExprs) + if !ok { + return false + } + return EqualsUpdateExprs(a, b) + case *Use: + b, ok := inB.(*Use) + if !ok { + return false + } + return EqualsRefOfUse(a, b) + case *VStream: + b, ok := inB.(*VStream) + if !ok { + return false + } + return EqualsRefOfVStream(a, b) + case ValTuple: + b, ok := inB.(ValTuple) + if !ok { + return false + } + return EqualsValTuple(a, b) + case *Validation: + b, ok := inB.(*Validation) + if !ok { + return false + } + return EqualsRefOfValidation(a, b) + case Values: + b, ok := inB.(Values) + if !ok { + return false + } + return EqualsValues(a, b) + case *ValuesFuncExpr: + b, ok := inB.(*ValuesFuncExpr) + if !ok { + return false + } + return EqualsRefOfValuesFuncExpr(a, b) + case VindexParam: + b, ok := inB.(VindexParam) + if !ok { + return false + } + return EqualsVindexParam(a, b) + case *VindexSpec: + b, ok := inB.(*VindexSpec) + if !ok { + return false + } + return EqualsRefOfVindexSpec(a, b) + case *When: + b, ok := inB.(*When) + if !ok { + return false + } + return EqualsRefOfWhen(a, b) + case *Where: + b, ok := inB.(*Where) + if !ok { + return false + } + return EqualsRefOfWhere(a, b) + case *XorExpr: + b, ok := inB.(*XorExpr) + if !ok { + return false + } + return EqualsRefOfXorExpr(a, b) + default: + // this should never happen + return false + } +} + +// EqualsSelectExpr does deep equals. +func EqualsSelectExpr(inA, inB SelectExpr) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AliasedExpr: + b, ok := inB.(*AliasedExpr) + if !ok { + return false + } + return EqualsRefOfAliasedExpr(a, b) + case *Nextval: + b, ok := inB.(*Nextval) + if !ok { + return false + } + return EqualsRefOfNextval(a, b) + case *StarExpr: + b, ok := inB.(*StarExpr) + if !ok { + return false + } + return EqualsRefOfStarExpr(a, b) + default: + // this should never happen + return false + } +} + +// EqualsSelectStatement does deep equals. +func EqualsSelectStatement(inA, inB SelectStatement) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *ParenSelect: + b, ok := inB.(*ParenSelect) + if !ok { + return false + } + return EqualsRefOfParenSelect(a, b) + case *Select: + b, ok := inB.(*Select) + if !ok { + return false + } + return EqualsRefOfSelect(a, b) + case *Union: + b, ok := inB.(*Union) + if !ok { + return false + } + return EqualsRefOfUnion(a, b) + default: + // this should never happen + return false + } +} + +// EqualsShowInternal does deep equals. +func EqualsShowInternal(inA, inB ShowInternal) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *ShowBasic: + b, ok := inB.(*ShowBasic) + if !ok { + return false + } + return EqualsRefOfShowBasic(a, b) + case *ShowCreate: + b, ok := inB.(*ShowCreate) + if !ok { + return false + } + return EqualsRefOfShowCreate(a, b) + case *ShowLegacy: + b, ok := inB.(*ShowLegacy) + if !ok { + return false + } + return EqualsRefOfShowLegacy(a, b) + default: + // this should never happen + return false + } +} + +// EqualsSimpleTableExpr does deep equals. +func EqualsSimpleTableExpr(inA, inB SimpleTableExpr) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *DerivedTable: + b, ok := inB.(*DerivedTable) + if !ok { + return false + } + return EqualsRefOfDerivedTable(a, b) + case TableName: + b, ok := inB.(TableName) + if !ok { + return false + } + return EqualsTableName(a, b) + default: + // this should never happen + return false + } +} + +// EqualsStatement does deep equals. +func EqualsStatement(inA, inB Statement) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AlterDatabase: + b, ok := inB.(*AlterDatabase) + if !ok { + return false + } + return EqualsRefOfAlterDatabase(a, b) + case *AlterTable: + b, ok := inB.(*AlterTable) + if !ok { + return false + } + return EqualsRefOfAlterTable(a, b) + case *AlterView: + b, ok := inB.(*AlterView) + if !ok { + return false + } + return EqualsRefOfAlterView(a, b) + case *AlterVschema: + b, ok := inB.(*AlterVschema) + if !ok { + return false + } + return EqualsRefOfAlterVschema(a, b) + case *Begin: + b, ok := inB.(*Begin) + if !ok { + return false + } + return EqualsRefOfBegin(a, b) + case *CallProc: + b, ok := inB.(*CallProc) + if !ok { + return false + } + return EqualsRefOfCallProc(a, b) + case *Commit: + b, ok := inB.(*Commit) + if !ok { + return false + } + return EqualsRefOfCommit(a, b) + case *CreateDatabase: + b, ok := inB.(*CreateDatabase) + if !ok { + return false + } + return EqualsRefOfCreateDatabase(a, b) + case *CreateTable: + b, ok := inB.(*CreateTable) + if !ok { + return false + } + return EqualsRefOfCreateTable(a, b) + case *CreateView: + b, ok := inB.(*CreateView) + if !ok { + return false + } + return EqualsRefOfCreateView(a, b) + case *Delete: + b, ok := inB.(*Delete) + if !ok { + return false + } + return EqualsRefOfDelete(a, b) + case *DropDatabase: + b, ok := inB.(*DropDatabase) + if !ok { + return false + } + return EqualsRefOfDropDatabase(a, b) + case *DropTable: + b, ok := inB.(*DropTable) + if !ok { + return false + } + return EqualsRefOfDropTable(a, b) + case *DropView: + b, ok := inB.(*DropView) + if !ok { + return false + } + return EqualsRefOfDropView(a, b) + case *ExplainStmt: + b, ok := inB.(*ExplainStmt) + if !ok { + return false + } + return EqualsRefOfExplainStmt(a, b) + case *ExplainTab: + b, ok := inB.(*ExplainTab) + if !ok { + return false + } + return EqualsRefOfExplainTab(a, b) + case *Flush: + b, ok := inB.(*Flush) + if !ok { + return false + } + return EqualsRefOfFlush(a, b) + case *Insert: + b, ok := inB.(*Insert) + if !ok { + return false + } + return EqualsRefOfInsert(a, b) + case *Load: + b, ok := inB.(*Load) + if !ok { + return false + } + return EqualsRefOfLoad(a, b) + case *LockTables: + b, ok := inB.(*LockTables) + if !ok { + return false + } + return EqualsRefOfLockTables(a, b) + case *OtherAdmin: + b, ok := inB.(*OtherAdmin) + if !ok { + return false + } + return EqualsRefOfOtherAdmin(a, b) + case *OtherRead: + b, ok := inB.(*OtherRead) + if !ok { + return false + } + return EqualsRefOfOtherRead(a, b) + case *ParenSelect: + b, ok := inB.(*ParenSelect) + if !ok { + return false + } + return EqualsRefOfParenSelect(a, b) + case *Release: + b, ok := inB.(*Release) + if !ok { + return false + } + return EqualsRefOfRelease(a, b) + case *RenameTable: + b, ok := inB.(*RenameTable) + if !ok { + return false + } + return EqualsRefOfRenameTable(a, b) + case *Rollback: + b, ok := inB.(*Rollback) + if !ok { + return false + } + return EqualsRefOfRollback(a, b) + case *SRollback: + b, ok := inB.(*SRollback) + if !ok { + return false + } + return EqualsRefOfSRollback(a, b) + case *Savepoint: + b, ok := inB.(*Savepoint) + if !ok { + return false + } + return EqualsRefOfSavepoint(a, b) + case *Select: + b, ok := inB.(*Select) + if !ok { + return false + } + return EqualsRefOfSelect(a, b) + case *Set: + b, ok := inB.(*Set) + if !ok { + return false + } + return EqualsRefOfSet(a, b) + case *SetTransaction: + b, ok := inB.(*SetTransaction) + if !ok { + return false + } + return EqualsRefOfSetTransaction(a, b) + case *Show: + b, ok := inB.(*Show) + if !ok { + return false + } + return EqualsRefOfShow(a, b) + case *Stream: + b, ok := inB.(*Stream) + if !ok { + return false + } + return EqualsRefOfStream(a, b) + case *TruncateTable: + b, ok := inB.(*TruncateTable) + if !ok { + return false + } + return EqualsRefOfTruncateTable(a, b) + case *Union: + b, ok := inB.(*Union) + if !ok { + return false + } + return EqualsRefOfUnion(a, b) + case *UnlockTables: + b, ok := inB.(*UnlockTables) + if !ok { + return false + } + return EqualsRefOfUnlockTables(a, b) + case *Update: + b, ok := inB.(*Update) + if !ok { + return false + } + return EqualsRefOfUpdate(a, b) + case *Use: + b, ok := inB.(*Use) + if !ok { + return false + } + return EqualsRefOfUse(a, b) + case *VStream: + b, ok := inB.(*VStream) + if !ok { + return false + } + return EqualsRefOfVStream(a, b) + default: + // this should never happen + return false + } +} + +// EqualsTableExpr does deep equals. +func EqualsTableExpr(inA, inB TableExpr) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AliasedTableExpr: + b, ok := inB.(*AliasedTableExpr) + if !ok { + return false + } + return EqualsRefOfAliasedTableExpr(a, b) + case *JoinTableExpr: + b, ok := inB.(*JoinTableExpr) + if !ok { + return false + } + return EqualsRefOfJoinTableExpr(a, b) + case *ParenTableExpr: + b, ok := inB.(*ParenTableExpr) + if !ok { + return false + } + return EqualsRefOfParenTableExpr(a, b) + default: + // this should never happen + return false + } +} + +// EqualsRefOfAddColumns does deep equals. +func EqualsRefOfAddColumns(a, b *AddColumns) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSliceOfRefOfColumnDefinition(a.Columns, b.Columns) && + EqualsRefOfColName(a.First, b.First) && + EqualsRefOfColName(a.After, b.After) +} + +// EqualsRefOfAddConstraintDefinition does deep equals. +func EqualsRefOfAddConstraintDefinition(a, b *AddConstraintDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfConstraintDefinition(a.ConstraintDefinition, b.ConstraintDefinition) +} + +// EqualsRefOfAddIndexDefinition does deep equals. +func EqualsRefOfAddIndexDefinition(a, b *AddIndexDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfIndexDefinition(a.IndexDefinition, b.IndexDefinition) +} + +// EqualsRefOfAlterCharset does deep equals. +func EqualsRefOfAlterCharset(a, b *AlterCharset) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.CharacterSet == b.CharacterSet && + a.Collate == b.Collate +} + +// EqualsRefOfAlterColumn does deep equals. +func EqualsRefOfAlterColumn(a, b *AlterColumn) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.DropDefault == b.DropDefault && + EqualsRefOfColName(a.Column, b.Column) && + EqualsExpr(a.DefaultVal, b.DefaultVal) +} + +// EqualsRefOfChangeColumn does deep equals. +func EqualsRefOfChangeColumn(a, b *ChangeColumn) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColName(a.OldColumn, b.OldColumn) && + EqualsRefOfColumnDefinition(a.NewColDefinition, b.NewColDefinition) && + EqualsRefOfColName(a.First, b.First) && + EqualsRefOfColName(a.After, b.After) +} + +// EqualsRefOfDropColumn does deep equals. +func EqualsRefOfDropColumn(a, b *DropColumn) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColName(a.Name, b.Name) +} + +// EqualsRefOfDropKey does deep equals. +func EqualsRefOfDropKey(a, b *DropKey) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Name == b.Name && + a.Type == b.Type +} + +// EqualsRefOfForce does deep equals. +func EqualsRefOfForce(a, b *Force) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + +// EqualsRefOfKeyState does deep equals. +func EqualsRefOfKeyState(a, b *KeyState) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Enable == b.Enable +} + +// EqualsRefOfLockOption does deep equals. +func EqualsRefOfLockOption(a, b *LockOption) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type +} + +// EqualsRefOfModifyColumn does deep equals. +func EqualsRefOfModifyColumn(a, b *ModifyColumn) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColumnDefinition(a.NewColDefinition, b.NewColDefinition) && + EqualsRefOfColName(a.First, b.First) && + EqualsRefOfColName(a.After, b.After) +} + +// EqualsRefOfOrderByOption does deep equals. +func EqualsRefOfOrderByOption(a, b *OrderByOption) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColumns(a.Cols, b.Cols) +} + +// EqualsRefOfRenameIndex does deep equals. +func EqualsRefOfRenameIndex(a, b *RenameIndex) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.OldName == b.OldName && + a.NewName == b.NewName +} + +// EqualsRefOfRenameTableName does deep equals. +func EqualsRefOfRenameTableName(a, b *RenameTableName) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.Table, b.Table) +} + +// EqualsTableOptions does deep equals. +func EqualsTableOptions(a, b TableOptions) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfTableOption(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfTablespaceOperation does deep equals. +func EqualsRefOfTablespaceOperation(a, b *TablespaceOperation) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Import == b.Import +} + +// EqualsRefOfValidation does deep equals. +func EqualsRefOfValidation(a, b *Validation) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.With == b.With +} + +// EqualsListArg does deep equals. +func EqualsListArg(a, b ListArg) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + return true +} + +// EqualsRefOfSubquery does deep equals. +func EqualsRefOfSubquery(a, b *Subquery) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSelectStatement(a.Select, b.Select) +} + +// EqualsValTuple does deep equals. +func EqualsValTuple(a, b ValTuple) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsExpr(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfCheckConstraintDefinition does deep equals. +func EqualsRefOfCheckConstraintDefinition(a, b *CheckConstraintDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Enforced == b.Enforced && + EqualsExpr(a.Expr, b.Expr) +} + +// EqualsRefOfForeignKeyDefinition does deep equals. +func EqualsRefOfForeignKeyDefinition(a, b *ForeignKeyDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColumns(a.Source, b.Source) && + EqualsTableName(a.ReferencedTable, b.ReferencedTable) && + EqualsColumns(a.ReferencedColumns, b.ReferencedColumns) && + a.OnDelete == b.OnDelete && + a.OnUpdate == b.OnUpdate +} + +// EqualsRefOfAlterDatabase does deep equals. +func EqualsRefOfAlterDatabase(a, b *AlterDatabase) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.DBName == b.DBName && + a.UpdateDataDirectory == b.UpdateDataDirectory && + a.FullyParsed == b.FullyParsed && + EqualsSliceOfCollateAndCharset(a.AlterOptions, b.AlterOptions) +} + +// EqualsRefOfCreateDatabase does deep equals. +func EqualsRefOfCreateDatabase(a, b *CreateDatabase) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.DBName == b.DBName && + a.IfNotExists == b.IfNotExists && + a.FullyParsed == b.FullyParsed && + EqualsComments(a.Comments, b.Comments) && + EqualsSliceOfCollateAndCharset(a.CreateOptions, b.CreateOptions) +} + +// EqualsRefOfDropDatabase does deep equals. +func EqualsRefOfDropDatabase(a, b *DropDatabase) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.DBName == b.DBName && + a.IfExists == b.IfExists && + EqualsComments(a.Comments, b.Comments) +} + +// EqualsRefOfAlterTable does deep equals. +func EqualsRefOfAlterTable(a, b *AlterTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.FullyParsed == b.FullyParsed && + EqualsTableName(a.Table, b.Table) && + EqualsSliceOfAlterOption(a.AlterOptions, b.AlterOptions) && + EqualsRefOfPartitionSpec(a.PartitionSpec, b.PartitionSpec) +} + +// EqualsRefOfAlterView does deep equals. +func EqualsRefOfAlterView(a, b *AlterView) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Algorithm == b.Algorithm && + a.Definer == b.Definer && + a.Security == b.Security && + a.CheckOption == b.CheckOption && + EqualsTableName(a.ViewName, b.ViewName) && + EqualsColumns(a.Columns, b.Columns) && + EqualsSelectStatement(a.Select, b.Select) +} + +// EqualsRefOfCreateTable does deep equals. +func EqualsRefOfCreateTable(a, b *CreateTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Temp == b.Temp && + a.IfNotExists == b.IfNotExists && + a.FullyParsed == b.FullyParsed && + EqualsTableName(a.Table, b.Table) && + EqualsRefOfTableSpec(a.TableSpec, b.TableSpec) && + EqualsRefOfOptLike(a.OptLike, b.OptLike) +} + +// EqualsRefOfCreateView does deep equals. +func EqualsRefOfCreateView(a, b *CreateView) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Algorithm == b.Algorithm && + a.Definer == b.Definer && + a.Security == b.Security && + a.CheckOption == b.CheckOption && + a.IsReplace == b.IsReplace && + EqualsTableName(a.ViewName, b.ViewName) && + EqualsColumns(a.Columns, b.Columns) && + EqualsSelectStatement(a.Select, b.Select) +} + +// EqualsRefOfDropTable does deep equals. +func EqualsRefOfDropTable(a, b *DropTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Temp == b.Temp && + a.IfExists == b.IfExists && + EqualsTableNames(a.FromTables, b.FromTables) +} + +// EqualsRefOfDropView does deep equals. +func EqualsRefOfDropView(a, b *DropView) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.IfExists == b.IfExists && + EqualsTableNames(a.FromTables, b.FromTables) +} + +// EqualsRefOfRenameTable does deep equals. +func EqualsRefOfRenameTable(a, b *RenameTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSliceOfRefOfRenameTablePair(a.TablePairs, b.TablePairs) +} + +// EqualsRefOfTruncateTable does deep equals. +func EqualsRefOfTruncateTable(a, b *TruncateTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.Table, b.Table) +} + +// EqualsRefOfExplainStmt does deep equals. +func EqualsRefOfExplainStmt(a, b *ExplainStmt) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + EqualsStatement(a.Statement, b.Statement) +} + +// EqualsRefOfExplainTab does deep equals. +func EqualsRefOfExplainTab(a, b *ExplainTab) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Wild == b.Wild && + EqualsTableName(a.Table, b.Table) +} + +// EqualsRefOfAndExpr does deep equals. +func EqualsRefOfAndExpr(a, b *AndExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.Right, b.Right) +} + +// EqualsRefOfBinaryExpr does deep equals. +func EqualsRefOfBinaryExpr(a, b *BinaryExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Operator == b.Operator && + EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.Right, b.Right) +} + +// EqualsRefOfCaseExpr does deep equals. +func EqualsRefOfCaseExpr(a, b *CaseExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) && + EqualsSliceOfRefOfWhen(a.Whens, b.Whens) && + EqualsExpr(a.Else, b.Else) +} + +// EqualsRefOfColName does deep equals. +func EqualsRefOfColName(a, b *ColName) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) && + EqualsTableName(a.Qualifier, b.Qualifier) +} + +// EqualsRefOfCollateExpr does deep equals. +func EqualsRefOfCollateExpr(a, b *CollateExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Charset == b.Charset && + EqualsExpr(a.Expr, b.Expr) +} + +// EqualsRefOfComparisonExpr does deep equals. +func EqualsRefOfComparisonExpr(a, b *ComparisonExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Operator == b.Operator && + EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.Right, b.Right) && + EqualsExpr(a.Escape, b.Escape) +} + +// EqualsRefOfConvertExpr does deep equals. +func EqualsRefOfConvertExpr(a, b *ConvertExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) && + EqualsRefOfConvertType(a.Type, b.Type) +} + +// EqualsRefOfConvertUsingExpr does deep equals. +func EqualsRefOfConvertUsingExpr(a, b *ConvertUsingExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + EqualsExpr(a.Expr, b.Expr) +} + +// EqualsRefOfCurTimeFuncExpr does deep equals. +func EqualsRefOfCurTimeFuncExpr(a, b *CurTimeFuncExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) && + EqualsExpr(a.Fsp, b.Fsp) +} + +// EqualsRefOfDefault does deep equals. +func EqualsRefOfDefault(a, b *Default) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.ColName == b.ColName +} + +// EqualsRefOfExistsExpr does deep equals. +func EqualsRefOfExistsExpr(a, b *ExistsExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfSubquery(a.Subquery, b.Subquery) +} + +// EqualsRefOfFuncExpr does deep equals. +func EqualsRefOfFuncExpr(a, b *FuncExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Distinct == b.Distinct && + EqualsTableIdent(a.Qualifier, b.Qualifier) && + EqualsColIdent(a.Name, b.Name) && + EqualsSelectExprs(a.Exprs, b.Exprs) +} + +// EqualsRefOfGroupConcatExpr does deep equals. +func EqualsRefOfGroupConcatExpr(a, b *GroupConcatExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Distinct == b.Distinct && + a.Separator == b.Separator && + EqualsSelectExprs(a.Exprs, b.Exprs) && + EqualsOrderBy(a.OrderBy, b.OrderBy) && + EqualsRefOfLimit(a.Limit, b.Limit) +} + +// EqualsRefOfIntervalExpr does deep equals. +func EqualsRefOfIntervalExpr(a, b *IntervalExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Unit == b.Unit && + EqualsExpr(a.Expr, b.Expr) +} + +// EqualsRefOfIsExpr does deep equals. +func EqualsRefOfIsExpr(a, b *IsExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Operator == b.Operator && + EqualsExpr(a.Expr, b.Expr) +} + +// EqualsRefOfLiteral does deep equals. +func EqualsRefOfLiteral(a, b *Literal) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Val == b.Val && + a.Type == b.Type +} + +// EqualsRefOfMatchExpr does deep equals. +func EqualsRefOfMatchExpr(a, b *MatchExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSelectExprs(a.Columns, b.Columns) && + EqualsExpr(a.Expr, b.Expr) && + a.Option == b.Option +} + +// EqualsRefOfNotExpr does deep equals. +func EqualsRefOfNotExpr(a, b *NotExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) +} + +// EqualsRefOfNullVal does deep equals. +func EqualsRefOfNullVal(a, b *NullVal) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + +// EqualsRefOfOrExpr does deep equals. +func EqualsRefOfOrExpr(a, b *OrExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.Right, b.Right) +} + +// EqualsRefOfRangeCond does deep equals. +func EqualsRefOfRangeCond(a, b *RangeCond) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Operator == b.Operator && + EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.From, b.From) && + EqualsExpr(a.To, b.To) +} + +// EqualsRefOfSubstrExpr does deep equals. +func EqualsRefOfSubstrExpr(a, b *SubstrExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColName(a.Name, b.Name) && + EqualsRefOfLiteral(a.StrVal, b.StrVal) && + EqualsExpr(a.From, b.From) && + EqualsExpr(a.To, b.To) +} + +// EqualsRefOfTimestampFuncExpr does deep equals. +func EqualsRefOfTimestampFuncExpr(a, b *TimestampFuncExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Name == b.Name && + a.Unit == b.Unit && + EqualsExpr(a.Expr1, b.Expr1) && + EqualsExpr(a.Expr2, b.Expr2) +} + +// EqualsRefOfUnaryExpr does deep equals. +func EqualsRefOfUnaryExpr(a, b *UnaryExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Operator == b.Operator && + EqualsExpr(a.Expr, b.Expr) +} + +// EqualsRefOfValuesFuncExpr does deep equals. +func EqualsRefOfValuesFuncExpr(a, b *ValuesFuncExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColName(a.Name, b.Name) +} + +// EqualsRefOfXorExpr does deep equals. +func EqualsRefOfXorExpr(a, b *XorExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.Right, b.Right) +} + +// EqualsRefOfParenSelect does deep equals. +func EqualsRefOfParenSelect(a, b *ParenSelect) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSelectStatement(a.Select, b.Select) +} + +// EqualsRefOfSelect does deep equals. +func EqualsRefOfSelect(a, b *Select) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Distinct == b.Distinct && + a.StraightJoinHint == b.StraightJoinHint && + a.SQLCalcFoundRows == b.SQLCalcFoundRows && + EqualsRefOfBool(a.Cache, b.Cache) && + EqualsComments(a.Comments, b.Comments) && + EqualsSelectExprs(a.SelectExprs, b.SelectExprs) && + EqualsTableExprs(a.From, b.From) && + EqualsRefOfWhere(a.Where, b.Where) && + EqualsGroupBy(a.GroupBy, b.GroupBy) && + EqualsRefOfWhere(a.Having, b.Having) && + EqualsOrderBy(a.OrderBy, b.OrderBy) && + EqualsRefOfLimit(a.Limit, b.Limit) && + a.Lock == b.Lock && + EqualsRefOfSelectInto(a.Into, b.Into) +} + +// EqualsRefOfUnion does deep equals. +func EqualsRefOfUnion(a, b *Union) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSelectStatement(a.FirstStatement, b.FirstStatement) && + EqualsSliceOfRefOfUnionSelect(a.UnionSelects, b.UnionSelects) && + EqualsOrderBy(a.OrderBy, b.OrderBy) && + EqualsRefOfLimit(a.Limit, b.Limit) && + a.Lock == b.Lock +} + +// EqualsValues does deep equals. +func EqualsValues(a, b Values) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsValTuple(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfAliasedExpr does deep equals. +func EqualsRefOfAliasedExpr(a, b *AliasedExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) && + EqualsColIdent(a.As, b.As) +} + +// EqualsRefOfAliasedTableExpr does deep equals. +func EqualsRefOfAliasedTableExpr(a, b *AliasedTableExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSimpleTableExpr(a.Expr, b.Expr) && + EqualsPartitions(a.Partitions, b.Partitions) && + EqualsTableIdent(a.As, b.As) && + EqualsRefOfIndexHints(a.Hints, b.Hints) +} + +// EqualsRefOfAlterVschema does deep equals. +func EqualsRefOfAlterVschema(a, b *AlterVschema) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Action == b.Action && + EqualsTableName(a.Table, b.Table) && + EqualsRefOfVindexSpec(a.VindexSpec, b.VindexSpec) && + EqualsSliceOfColIdent(a.VindexCols, b.VindexCols) && + EqualsRefOfAutoIncSpec(a.AutoIncSpec, b.AutoIncSpec) +} + +// EqualsRefOfAutoIncSpec does deep equals. +func EqualsRefOfAutoIncSpec(a, b *AutoIncSpec) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Column, b.Column) && + EqualsTableName(a.Sequence, b.Sequence) +} + +// EqualsRefOfBegin does deep equals. +func EqualsRefOfBegin(a, b *Begin) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + +// EqualsRefOfCallProc does deep equals. +func EqualsRefOfCallProc(a, b *CallProc) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.Name, b.Name) && + EqualsExprs(a.Params, b.Params) +} + +// EqualsColIdent does deep equals. +func EqualsColIdent(a, b ColIdent) bool { + return a.val == b.val && + a.lowered == b.lowered && + a.at == b.at +} + +// EqualsRefOfColumnDefinition does deep equals. +func EqualsRefOfColumnDefinition(a, b *ColumnDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) && + EqualsColumnType(a.Type, b.Type) +} + +// EqualsRefOfColumnType does deep equals. +func EqualsRefOfColumnType(a, b *ColumnType) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + a.Unsigned == b.Unsigned && + a.Zerofill == b.Zerofill && + a.Charset == b.Charset && + a.Collate == b.Collate && + EqualsRefOfColumnTypeOptions(a.Options, b.Options) && + EqualsRefOfLiteral(a.Length, b.Length) && + EqualsRefOfLiteral(a.Scale, b.Scale) && + EqualsSliceOfString(a.EnumValues, b.EnumValues) +} + +// EqualsColumns does deep equals. +func EqualsColumns(a, b Columns) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsColIdent(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsComments does deep equals. +func EqualsComments(a, b Comments) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + return true +} + +// EqualsRefOfCommit does deep equals. +func EqualsRefOfCommit(a, b *Commit) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + +// EqualsRefOfConstraintDefinition does deep equals. +func EqualsRefOfConstraintDefinition(a, b *ConstraintDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Name == b.Name && + EqualsConstraintInfo(a.Details, b.Details) +} + +// EqualsRefOfConvertType does deep equals. +func EqualsRefOfConvertType(a, b *ConvertType) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + a.Charset == b.Charset && + EqualsRefOfLiteral(a.Length, b.Length) && + EqualsRefOfLiteral(a.Scale, b.Scale) && + a.Operator == b.Operator +} + +// EqualsRefOfDelete does deep equals. +func EqualsRefOfDelete(a, b *Delete) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Ignore == b.Ignore && + EqualsComments(a.Comments, b.Comments) && + EqualsTableNames(a.Targets, b.Targets) && + EqualsTableExprs(a.TableExprs, b.TableExprs) && + EqualsPartitions(a.Partitions, b.Partitions) && + EqualsRefOfWhere(a.Where, b.Where) && + EqualsOrderBy(a.OrderBy, b.OrderBy) && + EqualsRefOfLimit(a.Limit, b.Limit) +} + +// EqualsRefOfDerivedTable does deep equals. +func EqualsRefOfDerivedTable(a, b *DerivedTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSelectStatement(a.Select, b.Select) +} + +// EqualsExprs does deep equals. +func EqualsExprs(a, b Exprs) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsExpr(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfFlush does deep equals. +func EqualsRefOfFlush(a, b *Flush) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.IsLocal == b.IsLocal && + a.WithLock == b.WithLock && + a.ForExport == b.ForExport && + EqualsSliceOfString(a.FlushOptions, b.FlushOptions) && + EqualsTableNames(a.TableNames, b.TableNames) +} + +// EqualsGroupBy does deep equals. +func EqualsGroupBy(a, b GroupBy) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsExpr(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfIndexDefinition does deep equals. +func EqualsRefOfIndexDefinition(a, b *IndexDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfIndexInfo(a.Info, b.Info) && + EqualsSliceOfRefOfIndexColumn(a.Columns, b.Columns) && + EqualsSliceOfRefOfIndexOption(a.Options, b.Options) +} + +// EqualsRefOfIndexHints does deep equals. +func EqualsRefOfIndexHints(a, b *IndexHints) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + EqualsSliceOfColIdent(a.Indexes, b.Indexes) +} + +// EqualsRefOfIndexInfo does deep equals. +func EqualsRefOfIndexInfo(a, b *IndexInfo) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + a.Primary == b.Primary && + a.Spatial == b.Spatial && + a.Fulltext == b.Fulltext && + a.Unique == b.Unique && + EqualsColIdent(a.Name, b.Name) && + EqualsColIdent(a.ConstraintName, b.ConstraintName) +} + +// EqualsRefOfInsert does deep equals. +func EqualsRefOfInsert(a, b *Insert) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Action == b.Action && + EqualsComments(a.Comments, b.Comments) && + a.Ignore == b.Ignore && + EqualsTableName(a.Table, b.Table) && + EqualsPartitions(a.Partitions, b.Partitions) && + EqualsColumns(a.Columns, b.Columns) && + EqualsInsertRows(a.Rows, b.Rows) && + EqualsOnDup(a.OnDup, b.OnDup) +} + +// EqualsJoinCondition does deep equals. +func EqualsJoinCondition(a, b JoinCondition) bool { + return EqualsExpr(a.On, b.On) && + EqualsColumns(a.Using, b.Using) +} + +// EqualsRefOfJoinTableExpr does deep equals. +func EqualsRefOfJoinTableExpr(a, b *JoinTableExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableExpr(a.LeftExpr, b.LeftExpr) && + a.Join == b.Join && + EqualsTableExpr(a.RightExpr, b.RightExpr) && + EqualsJoinCondition(a.Condition, b.Condition) +} + +// EqualsRefOfLimit does deep equals. +func EqualsRefOfLimit(a, b *Limit) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Offset, b.Offset) && + EqualsExpr(a.Rowcount, b.Rowcount) +} + +// EqualsRefOfLoad does deep equals. +func EqualsRefOfLoad(a, b *Load) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + +// EqualsRefOfLockTables does deep equals. +func EqualsRefOfLockTables(a, b *LockTables) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableAndLockTypes(a.Tables, b.Tables) +} + +// EqualsRefOfNextval does deep equals. +func EqualsRefOfNextval(a, b *Nextval) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) +} + +// EqualsOnDup does deep equals. +func EqualsOnDup(a, b OnDup) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfUpdateExpr(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfOptLike does deep equals. +func EqualsRefOfOptLike(a, b *OptLike) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.LikeTable, b.LikeTable) +} + +// EqualsRefOfOrder does deep equals. +func EqualsRefOfOrder(a, b *Order) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) && + a.Direction == b.Direction +} + +// EqualsOrderBy does deep equals. +func EqualsOrderBy(a, b OrderBy) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfOrder(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfOtherAdmin does deep equals. +func EqualsRefOfOtherAdmin(a, b *OtherAdmin) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + +// EqualsRefOfOtherRead does deep equals. +func EqualsRefOfOtherRead(a, b *OtherRead) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + +// EqualsRefOfParenTableExpr does deep equals. +func EqualsRefOfParenTableExpr(a, b *ParenTableExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableExprs(a.Exprs, b.Exprs) +} + +// EqualsRefOfPartitionDefinition does deep equals. +func EqualsRefOfPartitionDefinition(a, b *PartitionDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Maxvalue == b.Maxvalue && + EqualsColIdent(a.Name, b.Name) && + EqualsExpr(a.Limit, b.Limit) +} + +// EqualsRefOfPartitionSpec does deep equals. +func EqualsRefOfPartitionSpec(a, b *PartitionSpec) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.IsAll == b.IsAll && + a.WithoutValidation == b.WithoutValidation && + a.Action == b.Action && + EqualsPartitions(a.Names, b.Names) && + EqualsRefOfLiteral(a.Number, b.Number) && + EqualsTableName(a.TableName, b.TableName) && + EqualsSliceOfRefOfPartitionDefinition(a.Definitions, b.Definitions) +} + +// EqualsPartitions does deep equals. +func EqualsPartitions(a, b Partitions) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsColIdent(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfRelease does deep equals. +func EqualsRefOfRelease(a, b *Release) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) +} + +// EqualsRefOfRollback does deep equals. +func EqualsRefOfRollback(a, b *Rollback) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + +// EqualsRefOfSRollback does deep equals. +func EqualsRefOfSRollback(a, b *SRollback) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) +} + +// EqualsRefOfSavepoint does deep equals. +func EqualsRefOfSavepoint(a, b *Savepoint) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) +} + +// EqualsSelectExprs does deep equals. +func EqualsSelectExprs(a, b SelectExprs) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsSelectExpr(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfSelectInto does deep equals. +func EqualsRefOfSelectInto(a, b *SelectInto) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.FileName == b.FileName && + a.Charset == b.Charset && + a.FormatOption == b.FormatOption && + a.ExportOption == b.ExportOption && + a.Manifest == b.Manifest && + a.Overwrite == b.Overwrite && + a.Type == b.Type +} + +// EqualsRefOfSet does deep equals. +func EqualsRefOfSet(a, b *Set) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsComments(a.Comments, b.Comments) && + EqualsSetExprs(a.Exprs, b.Exprs) +} + +// EqualsRefOfSetExpr does deep equals. +func EqualsRefOfSetExpr(a, b *SetExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Scope == b.Scope && + EqualsColIdent(a.Name, b.Name) && + EqualsExpr(a.Expr, b.Expr) +} + +// EqualsSetExprs does deep equals. +func EqualsSetExprs(a, b SetExprs) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfSetExpr(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfSetTransaction does deep equals. +func EqualsRefOfSetTransaction(a, b *SetTransaction) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSQLNode(a.SQLNode, b.SQLNode) && + EqualsComments(a.Comments, b.Comments) && + a.Scope == b.Scope && + EqualsSliceOfCharacteristic(a.Characteristics, b.Characteristics) +} + +// EqualsRefOfShow does deep equals. +func EqualsRefOfShow(a, b *Show) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsShowInternal(a.Internal, b.Internal) +} + +// EqualsRefOfShowBasic does deep equals. +func EqualsRefOfShowBasic(a, b *ShowBasic) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Full == b.Full && + a.DbName == b.DbName && + a.Command == b.Command && + EqualsTableName(a.Tbl, b.Tbl) && + EqualsRefOfShowFilter(a.Filter, b.Filter) +} + +// EqualsRefOfShowCreate does deep equals. +func EqualsRefOfShowCreate(a, b *ShowCreate) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Command == b.Command && + EqualsTableName(a.Op, b.Op) +} + +// EqualsRefOfShowFilter does deep equals. +func EqualsRefOfShowFilter(a, b *ShowFilter) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Like == b.Like && + EqualsExpr(a.Filter, b.Filter) +} + +// EqualsRefOfShowLegacy does deep equals. +func EqualsRefOfShowLegacy(a, b *ShowLegacy) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Extended == b.Extended && + a.Type == b.Type && + EqualsTableName(a.OnTable, b.OnTable) && + EqualsTableName(a.Table, b.Table) && + EqualsRefOfShowTablesOpt(a.ShowTablesOpt, b.ShowTablesOpt) && + a.Scope == b.Scope && + EqualsExpr(a.ShowCollationFilterOpt, b.ShowCollationFilterOpt) +} + +// EqualsRefOfStarExpr does deep equals. +func EqualsRefOfStarExpr(a, b *StarExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.TableName, b.TableName) +} + +// EqualsRefOfStream does deep equals. +func EqualsRefOfStream(a, b *Stream) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsComments(a.Comments, b.Comments) && + EqualsSelectExpr(a.SelectExpr, b.SelectExpr) && + EqualsTableName(a.Table, b.Table) +} + +// EqualsTableExprs does deep equals. +func EqualsTableExprs(a, b TableExprs) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsTableExpr(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsTableIdent does deep equals. +func EqualsTableIdent(a, b TableIdent) bool { + return a.v == b.v +} + +// EqualsTableName does deep equals. +func EqualsTableName(a, b TableName) bool { + return EqualsTableIdent(a.Name, b.Name) && + EqualsTableIdent(a.Qualifier, b.Qualifier) +} + +// EqualsTableNames does deep equals. +func EqualsTableNames(a, b TableNames) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsTableName(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfTableSpec does deep equals. +func EqualsRefOfTableSpec(a, b *TableSpec) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSliceOfRefOfColumnDefinition(a.Columns, b.Columns) && + EqualsSliceOfRefOfIndexDefinition(a.Indexes, b.Indexes) && + EqualsSliceOfRefOfConstraintDefinition(a.Constraints, b.Constraints) && + EqualsTableOptions(a.Options, b.Options) +} + +// EqualsRefOfUnionSelect does deep equals. +func EqualsRefOfUnionSelect(a, b *UnionSelect) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Distinct == b.Distinct && + EqualsSelectStatement(a.Statement, b.Statement) +} + +// EqualsRefOfUnlockTables does deep equals. +func EqualsRefOfUnlockTables(a, b *UnlockTables) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + +// EqualsRefOfUpdate does deep equals. +func EqualsRefOfUpdate(a, b *Update) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsComments(a.Comments, b.Comments) && + a.Ignore == b.Ignore && + EqualsTableExprs(a.TableExprs, b.TableExprs) && + EqualsUpdateExprs(a.Exprs, b.Exprs) && + EqualsRefOfWhere(a.Where, b.Where) && + EqualsOrderBy(a.OrderBy, b.OrderBy) && + EqualsRefOfLimit(a.Limit, b.Limit) +} + +// EqualsRefOfUpdateExpr does deep equals. +func EqualsRefOfUpdateExpr(a, b *UpdateExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColName(a.Name, b.Name) && + EqualsExpr(a.Expr, b.Expr) +} + +// EqualsUpdateExprs does deep equals. +func EqualsUpdateExprs(a, b UpdateExprs) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfUpdateExpr(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfUse does deep equals. +func EqualsRefOfUse(a, b *Use) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableIdent(a.DBName, b.DBName) +} + +// EqualsRefOfVStream does deep equals. +func EqualsRefOfVStream(a, b *VStream) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsComments(a.Comments, b.Comments) && + EqualsSelectExpr(a.SelectExpr, b.SelectExpr) && + EqualsTableName(a.Table, b.Table) && + EqualsRefOfWhere(a.Where, b.Where) && + EqualsRefOfLimit(a.Limit, b.Limit) +} + +// EqualsVindexParam does deep equals. +func EqualsVindexParam(a, b VindexParam) bool { + return a.Val == b.Val && + EqualsColIdent(a.Key, b.Key) +} + +// EqualsRefOfVindexSpec does deep equals. +func EqualsRefOfVindexSpec(a, b *VindexSpec) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) && + EqualsColIdent(a.Type, b.Type) && + EqualsSliceOfVindexParam(a.Params, b.Params) +} + +// EqualsRefOfWhen does deep equals. +func EqualsRefOfWhen(a, b *When) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Cond, b.Cond) && + EqualsExpr(a.Val, b.Val) +} + +// EqualsRefOfWhere does deep equals. +func EqualsRefOfWhere(a, b *Where) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + EqualsExpr(a.Expr, b.Expr) +} + +// EqualsSliceOfRefOfColumnDefinition does deep equals. +func EqualsSliceOfRefOfColumnDefinition(a, b []*ColumnDefinition) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfColumnDefinition(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfTableOption does deep equals. +func EqualsRefOfTableOption(a, b *TableOption) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Name == b.Name && + a.String == b.String && + EqualsRefOfLiteral(a.Value, b.Value) && + EqualsTableNames(a.Tables, b.Tables) +} + +// EqualsSliceOfCollateAndCharset does deep equals. +func EqualsSliceOfCollateAndCharset(a, b []CollateAndCharset) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsCollateAndCharset(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsSliceOfAlterOption does deep equals. +func EqualsSliceOfAlterOption(a, b []AlterOption) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsAlterOption(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsSliceOfRefOfRenameTablePair does deep equals. +func EqualsSliceOfRefOfRenameTablePair(a, b []*RenameTablePair) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfRenameTablePair(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsSliceOfRefOfWhen does deep equals. +func EqualsSliceOfRefOfWhen(a, b []*When) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfWhen(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfBool does deep equals. +func EqualsRefOfBool(a, b *bool) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return *a == *b +} + +// EqualsSliceOfRefOfUnionSelect does deep equals. +func EqualsSliceOfRefOfUnionSelect(a, b []*UnionSelect) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfUnionSelect(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsSliceOfColIdent does deep equals. +func EqualsSliceOfColIdent(a, b []ColIdent) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsColIdent(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsColumnType does deep equals. +func EqualsColumnType(a, b ColumnType) bool { + return a.Type == b.Type && + a.Unsigned == b.Unsigned && + a.Zerofill == b.Zerofill && + a.Charset == b.Charset && + a.Collate == b.Collate && + EqualsRefOfColumnTypeOptions(a.Options, b.Options) && + EqualsRefOfLiteral(a.Length, b.Length) && + EqualsRefOfLiteral(a.Scale, b.Scale) && + EqualsSliceOfString(a.EnumValues, b.EnumValues) +} + +// EqualsRefOfColumnTypeOptions does deep equals. +func EqualsRefOfColumnTypeOptions(a, b *ColumnTypeOptions) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.NotNull == b.NotNull && + a.Autoincrement == b.Autoincrement && + EqualsExpr(a.Default, b.Default) && + EqualsExpr(a.OnUpdate, b.OnUpdate) && + EqualsRefOfLiteral(a.Comment, b.Comment) && + a.KeyOpt == b.KeyOpt +} + +// EqualsSliceOfString does deep equals. +func EqualsSliceOfString(a, b []string) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + return true +} + +// EqualsSliceOfRefOfIndexColumn does deep equals. +func EqualsSliceOfRefOfIndexColumn(a, b []*IndexColumn) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfIndexColumn(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsSliceOfRefOfIndexOption does deep equals. +func EqualsSliceOfRefOfIndexOption(a, b []*IndexOption) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfIndexOption(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsTableAndLockTypes does deep equals. +func EqualsTableAndLockTypes(a, b TableAndLockTypes) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfTableAndLockType(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsSliceOfRefOfPartitionDefinition does deep equals. +func EqualsSliceOfRefOfPartitionDefinition(a, b []*PartitionDefinition) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfPartitionDefinition(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsSliceOfCharacteristic does deep equals. +func EqualsSliceOfCharacteristic(a, b []Characteristic) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsCharacteristic(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfShowTablesOpt does deep equals. +func EqualsRefOfShowTablesOpt(a, b *ShowTablesOpt) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Full == b.Full && + a.DbName == b.DbName && + EqualsRefOfShowFilter(a.Filter, b.Filter) +} + +// EqualsSliceOfRefOfIndexDefinition does deep equals. +func EqualsSliceOfRefOfIndexDefinition(a, b []*IndexDefinition) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfIndexDefinition(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsSliceOfRefOfConstraintDefinition does deep equals. +func EqualsSliceOfRefOfConstraintDefinition(a, b []*ConstraintDefinition) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfConstraintDefinition(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsSliceOfVindexParam does deep equals. +func EqualsSliceOfVindexParam(a, b []VindexParam) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsVindexParam(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsCollateAndCharset does deep equals. +func EqualsCollateAndCharset(a, b CollateAndCharset) bool { + return a.IsDefault == b.IsDefault && + a.Value == b.Value && + a.Type == b.Type +} + +// EqualsRefOfRenameTablePair does deep equals. +func EqualsRefOfRenameTablePair(a, b *RenameTablePair) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.FromTable, b.FromTable) && + EqualsTableName(a.ToTable, b.ToTable) +} + +// EqualsRefOfIndexColumn does deep equals. +func EqualsRefOfIndexColumn(a, b *IndexColumn) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Column, b.Column) && + EqualsRefOfLiteral(a.Length, b.Length) && + a.Direction == b.Direction +} + +// EqualsRefOfIndexOption does deep equals. +func EqualsRefOfIndexOption(a, b *IndexOption) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Name == b.Name && + a.String == b.String && + EqualsRefOfLiteral(a.Value, b.Value) +} + +// EqualsRefOfTableAndLockType does deep equals. +func EqualsRefOfTableAndLockType(a, b *TableAndLockType) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableExpr(a.Table, b.Table) && + a.Lock == b.Lock +} From 3f7ff4a741539ef3d43dd7ffab59af49309dde3e Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Sat, 13 Mar 2021 07:28:47 +0100 Subject: [PATCH 11/13] regenerate the test asthelpers Signed-off-by: Andres Taylor --- go/tools/asthelpergen/integration/clone.go | 6 +----- go/tools/asthelpergen/integration/types.go | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/go/tools/asthelpergen/integration/clone.go b/go/tools/asthelpergen/integration/clone.go index 14254598dcd..2e7be6acc6c 100644 --- a/go/tools/asthelpergen/integration/clone.go +++ b/go/tools/asthelpergen/integration/clone.go @@ -108,11 +108,7 @@ func CloneLeafSlice(n LeafSlice) LeafSlice { // CloneRefOfNoCloneType creates a deep clone of the input. func CloneRefOfNoCloneType(n *NoCloneType) *NoCloneType { - if n == nil { - return nil - } - out := *n - return &out + return n } // CloneRefOfRefContainer creates a deep clone of the input. diff --git a/go/tools/asthelpergen/integration/types.go b/go/tools/asthelpergen/integration/types.go index 5d902873c05..043c97d87aa 100644 --- a/go/tools/asthelpergen/integration/types.go +++ b/go/tools/asthelpergen/integration/types.go @@ -26,7 +26,7 @@ import ( These types are used to test the rewriter generator against these types. To recreate them, just run: -go run go/tools/asthelpergen -in ./go/tools/asthelpergen/integration -iface vitess.io/vitess/go/tools/asthelpergen/integration.AST +go run go/tools/asthelpergen -in ./go/tools/asthelpergen/integration -iface vitess.io/vitess/go/tools/asthelpergen/integration.AST -except "*NoCloneType" */ // AST is the interface all interface types implement type AST interface { From a937d27f7c890cf5a57521e6297e8bcbefabdced Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Sat, 13 Mar 2021 07:47:45 +0100 Subject: [PATCH 12/13] unify clone_gen and equals_gen Signed-off-by: Andres Taylor --- go/tools/asthelpergen/asthelpergen.go | 3 +- go/tools/asthelpergen/clone_gen.go | 45 +- go/tools/asthelpergen/equals_gen.go | 167 +- go/tools/asthelpergen/integration/clone.go | 313 ++ go/tools/asthelpergen/integration/equals.go | 294 -- go/vt/sqlparser/clone.go | 4025 ++++++++++++++++++- go/vt/sqlparser/equals.go | 3956 ------------------ 7 files changed, 4381 insertions(+), 4422 deletions(-) delete mode 100644 go/tools/asthelpergen/integration/equals.go delete mode 100644 go/vt/sqlparser/equals.go diff --git a/go/tools/asthelpergen/asthelpergen.go b/go/tools/asthelpergen/asthelpergen.go index 3f66298d72d..f052d1579a4 100644 --- a/go/tools/asthelpergen/asthelpergen.go +++ b/go/tools/asthelpergen/asthelpergen.go @@ -248,9 +248,8 @@ func GenerateASTHelpers(packagePatterns []string, rootIface, exceptCloneType str } rewriter := newRewriterGen(interestingType, nt.Obj().Name()) clone := newCloneGen(iface, scope, exceptCloneType) - equals := newEqualsGen(scope) - generator := newGenerator(loaded[0].Module, loaded[0].TypesSizes, nt, rewriter, clone, equals) + generator := newGenerator(loaded[0].Module, loaded[0].TypesSizes, nt, rewriter, clone) it, err := generator.GenerateCode() if err != nil { return nil, err diff --git a/go/tools/asthelpergen/clone_gen.go b/go/tools/asthelpergen/clone_gen.go index f2930edbd5a..771d6ad0d8b 100644 --- a/go/tools/asthelpergen/clone_gen.go +++ b/go/tools/asthelpergen/clone_gen.go @@ -184,7 +184,7 @@ func (c *cloneGen) makeInterfaceCloneMethod(t types.Type, iface *types.Interface return nil } -func (c *cloneGen) makePtrCloneMethod(t types.Type, ptr *types.Pointer) error { +func (c *cloneGen) makePtrCloneMethod(t types.Type, ptr *types.Pointer) { receiveType := types.TypeString(t, noQualifier) funcName := "Clone" + printableTypeName(t) @@ -194,8 +194,6 @@ func (c *cloneGen) makePtrCloneMethod(t types.Type, ptr *types.Pointer) error { jen.Id("out").Op(":=").Add(c.readValueOfType(ptr.Elem(), jen.Op("*").Id("n"))), jen.Return(jen.Op("&").Id("out")), )) - - return nil } func (c *cloneGen) createFile(pkgName string) (string, *jen.File) { @@ -241,13 +239,15 @@ func isBasic(t types.Type) bool { } func (c *cloneGen) tryStruct(underlying, t types.Type) bool { - _, ok := underlying.(*types.Struct) + strct, ok := underlying.(*types.Struct) if !ok { return false } - err := c.makeStructCloneMethod(t) - if err != nil { + if err := c.makeStructCloneMethod(t); err != nil { + log.Fatalf("%v", err) + } + if err := c.makeStructEqualsMethod(t, strct); err != nil { log.Fatalf("%v", err) } return true @@ -258,15 +258,21 @@ func (c *cloneGen) tryPtr(underlying, t types.Type) bool { return false } - if strct, isStruct := ptr.Elem().Underlying().(*types.Struct); isStruct { - c.makePtrToStructCloneMethod(t, strct) + ptrToType := ptr.Elem().Underlying() + + switch ptrToType := ptrToType.(type) { + case *types.Struct: + c.makePtrToStructCloneMethod(t, ptrToType) + c.makePtrToStructEqualsMethod(t, ptrToType) + return true + case *types.Basic: + c.makePtrToBasicEqualsMethod(t) + c.makePtrCloneMethod(t, ptr) return true + default: + c.makePtrCloneMethod(t, ptr) } - err := c.makePtrCloneMethod(t, ptr) - if err != nil { - panic(err) // todo - } return true } @@ -321,9 +327,12 @@ func (c *cloneGen) tryInterface(underlying, t types.Type) bool { return false } - err := c.makeInterfaceCloneMethod(t, iface) - if err != nil { - panic(err) // todo + if err := c.makeInterfaceCloneMethod(t, iface); err != nil { + log.Fatalf("%v", err) + } + + if err := c.makeInterfaceEqualsMethod(t, iface); err != nil { + log.Fatalf("%v", err) } return true } @@ -334,8 +343,10 @@ func (c *cloneGen) trySlice(underlying, t types.Type) bool { return false } - err := c.makeSliceCloneMethod(t, slice) - if err != nil { + if err := c.makeSliceCloneMethod(t, slice); err != nil { + log.Fatalf("%v", err) + } + if err := c.makeSliceEqualsMethod(t, slice); err != nil { log.Fatalf("%v", err) } return true diff --git a/go/tools/asthelpergen/equals_gen.go b/go/tools/asthelpergen/equals_gen.go index a7d6fbb1dab..341528752ec 100644 --- a/go/tools/asthelpergen/equals_gen.go +++ b/go/tools/asthelpergen/equals_gen.go @@ -2,88 +2,13 @@ package asthelpergen import ( "go/types" - "log" "github.com/dave/jennifer/jen" ) -type equalsGen struct { - todo []types.Type - methods []jen.Code - scope *types.Scope -} - -var _ generator = (*equalsGen)(nil) - -func newEqualsGen(scope *types.Scope) *equalsGen { - return &equalsGen{ - scope: scope, - } -} - -func (e *equalsGen) visitStruct(t types.Type, stroct *types.Struct) error { - return nil -} - -func (e *equalsGen) visitSlice(t types.Type, slice *types.Slice) error { - return nil -} - -func (e *equalsGen) visitInterface(t types.Type, iface *types.Interface) error { - e.todo = append(e.todo, t) - return nil -} - -func (e *equalsGen) createFile(pkgName string) (string, *jen.File) { - out := jen.NewFile(pkgName) - out.HeaderComment(licenseFileHeader) - out.HeaderComment("Code generated by ASTHelperGen. DO NOT EDIT.") - - alreadyDone := map[string]bool{} - for len(e.todo) > 0 { - t := e.todo[0] - underlying := t.Underlying() - typeName := printableTypeName(t) - e.todo = e.todo[1:] - - if alreadyDone[typeName] { - continue - } - - if e.tryInterface(underlying, t) || - e.tryStruct(underlying, t) || - e.trySlice(underlying, t) || - e.tryPtr(underlying, t) { - alreadyDone[typeName] = true - continue - } - - log.Printf("don't know how to handle %s %T", typeName, underlying) - } - - for _, method := range e.methods { - out.Add(method) - } - - return "equals.go", out -} - -func (e *equalsGen) tryInterface(underlying, t types.Type) bool { - iface, ok := underlying.(*types.Interface) - if !ok { - return false - } - - err := e.makeInterfaceEqualsMethod(t, iface) - if err != nil { - log.Fatalf("%v", err) - } - return true -} - const equalsName = "Equals" -func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interface) error { +func (c *cloneGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interface) error { /* func EqualsAST(inA, inB AST) bool { @@ -110,7 +35,7 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa } var cases []jen.Code - _ = findImplementations(e.scope, iface, func(t types.Type) error { + _ = findImplementations(c.scope, iface, func(t types.Type) error { if _, ok := t.Underlying().(*types.Interface); ok { return nil } @@ -118,7 +43,7 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa caseBlock := jen.Case(jen.Id(typeString)).Block( jen.Id("b, ok := inB.").Call(jen.Id(typeString)), jen.If(jen.Id("!ok")).Block(jen.Return(jen.False())), - jen.Return(e.compareValueType(t, jen.Id("a"), jen.Id("b"), true)), + jen.Return(c.compareValueType(t, jen.Id("a"), jen.Id("b"), true)), ) cases = append(cases, caseBlock) return nil @@ -137,12 +62,12 @@ func (e *equalsGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfa typeString := types.TypeString(t, noQualifier) funcName := equalsName + printableTypeName(t) funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("inA"), jen.Id("inB")).Id(typeString)).Bool().Block(stmts...) - e.addFunc(funcName, funcDecl) + c.addFunc(funcName, funcDecl) return nil } -func (e *equalsGen) compareValueType(t types.Type, a, b *jen.Statement, eq bool) *jen.Statement { +func (c *cloneGen) compareValueType(t types.Type, a, b *jen.Statement, eq bool) *jen.Statement { switch t.Underlying().(type) { case *types.Basic: if eq { @@ -151,7 +76,7 @@ func (e *equalsGen) compareValueType(t types.Type, a, b *jen.Statement, eq bool) return a.Op("!=").Add(b) } - e.todo = append(e.todo, t) + c.todo = append(c.todo, t) var neg = "!" if eq { neg = "" @@ -159,24 +84,7 @@ func (e *equalsGen) compareValueType(t types.Type, a, b *jen.Statement, eq bool) return jen.Id(neg+equalsName+printableTypeName(t)).Call(a, b) } -func (e *equalsGen) addFunc(name string, code jen.Code) { - e.methods = append(e.methods, jen.Comment(name+" does deep equals."), code) -} - -func (e *equalsGen) tryStruct(underlying, t types.Type) bool { - stroct, ok := underlying.(*types.Struct) - if !ok { - return false - } - - err := e.makeStructEqualsMethod(t, stroct) - if err != nil { - log.Fatalf("%v", err) - } - return true -} - -func (e *equalsGen) makeStructEqualsMethod(t types.Type, stroct *types.Struct) error { +func (c *cloneGen) makeStructEqualsMethod(t types.Type, strct *types.Struct) error { /* func EqualsRefOfRefContainer(inA RefContainer, inB RefContainer) bool { return EqualsRefOfLeaf(inA.ASTImplementationType, inB.ASTImplementationType) && @@ -188,24 +96,24 @@ func (e *equalsGen) makeStructEqualsMethod(t types.Type, stroct *types.Struct) e typeString := types.TypeString(t, noQualifier) funcName := equalsName + printableTypeName(t) funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("a"), jen.Id("b")).Id(typeString)).Bool(). - Block(jen.Return(e.compareAllStructFields(stroct))) - e.addFunc(funcName, funcDecl) + Block(jen.Return(c.compareAllStructFields(strct))) + c.addFunc(funcName, funcDecl) return nil } -func (e *equalsGen) compareAllStructFields(stroct *types.Struct) jen.Code { +func (c *cloneGen) compareAllStructFields(strct *types.Struct) jen.Code { var basicsPred []*jen.Statement var others []*jen.Statement - for i := 0; i < stroct.NumFields(); i++ { - field := stroct.Field(i) + for i := 0; i < strct.NumFields(); i++ { + field := strct.Field(i) if field.Type().Underlying().String() == "interface{}" || field.Name() == "_" { // we can safely ignore this, we do not want ast to contain interface{} types. continue } fieldA := jen.Id("a").Dot(field.Name()) fieldB := jen.Id("b").Dot(field.Name()) - pred := e.compareValueType(field.Type(), fieldA, fieldB, true) + pred := c.compareValueType(field.Type(), fieldA, fieldB, true) if _, ok := field.Type().(*types.Basic); ok { basicsPred = append(basicsPred, pred) continue @@ -236,27 +144,7 @@ func (e *equalsGen) compareAllStructFields(stroct *types.Struct) jen.Code { return ret } -func (e *equalsGen) tryPtr(underlying, t types.Type) bool { - ptr, ok := underlying.(*types.Pointer) - if !ok { - return false - } - - ptrToType := ptr.Elem().Underlying() - - switch ptrToType := ptrToType.(type) { - case *types.Struct: - e.makePtrToStructEqualsMethod(t, ptrToType) - return true - case *types.Basic: - e.makePtrToBasicEqualsMethod(t) - return true - } - - return false -} - -func (e *equalsGen) makePtrToStructEqualsMethod(t types.Type, strct *types.Struct) { +func (c *cloneGen) makePtrToStructEqualsMethod(t types.Type, strct *types.Struct) { typeString := types.TypeString(t, noQualifier) funcName := equalsName + printableTypeName(t) @@ -265,12 +153,12 @@ func (e *equalsGen) makePtrToStructEqualsMethod(t types.Type, strct *types.Struc stmts := []jen.Code{ jen.If(jen.Id("a == b")).Block(jen.Return(jen.True())), jen.If(jen.Id("a == nil").Op("||").Id("b == nil")).Block(jen.Return(jen.False())), - jen.Return(e.compareAllStructFields(strct)), + jen.Return(c.compareAllStructFields(strct)), } - e.addFunc(funcName, funcDeclaration.Block(stmts...)) + c.addFunc(funcName, funcDeclaration.Block(stmts...)) } -func (e *equalsGen) makePtrToBasicEqualsMethod(t types.Type) { +func (c *cloneGen) makePtrToBasicEqualsMethod(t types.Type) { /* func EqualsRefOfBool(a, b *bool) bool { if a == b { @@ -292,23 +180,10 @@ func (e *equalsGen) makePtrToBasicEqualsMethod(t types.Type) { jen.If(jen.Id("a == nil").Op("||").Id("b == nil")).Block(jen.Return(jen.False())), jen.Return(jen.Id("*a == *b")), } - e.addFunc(funcName, funcDeclaration.Block(stmts...)) -} - -func (e *equalsGen) trySlice(underlying, t types.Type) bool { - slice, ok := underlying.(*types.Slice) - if !ok { - return false - } - - err := e.makeSliceEqualsMethod(t, slice) - if err != nil { - log.Fatalf("%v", err) - } - return true + c.addFunc(funcName, funcDeclaration.Block(stmts...)) } -func (e *equalsGen) makeSliceEqualsMethod(t types.Type, slice *types.Slice) error { +func (c *cloneGen) makeSliceEqualsMethod(t types.Type, slice *types.Slice) error { /* func EqualsSliceOfRefOfLeaf(a, b []*Leaf) bool { if len(a) != len(b) { @@ -325,13 +200,13 @@ func (e *equalsGen) makeSliceEqualsMethod(t types.Type, slice *types.Slice) erro stmts := []jen.Code{jen.If(jen.Id("len(a) != len(b)")).Block(jen.Return(jen.False())), jen.For(jen.Id("i := 0; i < len(a); i++")).Block( - jen.If(e.compareValueType(slice.Elem(), jen.Id("a[i]"), jen.Id("b[i]"), false)).Block(jen.Return(jen.False()))), + jen.If(c.compareValueType(slice.Elem(), jen.Id("a[i]"), jen.Id("b[i]"), false)).Block(jen.Return(jen.False()))), jen.Return(jen.True()), } typeString := types.TypeString(t, noQualifier) funcName := equalsName + printableTypeName(t) funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("a"), jen.Id("b")).Id(typeString)).Bool().Block(stmts...) - e.addFunc(funcName, funcDecl) + c.addFunc(funcName, funcDecl) return nil } diff --git a/go/tools/asthelpergen/integration/clone.go b/go/tools/asthelpergen/integration/clone.go index 2e7be6acc6c..df3a2376dfc 100644 --- a/go/tools/asthelpergen/integration/clone.go +++ b/go/tools/asthelpergen/integration/clone.go @@ -53,6 +53,93 @@ func CloneAST(in AST) AST { } } +// EqualsAST creates a deep clone of the input. +func EqualsAST(inA, inB AST) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case BasicType: + b, ok := inB.(BasicType) + if !ok { + return false + } + return a == b + case Bytes: + b, ok := inB.(Bytes) + if !ok { + return false + } + return EqualsBytes(a, b) + case InterfaceContainer: + b, ok := inB.(InterfaceContainer) + if !ok { + return false + } + return EqualsInterfaceContainer(a, b) + case InterfaceSlice: + b, ok := inB.(InterfaceSlice) + if !ok { + return false + } + return EqualsInterfaceSlice(a, b) + case *Leaf: + b, ok := inB.(*Leaf) + if !ok { + return false + } + return EqualsRefOfLeaf(a, b) + case LeafSlice: + b, ok := inB.(LeafSlice) + if !ok { + return false + } + return EqualsLeafSlice(a, b) + case *NoCloneType: + b, ok := inB.(*NoCloneType) + if !ok { + return false + } + return EqualsRefOfNoCloneType(a, b) + case *RefContainer: + b, ok := inB.(*RefContainer) + if !ok { + return false + } + return EqualsRefOfRefContainer(a, b) + case *RefSliceContainer: + b, ok := inB.(*RefSliceContainer) + if !ok { + return false + } + return EqualsRefOfRefSliceContainer(a, b) + case *SubImpl: + b, ok := inB.(*SubImpl) + if !ok { + return false + } + return EqualsRefOfSubImpl(a, b) + case ValueContainer: + b, ok := inB.(ValueContainer) + if !ok { + return false + } + return EqualsValueContainer(a, b) + case ValueSliceContainer: + b, ok := inB.(ValueSliceContainer) + if !ok { + return false + } + return EqualsValueSliceContainer(a, b) + default: + // this should never happen + return false + } +} + // CloneSubIface creates a deep clone of the input. func CloneSubIface(in SubIface) SubIface { if in == nil { @@ -67,6 +154,27 @@ func CloneSubIface(in SubIface) SubIface { } } +// EqualsSubIface creates a deep clone of the input. +func EqualsSubIface(inA, inB SubIface) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *SubImpl: + b, ok := inB.(*SubImpl) + if !ok { + return false + } + return EqualsRefOfSubImpl(a, b) + default: + // this should never happen + return false + } +} + // CloneBytes creates a deep clone of the input. func CloneBytes(n Bytes) Bytes { res := make(Bytes, 0, len(n)) @@ -74,11 +182,29 @@ func CloneBytes(n Bytes) Bytes { return res } +// EqualsBytes creates a deep clone of the input. +func EqualsBytes(a, b Bytes) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + return true +} + // CloneInterfaceContainer creates a deep clone of the input. func CloneInterfaceContainer(n InterfaceContainer) InterfaceContainer { return *CloneRefOfInterfaceContainer(&n) } +// EqualsInterfaceContainer creates a deep clone of the input. +func EqualsInterfaceContainer(a, b InterfaceContainer) bool { + return true +} + // CloneInterfaceSlice creates a deep clone of the input. func CloneInterfaceSlice(n InterfaceSlice) InterfaceSlice { res := make(InterfaceSlice, 0, len(n)) @@ -88,6 +214,19 @@ func CloneInterfaceSlice(n InterfaceSlice) InterfaceSlice { return res } +// EqualsInterfaceSlice creates a deep clone of the input. +func EqualsInterfaceSlice(a, b InterfaceSlice) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsAST(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfLeaf creates a deep clone of the input. func CloneRefOfLeaf(n *Leaf) *Leaf { if n == nil { @@ -97,6 +236,17 @@ func CloneRefOfLeaf(n *Leaf) *Leaf { return &out } +// EqualsRefOfLeaf creates a deep clone of the input. +func EqualsRefOfLeaf(a, b *Leaf) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.v == b.v +} + // CloneLeafSlice creates a deep clone of the input. func CloneLeafSlice(n LeafSlice) LeafSlice { res := make(LeafSlice, 0, len(n)) @@ -106,11 +256,35 @@ func CloneLeafSlice(n LeafSlice) LeafSlice { return res } +// EqualsLeafSlice creates a deep clone of the input. +func EqualsLeafSlice(a, b LeafSlice) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfLeaf(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfNoCloneType creates a deep clone of the input. func CloneRefOfNoCloneType(n *NoCloneType) *NoCloneType { return n } +// EqualsRefOfNoCloneType creates a deep clone of the input. +func EqualsRefOfNoCloneType(a, b *NoCloneType) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.v == b.v +} + // CloneRefOfRefContainer creates a deep clone of the input. func CloneRefOfRefContainer(n *RefContainer) *RefContainer { if n == nil { @@ -122,6 +296,19 @@ func CloneRefOfRefContainer(n *RefContainer) *RefContainer { return &out } +// EqualsRefOfRefContainer creates a deep clone of the input. +func EqualsRefOfRefContainer(a, b *RefContainer) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.NotASTType == b.NotASTType && + EqualsAST(a.ASTType, b.ASTType) && + EqualsRefOfLeaf(a.ASTImplementationType, b.ASTImplementationType) +} + // CloneRefOfRefSliceContainer creates a deep clone of the input. func CloneRefOfRefSliceContainer(n *RefSliceContainer) *RefSliceContainer { if n == nil { @@ -134,6 +321,19 @@ func CloneRefOfRefSliceContainer(n *RefSliceContainer) *RefSliceContainer { return &out } +// EqualsRefOfRefSliceContainer creates a deep clone of the input. +func EqualsRefOfRefSliceContainer(a, b *RefSliceContainer) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSliceOfAST(a.ASTElements, b.ASTElements) && + EqualsSliceOfInt(a.NotASTElements, b.NotASTElements) && + EqualsSliceOfRefOfLeaf(a.ASTImplementationElements, b.ASTImplementationElements) +} + // CloneRefOfSubImpl creates a deep clone of the input. func CloneRefOfSubImpl(n *SubImpl) *SubImpl { if n == nil { @@ -145,16 +345,42 @@ func CloneRefOfSubImpl(n *SubImpl) *SubImpl { return &out } +// EqualsRefOfSubImpl creates a deep clone of the input. +func EqualsRefOfSubImpl(a, b *SubImpl) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSubIface(a.inner, b.inner) && + EqualsRefOfBool(a.field, b.field) +} + // CloneValueContainer creates a deep clone of the input. func CloneValueContainer(n ValueContainer) ValueContainer { return *CloneRefOfValueContainer(&n) } +// EqualsValueContainer creates a deep clone of the input. +func EqualsValueContainer(a, b ValueContainer) bool { + return a.NotASTType == b.NotASTType && + EqualsAST(a.ASTType, b.ASTType) && + EqualsRefOfLeaf(a.ASTImplementationType, b.ASTImplementationType) +} + // CloneValueSliceContainer creates a deep clone of the input. func CloneValueSliceContainer(n ValueSliceContainer) ValueSliceContainer { return *CloneRefOfValueSliceContainer(&n) } +// EqualsValueSliceContainer creates a deep clone of the input. +func EqualsValueSliceContainer(a, b ValueSliceContainer) bool { + return EqualsSliceOfAST(a.ASTElements, b.ASTElements) && + EqualsSliceOfInt(a.NotASTElements, b.NotASTElements) && + EqualsSliceOfRefOfLeaf(a.ASTImplementationElements, b.ASTImplementationElements) +} + // CloneRefOfInterfaceContainer creates a deep clone of the input. func CloneRefOfInterfaceContainer(n *InterfaceContainer) *InterfaceContainer { if n == nil { @@ -165,6 +391,17 @@ func CloneRefOfInterfaceContainer(n *InterfaceContainer) *InterfaceContainer { return &out } +// EqualsRefOfInterfaceContainer creates a deep clone of the input. +func EqualsRefOfInterfaceContainer(a, b *InterfaceContainer) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + // CloneSliceOfAST creates a deep clone of the input. func CloneSliceOfAST(n []AST) []AST { res := make([]AST, 0, len(n)) @@ -174,6 +411,19 @@ func CloneSliceOfAST(n []AST) []AST { return res } +// EqualsSliceOfAST creates a deep clone of the input. +func EqualsSliceOfAST(a, b []AST) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsAST(a[i], b[i]) { + return false + } + } + return true +} + // CloneSliceOfInt creates a deep clone of the input. func CloneSliceOfInt(n []int) []int { res := make([]int, 0, len(n)) @@ -181,6 +431,19 @@ func CloneSliceOfInt(n []int) []int { return res } +// EqualsSliceOfInt creates a deep clone of the input. +func EqualsSliceOfInt(a, b []int) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + return true +} + // CloneSliceOfRefOfLeaf creates a deep clone of the input. func CloneSliceOfRefOfLeaf(n []*Leaf) []*Leaf { res := make([]*Leaf, 0, len(n)) @@ -190,6 +453,30 @@ func CloneSliceOfRefOfLeaf(n []*Leaf) []*Leaf { return res } +// EqualsSliceOfRefOfLeaf creates a deep clone of the input. +func EqualsSliceOfRefOfLeaf(a, b []*Leaf) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfLeaf(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfBool creates a deep clone of the input. +func EqualsRefOfBool(a, b *bool) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return *a == *b +} + // CloneRefOfBool creates a deep clone of the input. func CloneRefOfBool(n *bool) *bool { if n == nil { @@ -210,6 +497,19 @@ func CloneRefOfValueContainer(n *ValueContainer) *ValueContainer { return &out } +// EqualsRefOfValueContainer creates a deep clone of the input. +func EqualsRefOfValueContainer(a, b *ValueContainer) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.NotASTType == b.NotASTType && + EqualsAST(a.ASTType, b.ASTType) && + EqualsRefOfLeaf(a.ASTImplementationType, b.ASTImplementationType) +} + // CloneRefOfValueSliceContainer creates a deep clone of the input. func CloneRefOfValueSliceContainer(n *ValueSliceContainer) *ValueSliceContainer { if n == nil { @@ -221,3 +521,16 @@ func CloneRefOfValueSliceContainer(n *ValueSliceContainer) *ValueSliceContainer out.ASTImplementationElements = CloneSliceOfRefOfLeaf(n.ASTImplementationElements) return &out } + +// EqualsRefOfValueSliceContainer creates a deep clone of the input. +func EqualsRefOfValueSliceContainer(a, b *ValueSliceContainer) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSliceOfAST(a.ASTElements, b.ASTElements) && + EqualsSliceOfInt(a.NotASTElements, b.NotASTElements) && + EqualsSliceOfRefOfLeaf(a.ASTImplementationElements, b.ASTImplementationElements) +} diff --git a/go/tools/asthelpergen/integration/equals.go b/go/tools/asthelpergen/integration/equals.go deleted file mode 100644 index be4ef803ef4..00000000000 --- a/go/tools/asthelpergen/integration/equals.go +++ /dev/null @@ -1,294 +0,0 @@ -/* -Copyright 2021 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. -*/ -// Code generated by ASTHelperGen. DO NOT EDIT. - -package integration - -// EqualsAST does deep equals. -func EqualsAST(inA, inB AST) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case BasicType: - b, ok := inB.(BasicType) - if !ok { - return false - } - return a == b - case Bytes: - b, ok := inB.(Bytes) - if !ok { - return false - } - return EqualsBytes(a, b) - case InterfaceContainer: - b, ok := inB.(InterfaceContainer) - if !ok { - return false - } - return EqualsInterfaceContainer(a, b) - case InterfaceSlice: - b, ok := inB.(InterfaceSlice) - if !ok { - return false - } - return EqualsInterfaceSlice(a, b) - case *Leaf: - b, ok := inB.(*Leaf) - if !ok { - return false - } - return EqualsRefOfLeaf(a, b) - case LeafSlice: - b, ok := inB.(LeafSlice) - if !ok { - return false - } - return EqualsLeafSlice(a, b) - case *NoCloneType: - b, ok := inB.(*NoCloneType) - if !ok { - return false - } - return EqualsRefOfNoCloneType(a, b) - case *RefContainer: - b, ok := inB.(*RefContainer) - if !ok { - return false - } - return EqualsRefOfRefContainer(a, b) - case *RefSliceContainer: - b, ok := inB.(*RefSliceContainer) - if !ok { - return false - } - return EqualsRefOfRefSliceContainer(a, b) - case *SubImpl: - b, ok := inB.(*SubImpl) - if !ok { - return false - } - return EqualsRefOfSubImpl(a, b) - case ValueContainer: - b, ok := inB.(ValueContainer) - if !ok { - return false - } - return EqualsValueContainer(a, b) - case ValueSliceContainer: - b, ok := inB.(ValueSliceContainer) - if !ok { - return false - } - return EqualsValueSliceContainer(a, b) - default: - // this should never happen - return false - } -} - -// EqualsSubIface does deep equals. -func EqualsSubIface(inA, inB SubIface) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *SubImpl: - b, ok := inB.(*SubImpl) - if !ok { - return false - } - return EqualsRefOfSubImpl(a, b) - default: - // this should never happen - return false - } -} - -// EqualsBytes does deep equals. -func EqualsBytes(a, b Bytes) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if a[i] != b[i] { - return false - } - } - return true -} - -// EqualsInterfaceContainer does deep equals. -func EqualsInterfaceContainer(a, b InterfaceContainer) bool { - return true -} - -// EqualsInterfaceSlice does deep equals. -func EqualsInterfaceSlice(a, b InterfaceSlice) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsAST(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfLeaf does deep equals. -func EqualsRefOfLeaf(a, b *Leaf) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.v == b.v -} - -// EqualsLeafSlice does deep equals. -func EqualsLeafSlice(a, b LeafSlice) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfLeaf(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfNoCloneType does deep equals. -func EqualsRefOfNoCloneType(a, b *NoCloneType) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.v == b.v -} - -// EqualsRefOfRefContainer does deep equals. -func EqualsRefOfRefContainer(a, b *RefContainer) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.NotASTType == b.NotASTType && - EqualsAST(a.ASTType, b.ASTType) && - EqualsRefOfLeaf(a.ASTImplementationType, b.ASTImplementationType) -} - -// EqualsRefOfRefSliceContainer does deep equals. -func EqualsRefOfRefSliceContainer(a, b *RefSliceContainer) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSliceOfAST(a.ASTElements, b.ASTElements) && - EqualsSliceOfInt(a.NotASTElements, b.NotASTElements) && - EqualsSliceOfRefOfLeaf(a.ASTImplementationElements, b.ASTImplementationElements) -} - -// EqualsRefOfSubImpl does deep equals. -func EqualsRefOfSubImpl(a, b *SubImpl) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSubIface(a.inner, b.inner) && - EqualsRefOfBool(a.field, b.field) -} - -// EqualsValueContainer does deep equals. -func EqualsValueContainer(a, b ValueContainer) bool { - return a.NotASTType == b.NotASTType && - EqualsAST(a.ASTType, b.ASTType) && - EqualsRefOfLeaf(a.ASTImplementationType, b.ASTImplementationType) -} - -// EqualsValueSliceContainer does deep equals. -func EqualsValueSliceContainer(a, b ValueSliceContainer) bool { - return EqualsSliceOfAST(a.ASTElements, b.ASTElements) && - EqualsSliceOfInt(a.NotASTElements, b.NotASTElements) && - EqualsSliceOfRefOfLeaf(a.ASTImplementationElements, b.ASTImplementationElements) -} - -// EqualsSliceOfAST does deep equals. -func EqualsSliceOfAST(a, b []AST) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsAST(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsSliceOfInt does deep equals. -func EqualsSliceOfInt(a, b []int) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if a[i] != b[i] { - return false - } - } - return true -} - -// EqualsSliceOfRefOfLeaf does deep equals. -func EqualsSliceOfRefOfLeaf(a, b []*Leaf) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfLeaf(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfBool does deep equals. -func EqualsRefOfBool(a, b *bool) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return *a == *b -} diff --git a/go/vt/sqlparser/clone.go b/go/vt/sqlparser/clone.go index a0743ca4f50..e9210d81e45 100644 --- a/go/vt/sqlparser/clone.go +++ b/go/vt/sqlparser/clone.go @@ -67,6 +67,135 @@ func CloneAlterOption(in AlterOption) AlterOption { } } +// EqualsAlterOption creates a deep clone of the input. +func EqualsAlterOption(inA, inB AlterOption) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AddColumns: + b, ok := inB.(*AddColumns) + if !ok { + return false + } + return EqualsRefOfAddColumns(a, b) + case *AddConstraintDefinition: + b, ok := inB.(*AddConstraintDefinition) + if !ok { + return false + } + return EqualsRefOfAddConstraintDefinition(a, b) + case *AddIndexDefinition: + b, ok := inB.(*AddIndexDefinition) + if !ok { + return false + } + return EqualsRefOfAddIndexDefinition(a, b) + case AlgorithmValue: + b, ok := inB.(AlgorithmValue) + if !ok { + return false + } + return a == b + case *AlterCharset: + b, ok := inB.(*AlterCharset) + if !ok { + return false + } + return EqualsRefOfAlterCharset(a, b) + case *AlterColumn: + b, ok := inB.(*AlterColumn) + if !ok { + return false + } + return EqualsRefOfAlterColumn(a, b) + case *ChangeColumn: + b, ok := inB.(*ChangeColumn) + if !ok { + return false + } + return EqualsRefOfChangeColumn(a, b) + case *DropColumn: + b, ok := inB.(*DropColumn) + if !ok { + return false + } + return EqualsRefOfDropColumn(a, b) + case *DropKey: + b, ok := inB.(*DropKey) + if !ok { + return false + } + return EqualsRefOfDropKey(a, b) + case *Force: + b, ok := inB.(*Force) + if !ok { + return false + } + return EqualsRefOfForce(a, b) + case *KeyState: + b, ok := inB.(*KeyState) + if !ok { + return false + } + return EqualsRefOfKeyState(a, b) + case *LockOption: + b, ok := inB.(*LockOption) + if !ok { + return false + } + return EqualsRefOfLockOption(a, b) + case *ModifyColumn: + b, ok := inB.(*ModifyColumn) + if !ok { + return false + } + return EqualsRefOfModifyColumn(a, b) + case *OrderByOption: + b, ok := inB.(*OrderByOption) + if !ok { + return false + } + return EqualsRefOfOrderByOption(a, b) + case *RenameIndex: + b, ok := inB.(*RenameIndex) + if !ok { + return false + } + return EqualsRefOfRenameIndex(a, b) + case *RenameTableName: + b, ok := inB.(*RenameTableName) + if !ok { + return false + } + return EqualsRefOfRenameTableName(a, b) + case TableOptions: + b, ok := inB.(TableOptions) + if !ok { + return false + } + return EqualsTableOptions(a, b) + case *TablespaceOperation: + b, ok := inB.(*TablespaceOperation) + if !ok { + return false + } + return EqualsRefOfTablespaceOperation(a, b) + case *Validation: + b, ok := inB.(*Validation) + if !ok { + return false + } + return EqualsRefOfValidation(a, b) + default: + // this should never happen + return false + } +} + // CloneCharacteristic creates a deep clone of the input. func CloneCharacteristic(in Characteristic) Characteristic { if in == nil { @@ -83,6 +212,33 @@ func CloneCharacteristic(in Characteristic) Characteristic { } } +// EqualsCharacteristic creates a deep clone of the input. +func EqualsCharacteristic(inA, inB Characteristic) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case AccessMode: + b, ok := inB.(AccessMode) + if !ok { + return false + } + return a == b + case IsolationLevel: + b, ok := inB.(IsolationLevel) + if !ok { + return false + } + return a == b + default: + // this should never happen + return false + } +} + // CloneColTuple creates a deep clone of the input. func CloneColTuple(in ColTuple) ColTuple { if in == nil { @@ -101,6 +257,39 @@ func CloneColTuple(in ColTuple) ColTuple { } } +// EqualsColTuple creates a deep clone of the input. +func EqualsColTuple(inA, inB ColTuple) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case ListArg: + b, ok := inB.(ListArg) + if !ok { + return false + } + return EqualsListArg(a, b) + case *Subquery: + b, ok := inB.(*Subquery) + if !ok { + return false + } + return EqualsRefOfSubquery(a, b) + case ValTuple: + b, ok := inB.(ValTuple) + if !ok { + return false + } + return EqualsValTuple(a, b) + default: + // this should never happen + return false + } +} + // CloneConstraintInfo creates a deep clone of the input. func CloneConstraintInfo(in ConstraintInfo) ConstraintInfo { if in == nil { @@ -117,6 +306,33 @@ func CloneConstraintInfo(in ConstraintInfo) ConstraintInfo { } } +// EqualsConstraintInfo creates a deep clone of the input. +func EqualsConstraintInfo(inA, inB ConstraintInfo) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *CheckConstraintDefinition: + b, ok := inB.(*CheckConstraintDefinition) + if !ok { + return false + } + return EqualsRefOfCheckConstraintDefinition(a, b) + case *ForeignKeyDefinition: + b, ok := inB.(*ForeignKeyDefinition) + if !ok { + return false + } + return EqualsRefOfForeignKeyDefinition(a, b) + default: + // this should never happen + return false + } +} + // CloneDBDDLStatement creates a deep clone of the input. func CloneDBDDLStatement(in DBDDLStatement) DBDDLStatement { if in == nil { @@ -135,6 +351,39 @@ func CloneDBDDLStatement(in DBDDLStatement) DBDDLStatement { } } +// EqualsDBDDLStatement creates a deep clone of the input. +func EqualsDBDDLStatement(inA, inB DBDDLStatement) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AlterDatabase: + b, ok := inB.(*AlterDatabase) + if !ok { + return false + } + return EqualsRefOfAlterDatabase(a, b) + case *CreateDatabase: + b, ok := inB.(*CreateDatabase) + if !ok { + return false + } + return EqualsRefOfCreateDatabase(a, b) + case *DropDatabase: + b, ok := inB.(*DropDatabase) + if !ok { + return false + } + return EqualsRefOfDropDatabase(a, b) + default: + // this should never happen + return false + } +} + // CloneDDLStatement creates a deep clone of the input. func CloneDDLStatement(in DDLStatement) DDLStatement { if in == nil { @@ -163,6 +412,69 @@ func CloneDDLStatement(in DDLStatement) DDLStatement { } } +// EqualsDDLStatement creates a deep clone of the input. +func EqualsDDLStatement(inA, inB DDLStatement) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AlterTable: + b, ok := inB.(*AlterTable) + if !ok { + return false + } + return EqualsRefOfAlterTable(a, b) + case *AlterView: + b, ok := inB.(*AlterView) + if !ok { + return false + } + return EqualsRefOfAlterView(a, b) + case *CreateTable: + b, ok := inB.(*CreateTable) + if !ok { + return false + } + return EqualsRefOfCreateTable(a, b) + case *CreateView: + b, ok := inB.(*CreateView) + if !ok { + return false + } + return EqualsRefOfCreateView(a, b) + case *DropTable: + b, ok := inB.(*DropTable) + if !ok { + return false + } + return EqualsRefOfDropTable(a, b) + case *DropView: + b, ok := inB.(*DropView) + if !ok { + return false + } + return EqualsRefOfDropView(a, b) + case *RenameTable: + b, ok := inB.(*RenameTable) + if !ok { + return false + } + return EqualsRefOfRenameTable(a, b) + case *TruncateTable: + b, ok := inB.(*TruncateTable) + if !ok { + return false + } + return EqualsRefOfTruncateTable(a, b) + default: + // this should never happen + return false + } +} + // CloneExplain creates a deep clone of the input. func CloneExplain(in Explain) Explain { if in == nil { @@ -179,6 +491,33 @@ func CloneExplain(in Explain) Explain { } } +// EqualsExplain creates a deep clone of the input. +func EqualsExplain(inA, inB Explain) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *ExplainStmt: + b, ok := inB.(*ExplainStmt) + if !ok { + return false + } + return EqualsRefOfExplainStmt(a, b) + case *ExplainTab: + b, ok := inB.(*ExplainTab) + if !ok { + return false + } + return EqualsRefOfExplainTab(a, b) + default: + // this should never happen + return false + } +} + // CloneExpr creates a deep clone of the input. func CloneExpr(in Expr) Expr { if in == nil { @@ -253,6 +592,207 @@ func CloneExpr(in Expr) Expr { } } +// EqualsExpr creates a deep clone of the input. +func EqualsExpr(inA, inB Expr) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AndExpr: + b, ok := inB.(*AndExpr) + if !ok { + return false + } + return EqualsRefOfAndExpr(a, b) + case Argument: + b, ok := inB.(Argument) + if !ok { + return false + } + return a == b + case *BinaryExpr: + b, ok := inB.(*BinaryExpr) + if !ok { + return false + } + return EqualsRefOfBinaryExpr(a, b) + case BoolVal: + b, ok := inB.(BoolVal) + if !ok { + return false + } + return a == b + case *CaseExpr: + b, ok := inB.(*CaseExpr) + if !ok { + return false + } + return EqualsRefOfCaseExpr(a, b) + case *ColName: + b, ok := inB.(*ColName) + if !ok { + return false + } + return EqualsRefOfColName(a, b) + case *CollateExpr: + b, ok := inB.(*CollateExpr) + if !ok { + return false + } + return EqualsRefOfCollateExpr(a, b) + case *ComparisonExpr: + b, ok := inB.(*ComparisonExpr) + if !ok { + return false + } + return EqualsRefOfComparisonExpr(a, b) + case *ConvertExpr: + b, ok := inB.(*ConvertExpr) + if !ok { + return false + } + return EqualsRefOfConvertExpr(a, b) + case *ConvertUsingExpr: + b, ok := inB.(*ConvertUsingExpr) + if !ok { + return false + } + return EqualsRefOfConvertUsingExpr(a, b) + case *CurTimeFuncExpr: + b, ok := inB.(*CurTimeFuncExpr) + if !ok { + return false + } + return EqualsRefOfCurTimeFuncExpr(a, b) + case *Default: + b, ok := inB.(*Default) + if !ok { + return false + } + return EqualsRefOfDefault(a, b) + case *ExistsExpr: + b, ok := inB.(*ExistsExpr) + if !ok { + return false + } + return EqualsRefOfExistsExpr(a, b) + case *FuncExpr: + b, ok := inB.(*FuncExpr) + if !ok { + return false + } + return EqualsRefOfFuncExpr(a, b) + case *GroupConcatExpr: + b, ok := inB.(*GroupConcatExpr) + if !ok { + return false + } + return EqualsRefOfGroupConcatExpr(a, b) + case *IntervalExpr: + b, ok := inB.(*IntervalExpr) + if !ok { + return false + } + return EqualsRefOfIntervalExpr(a, b) + case *IsExpr: + b, ok := inB.(*IsExpr) + if !ok { + return false + } + return EqualsRefOfIsExpr(a, b) + case ListArg: + b, ok := inB.(ListArg) + if !ok { + return false + } + return EqualsListArg(a, b) + case *Literal: + b, ok := inB.(*Literal) + if !ok { + return false + } + return EqualsRefOfLiteral(a, b) + case *MatchExpr: + b, ok := inB.(*MatchExpr) + if !ok { + return false + } + return EqualsRefOfMatchExpr(a, b) + case *NotExpr: + b, ok := inB.(*NotExpr) + if !ok { + return false + } + return EqualsRefOfNotExpr(a, b) + case *NullVal: + b, ok := inB.(*NullVal) + if !ok { + return false + } + return EqualsRefOfNullVal(a, b) + case *OrExpr: + b, ok := inB.(*OrExpr) + if !ok { + return false + } + return EqualsRefOfOrExpr(a, b) + case *RangeCond: + b, ok := inB.(*RangeCond) + if !ok { + return false + } + return EqualsRefOfRangeCond(a, b) + case *Subquery: + b, ok := inB.(*Subquery) + if !ok { + return false + } + return EqualsRefOfSubquery(a, b) + case *SubstrExpr: + b, ok := inB.(*SubstrExpr) + if !ok { + return false + } + return EqualsRefOfSubstrExpr(a, b) + case *TimestampFuncExpr: + b, ok := inB.(*TimestampFuncExpr) + if !ok { + return false + } + return EqualsRefOfTimestampFuncExpr(a, b) + case *UnaryExpr: + b, ok := inB.(*UnaryExpr) + if !ok { + return false + } + return EqualsRefOfUnaryExpr(a, b) + case ValTuple: + b, ok := inB.(ValTuple) + if !ok { + return false + } + return EqualsValTuple(a, b) + case *ValuesFuncExpr: + b, ok := inB.(*ValuesFuncExpr) + if !ok { + return false + } + return EqualsRefOfValuesFuncExpr(a, b) + case *XorExpr: + b, ok := inB.(*XorExpr) + if !ok { + return false + } + return EqualsRefOfXorExpr(a, b) + default: + // this should never happen + return false + } +} + // CloneInsertRows creates a deep clone of the input. func CloneInsertRows(in InsertRows) InsertRows { if in == nil { @@ -273,6 +813,45 @@ func CloneInsertRows(in InsertRows) InsertRows { } } +// EqualsInsertRows creates a deep clone of the input. +func EqualsInsertRows(inA, inB InsertRows) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *ParenSelect: + b, ok := inB.(*ParenSelect) + if !ok { + return false + } + return EqualsRefOfParenSelect(a, b) + case *Select: + b, ok := inB.(*Select) + if !ok { + return false + } + return EqualsRefOfSelect(a, b) + case *Union: + b, ok := inB.(*Union) + if !ok { + return false + } + return EqualsRefOfUnion(a, b) + case Values: + b, ok := inB.(Values) + if !ok { + return false + } + return EqualsValues(a, b) + default: + // this should never happen + return false + } +} + // CloneSQLNode creates a deep clone of the input. func CloneSQLNode(in SQLNode) SQLNode { if in == nil { @@ -556,20 +1135,899 @@ func CloneSQLNode(in SQLNode) SQLNode { case Values: return CloneValues(in) case *ValuesFuncExpr: - return CloneRefOfValuesFuncExpr(in) + return CloneRefOfValuesFuncExpr(in) + case VindexParam: + return CloneVindexParam(in) + case *VindexSpec: + return CloneRefOfVindexSpec(in) + case *When: + return CloneRefOfWhen(in) + case *Where: + return CloneRefOfWhere(in) + case *XorExpr: + return CloneRefOfXorExpr(in) + default: + // this should never happen + return nil + } +} + +// EqualsSQLNode creates a deep clone of the input. +func EqualsSQLNode(inA, inB SQLNode) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case AccessMode: + b, ok := inB.(AccessMode) + if !ok { + return false + } + return a == b + case *AddColumns: + b, ok := inB.(*AddColumns) + if !ok { + return false + } + return EqualsRefOfAddColumns(a, b) + case *AddConstraintDefinition: + b, ok := inB.(*AddConstraintDefinition) + if !ok { + return false + } + return EqualsRefOfAddConstraintDefinition(a, b) + case *AddIndexDefinition: + b, ok := inB.(*AddIndexDefinition) + if !ok { + return false + } + return EqualsRefOfAddIndexDefinition(a, b) + case AlgorithmValue: + b, ok := inB.(AlgorithmValue) + if !ok { + return false + } + return a == b + case *AliasedExpr: + b, ok := inB.(*AliasedExpr) + if !ok { + return false + } + return EqualsRefOfAliasedExpr(a, b) + case *AliasedTableExpr: + b, ok := inB.(*AliasedTableExpr) + if !ok { + return false + } + return EqualsRefOfAliasedTableExpr(a, b) + case *AlterCharset: + b, ok := inB.(*AlterCharset) + if !ok { + return false + } + return EqualsRefOfAlterCharset(a, b) + case *AlterColumn: + b, ok := inB.(*AlterColumn) + if !ok { + return false + } + return EqualsRefOfAlterColumn(a, b) + case *AlterDatabase: + b, ok := inB.(*AlterDatabase) + if !ok { + return false + } + return EqualsRefOfAlterDatabase(a, b) + case *AlterTable: + b, ok := inB.(*AlterTable) + if !ok { + return false + } + return EqualsRefOfAlterTable(a, b) + case *AlterView: + b, ok := inB.(*AlterView) + if !ok { + return false + } + return EqualsRefOfAlterView(a, b) + case *AlterVschema: + b, ok := inB.(*AlterVschema) + if !ok { + return false + } + return EqualsRefOfAlterVschema(a, b) + case *AndExpr: + b, ok := inB.(*AndExpr) + if !ok { + return false + } + return EqualsRefOfAndExpr(a, b) + case Argument: + b, ok := inB.(Argument) + if !ok { + return false + } + return a == b + case *AutoIncSpec: + b, ok := inB.(*AutoIncSpec) + if !ok { + return false + } + return EqualsRefOfAutoIncSpec(a, b) + case *Begin: + b, ok := inB.(*Begin) + if !ok { + return false + } + return EqualsRefOfBegin(a, b) + case *BinaryExpr: + b, ok := inB.(*BinaryExpr) + if !ok { + return false + } + return EqualsRefOfBinaryExpr(a, b) + case BoolVal: + b, ok := inB.(BoolVal) + if !ok { + return false + } + return a == b + case *CallProc: + b, ok := inB.(*CallProc) + if !ok { + return false + } + return EqualsRefOfCallProc(a, b) + case *CaseExpr: + b, ok := inB.(*CaseExpr) + if !ok { + return false + } + return EqualsRefOfCaseExpr(a, b) + case *ChangeColumn: + b, ok := inB.(*ChangeColumn) + if !ok { + return false + } + return EqualsRefOfChangeColumn(a, b) + case *CheckConstraintDefinition: + b, ok := inB.(*CheckConstraintDefinition) + if !ok { + return false + } + return EqualsRefOfCheckConstraintDefinition(a, b) + case ColIdent: + b, ok := inB.(ColIdent) + if !ok { + return false + } + return EqualsColIdent(a, b) + case *ColName: + b, ok := inB.(*ColName) + if !ok { + return false + } + return EqualsRefOfColName(a, b) + case *CollateExpr: + b, ok := inB.(*CollateExpr) + if !ok { + return false + } + return EqualsRefOfCollateExpr(a, b) + case *ColumnDefinition: + b, ok := inB.(*ColumnDefinition) + if !ok { + return false + } + return EqualsRefOfColumnDefinition(a, b) + case *ColumnType: + b, ok := inB.(*ColumnType) + if !ok { + return false + } + return EqualsRefOfColumnType(a, b) + case Columns: + b, ok := inB.(Columns) + if !ok { + return false + } + return EqualsColumns(a, b) + case Comments: + b, ok := inB.(Comments) + if !ok { + return false + } + return EqualsComments(a, b) + case *Commit: + b, ok := inB.(*Commit) + if !ok { + return false + } + return EqualsRefOfCommit(a, b) + case *ComparisonExpr: + b, ok := inB.(*ComparisonExpr) + if !ok { + return false + } + return EqualsRefOfComparisonExpr(a, b) + case *ConstraintDefinition: + b, ok := inB.(*ConstraintDefinition) + if !ok { + return false + } + return EqualsRefOfConstraintDefinition(a, b) + case *ConvertExpr: + b, ok := inB.(*ConvertExpr) + if !ok { + return false + } + return EqualsRefOfConvertExpr(a, b) + case *ConvertType: + b, ok := inB.(*ConvertType) + if !ok { + return false + } + return EqualsRefOfConvertType(a, b) + case *ConvertUsingExpr: + b, ok := inB.(*ConvertUsingExpr) + if !ok { + return false + } + return EqualsRefOfConvertUsingExpr(a, b) + case *CreateDatabase: + b, ok := inB.(*CreateDatabase) + if !ok { + return false + } + return EqualsRefOfCreateDatabase(a, b) + case *CreateTable: + b, ok := inB.(*CreateTable) + if !ok { + return false + } + return EqualsRefOfCreateTable(a, b) + case *CreateView: + b, ok := inB.(*CreateView) + if !ok { + return false + } + return EqualsRefOfCreateView(a, b) + case *CurTimeFuncExpr: + b, ok := inB.(*CurTimeFuncExpr) + if !ok { + return false + } + return EqualsRefOfCurTimeFuncExpr(a, b) + case *Default: + b, ok := inB.(*Default) + if !ok { + return false + } + return EqualsRefOfDefault(a, b) + case *Delete: + b, ok := inB.(*Delete) + if !ok { + return false + } + return EqualsRefOfDelete(a, b) + case *DerivedTable: + b, ok := inB.(*DerivedTable) + if !ok { + return false + } + return EqualsRefOfDerivedTable(a, b) + case *DropColumn: + b, ok := inB.(*DropColumn) + if !ok { + return false + } + return EqualsRefOfDropColumn(a, b) + case *DropDatabase: + b, ok := inB.(*DropDatabase) + if !ok { + return false + } + return EqualsRefOfDropDatabase(a, b) + case *DropKey: + b, ok := inB.(*DropKey) + if !ok { + return false + } + return EqualsRefOfDropKey(a, b) + case *DropTable: + b, ok := inB.(*DropTable) + if !ok { + return false + } + return EqualsRefOfDropTable(a, b) + case *DropView: + b, ok := inB.(*DropView) + if !ok { + return false + } + return EqualsRefOfDropView(a, b) + case *ExistsExpr: + b, ok := inB.(*ExistsExpr) + if !ok { + return false + } + return EqualsRefOfExistsExpr(a, b) + case *ExplainStmt: + b, ok := inB.(*ExplainStmt) + if !ok { + return false + } + return EqualsRefOfExplainStmt(a, b) + case *ExplainTab: + b, ok := inB.(*ExplainTab) + if !ok { + return false + } + return EqualsRefOfExplainTab(a, b) + case Exprs: + b, ok := inB.(Exprs) + if !ok { + return false + } + return EqualsExprs(a, b) + case *Flush: + b, ok := inB.(*Flush) + if !ok { + return false + } + return EqualsRefOfFlush(a, b) + case *Force: + b, ok := inB.(*Force) + if !ok { + return false + } + return EqualsRefOfForce(a, b) + case *ForeignKeyDefinition: + b, ok := inB.(*ForeignKeyDefinition) + if !ok { + return false + } + return EqualsRefOfForeignKeyDefinition(a, b) + case *FuncExpr: + b, ok := inB.(*FuncExpr) + if !ok { + return false + } + return EqualsRefOfFuncExpr(a, b) + case GroupBy: + b, ok := inB.(GroupBy) + if !ok { + return false + } + return EqualsGroupBy(a, b) + case *GroupConcatExpr: + b, ok := inB.(*GroupConcatExpr) + if !ok { + return false + } + return EqualsRefOfGroupConcatExpr(a, b) + case *IndexDefinition: + b, ok := inB.(*IndexDefinition) + if !ok { + return false + } + return EqualsRefOfIndexDefinition(a, b) + case *IndexHints: + b, ok := inB.(*IndexHints) + if !ok { + return false + } + return EqualsRefOfIndexHints(a, b) + case *IndexInfo: + b, ok := inB.(*IndexInfo) + if !ok { + return false + } + return EqualsRefOfIndexInfo(a, b) + case *Insert: + b, ok := inB.(*Insert) + if !ok { + return false + } + return EqualsRefOfInsert(a, b) + case *IntervalExpr: + b, ok := inB.(*IntervalExpr) + if !ok { + return false + } + return EqualsRefOfIntervalExpr(a, b) + case *IsExpr: + b, ok := inB.(*IsExpr) + if !ok { + return false + } + return EqualsRefOfIsExpr(a, b) + case IsolationLevel: + b, ok := inB.(IsolationLevel) + if !ok { + return false + } + return a == b + case JoinCondition: + b, ok := inB.(JoinCondition) + if !ok { + return false + } + return EqualsJoinCondition(a, b) + case *JoinTableExpr: + b, ok := inB.(*JoinTableExpr) + if !ok { + return false + } + return EqualsRefOfJoinTableExpr(a, b) + case *KeyState: + b, ok := inB.(*KeyState) + if !ok { + return false + } + return EqualsRefOfKeyState(a, b) + case *Limit: + b, ok := inB.(*Limit) + if !ok { + return false + } + return EqualsRefOfLimit(a, b) + case ListArg: + b, ok := inB.(ListArg) + if !ok { + return false + } + return EqualsListArg(a, b) + case *Literal: + b, ok := inB.(*Literal) + if !ok { + return false + } + return EqualsRefOfLiteral(a, b) + case *Load: + b, ok := inB.(*Load) + if !ok { + return false + } + return EqualsRefOfLoad(a, b) + case *LockOption: + b, ok := inB.(*LockOption) + if !ok { + return false + } + return EqualsRefOfLockOption(a, b) + case *LockTables: + b, ok := inB.(*LockTables) + if !ok { + return false + } + return EqualsRefOfLockTables(a, b) + case *MatchExpr: + b, ok := inB.(*MatchExpr) + if !ok { + return false + } + return EqualsRefOfMatchExpr(a, b) + case *ModifyColumn: + b, ok := inB.(*ModifyColumn) + if !ok { + return false + } + return EqualsRefOfModifyColumn(a, b) + case *Nextval: + b, ok := inB.(*Nextval) + if !ok { + return false + } + return EqualsRefOfNextval(a, b) + case *NotExpr: + b, ok := inB.(*NotExpr) + if !ok { + return false + } + return EqualsRefOfNotExpr(a, b) + case *NullVal: + b, ok := inB.(*NullVal) + if !ok { + return false + } + return EqualsRefOfNullVal(a, b) + case OnDup: + b, ok := inB.(OnDup) + if !ok { + return false + } + return EqualsOnDup(a, b) + case *OptLike: + b, ok := inB.(*OptLike) + if !ok { + return false + } + return EqualsRefOfOptLike(a, b) + case *OrExpr: + b, ok := inB.(*OrExpr) + if !ok { + return false + } + return EqualsRefOfOrExpr(a, b) + case *Order: + b, ok := inB.(*Order) + if !ok { + return false + } + return EqualsRefOfOrder(a, b) + case OrderBy: + b, ok := inB.(OrderBy) + if !ok { + return false + } + return EqualsOrderBy(a, b) + case *OrderByOption: + b, ok := inB.(*OrderByOption) + if !ok { + return false + } + return EqualsRefOfOrderByOption(a, b) + case *OtherAdmin: + b, ok := inB.(*OtherAdmin) + if !ok { + return false + } + return EqualsRefOfOtherAdmin(a, b) + case *OtherRead: + b, ok := inB.(*OtherRead) + if !ok { + return false + } + return EqualsRefOfOtherRead(a, b) + case *ParenSelect: + b, ok := inB.(*ParenSelect) + if !ok { + return false + } + return EqualsRefOfParenSelect(a, b) + case *ParenTableExpr: + b, ok := inB.(*ParenTableExpr) + if !ok { + return false + } + return EqualsRefOfParenTableExpr(a, b) + case *PartitionDefinition: + b, ok := inB.(*PartitionDefinition) + if !ok { + return false + } + return EqualsRefOfPartitionDefinition(a, b) + case *PartitionSpec: + b, ok := inB.(*PartitionSpec) + if !ok { + return false + } + return EqualsRefOfPartitionSpec(a, b) + case Partitions: + b, ok := inB.(Partitions) + if !ok { + return false + } + return EqualsPartitions(a, b) + case *RangeCond: + b, ok := inB.(*RangeCond) + if !ok { + return false + } + return EqualsRefOfRangeCond(a, b) + case ReferenceAction: + b, ok := inB.(ReferenceAction) + if !ok { + return false + } + return a == b + case *Release: + b, ok := inB.(*Release) + if !ok { + return false + } + return EqualsRefOfRelease(a, b) + case *RenameIndex: + b, ok := inB.(*RenameIndex) + if !ok { + return false + } + return EqualsRefOfRenameIndex(a, b) + case *RenameTable: + b, ok := inB.(*RenameTable) + if !ok { + return false + } + return EqualsRefOfRenameTable(a, b) + case *RenameTableName: + b, ok := inB.(*RenameTableName) + if !ok { + return false + } + return EqualsRefOfRenameTableName(a, b) + case *Rollback: + b, ok := inB.(*Rollback) + if !ok { + return false + } + return EqualsRefOfRollback(a, b) + case *SRollback: + b, ok := inB.(*SRollback) + if !ok { + return false + } + return EqualsRefOfSRollback(a, b) + case *Savepoint: + b, ok := inB.(*Savepoint) + if !ok { + return false + } + return EqualsRefOfSavepoint(a, b) + case *Select: + b, ok := inB.(*Select) + if !ok { + return false + } + return EqualsRefOfSelect(a, b) + case SelectExprs: + b, ok := inB.(SelectExprs) + if !ok { + return false + } + return EqualsSelectExprs(a, b) + case *SelectInto: + b, ok := inB.(*SelectInto) + if !ok { + return false + } + return EqualsRefOfSelectInto(a, b) + case *Set: + b, ok := inB.(*Set) + if !ok { + return false + } + return EqualsRefOfSet(a, b) + case *SetExpr: + b, ok := inB.(*SetExpr) + if !ok { + return false + } + return EqualsRefOfSetExpr(a, b) + case SetExprs: + b, ok := inB.(SetExprs) + if !ok { + return false + } + return EqualsSetExprs(a, b) + case *SetTransaction: + b, ok := inB.(*SetTransaction) + if !ok { + return false + } + return EqualsRefOfSetTransaction(a, b) + case *Show: + b, ok := inB.(*Show) + if !ok { + return false + } + return EqualsRefOfShow(a, b) + case *ShowBasic: + b, ok := inB.(*ShowBasic) + if !ok { + return false + } + return EqualsRefOfShowBasic(a, b) + case *ShowCreate: + b, ok := inB.(*ShowCreate) + if !ok { + return false + } + return EqualsRefOfShowCreate(a, b) + case *ShowFilter: + b, ok := inB.(*ShowFilter) + if !ok { + return false + } + return EqualsRefOfShowFilter(a, b) + case *ShowLegacy: + b, ok := inB.(*ShowLegacy) + if !ok { + return false + } + return EqualsRefOfShowLegacy(a, b) + case *StarExpr: + b, ok := inB.(*StarExpr) + if !ok { + return false + } + return EqualsRefOfStarExpr(a, b) + case *Stream: + b, ok := inB.(*Stream) + if !ok { + return false + } + return EqualsRefOfStream(a, b) + case *Subquery: + b, ok := inB.(*Subquery) + if !ok { + return false + } + return EqualsRefOfSubquery(a, b) + case *SubstrExpr: + b, ok := inB.(*SubstrExpr) + if !ok { + return false + } + return EqualsRefOfSubstrExpr(a, b) + case TableExprs: + b, ok := inB.(TableExprs) + if !ok { + return false + } + return EqualsTableExprs(a, b) + case TableIdent: + b, ok := inB.(TableIdent) + if !ok { + return false + } + return EqualsTableIdent(a, b) + case TableName: + b, ok := inB.(TableName) + if !ok { + return false + } + return EqualsTableName(a, b) + case TableNames: + b, ok := inB.(TableNames) + if !ok { + return false + } + return EqualsTableNames(a, b) + case TableOptions: + b, ok := inB.(TableOptions) + if !ok { + return false + } + return EqualsTableOptions(a, b) + case *TableSpec: + b, ok := inB.(*TableSpec) + if !ok { + return false + } + return EqualsRefOfTableSpec(a, b) + case *TablespaceOperation: + b, ok := inB.(*TablespaceOperation) + if !ok { + return false + } + return EqualsRefOfTablespaceOperation(a, b) + case *TimestampFuncExpr: + b, ok := inB.(*TimestampFuncExpr) + if !ok { + return false + } + return EqualsRefOfTimestampFuncExpr(a, b) + case *TruncateTable: + b, ok := inB.(*TruncateTable) + if !ok { + return false + } + return EqualsRefOfTruncateTable(a, b) + case *UnaryExpr: + b, ok := inB.(*UnaryExpr) + if !ok { + return false + } + return EqualsRefOfUnaryExpr(a, b) + case *Union: + b, ok := inB.(*Union) + if !ok { + return false + } + return EqualsRefOfUnion(a, b) + case *UnionSelect: + b, ok := inB.(*UnionSelect) + if !ok { + return false + } + return EqualsRefOfUnionSelect(a, b) + case *UnlockTables: + b, ok := inB.(*UnlockTables) + if !ok { + return false + } + return EqualsRefOfUnlockTables(a, b) + case *Update: + b, ok := inB.(*Update) + if !ok { + return false + } + return EqualsRefOfUpdate(a, b) + case *UpdateExpr: + b, ok := inB.(*UpdateExpr) + if !ok { + return false + } + return EqualsRefOfUpdateExpr(a, b) + case UpdateExprs: + b, ok := inB.(UpdateExprs) + if !ok { + return false + } + return EqualsUpdateExprs(a, b) + case *Use: + b, ok := inB.(*Use) + if !ok { + return false + } + return EqualsRefOfUse(a, b) + case *VStream: + b, ok := inB.(*VStream) + if !ok { + return false + } + return EqualsRefOfVStream(a, b) + case ValTuple: + b, ok := inB.(ValTuple) + if !ok { + return false + } + return EqualsValTuple(a, b) + case *Validation: + b, ok := inB.(*Validation) + if !ok { + return false + } + return EqualsRefOfValidation(a, b) + case Values: + b, ok := inB.(Values) + if !ok { + return false + } + return EqualsValues(a, b) + case *ValuesFuncExpr: + b, ok := inB.(*ValuesFuncExpr) + if !ok { + return false + } + return EqualsRefOfValuesFuncExpr(a, b) case VindexParam: - return CloneVindexParam(in) + b, ok := inB.(VindexParam) + if !ok { + return false + } + return EqualsVindexParam(a, b) case *VindexSpec: - return CloneRefOfVindexSpec(in) + b, ok := inB.(*VindexSpec) + if !ok { + return false + } + return EqualsRefOfVindexSpec(a, b) case *When: - return CloneRefOfWhen(in) + b, ok := inB.(*When) + if !ok { + return false + } + return EqualsRefOfWhen(a, b) case *Where: - return CloneRefOfWhere(in) + b, ok := inB.(*Where) + if !ok { + return false + } + return EqualsRefOfWhere(a, b) case *XorExpr: - return CloneRefOfXorExpr(in) + b, ok := inB.(*XorExpr) + if !ok { + return false + } + return EqualsRefOfXorExpr(a, b) default: // this should never happen - return nil + return false } } @@ -591,6 +2049,39 @@ func CloneSelectExpr(in SelectExpr) SelectExpr { } } +// EqualsSelectExpr creates a deep clone of the input. +func EqualsSelectExpr(inA, inB SelectExpr) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AliasedExpr: + b, ok := inB.(*AliasedExpr) + if !ok { + return false + } + return EqualsRefOfAliasedExpr(a, b) + case *Nextval: + b, ok := inB.(*Nextval) + if !ok { + return false + } + return EqualsRefOfNextval(a, b) + case *StarExpr: + b, ok := inB.(*StarExpr) + if !ok { + return false + } + return EqualsRefOfStarExpr(a, b) + default: + // this should never happen + return false + } +} + // CloneSelectStatement creates a deep clone of the input. func CloneSelectStatement(in SelectStatement) SelectStatement { if in == nil { @@ -609,6 +2100,39 @@ func CloneSelectStatement(in SelectStatement) SelectStatement { } } +// EqualsSelectStatement creates a deep clone of the input. +func EqualsSelectStatement(inA, inB SelectStatement) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *ParenSelect: + b, ok := inB.(*ParenSelect) + if !ok { + return false + } + return EqualsRefOfParenSelect(a, b) + case *Select: + b, ok := inB.(*Select) + if !ok { + return false + } + return EqualsRefOfSelect(a, b) + case *Union: + b, ok := inB.(*Union) + if !ok { + return false + } + return EqualsRefOfUnion(a, b) + default: + // this should never happen + return false + } +} + // CloneShowInternal creates a deep clone of the input. func CloneShowInternal(in ShowInternal) ShowInternal { if in == nil { @@ -627,6 +2151,39 @@ func CloneShowInternal(in ShowInternal) ShowInternal { } } +// EqualsShowInternal creates a deep clone of the input. +func EqualsShowInternal(inA, inB ShowInternal) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *ShowBasic: + b, ok := inB.(*ShowBasic) + if !ok { + return false + } + return EqualsRefOfShowBasic(a, b) + case *ShowCreate: + b, ok := inB.(*ShowCreate) + if !ok { + return false + } + return EqualsRefOfShowCreate(a, b) + case *ShowLegacy: + b, ok := inB.(*ShowLegacy) + if !ok { + return false + } + return EqualsRefOfShowLegacy(a, b) + default: + // this should never happen + return false + } +} + // CloneSimpleTableExpr creates a deep clone of the input. func CloneSimpleTableExpr(in SimpleTableExpr) SimpleTableExpr { if in == nil { @@ -643,6 +2200,33 @@ func CloneSimpleTableExpr(in SimpleTableExpr) SimpleTableExpr { } } +// EqualsSimpleTableExpr creates a deep clone of the input. +func EqualsSimpleTableExpr(inA, inB SimpleTableExpr) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *DerivedTable: + b, ok := inB.(*DerivedTable) + if !ok { + return false + } + return EqualsRefOfDerivedTable(a, b) + case TableName: + b, ok := inB.(TableName) + if !ok { + return false + } + return EqualsTableName(a, b) + default: + // this should never happen + return false + } +} + // CloneStatement creates a deep clone of the input. func CloneStatement(in Statement) Statement { if in == nil { @@ -733,6 +2317,255 @@ func CloneStatement(in Statement) Statement { } } +// EqualsStatement creates a deep clone of the input. +func EqualsStatement(inA, inB Statement) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AlterDatabase: + b, ok := inB.(*AlterDatabase) + if !ok { + return false + } + return EqualsRefOfAlterDatabase(a, b) + case *AlterTable: + b, ok := inB.(*AlterTable) + if !ok { + return false + } + return EqualsRefOfAlterTable(a, b) + case *AlterView: + b, ok := inB.(*AlterView) + if !ok { + return false + } + return EqualsRefOfAlterView(a, b) + case *AlterVschema: + b, ok := inB.(*AlterVschema) + if !ok { + return false + } + return EqualsRefOfAlterVschema(a, b) + case *Begin: + b, ok := inB.(*Begin) + if !ok { + return false + } + return EqualsRefOfBegin(a, b) + case *CallProc: + b, ok := inB.(*CallProc) + if !ok { + return false + } + return EqualsRefOfCallProc(a, b) + case *Commit: + b, ok := inB.(*Commit) + if !ok { + return false + } + return EqualsRefOfCommit(a, b) + case *CreateDatabase: + b, ok := inB.(*CreateDatabase) + if !ok { + return false + } + return EqualsRefOfCreateDatabase(a, b) + case *CreateTable: + b, ok := inB.(*CreateTable) + if !ok { + return false + } + return EqualsRefOfCreateTable(a, b) + case *CreateView: + b, ok := inB.(*CreateView) + if !ok { + return false + } + return EqualsRefOfCreateView(a, b) + case *Delete: + b, ok := inB.(*Delete) + if !ok { + return false + } + return EqualsRefOfDelete(a, b) + case *DropDatabase: + b, ok := inB.(*DropDatabase) + if !ok { + return false + } + return EqualsRefOfDropDatabase(a, b) + case *DropTable: + b, ok := inB.(*DropTable) + if !ok { + return false + } + return EqualsRefOfDropTable(a, b) + case *DropView: + b, ok := inB.(*DropView) + if !ok { + return false + } + return EqualsRefOfDropView(a, b) + case *ExplainStmt: + b, ok := inB.(*ExplainStmt) + if !ok { + return false + } + return EqualsRefOfExplainStmt(a, b) + case *ExplainTab: + b, ok := inB.(*ExplainTab) + if !ok { + return false + } + return EqualsRefOfExplainTab(a, b) + case *Flush: + b, ok := inB.(*Flush) + if !ok { + return false + } + return EqualsRefOfFlush(a, b) + case *Insert: + b, ok := inB.(*Insert) + if !ok { + return false + } + return EqualsRefOfInsert(a, b) + case *Load: + b, ok := inB.(*Load) + if !ok { + return false + } + return EqualsRefOfLoad(a, b) + case *LockTables: + b, ok := inB.(*LockTables) + if !ok { + return false + } + return EqualsRefOfLockTables(a, b) + case *OtherAdmin: + b, ok := inB.(*OtherAdmin) + if !ok { + return false + } + return EqualsRefOfOtherAdmin(a, b) + case *OtherRead: + b, ok := inB.(*OtherRead) + if !ok { + return false + } + return EqualsRefOfOtherRead(a, b) + case *ParenSelect: + b, ok := inB.(*ParenSelect) + if !ok { + return false + } + return EqualsRefOfParenSelect(a, b) + case *Release: + b, ok := inB.(*Release) + if !ok { + return false + } + return EqualsRefOfRelease(a, b) + case *RenameTable: + b, ok := inB.(*RenameTable) + if !ok { + return false + } + return EqualsRefOfRenameTable(a, b) + case *Rollback: + b, ok := inB.(*Rollback) + if !ok { + return false + } + return EqualsRefOfRollback(a, b) + case *SRollback: + b, ok := inB.(*SRollback) + if !ok { + return false + } + return EqualsRefOfSRollback(a, b) + case *Savepoint: + b, ok := inB.(*Savepoint) + if !ok { + return false + } + return EqualsRefOfSavepoint(a, b) + case *Select: + b, ok := inB.(*Select) + if !ok { + return false + } + return EqualsRefOfSelect(a, b) + case *Set: + b, ok := inB.(*Set) + if !ok { + return false + } + return EqualsRefOfSet(a, b) + case *SetTransaction: + b, ok := inB.(*SetTransaction) + if !ok { + return false + } + return EqualsRefOfSetTransaction(a, b) + case *Show: + b, ok := inB.(*Show) + if !ok { + return false + } + return EqualsRefOfShow(a, b) + case *Stream: + b, ok := inB.(*Stream) + if !ok { + return false + } + return EqualsRefOfStream(a, b) + case *TruncateTable: + b, ok := inB.(*TruncateTable) + if !ok { + return false + } + return EqualsRefOfTruncateTable(a, b) + case *Union: + b, ok := inB.(*Union) + if !ok { + return false + } + return EqualsRefOfUnion(a, b) + case *UnlockTables: + b, ok := inB.(*UnlockTables) + if !ok { + return false + } + return EqualsRefOfUnlockTables(a, b) + case *Update: + b, ok := inB.(*Update) + if !ok { + return false + } + return EqualsRefOfUpdate(a, b) + case *Use: + b, ok := inB.(*Use) + if !ok { + return false + } + return EqualsRefOfUse(a, b) + case *VStream: + b, ok := inB.(*VStream) + if !ok { + return false + } + return EqualsRefOfVStream(a, b) + default: + // this should never happen + return false + } +} + // CloneTableExpr creates a deep clone of the input. func CloneTableExpr(in TableExpr) TableExpr { if in == nil { @@ -751,6 +2584,39 @@ func CloneTableExpr(in TableExpr) TableExpr { } } +// EqualsTableExpr creates a deep clone of the input. +func EqualsTableExpr(inA, inB TableExpr) bool { + if inA == nil && inB == nil { + return true + } + if inA == nil || inB == nil { + return false + } + switch a := inA.(type) { + case *AliasedTableExpr: + b, ok := inB.(*AliasedTableExpr) + if !ok { + return false + } + return EqualsRefOfAliasedTableExpr(a, b) + case *JoinTableExpr: + b, ok := inB.(*JoinTableExpr) + if !ok { + return false + } + return EqualsRefOfJoinTableExpr(a, b) + case *ParenTableExpr: + b, ok := inB.(*ParenTableExpr) + if !ok { + return false + } + return EqualsRefOfParenTableExpr(a, b) + default: + // this should never happen + return false + } +} + // CloneRefOfAddColumns creates a deep clone of the input. func CloneRefOfAddColumns(n *AddColumns) *AddColumns { if n == nil { @@ -763,6 +2629,19 @@ func CloneRefOfAddColumns(n *AddColumns) *AddColumns { return &out } +// EqualsRefOfAddColumns creates a deep clone of the input. +func EqualsRefOfAddColumns(a, b *AddColumns) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSliceOfRefOfColumnDefinition(a.Columns, b.Columns) && + EqualsRefOfColName(a.First, b.First) && + EqualsRefOfColName(a.After, b.After) +} + // CloneRefOfAddConstraintDefinition creates a deep clone of the input. func CloneRefOfAddConstraintDefinition(n *AddConstraintDefinition) *AddConstraintDefinition { if n == nil { @@ -773,6 +2652,17 @@ func CloneRefOfAddConstraintDefinition(n *AddConstraintDefinition) *AddConstrain return &out } +// EqualsRefOfAddConstraintDefinition creates a deep clone of the input. +func EqualsRefOfAddConstraintDefinition(a, b *AddConstraintDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfConstraintDefinition(a.ConstraintDefinition, b.ConstraintDefinition) +} + // CloneRefOfAddIndexDefinition creates a deep clone of the input. func CloneRefOfAddIndexDefinition(n *AddIndexDefinition) *AddIndexDefinition { if n == nil { @@ -783,6 +2673,17 @@ func CloneRefOfAddIndexDefinition(n *AddIndexDefinition) *AddIndexDefinition { return &out } +// EqualsRefOfAddIndexDefinition creates a deep clone of the input. +func EqualsRefOfAddIndexDefinition(a, b *AddIndexDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfIndexDefinition(a.IndexDefinition, b.IndexDefinition) +} + // CloneRefOfAlterCharset creates a deep clone of the input. func CloneRefOfAlterCharset(n *AlterCharset) *AlterCharset { if n == nil { @@ -792,6 +2693,18 @@ func CloneRefOfAlterCharset(n *AlterCharset) *AlterCharset { return &out } +// EqualsRefOfAlterCharset creates a deep clone of the input. +func EqualsRefOfAlterCharset(a, b *AlterCharset) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.CharacterSet == b.CharacterSet && + a.Collate == b.Collate +} + // CloneRefOfAlterColumn creates a deep clone of the input. func CloneRefOfAlterColumn(n *AlterColumn) *AlterColumn { if n == nil { @@ -803,6 +2716,19 @@ func CloneRefOfAlterColumn(n *AlterColumn) *AlterColumn { return &out } +// EqualsRefOfAlterColumn creates a deep clone of the input. +func EqualsRefOfAlterColumn(a, b *AlterColumn) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.DropDefault == b.DropDefault && + EqualsRefOfColName(a.Column, b.Column) && + EqualsExpr(a.DefaultVal, b.DefaultVal) +} + // CloneRefOfChangeColumn creates a deep clone of the input. func CloneRefOfChangeColumn(n *ChangeColumn) *ChangeColumn { if n == nil { @@ -816,6 +2742,20 @@ func CloneRefOfChangeColumn(n *ChangeColumn) *ChangeColumn { return &out } +// EqualsRefOfChangeColumn creates a deep clone of the input. +func EqualsRefOfChangeColumn(a, b *ChangeColumn) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColName(a.OldColumn, b.OldColumn) && + EqualsRefOfColumnDefinition(a.NewColDefinition, b.NewColDefinition) && + EqualsRefOfColName(a.First, b.First) && + EqualsRefOfColName(a.After, b.After) +} + // CloneRefOfDropColumn creates a deep clone of the input. func CloneRefOfDropColumn(n *DropColumn) *DropColumn { if n == nil { @@ -826,6 +2766,17 @@ func CloneRefOfDropColumn(n *DropColumn) *DropColumn { return &out } +// EqualsRefOfDropColumn creates a deep clone of the input. +func EqualsRefOfDropColumn(a, b *DropColumn) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColName(a.Name, b.Name) +} + // CloneRefOfDropKey creates a deep clone of the input. func CloneRefOfDropKey(n *DropKey) *DropKey { if n == nil { @@ -835,6 +2786,18 @@ func CloneRefOfDropKey(n *DropKey) *DropKey { return &out } +// EqualsRefOfDropKey creates a deep clone of the input. +func EqualsRefOfDropKey(a, b *DropKey) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Name == b.Name && + a.Type == b.Type +} + // CloneRefOfForce creates a deep clone of the input. func CloneRefOfForce(n *Force) *Force { if n == nil { @@ -844,6 +2807,17 @@ func CloneRefOfForce(n *Force) *Force { return &out } +// EqualsRefOfForce creates a deep clone of the input. +func EqualsRefOfForce(a, b *Force) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + // CloneRefOfKeyState creates a deep clone of the input. func CloneRefOfKeyState(n *KeyState) *KeyState { if n == nil { @@ -853,6 +2827,17 @@ func CloneRefOfKeyState(n *KeyState) *KeyState { return &out } +// EqualsRefOfKeyState creates a deep clone of the input. +func EqualsRefOfKeyState(a, b *KeyState) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Enable == b.Enable +} + // CloneRefOfLockOption creates a deep clone of the input. func CloneRefOfLockOption(n *LockOption) *LockOption { if n == nil { @@ -862,6 +2847,17 @@ func CloneRefOfLockOption(n *LockOption) *LockOption { return &out } +// EqualsRefOfLockOption creates a deep clone of the input. +func EqualsRefOfLockOption(a, b *LockOption) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type +} + // CloneRefOfModifyColumn creates a deep clone of the input. func CloneRefOfModifyColumn(n *ModifyColumn) *ModifyColumn { if n == nil { @@ -874,6 +2870,19 @@ func CloneRefOfModifyColumn(n *ModifyColumn) *ModifyColumn { return &out } +// EqualsRefOfModifyColumn creates a deep clone of the input. +func EqualsRefOfModifyColumn(a, b *ModifyColumn) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColumnDefinition(a.NewColDefinition, b.NewColDefinition) && + EqualsRefOfColName(a.First, b.First) && + EqualsRefOfColName(a.After, b.After) +} + // CloneRefOfOrderByOption creates a deep clone of the input. func CloneRefOfOrderByOption(n *OrderByOption) *OrderByOption { if n == nil { @@ -884,6 +2893,17 @@ func CloneRefOfOrderByOption(n *OrderByOption) *OrderByOption { return &out } +// EqualsRefOfOrderByOption creates a deep clone of the input. +func EqualsRefOfOrderByOption(a, b *OrderByOption) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColumns(a.Cols, b.Cols) +} + // CloneRefOfRenameIndex creates a deep clone of the input. func CloneRefOfRenameIndex(n *RenameIndex) *RenameIndex { if n == nil { @@ -893,6 +2913,18 @@ func CloneRefOfRenameIndex(n *RenameIndex) *RenameIndex { return &out } +// EqualsRefOfRenameIndex creates a deep clone of the input. +func EqualsRefOfRenameIndex(a, b *RenameIndex) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.OldName == b.OldName && + a.NewName == b.NewName +} + // CloneRefOfRenameTableName creates a deep clone of the input. func CloneRefOfRenameTableName(n *RenameTableName) *RenameTableName { if n == nil { @@ -903,6 +2935,17 @@ func CloneRefOfRenameTableName(n *RenameTableName) *RenameTableName { return &out } +// EqualsRefOfRenameTableName creates a deep clone of the input. +func EqualsRefOfRenameTableName(a, b *RenameTableName) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.Table, b.Table) +} + // CloneTableOptions creates a deep clone of the input. func CloneTableOptions(n TableOptions) TableOptions { res := make(TableOptions, 0, len(n)) @@ -912,6 +2955,19 @@ func CloneTableOptions(n TableOptions) TableOptions { return res } +// EqualsTableOptions creates a deep clone of the input. +func EqualsTableOptions(a, b TableOptions) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfTableOption(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfTablespaceOperation creates a deep clone of the input. func CloneRefOfTablespaceOperation(n *TablespaceOperation) *TablespaceOperation { if n == nil { @@ -921,6 +2977,17 @@ func CloneRefOfTablespaceOperation(n *TablespaceOperation) *TablespaceOperation return &out } +// EqualsRefOfTablespaceOperation creates a deep clone of the input. +func EqualsRefOfTablespaceOperation(a, b *TablespaceOperation) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Import == b.Import +} + // CloneRefOfValidation creates a deep clone of the input. func CloneRefOfValidation(n *Validation) *Validation { if n == nil { @@ -930,6 +2997,17 @@ func CloneRefOfValidation(n *Validation) *Validation { return &out } +// EqualsRefOfValidation creates a deep clone of the input. +func EqualsRefOfValidation(a, b *Validation) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.With == b.With +} + // CloneListArg creates a deep clone of the input. func CloneListArg(n ListArg) ListArg { res := make(ListArg, 0, len(n)) @@ -937,6 +3015,19 @@ func CloneListArg(n ListArg) ListArg { return res } +// EqualsListArg creates a deep clone of the input. +func EqualsListArg(a, b ListArg) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + return true +} + // CloneRefOfSubquery creates a deep clone of the input. func CloneRefOfSubquery(n *Subquery) *Subquery { if n == nil { @@ -947,6 +3038,17 @@ func CloneRefOfSubquery(n *Subquery) *Subquery { return &out } +// EqualsRefOfSubquery creates a deep clone of the input. +func EqualsRefOfSubquery(a, b *Subquery) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSelectStatement(a.Select, b.Select) +} + // CloneValTuple creates a deep clone of the input. func CloneValTuple(n ValTuple) ValTuple { res := make(ValTuple, 0, len(n)) @@ -956,6 +3058,19 @@ func CloneValTuple(n ValTuple) ValTuple { return res } +// EqualsValTuple creates a deep clone of the input. +func EqualsValTuple(a, b ValTuple) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsExpr(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfCheckConstraintDefinition creates a deep clone of the input. func CloneRefOfCheckConstraintDefinition(n *CheckConstraintDefinition) *CheckConstraintDefinition { if n == nil { @@ -966,6 +3081,18 @@ func CloneRefOfCheckConstraintDefinition(n *CheckConstraintDefinition) *CheckCon return &out } +// EqualsRefOfCheckConstraintDefinition creates a deep clone of the input. +func EqualsRefOfCheckConstraintDefinition(a, b *CheckConstraintDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Enforced == b.Enforced && + EqualsExpr(a.Expr, b.Expr) +} + // CloneRefOfForeignKeyDefinition creates a deep clone of the input. func CloneRefOfForeignKeyDefinition(n *ForeignKeyDefinition) *ForeignKeyDefinition { if n == nil { @@ -978,6 +3105,21 @@ func CloneRefOfForeignKeyDefinition(n *ForeignKeyDefinition) *ForeignKeyDefiniti return &out } +// EqualsRefOfForeignKeyDefinition creates a deep clone of the input. +func EqualsRefOfForeignKeyDefinition(a, b *ForeignKeyDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColumns(a.Source, b.Source) && + EqualsTableName(a.ReferencedTable, b.ReferencedTable) && + EqualsColumns(a.ReferencedColumns, b.ReferencedColumns) && + a.OnDelete == b.OnDelete && + a.OnUpdate == b.OnUpdate +} + // CloneRefOfAlterDatabase creates a deep clone of the input. func CloneRefOfAlterDatabase(n *AlterDatabase) *AlterDatabase { if n == nil { @@ -988,6 +3130,20 @@ func CloneRefOfAlterDatabase(n *AlterDatabase) *AlterDatabase { return &out } +// EqualsRefOfAlterDatabase creates a deep clone of the input. +func EqualsRefOfAlterDatabase(a, b *AlterDatabase) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.DBName == b.DBName && + a.UpdateDataDirectory == b.UpdateDataDirectory && + a.FullyParsed == b.FullyParsed && + EqualsSliceOfCollateAndCharset(a.AlterOptions, b.AlterOptions) +} + // CloneRefOfCreateDatabase creates a deep clone of the input. func CloneRefOfCreateDatabase(n *CreateDatabase) *CreateDatabase { if n == nil { @@ -999,6 +3155,21 @@ func CloneRefOfCreateDatabase(n *CreateDatabase) *CreateDatabase { return &out } +// EqualsRefOfCreateDatabase creates a deep clone of the input. +func EqualsRefOfCreateDatabase(a, b *CreateDatabase) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.DBName == b.DBName && + a.IfNotExists == b.IfNotExists && + a.FullyParsed == b.FullyParsed && + EqualsComments(a.Comments, b.Comments) && + EqualsSliceOfCollateAndCharset(a.CreateOptions, b.CreateOptions) +} + // CloneRefOfDropDatabase creates a deep clone of the input. func CloneRefOfDropDatabase(n *DropDatabase) *DropDatabase { if n == nil { @@ -1009,6 +3180,19 @@ func CloneRefOfDropDatabase(n *DropDatabase) *DropDatabase { return &out } +// EqualsRefOfDropDatabase creates a deep clone of the input. +func EqualsRefOfDropDatabase(a, b *DropDatabase) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.DBName == b.DBName && + a.IfExists == b.IfExists && + EqualsComments(a.Comments, b.Comments) +} + // CloneRefOfAlterTable creates a deep clone of the input. func CloneRefOfAlterTable(n *AlterTable) *AlterTable { if n == nil { @@ -1021,6 +3205,20 @@ func CloneRefOfAlterTable(n *AlterTable) *AlterTable { return &out } +// EqualsRefOfAlterTable creates a deep clone of the input. +func EqualsRefOfAlterTable(a, b *AlterTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.FullyParsed == b.FullyParsed && + EqualsTableName(a.Table, b.Table) && + EqualsSliceOfAlterOption(a.AlterOptions, b.AlterOptions) && + EqualsRefOfPartitionSpec(a.PartitionSpec, b.PartitionSpec) +} + // CloneRefOfAlterView creates a deep clone of the input. func CloneRefOfAlterView(n *AlterView) *AlterView { if n == nil { @@ -1033,6 +3231,23 @@ func CloneRefOfAlterView(n *AlterView) *AlterView { return &out } +// EqualsRefOfAlterView creates a deep clone of the input. +func EqualsRefOfAlterView(a, b *AlterView) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Algorithm == b.Algorithm && + a.Definer == b.Definer && + a.Security == b.Security && + a.CheckOption == b.CheckOption && + EqualsTableName(a.ViewName, b.ViewName) && + EqualsColumns(a.Columns, b.Columns) && + EqualsSelectStatement(a.Select, b.Select) +} + // CloneRefOfCreateTable creates a deep clone of the input. func CloneRefOfCreateTable(n *CreateTable) *CreateTable { if n == nil { @@ -1045,6 +3260,22 @@ func CloneRefOfCreateTable(n *CreateTable) *CreateTable { return &out } +// EqualsRefOfCreateTable creates a deep clone of the input. +func EqualsRefOfCreateTable(a, b *CreateTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Temp == b.Temp && + a.IfNotExists == b.IfNotExists && + a.FullyParsed == b.FullyParsed && + EqualsTableName(a.Table, b.Table) && + EqualsRefOfTableSpec(a.TableSpec, b.TableSpec) && + EqualsRefOfOptLike(a.OptLike, b.OptLike) +} + // CloneRefOfCreateView creates a deep clone of the input. func CloneRefOfCreateView(n *CreateView) *CreateView { if n == nil { @@ -1057,6 +3288,24 @@ func CloneRefOfCreateView(n *CreateView) *CreateView { return &out } +// EqualsRefOfCreateView creates a deep clone of the input. +func EqualsRefOfCreateView(a, b *CreateView) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Algorithm == b.Algorithm && + a.Definer == b.Definer && + a.Security == b.Security && + a.CheckOption == b.CheckOption && + a.IsReplace == b.IsReplace && + EqualsTableName(a.ViewName, b.ViewName) && + EqualsColumns(a.Columns, b.Columns) && + EqualsSelectStatement(a.Select, b.Select) +} + // CloneRefOfDropTable creates a deep clone of the input. func CloneRefOfDropTable(n *DropTable) *DropTable { if n == nil { @@ -1067,6 +3316,19 @@ func CloneRefOfDropTable(n *DropTable) *DropTable { return &out } +// EqualsRefOfDropTable creates a deep clone of the input. +func EqualsRefOfDropTable(a, b *DropTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Temp == b.Temp && + a.IfExists == b.IfExists && + EqualsTableNames(a.FromTables, b.FromTables) +} + // CloneRefOfDropView creates a deep clone of the input. func CloneRefOfDropView(n *DropView) *DropView { if n == nil { @@ -1077,6 +3339,18 @@ func CloneRefOfDropView(n *DropView) *DropView { return &out } +// EqualsRefOfDropView creates a deep clone of the input. +func EqualsRefOfDropView(a, b *DropView) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.IfExists == b.IfExists && + EqualsTableNames(a.FromTables, b.FromTables) +} + // CloneRefOfRenameTable creates a deep clone of the input. func CloneRefOfRenameTable(n *RenameTable) *RenameTable { if n == nil { @@ -1087,6 +3361,17 @@ func CloneRefOfRenameTable(n *RenameTable) *RenameTable { return &out } +// EqualsRefOfRenameTable creates a deep clone of the input. +func EqualsRefOfRenameTable(a, b *RenameTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSliceOfRefOfRenameTablePair(a.TablePairs, b.TablePairs) +} + // CloneRefOfTruncateTable creates a deep clone of the input. func CloneRefOfTruncateTable(n *TruncateTable) *TruncateTable { if n == nil { @@ -1097,6 +3382,17 @@ func CloneRefOfTruncateTable(n *TruncateTable) *TruncateTable { return &out } +// EqualsRefOfTruncateTable creates a deep clone of the input. +func EqualsRefOfTruncateTable(a, b *TruncateTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.Table, b.Table) +} + // CloneRefOfExplainStmt creates a deep clone of the input. func CloneRefOfExplainStmt(n *ExplainStmt) *ExplainStmt { if n == nil { @@ -1107,6 +3403,18 @@ func CloneRefOfExplainStmt(n *ExplainStmt) *ExplainStmt { return &out } +// EqualsRefOfExplainStmt creates a deep clone of the input. +func EqualsRefOfExplainStmt(a, b *ExplainStmt) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + EqualsStatement(a.Statement, b.Statement) +} + // CloneRefOfExplainTab creates a deep clone of the input. func CloneRefOfExplainTab(n *ExplainTab) *ExplainTab { if n == nil { @@ -1117,6 +3425,18 @@ func CloneRefOfExplainTab(n *ExplainTab) *ExplainTab { return &out } +// EqualsRefOfExplainTab creates a deep clone of the input. +func EqualsRefOfExplainTab(a, b *ExplainTab) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Wild == b.Wild && + EqualsTableName(a.Table, b.Table) +} + // CloneRefOfAndExpr creates a deep clone of the input. func CloneRefOfAndExpr(n *AndExpr) *AndExpr { if n == nil { @@ -1128,6 +3448,18 @@ func CloneRefOfAndExpr(n *AndExpr) *AndExpr { return &out } +// EqualsRefOfAndExpr creates a deep clone of the input. +func EqualsRefOfAndExpr(a, b *AndExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.Right, b.Right) +} + // CloneRefOfBinaryExpr creates a deep clone of the input. func CloneRefOfBinaryExpr(n *BinaryExpr) *BinaryExpr { if n == nil { @@ -1139,6 +3471,19 @@ func CloneRefOfBinaryExpr(n *BinaryExpr) *BinaryExpr { return &out } +// EqualsRefOfBinaryExpr creates a deep clone of the input. +func EqualsRefOfBinaryExpr(a, b *BinaryExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Operator == b.Operator && + EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.Right, b.Right) +} + // CloneRefOfCaseExpr creates a deep clone of the input. func CloneRefOfCaseExpr(n *CaseExpr) *CaseExpr { if n == nil { @@ -1151,11 +3496,36 @@ func CloneRefOfCaseExpr(n *CaseExpr) *CaseExpr { return &out } +// EqualsRefOfCaseExpr creates a deep clone of the input. +func EqualsRefOfCaseExpr(a, b *CaseExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) && + EqualsSliceOfRefOfWhen(a.Whens, b.Whens) && + EqualsExpr(a.Else, b.Else) +} + // CloneRefOfColName creates a deep clone of the input. func CloneRefOfColName(n *ColName) *ColName { return n } +// EqualsRefOfColName creates a deep clone of the input. +func EqualsRefOfColName(a, b *ColName) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) && + EqualsTableName(a.Qualifier, b.Qualifier) +} + // CloneRefOfCollateExpr creates a deep clone of the input. func CloneRefOfCollateExpr(n *CollateExpr) *CollateExpr { if n == nil { @@ -1166,6 +3536,18 @@ func CloneRefOfCollateExpr(n *CollateExpr) *CollateExpr { return &out } +// EqualsRefOfCollateExpr creates a deep clone of the input. +func EqualsRefOfCollateExpr(a, b *CollateExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Charset == b.Charset && + EqualsExpr(a.Expr, b.Expr) +} + // CloneRefOfComparisonExpr creates a deep clone of the input. func CloneRefOfComparisonExpr(n *ComparisonExpr) *ComparisonExpr { if n == nil { @@ -1178,6 +3560,20 @@ func CloneRefOfComparisonExpr(n *ComparisonExpr) *ComparisonExpr { return &out } +// EqualsRefOfComparisonExpr creates a deep clone of the input. +func EqualsRefOfComparisonExpr(a, b *ComparisonExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Operator == b.Operator && + EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.Right, b.Right) && + EqualsExpr(a.Escape, b.Escape) +} + // CloneRefOfConvertExpr creates a deep clone of the input. func CloneRefOfConvertExpr(n *ConvertExpr) *ConvertExpr { if n == nil { @@ -1189,6 +3585,18 @@ func CloneRefOfConvertExpr(n *ConvertExpr) *ConvertExpr { return &out } +// EqualsRefOfConvertExpr creates a deep clone of the input. +func EqualsRefOfConvertExpr(a, b *ConvertExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) && + EqualsRefOfConvertType(a.Type, b.Type) +} + // CloneRefOfConvertUsingExpr creates a deep clone of the input. func CloneRefOfConvertUsingExpr(n *ConvertUsingExpr) *ConvertUsingExpr { if n == nil { @@ -1199,6 +3607,18 @@ func CloneRefOfConvertUsingExpr(n *ConvertUsingExpr) *ConvertUsingExpr { return &out } +// EqualsRefOfConvertUsingExpr creates a deep clone of the input. +func EqualsRefOfConvertUsingExpr(a, b *ConvertUsingExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + EqualsExpr(a.Expr, b.Expr) +} + // CloneRefOfCurTimeFuncExpr creates a deep clone of the input. func CloneRefOfCurTimeFuncExpr(n *CurTimeFuncExpr) *CurTimeFuncExpr { if n == nil { @@ -1210,6 +3630,18 @@ func CloneRefOfCurTimeFuncExpr(n *CurTimeFuncExpr) *CurTimeFuncExpr { return &out } +// EqualsRefOfCurTimeFuncExpr creates a deep clone of the input. +func EqualsRefOfCurTimeFuncExpr(a, b *CurTimeFuncExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) && + EqualsExpr(a.Fsp, b.Fsp) +} + // CloneRefOfDefault creates a deep clone of the input. func CloneRefOfDefault(n *Default) *Default { if n == nil { @@ -1219,6 +3651,17 @@ func CloneRefOfDefault(n *Default) *Default { return &out } +// EqualsRefOfDefault creates a deep clone of the input. +func EqualsRefOfDefault(a, b *Default) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.ColName == b.ColName +} + // CloneRefOfExistsExpr creates a deep clone of the input. func CloneRefOfExistsExpr(n *ExistsExpr) *ExistsExpr { if n == nil { @@ -1229,6 +3672,17 @@ func CloneRefOfExistsExpr(n *ExistsExpr) *ExistsExpr { return &out } +// EqualsRefOfExistsExpr creates a deep clone of the input. +func EqualsRefOfExistsExpr(a, b *ExistsExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfSubquery(a.Subquery, b.Subquery) +} + // CloneRefOfFuncExpr creates a deep clone of the input. func CloneRefOfFuncExpr(n *FuncExpr) *FuncExpr { if n == nil { @@ -1241,6 +3695,20 @@ func CloneRefOfFuncExpr(n *FuncExpr) *FuncExpr { return &out } +// EqualsRefOfFuncExpr creates a deep clone of the input. +func EqualsRefOfFuncExpr(a, b *FuncExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Distinct == b.Distinct && + EqualsTableIdent(a.Qualifier, b.Qualifier) && + EqualsColIdent(a.Name, b.Name) && + EqualsSelectExprs(a.Exprs, b.Exprs) +} + // CloneRefOfGroupConcatExpr creates a deep clone of the input. func CloneRefOfGroupConcatExpr(n *GroupConcatExpr) *GroupConcatExpr { if n == nil { @@ -1253,6 +3721,21 @@ func CloneRefOfGroupConcatExpr(n *GroupConcatExpr) *GroupConcatExpr { return &out } +// EqualsRefOfGroupConcatExpr creates a deep clone of the input. +func EqualsRefOfGroupConcatExpr(a, b *GroupConcatExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Distinct == b.Distinct && + a.Separator == b.Separator && + EqualsSelectExprs(a.Exprs, b.Exprs) && + EqualsOrderBy(a.OrderBy, b.OrderBy) && + EqualsRefOfLimit(a.Limit, b.Limit) +} + // CloneRefOfIntervalExpr creates a deep clone of the input. func CloneRefOfIntervalExpr(n *IntervalExpr) *IntervalExpr { if n == nil { @@ -1263,6 +3746,18 @@ func CloneRefOfIntervalExpr(n *IntervalExpr) *IntervalExpr { return &out } +// EqualsRefOfIntervalExpr creates a deep clone of the input. +func EqualsRefOfIntervalExpr(a, b *IntervalExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Unit == b.Unit && + EqualsExpr(a.Expr, b.Expr) +} + // CloneRefOfIsExpr creates a deep clone of the input. func CloneRefOfIsExpr(n *IsExpr) *IsExpr { if n == nil { @@ -1273,6 +3768,18 @@ func CloneRefOfIsExpr(n *IsExpr) *IsExpr { return &out } +// EqualsRefOfIsExpr creates a deep clone of the input. +func EqualsRefOfIsExpr(a, b *IsExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Operator == b.Operator && + EqualsExpr(a.Expr, b.Expr) +} + // CloneRefOfLiteral creates a deep clone of the input. func CloneRefOfLiteral(n *Literal) *Literal { if n == nil { @@ -1282,6 +3789,18 @@ func CloneRefOfLiteral(n *Literal) *Literal { return &out } +// EqualsRefOfLiteral creates a deep clone of the input. +func EqualsRefOfLiteral(a, b *Literal) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Val == b.Val && + a.Type == b.Type +} + // CloneRefOfMatchExpr creates a deep clone of the input. func CloneRefOfMatchExpr(n *MatchExpr) *MatchExpr { if n == nil { @@ -1293,6 +3812,19 @@ func CloneRefOfMatchExpr(n *MatchExpr) *MatchExpr { return &out } +// EqualsRefOfMatchExpr creates a deep clone of the input. +func EqualsRefOfMatchExpr(a, b *MatchExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSelectExprs(a.Columns, b.Columns) && + EqualsExpr(a.Expr, b.Expr) && + a.Option == b.Option +} + // CloneRefOfNotExpr creates a deep clone of the input. func CloneRefOfNotExpr(n *NotExpr) *NotExpr { if n == nil { @@ -1303,6 +3835,17 @@ func CloneRefOfNotExpr(n *NotExpr) *NotExpr { return &out } +// EqualsRefOfNotExpr creates a deep clone of the input. +func EqualsRefOfNotExpr(a, b *NotExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) +} + // CloneRefOfNullVal creates a deep clone of the input. func CloneRefOfNullVal(n *NullVal) *NullVal { if n == nil { @@ -1312,6 +3855,17 @@ func CloneRefOfNullVal(n *NullVal) *NullVal { return &out } +// EqualsRefOfNullVal creates a deep clone of the input. +func EqualsRefOfNullVal(a, b *NullVal) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + // CloneRefOfOrExpr creates a deep clone of the input. func CloneRefOfOrExpr(n *OrExpr) *OrExpr { if n == nil { @@ -1323,6 +3877,18 @@ func CloneRefOfOrExpr(n *OrExpr) *OrExpr { return &out } +// EqualsRefOfOrExpr creates a deep clone of the input. +func EqualsRefOfOrExpr(a, b *OrExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.Right, b.Right) +} + // CloneRefOfRangeCond creates a deep clone of the input. func CloneRefOfRangeCond(n *RangeCond) *RangeCond { if n == nil { @@ -1335,6 +3901,20 @@ func CloneRefOfRangeCond(n *RangeCond) *RangeCond { return &out } +// EqualsRefOfRangeCond creates a deep clone of the input. +func EqualsRefOfRangeCond(a, b *RangeCond) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Operator == b.Operator && + EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.From, b.From) && + EqualsExpr(a.To, b.To) +} + // CloneRefOfSubstrExpr creates a deep clone of the input. func CloneRefOfSubstrExpr(n *SubstrExpr) *SubstrExpr { if n == nil { @@ -1348,6 +3928,20 @@ func CloneRefOfSubstrExpr(n *SubstrExpr) *SubstrExpr { return &out } +// EqualsRefOfSubstrExpr creates a deep clone of the input. +func EqualsRefOfSubstrExpr(a, b *SubstrExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColName(a.Name, b.Name) && + EqualsRefOfLiteral(a.StrVal, b.StrVal) && + EqualsExpr(a.From, b.From) && + EqualsExpr(a.To, b.To) +} + // CloneRefOfTimestampFuncExpr creates a deep clone of the input. func CloneRefOfTimestampFuncExpr(n *TimestampFuncExpr) *TimestampFuncExpr { if n == nil { @@ -1359,6 +3953,20 @@ func CloneRefOfTimestampFuncExpr(n *TimestampFuncExpr) *TimestampFuncExpr { return &out } +// EqualsRefOfTimestampFuncExpr creates a deep clone of the input. +func EqualsRefOfTimestampFuncExpr(a, b *TimestampFuncExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Name == b.Name && + a.Unit == b.Unit && + EqualsExpr(a.Expr1, b.Expr1) && + EqualsExpr(a.Expr2, b.Expr2) +} + // CloneRefOfUnaryExpr creates a deep clone of the input. func CloneRefOfUnaryExpr(n *UnaryExpr) *UnaryExpr { if n == nil { @@ -1369,6 +3977,18 @@ func CloneRefOfUnaryExpr(n *UnaryExpr) *UnaryExpr { return &out } +// EqualsRefOfUnaryExpr creates a deep clone of the input. +func EqualsRefOfUnaryExpr(a, b *UnaryExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Operator == b.Operator && + EqualsExpr(a.Expr, b.Expr) +} + // CloneRefOfValuesFuncExpr creates a deep clone of the input. func CloneRefOfValuesFuncExpr(n *ValuesFuncExpr) *ValuesFuncExpr { if n == nil { @@ -1379,6 +3999,17 @@ func CloneRefOfValuesFuncExpr(n *ValuesFuncExpr) *ValuesFuncExpr { return &out } +// EqualsRefOfValuesFuncExpr creates a deep clone of the input. +func EqualsRefOfValuesFuncExpr(a, b *ValuesFuncExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColName(a.Name, b.Name) +} + // CloneRefOfXorExpr creates a deep clone of the input. func CloneRefOfXorExpr(n *XorExpr) *XorExpr { if n == nil { @@ -1390,6 +4021,18 @@ func CloneRefOfXorExpr(n *XorExpr) *XorExpr { return &out } +// EqualsRefOfXorExpr creates a deep clone of the input. +func EqualsRefOfXorExpr(a, b *XorExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Left, b.Left) && + EqualsExpr(a.Right, b.Right) +} + // CloneRefOfParenSelect creates a deep clone of the input. func CloneRefOfParenSelect(n *ParenSelect) *ParenSelect { if n == nil { @@ -1400,6 +4043,17 @@ func CloneRefOfParenSelect(n *ParenSelect) *ParenSelect { return &out } +// EqualsRefOfParenSelect creates a deep clone of the input. +func EqualsRefOfParenSelect(a, b *ParenSelect) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSelectStatement(a.Select, b.Select) +} + // CloneRefOfSelect creates a deep clone of the input. func CloneRefOfSelect(n *Select) *Select { if n == nil { @@ -1419,6 +4073,30 @@ func CloneRefOfSelect(n *Select) *Select { return &out } +// EqualsRefOfSelect creates a deep clone of the input. +func EqualsRefOfSelect(a, b *Select) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Distinct == b.Distinct && + a.StraightJoinHint == b.StraightJoinHint && + a.SQLCalcFoundRows == b.SQLCalcFoundRows && + EqualsRefOfBool(a.Cache, b.Cache) && + EqualsComments(a.Comments, b.Comments) && + EqualsSelectExprs(a.SelectExprs, b.SelectExprs) && + EqualsTableExprs(a.From, b.From) && + EqualsRefOfWhere(a.Where, b.Where) && + EqualsGroupBy(a.GroupBy, b.GroupBy) && + EqualsRefOfWhere(a.Having, b.Having) && + EqualsOrderBy(a.OrderBy, b.OrderBy) && + EqualsRefOfLimit(a.Limit, b.Limit) && + a.Lock == b.Lock && + EqualsRefOfSelectInto(a.Into, b.Into) +} + // CloneRefOfUnion creates a deep clone of the input. func CloneRefOfUnion(n *Union) *Union { if n == nil { @@ -1432,6 +4110,21 @@ func CloneRefOfUnion(n *Union) *Union { return &out } +// EqualsRefOfUnion creates a deep clone of the input. +func EqualsRefOfUnion(a, b *Union) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSelectStatement(a.FirstStatement, b.FirstStatement) && + EqualsSliceOfRefOfUnionSelect(a.UnionSelects, b.UnionSelects) && + EqualsOrderBy(a.OrderBy, b.OrderBy) && + EqualsRefOfLimit(a.Limit, b.Limit) && + a.Lock == b.Lock +} + // CloneValues creates a deep clone of the input. func CloneValues(n Values) Values { res := make(Values, 0, len(n)) @@ -1441,6 +4134,19 @@ func CloneValues(n Values) Values { return res } +// EqualsValues creates a deep clone of the input. +func EqualsValues(a, b Values) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsValTuple(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfAliasedExpr creates a deep clone of the input. func CloneRefOfAliasedExpr(n *AliasedExpr) *AliasedExpr { if n == nil { @@ -1452,6 +4158,18 @@ func CloneRefOfAliasedExpr(n *AliasedExpr) *AliasedExpr { return &out } +// EqualsRefOfAliasedExpr creates a deep clone of the input. +func EqualsRefOfAliasedExpr(a, b *AliasedExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) && + EqualsColIdent(a.As, b.As) +} + // CloneRefOfAliasedTableExpr creates a deep clone of the input. func CloneRefOfAliasedTableExpr(n *AliasedTableExpr) *AliasedTableExpr { if n == nil { @@ -1465,6 +4183,20 @@ func CloneRefOfAliasedTableExpr(n *AliasedTableExpr) *AliasedTableExpr { return &out } +// EqualsRefOfAliasedTableExpr creates a deep clone of the input. +func EqualsRefOfAliasedTableExpr(a, b *AliasedTableExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSimpleTableExpr(a.Expr, b.Expr) && + EqualsPartitions(a.Partitions, b.Partitions) && + EqualsTableIdent(a.As, b.As) && + EqualsRefOfIndexHints(a.Hints, b.Hints) +} + // CloneRefOfAlterVschema creates a deep clone of the input. func CloneRefOfAlterVschema(n *AlterVschema) *AlterVschema { if n == nil { @@ -1478,6 +4210,21 @@ func CloneRefOfAlterVschema(n *AlterVschema) *AlterVschema { return &out } +// EqualsRefOfAlterVschema creates a deep clone of the input. +func EqualsRefOfAlterVschema(a, b *AlterVschema) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Action == b.Action && + EqualsTableName(a.Table, b.Table) && + EqualsRefOfVindexSpec(a.VindexSpec, b.VindexSpec) && + EqualsSliceOfColIdent(a.VindexCols, b.VindexCols) && + EqualsRefOfAutoIncSpec(a.AutoIncSpec, b.AutoIncSpec) +} + // CloneRefOfAutoIncSpec creates a deep clone of the input. func CloneRefOfAutoIncSpec(n *AutoIncSpec) *AutoIncSpec { if n == nil { @@ -1489,6 +4236,18 @@ func CloneRefOfAutoIncSpec(n *AutoIncSpec) *AutoIncSpec { return &out } +// EqualsRefOfAutoIncSpec creates a deep clone of the input. +func EqualsRefOfAutoIncSpec(a, b *AutoIncSpec) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Column, b.Column) && + EqualsTableName(a.Sequence, b.Sequence) +} + // CloneRefOfBegin creates a deep clone of the input. func CloneRefOfBegin(n *Begin) *Begin { if n == nil { @@ -1498,6 +4257,17 @@ func CloneRefOfBegin(n *Begin) *Begin { return &out } +// EqualsRefOfBegin creates a deep clone of the input. +func EqualsRefOfBegin(a, b *Begin) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + // CloneRefOfCallProc creates a deep clone of the input. func CloneRefOfCallProc(n *CallProc) *CallProc { if n == nil { @@ -1509,11 +4279,30 @@ func CloneRefOfCallProc(n *CallProc) *CallProc { return &out } +// EqualsRefOfCallProc creates a deep clone of the input. +func EqualsRefOfCallProc(a, b *CallProc) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.Name, b.Name) && + EqualsExprs(a.Params, b.Params) +} + // CloneColIdent creates a deep clone of the input. func CloneColIdent(n ColIdent) ColIdent { return *CloneRefOfColIdent(&n) } +// EqualsColIdent creates a deep clone of the input. +func EqualsColIdent(a, b ColIdent) bool { + return a.val == b.val && + a.lowered == b.lowered && + a.at == b.at +} + // CloneRefOfColumnDefinition creates a deep clone of the input. func CloneRefOfColumnDefinition(n *ColumnDefinition) *ColumnDefinition { if n == nil { @@ -1525,6 +4314,18 @@ func CloneRefOfColumnDefinition(n *ColumnDefinition) *ColumnDefinition { return &out } +// EqualsRefOfColumnDefinition creates a deep clone of the input. +func EqualsRefOfColumnDefinition(a, b *ColumnDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) && + EqualsColumnType(a.Type, b.Type) +} + // CloneRefOfColumnType creates a deep clone of the input. func CloneRefOfColumnType(n *ColumnType) *ColumnType { if n == nil { @@ -1538,6 +4339,25 @@ func CloneRefOfColumnType(n *ColumnType) *ColumnType { return &out } +// EqualsRefOfColumnType creates a deep clone of the input. +func EqualsRefOfColumnType(a, b *ColumnType) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + a.Unsigned == b.Unsigned && + a.Zerofill == b.Zerofill && + a.Charset == b.Charset && + a.Collate == b.Collate && + EqualsRefOfColumnTypeOptions(a.Options, b.Options) && + EqualsRefOfLiteral(a.Length, b.Length) && + EqualsRefOfLiteral(a.Scale, b.Scale) && + EqualsSliceOfString(a.EnumValues, b.EnumValues) +} + // CloneColumns creates a deep clone of the input. func CloneColumns(n Columns) Columns { res := make(Columns, 0, len(n)) @@ -1547,6 +4367,19 @@ func CloneColumns(n Columns) Columns { return res } +// EqualsColumns creates a deep clone of the input. +func EqualsColumns(a, b Columns) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsColIdent(a[i], b[i]) { + return false + } + } + return true +} + // CloneComments creates a deep clone of the input. func CloneComments(n Comments) Comments { res := make(Comments, 0, len(n)) @@ -1554,6 +4387,19 @@ func CloneComments(n Comments) Comments { return res } +// EqualsComments creates a deep clone of the input. +func EqualsComments(a, b Comments) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + return true +} + // CloneRefOfCommit creates a deep clone of the input. func CloneRefOfCommit(n *Commit) *Commit { if n == nil { @@ -1563,6 +4409,17 @@ func CloneRefOfCommit(n *Commit) *Commit { return &out } +// EqualsRefOfCommit creates a deep clone of the input. +func EqualsRefOfCommit(a, b *Commit) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + // CloneRefOfConstraintDefinition creates a deep clone of the input. func CloneRefOfConstraintDefinition(n *ConstraintDefinition) *ConstraintDefinition { if n == nil { @@ -1573,6 +4430,18 @@ func CloneRefOfConstraintDefinition(n *ConstraintDefinition) *ConstraintDefiniti return &out } +// EqualsRefOfConstraintDefinition creates a deep clone of the input. +func EqualsRefOfConstraintDefinition(a, b *ConstraintDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Name == b.Name && + EqualsConstraintInfo(a.Details, b.Details) +} + // CloneRefOfConvertType creates a deep clone of the input. func CloneRefOfConvertType(n *ConvertType) *ConvertType { if n == nil { @@ -1584,6 +4453,21 @@ func CloneRefOfConvertType(n *ConvertType) *ConvertType { return &out } +// EqualsRefOfConvertType creates a deep clone of the input. +func EqualsRefOfConvertType(a, b *ConvertType) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + a.Charset == b.Charset && + EqualsRefOfLiteral(a.Length, b.Length) && + EqualsRefOfLiteral(a.Scale, b.Scale) && + a.Operator == b.Operator +} + // CloneRefOfDelete creates a deep clone of the input. func CloneRefOfDelete(n *Delete) *Delete { if n == nil { @@ -1600,6 +4484,24 @@ func CloneRefOfDelete(n *Delete) *Delete { return &out } +// EqualsRefOfDelete creates a deep clone of the input. +func EqualsRefOfDelete(a, b *Delete) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Ignore == b.Ignore && + EqualsComments(a.Comments, b.Comments) && + EqualsTableNames(a.Targets, b.Targets) && + EqualsTableExprs(a.TableExprs, b.TableExprs) && + EqualsPartitions(a.Partitions, b.Partitions) && + EqualsRefOfWhere(a.Where, b.Where) && + EqualsOrderBy(a.OrderBy, b.OrderBy) && + EqualsRefOfLimit(a.Limit, b.Limit) +} + // CloneRefOfDerivedTable creates a deep clone of the input. func CloneRefOfDerivedTable(n *DerivedTable) *DerivedTable { if n == nil { @@ -1610,6 +4512,17 @@ func CloneRefOfDerivedTable(n *DerivedTable) *DerivedTable { return &out } +// EqualsRefOfDerivedTable creates a deep clone of the input. +func EqualsRefOfDerivedTable(a, b *DerivedTable) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSelectStatement(a.Select, b.Select) +} + // CloneExprs creates a deep clone of the input. func CloneExprs(n Exprs) Exprs { res := make(Exprs, 0, len(n)) @@ -1619,6 +4532,19 @@ func CloneExprs(n Exprs) Exprs { return res } +// EqualsExprs creates a deep clone of the input. +func EqualsExprs(a, b Exprs) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsExpr(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfFlush creates a deep clone of the input. func CloneRefOfFlush(n *Flush) *Flush { if n == nil { @@ -1630,6 +4556,21 @@ func CloneRefOfFlush(n *Flush) *Flush { return &out } +// EqualsRefOfFlush creates a deep clone of the input. +func EqualsRefOfFlush(a, b *Flush) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.IsLocal == b.IsLocal && + a.WithLock == b.WithLock && + a.ForExport == b.ForExport && + EqualsSliceOfString(a.FlushOptions, b.FlushOptions) && + EqualsTableNames(a.TableNames, b.TableNames) +} + // CloneGroupBy creates a deep clone of the input. func CloneGroupBy(n GroupBy) GroupBy { res := make(GroupBy, 0, len(n)) @@ -1639,6 +4580,19 @@ func CloneGroupBy(n GroupBy) GroupBy { return res } +// EqualsGroupBy creates a deep clone of the input. +func EqualsGroupBy(a, b GroupBy) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsExpr(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfIndexDefinition creates a deep clone of the input. func CloneRefOfIndexDefinition(n *IndexDefinition) *IndexDefinition { if n == nil { @@ -1651,6 +4605,19 @@ func CloneRefOfIndexDefinition(n *IndexDefinition) *IndexDefinition { return &out } +// EqualsRefOfIndexDefinition creates a deep clone of the input. +func EqualsRefOfIndexDefinition(a, b *IndexDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfIndexInfo(a.Info, b.Info) && + EqualsSliceOfRefOfIndexColumn(a.Columns, b.Columns) && + EqualsSliceOfRefOfIndexOption(a.Options, b.Options) +} + // CloneRefOfIndexHints creates a deep clone of the input. func CloneRefOfIndexHints(n *IndexHints) *IndexHints { if n == nil { @@ -1661,6 +4628,18 @@ func CloneRefOfIndexHints(n *IndexHints) *IndexHints { return &out } +// EqualsRefOfIndexHints creates a deep clone of the input. +func EqualsRefOfIndexHints(a, b *IndexHints) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + EqualsSliceOfColIdent(a.Indexes, b.Indexes) +} + // CloneRefOfIndexInfo creates a deep clone of the input. func CloneRefOfIndexInfo(n *IndexInfo) *IndexInfo { if n == nil { @@ -1672,6 +4651,23 @@ func CloneRefOfIndexInfo(n *IndexInfo) *IndexInfo { return &out } +// EqualsRefOfIndexInfo creates a deep clone of the input. +func EqualsRefOfIndexInfo(a, b *IndexInfo) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + a.Primary == b.Primary && + a.Spatial == b.Spatial && + a.Fulltext == b.Fulltext && + a.Unique == b.Unique && + EqualsColIdent(a.Name, b.Name) && + EqualsColIdent(a.ConstraintName, b.ConstraintName) +} + // CloneRefOfInsert creates a deep clone of the input. func CloneRefOfInsert(n *Insert) *Insert { if n == nil { @@ -1687,11 +4683,35 @@ func CloneRefOfInsert(n *Insert) *Insert { return &out } +// EqualsRefOfInsert creates a deep clone of the input. +func EqualsRefOfInsert(a, b *Insert) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Action == b.Action && + EqualsComments(a.Comments, b.Comments) && + a.Ignore == b.Ignore && + EqualsTableName(a.Table, b.Table) && + EqualsPartitions(a.Partitions, b.Partitions) && + EqualsColumns(a.Columns, b.Columns) && + EqualsInsertRows(a.Rows, b.Rows) && + EqualsOnDup(a.OnDup, b.OnDup) +} + // CloneJoinCondition creates a deep clone of the input. func CloneJoinCondition(n JoinCondition) JoinCondition { return *CloneRefOfJoinCondition(&n) } +// EqualsJoinCondition creates a deep clone of the input. +func EqualsJoinCondition(a, b JoinCondition) bool { + return EqualsExpr(a.On, b.On) && + EqualsColumns(a.Using, b.Using) +} + // CloneRefOfJoinTableExpr creates a deep clone of the input. func CloneRefOfJoinTableExpr(n *JoinTableExpr) *JoinTableExpr { if n == nil { @@ -1704,6 +4724,20 @@ func CloneRefOfJoinTableExpr(n *JoinTableExpr) *JoinTableExpr { return &out } +// EqualsRefOfJoinTableExpr creates a deep clone of the input. +func EqualsRefOfJoinTableExpr(a, b *JoinTableExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableExpr(a.LeftExpr, b.LeftExpr) && + a.Join == b.Join && + EqualsTableExpr(a.RightExpr, b.RightExpr) && + EqualsJoinCondition(a.Condition, b.Condition) +} + // CloneRefOfLimit creates a deep clone of the input. func CloneRefOfLimit(n *Limit) *Limit { if n == nil { @@ -1715,6 +4749,18 @@ func CloneRefOfLimit(n *Limit) *Limit { return &out } +// EqualsRefOfLimit creates a deep clone of the input. +func EqualsRefOfLimit(a, b *Limit) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Offset, b.Offset) && + EqualsExpr(a.Rowcount, b.Rowcount) +} + // CloneRefOfLoad creates a deep clone of the input. func CloneRefOfLoad(n *Load) *Load { if n == nil { @@ -1724,6 +4770,17 @@ func CloneRefOfLoad(n *Load) *Load { return &out } +// EqualsRefOfLoad creates a deep clone of the input. +func EqualsRefOfLoad(a, b *Load) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + // CloneRefOfLockTables creates a deep clone of the input. func CloneRefOfLockTables(n *LockTables) *LockTables { if n == nil { @@ -1734,6 +4791,17 @@ func CloneRefOfLockTables(n *LockTables) *LockTables { return &out } +// EqualsRefOfLockTables creates a deep clone of the input. +func EqualsRefOfLockTables(a, b *LockTables) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableAndLockTypes(a.Tables, b.Tables) +} + // CloneRefOfNextval creates a deep clone of the input. func CloneRefOfNextval(n *Nextval) *Nextval { if n == nil { @@ -1744,6 +4812,17 @@ func CloneRefOfNextval(n *Nextval) *Nextval { return &out } +// EqualsRefOfNextval creates a deep clone of the input. +func EqualsRefOfNextval(a, b *Nextval) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) +} + // CloneOnDup creates a deep clone of the input. func CloneOnDup(n OnDup) OnDup { res := make(OnDup, 0, len(n)) @@ -1753,6 +4832,19 @@ func CloneOnDup(n OnDup) OnDup { return res } +// EqualsOnDup creates a deep clone of the input. +func EqualsOnDup(a, b OnDup) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfUpdateExpr(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfOptLike creates a deep clone of the input. func CloneRefOfOptLike(n *OptLike) *OptLike { if n == nil { @@ -1763,6 +4855,17 @@ func CloneRefOfOptLike(n *OptLike) *OptLike { return &out } +// EqualsRefOfOptLike creates a deep clone of the input. +func EqualsRefOfOptLike(a, b *OptLike) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.LikeTable, b.LikeTable) +} + // CloneRefOfOrder creates a deep clone of the input. func CloneRefOfOrder(n *Order) *Order { if n == nil { @@ -1773,6 +4876,18 @@ func CloneRefOfOrder(n *Order) *Order { return &out } +// EqualsRefOfOrder creates a deep clone of the input. +func EqualsRefOfOrder(a, b *Order) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Expr, b.Expr) && + a.Direction == b.Direction +} + // CloneOrderBy creates a deep clone of the input. func CloneOrderBy(n OrderBy) OrderBy { res := make(OrderBy, 0, len(n)) @@ -1782,6 +4897,19 @@ func CloneOrderBy(n OrderBy) OrderBy { return res } +// EqualsOrderBy creates a deep clone of the input. +func EqualsOrderBy(a, b OrderBy) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfOrder(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfOtherAdmin creates a deep clone of the input. func CloneRefOfOtherAdmin(n *OtherAdmin) *OtherAdmin { if n == nil { @@ -1791,6 +4919,17 @@ func CloneRefOfOtherAdmin(n *OtherAdmin) *OtherAdmin { return &out } +// EqualsRefOfOtherAdmin creates a deep clone of the input. +func EqualsRefOfOtherAdmin(a, b *OtherAdmin) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + // CloneRefOfOtherRead creates a deep clone of the input. func CloneRefOfOtherRead(n *OtherRead) *OtherRead { if n == nil { @@ -1800,6 +4939,17 @@ func CloneRefOfOtherRead(n *OtherRead) *OtherRead { return &out } +// EqualsRefOfOtherRead creates a deep clone of the input. +func EqualsRefOfOtherRead(a, b *OtherRead) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + // CloneRefOfParenTableExpr creates a deep clone of the input. func CloneRefOfParenTableExpr(n *ParenTableExpr) *ParenTableExpr { if n == nil { @@ -1810,6 +4960,17 @@ func CloneRefOfParenTableExpr(n *ParenTableExpr) *ParenTableExpr { return &out } +// EqualsRefOfParenTableExpr creates a deep clone of the input. +func EqualsRefOfParenTableExpr(a, b *ParenTableExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableExprs(a.Exprs, b.Exprs) +} + // CloneRefOfPartitionDefinition creates a deep clone of the input. func CloneRefOfPartitionDefinition(n *PartitionDefinition) *PartitionDefinition { if n == nil { @@ -1821,6 +4982,19 @@ func CloneRefOfPartitionDefinition(n *PartitionDefinition) *PartitionDefinition return &out } +// EqualsRefOfPartitionDefinition creates a deep clone of the input. +func EqualsRefOfPartitionDefinition(a, b *PartitionDefinition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Maxvalue == b.Maxvalue && + EqualsColIdent(a.Name, b.Name) && + EqualsExpr(a.Limit, b.Limit) +} + // CloneRefOfPartitionSpec creates a deep clone of the input. func CloneRefOfPartitionSpec(n *PartitionSpec) *PartitionSpec { if n == nil { @@ -1834,6 +5008,23 @@ func CloneRefOfPartitionSpec(n *PartitionSpec) *PartitionSpec { return &out } +// EqualsRefOfPartitionSpec creates a deep clone of the input. +func EqualsRefOfPartitionSpec(a, b *PartitionSpec) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.IsAll == b.IsAll && + a.WithoutValidation == b.WithoutValidation && + a.Action == b.Action && + EqualsPartitions(a.Names, b.Names) && + EqualsRefOfLiteral(a.Number, b.Number) && + EqualsTableName(a.TableName, b.TableName) && + EqualsSliceOfRefOfPartitionDefinition(a.Definitions, b.Definitions) +} + // ClonePartitions creates a deep clone of the input. func ClonePartitions(n Partitions) Partitions { res := make(Partitions, 0, len(n)) @@ -1843,6 +5034,19 @@ func ClonePartitions(n Partitions) Partitions { return res } +// EqualsPartitions creates a deep clone of the input. +func EqualsPartitions(a, b Partitions) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsColIdent(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfRelease creates a deep clone of the input. func CloneRefOfRelease(n *Release) *Release { if n == nil { @@ -1853,6 +5057,17 @@ func CloneRefOfRelease(n *Release) *Release { return &out } +// EqualsRefOfRelease creates a deep clone of the input. +func EqualsRefOfRelease(a, b *Release) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) +} + // CloneRefOfRollback creates a deep clone of the input. func CloneRefOfRollback(n *Rollback) *Rollback { if n == nil { @@ -1862,6 +5077,17 @@ func CloneRefOfRollback(n *Rollback) *Rollback { return &out } +// EqualsRefOfRollback creates a deep clone of the input. +func EqualsRefOfRollback(a, b *Rollback) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + // CloneRefOfSRollback creates a deep clone of the input. func CloneRefOfSRollback(n *SRollback) *SRollback { if n == nil { @@ -1872,6 +5098,17 @@ func CloneRefOfSRollback(n *SRollback) *SRollback { return &out } +// EqualsRefOfSRollback creates a deep clone of the input. +func EqualsRefOfSRollback(a, b *SRollback) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) +} + // CloneRefOfSavepoint creates a deep clone of the input. func CloneRefOfSavepoint(n *Savepoint) *Savepoint { if n == nil { @@ -1882,6 +5119,17 @@ func CloneRefOfSavepoint(n *Savepoint) *Savepoint { return &out } +// EqualsRefOfSavepoint creates a deep clone of the input. +func EqualsRefOfSavepoint(a, b *Savepoint) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) +} + // CloneSelectExprs creates a deep clone of the input. func CloneSelectExprs(n SelectExprs) SelectExprs { res := make(SelectExprs, 0, len(n)) @@ -1891,6 +5139,19 @@ func CloneSelectExprs(n SelectExprs) SelectExprs { return res } +// EqualsSelectExprs creates a deep clone of the input. +func EqualsSelectExprs(a, b SelectExprs) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsSelectExpr(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfSelectInto creates a deep clone of the input. func CloneRefOfSelectInto(n *SelectInto) *SelectInto { if n == nil { @@ -1900,6 +5161,23 @@ func CloneRefOfSelectInto(n *SelectInto) *SelectInto { return &out } +// EqualsRefOfSelectInto creates a deep clone of the input. +func EqualsRefOfSelectInto(a, b *SelectInto) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.FileName == b.FileName && + a.Charset == b.Charset && + a.FormatOption == b.FormatOption && + a.ExportOption == b.ExportOption && + a.Manifest == b.Manifest && + a.Overwrite == b.Overwrite && + a.Type == b.Type +} + // CloneRefOfSet creates a deep clone of the input. func CloneRefOfSet(n *Set) *Set { if n == nil { @@ -1911,6 +5189,18 @@ func CloneRefOfSet(n *Set) *Set { return &out } +// EqualsRefOfSet creates a deep clone of the input. +func EqualsRefOfSet(a, b *Set) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsComments(a.Comments, b.Comments) && + EqualsSetExprs(a.Exprs, b.Exprs) +} + // CloneRefOfSetExpr creates a deep clone of the input. func CloneRefOfSetExpr(n *SetExpr) *SetExpr { if n == nil { @@ -1922,6 +5212,19 @@ func CloneRefOfSetExpr(n *SetExpr) *SetExpr { return &out } +// EqualsRefOfSetExpr creates a deep clone of the input. +func EqualsRefOfSetExpr(a, b *SetExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Scope == b.Scope && + EqualsColIdent(a.Name, b.Name) && + EqualsExpr(a.Expr, b.Expr) +} + // CloneSetExprs creates a deep clone of the input. func CloneSetExprs(n SetExprs) SetExprs { res := make(SetExprs, 0, len(n)) @@ -1931,6 +5234,19 @@ func CloneSetExprs(n SetExprs) SetExprs { return res } +// EqualsSetExprs creates a deep clone of the input. +func EqualsSetExprs(a, b SetExprs) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfSetExpr(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfSetTransaction creates a deep clone of the input. func CloneRefOfSetTransaction(n *SetTransaction) *SetTransaction { if n == nil { @@ -1943,6 +5259,20 @@ func CloneRefOfSetTransaction(n *SetTransaction) *SetTransaction { return &out } +// EqualsRefOfSetTransaction creates a deep clone of the input. +func EqualsRefOfSetTransaction(a, b *SetTransaction) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSQLNode(a.SQLNode, b.SQLNode) && + EqualsComments(a.Comments, b.Comments) && + a.Scope == b.Scope && + EqualsSliceOfCharacteristic(a.Characteristics, b.Characteristics) +} + // CloneRefOfShow creates a deep clone of the input. func CloneRefOfShow(n *Show) *Show { if n == nil { @@ -1953,6 +5283,17 @@ func CloneRefOfShow(n *Show) *Show { return &out } +// EqualsRefOfShow creates a deep clone of the input. +func EqualsRefOfShow(a, b *Show) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsShowInternal(a.Internal, b.Internal) +} + // CloneRefOfShowBasic creates a deep clone of the input. func CloneRefOfShowBasic(n *ShowBasic) *ShowBasic { if n == nil { @@ -1964,6 +5305,21 @@ func CloneRefOfShowBasic(n *ShowBasic) *ShowBasic { return &out } +// EqualsRefOfShowBasic creates a deep clone of the input. +func EqualsRefOfShowBasic(a, b *ShowBasic) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Full == b.Full && + a.DbName == b.DbName && + a.Command == b.Command && + EqualsTableName(a.Tbl, b.Tbl) && + EqualsRefOfShowFilter(a.Filter, b.Filter) +} + // CloneRefOfShowCreate creates a deep clone of the input. func CloneRefOfShowCreate(n *ShowCreate) *ShowCreate { if n == nil { @@ -1974,6 +5330,18 @@ func CloneRefOfShowCreate(n *ShowCreate) *ShowCreate { return &out } +// EqualsRefOfShowCreate creates a deep clone of the input. +func EqualsRefOfShowCreate(a, b *ShowCreate) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Command == b.Command && + EqualsTableName(a.Op, b.Op) +} + // CloneRefOfShowFilter creates a deep clone of the input. func CloneRefOfShowFilter(n *ShowFilter) *ShowFilter { if n == nil { @@ -1984,6 +5352,18 @@ func CloneRefOfShowFilter(n *ShowFilter) *ShowFilter { return &out } +// EqualsRefOfShowFilter creates a deep clone of the input. +func EqualsRefOfShowFilter(a, b *ShowFilter) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Like == b.Like && + EqualsExpr(a.Filter, b.Filter) +} + // CloneRefOfShowLegacy creates a deep clone of the input. func CloneRefOfShowLegacy(n *ShowLegacy) *ShowLegacy { if n == nil { @@ -1997,6 +5377,23 @@ func CloneRefOfShowLegacy(n *ShowLegacy) *ShowLegacy { return &out } +// EqualsRefOfShowLegacy creates a deep clone of the input. +func EqualsRefOfShowLegacy(a, b *ShowLegacy) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Extended == b.Extended && + a.Type == b.Type && + EqualsTableName(a.OnTable, b.OnTable) && + EqualsTableName(a.Table, b.Table) && + EqualsRefOfShowTablesOpt(a.ShowTablesOpt, b.ShowTablesOpt) && + a.Scope == b.Scope && + EqualsExpr(a.ShowCollationFilterOpt, b.ShowCollationFilterOpt) +} + // CloneRefOfStarExpr creates a deep clone of the input. func CloneRefOfStarExpr(n *StarExpr) *StarExpr { if n == nil { @@ -2007,6 +5404,17 @@ func CloneRefOfStarExpr(n *StarExpr) *StarExpr { return &out } +// EqualsRefOfStarExpr creates a deep clone of the input. +func EqualsRefOfStarExpr(a, b *StarExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.TableName, b.TableName) +} + // CloneRefOfStream creates a deep clone of the input. func CloneRefOfStream(n *Stream) *Stream { if n == nil { @@ -2019,6 +5427,19 @@ func CloneRefOfStream(n *Stream) *Stream { return &out } +// EqualsRefOfStream creates a deep clone of the input. +func EqualsRefOfStream(a, b *Stream) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsComments(a.Comments, b.Comments) && + EqualsSelectExpr(a.SelectExpr, b.SelectExpr) && + EqualsTableName(a.Table, b.Table) +} + // CloneTableExprs creates a deep clone of the input. func CloneTableExprs(n TableExprs) TableExprs { res := make(TableExprs, 0, len(n)) @@ -2028,16 +5449,40 @@ func CloneTableExprs(n TableExprs) TableExprs { return res } +// EqualsTableExprs creates a deep clone of the input. +func EqualsTableExprs(a, b TableExprs) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsTableExpr(a[i], b[i]) { + return false + } + } + return true +} + // CloneTableIdent creates a deep clone of the input. func CloneTableIdent(n TableIdent) TableIdent { return *CloneRefOfTableIdent(&n) } +// EqualsTableIdent creates a deep clone of the input. +func EqualsTableIdent(a, b TableIdent) bool { + return a.v == b.v +} + // CloneTableName creates a deep clone of the input. func CloneTableName(n TableName) TableName { return *CloneRefOfTableName(&n) } +// EqualsTableName creates a deep clone of the input. +func EqualsTableName(a, b TableName) bool { + return EqualsTableIdent(a.Name, b.Name) && + EqualsTableIdent(a.Qualifier, b.Qualifier) +} + // CloneTableNames creates a deep clone of the input. func CloneTableNames(n TableNames) TableNames { res := make(TableNames, 0, len(n)) @@ -2047,6 +5492,19 @@ func CloneTableNames(n TableNames) TableNames { return res } +// EqualsTableNames creates a deep clone of the input. +func EqualsTableNames(a, b TableNames) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsTableName(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfTableSpec creates a deep clone of the input. func CloneRefOfTableSpec(n *TableSpec) *TableSpec { if n == nil { @@ -2060,6 +5518,20 @@ func CloneRefOfTableSpec(n *TableSpec) *TableSpec { return &out } +// EqualsRefOfTableSpec creates a deep clone of the input. +func EqualsRefOfTableSpec(a, b *TableSpec) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsSliceOfRefOfColumnDefinition(a.Columns, b.Columns) && + EqualsSliceOfRefOfIndexDefinition(a.Indexes, b.Indexes) && + EqualsSliceOfRefOfConstraintDefinition(a.Constraints, b.Constraints) && + EqualsTableOptions(a.Options, b.Options) +} + // CloneRefOfUnionSelect creates a deep clone of the input. func CloneRefOfUnionSelect(n *UnionSelect) *UnionSelect { if n == nil { @@ -2070,6 +5542,18 @@ func CloneRefOfUnionSelect(n *UnionSelect) *UnionSelect { return &out } +// EqualsRefOfUnionSelect creates a deep clone of the input. +func EqualsRefOfUnionSelect(a, b *UnionSelect) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Distinct == b.Distinct && + EqualsSelectStatement(a.Statement, b.Statement) +} + // CloneRefOfUnlockTables creates a deep clone of the input. func CloneRefOfUnlockTables(n *UnlockTables) *UnlockTables { if n == nil { @@ -2079,6 +5563,17 @@ func CloneRefOfUnlockTables(n *UnlockTables) *UnlockTables { return &out } +// EqualsRefOfUnlockTables creates a deep clone of the input. +func EqualsRefOfUnlockTables(a, b *UnlockTables) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return true +} + // CloneRefOfUpdate creates a deep clone of the input. func CloneRefOfUpdate(n *Update) *Update { if n == nil { @@ -2094,6 +5589,23 @@ func CloneRefOfUpdate(n *Update) *Update { return &out } +// EqualsRefOfUpdate creates a deep clone of the input. +func EqualsRefOfUpdate(a, b *Update) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsComments(a.Comments, b.Comments) && + a.Ignore == b.Ignore && + EqualsTableExprs(a.TableExprs, b.TableExprs) && + EqualsUpdateExprs(a.Exprs, b.Exprs) && + EqualsRefOfWhere(a.Where, b.Where) && + EqualsOrderBy(a.OrderBy, b.OrderBy) && + EqualsRefOfLimit(a.Limit, b.Limit) +} + // CloneRefOfUpdateExpr creates a deep clone of the input. func CloneRefOfUpdateExpr(n *UpdateExpr) *UpdateExpr { if n == nil { @@ -2105,6 +5617,18 @@ func CloneRefOfUpdateExpr(n *UpdateExpr) *UpdateExpr { return &out } +// EqualsRefOfUpdateExpr creates a deep clone of the input. +func EqualsRefOfUpdateExpr(a, b *UpdateExpr) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsRefOfColName(a.Name, b.Name) && + EqualsExpr(a.Expr, b.Expr) +} + // CloneUpdateExprs creates a deep clone of the input. func CloneUpdateExprs(n UpdateExprs) UpdateExprs { res := make(UpdateExprs, 0, len(n)) @@ -2114,6 +5638,19 @@ func CloneUpdateExprs(n UpdateExprs) UpdateExprs { return res } +// EqualsUpdateExprs creates a deep clone of the input. +func EqualsUpdateExprs(a, b UpdateExprs) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfUpdateExpr(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfUse creates a deep clone of the input. func CloneRefOfUse(n *Use) *Use { if n == nil { @@ -2124,6 +5661,17 @@ func CloneRefOfUse(n *Use) *Use { return &out } +// EqualsRefOfUse creates a deep clone of the input. +func EqualsRefOfUse(a, b *Use) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableIdent(a.DBName, b.DBName) +} + // CloneRefOfVStream creates a deep clone of the input. func CloneRefOfVStream(n *VStream) *VStream { if n == nil { @@ -2138,11 +5686,32 @@ func CloneRefOfVStream(n *VStream) *VStream { return &out } +// EqualsRefOfVStream creates a deep clone of the input. +func EqualsRefOfVStream(a, b *VStream) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsComments(a.Comments, b.Comments) && + EqualsSelectExpr(a.SelectExpr, b.SelectExpr) && + EqualsTableName(a.Table, b.Table) && + EqualsRefOfWhere(a.Where, b.Where) && + EqualsRefOfLimit(a.Limit, b.Limit) +} + // CloneVindexParam creates a deep clone of the input. func CloneVindexParam(n VindexParam) VindexParam { return *CloneRefOfVindexParam(&n) } +// EqualsVindexParam creates a deep clone of the input. +func EqualsVindexParam(a, b VindexParam) bool { + return a.Val == b.Val && + EqualsColIdent(a.Key, b.Key) +} + // CloneRefOfVindexSpec creates a deep clone of the input. func CloneRefOfVindexSpec(n *VindexSpec) *VindexSpec { if n == nil { @@ -2155,6 +5724,19 @@ func CloneRefOfVindexSpec(n *VindexSpec) *VindexSpec { return &out } +// EqualsRefOfVindexSpec creates a deep clone of the input. +func EqualsRefOfVindexSpec(a, b *VindexSpec) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Name, b.Name) && + EqualsColIdent(a.Type, b.Type) && + EqualsSliceOfVindexParam(a.Params, b.Params) +} + // CloneRefOfWhen creates a deep clone of the input. func CloneRefOfWhen(n *When) *When { if n == nil { @@ -2166,6 +5748,18 @@ func CloneRefOfWhen(n *When) *When { return &out } +// EqualsRefOfWhen creates a deep clone of the input. +func EqualsRefOfWhen(a, b *When) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.Cond, b.Cond) && + EqualsExpr(a.Val, b.Val) +} + // CloneRefOfWhere creates a deep clone of the input. func CloneRefOfWhere(n *Where) *Where { if n == nil { @@ -2176,6 +5770,18 @@ func CloneRefOfWhere(n *Where) *Where { return &out } +// EqualsRefOfWhere creates a deep clone of the input. +func EqualsRefOfWhere(a, b *Where) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Type == b.Type && + EqualsExpr(a.Expr, b.Expr) +} + // CloneSliceOfRefOfColumnDefinition creates a deep clone of the input. func CloneSliceOfRefOfColumnDefinition(n []*ColumnDefinition) []*ColumnDefinition { res := make([]*ColumnDefinition, 0, len(n)) @@ -2185,6 +5791,19 @@ func CloneSliceOfRefOfColumnDefinition(n []*ColumnDefinition) []*ColumnDefinitio return res } +// EqualsSliceOfRefOfColumnDefinition creates a deep clone of the input. +func EqualsSliceOfRefOfColumnDefinition(a, b []*ColumnDefinition) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfColumnDefinition(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfTableOption creates a deep clone of the input. func CloneRefOfTableOption(n *TableOption) *TableOption { if n == nil { @@ -2196,6 +5815,20 @@ func CloneRefOfTableOption(n *TableOption) *TableOption { return &out } +// EqualsRefOfTableOption creates a deep clone of the input. +func EqualsRefOfTableOption(a, b *TableOption) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Name == b.Name && + a.String == b.String && + EqualsRefOfLiteral(a.Value, b.Value) && + EqualsTableNames(a.Tables, b.Tables) +} + // CloneSliceOfCollateAndCharset creates a deep clone of the input. func CloneSliceOfCollateAndCharset(n []CollateAndCharset) []CollateAndCharset { res := make([]CollateAndCharset, 0, len(n)) @@ -2205,6 +5838,19 @@ func CloneSliceOfCollateAndCharset(n []CollateAndCharset) []CollateAndCharset { return res } +// EqualsSliceOfCollateAndCharset creates a deep clone of the input. +func EqualsSliceOfCollateAndCharset(a, b []CollateAndCharset) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsCollateAndCharset(a[i], b[i]) { + return false + } + } + return true +} + // CloneSliceOfAlterOption creates a deep clone of the input. func CloneSliceOfAlterOption(n []AlterOption) []AlterOption { res := make([]AlterOption, 0, len(n)) @@ -2214,6 +5860,19 @@ func CloneSliceOfAlterOption(n []AlterOption) []AlterOption { return res } +// EqualsSliceOfAlterOption creates a deep clone of the input. +func EqualsSliceOfAlterOption(a, b []AlterOption) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsAlterOption(a[i], b[i]) { + return false + } + } + return true +} + // CloneSliceOfRefOfRenameTablePair creates a deep clone of the input. func CloneSliceOfRefOfRenameTablePair(n []*RenameTablePair) []*RenameTablePair { res := make([]*RenameTablePair, 0, len(n)) @@ -2223,6 +5882,19 @@ func CloneSliceOfRefOfRenameTablePair(n []*RenameTablePair) []*RenameTablePair { return res } +// EqualsSliceOfRefOfRenameTablePair creates a deep clone of the input. +func EqualsSliceOfRefOfRenameTablePair(a, b []*RenameTablePair) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfRenameTablePair(a[i], b[i]) { + return false + } + } + return true +} + // CloneSliceOfRefOfWhen creates a deep clone of the input. func CloneSliceOfRefOfWhen(n []*When) []*When { res := make([]*When, 0, len(n)) @@ -2232,6 +5904,30 @@ func CloneSliceOfRefOfWhen(n []*When) []*When { return res } +// EqualsSliceOfRefOfWhen creates a deep clone of the input. +func EqualsSliceOfRefOfWhen(a, b []*When) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfWhen(a[i], b[i]) { + return false + } + } + return true +} + +// EqualsRefOfBool creates a deep clone of the input. +func EqualsRefOfBool(a, b *bool) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return *a == *b +} + // CloneRefOfBool creates a deep clone of the input. func CloneRefOfBool(n *bool) *bool { if n == nil { @@ -2250,6 +5946,19 @@ func CloneSliceOfRefOfUnionSelect(n []*UnionSelect) []*UnionSelect { return res } +// EqualsSliceOfRefOfUnionSelect creates a deep clone of the input. +func EqualsSliceOfRefOfUnionSelect(a, b []*UnionSelect) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfUnionSelect(a[i], b[i]) { + return false + } + } + return true +} + // CloneSliceOfColIdent creates a deep clone of the input. func CloneSliceOfColIdent(n []ColIdent) []ColIdent { res := make([]ColIdent, 0, len(n)) @@ -2259,6 +5968,19 @@ func CloneSliceOfColIdent(n []ColIdent) []ColIdent { return res } +// EqualsSliceOfColIdent creates a deep clone of the input. +func EqualsSliceOfColIdent(a, b []ColIdent) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsColIdent(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfColIdent creates a deep clone of the input. func CloneRefOfColIdent(n *ColIdent) *ColIdent { if n == nil { @@ -2268,11 +5990,37 @@ func CloneRefOfColIdent(n *ColIdent) *ColIdent { return &out } +// EqualsRefOfColIdent creates a deep clone of the input. +func EqualsRefOfColIdent(a, b *ColIdent) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.val == b.val && + a.lowered == b.lowered && + a.at == b.at +} + // CloneColumnType creates a deep clone of the input. func CloneColumnType(n ColumnType) ColumnType { return *CloneRefOfColumnType(&n) } +// EqualsColumnType creates a deep clone of the input. +func EqualsColumnType(a, b ColumnType) bool { + return a.Type == b.Type && + a.Unsigned == b.Unsigned && + a.Zerofill == b.Zerofill && + a.Charset == b.Charset && + a.Collate == b.Collate && + EqualsRefOfColumnTypeOptions(a.Options, b.Options) && + EqualsRefOfLiteral(a.Length, b.Length) && + EqualsRefOfLiteral(a.Scale, b.Scale) && + EqualsSliceOfString(a.EnumValues, b.EnumValues) +} + // CloneRefOfColumnTypeOptions creates a deep clone of the input. func CloneRefOfColumnTypeOptions(n *ColumnTypeOptions) *ColumnTypeOptions { if n == nil { @@ -2285,6 +6033,22 @@ func CloneRefOfColumnTypeOptions(n *ColumnTypeOptions) *ColumnTypeOptions { return &out } +// EqualsRefOfColumnTypeOptions creates a deep clone of the input. +func EqualsRefOfColumnTypeOptions(a, b *ColumnTypeOptions) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.NotNull == b.NotNull && + a.Autoincrement == b.Autoincrement && + EqualsExpr(a.Default, b.Default) && + EqualsExpr(a.OnUpdate, b.OnUpdate) && + EqualsRefOfLiteral(a.Comment, b.Comment) && + a.KeyOpt == b.KeyOpt +} + // CloneSliceOfString creates a deep clone of the input. func CloneSliceOfString(n []string) []string { res := make([]string, 0, len(n)) @@ -2292,6 +6056,19 @@ func CloneSliceOfString(n []string) []string { return res } +// EqualsSliceOfString creates a deep clone of the input. +func EqualsSliceOfString(a, b []string) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + return true +} + // CloneSliceOfRefOfIndexColumn creates a deep clone of the input. func CloneSliceOfRefOfIndexColumn(n []*IndexColumn) []*IndexColumn { res := make([]*IndexColumn, 0, len(n)) @@ -2301,6 +6078,19 @@ func CloneSliceOfRefOfIndexColumn(n []*IndexColumn) []*IndexColumn { return res } +// EqualsSliceOfRefOfIndexColumn creates a deep clone of the input. +func EqualsSliceOfRefOfIndexColumn(a, b []*IndexColumn) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfIndexColumn(a[i], b[i]) { + return false + } + } + return true +} + // CloneSliceOfRefOfIndexOption creates a deep clone of the input. func CloneSliceOfRefOfIndexOption(n []*IndexOption) []*IndexOption { res := make([]*IndexOption, 0, len(n)) @@ -2310,6 +6100,19 @@ func CloneSliceOfRefOfIndexOption(n []*IndexOption) []*IndexOption { return res } +// EqualsSliceOfRefOfIndexOption creates a deep clone of the input. +func EqualsSliceOfRefOfIndexOption(a, b []*IndexOption) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfIndexOption(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfJoinCondition creates a deep clone of the input. func CloneRefOfJoinCondition(n *JoinCondition) *JoinCondition { if n == nil { @@ -2321,6 +6124,18 @@ func CloneRefOfJoinCondition(n *JoinCondition) *JoinCondition { return &out } +// EqualsRefOfJoinCondition creates a deep clone of the input. +func EqualsRefOfJoinCondition(a, b *JoinCondition) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsExpr(a.On, b.On) && + EqualsColumns(a.Using, b.Using) +} + // CloneTableAndLockTypes creates a deep clone of the input. func CloneTableAndLockTypes(n TableAndLockTypes) TableAndLockTypes { res := make(TableAndLockTypes, 0, len(n)) @@ -2330,6 +6145,19 @@ func CloneTableAndLockTypes(n TableAndLockTypes) TableAndLockTypes { return res } +// EqualsTableAndLockTypes creates a deep clone of the input. +func EqualsTableAndLockTypes(a, b TableAndLockTypes) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfTableAndLockType(a[i], b[i]) { + return false + } + } + return true +} + // CloneSliceOfRefOfPartitionDefinition creates a deep clone of the input. func CloneSliceOfRefOfPartitionDefinition(n []*PartitionDefinition) []*PartitionDefinition { res := make([]*PartitionDefinition, 0, len(n)) @@ -2339,6 +6167,19 @@ func CloneSliceOfRefOfPartitionDefinition(n []*PartitionDefinition) []*Partition return res } +// EqualsSliceOfRefOfPartitionDefinition creates a deep clone of the input. +func EqualsSliceOfRefOfPartitionDefinition(a, b []*PartitionDefinition) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfPartitionDefinition(a[i], b[i]) { + return false + } + } + return true +} + // CloneSliceOfCharacteristic creates a deep clone of the input. func CloneSliceOfCharacteristic(n []Characteristic) []Characteristic { res := make([]Characteristic, 0, len(n)) @@ -2348,6 +6189,19 @@ func CloneSliceOfCharacteristic(n []Characteristic) []Characteristic { return res } +// EqualsSliceOfCharacteristic creates a deep clone of the input. +func EqualsSliceOfCharacteristic(a, b []Characteristic) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsCharacteristic(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfShowTablesOpt creates a deep clone of the input. func CloneRefOfShowTablesOpt(n *ShowTablesOpt) *ShowTablesOpt { if n == nil { @@ -2358,6 +6212,19 @@ func CloneRefOfShowTablesOpt(n *ShowTablesOpt) *ShowTablesOpt { return &out } +// EqualsRefOfShowTablesOpt creates a deep clone of the input. +func EqualsRefOfShowTablesOpt(a, b *ShowTablesOpt) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Full == b.Full && + a.DbName == b.DbName && + EqualsRefOfShowFilter(a.Filter, b.Filter) +} + // CloneRefOfTableIdent creates a deep clone of the input. func CloneRefOfTableIdent(n *TableIdent) *TableIdent { if n == nil { @@ -2367,6 +6234,17 @@ func CloneRefOfTableIdent(n *TableIdent) *TableIdent { return &out } +// EqualsRefOfTableIdent creates a deep clone of the input. +func EqualsRefOfTableIdent(a, b *TableIdent) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.v == b.v +} + // CloneRefOfTableName creates a deep clone of the input. func CloneRefOfTableName(n *TableName) *TableName { if n == nil { @@ -2378,6 +6256,18 @@ func CloneRefOfTableName(n *TableName) *TableName { return &out } +// EqualsRefOfTableName creates a deep clone of the input. +func EqualsRefOfTableName(a, b *TableName) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableIdent(a.Name, b.Name) && + EqualsTableIdent(a.Qualifier, b.Qualifier) +} + // CloneSliceOfRefOfIndexDefinition creates a deep clone of the input. func CloneSliceOfRefOfIndexDefinition(n []*IndexDefinition) []*IndexDefinition { res := make([]*IndexDefinition, 0, len(n)) @@ -2387,6 +6277,19 @@ func CloneSliceOfRefOfIndexDefinition(n []*IndexDefinition) []*IndexDefinition { return res } +// EqualsSliceOfRefOfIndexDefinition creates a deep clone of the input. +func EqualsSliceOfRefOfIndexDefinition(a, b []*IndexDefinition) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfIndexDefinition(a[i], b[i]) { + return false + } + } + return true +} + // CloneSliceOfRefOfConstraintDefinition creates a deep clone of the input. func CloneSliceOfRefOfConstraintDefinition(n []*ConstraintDefinition) []*ConstraintDefinition { res := make([]*ConstraintDefinition, 0, len(n)) @@ -2396,6 +6299,19 @@ func CloneSliceOfRefOfConstraintDefinition(n []*ConstraintDefinition) []*Constra return res } +// EqualsSliceOfRefOfConstraintDefinition creates a deep clone of the input. +func EqualsSliceOfRefOfConstraintDefinition(a, b []*ConstraintDefinition) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsRefOfConstraintDefinition(a[i], b[i]) { + return false + } + } + return true +} + // CloneRefOfVindexParam creates a deep clone of the input. func CloneRefOfVindexParam(n *VindexParam) *VindexParam { if n == nil { @@ -2406,6 +6322,18 @@ func CloneRefOfVindexParam(n *VindexParam) *VindexParam { return &out } +// EqualsRefOfVindexParam creates a deep clone of the input. +func EqualsRefOfVindexParam(a, b *VindexParam) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Val == b.Val && + EqualsColIdent(a.Key, b.Key) +} + // CloneSliceOfVindexParam creates a deep clone of the input. func CloneSliceOfVindexParam(n []VindexParam) []VindexParam { res := make([]VindexParam, 0, len(n)) @@ -2415,11 +6343,31 @@ func CloneSliceOfVindexParam(n []VindexParam) []VindexParam { return res } +// EqualsSliceOfVindexParam creates a deep clone of the input. +func EqualsSliceOfVindexParam(a, b []VindexParam) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if !EqualsVindexParam(a[i], b[i]) { + return false + } + } + return true +} + // CloneCollateAndCharset creates a deep clone of the input. func CloneCollateAndCharset(n CollateAndCharset) CollateAndCharset { return *CloneRefOfCollateAndCharset(&n) } +// EqualsCollateAndCharset creates a deep clone of the input. +func EqualsCollateAndCharset(a, b CollateAndCharset) bool { + return a.IsDefault == b.IsDefault && + a.Value == b.Value && + a.Type == b.Type +} + // CloneRefOfRenameTablePair creates a deep clone of the input. func CloneRefOfRenameTablePair(n *RenameTablePair) *RenameTablePair { if n == nil { @@ -2431,6 +6379,18 @@ func CloneRefOfRenameTablePair(n *RenameTablePair) *RenameTablePair { return &out } +// EqualsRefOfRenameTablePair creates a deep clone of the input. +func EqualsRefOfRenameTablePair(a, b *RenameTablePair) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableName(a.FromTable, b.FromTable) && + EqualsTableName(a.ToTable, b.ToTable) +} + // CloneRefOfIndexColumn creates a deep clone of the input. func CloneRefOfIndexColumn(n *IndexColumn) *IndexColumn { if n == nil { @@ -2442,6 +6402,19 @@ func CloneRefOfIndexColumn(n *IndexColumn) *IndexColumn { return &out } +// EqualsRefOfIndexColumn creates a deep clone of the input. +func EqualsRefOfIndexColumn(a, b *IndexColumn) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsColIdent(a.Column, b.Column) && + EqualsRefOfLiteral(a.Length, b.Length) && + a.Direction == b.Direction +} + // CloneRefOfIndexOption creates a deep clone of the input. func CloneRefOfIndexOption(n *IndexOption) *IndexOption { if n == nil { @@ -2452,6 +6425,19 @@ func CloneRefOfIndexOption(n *IndexOption) *IndexOption { return &out } +// EqualsRefOfIndexOption creates a deep clone of the input. +func EqualsRefOfIndexOption(a, b *IndexOption) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.Name == b.Name && + a.String == b.String && + EqualsRefOfLiteral(a.Value, b.Value) +} + // CloneRefOfTableAndLockType creates a deep clone of the input. func CloneRefOfTableAndLockType(n *TableAndLockType) *TableAndLockType { if n == nil { @@ -2462,6 +6448,18 @@ func CloneRefOfTableAndLockType(n *TableAndLockType) *TableAndLockType { return &out } +// EqualsRefOfTableAndLockType creates a deep clone of the input. +func EqualsRefOfTableAndLockType(a, b *TableAndLockType) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return EqualsTableExpr(a.Table, b.Table) && + a.Lock == b.Lock +} + // CloneRefOfCollateAndCharset creates a deep clone of the input. func CloneRefOfCollateAndCharset(n *CollateAndCharset) *CollateAndCharset { if n == nil { @@ -2470,3 +6468,16 @@ func CloneRefOfCollateAndCharset(n *CollateAndCharset) *CollateAndCharset { out := *n return &out } + +// EqualsRefOfCollateAndCharset creates a deep clone of the input. +func EqualsRefOfCollateAndCharset(a, b *CollateAndCharset) bool { + if a == b { + return true + } + if a == nil || b == nil { + return false + } + return a.IsDefault == b.IsDefault && + a.Value == b.Value && + a.Type == b.Type +} diff --git a/go/vt/sqlparser/equals.go b/go/vt/sqlparser/equals.go deleted file mode 100644 index b8b172cf3dd..00000000000 --- a/go/vt/sqlparser/equals.go +++ /dev/null @@ -1,3956 +0,0 @@ -/* -Copyright 2021 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. -*/ -// Code generated by ASTHelperGen. DO NOT EDIT. - -package sqlparser - -// EqualsAlterOption does deep equals. -func EqualsAlterOption(inA, inB AlterOption) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *AddColumns: - b, ok := inB.(*AddColumns) - if !ok { - return false - } - return EqualsRefOfAddColumns(a, b) - case *AddConstraintDefinition: - b, ok := inB.(*AddConstraintDefinition) - if !ok { - return false - } - return EqualsRefOfAddConstraintDefinition(a, b) - case *AddIndexDefinition: - b, ok := inB.(*AddIndexDefinition) - if !ok { - return false - } - return EqualsRefOfAddIndexDefinition(a, b) - case AlgorithmValue: - b, ok := inB.(AlgorithmValue) - if !ok { - return false - } - return a == b - case *AlterCharset: - b, ok := inB.(*AlterCharset) - if !ok { - return false - } - return EqualsRefOfAlterCharset(a, b) - case *AlterColumn: - b, ok := inB.(*AlterColumn) - if !ok { - return false - } - return EqualsRefOfAlterColumn(a, b) - case *ChangeColumn: - b, ok := inB.(*ChangeColumn) - if !ok { - return false - } - return EqualsRefOfChangeColumn(a, b) - case *DropColumn: - b, ok := inB.(*DropColumn) - if !ok { - return false - } - return EqualsRefOfDropColumn(a, b) - case *DropKey: - b, ok := inB.(*DropKey) - if !ok { - return false - } - return EqualsRefOfDropKey(a, b) - case *Force: - b, ok := inB.(*Force) - if !ok { - return false - } - return EqualsRefOfForce(a, b) - case *KeyState: - b, ok := inB.(*KeyState) - if !ok { - return false - } - return EqualsRefOfKeyState(a, b) - case *LockOption: - b, ok := inB.(*LockOption) - if !ok { - return false - } - return EqualsRefOfLockOption(a, b) - case *ModifyColumn: - b, ok := inB.(*ModifyColumn) - if !ok { - return false - } - return EqualsRefOfModifyColumn(a, b) - case *OrderByOption: - b, ok := inB.(*OrderByOption) - if !ok { - return false - } - return EqualsRefOfOrderByOption(a, b) - case *RenameIndex: - b, ok := inB.(*RenameIndex) - if !ok { - return false - } - return EqualsRefOfRenameIndex(a, b) - case *RenameTableName: - b, ok := inB.(*RenameTableName) - if !ok { - return false - } - return EqualsRefOfRenameTableName(a, b) - case TableOptions: - b, ok := inB.(TableOptions) - if !ok { - return false - } - return EqualsTableOptions(a, b) - case *TablespaceOperation: - b, ok := inB.(*TablespaceOperation) - if !ok { - return false - } - return EqualsRefOfTablespaceOperation(a, b) - case *Validation: - b, ok := inB.(*Validation) - if !ok { - return false - } - return EqualsRefOfValidation(a, b) - default: - // this should never happen - return false - } -} - -// EqualsCharacteristic does deep equals. -func EqualsCharacteristic(inA, inB Characteristic) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case AccessMode: - b, ok := inB.(AccessMode) - if !ok { - return false - } - return a == b - case IsolationLevel: - b, ok := inB.(IsolationLevel) - if !ok { - return false - } - return a == b - default: - // this should never happen - return false - } -} - -// EqualsColTuple does deep equals. -func EqualsColTuple(inA, inB ColTuple) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case ListArg: - b, ok := inB.(ListArg) - if !ok { - return false - } - return EqualsListArg(a, b) - case *Subquery: - b, ok := inB.(*Subquery) - if !ok { - return false - } - return EqualsRefOfSubquery(a, b) - case ValTuple: - b, ok := inB.(ValTuple) - if !ok { - return false - } - return EqualsValTuple(a, b) - default: - // this should never happen - return false - } -} - -// EqualsConstraintInfo does deep equals. -func EqualsConstraintInfo(inA, inB ConstraintInfo) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *CheckConstraintDefinition: - b, ok := inB.(*CheckConstraintDefinition) - if !ok { - return false - } - return EqualsRefOfCheckConstraintDefinition(a, b) - case *ForeignKeyDefinition: - b, ok := inB.(*ForeignKeyDefinition) - if !ok { - return false - } - return EqualsRefOfForeignKeyDefinition(a, b) - default: - // this should never happen - return false - } -} - -// EqualsDBDDLStatement does deep equals. -func EqualsDBDDLStatement(inA, inB DBDDLStatement) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *AlterDatabase: - b, ok := inB.(*AlterDatabase) - if !ok { - return false - } - return EqualsRefOfAlterDatabase(a, b) - case *CreateDatabase: - b, ok := inB.(*CreateDatabase) - if !ok { - return false - } - return EqualsRefOfCreateDatabase(a, b) - case *DropDatabase: - b, ok := inB.(*DropDatabase) - if !ok { - return false - } - return EqualsRefOfDropDatabase(a, b) - default: - // this should never happen - return false - } -} - -// EqualsDDLStatement does deep equals. -func EqualsDDLStatement(inA, inB DDLStatement) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *AlterTable: - b, ok := inB.(*AlterTable) - if !ok { - return false - } - return EqualsRefOfAlterTable(a, b) - case *AlterView: - b, ok := inB.(*AlterView) - if !ok { - return false - } - return EqualsRefOfAlterView(a, b) - case *CreateTable: - b, ok := inB.(*CreateTable) - if !ok { - return false - } - return EqualsRefOfCreateTable(a, b) - case *CreateView: - b, ok := inB.(*CreateView) - if !ok { - return false - } - return EqualsRefOfCreateView(a, b) - case *DropTable: - b, ok := inB.(*DropTable) - if !ok { - return false - } - return EqualsRefOfDropTable(a, b) - case *DropView: - b, ok := inB.(*DropView) - if !ok { - return false - } - return EqualsRefOfDropView(a, b) - case *RenameTable: - b, ok := inB.(*RenameTable) - if !ok { - return false - } - return EqualsRefOfRenameTable(a, b) - case *TruncateTable: - b, ok := inB.(*TruncateTable) - if !ok { - return false - } - return EqualsRefOfTruncateTable(a, b) - default: - // this should never happen - return false - } -} - -// EqualsExplain does deep equals. -func EqualsExplain(inA, inB Explain) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *ExplainStmt: - b, ok := inB.(*ExplainStmt) - if !ok { - return false - } - return EqualsRefOfExplainStmt(a, b) - case *ExplainTab: - b, ok := inB.(*ExplainTab) - if !ok { - return false - } - return EqualsRefOfExplainTab(a, b) - default: - // this should never happen - return false - } -} - -// EqualsExpr does deep equals. -func EqualsExpr(inA, inB Expr) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *AndExpr: - b, ok := inB.(*AndExpr) - if !ok { - return false - } - return EqualsRefOfAndExpr(a, b) - case Argument: - b, ok := inB.(Argument) - if !ok { - return false - } - return a == b - case *BinaryExpr: - b, ok := inB.(*BinaryExpr) - if !ok { - return false - } - return EqualsRefOfBinaryExpr(a, b) - case BoolVal: - b, ok := inB.(BoolVal) - if !ok { - return false - } - return a == b - case *CaseExpr: - b, ok := inB.(*CaseExpr) - if !ok { - return false - } - return EqualsRefOfCaseExpr(a, b) - case *ColName: - b, ok := inB.(*ColName) - if !ok { - return false - } - return EqualsRefOfColName(a, b) - case *CollateExpr: - b, ok := inB.(*CollateExpr) - if !ok { - return false - } - return EqualsRefOfCollateExpr(a, b) - case *ComparisonExpr: - b, ok := inB.(*ComparisonExpr) - if !ok { - return false - } - return EqualsRefOfComparisonExpr(a, b) - case *ConvertExpr: - b, ok := inB.(*ConvertExpr) - if !ok { - return false - } - return EqualsRefOfConvertExpr(a, b) - case *ConvertUsingExpr: - b, ok := inB.(*ConvertUsingExpr) - if !ok { - return false - } - return EqualsRefOfConvertUsingExpr(a, b) - case *CurTimeFuncExpr: - b, ok := inB.(*CurTimeFuncExpr) - if !ok { - return false - } - return EqualsRefOfCurTimeFuncExpr(a, b) - case *Default: - b, ok := inB.(*Default) - if !ok { - return false - } - return EqualsRefOfDefault(a, b) - case *ExistsExpr: - b, ok := inB.(*ExistsExpr) - if !ok { - return false - } - return EqualsRefOfExistsExpr(a, b) - case *FuncExpr: - b, ok := inB.(*FuncExpr) - if !ok { - return false - } - return EqualsRefOfFuncExpr(a, b) - case *GroupConcatExpr: - b, ok := inB.(*GroupConcatExpr) - if !ok { - return false - } - return EqualsRefOfGroupConcatExpr(a, b) - case *IntervalExpr: - b, ok := inB.(*IntervalExpr) - if !ok { - return false - } - return EqualsRefOfIntervalExpr(a, b) - case *IsExpr: - b, ok := inB.(*IsExpr) - if !ok { - return false - } - return EqualsRefOfIsExpr(a, b) - case ListArg: - b, ok := inB.(ListArg) - if !ok { - return false - } - return EqualsListArg(a, b) - case *Literal: - b, ok := inB.(*Literal) - if !ok { - return false - } - return EqualsRefOfLiteral(a, b) - case *MatchExpr: - b, ok := inB.(*MatchExpr) - if !ok { - return false - } - return EqualsRefOfMatchExpr(a, b) - case *NotExpr: - b, ok := inB.(*NotExpr) - if !ok { - return false - } - return EqualsRefOfNotExpr(a, b) - case *NullVal: - b, ok := inB.(*NullVal) - if !ok { - return false - } - return EqualsRefOfNullVal(a, b) - case *OrExpr: - b, ok := inB.(*OrExpr) - if !ok { - return false - } - return EqualsRefOfOrExpr(a, b) - case *RangeCond: - b, ok := inB.(*RangeCond) - if !ok { - return false - } - return EqualsRefOfRangeCond(a, b) - case *Subquery: - b, ok := inB.(*Subquery) - if !ok { - return false - } - return EqualsRefOfSubquery(a, b) - case *SubstrExpr: - b, ok := inB.(*SubstrExpr) - if !ok { - return false - } - return EqualsRefOfSubstrExpr(a, b) - case *TimestampFuncExpr: - b, ok := inB.(*TimestampFuncExpr) - if !ok { - return false - } - return EqualsRefOfTimestampFuncExpr(a, b) - case *UnaryExpr: - b, ok := inB.(*UnaryExpr) - if !ok { - return false - } - return EqualsRefOfUnaryExpr(a, b) - case ValTuple: - b, ok := inB.(ValTuple) - if !ok { - return false - } - return EqualsValTuple(a, b) - case *ValuesFuncExpr: - b, ok := inB.(*ValuesFuncExpr) - if !ok { - return false - } - return EqualsRefOfValuesFuncExpr(a, b) - case *XorExpr: - b, ok := inB.(*XorExpr) - if !ok { - return false - } - return EqualsRefOfXorExpr(a, b) - default: - // this should never happen - return false - } -} - -// EqualsInsertRows does deep equals. -func EqualsInsertRows(inA, inB InsertRows) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *ParenSelect: - b, ok := inB.(*ParenSelect) - if !ok { - return false - } - return EqualsRefOfParenSelect(a, b) - case *Select: - b, ok := inB.(*Select) - if !ok { - return false - } - return EqualsRefOfSelect(a, b) - case *Union: - b, ok := inB.(*Union) - if !ok { - return false - } - return EqualsRefOfUnion(a, b) - case Values: - b, ok := inB.(Values) - if !ok { - return false - } - return EqualsValues(a, b) - default: - // this should never happen - return false - } -} - -// EqualsSQLNode does deep equals. -func EqualsSQLNode(inA, inB SQLNode) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case AccessMode: - b, ok := inB.(AccessMode) - if !ok { - return false - } - return a == b - case *AddColumns: - b, ok := inB.(*AddColumns) - if !ok { - return false - } - return EqualsRefOfAddColumns(a, b) - case *AddConstraintDefinition: - b, ok := inB.(*AddConstraintDefinition) - if !ok { - return false - } - return EqualsRefOfAddConstraintDefinition(a, b) - case *AddIndexDefinition: - b, ok := inB.(*AddIndexDefinition) - if !ok { - return false - } - return EqualsRefOfAddIndexDefinition(a, b) - case AlgorithmValue: - b, ok := inB.(AlgorithmValue) - if !ok { - return false - } - return a == b - case *AliasedExpr: - b, ok := inB.(*AliasedExpr) - if !ok { - return false - } - return EqualsRefOfAliasedExpr(a, b) - case *AliasedTableExpr: - b, ok := inB.(*AliasedTableExpr) - if !ok { - return false - } - return EqualsRefOfAliasedTableExpr(a, b) - case *AlterCharset: - b, ok := inB.(*AlterCharset) - if !ok { - return false - } - return EqualsRefOfAlterCharset(a, b) - case *AlterColumn: - b, ok := inB.(*AlterColumn) - if !ok { - return false - } - return EqualsRefOfAlterColumn(a, b) - case *AlterDatabase: - b, ok := inB.(*AlterDatabase) - if !ok { - return false - } - return EqualsRefOfAlterDatabase(a, b) - case *AlterTable: - b, ok := inB.(*AlterTable) - if !ok { - return false - } - return EqualsRefOfAlterTable(a, b) - case *AlterView: - b, ok := inB.(*AlterView) - if !ok { - return false - } - return EqualsRefOfAlterView(a, b) - case *AlterVschema: - b, ok := inB.(*AlterVschema) - if !ok { - return false - } - return EqualsRefOfAlterVschema(a, b) - case *AndExpr: - b, ok := inB.(*AndExpr) - if !ok { - return false - } - return EqualsRefOfAndExpr(a, b) - case Argument: - b, ok := inB.(Argument) - if !ok { - return false - } - return a == b - case *AutoIncSpec: - b, ok := inB.(*AutoIncSpec) - if !ok { - return false - } - return EqualsRefOfAutoIncSpec(a, b) - case *Begin: - b, ok := inB.(*Begin) - if !ok { - return false - } - return EqualsRefOfBegin(a, b) - case *BinaryExpr: - b, ok := inB.(*BinaryExpr) - if !ok { - return false - } - return EqualsRefOfBinaryExpr(a, b) - case BoolVal: - b, ok := inB.(BoolVal) - if !ok { - return false - } - return a == b - case *CallProc: - b, ok := inB.(*CallProc) - if !ok { - return false - } - return EqualsRefOfCallProc(a, b) - case *CaseExpr: - b, ok := inB.(*CaseExpr) - if !ok { - return false - } - return EqualsRefOfCaseExpr(a, b) - case *ChangeColumn: - b, ok := inB.(*ChangeColumn) - if !ok { - return false - } - return EqualsRefOfChangeColumn(a, b) - case *CheckConstraintDefinition: - b, ok := inB.(*CheckConstraintDefinition) - if !ok { - return false - } - return EqualsRefOfCheckConstraintDefinition(a, b) - case ColIdent: - b, ok := inB.(ColIdent) - if !ok { - return false - } - return EqualsColIdent(a, b) - case *ColName: - b, ok := inB.(*ColName) - if !ok { - return false - } - return EqualsRefOfColName(a, b) - case *CollateExpr: - b, ok := inB.(*CollateExpr) - if !ok { - return false - } - return EqualsRefOfCollateExpr(a, b) - case *ColumnDefinition: - b, ok := inB.(*ColumnDefinition) - if !ok { - return false - } - return EqualsRefOfColumnDefinition(a, b) - case *ColumnType: - b, ok := inB.(*ColumnType) - if !ok { - return false - } - return EqualsRefOfColumnType(a, b) - case Columns: - b, ok := inB.(Columns) - if !ok { - return false - } - return EqualsColumns(a, b) - case Comments: - b, ok := inB.(Comments) - if !ok { - return false - } - return EqualsComments(a, b) - case *Commit: - b, ok := inB.(*Commit) - if !ok { - return false - } - return EqualsRefOfCommit(a, b) - case *ComparisonExpr: - b, ok := inB.(*ComparisonExpr) - if !ok { - return false - } - return EqualsRefOfComparisonExpr(a, b) - case *ConstraintDefinition: - b, ok := inB.(*ConstraintDefinition) - if !ok { - return false - } - return EqualsRefOfConstraintDefinition(a, b) - case *ConvertExpr: - b, ok := inB.(*ConvertExpr) - if !ok { - return false - } - return EqualsRefOfConvertExpr(a, b) - case *ConvertType: - b, ok := inB.(*ConvertType) - if !ok { - return false - } - return EqualsRefOfConvertType(a, b) - case *ConvertUsingExpr: - b, ok := inB.(*ConvertUsingExpr) - if !ok { - return false - } - return EqualsRefOfConvertUsingExpr(a, b) - case *CreateDatabase: - b, ok := inB.(*CreateDatabase) - if !ok { - return false - } - return EqualsRefOfCreateDatabase(a, b) - case *CreateTable: - b, ok := inB.(*CreateTable) - if !ok { - return false - } - return EqualsRefOfCreateTable(a, b) - case *CreateView: - b, ok := inB.(*CreateView) - if !ok { - return false - } - return EqualsRefOfCreateView(a, b) - case *CurTimeFuncExpr: - b, ok := inB.(*CurTimeFuncExpr) - if !ok { - return false - } - return EqualsRefOfCurTimeFuncExpr(a, b) - case *Default: - b, ok := inB.(*Default) - if !ok { - return false - } - return EqualsRefOfDefault(a, b) - case *Delete: - b, ok := inB.(*Delete) - if !ok { - return false - } - return EqualsRefOfDelete(a, b) - case *DerivedTable: - b, ok := inB.(*DerivedTable) - if !ok { - return false - } - return EqualsRefOfDerivedTable(a, b) - case *DropColumn: - b, ok := inB.(*DropColumn) - if !ok { - return false - } - return EqualsRefOfDropColumn(a, b) - case *DropDatabase: - b, ok := inB.(*DropDatabase) - if !ok { - return false - } - return EqualsRefOfDropDatabase(a, b) - case *DropKey: - b, ok := inB.(*DropKey) - if !ok { - return false - } - return EqualsRefOfDropKey(a, b) - case *DropTable: - b, ok := inB.(*DropTable) - if !ok { - return false - } - return EqualsRefOfDropTable(a, b) - case *DropView: - b, ok := inB.(*DropView) - if !ok { - return false - } - return EqualsRefOfDropView(a, b) - case *ExistsExpr: - b, ok := inB.(*ExistsExpr) - if !ok { - return false - } - return EqualsRefOfExistsExpr(a, b) - case *ExplainStmt: - b, ok := inB.(*ExplainStmt) - if !ok { - return false - } - return EqualsRefOfExplainStmt(a, b) - case *ExplainTab: - b, ok := inB.(*ExplainTab) - if !ok { - return false - } - return EqualsRefOfExplainTab(a, b) - case Exprs: - b, ok := inB.(Exprs) - if !ok { - return false - } - return EqualsExprs(a, b) - case *Flush: - b, ok := inB.(*Flush) - if !ok { - return false - } - return EqualsRefOfFlush(a, b) - case *Force: - b, ok := inB.(*Force) - if !ok { - return false - } - return EqualsRefOfForce(a, b) - case *ForeignKeyDefinition: - b, ok := inB.(*ForeignKeyDefinition) - if !ok { - return false - } - return EqualsRefOfForeignKeyDefinition(a, b) - case *FuncExpr: - b, ok := inB.(*FuncExpr) - if !ok { - return false - } - return EqualsRefOfFuncExpr(a, b) - case GroupBy: - b, ok := inB.(GroupBy) - if !ok { - return false - } - return EqualsGroupBy(a, b) - case *GroupConcatExpr: - b, ok := inB.(*GroupConcatExpr) - if !ok { - return false - } - return EqualsRefOfGroupConcatExpr(a, b) - case *IndexDefinition: - b, ok := inB.(*IndexDefinition) - if !ok { - return false - } - return EqualsRefOfIndexDefinition(a, b) - case *IndexHints: - b, ok := inB.(*IndexHints) - if !ok { - return false - } - return EqualsRefOfIndexHints(a, b) - case *IndexInfo: - b, ok := inB.(*IndexInfo) - if !ok { - return false - } - return EqualsRefOfIndexInfo(a, b) - case *Insert: - b, ok := inB.(*Insert) - if !ok { - return false - } - return EqualsRefOfInsert(a, b) - case *IntervalExpr: - b, ok := inB.(*IntervalExpr) - if !ok { - return false - } - return EqualsRefOfIntervalExpr(a, b) - case *IsExpr: - b, ok := inB.(*IsExpr) - if !ok { - return false - } - return EqualsRefOfIsExpr(a, b) - case IsolationLevel: - b, ok := inB.(IsolationLevel) - if !ok { - return false - } - return a == b - case JoinCondition: - b, ok := inB.(JoinCondition) - if !ok { - return false - } - return EqualsJoinCondition(a, b) - case *JoinTableExpr: - b, ok := inB.(*JoinTableExpr) - if !ok { - return false - } - return EqualsRefOfJoinTableExpr(a, b) - case *KeyState: - b, ok := inB.(*KeyState) - if !ok { - return false - } - return EqualsRefOfKeyState(a, b) - case *Limit: - b, ok := inB.(*Limit) - if !ok { - return false - } - return EqualsRefOfLimit(a, b) - case ListArg: - b, ok := inB.(ListArg) - if !ok { - return false - } - return EqualsListArg(a, b) - case *Literal: - b, ok := inB.(*Literal) - if !ok { - return false - } - return EqualsRefOfLiteral(a, b) - case *Load: - b, ok := inB.(*Load) - if !ok { - return false - } - return EqualsRefOfLoad(a, b) - case *LockOption: - b, ok := inB.(*LockOption) - if !ok { - return false - } - return EqualsRefOfLockOption(a, b) - case *LockTables: - b, ok := inB.(*LockTables) - if !ok { - return false - } - return EqualsRefOfLockTables(a, b) - case *MatchExpr: - b, ok := inB.(*MatchExpr) - if !ok { - return false - } - return EqualsRefOfMatchExpr(a, b) - case *ModifyColumn: - b, ok := inB.(*ModifyColumn) - if !ok { - return false - } - return EqualsRefOfModifyColumn(a, b) - case *Nextval: - b, ok := inB.(*Nextval) - if !ok { - return false - } - return EqualsRefOfNextval(a, b) - case *NotExpr: - b, ok := inB.(*NotExpr) - if !ok { - return false - } - return EqualsRefOfNotExpr(a, b) - case *NullVal: - b, ok := inB.(*NullVal) - if !ok { - return false - } - return EqualsRefOfNullVal(a, b) - case OnDup: - b, ok := inB.(OnDup) - if !ok { - return false - } - return EqualsOnDup(a, b) - case *OptLike: - b, ok := inB.(*OptLike) - if !ok { - return false - } - return EqualsRefOfOptLike(a, b) - case *OrExpr: - b, ok := inB.(*OrExpr) - if !ok { - return false - } - return EqualsRefOfOrExpr(a, b) - case *Order: - b, ok := inB.(*Order) - if !ok { - return false - } - return EqualsRefOfOrder(a, b) - case OrderBy: - b, ok := inB.(OrderBy) - if !ok { - return false - } - return EqualsOrderBy(a, b) - case *OrderByOption: - b, ok := inB.(*OrderByOption) - if !ok { - return false - } - return EqualsRefOfOrderByOption(a, b) - case *OtherAdmin: - b, ok := inB.(*OtherAdmin) - if !ok { - return false - } - return EqualsRefOfOtherAdmin(a, b) - case *OtherRead: - b, ok := inB.(*OtherRead) - if !ok { - return false - } - return EqualsRefOfOtherRead(a, b) - case *ParenSelect: - b, ok := inB.(*ParenSelect) - if !ok { - return false - } - return EqualsRefOfParenSelect(a, b) - case *ParenTableExpr: - b, ok := inB.(*ParenTableExpr) - if !ok { - return false - } - return EqualsRefOfParenTableExpr(a, b) - case *PartitionDefinition: - b, ok := inB.(*PartitionDefinition) - if !ok { - return false - } - return EqualsRefOfPartitionDefinition(a, b) - case *PartitionSpec: - b, ok := inB.(*PartitionSpec) - if !ok { - return false - } - return EqualsRefOfPartitionSpec(a, b) - case Partitions: - b, ok := inB.(Partitions) - if !ok { - return false - } - return EqualsPartitions(a, b) - case *RangeCond: - b, ok := inB.(*RangeCond) - if !ok { - return false - } - return EqualsRefOfRangeCond(a, b) - case ReferenceAction: - b, ok := inB.(ReferenceAction) - if !ok { - return false - } - return a == b - case *Release: - b, ok := inB.(*Release) - if !ok { - return false - } - return EqualsRefOfRelease(a, b) - case *RenameIndex: - b, ok := inB.(*RenameIndex) - if !ok { - return false - } - return EqualsRefOfRenameIndex(a, b) - case *RenameTable: - b, ok := inB.(*RenameTable) - if !ok { - return false - } - return EqualsRefOfRenameTable(a, b) - case *RenameTableName: - b, ok := inB.(*RenameTableName) - if !ok { - return false - } - return EqualsRefOfRenameTableName(a, b) - case *Rollback: - b, ok := inB.(*Rollback) - if !ok { - return false - } - return EqualsRefOfRollback(a, b) - case *SRollback: - b, ok := inB.(*SRollback) - if !ok { - return false - } - return EqualsRefOfSRollback(a, b) - case *Savepoint: - b, ok := inB.(*Savepoint) - if !ok { - return false - } - return EqualsRefOfSavepoint(a, b) - case *Select: - b, ok := inB.(*Select) - if !ok { - return false - } - return EqualsRefOfSelect(a, b) - case SelectExprs: - b, ok := inB.(SelectExprs) - if !ok { - return false - } - return EqualsSelectExprs(a, b) - case *SelectInto: - b, ok := inB.(*SelectInto) - if !ok { - return false - } - return EqualsRefOfSelectInto(a, b) - case *Set: - b, ok := inB.(*Set) - if !ok { - return false - } - return EqualsRefOfSet(a, b) - case *SetExpr: - b, ok := inB.(*SetExpr) - if !ok { - return false - } - return EqualsRefOfSetExpr(a, b) - case SetExprs: - b, ok := inB.(SetExprs) - if !ok { - return false - } - return EqualsSetExprs(a, b) - case *SetTransaction: - b, ok := inB.(*SetTransaction) - if !ok { - return false - } - return EqualsRefOfSetTransaction(a, b) - case *Show: - b, ok := inB.(*Show) - if !ok { - return false - } - return EqualsRefOfShow(a, b) - case *ShowBasic: - b, ok := inB.(*ShowBasic) - if !ok { - return false - } - return EqualsRefOfShowBasic(a, b) - case *ShowCreate: - b, ok := inB.(*ShowCreate) - if !ok { - return false - } - return EqualsRefOfShowCreate(a, b) - case *ShowFilter: - b, ok := inB.(*ShowFilter) - if !ok { - return false - } - return EqualsRefOfShowFilter(a, b) - case *ShowLegacy: - b, ok := inB.(*ShowLegacy) - if !ok { - return false - } - return EqualsRefOfShowLegacy(a, b) - case *StarExpr: - b, ok := inB.(*StarExpr) - if !ok { - return false - } - return EqualsRefOfStarExpr(a, b) - case *Stream: - b, ok := inB.(*Stream) - if !ok { - return false - } - return EqualsRefOfStream(a, b) - case *Subquery: - b, ok := inB.(*Subquery) - if !ok { - return false - } - return EqualsRefOfSubquery(a, b) - case *SubstrExpr: - b, ok := inB.(*SubstrExpr) - if !ok { - return false - } - return EqualsRefOfSubstrExpr(a, b) - case TableExprs: - b, ok := inB.(TableExprs) - if !ok { - return false - } - return EqualsTableExprs(a, b) - case TableIdent: - b, ok := inB.(TableIdent) - if !ok { - return false - } - return EqualsTableIdent(a, b) - case TableName: - b, ok := inB.(TableName) - if !ok { - return false - } - return EqualsTableName(a, b) - case TableNames: - b, ok := inB.(TableNames) - if !ok { - return false - } - return EqualsTableNames(a, b) - case TableOptions: - b, ok := inB.(TableOptions) - if !ok { - return false - } - return EqualsTableOptions(a, b) - case *TableSpec: - b, ok := inB.(*TableSpec) - if !ok { - return false - } - return EqualsRefOfTableSpec(a, b) - case *TablespaceOperation: - b, ok := inB.(*TablespaceOperation) - if !ok { - return false - } - return EqualsRefOfTablespaceOperation(a, b) - case *TimestampFuncExpr: - b, ok := inB.(*TimestampFuncExpr) - if !ok { - return false - } - return EqualsRefOfTimestampFuncExpr(a, b) - case *TruncateTable: - b, ok := inB.(*TruncateTable) - if !ok { - return false - } - return EqualsRefOfTruncateTable(a, b) - case *UnaryExpr: - b, ok := inB.(*UnaryExpr) - if !ok { - return false - } - return EqualsRefOfUnaryExpr(a, b) - case *Union: - b, ok := inB.(*Union) - if !ok { - return false - } - return EqualsRefOfUnion(a, b) - case *UnionSelect: - b, ok := inB.(*UnionSelect) - if !ok { - return false - } - return EqualsRefOfUnionSelect(a, b) - case *UnlockTables: - b, ok := inB.(*UnlockTables) - if !ok { - return false - } - return EqualsRefOfUnlockTables(a, b) - case *Update: - b, ok := inB.(*Update) - if !ok { - return false - } - return EqualsRefOfUpdate(a, b) - case *UpdateExpr: - b, ok := inB.(*UpdateExpr) - if !ok { - return false - } - return EqualsRefOfUpdateExpr(a, b) - case UpdateExprs: - b, ok := inB.(UpdateExprs) - if !ok { - return false - } - return EqualsUpdateExprs(a, b) - case *Use: - b, ok := inB.(*Use) - if !ok { - return false - } - return EqualsRefOfUse(a, b) - case *VStream: - b, ok := inB.(*VStream) - if !ok { - return false - } - return EqualsRefOfVStream(a, b) - case ValTuple: - b, ok := inB.(ValTuple) - if !ok { - return false - } - return EqualsValTuple(a, b) - case *Validation: - b, ok := inB.(*Validation) - if !ok { - return false - } - return EqualsRefOfValidation(a, b) - case Values: - b, ok := inB.(Values) - if !ok { - return false - } - return EqualsValues(a, b) - case *ValuesFuncExpr: - b, ok := inB.(*ValuesFuncExpr) - if !ok { - return false - } - return EqualsRefOfValuesFuncExpr(a, b) - case VindexParam: - b, ok := inB.(VindexParam) - if !ok { - return false - } - return EqualsVindexParam(a, b) - case *VindexSpec: - b, ok := inB.(*VindexSpec) - if !ok { - return false - } - return EqualsRefOfVindexSpec(a, b) - case *When: - b, ok := inB.(*When) - if !ok { - return false - } - return EqualsRefOfWhen(a, b) - case *Where: - b, ok := inB.(*Where) - if !ok { - return false - } - return EqualsRefOfWhere(a, b) - case *XorExpr: - b, ok := inB.(*XorExpr) - if !ok { - return false - } - return EqualsRefOfXorExpr(a, b) - default: - // this should never happen - return false - } -} - -// EqualsSelectExpr does deep equals. -func EqualsSelectExpr(inA, inB SelectExpr) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *AliasedExpr: - b, ok := inB.(*AliasedExpr) - if !ok { - return false - } - return EqualsRefOfAliasedExpr(a, b) - case *Nextval: - b, ok := inB.(*Nextval) - if !ok { - return false - } - return EqualsRefOfNextval(a, b) - case *StarExpr: - b, ok := inB.(*StarExpr) - if !ok { - return false - } - return EqualsRefOfStarExpr(a, b) - default: - // this should never happen - return false - } -} - -// EqualsSelectStatement does deep equals. -func EqualsSelectStatement(inA, inB SelectStatement) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *ParenSelect: - b, ok := inB.(*ParenSelect) - if !ok { - return false - } - return EqualsRefOfParenSelect(a, b) - case *Select: - b, ok := inB.(*Select) - if !ok { - return false - } - return EqualsRefOfSelect(a, b) - case *Union: - b, ok := inB.(*Union) - if !ok { - return false - } - return EqualsRefOfUnion(a, b) - default: - // this should never happen - return false - } -} - -// EqualsShowInternal does deep equals. -func EqualsShowInternal(inA, inB ShowInternal) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *ShowBasic: - b, ok := inB.(*ShowBasic) - if !ok { - return false - } - return EqualsRefOfShowBasic(a, b) - case *ShowCreate: - b, ok := inB.(*ShowCreate) - if !ok { - return false - } - return EqualsRefOfShowCreate(a, b) - case *ShowLegacy: - b, ok := inB.(*ShowLegacy) - if !ok { - return false - } - return EqualsRefOfShowLegacy(a, b) - default: - // this should never happen - return false - } -} - -// EqualsSimpleTableExpr does deep equals. -func EqualsSimpleTableExpr(inA, inB SimpleTableExpr) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *DerivedTable: - b, ok := inB.(*DerivedTable) - if !ok { - return false - } - return EqualsRefOfDerivedTable(a, b) - case TableName: - b, ok := inB.(TableName) - if !ok { - return false - } - return EqualsTableName(a, b) - default: - // this should never happen - return false - } -} - -// EqualsStatement does deep equals. -func EqualsStatement(inA, inB Statement) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *AlterDatabase: - b, ok := inB.(*AlterDatabase) - if !ok { - return false - } - return EqualsRefOfAlterDatabase(a, b) - case *AlterTable: - b, ok := inB.(*AlterTable) - if !ok { - return false - } - return EqualsRefOfAlterTable(a, b) - case *AlterView: - b, ok := inB.(*AlterView) - if !ok { - return false - } - return EqualsRefOfAlterView(a, b) - case *AlterVschema: - b, ok := inB.(*AlterVschema) - if !ok { - return false - } - return EqualsRefOfAlterVschema(a, b) - case *Begin: - b, ok := inB.(*Begin) - if !ok { - return false - } - return EqualsRefOfBegin(a, b) - case *CallProc: - b, ok := inB.(*CallProc) - if !ok { - return false - } - return EqualsRefOfCallProc(a, b) - case *Commit: - b, ok := inB.(*Commit) - if !ok { - return false - } - return EqualsRefOfCommit(a, b) - case *CreateDatabase: - b, ok := inB.(*CreateDatabase) - if !ok { - return false - } - return EqualsRefOfCreateDatabase(a, b) - case *CreateTable: - b, ok := inB.(*CreateTable) - if !ok { - return false - } - return EqualsRefOfCreateTable(a, b) - case *CreateView: - b, ok := inB.(*CreateView) - if !ok { - return false - } - return EqualsRefOfCreateView(a, b) - case *Delete: - b, ok := inB.(*Delete) - if !ok { - return false - } - return EqualsRefOfDelete(a, b) - case *DropDatabase: - b, ok := inB.(*DropDatabase) - if !ok { - return false - } - return EqualsRefOfDropDatabase(a, b) - case *DropTable: - b, ok := inB.(*DropTable) - if !ok { - return false - } - return EqualsRefOfDropTable(a, b) - case *DropView: - b, ok := inB.(*DropView) - if !ok { - return false - } - return EqualsRefOfDropView(a, b) - case *ExplainStmt: - b, ok := inB.(*ExplainStmt) - if !ok { - return false - } - return EqualsRefOfExplainStmt(a, b) - case *ExplainTab: - b, ok := inB.(*ExplainTab) - if !ok { - return false - } - return EqualsRefOfExplainTab(a, b) - case *Flush: - b, ok := inB.(*Flush) - if !ok { - return false - } - return EqualsRefOfFlush(a, b) - case *Insert: - b, ok := inB.(*Insert) - if !ok { - return false - } - return EqualsRefOfInsert(a, b) - case *Load: - b, ok := inB.(*Load) - if !ok { - return false - } - return EqualsRefOfLoad(a, b) - case *LockTables: - b, ok := inB.(*LockTables) - if !ok { - return false - } - return EqualsRefOfLockTables(a, b) - case *OtherAdmin: - b, ok := inB.(*OtherAdmin) - if !ok { - return false - } - return EqualsRefOfOtherAdmin(a, b) - case *OtherRead: - b, ok := inB.(*OtherRead) - if !ok { - return false - } - return EqualsRefOfOtherRead(a, b) - case *ParenSelect: - b, ok := inB.(*ParenSelect) - if !ok { - return false - } - return EqualsRefOfParenSelect(a, b) - case *Release: - b, ok := inB.(*Release) - if !ok { - return false - } - return EqualsRefOfRelease(a, b) - case *RenameTable: - b, ok := inB.(*RenameTable) - if !ok { - return false - } - return EqualsRefOfRenameTable(a, b) - case *Rollback: - b, ok := inB.(*Rollback) - if !ok { - return false - } - return EqualsRefOfRollback(a, b) - case *SRollback: - b, ok := inB.(*SRollback) - if !ok { - return false - } - return EqualsRefOfSRollback(a, b) - case *Savepoint: - b, ok := inB.(*Savepoint) - if !ok { - return false - } - return EqualsRefOfSavepoint(a, b) - case *Select: - b, ok := inB.(*Select) - if !ok { - return false - } - return EqualsRefOfSelect(a, b) - case *Set: - b, ok := inB.(*Set) - if !ok { - return false - } - return EqualsRefOfSet(a, b) - case *SetTransaction: - b, ok := inB.(*SetTransaction) - if !ok { - return false - } - return EqualsRefOfSetTransaction(a, b) - case *Show: - b, ok := inB.(*Show) - if !ok { - return false - } - return EqualsRefOfShow(a, b) - case *Stream: - b, ok := inB.(*Stream) - if !ok { - return false - } - return EqualsRefOfStream(a, b) - case *TruncateTable: - b, ok := inB.(*TruncateTable) - if !ok { - return false - } - return EqualsRefOfTruncateTable(a, b) - case *Union: - b, ok := inB.(*Union) - if !ok { - return false - } - return EqualsRefOfUnion(a, b) - case *UnlockTables: - b, ok := inB.(*UnlockTables) - if !ok { - return false - } - return EqualsRefOfUnlockTables(a, b) - case *Update: - b, ok := inB.(*Update) - if !ok { - return false - } - return EqualsRefOfUpdate(a, b) - case *Use: - b, ok := inB.(*Use) - if !ok { - return false - } - return EqualsRefOfUse(a, b) - case *VStream: - b, ok := inB.(*VStream) - if !ok { - return false - } - return EqualsRefOfVStream(a, b) - default: - // this should never happen - return false - } -} - -// EqualsTableExpr does deep equals. -func EqualsTableExpr(inA, inB TableExpr) bool { - if inA == nil && inB == nil { - return true - } - if inA == nil || inB == nil { - return false - } - switch a := inA.(type) { - case *AliasedTableExpr: - b, ok := inB.(*AliasedTableExpr) - if !ok { - return false - } - return EqualsRefOfAliasedTableExpr(a, b) - case *JoinTableExpr: - b, ok := inB.(*JoinTableExpr) - if !ok { - return false - } - return EqualsRefOfJoinTableExpr(a, b) - case *ParenTableExpr: - b, ok := inB.(*ParenTableExpr) - if !ok { - return false - } - return EqualsRefOfParenTableExpr(a, b) - default: - // this should never happen - return false - } -} - -// EqualsRefOfAddColumns does deep equals. -func EqualsRefOfAddColumns(a, b *AddColumns) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSliceOfRefOfColumnDefinition(a.Columns, b.Columns) && - EqualsRefOfColName(a.First, b.First) && - EqualsRefOfColName(a.After, b.After) -} - -// EqualsRefOfAddConstraintDefinition does deep equals. -func EqualsRefOfAddConstraintDefinition(a, b *AddConstraintDefinition) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsRefOfConstraintDefinition(a.ConstraintDefinition, b.ConstraintDefinition) -} - -// EqualsRefOfAddIndexDefinition does deep equals. -func EqualsRefOfAddIndexDefinition(a, b *AddIndexDefinition) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsRefOfIndexDefinition(a.IndexDefinition, b.IndexDefinition) -} - -// EqualsRefOfAlterCharset does deep equals. -func EqualsRefOfAlterCharset(a, b *AlterCharset) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.CharacterSet == b.CharacterSet && - a.Collate == b.Collate -} - -// EqualsRefOfAlterColumn does deep equals. -func EqualsRefOfAlterColumn(a, b *AlterColumn) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.DropDefault == b.DropDefault && - EqualsRefOfColName(a.Column, b.Column) && - EqualsExpr(a.DefaultVal, b.DefaultVal) -} - -// EqualsRefOfChangeColumn does deep equals. -func EqualsRefOfChangeColumn(a, b *ChangeColumn) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsRefOfColName(a.OldColumn, b.OldColumn) && - EqualsRefOfColumnDefinition(a.NewColDefinition, b.NewColDefinition) && - EqualsRefOfColName(a.First, b.First) && - EqualsRefOfColName(a.After, b.After) -} - -// EqualsRefOfDropColumn does deep equals. -func EqualsRefOfDropColumn(a, b *DropColumn) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsRefOfColName(a.Name, b.Name) -} - -// EqualsRefOfDropKey does deep equals. -func EqualsRefOfDropKey(a, b *DropKey) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Name == b.Name && - a.Type == b.Type -} - -// EqualsRefOfForce does deep equals. -func EqualsRefOfForce(a, b *Force) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return true -} - -// EqualsRefOfKeyState does deep equals. -func EqualsRefOfKeyState(a, b *KeyState) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Enable == b.Enable -} - -// EqualsRefOfLockOption does deep equals. -func EqualsRefOfLockOption(a, b *LockOption) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Type == b.Type -} - -// EqualsRefOfModifyColumn does deep equals. -func EqualsRefOfModifyColumn(a, b *ModifyColumn) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsRefOfColumnDefinition(a.NewColDefinition, b.NewColDefinition) && - EqualsRefOfColName(a.First, b.First) && - EqualsRefOfColName(a.After, b.After) -} - -// EqualsRefOfOrderByOption does deep equals. -func EqualsRefOfOrderByOption(a, b *OrderByOption) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColumns(a.Cols, b.Cols) -} - -// EqualsRefOfRenameIndex does deep equals. -func EqualsRefOfRenameIndex(a, b *RenameIndex) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.OldName == b.OldName && - a.NewName == b.NewName -} - -// EqualsRefOfRenameTableName does deep equals. -func EqualsRefOfRenameTableName(a, b *RenameTableName) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableName(a.Table, b.Table) -} - -// EqualsTableOptions does deep equals. -func EqualsTableOptions(a, b TableOptions) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfTableOption(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfTablespaceOperation does deep equals. -func EqualsRefOfTablespaceOperation(a, b *TablespaceOperation) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Import == b.Import -} - -// EqualsRefOfValidation does deep equals. -func EqualsRefOfValidation(a, b *Validation) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.With == b.With -} - -// EqualsListArg does deep equals. -func EqualsListArg(a, b ListArg) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if a[i] != b[i] { - return false - } - } - return true -} - -// EqualsRefOfSubquery does deep equals. -func EqualsRefOfSubquery(a, b *Subquery) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSelectStatement(a.Select, b.Select) -} - -// EqualsValTuple does deep equals. -func EqualsValTuple(a, b ValTuple) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsExpr(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfCheckConstraintDefinition does deep equals. -func EqualsRefOfCheckConstraintDefinition(a, b *CheckConstraintDefinition) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Enforced == b.Enforced && - EqualsExpr(a.Expr, b.Expr) -} - -// EqualsRefOfForeignKeyDefinition does deep equals. -func EqualsRefOfForeignKeyDefinition(a, b *ForeignKeyDefinition) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColumns(a.Source, b.Source) && - EqualsTableName(a.ReferencedTable, b.ReferencedTable) && - EqualsColumns(a.ReferencedColumns, b.ReferencedColumns) && - a.OnDelete == b.OnDelete && - a.OnUpdate == b.OnUpdate -} - -// EqualsRefOfAlterDatabase does deep equals. -func EqualsRefOfAlterDatabase(a, b *AlterDatabase) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.DBName == b.DBName && - a.UpdateDataDirectory == b.UpdateDataDirectory && - a.FullyParsed == b.FullyParsed && - EqualsSliceOfCollateAndCharset(a.AlterOptions, b.AlterOptions) -} - -// EqualsRefOfCreateDatabase does deep equals. -func EqualsRefOfCreateDatabase(a, b *CreateDatabase) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.DBName == b.DBName && - a.IfNotExists == b.IfNotExists && - a.FullyParsed == b.FullyParsed && - EqualsComments(a.Comments, b.Comments) && - EqualsSliceOfCollateAndCharset(a.CreateOptions, b.CreateOptions) -} - -// EqualsRefOfDropDatabase does deep equals. -func EqualsRefOfDropDatabase(a, b *DropDatabase) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.DBName == b.DBName && - a.IfExists == b.IfExists && - EqualsComments(a.Comments, b.Comments) -} - -// EqualsRefOfAlterTable does deep equals. -func EqualsRefOfAlterTable(a, b *AlterTable) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.FullyParsed == b.FullyParsed && - EqualsTableName(a.Table, b.Table) && - EqualsSliceOfAlterOption(a.AlterOptions, b.AlterOptions) && - EqualsRefOfPartitionSpec(a.PartitionSpec, b.PartitionSpec) -} - -// EqualsRefOfAlterView does deep equals. -func EqualsRefOfAlterView(a, b *AlterView) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Algorithm == b.Algorithm && - a.Definer == b.Definer && - a.Security == b.Security && - a.CheckOption == b.CheckOption && - EqualsTableName(a.ViewName, b.ViewName) && - EqualsColumns(a.Columns, b.Columns) && - EqualsSelectStatement(a.Select, b.Select) -} - -// EqualsRefOfCreateTable does deep equals. -func EqualsRefOfCreateTable(a, b *CreateTable) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Temp == b.Temp && - a.IfNotExists == b.IfNotExists && - a.FullyParsed == b.FullyParsed && - EqualsTableName(a.Table, b.Table) && - EqualsRefOfTableSpec(a.TableSpec, b.TableSpec) && - EqualsRefOfOptLike(a.OptLike, b.OptLike) -} - -// EqualsRefOfCreateView does deep equals. -func EqualsRefOfCreateView(a, b *CreateView) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Algorithm == b.Algorithm && - a.Definer == b.Definer && - a.Security == b.Security && - a.CheckOption == b.CheckOption && - a.IsReplace == b.IsReplace && - EqualsTableName(a.ViewName, b.ViewName) && - EqualsColumns(a.Columns, b.Columns) && - EqualsSelectStatement(a.Select, b.Select) -} - -// EqualsRefOfDropTable does deep equals. -func EqualsRefOfDropTable(a, b *DropTable) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Temp == b.Temp && - a.IfExists == b.IfExists && - EqualsTableNames(a.FromTables, b.FromTables) -} - -// EqualsRefOfDropView does deep equals. -func EqualsRefOfDropView(a, b *DropView) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.IfExists == b.IfExists && - EqualsTableNames(a.FromTables, b.FromTables) -} - -// EqualsRefOfRenameTable does deep equals. -func EqualsRefOfRenameTable(a, b *RenameTable) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSliceOfRefOfRenameTablePair(a.TablePairs, b.TablePairs) -} - -// EqualsRefOfTruncateTable does deep equals. -func EqualsRefOfTruncateTable(a, b *TruncateTable) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableName(a.Table, b.Table) -} - -// EqualsRefOfExplainStmt does deep equals. -func EqualsRefOfExplainStmt(a, b *ExplainStmt) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Type == b.Type && - EqualsStatement(a.Statement, b.Statement) -} - -// EqualsRefOfExplainTab does deep equals. -func EqualsRefOfExplainTab(a, b *ExplainTab) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Wild == b.Wild && - EqualsTableName(a.Table, b.Table) -} - -// EqualsRefOfAndExpr does deep equals. -func EqualsRefOfAndExpr(a, b *AndExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Left, b.Left) && - EqualsExpr(a.Right, b.Right) -} - -// EqualsRefOfBinaryExpr does deep equals. -func EqualsRefOfBinaryExpr(a, b *BinaryExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Operator == b.Operator && - EqualsExpr(a.Left, b.Left) && - EqualsExpr(a.Right, b.Right) -} - -// EqualsRefOfCaseExpr does deep equals. -func EqualsRefOfCaseExpr(a, b *CaseExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Expr, b.Expr) && - EqualsSliceOfRefOfWhen(a.Whens, b.Whens) && - EqualsExpr(a.Else, b.Else) -} - -// EqualsRefOfColName does deep equals. -func EqualsRefOfColName(a, b *ColName) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColIdent(a.Name, b.Name) && - EqualsTableName(a.Qualifier, b.Qualifier) -} - -// EqualsRefOfCollateExpr does deep equals. -func EqualsRefOfCollateExpr(a, b *CollateExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Charset == b.Charset && - EqualsExpr(a.Expr, b.Expr) -} - -// EqualsRefOfComparisonExpr does deep equals. -func EqualsRefOfComparisonExpr(a, b *ComparisonExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Operator == b.Operator && - EqualsExpr(a.Left, b.Left) && - EqualsExpr(a.Right, b.Right) && - EqualsExpr(a.Escape, b.Escape) -} - -// EqualsRefOfConvertExpr does deep equals. -func EqualsRefOfConvertExpr(a, b *ConvertExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Expr, b.Expr) && - EqualsRefOfConvertType(a.Type, b.Type) -} - -// EqualsRefOfConvertUsingExpr does deep equals. -func EqualsRefOfConvertUsingExpr(a, b *ConvertUsingExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Type == b.Type && - EqualsExpr(a.Expr, b.Expr) -} - -// EqualsRefOfCurTimeFuncExpr does deep equals. -func EqualsRefOfCurTimeFuncExpr(a, b *CurTimeFuncExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColIdent(a.Name, b.Name) && - EqualsExpr(a.Fsp, b.Fsp) -} - -// EqualsRefOfDefault does deep equals. -func EqualsRefOfDefault(a, b *Default) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.ColName == b.ColName -} - -// EqualsRefOfExistsExpr does deep equals. -func EqualsRefOfExistsExpr(a, b *ExistsExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsRefOfSubquery(a.Subquery, b.Subquery) -} - -// EqualsRefOfFuncExpr does deep equals. -func EqualsRefOfFuncExpr(a, b *FuncExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Distinct == b.Distinct && - EqualsTableIdent(a.Qualifier, b.Qualifier) && - EqualsColIdent(a.Name, b.Name) && - EqualsSelectExprs(a.Exprs, b.Exprs) -} - -// EqualsRefOfGroupConcatExpr does deep equals. -func EqualsRefOfGroupConcatExpr(a, b *GroupConcatExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Distinct == b.Distinct && - a.Separator == b.Separator && - EqualsSelectExprs(a.Exprs, b.Exprs) && - EqualsOrderBy(a.OrderBy, b.OrderBy) && - EqualsRefOfLimit(a.Limit, b.Limit) -} - -// EqualsRefOfIntervalExpr does deep equals. -func EqualsRefOfIntervalExpr(a, b *IntervalExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Unit == b.Unit && - EqualsExpr(a.Expr, b.Expr) -} - -// EqualsRefOfIsExpr does deep equals. -func EqualsRefOfIsExpr(a, b *IsExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Operator == b.Operator && - EqualsExpr(a.Expr, b.Expr) -} - -// EqualsRefOfLiteral does deep equals. -func EqualsRefOfLiteral(a, b *Literal) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Val == b.Val && - a.Type == b.Type -} - -// EqualsRefOfMatchExpr does deep equals. -func EqualsRefOfMatchExpr(a, b *MatchExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSelectExprs(a.Columns, b.Columns) && - EqualsExpr(a.Expr, b.Expr) && - a.Option == b.Option -} - -// EqualsRefOfNotExpr does deep equals. -func EqualsRefOfNotExpr(a, b *NotExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Expr, b.Expr) -} - -// EqualsRefOfNullVal does deep equals. -func EqualsRefOfNullVal(a, b *NullVal) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return true -} - -// EqualsRefOfOrExpr does deep equals. -func EqualsRefOfOrExpr(a, b *OrExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Left, b.Left) && - EqualsExpr(a.Right, b.Right) -} - -// EqualsRefOfRangeCond does deep equals. -func EqualsRefOfRangeCond(a, b *RangeCond) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Operator == b.Operator && - EqualsExpr(a.Left, b.Left) && - EqualsExpr(a.From, b.From) && - EqualsExpr(a.To, b.To) -} - -// EqualsRefOfSubstrExpr does deep equals. -func EqualsRefOfSubstrExpr(a, b *SubstrExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsRefOfColName(a.Name, b.Name) && - EqualsRefOfLiteral(a.StrVal, b.StrVal) && - EqualsExpr(a.From, b.From) && - EqualsExpr(a.To, b.To) -} - -// EqualsRefOfTimestampFuncExpr does deep equals. -func EqualsRefOfTimestampFuncExpr(a, b *TimestampFuncExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Name == b.Name && - a.Unit == b.Unit && - EqualsExpr(a.Expr1, b.Expr1) && - EqualsExpr(a.Expr2, b.Expr2) -} - -// EqualsRefOfUnaryExpr does deep equals. -func EqualsRefOfUnaryExpr(a, b *UnaryExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Operator == b.Operator && - EqualsExpr(a.Expr, b.Expr) -} - -// EqualsRefOfValuesFuncExpr does deep equals. -func EqualsRefOfValuesFuncExpr(a, b *ValuesFuncExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsRefOfColName(a.Name, b.Name) -} - -// EqualsRefOfXorExpr does deep equals. -func EqualsRefOfXorExpr(a, b *XorExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Left, b.Left) && - EqualsExpr(a.Right, b.Right) -} - -// EqualsRefOfParenSelect does deep equals. -func EqualsRefOfParenSelect(a, b *ParenSelect) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSelectStatement(a.Select, b.Select) -} - -// EqualsRefOfSelect does deep equals. -func EqualsRefOfSelect(a, b *Select) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Distinct == b.Distinct && - a.StraightJoinHint == b.StraightJoinHint && - a.SQLCalcFoundRows == b.SQLCalcFoundRows && - EqualsRefOfBool(a.Cache, b.Cache) && - EqualsComments(a.Comments, b.Comments) && - EqualsSelectExprs(a.SelectExprs, b.SelectExprs) && - EqualsTableExprs(a.From, b.From) && - EqualsRefOfWhere(a.Where, b.Where) && - EqualsGroupBy(a.GroupBy, b.GroupBy) && - EqualsRefOfWhere(a.Having, b.Having) && - EqualsOrderBy(a.OrderBy, b.OrderBy) && - EqualsRefOfLimit(a.Limit, b.Limit) && - a.Lock == b.Lock && - EqualsRefOfSelectInto(a.Into, b.Into) -} - -// EqualsRefOfUnion does deep equals. -func EqualsRefOfUnion(a, b *Union) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSelectStatement(a.FirstStatement, b.FirstStatement) && - EqualsSliceOfRefOfUnionSelect(a.UnionSelects, b.UnionSelects) && - EqualsOrderBy(a.OrderBy, b.OrderBy) && - EqualsRefOfLimit(a.Limit, b.Limit) && - a.Lock == b.Lock -} - -// EqualsValues does deep equals. -func EqualsValues(a, b Values) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsValTuple(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfAliasedExpr does deep equals. -func EqualsRefOfAliasedExpr(a, b *AliasedExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Expr, b.Expr) && - EqualsColIdent(a.As, b.As) -} - -// EqualsRefOfAliasedTableExpr does deep equals. -func EqualsRefOfAliasedTableExpr(a, b *AliasedTableExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSimpleTableExpr(a.Expr, b.Expr) && - EqualsPartitions(a.Partitions, b.Partitions) && - EqualsTableIdent(a.As, b.As) && - EqualsRefOfIndexHints(a.Hints, b.Hints) -} - -// EqualsRefOfAlterVschema does deep equals. -func EqualsRefOfAlterVschema(a, b *AlterVschema) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Action == b.Action && - EqualsTableName(a.Table, b.Table) && - EqualsRefOfVindexSpec(a.VindexSpec, b.VindexSpec) && - EqualsSliceOfColIdent(a.VindexCols, b.VindexCols) && - EqualsRefOfAutoIncSpec(a.AutoIncSpec, b.AutoIncSpec) -} - -// EqualsRefOfAutoIncSpec does deep equals. -func EqualsRefOfAutoIncSpec(a, b *AutoIncSpec) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColIdent(a.Column, b.Column) && - EqualsTableName(a.Sequence, b.Sequence) -} - -// EqualsRefOfBegin does deep equals. -func EqualsRefOfBegin(a, b *Begin) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return true -} - -// EqualsRefOfCallProc does deep equals. -func EqualsRefOfCallProc(a, b *CallProc) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableName(a.Name, b.Name) && - EqualsExprs(a.Params, b.Params) -} - -// EqualsColIdent does deep equals. -func EqualsColIdent(a, b ColIdent) bool { - return a.val == b.val && - a.lowered == b.lowered && - a.at == b.at -} - -// EqualsRefOfColumnDefinition does deep equals. -func EqualsRefOfColumnDefinition(a, b *ColumnDefinition) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColIdent(a.Name, b.Name) && - EqualsColumnType(a.Type, b.Type) -} - -// EqualsRefOfColumnType does deep equals. -func EqualsRefOfColumnType(a, b *ColumnType) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Type == b.Type && - a.Unsigned == b.Unsigned && - a.Zerofill == b.Zerofill && - a.Charset == b.Charset && - a.Collate == b.Collate && - EqualsRefOfColumnTypeOptions(a.Options, b.Options) && - EqualsRefOfLiteral(a.Length, b.Length) && - EqualsRefOfLiteral(a.Scale, b.Scale) && - EqualsSliceOfString(a.EnumValues, b.EnumValues) -} - -// EqualsColumns does deep equals. -func EqualsColumns(a, b Columns) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsColIdent(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsComments does deep equals. -func EqualsComments(a, b Comments) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if a[i] != b[i] { - return false - } - } - return true -} - -// EqualsRefOfCommit does deep equals. -func EqualsRefOfCommit(a, b *Commit) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return true -} - -// EqualsRefOfConstraintDefinition does deep equals. -func EqualsRefOfConstraintDefinition(a, b *ConstraintDefinition) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Name == b.Name && - EqualsConstraintInfo(a.Details, b.Details) -} - -// EqualsRefOfConvertType does deep equals. -func EqualsRefOfConvertType(a, b *ConvertType) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Type == b.Type && - a.Charset == b.Charset && - EqualsRefOfLiteral(a.Length, b.Length) && - EqualsRefOfLiteral(a.Scale, b.Scale) && - a.Operator == b.Operator -} - -// EqualsRefOfDelete does deep equals. -func EqualsRefOfDelete(a, b *Delete) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Ignore == b.Ignore && - EqualsComments(a.Comments, b.Comments) && - EqualsTableNames(a.Targets, b.Targets) && - EqualsTableExprs(a.TableExprs, b.TableExprs) && - EqualsPartitions(a.Partitions, b.Partitions) && - EqualsRefOfWhere(a.Where, b.Where) && - EqualsOrderBy(a.OrderBy, b.OrderBy) && - EqualsRefOfLimit(a.Limit, b.Limit) -} - -// EqualsRefOfDerivedTable does deep equals. -func EqualsRefOfDerivedTable(a, b *DerivedTable) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSelectStatement(a.Select, b.Select) -} - -// EqualsExprs does deep equals. -func EqualsExprs(a, b Exprs) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsExpr(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfFlush does deep equals. -func EqualsRefOfFlush(a, b *Flush) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.IsLocal == b.IsLocal && - a.WithLock == b.WithLock && - a.ForExport == b.ForExport && - EqualsSliceOfString(a.FlushOptions, b.FlushOptions) && - EqualsTableNames(a.TableNames, b.TableNames) -} - -// EqualsGroupBy does deep equals. -func EqualsGroupBy(a, b GroupBy) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsExpr(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfIndexDefinition does deep equals. -func EqualsRefOfIndexDefinition(a, b *IndexDefinition) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsRefOfIndexInfo(a.Info, b.Info) && - EqualsSliceOfRefOfIndexColumn(a.Columns, b.Columns) && - EqualsSliceOfRefOfIndexOption(a.Options, b.Options) -} - -// EqualsRefOfIndexHints does deep equals. -func EqualsRefOfIndexHints(a, b *IndexHints) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Type == b.Type && - EqualsSliceOfColIdent(a.Indexes, b.Indexes) -} - -// EqualsRefOfIndexInfo does deep equals. -func EqualsRefOfIndexInfo(a, b *IndexInfo) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Type == b.Type && - a.Primary == b.Primary && - a.Spatial == b.Spatial && - a.Fulltext == b.Fulltext && - a.Unique == b.Unique && - EqualsColIdent(a.Name, b.Name) && - EqualsColIdent(a.ConstraintName, b.ConstraintName) -} - -// EqualsRefOfInsert does deep equals. -func EqualsRefOfInsert(a, b *Insert) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Action == b.Action && - EqualsComments(a.Comments, b.Comments) && - a.Ignore == b.Ignore && - EqualsTableName(a.Table, b.Table) && - EqualsPartitions(a.Partitions, b.Partitions) && - EqualsColumns(a.Columns, b.Columns) && - EqualsInsertRows(a.Rows, b.Rows) && - EqualsOnDup(a.OnDup, b.OnDup) -} - -// EqualsJoinCondition does deep equals. -func EqualsJoinCondition(a, b JoinCondition) bool { - return EqualsExpr(a.On, b.On) && - EqualsColumns(a.Using, b.Using) -} - -// EqualsRefOfJoinTableExpr does deep equals. -func EqualsRefOfJoinTableExpr(a, b *JoinTableExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableExpr(a.LeftExpr, b.LeftExpr) && - a.Join == b.Join && - EqualsTableExpr(a.RightExpr, b.RightExpr) && - EqualsJoinCondition(a.Condition, b.Condition) -} - -// EqualsRefOfLimit does deep equals. -func EqualsRefOfLimit(a, b *Limit) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Offset, b.Offset) && - EqualsExpr(a.Rowcount, b.Rowcount) -} - -// EqualsRefOfLoad does deep equals. -func EqualsRefOfLoad(a, b *Load) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return true -} - -// EqualsRefOfLockTables does deep equals. -func EqualsRefOfLockTables(a, b *LockTables) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableAndLockTypes(a.Tables, b.Tables) -} - -// EqualsRefOfNextval does deep equals. -func EqualsRefOfNextval(a, b *Nextval) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Expr, b.Expr) -} - -// EqualsOnDup does deep equals. -func EqualsOnDup(a, b OnDup) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfUpdateExpr(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfOptLike does deep equals. -func EqualsRefOfOptLike(a, b *OptLike) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableName(a.LikeTable, b.LikeTable) -} - -// EqualsRefOfOrder does deep equals. -func EqualsRefOfOrder(a, b *Order) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Expr, b.Expr) && - a.Direction == b.Direction -} - -// EqualsOrderBy does deep equals. -func EqualsOrderBy(a, b OrderBy) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfOrder(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfOtherAdmin does deep equals. -func EqualsRefOfOtherAdmin(a, b *OtherAdmin) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return true -} - -// EqualsRefOfOtherRead does deep equals. -func EqualsRefOfOtherRead(a, b *OtherRead) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return true -} - -// EqualsRefOfParenTableExpr does deep equals. -func EqualsRefOfParenTableExpr(a, b *ParenTableExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableExprs(a.Exprs, b.Exprs) -} - -// EqualsRefOfPartitionDefinition does deep equals. -func EqualsRefOfPartitionDefinition(a, b *PartitionDefinition) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Maxvalue == b.Maxvalue && - EqualsColIdent(a.Name, b.Name) && - EqualsExpr(a.Limit, b.Limit) -} - -// EqualsRefOfPartitionSpec does deep equals. -func EqualsRefOfPartitionSpec(a, b *PartitionSpec) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.IsAll == b.IsAll && - a.WithoutValidation == b.WithoutValidation && - a.Action == b.Action && - EqualsPartitions(a.Names, b.Names) && - EqualsRefOfLiteral(a.Number, b.Number) && - EqualsTableName(a.TableName, b.TableName) && - EqualsSliceOfRefOfPartitionDefinition(a.Definitions, b.Definitions) -} - -// EqualsPartitions does deep equals. -func EqualsPartitions(a, b Partitions) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsColIdent(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfRelease does deep equals. -func EqualsRefOfRelease(a, b *Release) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColIdent(a.Name, b.Name) -} - -// EqualsRefOfRollback does deep equals. -func EqualsRefOfRollback(a, b *Rollback) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return true -} - -// EqualsRefOfSRollback does deep equals. -func EqualsRefOfSRollback(a, b *SRollback) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColIdent(a.Name, b.Name) -} - -// EqualsRefOfSavepoint does deep equals. -func EqualsRefOfSavepoint(a, b *Savepoint) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColIdent(a.Name, b.Name) -} - -// EqualsSelectExprs does deep equals. -func EqualsSelectExprs(a, b SelectExprs) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsSelectExpr(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfSelectInto does deep equals. -func EqualsRefOfSelectInto(a, b *SelectInto) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.FileName == b.FileName && - a.Charset == b.Charset && - a.FormatOption == b.FormatOption && - a.ExportOption == b.ExportOption && - a.Manifest == b.Manifest && - a.Overwrite == b.Overwrite && - a.Type == b.Type -} - -// EqualsRefOfSet does deep equals. -func EqualsRefOfSet(a, b *Set) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsComments(a.Comments, b.Comments) && - EqualsSetExprs(a.Exprs, b.Exprs) -} - -// EqualsRefOfSetExpr does deep equals. -func EqualsRefOfSetExpr(a, b *SetExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Scope == b.Scope && - EqualsColIdent(a.Name, b.Name) && - EqualsExpr(a.Expr, b.Expr) -} - -// EqualsSetExprs does deep equals. -func EqualsSetExprs(a, b SetExprs) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfSetExpr(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfSetTransaction does deep equals. -func EqualsRefOfSetTransaction(a, b *SetTransaction) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSQLNode(a.SQLNode, b.SQLNode) && - EqualsComments(a.Comments, b.Comments) && - a.Scope == b.Scope && - EqualsSliceOfCharacteristic(a.Characteristics, b.Characteristics) -} - -// EqualsRefOfShow does deep equals. -func EqualsRefOfShow(a, b *Show) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsShowInternal(a.Internal, b.Internal) -} - -// EqualsRefOfShowBasic does deep equals. -func EqualsRefOfShowBasic(a, b *ShowBasic) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Full == b.Full && - a.DbName == b.DbName && - a.Command == b.Command && - EqualsTableName(a.Tbl, b.Tbl) && - EqualsRefOfShowFilter(a.Filter, b.Filter) -} - -// EqualsRefOfShowCreate does deep equals. -func EqualsRefOfShowCreate(a, b *ShowCreate) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Command == b.Command && - EqualsTableName(a.Op, b.Op) -} - -// EqualsRefOfShowFilter does deep equals. -func EqualsRefOfShowFilter(a, b *ShowFilter) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Like == b.Like && - EqualsExpr(a.Filter, b.Filter) -} - -// EqualsRefOfShowLegacy does deep equals. -func EqualsRefOfShowLegacy(a, b *ShowLegacy) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Extended == b.Extended && - a.Type == b.Type && - EqualsTableName(a.OnTable, b.OnTable) && - EqualsTableName(a.Table, b.Table) && - EqualsRefOfShowTablesOpt(a.ShowTablesOpt, b.ShowTablesOpt) && - a.Scope == b.Scope && - EqualsExpr(a.ShowCollationFilterOpt, b.ShowCollationFilterOpt) -} - -// EqualsRefOfStarExpr does deep equals. -func EqualsRefOfStarExpr(a, b *StarExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableName(a.TableName, b.TableName) -} - -// EqualsRefOfStream does deep equals. -func EqualsRefOfStream(a, b *Stream) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsComments(a.Comments, b.Comments) && - EqualsSelectExpr(a.SelectExpr, b.SelectExpr) && - EqualsTableName(a.Table, b.Table) -} - -// EqualsTableExprs does deep equals. -func EqualsTableExprs(a, b TableExprs) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsTableExpr(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsTableIdent does deep equals. -func EqualsTableIdent(a, b TableIdent) bool { - return a.v == b.v -} - -// EqualsTableName does deep equals. -func EqualsTableName(a, b TableName) bool { - return EqualsTableIdent(a.Name, b.Name) && - EqualsTableIdent(a.Qualifier, b.Qualifier) -} - -// EqualsTableNames does deep equals. -func EqualsTableNames(a, b TableNames) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsTableName(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfTableSpec does deep equals. -func EqualsRefOfTableSpec(a, b *TableSpec) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsSliceOfRefOfColumnDefinition(a.Columns, b.Columns) && - EqualsSliceOfRefOfIndexDefinition(a.Indexes, b.Indexes) && - EqualsSliceOfRefOfConstraintDefinition(a.Constraints, b.Constraints) && - EqualsTableOptions(a.Options, b.Options) -} - -// EqualsRefOfUnionSelect does deep equals. -func EqualsRefOfUnionSelect(a, b *UnionSelect) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Distinct == b.Distinct && - EqualsSelectStatement(a.Statement, b.Statement) -} - -// EqualsRefOfUnlockTables does deep equals. -func EqualsRefOfUnlockTables(a, b *UnlockTables) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return true -} - -// EqualsRefOfUpdate does deep equals. -func EqualsRefOfUpdate(a, b *Update) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsComments(a.Comments, b.Comments) && - a.Ignore == b.Ignore && - EqualsTableExprs(a.TableExprs, b.TableExprs) && - EqualsUpdateExprs(a.Exprs, b.Exprs) && - EqualsRefOfWhere(a.Where, b.Where) && - EqualsOrderBy(a.OrderBy, b.OrderBy) && - EqualsRefOfLimit(a.Limit, b.Limit) -} - -// EqualsRefOfUpdateExpr does deep equals. -func EqualsRefOfUpdateExpr(a, b *UpdateExpr) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsRefOfColName(a.Name, b.Name) && - EqualsExpr(a.Expr, b.Expr) -} - -// EqualsUpdateExprs does deep equals. -func EqualsUpdateExprs(a, b UpdateExprs) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfUpdateExpr(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfUse does deep equals. -func EqualsRefOfUse(a, b *Use) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableIdent(a.DBName, b.DBName) -} - -// EqualsRefOfVStream does deep equals. -func EqualsRefOfVStream(a, b *VStream) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsComments(a.Comments, b.Comments) && - EqualsSelectExpr(a.SelectExpr, b.SelectExpr) && - EqualsTableName(a.Table, b.Table) && - EqualsRefOfWhere(a.Where, b.Where) && - EqualsRefOfLimit(a.Limit, b.Limit) -} - -// EqualsVindexParam does deep equals. -func EqualsVindexParam(a, b VindexParam) bool { - return a.Val == b.Val && - EqualsColIdent(a.Key, b.Key) -} - -// EqualsRefOfVindexSpec does deep equals. -func EqualsRefOfVindexSpec(a, b *VindexSpec) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColIdent(a.Name, b.Name) && - EqualsColIdent(a.Type, b.Type) && - EqualsSliceOfVindexParam(a.Params, b.Params) -} - -// EqualsRefOfWhen does deep equals. -func EqualsRefOfWhen(a, b *When) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsExpr(a.Cond, b.Cond) && - EqualsExpr(a.Val, b.Val) -} - -// EqualsRefOfWhere does deep equals. -func EqualsRefOfWhere(a, b *Where) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Type == b.Type && - EqualsExpr(a.Expr, b.Expr) -} - -// EqualsSliceOfRefOfColumnDefinition does deep equals. -func EqualsSliceOfRefOfColumnDefinition(a, b []*ColumnDefinition) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfColumnDefinition(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfTableOption does deep equals. -func EqualsRefOfTableOption(a, b *TableOption) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Name == b.Name && - a.String == b.String && - EqualsRefOfLiteral(a.Value, b.Value) && - EqualsTableNames(a.Tables, b.Tables) -} - -// EqualsSliceOfCollateAndCharset does deep equals. -func EqualsSliceOfCollateAndCharset(a, b []CollateAndCharset) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsCollateAndCharset(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsSliceOfAlterOption does deep equals. -func EqualsSliceOfAlterOption(a, b []AlterOption) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsAlterOption(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsSliceOfRefOfRenameTablePair does deep equals. -func EqualsSliceOfRefOfRenameTablePair(a, b []*RenameTablePair) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfRenameTablePair(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsSliceOfRefOfWhen does deep equals. -func EqualsSliceOfRefOfWhen(a, b []*When) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfWhen(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfBool does deep equals. -func EqualsRefOfBool(a, b *bool) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return *a == *b -} - -// EqualsSliceOfRefOfUnionSelect does deep equals. -func EqualsSliceOfRefOfUnionSelect(a, b []*UnionSelect) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfUnionSelect(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsSliceOfColIdent does deep equals. -func EqualsSliceOfColIdent(a, b []ColIdent) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsColIdent(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsColumnType does deep equals. -func EqualsColumnType(a, b ColumnType) bool { - return a.Type == b.Type && - a.Unsigned == b.Unsigned && - a.Zerofill == b.Zerofill && - a.Charset == b.Charset && - a.Collate == b.Collate && - EqualsRefOfColumnTypeOptions(a.Options, b.Options) && - EqualsRefOfLiteral(a.Length, b.Length) && - EqualsRefOfLiteral(a.Scale, b.Scale) && - EqualsSliceOfString(a.EnumValues, b.EnumValues) -} - -// EqualsRefOfColumnTypeOptions does deep equals. -func EqualsRefOfColumnTypeOptions(a, b *ColumnTypeOptions) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.NotNull == b.NotNull && - a.Autoincrement == b.Autoincrement && - EqualsExpr(a.Default, b.Default) && - EqualsExpr(a.OnUpdate, b.OnUpdate) && - EqualsRefOfLiteral(a.Comment, b.Comment) && - a.KeyOpt == b.KeyOpt -} - -// EqualsSliceOfString does deep equals. -func EqualsSliceOfString(a, b []string) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if a[i] != b[i] { - return false - } - } - return true -} - -// EqualsSliceOfRefOfIndexColumn does deep equals. -func EqualsSliceOfRefOfIndexColumn(a, b []*IndexColumn) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfIndexColumn(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsSliceOfRefOfIndexOption does deep equals. -func EqualsSliceOfRefOfIndexOption(a, b []*IndexOption) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfIndexOption(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsTableAndLockTypes does deep equals. -func EqualsTableAndLockTypes(a, b TableAndLockTypes) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfTableAndLockType(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsSliceOfRefOfPartitionDefinition does deep equals. -func EqualsSliceOfRefOfPartitionDefinition(a, b []*PartitionDefinition) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfPartitionDefinition(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsSliceOfCharacteristic does deep equals. -func EqualsSliceOfCharacteristic(a, b []Characteristic) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsCharacteristic(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsRefOfShowTablesOpt does deep equals. -func EqualsRefOfShowTablesOpt(a, b *ShowTablesOpt) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Full == b.Full && - a.DbName == b.DbName && - EqualsRefOfShowFilter(a.Filter, b.Filter) -} - -// EqualsSliceOfRefOfIndexDefinition does deep equals. -func EqualsSliceOfRefOfIndexDefinition(a, b []*IndexDefinition) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfIndexDefinition(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsSliceOfRefOfConstraintDefinition does deep equals. -func EqualsSliceOfRefOfConstraintDefinition(a, b []*ConstraintDefinition) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsRefOfConstraintDefinition(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsSliceOfVindexParam does deep equals. -func EqualsSliceOfVindexParam(a, b []VindexParam) bool { - if len(a) != len(b) { - return false - } - for i := 0; i < len(a); i++ { - if !EqualsVindexParam(a[i], b[i]) { - return false - } - } - return true -} - -// EqualsCollateAndCharset does deep equals. -func EqualsCollateAndCharset(a, b CollateAndCharset) bool { - return a.IsDefault == b.IsDefault && - a.Value == b.Value && - a.Type == b.Type -} - -// EqualsRefOfRenameTablePair does deep equals. -func EqualsRefOfRenameTablePair(a, b *RenameTablePair) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableName(a.FromTable, b.FromTable) && - EqualsTableName(a.ToTable, b.ToTable) -} - -// EqualsRefOfIndexColumn does deep equals. -func EqualsRefOfIndexColumn(a, b *IndexColumn) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsColIdent(a.Column, b.Column) && - EqualsRefOfLiteral(a.Length, b.Length) && - a.Direction == b.Direction -} - -// EqualsRefOfIndexOption does deep equals. -func EqualsRefOfIndexOption(a, b *IndexOption) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.Name == b.Name && - a.String == b.String && - EqualsRefOfLiteral(a.Value, b.Value) -} - -// EqualsRefOfTableAndLockType does deep equals. -func EqualsRefOfTableAndLockType(a, b *TableAndLockType) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return EqualsTableExpr(a.Table, b.Table) && - a.Lock == b.Lock -} From 968f8a4bc70373b46e194e7e81fef89b18b9e907 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Sat, 13 Mar 2021 07:55:23 +0100 Subject: [PATCH 13/13] fix comments on generated methods Signed-off-by: Andres Taylor --- go/tools/asthelpergen/clone_gen.go | 30 +- go/tools/asthelpergen/equals_gen.go | 10 +- go/tools/asthelpergen/integration/clone.go | 40 +-- go/vt/sqlparser/clone.go | 372 ++++++++++----------- 4 files changed, 233 insertions(+), 219 deletions(-) diff --git a/go/tools/asthelpergen/clone_gen.go b/go/tools/asthelpergen/clone_gen.go index 771d6ad0d8b..8d86318c1a9 100644 --- a/go/tools/asthelpergen/clone_gen.go +++ b/go/tools/asthelpergen/clone_gen.go @@ -61,8 +61,22 @@ func (c *cloneGen) visitInterface(t types.Type, _ *types.Interface) error { const cloneName = "Clone" -func (c *cloneGen) addFunc(name string, code jen.Code) { - c.methods = append(c.methods, jen.Comment(name+" creates a deep clone of the input."), code) +type methodType int + +const ( + clone methodType = iota + equals +) + +func (c *cloneGen) addFunc(name string, typ methodType, code jen.Code) { + var comment string + switch typ { + case clone: + comment = " creates a deep clone of the input." + case equals: + comment = " does deep equals between the two objects." + } + c.methods = append(c.methods, jen.Comment(name+comment), code) } // readValueOfType produces code to read the expression of type `t`, and adds the type to the todo-list @@ -83,7 +97,7 @@ func (c *cloneGen) readValueOfType(t types.Type, expr jen.Code) jen.Code { func (c *cloneGen) makeStructCloneMethod(t types.Type) error { typeString := types.TypeString(t, noQualifier) funcName := cloneName + printableTypeName(t) - c.addFunc(funcName, + c.addFunc(funcName, clone, jen.Func().Id(funcName).Call(jen.Id("n").Id(typeString)).Id(typeString).Block( jen.Return(jen.Op("*").Add(c.readValueOfType(types.NewPointer(t), jen.Op("&").Id("n")))), )) @@ -95,7 +109,7 @@ func (c *cloneGen) makeSliceCloneMethod(t types.Type, slice *types.Slice) error name := printableTypeName(t) funcName := cloneName + name - c.addFunc(funcName, + c.addFunc(funcName, clone, //func (n Bytes) Clone() Bytes { jen.Func().Id(funcName).Call(jen.Id("n").Id(typeString)).Id(typeString).Block( // res := make(Bytes, len(n)) @@ -180,7 +194,7 @@ func (c *cloneGen) makeInterfaceCloneMethod(t types.Type, iface *types.Interface funcName := cloneName + typeName funcDecl := jen.Func().Id(funcName).Call(jen.Id("in").Id(typeString)).Id(typeString).Block(stmts...) - c.addFunc(funcName, funcDecl) + c.addFunc(funcName, clone, funcDecl) return nil } @@ -188,7 +202,7 @@ func (c *cloneGen) makePtrCloneMethod(t types.Type, ptr *types.Pointer) { receiveType := types.TypeString(t, noQualifier) funcName := "Clone" + printableTypeName(t) - c.addFunc(funcName, + c.addFunc(funcName, clone, jen.Func().Id(funcName).Call(jen.Id("n").Id(receiveType)).Id(receiveType).Block( ifNilReturnNil("n"), jen.Id("out").Op(":=").Add(c.readValueOfType(ptr.Elem(), jen.Op("*").Id("n"))), @@ -284,7 +298,7 @@ func (c *cloneGen) makePtrToStructCloneMethod(t types.Type, strct *types.Struct) funcDeclaration := jen.Func().Id(funcName).Call(jen.Id("n").Id(receiveType)).Id(receiveType) if receiveType == c.exceptType { - c.addFunc(funcName, funcDeclaration.Block( + c.addFunc(funcName, clone, funcDeclaration.Block( jen.Return(jen.Id("n")), )) return @@ -316,7 +330,7 @@ func (c *cloneGen) makePtrToStructCloneMethod(t types.Type, strct *types.Struct) jen.Return(jen.Op("&").Id("out")), ) - c.addFunc(funcName, + c.addFunc(funcName, clone, funcDeclaration.Block(stmts...), ) } diff --git a/go/tools/asthelpergen/equals_gen.go b/go/tools/asthelpergen/equals_gen.go index 341528752ec..76756bf0bec 100644 --- a/go/tools/asthelpergen/equals_gen.go +++ b/go/tools/asthelpergen/equals_gen.go @@ -62,7 +62,7 @@ func (c *cloneGen) makeInterfaceEqualsMethod(t types.Type, iface *types.Interfac typeString := types.TypeString(t, noQualifier) funcName := equalsName + printableTypeName(t) funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("inA"), jen.Id("inB")).Id(typeString)).Bool().Block(stmts...) - c.addFunc(funcName, funcDecl) + c.addFunc(funcName, equals, funcDecl) return nil } @@ -97,7 +97,7 @@ func (c *cloneGen) makeStructEqualsMethod(t types.Type, strct *types.Struct) err funcName := equalsName + printableTypeName(t) funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("a"), jen.Id("b")).Id(typeString)).Bool(). Block(jen.Return(c.compareAllStructFields(strct))) - c.addFunc(funcName, funcDecl) + c.addFunc(funcName, equals, funcDecl) return nil } @@ -156,7 +156,7 @@ func (c *cloneGen) makePtrToStructEqualsMethod(t types.Type, strct *types.Struct jen.Return(c.compareAllStructFields(strct)), } - c.addFunc(funcName, funcDeclaration.Block(stmts...)) + c.addFunc(funcName, equals, funcDeclaration.Block(stmts...)) } func (c *cloneGen) makePtrToBasicEqualsMethod(t types.Type) { /* @@ -180,7 +180,7 @@ func (c *cloneGen) makePtrToBasicEqualsMethod(t types.Type) { jen.If(jen.Id("a == nil").Op("||").Id("b == nil")).Block(jen.Return(jen.False())), jen.Return(jen.Id("*a == *b")), } - c.addFunc(funcName, funcDeclaration.Block(stmts...)) + c.addFunc(funcName, equals, funcDeclaration.Block(stmts...)) } func (c *cloneGen) makeSliceEqualsMethod(t types.Type, slice *types.Slice) error { @@ -207,6 +207,6 @@ func (c *cloneGen) makeSliceEqualsMethod(t types.Type, slice *types.Slice) error typeString := types.TypeString(t, noQualifier) funcName := equalsName + printableTypeName(t) funcDecl := jen.Func().Id(funcName).Call(jen.List(jen.Id("a"), jen.Id("b")).Id(typeString)).Bool().Block(stmts...) - c.addFunc(funcName, funcDecl) + c.addFunc(funcName, equals, funcDecl) return nil } diff --git a/go/tools/asthelpergen/integration/clone.go b/go/tools/asthelpergen/integration/clone.go index df3a2376dfc..fda3a414e66 100644 --- a/go/tools/asthelpergen/integration/clone.go +++ b/go/tools/asthelpergen/integration/clone.go @@ -53,7 +53,7 @@ func CloneAST(in AST) AST { } } -// EqualsAST creates a deep clone of the input. +// EqualsAST does deep equals between the two objects. func EqualsAST(inA, inB AST) bool { if inA == nil && inB == nil { return true @@ -154,7 +154,7 @@ func CloneSubIface(in SubIface) SubIface { } } -// EqualsSubIface creates a deep clone of the input. +// EqualsSubIface does deep equals between the two objects. func EqualsSubIface(inA, inB SubIface) bool { if inA == nil && inB == nil { return true @@ -182,7 +182,7 @@ func CloneBytes(n Bytes) Bytes { return res } -// EqualsBytes creates a deep clone of the input. +// EqualsBytes does deep equals between the two objects. func EqualsBytes(a, b Bytes) bool { if len(a) != len(b) { return false @@ -200,7 +200,7 @@ func CloneInterfaceContainer(n InterfaceContainer) InterfaceContainer { return *CloneRefOfInterfaceContainer(&n) } -// EqualsInterfaceContainer creates a deep clone of the input. +// EqualsInterfaceContainer does deep equals between the two objects. func EqualsInterfaceContainer(a, b InterfaceContainer) bool { return true } @@ -214,7 +214,7 @@ func CloneInterfaceSlice(n InterfaceSlice) InterfaceSlice { return res } -// EqualsInterfaceSlice creates a deep clone of the input. +// EqualsInterfaceSlice does deep equals between the two objects. func EqualsInterfaceSlice(a, b InterfaceSlice) bool { if len(a) != len(b) { return false @@ -236,7 +236,7 @@ func CloneRefOfLeaf(n *Leaf) *Leaf { return &out } -// EqualsRefOfLeaf creates a deep clone of the input. +// EqualsRefOfLeaf does deep equals between the two objects. func EqualsRefOfLeaf(a, b *Leaf) bool { if a == b { return true @@ -256,7 +256,7 @@ func CloneLeafSlice(n LeafSlice) LeafSlice { return res } -// EqualsLeafSlice creates a deep clone of the input. +// EqualsLeafSlice does deep equals between the two objects. func EqualsLeafSlice(a, b LeafSlice) bool { if len(a) != len(b) { return false @@ -274,7 +274,7 @@ func CloneRefOfNoCloneType(n *NoCloneType) *NoCloneType { return n } -// EqualsRefOfNoCloneType creates a deep clone of the input. +// EqualsRefOfNoCloneType does deep equals between the two objects. func EqualsRefOfNoCloneType(a, b *NoCloneType) bool { if a == b { return true @@ -296,7 +296,7 @@ func CloneRefOfRefContainer(n *RefContainer) *RefContainer { return &out } -// EqualsRefOfRefContainer creates a deep clone of the input. +// EqualsRefOfRefContainer does deep equals between the two objects. func EqualsRefOfRefContainer(a, b *RefContainer) bool { if a == b { return true @@ -321,7 +321,7 @@ func CloneRefOfRefSliceContainer(n *RefSliceContainer) *RefSliceContainer { return &out } -// EqualsRefOfRefSliceContainer creates a deep clone of the input. +// EqualsRefOfRefSliceContainer does deep equals between the two objects. func EqualsRefOfRefSliceContainer(a, b *RefSliceContainer) bool { if a == b { return true @@ -345,7 +345,7 @@ func CloneRefOfSubImpl(n *SubImpl) *SubImpl { return &out } -// EqualsRefOfSubImpl creates a deep clone of the input. +// EqualsRefOfSubImpl does deep equals between the two objects. func EqualsRefOfSubImpl(a, b *SubImpl) bool { if a == b { return true @@ -362,7 +362,7 @@ func CloneValueContainer(n ValueContainer) ValueContainer { return *CloneRefOfValueContainer(&n) } -// EqualsValueContainer creates a deep clone of the input. +// EqualsValueContainer does deep equals between the two objects. func EqualsValueContainer(a, b ValueContainer) bool { return a.NotASTType == b.NotASTType && EqualsAST(a.ASTType, b.ASTType) && @@ -374,7 +374,7 @@ func CloneValueSliceContainer(n ValueSliceContainer) ValueSliceContainer { return *CloneRefOfValueSliceContainer(&n) } -// EqualsValueSliceContainer creates a deep clone of the input. +// EqualsValueSliceContainer does deep equals between the two objects. func EqualsValueSliceContainer(a, b ValueSliceContainer) bool { return EqualsSliceOfAST(a.ASTElements, b.ASTElements) && EqualsSliceOfInt(a.NotASTElements, b.NotASTElements) && @@ -391,7 +391,7 @@ func CloneRefOfInterfaceContainer(n *InterfaceContainer) *InterfaceContainer { return &out } -// EqualsRefOfInterfaceContainer creates a deep clone of the input. +// EqualsRefOfInterfaceContainer does deep equals between the two objects. func EqualsRefOfInterfaceContainer(a, b *InterfaceContainer) bool { if a == b { return true @@ -411,7 +411,7 @@ func CloneSliceOfAST(n []AST) []AST { return res } -// EqualsSliceOfAST creates a deep clone of the input. +// EqualsSliceOfAST does deep equals between the two objects. func EqualsSliceOfAST(a, b []AST) bool { if len(a) != len(b) { return false @@ -431,7 +431,7 @@ func CloneSliceOfInt(n []int) []int { return res } -// EqualsSliceOfInt creates a deep clone of the input. +// EqualsSliceOfInt does deep equals between the two objects. func EqualsSliceOfInt(a, b []int) bool { if len(a) != len(b) { return false @@ -453,7 +453,7 @@ func CloneSliceOfRefOfLeaf(n []*Leaf) []*Leaf { return res } -// EqualsSliceOfRefOfLeaf creates a deep clone of the input. +// EqualsSliceOfRefOfLeaf does deep equals between the two objects. func EqualsSliceOfRefOfLeaf(a, b []*Leaf) bool { if len(a) != len(b) { return false @@ -466,7 +466,7 @@ func EqualsSliceOfRefOfLeaf(a, b []*Leaf) bool { return true } -// EqualsRefOfBool creates a deep clone of the input. +// EqualsRefOfBool does deep equals between the two objects. func EqualsRefOfBool(a, b *bool) bool { if a == b { return true @@ -497,7 +497,7 @@ func CloneRefOfValueContainer(n *ValueContainer) *ValueContainer { return &out } -// EqualsRefOfValueContainer creates a deep clone of the input. +// EqualsRefOfValueContainer does deep equals between the two objects. func EqualsRefOfValueContainer(a, b *ValueContainer) bool { if a == b { return true @@ -522,7 +522,7 @@ func CloneRefOfValueSliceContainer(n *ValueSliceContainer) *ValueSliceContainer return &out } -// EqualsRefOfValueSliceContainer creates a deep clone of the input. +// EqualsRefOfValueSliceContainer does deep equals between the two objects. func EqualsRefOfValueSliceContainer(a, b *ValueSliceContainer) bool { if a == b { return true diff --git a/go/vt/sqlparser/clone.go b/go/vt/sqlparser/clone.go index e9210d81e45..7c70637a4cf 100644 --- a/go/vt/sqlparser/clone.go +++ b/go/vt/sqlparser/clone.go @@ -67,7 +67,7 @@ func CloneAlterOption(in AlterOption) AlterOption { } } -// EqualsAlterOption creates a deep clone of the input. +// EqualsAlterOption does deep equals between the two objects. func EqualsAlterOption(inA, inB AlterOption) bool { if inA == nil && inB == nil { return true @@ -212,7 +212,7 @@ func CloneCharacteristic(in Characteristic) Characteristic { } } -// EqualsCharacteristic creates a deep clone of the input. +// EqualsCharacteristic does deep equals between the two objects. func EqualsCharacteristic(inA, inB Characteristic) bool { if inA == nil && inB == nil { return true @@ -257,7 +257,7 @@ func CloneColTuple(in ColTuple) ColTuple { } } -// EqualsColTuple creates a deep clone of the input. +// EqualsColTuple does deep equals between the two objects. func EqualsColTuple(inA, inB ColTuple) bool { if inA == nil && inB == nil { return true @@ -306,7 +306,7 @@ func CloneConstraintInfo(in ConstraintInfo) ConstraintInfo { } } -// EqualsConstraintInfo creates a deep clone of the input. +// EqualsConstraintInfo does deep equals between the two objects. func EqualsConstraintInfo(inA, inB ConstraintInfo) bool { if inA == nil && inB == nil { return true @@ -351,7 +351,7 @@ func CloneDBDDLStatement(in DBDDLStatement) DBDDLStatement { } } -// EqualsDBDDLStatement creates a deep clone of the input. +// EqualsDBDDLStatement does deep equals between the two objects. func EqualsDBDDLStatement(inA, inB DBDDLStatement) bool { if inA == nil && inB == nil { return true @@ -412,7 +412,7 @@ func CloneDDLStatement(in DDLStatement) DDLStatement { } } -// EqualsDDLStatement creates a deep clone of the input. +// EqualsDDLStatement does deep equals between the two objects. func EqualsDDLStatement(inA, inB DDLStatement) bool { if inA == nil && inB == nil { return true @@ -491,7 +491,7 @@ func CloneExplain(in Explain) Explain { } } -// EqualsExplain creates a deep clone of the input. +// EqualsExplain does deep equals between the two objects. func EqualsExplain(inA, inB Explain) bool { if inA == nil && inB == nil { return true @@ -592,7 +592,7 @@ func CloneExpr(in Expr) Expr { } } -// EqualsExpr creates a deep clone of the input. +// EqualsExpr does deep equals between the two objects. func EqualsExpr(inA, inB Expr) bool { if inA == nil && inB == nil { return true @@ -813,7 +813,7 @@ func CloneInsertRows(in InsertRows) InsertRows { } } -// EqualsInsertRows creates a deep clone of the input. +// EqualsInsertRows does deep equals between the two objects. func EqualsInsertRows(inA, inB InsertRows) bool { if inA == nil && inB == nil { return true @@ -1152,7 +1152,7 @@ func CloneSQLNode(in SQLNode) SQLNode { } } -// EqualsSQLNode creates a deep clone of the input. +// EqualsSQLNode does deep equals between the two objects. func EqualsSQLNode(inA, inB SQLNode) bool { if inA == nil && inB == nil { return true @@ -2049,7 +2049,7 @@ func CloneSelectExpr(in SelectExpr) SelectExpr { } } -// EqualsSelectExpr creates a deep clone of the input. +// EqualsSelectExpr does deep equals between the two objects. func EqualsSelectExpr(inA, inB SelectExpr) bool { if inA == nil && inB == nil { return true @@ -2100,7 +2100,7 @@ func CloneSelectStatement(in SelectStatement) SelectStatement { } } -// EqualsSelectStatement creates a deep clone of the input. +// EqualsSelectStatement does deep equals between the two objects. func EqualsSelectStatement(inA, inB SelectStatement) bool { if inA == nil && inB == nil { return true @@ -2151,7 +2151,7 @@ func CloneShowInternal(in ShowInternal) ShowInternal { } } -// EqualsShowInternal creates a deep clone of the input. +// EqualsShowInternal does deep equals between the two objects. func EqualsShowInternal(inA, inB ShowInternal) bool { if inA == nil && inB == nil { return true @@ -2200,7 +2200,7 @@ func CloneSimpleTableExpr(in SimpleTableExpr) SimpleTableExpr { } } -// EqualsSimpleTableExpr creates a deep clone of the input. +// EqualsSimpleTableExpr does deep equals between the two objects. func EqualsSimpleTableExpr(inA, inB SimpleTableExpr) bool { if inA == nil && inB == nil { return true @@ -2317,7 +2317,7 @@ func CloneStatement(in Statement) Statement { } } -// EqualsStatement creates a deep clone of the input. +// EqualsStatement does deep equals between the two objects. func EqualsStatement(inA, inB Statement) bool { if inA == nil && inB == nil { return true @@ -2584,7 +2584,7 @@ func CloneTableExpr(in TableExpr) TableExpr { } } -// EqualsTableExpr creates a deep clone of the input. +// EqualsTableExpr does deep equals between the two objects. func EqualsTableExpr(inA, inB TableExpr) bool { if inA == nil && inB == nil { return true @@ -2629,7 +2629,7 @@ func CloneRefOfAddColumns(n *AddColumns) *AddColumns { return &out } -// EqualsRefOfAddColumns creates a deep clone of the input. +// EqualsRefOfAddColumns does deep equals between the two objects. func EqualsRefOfAddColumns(a, b *AddColumns) bool { if a == b { return true @@ -2652,7 +2652,7 @@ func CloneRefOfAddConstraintDefinition(n *AddConstraintDefinition) *AddConstrain return &out } -// EqualsRefOfAddConstraintDefinition creates a deep clone of the input. +// EqualsRefOfAddConstraintDefinition does deep equals between the two objects. func EqualsRefOfAddConstraintDefinition(a, b *AddConstraintDefinition) bool { if a == b { return true @@ -2673,7 +2673,7 @@ func CloneRefOfAddIndexDefinition(n *AddIndexDefinition) *AddIndexDefinition { return &out } -// EqualsRefOfAddIndexDefinition creates a deep clone of the input. +// EqualsRefOfAddIndexDefinition does deep equals between the two objects. func EqualsRefOfAddIndexDefinition(a, b *AddIndexDefinition) bool { if a == b { return true @@ -2693,7 +2693,7 @@ func CloneRefOfAlterCharset(n *AlterCharset) *AlterCharset { return &out } -// EqualsRefOfAlterCharset creates a deep clone of the input. +// EqualsRefOfAlterCharset does deep equals between the two objects. func EqualsRefOfAlterCharset(a, b *AlterCharset) bool { if a == b { return true @@ -2716,7 +2716,7 @@ func CloneRefOfAlterColumn(n *AlterColumn) *AlterColumn { return &out } -// EqualsRefOfAlterColumn creates a deep clone of the input. +// EqualsRefOfAlterColumn does deep equals between the two objects. func EqualsRefOfAlterColumn(a, b *AlterColumn) bool { if a == b { return true @@ -2742,7 +2742,7 @@ func CloneRefOfChangeColumn(n *ChangeColumn) *ChangeColumn { return &out } -// EqualsRefOfChangeColumn creates a deep clone of the input. +// EqualsRefOfChangeColumn does deep equals between the two objects. func EqualsRefOfChangeColumn(a, b *ChangeColumn) bool { if a == b { return true @@ -2766,7 +2766,7 @@ func CloneRefOfDropColumn(n *DropColumn) *DropColumn { return &out } -// EqualsRefOfDropColumn creates a deep clone of the input. +// EqualsRefOfDropColumn does deep equals between the two objects. func EqualsRefOfDropColumn(a, b *DropColumn) bool { if a == b { return true @@ -2786,7 +2786,7 @@ func CloneRefOfDropKey(n *DropKey) *DropKey { return &out } -// EqualsRefOfDropKey creates a deep clone of the input. +// EqualsRefOfDropKey does deep equals between the two objects. func EqualsRefOfDropKey(a, b *DropKey) bool { if a == b { return true @@ -2807,7 +2807,7 @@ func CloneRefOfForce(n *Force) *Force { return &out } -// EqualsRefOfForce creates a deep clone of the input. +// EqualsRefOfForce does deep equals between the two objects. func EqualsRefOfForce(a, b *Force) bool { if a == b { return true @@ -2827,7 +2827,7 @@ func CloneRefOfKeyState(n *KeyState) *KeyState { return &out } -// EqualsRefOfKeyState creates a deep clone of the input. +// EqualsRefOfKeyState does deep equals between the two objects. func EqualsRefOfKeyState(a, b *KeyState) bool { if a == b { return true @@ -2847,7 +2847,7 @@ func CloneRefOfLockOption(n *LockOption) *LockOption { return &out } -// EqualsRefOfLockOption creates a deep clone of the input. +// EqualsRefOfLockOption does deep equals between the two objects. func EqualsRefOfLockOption(a, b *LockOption) bool { if a == b { return true @@ -2870,7 +2870,7 @@ func CloneRefOfModifyColumn(n *ModifyColumn) *ModifyColumn { return &out } -// EqualsRefOfModifyColumn creates a deep clone of the input. +// EqualsRefOfModifyColumn does deep equals between the two objects. func EqualsRefOfModifyColumn(a, b *ModifyColumn) bool { if a == b { return true @@ -2893,7 +2893,7 @@ func CloneRefOfOrderByOption(n *OrderByOption) *OrderByOption { return &out } -// EqualsRefOfOrderByOption creates a deep clone of the input. +// EqualsRefOfOrderByOption does deep equals between the two objects. func EqualsRefOfOrderByOption(a, b *OrderByOption) bool { if a == b { return true @@ -2913,7 +2913,7 @@ func CloneRefOfRenameIndex(n *RenameIndex) *RenameIndex { return &out } -// EqualsRefOfRenameIndex creates a deep clone of the input. +// EqualsRefOfRenameIndex does deep equals between the two objects. func EqualsRefOfRenameIndex(a, b *RenameIndex) bool { if a == b { return true @@ -2935,7 +2935,7 @@ func CloneRefOfRenameTableName(n *RenameTableName) *RenameTableName { return &out } -// EqualsRefOfRenameTableName creates a deep clone of the input. +// EqualsRefOfRenameTableName does deep equals between the two objects. func EqualsRefOfRenameTableName(a, b *RenameTableName) bool { if a == b { return true @@ -2955,7 +2955,7 @@ func CloneTableOptions(n TableOptions) TableOptions { return res } -// EqualsTableOptions creates a deep clone of the input. +// EqualsTableOptions does deep equals between the two objects. func EqualsTableOptions(a, b TableOptions) bool { if len(a) != len(b) { return false @@ -2977,7 +2977,7 @@ func CloneRefOfTablespaceOperation(n *TablespaceOperation) *TablespaceOperation return &out } -// EqualsRefOfTablespaceOperation creates a deep clone of the input. +// EqualsRefOfTablespaceOperation does deep equals between the two objects. func EqualsRefOfTablespaceOperation(a, b *TablespaceOperation) bool { if a == b { return true @@ -2997,7 +2997,7 @@ func CloneRefOfValidation(n *Validation) *Validation { return &out } -// EqualsRefOfValidation creates a deep clone of the input. +// EqualsRefOfValidation does deep equals between the two objects. func EqualsRefOfValidation(a, b *Validation) bool { if a == b { return true @@ -3015,7 +3015,7 @@ func CloneListArg(n ListArg) ListArg { return res } -// EqualsListArg creates a deep clone of the input. +// EqualsListArg does deep equals between the two objects. func EqualsListArg(a, b ListArg) bool { if len(a) != len(b) { return false @@ -3038,7 +3038,7 @@ func CloneRefOfSubquery(n *Subquery) *Subquery { return &out } -// EqualsRefOfSubquery creates a deep clone of the input. +// EqualsRefOfSubquery does deep equals between the two objects. func EqualsRefOfSubquery(a, b *Subquery) bool { if a == b { return true @@ -3058,7 +3058,7 @@ func CloneValTuple(n ValTuple) ValTuple { return res } -// EqualsValTuple creates a deep clone of the input. +// EqualsValTuple does deep equals between the two objects. func EqualsValTuple(a, b ValTuple) bool { if len(a) != len(b) { return false @@ -3081,7 +3081,7 @@ func CloneRefOfCheckConstraintDefinition(n *CheckConstraintDefinition) *CheckCon return &out } -// EqualsRefOfCheckConstraintDefinition creates a deep clone of the input. +// EqualsRefOfCheckConstraintDefinition does deep equals between the two objects. func EqualsRefOfCheckConstraintDefinition(a, b *CheckConstraintDefinition) bool { if a == b { return true @@ -3105,7 +3105,7 @@ func CloneRefOfForeignKeyDefinition(n *ForeignKeyDefinition) *ForeignKeyDefiniti return &out } -// EqualsRefOfForeignKeyDefinition creates a deep clone of the input. +// EqualsRefOfForeignKeyDefinition does deep equals between the two objects. func EqualsRefOfForeignKeyDefinition(a, b *ForeignKeyDefinition) bool { if a == b { return true @@ -3130,7 +3130,7 @@ func CloneRefOfAlterDatabase(n *AlterDatabase) *AlterDatabase { return &out } -// EqualsRefOfAlterDatabase creates a deep clone of the input. +// EqualsRefOfAlterDatabase does deep equals between the two objects. func EqualsRefOfAlterDatabase(a, b *AlterDatabase) bool { if a == b { return true @@ -3155,7 +3155,7 @@ func CloneRefOfCreateDatabase(n *CreateDatabase) *CreateDatabase { return &out } -// EqualsRefOfCreateDatabase creates a deep clone of the input. +// EqualsRefOfCreateDatabase does deep equals between the two objects. func EqualsRefOfCreateDatabase(a, b *CreateDatabase) bool { if a == b { return true @@ -3180,7 +3180,7 @@ func CloneRefOfDropDatabase(n *DropDatabase) *DropDatabase { return &out } -// EqualsRefOfDropDatabase creates a deep clone of the input. +// EqualsRefOfDropDatabase does deep equals between the two objects. func EqualsRefOfDropDatabase(a, b *DropDatabase) bool { if a == b { return true @@ -3205,7 +3205,7 @@ func CloneRefOfAlterTable(n *AlterTable) *AlterTable { return &out } -// EqualsRefOfAlterTable creates a deep clone of the input. +// EqualsRefOfAlterTable does deep equals between the two objects. func EqualsRefOfAlterTable(a, b *AlterTable) bool { if a == b { return true @@ -3231,7 +3231,7 @@ func CloneRefOfAlterView(n *AlterView) *AlterView { return &out } -// EqualsRefOfAlterView creates a deep clone of the input. +// EqualsRefOfAlterView does deep equals between the two objects. func EqualsRefOfAlterView(a, b *AlterView) bool { if a == b { return true @@ -3260,7 +3260,7 @@ func CloneRefOfCreateTable(n *CreateTable) *CreateTable { return &out } -// EqualsRefOfCreateTable creates a deep clone of the input. +// EqualsRefOfCreateTable does deep equals between the two objects. func EqualsRefOfCreateTable(a, b *CreateTable) bool { if a == b { return true @@ -3288,7 +3288,7 @@ func CloneRefOfCreateView(n *CreateView) *CreateView { return &out } -// EqualsRefOfCreateView creates a deep clone of the input. +// EqualsRefOfCreateView does deep equals between the two objects. func EqualsRefOfCreateView(a, b *CreateView) bool { if a == b { return true @@ -3316,7 +3316,7 @@ func CloneRefOfDropTable(n *DropTable) *DropTable { return &out } -// EqualsRefOfDropTable creates a deep clone of the input. +// EqualsRefOfDropTable does deep equals between the two objects. func EqualsRefOfDropTable(a, b *DropTable) bool { if a == b { return true @@ -3339,7 +3339,7 @@ func CloneRefOfDropView(n *DropView) *DropView { return &out } -// EqualsRefOfDropView creates a deep clone of the input. +// EqualsRefOfDropView does deep equals between the two objects. func EqualsRefOfDropView(a, b *DropView) bool { if a == b { return true @@ -3361,7 +3361,7 @@ func CloneRefOfRenameTable(n *RenameTable) *RenameTable { return &out } -// EqualsRefOfRenameTable creates a deep clone of the input. +// EqualsRefOfRenameTable does deep equals between the two objects. func EqualsRefOfRenameTable(a, b *RenameTable) bool { if a == b { return true @@ -3382,7 +3382,7 @@ func CloneRefOfTruncateTable(n *TruncateTable) *TruncateTable { return &out } -// EqualsRefOfTruncateTable creates a deep clone of the input. +// EqualsRefOfTruncateTable does deep equals between the two objects. func EqualsRefOfTruncateTable(a, b *TruncateTable) bool { if a == b { return true @@ -3403,7 +3403,7 @@ func CloneRefOfExplainStmt(n *ExplainStmt) *ExplainStmt { return &out } -// EqualsRefOfExplainStmt creates a deep clone of the input. +// EqualsRefOfExplainStmt does deep equals between the two objects. func EqualsRefOfExplainStmt(a, b *ExplainStmt) bool { if a == b { return true @@ -3425,7 +3425,7 @@ func CloneRefOfExplainTab(n *ExplainTab) *ExplainTab { return &out } -// EqualsRefOfExplainTab creates a deep clone of the input. +// EqualsRefOfExplainTab does deep equals between the two objects. func EqualsRefOfExplainTab(a, b *ExplainTab) bool { if a == b { return true @@ -3448,7 +3448,7 @@ func CloneRefOfAndExpr(n *AndExpr) *AndExpr { return &out } -// EqualsRefOfAndExpr creates a deep clone of the input. +// EqualsRefOfAndExpr does deep equals between the two objects. func EqualsRefOfAndExpr(a, b *AndExpr) bool { if a == b { return true @@ -3471,7 +3471,7 @@ func CloneRefOfBinaryExpr(n *BinaryExpr) *BinaryExpr { return &out } -// EqualsRefOfBinaryExpr creates a deep clone of the input. +// EqualsRefOfBinaryExpr does deep equals between the two objects. func EqualsRefOfBinaryExpr(a, b *BinaryExpr) bool { if a == b { return true @@ -3496,7 +3496,7 @@ func CloneRefOfCaseExpr(n *CaseExpr) *CaseExpr { return &out } -// EqualsRefOfCaseExpr creates a deep clone of the input. +// EqualsRefOfCaseExpr does deep equals between the two objects. func EqualsRefOfCaseExpr(a, b *CaseExpr) bool { if a == b { return true @@ -3514,7 +3514,7 @@ func CloneRefOfColName(n *ColName) *ColName { return n } -// EqualsRefOfColName creates a deep clone of the input. +// EqualsRefOfColName does deep equals between the two objects. func EqualsRefOfColName(a, b *ColName) bool { if a == b { return true @@ -3536,7 +3536,7 @@ func CloneRefOfCollateExpr(n *CollateExpr) *CollateExpr { return &out } -// EqualsRefOfCollateExpr creates a deep clone of the input. +// EqualsRefOfCollateExpr does deep equals between the two objects. func EqualsRefOfCollateExpr(a, b *CollateExpr) bool { if a == b { return true @@ -3560,7 +3560,7 @@ func CloneRefOfComparisonExpr(n *ComparisonExpr) *ComparisonExpr { return &out } -// EqualsRefOfComparisonExpr creates a deep clone of the input. +// EqualsRefOfComparisonExpr does deep equals between the two objects. func EqualsRefOfComparisonExpr(a, b *ComparisonExpr) bool { if a == b { return true @@ -3585,7 +3585,7 @@ func CloneRefOfConvertExpr(n *ConvertExpr) *ConvertExpr { return &out } -// EqualsRefOfConvertExpr creates a deep clone of the input. +// EqualsRefOfConvertExpr does deep equals between the two objects. func EqualsRefOfConvertExpr(a, b *ConvertExpr) bool { if a == b { return true @@ -3607,7 +3607,7 @@ func CloneRefOfConvertUsingExpr(n *ConvertUsingExpr) *ConvertUsingExpr { return &out } -// EqualsRefOfConvertUsingExpr creates a deep clone of the input. +// EqualsRefOfConvertUsingExpr does deep equals between the two objects. func EqualsRefOfConvertUsingExpr(a, b *ConvertUsingExpr) bool { if a == b { return true @@ -3630,7 +3630,7 @@ func CloneRefOfCurTimeFuncExpr(n *CurTimeFuncExpr) *CurTimeFuncExpr { return &out } -// EqualsRefOfCurTimeFuncExpr creates a deep clone of the input. +// EqualsRefOfCurTimeFuncExpr does deep equals between the two objects. func EqualsRefOfCurTimeFuncExpr(a, b *CurTimeFuncExpr) bool { if a == b { return true @@ -3651,7 +3651,7 @@ func CloneRefOfDefault(n *Default) *Default { return &out } -// EqualsRefOfDefault creates a deep clone of the input. +// EqualsRefOfDefault does deep equals between the two objects. func EqualsRefOfDefault(a, b *Default) bool { if a == b { return true @@ -3672,7 +3672,7 @@ func CloneRefOfExistsExpr(n *ExistsExpr) *ExistsExpr { return &out } -// EqualsRefOfExistsExpr creates a deep clone of the input. +// EqualsRefOfExistsExpr does deep equals between the two objects. func EqualsRefOfExistsExpr(a, b *ExistsExpr) bool { if a == b { return true @@ -3695,7 +3695,7 @@ func CloneRefOfFuncExpr(n *FuncExpr) *FuncExpr { return &out } -// EqualsRefOfFuncExpr creates a deep clone of the input. +// EqualsRefOfFuncExpr does deep equals between the two objects. func EqualsRefOfFuncExpr(a, b *FuncExpr) bool { if a == b { return true @@ -3721,7 +3721,7 @@ func CloneRefOfGroupConcatExpr(n *GroupConcatExpr) *GroupConcatExpr { return &out } -// EqualsRefOfGroupConcatExpr creates a deep clone of the input. +// EqualsRefOfGroupConcatExpr does deep equals between the two objects. func EqualsRefOfGroupConcatExpr(a, b *GroupConcatExpr) bool { if a == b { return true @@ -3746,7 +3746,7 @@ func CloneRefOfIntervalExpr(n *IntervalExpr) *IntervalExpr { return &out } -// EqualsRefOfIntervalExpr creates a deep clone of the input. +// EqualsRefOfIntervalExpr does deep equals between the two objects. func EqualsRefOfIntervalExpr(a, b *IntervalExpr) bool { if a == b { return true @@ -3768,7 +3768,7 @@ func CloneRefOfIsExpr(n *IsExpr) *IsExpr { return &out } -// EqualsRefOfIsExpr creates a deep clone of the input. +// EqualsRefOfIsExpr does deep equals between the two objects. func EqualsRefOfIsExpr(a, b *IsExpr) bool { if a == b { return true @@ -3789,7 +3789,7 @@ func CloneRefOfLiteral(n *Literal) *Literal { return &out } -// EqualsRefOfLiteral creates a deep clone of the input. +// EqualsRefOfLiteral does deep equals between the two objects. func EqualsRefOfLiteral(a, b *Literal) bool { if a == b { return true @@ -3812,7 +3812,7 @@ func CloneRefOfMatchExpr(n *MatchExpr) *MatchExpr { return &out } -// EqualsRefOfMatchExpr creates a deep clone of the input. +// EqualsRefOfMatchExpr does deep equals between the two objects. func EqualsRefOfMatchExpr(a, b *MatchExpr) bool { if a == b { return true @@ -3835,7 +3835,7 @@ func CloneRefOfNotExpr(n *NotExpr) *NotExpr { return &out } -// EqualsRefOfNotExpr creates a deep clone of the input. +// EqualsRefOfNotExpr does deep equals between the two objects. func EqualsRefOfNotExpr(a, b *NotExpr) bool { if a == b { return true @@ -3855,7 +3855,7 @@ func CloneRefOfNullVal(n *NullVal) *NullVal { return &out } -// EqualsRefOfNullVal creates a deep clone of the input. +// EqualsRefOfNullVal does deep equals between the two objects. func EqualsRefOfNullVal(a, b *NullVal) bool { if a == b { return true @@ -3877,7 +3877,7 @@ func CloneRefOfOrExpr(n *OrExpr) *OrExpr { return &out } -// EqualsRefOfOrExpr creates a deep clone of the input. +// EqualsRefOfOrExpr does deep equals between the two objects. func EqualsRefOfOrExpr(a, b *OrExpr) bool { if a == b { return true @@ -3901,7 +3901,7 @@ func CloneRefOfRangeCond(n *RangeCond) *RangeCond { return &out } -// EqualsRefOfRangeCond creates a deep clone of the input. +// EqualsRefOfRangeCond does deep equals between the two objects. func EqualsRefOfRangeCond(a, b *RangeCond) bool { if a == b { return true @@ -3928,7 +3928,7 @@ func CloneRefOfSubstrExpr(n *SubstrExpr) *SubstrExpr { return &out } -// EqualsRefOfSubstrExpr creates a deep clone of the input. +// EqualsRefOfSubstrExpr does deep equals between the two objects. func EqualsRefOfSubstrExpr(a, b *SubstrExpr) bool { if a == b { return true @@ -3953,7 +3953,7 @@ func CloneRefOfTimestampFuncExpr(n *TimestampFuncExpr) *TimestampFuncExpr { return &out } -// EqualsRefOfTimestampFuncExpr creates a deep clone of the input. +// EqualsRefOfTimestampFuncExpr does deep equals between the two objects. func EqualsRefOfTimestampFuncExpr(a, b *TimestampFuncExpr) bool { if a == b { return true @@ -3977,7 +3977,7 @@ func CloneRefOfUnaryExpr(n *UnaryExpr) *UnaryExpr { return &out } -// EqualsRefOfUnaryExpr creates a deep clone of the input. +// EqualsRefOfUnaryExpr does deep equals between the two objects. func EqualsRefOfUnaryExpr(a, b *UnaryExpr) bool { if a == b { return true @@ -3999,7 +3999,7 @@ func CloneRefOfValuesFuncExpr(n *ValuesFuncExpr) *ValuesFuncExpr { return &out } -// EqualsRefOfValuesFuncExpr creates a deep clone of the input. +// EqualsRefOfValuesFuncExpr does deep equals between the two objects. func EqualsRefOfValuesFuncExpr(a, b *ValuesFuncExpr) bool { if a == b { return true @@ -4021,7 +4021,7 @@ func CloneRefOfXorExpr(n *XorExpr) *XorExpr { return &out } -// EqualsRefOfXorExpr creates a deep clone of the input. +// EqualsRefOfXorExpr does deep equals between the two objects. func EqualsRefOfXorExpr(a, b *XorExpr) bool { if a == b { return true @@ -4043,7 +4043,7 @@ func CloneRefOfParenSelect(n *ParenSelect) *ParenSelect { return &out } -// EqualsRefOfParenSelect creates a deep clone of the input. +// EqualsRefOfParenSelect does deep equals between the two objects. func EqualsRefOfParenSelect(a, b *ParenSelect) bool { if a == b { return true @@ -4073,7 +4073,7 @@ func CloneRefOfSelect(n *Select) *Select { return &out } -// EqualsRefOfSelect creates a deep clone of the input. +// EqualsRefOfSelect does deep equals between the two objects. func EqualsRefOfSelect(a, b *Select) bool { if a == b { return true @@ -4110,7 +4110,7 @@ func CloneRefOfUnion(n *Union) *Union { return &out } -// EqualsRefOfUnion creates a deep clone of the input. +// EqualsRefOfUnion does deep equals between the two objects. func EqualsRefOfUnion(a, b *Union) bool { if a == b { return true @@ -4134,7 +4134,7 @@ func CloneValues(n Values) Values { return res } -// EqualsValues creates a deep clone of the input. +// EqualsValues does deep equals between the two objects. func EqualsValues(a, b Values) bool { if len(a) != len(b) { return false @@ -4158,7 +4158,7 @@ func CloneRefOfAliasedExpr(n *AliasedExpr) *AliasedExpr { return &out } -// EqualsRefOfAliasedExpr creates a deep clone of the input. +// EqualsRefOfAliasedExpr does deep equals between the two objects. func EqualsRefOfAliasedExpr(a, b *AliasedExpr) bool { if a == b { return true @@ -4183,7 +4183,7 @@ func CloneRefOfAliasedTableExpr(n *AliasedTableExpr) *AliasedTableExpr { return &out } -// EqualsRefOfAliasedTableExpr creates a deep clone of the input. +// EqualsRefOfAliasedTableExpr does deep equals between the two objects. func EqualsRefOfAliasedTableExpr(a, b *AliasedTableExpr) bool { if a == b { return true @@ -4210,7 +4210,7 @@ func CloneRefOfAlterVschema(n *AlterVschema) *AlterVschema { return &out } -// EqualsRefOfAlterVschema creates a deep clone of the input. +// EqualsRefOfAlterVschema does deep equals between the two objects. func EqualsRefOfAlterVschema(a, b *AlterVschema) bool { if a == b { return true @@ -4236,7 +4236,7 @@ func CloneRefOfAutoIncSpec(n *AutoIncSpec) *AutoIncSpec { return &out } -// EqualsRefOfAutoIncSpec creates a deep clone of the input. +// EqualsRefOfAutoIncSpec does deep equals between the two objects. func EqualsRefOfAutoIncSpec(a, b *AutoIncSpec) bool { if a == b { return true @@ -4257,7 +4257,7 @@ func CloneRefOfBegin(n *Begin) *Begin { return &out } -// EqualsRefOfBegin creates a deep clone of the input. +// EqualsRefOfBegin does deep equals between the two objects. func EqualsRefOfBegin(a, b *Begin) bool { if a == b { return true @@ -4279,7 +4279,7 @@ func CloneRefOfCallProc(n *CallProc) *CallProc { return &out } -// EqualsRefOfCallProc creates a deep clone of the input. +// EqualsRefOfCallProc does deep equals between the two objects. func EqualsRefOfCallProc(a, b *CallProc) bool { if a == b { return true @@ -4296,7 +4296,7 @@ func CloneColIdent(n ColIdent) ColIdent { return *CloneRefOfColIdent(&n) } -// EqualsColIdent creates a deep clone of the input. +// EqualsColIdent does deep equals between the two objects. func EqualsColIdent(a, b ColIdent) bool { return a.val == b.val && a.lowered == b.lowered && @@ -4314,7 +4314,7 @@ func CloneRefOfColumnDefinition(n *ColumnDefinition) *ColumnDefinition { return &out } -// EqualsRefOfColumnDefinition creates a deep clone of the input. +// EqualsRefOfColumnDefinition does deep equals between the two objects. func EqualsRefOfColumnDefinition(a, b *ColumnDefinition) bool { if a == b { return true @@ -4339,7 +4339,7 @@ func CloneRefOfColumnType(n *ColumnType) *ColumnType { return &out } -// EqualsRefOfColumnType creates a deep clone of the input. +// EqualsRefOfColumnType does deep equals between the two objects. func EqualsRefOfColumnType(a, b *ColumnType) bool { if a == b { return true @@ -4367,7 +4367,7 @@ func CloneColumns(n Columns) Columns { return res } -// EqualsColumns creates a deep clone of the input. +// EqualsColumns does deep equals between the two objects. func EqualsColumns(a, b Columns) bool { if len(a) != len(b) { return false @@ -4387,7 +4387,7 @@ func CloneComments(n Comments) Comments { return res } -// EqualsComments creates a deep clone of the input. +// EqualsComments does deep equals between the two objects. func EqualsComments(a, b Comments) bool { if len(a) != len(b) { return false @@ -4409,7 +4409,7 @@ func CloneRefOfCommit(n *Commit) *Commit { return &out } -// EqualsRefOfCommit creates a deep clone of the input. +// EqualsRefOfCommit does deep equals between the two objects. func EqualsRefOfCommit(a, b *Commit) bool { if a == b { return true @@ -4430,7 +4430,7 @@ func CloneRefOfConstraintDefinition(n *ConstraintDefinition) *ConstraintDefiniti return &out } -// EqualsRefOfConstraintDefinition creates a deep clone of the input. +// EqualsRefOfConstraintDefinition does deep equals between the two objects. func EqualsRefOfConstraintDefinition(a, b *ConstraintDefinition) bool { if a == b { return true @@ -4453,7 +4453,7 @@ func CloneRefOfConvertType(n *ConvertType) *ConvertType { return &out } -// EqualsRefOfConvertType creates a deep clone of the input. +// EqualsRefOfConvertType does deep equals between the two objects. func EqualsRefOfConvertType(a, b *ConvertType) bool { if a == b { return true @@ -4484,7 +4484,7 @@ func CloneRefOfDelete(n *Delete) *Delete { return &out } -// EqualsRefOfDelete creates a deep clone of the input. +// EqualsRefOfDelete does deep equals between the two objects. func EqualsRefOfDelete(a, b *Delete) bool { if a == b { return true @@ -4512,7 +4512,7 @@ func CloneRefOfDerivedTable(n *DerivedTable) *DerivedTable { return &out } -// EqualsRefOfDerivedTable creates a deep clone of the input. +// EqualsRefOfDerivedTable does deep equals between the two objects. func EqualsRefOfDerivedTable(a, b *DerivedTable) bool { if a == b { return true @@ -4532,7 +4532,7 @@ func CloneExprs(n Exprs) Exprs { return res } -// EqualsExprs creates a deep clone of the input. +// EqualsExprs does deep equals between the two objects. func EqualsExprs(a, b Exprs) bool { if len(a) != len(b) { return false @@ -4556,7 +4556,7 @@ func CloneRefOfFlush(n *Flush) *Flush { return &out } -// EqualsRefOfFlush creates a deep clone of the input. +// EqualsRefOfFlush does deep equals between the two objects. func EqualsRefOfFlush(a, b *Flush) bool { if a == b { return true @@ -4580,7 +4580,7 @@ func CloneGroupBy(n GroupBy) GroupBy { return res } -// EqualsGroupBy creates a deep clone of the input. +// EqualsGroupBy does deep equals between the two objects. func EqualsGroupBy(a, b GroupBy) bool { if len(a) != len(b) { return false @@ -4605,7 +4605,7 @@ func CloneRefOfIndexDefinition(n *IndexDefinition) *IndexDefinition { return &out } -// EqualsRefOfIndexDefinition creates a deep clone of the input. +// EqualsRefOfIndexDefinition does deep equals between the two objects. func EqualsRefOfIndexDefinition(a, b *IndexDefinition) bool { if a == b { return true @@ -4628,7 +4628,7 @@ func CloneRefOfIndexHints(n *IndexHints) *IndexHints { return &out } -// EqualsRefOfIndexHints creates a deep clone of the input. +// EqualsRefOfIndexHints does deep equals between the two objects. func EqualsRefOfIndexHints(a, b *IndexHints) bool { if a == b { return true @@ -4651,7 +4651,7 @@ func CloneRefOfIndexInfo(n *IndexInfo) *IndexInfo { return &out } -// EqualsRefOfIndexInfo creates a deep clone of the input. +// EqualsRefOfIndexInfo does deep equals between the two objects. func EqualsRefOfIndexInfo(a, b *IndexInfo) bool { if a == b { return true @@ -4683,7 +4683,7 @@ func CloneRefOfInsert(n *Insert) *Insert { return &out } -// EqualsRefOfInsert creates a deep clone of the input. +// EqualsRefOfInsert does deep equals between the two objects. func EqualsRefOfInsert(a, b *Insert) bool { if a == b { return true @@ -4706,7 +4706,7 @@ func CloneJoinCondition(n JoinCondition) JoinCondition { return *CloneRefOfJoinCondition(&n) } -// EqualsJoinCondition creates a deep clone of the input. +// EqualsJoinCondition does deep equals between the two objects. func EqualsJoinCondition(a, b JoinCondition) bool { return EqualsExpr(a.On, b.On) && EqualsColumns(a.Using, b.Using) @@ -4724,7 +4724,7 @@ func CloneRefOfJoinTableExpr(n *JoinTableExpr) *JoinTableExpr { return &out } -// EqualsRefOfJoinTableExpr creates a deep clone of the input. +// EqualsRefOfJoinTableExpr does deep equals between the two objects. func EqualsRefOfJoinTableExpr(a, b *JoinTableExpr) bool { if a == b { return true @@ -4749,7 +4749,7 @@ func CloneRefOfLimit(n *Limit) *Limit { return &out } -// EqualsRefOfLimit creates a deep clone of the input. +// EqualsRefOfLimit does deep equals between the two objects. func EqualsRefOfLimit(a, b *Limit) bool { if a == b { return true @@ -4770,7 +4770,7 @@ func CloneRefOfLoad(n *Load) *Load { return &out } -// EqualsRefOfLoad creates a deep clone of the input. +// EqualsRefOfLoad does deep equals between the two objects. func EqualsRefOfLoad(a, b *Load) bool { if a == b { return true @@ -4791,7 +4791,7 @@ func CloneRefOfLockTables(n *LockTables) *LockTables { return &out } -// EqualsRefOfLockTables creates a deep clone of the input. +// EqualsRefOfLockTables does deep equals between the two objects. func EqualsRefOfLockTables(a, b *LockTables) bool { if a == b { return true @@ -4812,7 +4812,7 @@ func CloneRefOfNextval(n *Nextval) *Nextval { return &out } -// EqualsRefOfNextval creates a deep clone of the input. +// EqualsRefOfNextval does deep equals between the two objects. func EqualsRefOfNextval(a, b *Nextval) bool { if a == b { return true @@ -4832,7 +4832,7 @@ func CloneOnDup(n OnDup) OnDup { return res } -// EqualsOnDup creates a deep clone of the input. +// EqualsOnDup does deep equals between the two objects. func EqualsOnDup(a, b OnDup) bool { if len(a) != len(b) { return false @@ -4855,7 +4855,7 @@ func CloneRefOfOptLike(n *OptLike) *OptLike { return &out } -// EqualsRefOfOptLike creates a deep clone of the input. +// EqualsRefOfOptLike does deep equals between the two objects. func EqualsRefOfOptLike(a, b *OptLike) bool { if a == b { return true @@ -4876,7 +4876,7 @@ func CloneRefOfOrder(n *Order) *Order { return &out } -// EqualsRefOfOrder creates a deep clone of the input. +// EqualsRefOfOrder does deep equals between the two objects. func EqualsRefOfOrder(a, b *Order) bool { if a == b { return true @@ -4897,7 +4897,7 @@ func CloneOrderBy(n OrderBy) OrderBy { return res } -// EqualsOrderBy creates a deep clone of the input. +// EqualsOrderBy does deep equals between the two objects. func EqualsOrderBy(a, b OrderBy) bool { if len(a) != len(b) { return false @@ -4919,7 +4919,7 @@ func CloneRefOfOtherAdmin(n *OtherAdmin) *OtherAdmin { return &out } -// EqualsRefOfOtherAdmin creates a deep clone of the input. +// EqualsRefOfOtherAdmin does deep equals between the two objects. func EqualsRefOfOtherAdmin(a, b *OtherAdmin) bool { if a == b { return true @@ -4939,7 +4939,7 @@ func CloneRefOfOtherRead(n *OtherRead) *OtherRead { return &out } -// EqualsRefOfOtherRead creates a deep clone of the input. +// EqualsRefOfOtherRead does deep equals between the two objects. func EqualsRefOfOtherRead(a, b *OtherRead) bool { if a == b { return true @@ -4960,7 +4960,7 @@ func CloneRefOfParenTableExpr(n *ParenTableExpr) *ParenTableExpr { return &out } -// EqualsRefOfParenTableExpr creates a deep clone of the input. +// EqualsRefOfParenTableExpr does deep equals between the two objects. func EqualsRefOfParenTableExpr(a, b *ParenTableExpr) bool { if a == b { return true @@ -4982,7 +4982,7 @@ func CloneRefOfPartitionDefinition(n *PartitionDefinition) *PartitionDefinition return &out } -// EqualsRefOfPartitionDefinition creates a deep clone of the input. +// EqualsRefOfPartitionDefinition does deep equals between the two objects. func EqualsRefOfPartitionDefinition(a, b *PartitionDefinition) bool { if a == b { return true @@ -5008,7 +5008,7 @@ func CloneRefOfPartitionSpec(n *PartitionSpec) *PartitionSpec { return &out } -// EqualsRefOfPartitionSpec creates a deep clone of the input. +// EqualsRefOfPartitionSpec does deep equals between the two objects. func EqualsRefOfPartitionSpec(a, b *PartitionSpec) bool { if a == b { return true @@ -5034,7 +5034,7 @@ func ClonePartitions(n Partitions) Partitions { return res } -// EqualsPartitions creates a deep clone of the input. +// EqualsPartitions does deep equals between the two objects. func EqualsPartitions(a, b Partitions) bool { if len(a) != len(b) { return false @@ -5057,7 +5057,7 @@ func CloneRefOfRelease(n *Release) *Release { return &out } -// EqualsRefOfRelease creates a deep clone of the input. +// EqualsRefOfRelease does deep equals between the two objects. func EqualsRefOfRelease(a, b *Release) bool { if a == b { return true @@ -5077,7 +5077,7 @@ func CloneRefOfRollback(n *Rollback) *Rollback { return &out } -// EqualsRefOfRollback creates a deep clone of the input. +// EqualsRefOfRollback does deep equals between the two objects. func EqualsRefOfRollback(a, b *Rollback) bool { if a == b { return true @@ -5098,7 +5098,7 @@ func CloneRefOfSRollback(n *SRollback) *SRollback { return &out } -// EqualsRefOfSRollback creates a deep clone of the input. +// EqualsRefOfSRollback does deep equals between the two objects. func EqualsRefOfSRollback(a, b *SRollback) bool { if a == b { return true @@ -5119,7 +5119,7 @@ func CloneRefOfSavepoint(n *Savepoint) *Savepoint { return &out } -// EqualsRefOfSavepoint creates a deep clone of the input. +// EqualsRefOfSavepoint does deep equals between the two objects. func EqualsRefOfSavepoint(a, b *Savepoint) bool { if a == b { return true @@ -5139,7 +5139,7 @@ func CloneSelectExprs(n SelectExprs) SelectExprs { return res } -// EqualsSelectExprs creates a deep clone of the input. +// EqualsSelectExprs does deep equals between the two objects. func EqualsSelectExprs(a, b SelectExprs) bool { if len(a) != len(b) { return false @@ -5161,7 +5161,7 @@ func CloneRefOfSelectInto(n *SelectInto) *SelectInto { return &out } -// EqualsRefOfSelectInto creates a deep clone of the input. +// EqualsRefOfSelectInto does deep equals between the two objects. func EqualsRefOfSelectInto(a, b *SelectInto) bool { if a == b { return true @@ -5189,7 +5189,7 @@ func CloneRefOfSet(n *Set) *Set { return &out } -// EqualsRefOfSet creates a deep clone of the input. +// EqualsRefOfSet does deep equals between the two objects. func EqualsRefOfSet(a, b *Set) bool { if a == b { return true @@ -5212,7 +5212,7 @@ func CloneRefOfSetExpr(n *SetExpr) *SetExpr { return &out } -// EqualsRefOfSetExpr creates a deep clone of the input. +// EqualsRefOfSetExpr does deep equals between the two objects. func EqualsRefOfSetExpr(a, b *SetExpr) bool { if a == b { return true @@ -5234,7 +5234,7 @@ func CloneSetExprs(n SetExprs) SetExprs { return res } -// EqualsSetExprs creates a deep clone of the input. +// EqualsSetExprs does deep equals between the two objects. func EqualsSetExprs(a, b SetExprs) bool { if len(a) != len(b) { return false @@ -5259,7 +5259,7 @@ func CloneRefOfSetTransaction(n *SetTransaction) *SetTransaction { return &out } -// EqualsRefOfSetTransaction creates a deep clone of the input. +// EqualsRefOfSetTransaction does deep equals between the two objects. func EqualsRefOfSetTransaction(a, b *SetTransaction) bool { if a == b { return true @@ -5283,7 +5283,7 @@ func CloneRefOfShow(n *Show) *Show { return &out } -// EqualsRefOfShow creates a deep clone of the input. +// EqualsRefOfShow does deep equals between the two objects. func EqualsRefOfShow(a, b *Show) bool { if a == b { return true @@ -5305,7 +5305,7 @@ func CloneRefOfShowBasic(n *ShowBasic) *ShowBasic { return &out } -// EqualsRefOfShowBasic creates a deep clone of the input. +// EqualsRefOfShowBasic does deep equals between the two objects. func EqualsRefOfShowBasic(a, b *ShowBasic) bool { if a == b { return true @@ -5330,7 +5330,7 @@ func CloneRefOfShowCreate(n *ShowCreate) *ShowCreate { return &out } -// EqualsRefOfShowCreate creates a deep clone of the input. +// EqualsRefOfShowCreate does deep equals between the two objects. func EqualsRefOfShowCreate(a, b *ShowCreate) bool { if a == b { return true @@ -5352,7 +5352,7 @@ func CloneRefOfShowFilter(n *ShowFilter) *ShowFilter { return &out } -// EqualsRefOfShowFilter creates a deep clone of the input. +// EqualsRefOfShowFilter does deep equals between the two objects. func EqualsRefOfShowFilter(a, b *ShowFilter) bool { if a == b { return true @@ -5377,7 +5377,7 @@ func CloneRefOfShowLegacy(n *ShowLegacy) *ShowLegacy { return &out } -// EqualsRefOfShowLegacy creates a deep clone of the input. +// EqualsRefOfShowLegacy does deep equals between the two objects. func EqualsRefOfShowLegacy(a, b *ShowLegacy) bool { if a == b { return true @@ -5404,7 +5404,7 @@ func CloneRefOfStarExpr(n *StarExpr) *StarExpr { return &out } -// EqualsRefOfStarExpr creates a deep clone of the input. +// EqualsRefOfStarExpr does deep equals between the two objects. func EqualsRefOfStarExpr(a, b *StarExpr) bool { if a == b { return true @@ -5427,7 +5427,7 @@ func CloneRefOfStream(n *Stream) *Stream { return &out } -// EqualsRefOfStream creates a deep clone of the input. +// EqualsRefOfStream does deep equals between the two objects. func EqualsRefOfStream(a, b *Stream) bool { if a == b { return true @@ -5449,7 +5449,7 @@ func CloneTableExprs(n TableExprs) TableExprs { return res } -// EqualsTableExprs creates a deep clone of the input. +// EqualsTableExprs does deep equals between the two objects. func EqualsTableExprs(a, b TableExprs) bool { if len(a) != len(b) { return false @@ -5467,7 +5467,7 @@ func CloneTableIdent(n TableIdent) TableIdent { return *CloneRefOfTableIdent(&n) } -// EqualsTableIdent creates a deep clone of the input. +// EqualsTableIdent does deep equals between the two objects. func EqualsTableIdent(a, b TableIdent) bool { return a.v == b.v } @@ -5477,7 +5477,7 @@ func CloneTableName(n TableName) TableName { return *CloneRefOfTableName(&n) } -// EqualsTableName creates a deep clone of the input. +// EqualsTableName does deep equals between the two objects. func EqualsTableName(a, b TableName) bool { return EqualsTableIdent(a.Name, b.Name) && EqualsTableIdent(a.Qualifier, b.Qualifier) @@ -5492,7 +5492,7 @@ func CloneTableNames(n TableNames) TableNames { return res } -// EqualsTableNames creates a deep clone of the input. +// EqualsTableNames does deep equals between the two objects. func EqualsTableNames(a, b TableNames) bool { if len(a) != len(b) { return false @@ -5518,7 +5518,7 @@ func CloneRefOfTableSpec(n *TableSpec) *TableSpec { return &out } -// EqualsRefOfTableSpec creates a deep clone of the input. +// EqualsRefOfTableSpec does deep equals between the two objects. func EqualsRefOfTableSpec(a, b *TableSpec) bool { if a == b { return true @@ -5542,7 +5542,7 @@ func CloneRefOfUnionSelect(n *UnionSelect) *UnionSelect { return &out } -// EqualsRefOfUnionSelect creates a deep clone of the input. +// EqualsRefOfUnionSelect does deep equals between the two objects. func EqualsRefOfUnionSelect(a, b *UnionSelect) bool { if a == b { return true @@ -5563,7 +5563,7 @@ func CloneRefOfUnlockTables(n *UnlockTables) *UnlockTables { return &out } -// EqualsRefOfUnlockTables creates a deep clone of the input. +// EqualsRefOfUnlockTables does deep equals between the two objects. func EqualsRefOfUnlockTables(a, b *UnlockTables) bool { if a == b { return true @@ -5589,7 +5589,7 @@ func CloneRefOfUpdate(n *Update) *Update { return &out } -// EqualsRefOfUpdate creates a deep clone of the input. +// EqualsRefOfUpdate does deep equals between the two objects. func EqualsRefOfUpdate(a, b *Update) bool { if a == b { return true @@ -5617,7 +5617,7 @@ func CloneRefOfUpdateExpr(n *UpdateExpr) *UpdateExpr { return &out } -// EqualsRefOfUpdateExpr creates a deep clone of the input. +// EqualsRefOfUpdateExpr does deep equals between the two objects. func EqualsRefOfUpdateExpr(a, b *UpdateExpr) bool { if a == b { return true @@ -5638,7 +5638,7 @@ func CloneUpdateExprs(n UpdateExprs) UpdateExprs { return res } -// EqualsUpdateExprs creates a deep clone of the input. +// EqualsUpdateExprs does deep equals between the two objects. func EqualsUpdateExprs(a, b UpdateExprs) bool { if len(a) != len(b) { return false @@ -5661,7 +5661,7 @@ func CloneRefOfUse(n *Use) *Use { return &out } -// EqualsRefOfUse creates a deep clone of the input. +// EqualsRefOfUse does deep equals between the two objects. func EqualsRefOfUse(a, b *Use) bool { if a == b { return true @@ -5686,7 +5686,7 @@ func CloneRefOfVStream(n *VStream) *VStream { return &out } -// EqualsRefOfVStream creates a deep clone of the input. +// EqualsRefOfVStream does deep equals between the two objects. func EqualsRefOfVStream(a, b *VStream) bool { if a == b { return true @@ -5706,7 +5706,7 @@ func CloneVindexParam(n VindexParam) VindexParam { return *CloneRefOfVindexParam(&n) } -// EqualsVindexParam creates a deep clone of the input. +// EqualsVindexParam does deep equals between the two objects. func EqualsVindexParam(a, b VindexParam) bool { return a.Val == b.Val && EqualsColIdent(a.Key, b.Key) @@ -5724,7 +5724,7 @@ func CloneRefOfVindexSpec(n *VindexSpec) *VindexSpec { return &out } -// EqualsRefOfVindexSpec creates a deep clone of the input. +// EqualsRefOfVindexSpec does deep equals between the two objects. func EqualsRefOfVindexSpec(a, b *VindexSpec) bool { if a == b { return true @@ -5748,7 +5748,7 @@ func CloneRefOfWhen(n *When) *When { return &out } -// EqualsRefOfWhen creates a deep clone of the input. +// EqualsRefOfWhen does deep equals between the two objects. func EqualsRefOfWhen(a, b *When) bool { if a == b { return true @@ -5770,7 +5770,7 @@ func CloneRefOfWhere(n *Where) *Where { return &out } -// EqualsRefOfWhere creates a deep clone of the input. +// EqualsRefOfWhere does deep equals between the two objects. func EqualsRefOfWhere(a, b *Where) bool { if a == b { return true @@ -5791,7 +5791,7 @@ func CloneSliceOfRefOfColumnDefinition(n []*ColumnDefinition) []*ColumnDefinitio return res } -// EqualsSliceOfRefOfColumnDefinition creates a deep clone of the input. +// EqualsSliceOfRefOfColumnDefinition does deep equals between the two objects. func EqualsSliceOfRefOfColumnDefinition(a, b []*ColumnDefinition) bool { if len(a) != len(b) { return false @@ -5815,7 +5815,7 @@ func CloneRefOfTableOption(n *TableOption) *TableOption { return &out } -// EqualsRefOfTableOption creates a deep clone of the input. +// EqualsRefOfTableOption does deep equals between the two objects. func EqualsRefOfTableOption(a, b *TableOption) bool { if a == b { return true @@ -5838,7 +5838,7 @@ func CloneSliceOfCollateAndCharset(n []CollateAndCharset) []CollateAndCharset { return res } -// EqualsSliceOfCollateAndCharset creates a deep clone of the input. +// EqualsSliceOfCollateAndCharset does deep equals between the two objects. func EqualsSliceOfCollateAndCharset(a, b []CollateAndCharset) bool { if len(a) != len(b) { return false @@ -5860,7 +5860,7 @@ func CloneSliceOfAlterOption(n []AlterOption) []AlterOption { return res } -// EqualsSliceOfAlterOption creates a deep clone of the input. +// EqualsSliceOfAlterOption does deep equals between the two objects. func EqualsSliceOfAlterOption(a, b []AlterOption) bool { if len(a) != len(b) { return false @@ -5882,7 +5882,7 @@ func CloneSliceOfRefOfRenameTablePair(n []*RenameTablePair) []*RenameTablePair { return res } -// EqualsSliceOfRefOfRenameTablePair creates a deep clone of the input. +// EqualsSliceOfRefOfRenameTablePair does deep equals between the two objects. func EqualsSliceOfRefOfRenameTablePair(a, b []*RenameTablePair) bool { if len(a) != len(b) { return false @@ -5904,7 +5904,7 @@ func CloneSliceOfRefOfWhen(n []*When) []*When { return res } -// EqualsSliceOfRefOfWhen creates a deep clone of the input. +// EqualsSliceOfRefOfWhen does deep equals between the two objects. func EqualsSliceOfRefOfWhen(a, b []*When) bool { if len(a) != len(b) { return false @@ -5917,7 +5917,7 @@ func EqualsSliceOfRefOfWhen(a, b []*When) bool { return true } -// EqualsRefOfBool creates a deep clone of the input. +// EqualsRefOfBool does deep equals between the two objects. func EqualsRefOfBool(a, b *bool) bool { if a == b { return true @@ -5946,7 +5946,7 @@ func CloneSliceOfRefOfUnionSelect(n []*UnionSelect) []*UnionSelect { return res } -// EqualsSliceOfRefOfUnionSelect creates a deep clone of the input. +// EqualsSliceOfRefOfUnionSelect does deep equals between the two objects. func EqualsSliceOfRefOfUnionSelect(a, b []*UnionSelect) bool { if len(a) != len(b) { return false @@ -5968,7 +5968,7 @@ func CloneSliceOfColIdent(n []ColIdent) []ColIdent { return res } -// EqualsSliceOfColIdent creates a deep clone of the input. +// EqualsSliceOfColIdent does deep equals between the two objects. func EqualsSliceOfColIdent(a, b []ColIdent) bool { if len(a) != len(b) { return false @@ -5990,7 +5990,7 @@ func CloneRefOfColIdent(n *ColIdent) *ColIdent { return &out } -// EqualsRefOfColIdent creates a deep clone of the input. +// EqualsRefOfColIdent does deep equals between the two objects. func EqualsRefOfColIdent(a, b *ColIdent) bool { if a == b { return true @@ -6008,7 +6008,7 @@ func CloneColumnType(n ColumnType) ColumnType { return *CloneRefOfColumnType(&n) } -// EqualsColumnType creates a deep clone of the input. +// EqualsColumnType does deep equals between the two objects. func EqualsColumnType(a, b ColumnType) bool { return a.Type == b.Type && a.Unsigned == b.Unsigned && @@ -6033,7 +6033,7 @@ func CloneRefOfColumnTypeOptions(n *ColumnTypeOptions) *ColumnTypeOptions { return &out } -// EqualsRefOfColumnTypeOptions creates a deep clone of the input. +// EqualsRefOfColumnTypeOptions does deep equals between the two objects. func EqualsRefOfColumnTypeOptions(a, b *ColumnTypeOptions) bool { if a == b { return true @@ -6056,7 +6056,7 @@ func CloneSliceOfString(n []string) []string { return res } -// EqualsSliceOfString creates a deep clone of the input. +// EqualsSliceOfString does deep equals between the two objects. func EqualsSliceOfString(a, b []string) bool { if len(a) != len(b) { return false @@ -6078,7 +6078,7 @@ func CloneSliceOfRefOfIndexColumn(n []*IndexColumn) []*IndexColumn { return res } -// EqualsSliceOfRefOfIndexColumn creates a deep clone of the input. +// EqualsSliceOfRefOfIndexColumn does deep equals between the two objects. func EqualsSliceOfRefOfIndexColumn(a, b []*IndexColumn) bool { if len(a) != len(b) { return false @@ -6100,7 +6100,7 @@ func CloneSliceOfRefOfIndexOption(n []*IndexOption) []*IndexOption { return res } -// EqualsSliceOfRefOfIndexOption creates a deep clone of the input. +// EqualsSliceOfRefOfIndexOption does deep equals between the two objects. func EqualsSliceOfRefOfIndexOption(a, b []*IndexOption) bool { if len(a) != len(b) { return false @@ -6124,7 +6124,7 @@ func CloneRefOfJoinCondition(n *JoinCondition) *JoinCondition { return &out } -// EqualsRefOfJoinCondition creates a deep clone of the input. +// EqualsRefOfJoinCondition does deep equals between the two objects. func EqualsRefOfJoinCondition(a, b *JoinCondition) bool { if a == b { return true @@ -6145,7 +6145,7 @@ func CloneTableAndLockTypes(n TableAndLockTypes) TableAndLockTypes { return res } -// EqualsTableAndLockTypes creates a deep clone of the input. +// EqualsTableAndLockTypes does deep equals between the two objects. func EqualsTableAndLockTypes(a, b TableAndLockTypes) bool { if len(a) != len(b) { return false @@ -6167,7 +6167,7 @@ func CloneSliceOfRefOfPartitionDefinition(n []*PartitionDefinition) []*Partition return res } -// EqualsSliceOfRefOfPartitionDefinition creates a deep clone of the input. +// EqualsSliceOfRefOfPartitionDefinition does deep equals between the two objects. func EqualsSliceOfRefOfPartitionDefinition(a, b []*PartitionDefinition) bool { if len(a) != len(b) { return false @@ -6189,7 +6189,7 @@ func CloneSliceOfCharacteristic(n []Characteristic) []Characteristic { return res } -// EqualsSliceOfCharacteristic creates a deep clone of the input. +// EqualsSliceOfCharacteristic does deep equals between the two objects. func EqualsSliceOfCharacteristic(a, b []Characteristic) bool { if len(a) != len(b) { return false @@ -6212,7 +6212,7 @@ func CloneRefOfShowTablesOpt(n *ShowTablesOpt) *ShowTablesOpt { return &out } -// EqualsRefOfShowTablesOpt creates a deep clone of the input. +// EqualsRefOfShowTablesOpt does deep equals between the two objects. func EqualsRefOfShowTablesOpt(a, b *ShowTablesOpt) bool { if a == b { return true @@ -6234,7 +6234,7 @@ func CloneRefOfTableIdent(n *TableIdent) *TableIdent { return &out } -// EqualsRefOfTableIdent creates a deep clone of the input. +// EqualsRefOfTableIdent does deep equals between the two objects. func EqualsRefOfTableIdent(a, b *TableIdent) bool { if a == b { return true @@ -6256,7 +6256,7 @@ func CloneRefOfTableName(n *TableName) *TableName { return &out } -// EqualsRefOfTableName creates a deep clone of the input. +// EqualsRefOfTableName does deep equals between the two objects. func EqualsRefOfTableName(a, b *TableName) bool { if a == b { return true @@ -6277,7 +6277,7 @@ func CloneSliceOfRefOfIndexDefinition(n []*IndexDefinition) []*IndexDefinition { return res } -// EqualsSliceOfRefOfIndexDefinition creates a deep clone of the input. +// EqualsSliceOfRefOfIndexDefinition does deep equals between the two objects. func EqualsSliceOfRefOfIndexDefinition(a, b []*IndexDefinition) bool { if len(a) != len(b) { return false @@ -6299,7 +6299,7 @@ func CloneSliceOfRefOfConstraintDefinition(n []*ConstraintDefinition) []*Constra return res } -// EqualsSliceOfRefOfConstraintDefinition creates a deep clone of the input. +// EqualsSliceOfRefOfConstraintDefinition does deep equals between the two objects. func EqualsSliceOfRefOfConstraintDefinition(a, b []*ConstraintDefinition) bool { if len(a) != len(b) { return false @@ -6322,7 +6322,7 @@ func CloneRefOfVindexParam(n *VindexParam) *VindexParam { return &out } -// EqualsRefOfVindexParam creates a deep clone of the input. +// EqualsRefOfVindexParam does deep equals between the two objects. func EqualsRefOfVindexParam(a, b *VindexParam) bool { if a == b { return true @@ -6343,7 +6343,7 @@ func CloneSliceOfVindexParam(n []VindexParam) []VindexParam { return res } -// EqualsSliceOfVindexParam creates a deep clone of the input. +// EqualsSliceOfVindexParam does deep equals between the two objects. func EqualsSliceOfVindexParam(a, b []VindexParam) bool { if len(a) != len(b) { return false @@ -6361,7 +6361,7 @@ func CloneCollateAndCharset(n CollateAndCharset) CollateAndCharset { return *CloneRefOfCollateAndCharset(&n) } -// EqualsCollateAndCharset creates a deep clone of the input. +// EqualsCollateAndCharset does deep equals between the two objects. func EqualsCollateAndCharset(a, b CollateAndCharset) bool { return a.IsDefault == b.IsDefault && a.Value == b.Value && @@ -6379,7 +6379,7 @@ func CloneRefOfRenameTablePair(n *RenameTablePair) *RenameTablePair { return &out } -// EqualsRefOfRenameTablePair creates a deep clone of the input. +// EqualsRefOfRenameTablePair does deep equals between the two objects. func EqualsRefOfRenameTablePair(a, b *RenameTablePair) bool { if a == b { return true @@ -6402,7 +6402,7 @@ func CloneRefOfIndexColumn(n *IndexColumn) *IndexColumn { return &out } -// EqualsRefOfIndexColumn creates a deep clone of the input. +// EqualsRefOfIndexColumn does deep equals between the two objects. func EqualsRefOfIndexColumn(a, b *IndexColumn) bool { if a == b { return true @@ -6425,7 +6425,7 @@ func CloneRefOfIndexOption(n *IndexOption) *IndexOption { return &out } -// EqualsRefOfIndexOption creates a deep clone of the input. +// EqualsRefOfIndexOption does deep equals between the two objects. func EqualsRefOfIndexOption(a, b *IndexOption) bool { if a == b { return true @@ -6448,7 +6448,7 @@ func CloneRefOfTableAndLockType(n *TableAndLockType) *TableAndLockType { return &out } -// EqualsRefOfTableAndLockType creates a deep clone of the input. +// EqualsRefOfTableAndLockType does deep equals between the two objects. func EqualsRefOfTableAndLockType(a, b *TableAndLockType) bool { if a == b { return true @@ -6469,7 +6469,7 @@ func CloneRefOfCollateAndCharset(n *CollateAndCharset) *CollateAndCharset { return &out } -// EqualsRefOfCollateAndCharset creates a deep clone of the input. +// EqualsRefOfCollateAndCharset does deep equals between the two objects. func EqualsRefOfCollateAndCharset(a, b *CollateAndCharset) bool { if a == b { return true