Commit 89220d07 authored by unknown's avatar unknown
Browse files

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


BitKeeper/etc/ignore:
  Added mysql-test/t/tmp.test mysql-test/r/tmp.result client/tmp.diff to the ignore list
client/mysql.cc:
  Fix for Bug #21412 (client allows DELIMITER with backslash)
mysql-test/r/mysql.result:
  Added test case for Bug #21412
mysql-test/t/mysql.test:
  Added test case for Bug #21412
parent 01a75941
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
+24 −3
Original line number Diff line number Diff line
@@ -801,9 +801,22 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
    break;
  case OPT_DELIMITER:
    if (argument == disabled_my_option) 
    {
      strmov(delimiter, DEFAULT_DELIMITER);
    }
    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;
+4 −0
Original line number Diff line number Diff line
@@ -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
+18 −0
Original line number Diff line number Diff line
@@ -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