diff --git a/go.mod b/go.mod index 45544ab7a4..cdc24ab5bd 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-20241002230050-2c2ea65cf324 + github.com/dolthub/vitess v0.0.0-20241009160728-54c0746cbff7 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 ba678884fe..8ff132713b 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71 h1:bMGS25NWAGTE github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71/go.mod h1:2/2zjLQ/JOOSbbSboojeg+cAwcRV0fDLzIiWch/lhqI= github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9XGFa6q5Ap4Z/OhNkAMBaK5YeuEzwJt+NZdhiE= github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY= -github.com/dolthub/vitess v0.0.0-20241002230050-2c2ea65cf324 h1:OO1XBXmBM3HBJfbwEwsj8h0m/bwYKIgFgGN8d+S+vrw= -github.com/dolthub/vitess v0.0.0-20241002230050-2c2ea65cf324/go.mod h1:uBvlRluuL+SbEWTCZ68o0xvsdYZER3CEG/35INdzfJM= +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/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/show.go b/sql/planbuilder/show.go index 418235a2a7..b9859f15a1 100644 --- a/sql/planbuilder/show.go +++ b/sql/planbuilder/show.go @@ -612,10 +612,12 @@ func (b *Builder) buildShowAllTables(inScope *scope, s *ast.Show) (outScope *sco outScope = inScope.push() var dbName string + var schemaName string var filter sql.Expression var asOf sql.Expression if s.ShowTablesOpt != nil { dbName = s.ShowTablesOpt.DbName + schemaName = s.ShowTablesOpt.SchemaName if s.ShowTablesOpt.AsOf != nil { asOf = b.buildAsOfExpr(inScope, s.ShowTablesOpt.AsOf) } @@ -626,6 +628,25 @@ func (b *Builder) buildShowAllTables(inScope *scope, s *ast.Show) (outScope *sco } db := b.resolveDb(dbName) + if schemaName != "" { + sdb, ok := db.(sql.SchemaDatabase) + if !ok { + err := sql.ErrDatabaseSchemasNotSupported.New(db.Name()) + b.handleErr(err) + } + + s, ok, err := sdb.GetSchema(b.ctx, schemaName) + if err != nil { + b.handleErr(err) + } + if !ok { + err := sql.ErrDatabaseSchemaNotFound.New(schemaName) + b.handleErr(err) + } + + db = s + } + b.qFlags.Set(sql.QFlagSetDatabase) showTabs := plan.NewShowTables(db, s.Full, asOf) for _, c := range showTabs.Schema() {