diff --git a/sql/planbuilder/select.go b/sql/planbuilder/select.go index 511bde12a2..d3c3cec402 100644 --- a/sql/planbuilder/select.go +++ b/sql/planbuilder/select.go @@ -211,12 +211,11 @@ func (b *Builder) currentDb() sql.Database { if err != nil { b.handleErr(err) } - - if privilegedDatabase, ok := database.(mysql_db.PrivilegedDatabase); ok { - database = privilegedDatabase.Unwrap() - } b.currentDatabase = database } + if privilegedDatabase, ok := b.currentDatabase.(mysql_db.PrivilegedDatabase); ok { + b.currentDatabase = privilegedDatabase.Unwrap() + } return b.currentDatabase }