Commit a54adfc3 authored by unknown's avatar unknown

fixed bug #2592 mysqldump doesn't quote "tricky" names correctly


mysql-test/r/mysqldump.result:
  added test for 
  bug #2592 mysqldump doesn't quote "tricky" names correctly
  please note, output's still looking wrong because of bug #2593
  it will be fixed when fix for bug #2593 will be pushed
mysql-test/t/mysqldump.test:
  added test for bug 
  #2592 mysqldump doesn't quote "tricky" names correctly
sql/sql_lex.cc:
  fixed processing of multibyte quoted variables
parent 150c99df
...@@ -649,7 +649,7 @@ static char *quote_name(const char *name, char *buff, my_bool force) ...@@ -649,7 +649,7 @@ static char *quote_name(const char *name, char *buff, my_bool force)
while (*name) while (*name)
{ {
if (*name == QUOTE_CHAR) if (*name == QUOTE_CHAR)
*to= QUOTE_CHAR; *to++= QUOTE_CHAR;
*to++= *name++; *to++= *name++;
} }
to[0]=QUOTE_CHAR; to[0]=QUOTE_CHAR;
...@@ -1647,7 +1647,7 @@ static int dump_all_tables_in_db(char *database) ...@@ -1647,7 +1647,7 @@ static int dump_all_tables_in_db(char *database)
if (opt_xml) if (opt_xml)
fputs("</database>\n", md_result_file); fputs("</database>\n", md_result_file);
if (lock_tables) if (lock_tables)
mysql_query(sock,"UNLOCK_TABLES"); mysql_query(sock,"UNLOCK TABLES");
return 0; return 0;
} /* dump_all_tables_in_db */ } /* dump_all_tables_in_db */
......
...@@ -123,3 +123,21 @@ UNLOCK TABLES; ...@@ -123,3 +123,21 @@ UNLOCK TABLES;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
DROP TABLE t1; DROP TABLE t1;
create table ```a` (i int);
DROP TABLE IF EXISTS ```a`;
CREATE TABLE ``a` (
`i` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE ```a` DISABLE KEYS */;
LOCK TABLES ```a` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE ```a` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
drop table ```a`;
...@@ -53,3 +53,11 @@ CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r; ...@@ -53,3 +53,11 @@ CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r;
INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'); INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5');
--exec $MYSQL_DUMP --skip-comments test t1 --exec $MYSQL_DUMP --skip-comments test t1
DROP TABLE t1; DROP TABLE t1;
#
# Bug #2592
#
create table ```a` (i int);
--exec $MYSQL_DUMP --skip-comments test
drop table ```a`;
\ No newline at end of file
...@@ -667,13 +667,24 @@ int yylex(void *arg, void *yythd) ...@@ -667,13 +667,24 @@ int yylex(void *arg, void *yythd)
case MY_LEX_USER_VARIABLE_DELIMITER: case MY_LEX_USER_VARIABLE_DELIMITER:
{ {
char delim= c; // Used char uint double_quotes= 0;
char quote_char= c; // Used char
lex->tok_start=lex->ptr; // Skip first ` lex->tok_start=lex->ptr; // Skip first `
#ifdef USE_MB #ifdef USE_MB
if (use_mb(cs)) if (use_mb(cs))
{ {
while ((c=yyGet()) && c != delim && c != (uchar) NAMES_SEP_CHAR) while ((c= yyGet()))
{ {
if (c == quote_char)
{
if (yyPeek() != quote_char)
break;
c= yyGet();
double_quotes++;
continue;
}
if (c == (uchar) NAMES_SEP_CHAR)
break;
if (my_mbcharlen(cs, c) > 1) if (my_mbcharlen(cs, c) > 1)
{ {
int l; int l;
...@@ -684,13 +695,10 @@ int yylex(void *arg, void *yythd) ...@@ -684,13 +695,10 @@ int yylex(void *arg, void *yythd)
lex->ptr += l-1; lex->ptr += l-1;
} }
} }
yylval->lex_str=get_token(lex,yyLength());
} }
else else
#endif #endif
{ {
uint double_quotes= 0;
char quote_char= c;
while ((c=yyGet())) while ((c=yyGet()))
{ {
if (c == quote_char) if (c == quote_char)
...@@ -704,13 +712,13 @@ int yylex(void *arg, void *yythd) ...@@ -704,13 +712,13 @@ int yylex(void *arg, void *yythd)
if (c == (uchar) NAMES_SEP_CHAR) if (c == (uchar) NAMES_SEP_CHAR)
break; break;
} }
if (double_quotes)
yylval->lex_str=get_quoted_token(lex,yyLength() - double_quotes,
quote_char);
else
yylval->lex_str=get_token(lex,yyLength());
} }
if (c == delim) if (double_quotes)
yylval->lex_str=get_quoted_token(lex,yyLength() - double_quotes,
quote_char);
else
yylval->lex_str=get_token(lex,yyLength());
if (c == quote_char)
yySkip(); // Skip end ` yySkip(); // Skip end `
lex->next_state= MY_LEX_START; lex->next_state= MY_LEX_START;
return(IDENT_QUOTED); return(IDENT_QUOTED);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment