mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-26 01:40:36 +00:00
fix: return err msg if use wrong database in MySQL (#1866)
This commit is contained in:
@@ -344,10 +344,16 @@ impl<W: AsyncWrite + Send + Sync + Unpin> AsyncMysqlShim<W> for MysqlInstanceShi
|
||||
|
||||
async fn on_init<'a>(&'a mut self, database: &'a str, w: InitWriter<'a, W>) -> Result<()> {
|
||||
let (catalog, schema) = crate::parse_catalog_and_schema_from_client_database_name(database);
|
||||
ensure!(
|
||||
self.query_handler.is_valid_schema(catalog, schema).await?,
|
||||
error::DatabaseNotFoundSnafu { catalog, schema }
|
||||
);
|
||||
|
||||
if !self.query_handler.is_valid_schema(catalog, schema).await? {
|
||||
return w
|
||||
.error(
|
||||
ErrorKind::ER_WRONG_DB_NAME,
|
||||
format!("Unknown database '{}'", database).as_bytes(),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| e.into());
|
||||
}
|
||||
|
||||
let user_info = &self.session.user_info();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user