Skip to content

Commit df911d8

Browse files
committed
Another fix
1 parent fe665b1 commit df911d8

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

sql/planbuilder/ddl.go

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,36 +48,11 @@ func (b *Builder) resolveDb(name string) sql.Database {
4848
}
4949

5050
func (b *Builder) resolveDbForTable(table ast.TableName) sql.Database {
51-
dbName := table.DbQualifier.String()
52-
if dbName == "" {
53-
dbName = b.ctx.GetCurrentDatabase()
54-
}
55-
56-
if dbName == "" {
57-
b.handleErr(sql.ErrNoDatabaseSelected.New())
58-
}
59-
60-
database, err := b.cat.Database(b.ctx, dbName)
61-
if err != nil {
62-
b.handleErr(err)
63-
}
64-
65-
schema := table.SchemaQualifier.String()
66-
if schema != "" {
67-
scd, ok := database.(sql.SchemaDatabase)
68-
if !ok {
69-
b.handleErr(fmt.Errorf("database %T does not support schemas", database))
70-
}
71-
database, ok, err = scd.GetSchema(b.ctx, schema)
72-
if err != nil {
73-
b.handleErr(err)
74-
}
75-
if !ok {
76-
b.handleErr(sql.ErrDatabaseSchemaNotFound.New(schema))
77-
}
51+
db, ok := b.maybeResolveDbForTable(table)
52+
if !ok {
53+
b.handleErr(sql.ErrDatabaseSchemaNotFound.New(table.SchemaQualifier.String()))
7854
}
79-
80-
return database
55+
return db
8156
}
8257

8358
func (b *Builder) maybeResolveDbForTable(table ast.TableName) (sql.Database, bool) {

0 commit comments

Comments
 (0)