Fix for Bug #21412 (client allows DELIMITER with backslash character)

parent d3a67330
......@@ -1318,3 +1318,6 @@ win/vs71cache.txt
win/vs8cache.txt
zlib/*.ds?
zlib/*.vcproj
mysql-test/t/tmp.test
mysql-test/r/tmp.result
client/tmp.diff
......@@ -800,10 +800,23 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
default_charset_used= 1;
break;
case OPT_DELIMITER:
if (argument == disabled_my_option)
if (argument == disabled_my_option)
{
strmov(delimiter, DEFAULT_DELIMITER);
else
strmake(delimiter, argument, sizeof(delimiter) - 1);
}
else
{
/* Check that delimiter does not contain a backslash */
if (!strstr(argument, "\\"))
{
strmake(delimiter, argument, sizeof(delimiter) - 1);
}
else
{
put_info("DELIMITER cannot contain a backslash character", INFO_ERROR);
return 0;
}
}
delimiter_length= (uint)strlen(delimiter);
delimiter_str= delimiter;
break;
......@@ -3011,6 +3024,14 @@ com_delimiter(String *buffer __attribute__((unused)), char *line)
INFO_ERROR);
return 0;
}
else
{
if (strstr(tmp, "\\"))
{
put_info("DELIMITER cannot contain a backslash character", INFO_ERROR);
return 0;
}
}
strmake(delimiter, tmp, sizeof(delimiter) - 1);
delimiter_length= (int)strlen(delimiter);
delimiter_str= delimiter;
......
......@@ -139,4 +139,8 @@ ERROR at line 1: USE must be followed by a database name
\\
';
';
1
1
ERROR at line 1: DELIMITER cannot contain a backslash character
ERROR at line 1: DELIMITER cannot contain a backslash character
End of 5.0 tests
......@@ -147,4 +147,22 @@ drop table t1;
--exec echo "SELECT '\';';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
#
# Bug #21412: mysql cmdline client allows backslash(es)
# as delimiter but can't recognize them
#
# This should work just fine...
--exec echo "DELIMITER /" > $MYSQLTEST_VARDIR/tmp/bug21412.sql
--exec echo "SELECT 1/" >> $MYSQLTEST_VARDIR/tmp/bug21412.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1
# This should give an error...
--exec echo "DELIMITER \\" > $MYSQLTEST_VARDIR/tmp/bug21412.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1
# As should this...
--exec echo "DELIMITER \\\\" > $MYSQLTEST_VARDIR/tmp/bug21412.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1
--echo End of 5.0 tests
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