diff options
author | unknown <hf@deer.(none)> | 2004-09-13 12:13:24 +0500 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2004-09-13 12:13:24 +0500 |
commit | 4015c585ad6df0e585d5d4f80f6b27789697e666 (patch) | |
tree | cbe5df050b918ab301f5b5afa606981d8820f241 /client | |
parent | c1e84276868d04c165bca8b7a5fd36fe7ff4aed5 (diff) | |
download | mariadb-git-4015c585ad6df0e585d5d4f80f6b27789697e666.tar.gz |
Fix for bug #4809 (Backticks not handled in mysql)
client/mysql.cc:
Code added to handle backticks
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 7d1b6af2c37..4aac548a065 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2201,17 +2201,49 @@ static int com_source(String *buffer, char *line) static int com_use(String *buffer __attribute__((unused)), char *line) { - char *tmp, buff[FN_REFLEN + 1]; + char tmp[FN_REFLEN], buff[FN_REFLEN + 1]; MYSQL_RES *res; MYSQL_ROW row; + char *c_buff, *c_tmp; while (isspace(*line)) line++; strnmov(buff,line,sizeof(buff)-1); // Don't destroy history if (buff[0] == '\\') // Short command buff[1]=' '; - tmp=(char *) strtok(buff," \t;"); // Skip connect command - if (!tmp || !(tmp=(char *) strtok(NullS," \t;"))) + c_buff= buff; + while ((*c_buff != ' ') && (*c_buff != '\t')) // Skip connect command + c_buff++; + c_buff++; + + while ((*c_buff == ' ') || (*c_buff == '\t')) + c_buff++; + c_tmp= tmp; + if (*c_buff == '`') // Handling backticks + { + c_buff++; + for (; *c_buff; c_tmp++) + { + if (*c_buff == '`') + { + if (c_buff[1] == '`') + { + *c_tmp= '`'; + c_buff+= 2; + } + else + break; + } + else + *c_tmp= *(c_buff++); + } + } + else + for (; !strchr(" \t;", *c_buff); c_buff++, c_tmp++) + *c_tmp= *c_buff; + *c_tmp= '\0'; + + if (!*tmp) { put_info("USE must be followed by a database name",INFO_ERROR); return 0; |