File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -612,10 +612,12 @@ func (b *Builder) buildShowAllTables(inScope *scope, s *ast.Show) (outScope *sco
612612 outScope = inScope .push ()
613613
614614 var dbName string
615+ var schemaName string
615616 var filter sql.Expression
616617 var asOf sql.Expression
617618 if s .ShowTablesOpt != nil {
618619 dbName = s .ShowTablesOpt .DbName
620+ schemaName = s .ShowTablesOpt .SchemaName
619621 if s .ShowTablesOpt .AsOf != nil {
620622 asOf = b .buildAsOfExpr (inScope , s .ShowTablesOpt .AsOf )
621623 }
@@ -625,6 +627,25 @@ func (b *Builder) buildShowAllTables(inScope *scope, s *ast.Show) (outScope *sco
625627 dbName = b .ctx .GetCurrentDatabase ()
626628 }
627629 db := b .resolveDb (dbName )
630+
631+ if schemaName != "" {
632+ sdb , ok := db .(sql.SchemaDatabase )
633+ if ! ok {
634+ err := sql .ErrDatabaseSchemasNotSupported .New (db .Name ())
635+ b .handleErr (err )
636+ }
637+
638+ s , ok , err := sdb .GetSchema (b .ctx , schemaName )
639+ if err != nil {
640+ b .handleErr (err )
641+ }
642+ if ! ok {
643+ err := sql .ErrDatabaseSchemaNotFound .New (schemaName )
644+ b .handleErr (err )
645+ }
646+
647+ db = s
648+ }
628649
629650 b .qFlags .Set (sql .QFlagSetDatabase )
630651 showTabs := plan .NewShowTables (db , s .Full , asOf )
You can’t perform that action at this time.
0 commit comments