summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorjimw@mysql.com <>2005-02-17 16:16:58 -0800
committerjimw@mysql.com <>2005-02-17 16:16:58 -0800
commit7eb8c130f7fc6a5aea90233c31ef219796a17390 (patch)
tree76f459723b9f122eb50373fe7c42ffc72f277131 /sql/sql_lex.cc
parent613e09a92a52d15a9b8838c8ef2e42707018dfeb (diff)
parent3c700572b45c578c5e408b991ac0bed8b75a6832 (diff)
downloadmariadb-git-7eb8c130f7fc6a5aea90233c31ef219796a17390.tar.gz
Merge
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc33
1 files changed, 27 insertions, 6 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 08cf4402b74..9d7b2183f52 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -296,7 +296,18 @@ static char *get_text(LEX *lex)
found_escape=1;
if (lex->ptr == lex->end_of_query)
return 0;
- yySkip();
+#ifdef USE_MB
+ int l;
+ if (use_mb(cs) &&
+ (l = my_ismbchar(cs,
+ (const char *)lex->ptr,
+ (const char *)lex->end_of_query))) {
+ lex->ptr += l;
+ continue;
+ }
+ else
+#endif
+ yySkip();
}
else if (c == sep)
{
@@ -324,6 +335,10 @@ static char *get_text(LEX *lex)
else
{
uchar *to;
+
+ /* Re-use found_escape for tracking state of escapes */
+ found_escape= 0;
+
for (to=start ; str != end ; str++)
{
#ifdef USE_MB
@@ -337,7 +352,8 @@ static char *get_text(LEX *lex)
continue;
}
#endif
- if (!(lex->thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) &&
+ if (!found_escape &&
+ !(lex->thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) &&
*str == '\\' && str+1 != end)
{
switch(*++str) {
@@ -364,15 +380,20 @@ static char *get_text(LEX *lex)
*to++= '\\'; // remember prefix for wildcard
/* Fall through */
default:
- *to++ = *str;
+ found_escape= 1;
+ str--;
break;
}
}
- else if (*str == sep)
- *to++= *str++; // Two ' or "
+ else if (!found_escape && *str == sep)
+ {
+ found_escape= 1;
+ }
else
+ {
*to++ = *str;
-
+ found_escape= 0;
+ }
}
*to=0;
lex->yytoklen=(uint) (to-start);