Commit 3443fdf9 authored by unknown's avatar unknown
Browse files

Handle backslashes correctly in strings that also have doubled quotes when

we are using the NO_BACKSLASH_ESCAPES SQL mode. (Bug #6368)


mysql-test/t/sql_mode.test:
  Add regression test for Bug #6368
mysql-test/r/sql_mode.result:
  Add new results
sql/sql_lex.cc:
  Handle NO_BACKSLASH_ESCAPES mode when copying string that
  also has escapes due to doubled quotes
parent 2ae812a7
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -386,4 +386,18 @@ p mask example
20	\\\\%	\\\\%
20	\\\\%	\\\\_
DROP TABLE t1;
SET @@SQL_MODE='NO_BACKSLASH_ESCAPES';
SELECT 'a\\b', 'a\\\"b', 'a''\\b', 'a''\\\"b';
a\\b	a\\\"b	a'\\b	a'\\\"b
a\\b	a\\\"b	a'\\b	a'\\\"b
SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b";
a\\b	a\\\'b	a"\\b	a"\\\'b
a\\b	a\\\'b	a"\\b	a"\\\'b
SET @@SQL_MODE='';
SELECT 'a\\b', 'a\\\"b', 'a''\\b', 'a''\\\"b';
a\b	a\"b	a'\b	a'\"b
a\b	a\"b	a'\b	a'\"b
SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b";
a\b	a\'b	a"\b	a"\'b
a\b	a\'b	a"\b	a"\'b
SET @@SQL_MODE=@OLD_SQL_MODE;
+10 −0
Original line number Diff line number Diff line
@@ -174,4 +174,14 @@ order by masks.p, example;

DROP TABLE t1;

# Bug #6368: Make sure backslashes mixed with doubled quotes are handled
# correctly in NO_BACKSLASH_ESCAPES mode
SET @@SQL_MODE='NO_BACKSLASH_ESCAPES';
SELECT 'a\\b', 'a\\\"b', 'a''\\b', 'a''\\\"b';
SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b";

SET @@SQL_MODE='';
SELECT 'a\\b', 'a\\\"b', 'a''\\b', 'a''\\\"b';
SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b";

SET @@SQL_MODE=@OLD_SQL_MODE;
+2 −1
Original line number Diff line number Diff line
@@ -334,7 +334,8 @@ static char *get_text(LEX *lex)
	      continue;
	  }
#endif
	  if (*str == '\\' && str+1 != end)
	  if (!(lex->thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) &&
              *str == '\\' && str+1 != end)
	  {
	    switch(*++str) {
	    case 'n':