summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <ram@gw.mysql.r18.ru>2004-10-21 17:02:24 +0500
committerunknown <ram@gw.mysql.r18.ru>2004-10-21 17:02:24 +0500
commit70fe41d2ec0fccdd54f643d832b67274a8f76f16 (patch)
treecc1d9f6ec82546e9be474e94ed72da5e649bfad8 /client
parentffd77c4679615ba3e4dd7614dadc735af5d4aa9c (diff)
downloadmariadb-git-70fe41d2ec0fccdd54f643d832b67274a8f76f16.tar.gz
A fix (bug #4802 prompt in mysql client shows wrong database after dropping default db).
client/mysql.cc: A fix (bug #4802 prompt in mysql client shows wrong database after dropping default db). Introduced new get_current_db() function which is called from the com_use() and the com_go() if we get SERVER_STATUS_DB_DROPPED. include/mysql_com.h: A fix (bug #4802 prompt in mysql client shows wrong database after dropping default db). SERVER_STATUS_DB_DROPPED flag added. Note: it is set to 256 to don't conflict with 5.0 ver. sql/sql_db.cc: A fix (bug #4802 prompt in mysql client shows wrong database after dropping default db). SERVER_STATUS_DB_DROPPED flag is set/unset.
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc38
1 files changed, 20 insertions, 18 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 05d5d1355ad..18dc4dd76cb 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1574,6 +1574,22 @@ static int reconnect(void)
return 0;
}
+static void get_current_db()
+{
+ MYSQL_RES *res;
+
+ my_free(current_db, MYF(MY_ALLOW_ZERO_PTR));
+ current_db= NULL;
+ /* In case of error below current_db will be NULL */
+ if (!mysql_query(&mysql, "SELECT DATABASE()") &&
+ (res= mysql_use_result(&mysql)))
+ {
+ MYSQL_ROW row= mysql_fetch_row(res);
+ if (row[0])
+ current_db= my_strdup(row[0], MYF(MY_WME));
+ mysql_free_result(res);
+ }
+}
/***************************************************************************
The different commands
@@ -1899,6 +1915,9 @@ com_go(String *buffer,char *line __attribute__((unused)))
if (err >= 1)
error= put_error(&mysql);
+ if (!status.batch && (mysql.server_status & SERVER_STATUS_DB_DROPPED))
+ get_current_db();
+
return error; /* New command follows */
}
@@ -2614,24 +2633,7 @@ com_use(String *buffer __attribute__((unused)), char *line)
under our feet, for example if DROP DATABASE or RENAME DATABASE
(latter one not yet available by the time the comment was written)
*/
- /* Let's reset current_db, assume it's gone */
- my_free(current_db, MYF(MY_ALLOW_ZERO_PTR));
- current_db= 0;
- /*
- We don't care about in case of an error below because current_db
- was just set to 0.
- */
- if (!mysql_query(&mysql, "SELECT DATABASE()") &&
- (res= mysql_use_result(&mysql)))
- {
- row= mysql_fetch_row(res);
- if (row[0])
- {
- current_db= my_strdup(row[0], MYF(MY_WME));
- }
- (void) mysql_fetch_row(res); // Read eof
- mysql_free_result(res);
- }
+ get_current_db();
if (!current_db || cmp_database(charset_info, current_db,tmp))
{