diff --git a/go.mod b/go.mod index cdc24ab5bd..a256d796c6 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662 github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71 github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 - github.com/dolthub/vitess v0.0.0-20241009160728-54c0746cbff7 + github.com/dolthub/vitess v0.0.0-20241009211835-ba88416ec164 github.com/go-kit/kit v0.10.0 github.com/go-sql-driver/mysql v1.7.2-0.20231213112541-0004702b931d github.com/gocraft/dbr/v2 v2.7.2 diff --git a/go.sum b/go.sum index 8ff132713b..4134490d2a 100644 --- a/go.sum +++ b/go.sum @@ -60,6 +60,8 @@ github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9X github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY= github.com/dolthub/vitess v0.0.0-20241009160728-54c0746cbff7 h1:mepdzTqvr0ZAbyOEsdgLg/nJ2qQzLJIwHD7xityHzz4= github.com/dolthub/vitess v0.0.0-20241009160728-54c0746cbff7/go.mod h1:uBvlRluuL+SbEWTCZ68o0xvsdYZER3CEG/35INdzfJM= +github.com/dolthub/vitess v0.0.0-20241009211835-ba88416ec164 h1:E801UUi91AGx0EfIA1/59hxfDpGI8P9Mvc9KHw8O5Rg= +github.com/dolthub/vitess v0.0.0-20241009211835-ba88416ec164/go.mod h1:uBvlRluuL+SbEWTCZ68o0xvsdYZER3CEG/35INdzfJM= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= diff --git a/sql/planbuilder/create_ddl.go b/sql/planbuilder/create_ddl.go index 91114e0cd5..f9e38e455e 100644 --- a/sql/planbuilder/create_ddl.go +++ b/sql/planbuilder/create_ddl.go @@ -143,7 +143,7 @@ func (b *Builder) buildCreateProcedure(inScope *scope, subQuery string, fullQuer err := fmt.Errorf("unknown procedure parameter direction: `%s`", string(param.Direction)) b.handleErr(err) } - internalTyp, err := types.ColumnTypeToType(¶m.Type) + internalTyp, err := types.ColumnTypeToType(param.Type) if err != nil { b.handleErr(err) } diff --git a/sql/planbuilder/ddl.go b/sql/planbuilder/ddl.go index a9bb6cee01..1e325881a6 100644 --- a/sql/planbuilder/ddl.go +++ b/sql/planbuilder/ddl.go @@ -1299,7 +1299,7 @@ func (b *Builder) jsonTableSpecToSchemaHelper(jsonTableSpec *ast.JSONTableSpec, b.jsonTableSpecToSchemaHelper(cd.Spec, sch) continue } - typ, err := types.ColumnTypeToType(&cd.Type) + typ, err := types.ColumnTypeToType(cd.Type) if err != nil { b.handleErr(err) } @@ -1362,7 +1362,7 @@ func getPkOrdinals(ts *ast.TableSpec) []int { // columnDefinitionToColumn returns the sql.Column for the column definition given, as part of a create table // statement. Defaults and generated expressions must be handled separately. func (b *Builder) columnDefinitionToColumn(inScope *scope, cd *ast.ColumnDefinition, indexes []*ast.IndexDefinition) *sql.Column { - internalTyp, err := types.ColumnTypeToType(&cd.Type) + internalTyp, err := types.ColumnTypeToType(cd.Type) if err != nil { b.handleErr(err) } @@ -1703,7 +1703,7 @@ func ParseColumnTypeString(columnType string) (sql.Type, error) { return nil, fmt.Errorf("failed to parse type info for column: %s", columnType) } parsedTyp := ddl.TableSpec.Columns[0].Type - typ, err := types.ColumnTypeToType(&parsedTyp) + typ, err := types.ColumnTypeToType(parsedTyp) if err != nil { return nil, err } diff --git a/sql/planbuilder/from.go b/sql/planbuilder/from.go index a432d439b0..c81ec4ef13 100644 --- a/sql/planbuilder/from.go +++ b/sql/planbuilder/from.go @@ -541,7 +541,7 @@ func (b *Builder) buildJSONTableCols(inScope *scope, jtSpec *ast.JSONTableSpec) continue } - typ, err := types.ColumnTypeToType(&jtColDef.Type) + typ, err := types.ColumnTypeToType(jtColDef.Type) if err != nil { b.handleErr(err) } diff --git a/sql/planbuilder/proc.go b/sql/planbuilder/proc.go index eaf154cb29..efcea7f22d 100644 --- a/sql/planbuilder/proc.go +++ b/sql/planbuilder/proc.go @@ -312,7 +312,7 @@ func (b *Builder) buildDeclareVariables(inScope *scope, d *ast.Declare) (outScop outScope = inScope.push() dVars := d.Variables names := make([]string, len(dVars.Names)) - typ, err := types.ColumnTypeToType(&dVars.VarType) + typ, err := types.ColumnTypeToType(dVars.VarType) if err != nil { err := err b.handleErr(err) diff --git a/sql/planbuilder/scalar.go b/sql/planbuilder/scalar.go index 2ee0ec8c78..7e3fb2a2c3 100644 --- a/sql/planbuilder/scalar.go +++ b/sql/planbuilder/scalar.go @@ -837,6 +837,9 @@ func (b *Builder) convertInt(value string, base int) *expression.Literal { } func (b *Builder) ConvertVal(v *ast.SQLVal) sql.Expression { + if v == nil { + return nil + } switch v.Type { case ast.StrVal: return expression.NewLiteral(string(v.Val), types.CreateLongText(b.ctx.GetCollation())) diff --git a/sql/planbuilder/select.go b/sql/planbuilder/select.go index 56900b5062..221bc42034 100644 --- a/sql/planbuilder/select.go +++ b/sql/planbuilder/select.go @@ -107,7 +107,7 @@ func (b *Builder) buildSelect(inScope *scope, s *ast.Select) (outScope *scope) { b.buildProjection(outScope, projScope) outScope = projScope - b.buildDistinct(outScope, s.QueryOpts.Distinct) + b.buildDistinct(outScope, s.QueryOpts) // OFFSET and LIMIT are last offset := b.buildOffset(outScope, s.Limit) @@ -117,7 +117,9 @@ func (b *Builder) buildSelect(inScope *scope, s *ast.Select) (outScope *scope) { limit := b.buildLimit(outScope, s.Limit) if limit != nil { l := plan.NewLimit(limit, outScope.node) - l.CalcFoundRows = s.QueryOpts.SQLCalcFoundRows + if s.QueryOpts != nil { + l.CalcFoundRows = s.QueryOpts.SQLCalcFoundRows + } outScope.node = l } @@ -194,8 +196,8 @@ func (b *Builder) typeCoerceLiteral(e sql.Expression) sql.Expression { // buildDistinct creates a new plan.Distinct node if the query has a DISTINCT option. // If the query has both DISTINCT and ALL, an error is returned. -func (b *Builder) buildDistinct(inScope *scope, distinct bool) { - if distinct { +func (b *Builder) buildDistinct(inScope *scope, qo *ast.QueryOpts) { + if qo != nil && qo.Distinct { inScope.node = plan.NewDistinct(inScope.node) } }