Commit 708e741b authored by unknown's avatar unknown

N'xxx' and _utf8'xxx' are not equivalent

Problem: Unescaping of '\' characters didn't work when processing N'xxx'.
Fix: using get_text() instead of get_token() when scanning nationa strings.


mysql-test/r/ctype_utf8.result:
  Adding test case
mysql-test/t/ctype_utf8.test:
  Adding test case
sql/sql_lex.cc:
  Fixing to process national strings using get_tex(),
  i.e. the same way with usual strings, to make
  unescaping work.
parent 090c339a
......@@ -1066,6 +1066,18 @@ LENGTH(bug)
100
DROP TABLE t2;
DROP TABLE t1;
CREATE TABLE t1 (item varchar(255)) default character set utf8;
INSERT INTO t1 VALUES (N'\\');
INSERT INTO t1 VALUES (_utf8'\\');
INSERT INTO t1 VALUES (N'Cote d\'Ivoire');
INSERT INTO t1 VALUES (_utf8'Cote d\'Ivoire');
SELECT item FROM t1 ORDER BY item;
item
Cote d'Ivoire
Cote d'Ivoire
\
\
DROP TABLE t1;
SET NAMES utf8;
DROP TABLE IF EXISTS t1;
Warnings:
......
......@@ -878,6 +878,17 @@ SELECT LENGTH(bug) FROM t2;
DROP TABLE t2;
DROP TABLE t1;
#
# Bug#17313: N'xxx' and _utf8'xxx' are not equivalent
#
CREATE TABLE t1 (item varchar(255)) default character set utf8;
INSERT INTO t1 VALUES (N'\\');
INSERT INTO t1 VALUES (_utf8'\\');
INSERT INTO t1 VALUES (N'Cote d\'Ivoire');
INSERT INTO t1 VALUES (_utf8'Cote d\'Ivoire');
SELECT item FROM t1 ORDER BY item;
DROP TABLE t1;
#
# Bug#17705: Corruption of compressed index when index length changes between
# 254 and 256
......
......@@ -557,23 +557,20 @@ int MYSQLlex(void *arg, void *yythd)
case MY_LEX_IDENT_OR_NCHAR:
if (yyPeek() != '\'')
{ // Found x'hex-number'
{
state= MY_LEX_IDENT;
break;
}
yyGet(); // Skip '
while ((c = yyGet()) && (c !='\'')) ;
length=(lex->ptr - lex->tok_start); // Length of hexnum+3
if (c != '\'')
/* Found N'string' */
lex->tok_start++; // Skip N
yySkip(); // Skip '
if (!(yylval->lex_str.str = get_text(lex)))
{
return(ABORT_SYM); // Illegal hex constant
state= MY_LEX_CHAR; // Read char by char
break;
}
yyGet(); // get_token makes an unget
yylval->lex_str=get_token(lex,length);
yylval->lex_str.str+=2; // Skip x'
yylval->lex_str.length-=3; // Don't count x' and last '
lex->yytoklen-=3;
return (NCHAR_STRING);
yylval->lex_str.length= lex->yytoklen;
return(NCHAR_STRING);
case MY_LEX_IDENT_OR_HEX:
if (yyPeek() == '\'')
......
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