From d3a67330ff9f200bdb20c89cadd9cc2003dd403d Mon Sep 17 00:00:00 2001 From: "jpipes@shakedown.(none)" <> Date: Mon, 25 Sep 2006 14:58:10 -0400 Subject: [PATCH 1/2] Fix for Bug #21466: INET_ATON() returns signed int, not unsigned --- mysql-test/r/func_misc.result | 7 +++++++ mysql-test/t/func_misc.test | 7 +++++++ sql/item_func.h | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index f0262acd71e..6b6277ea649 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -134,4 +134,11 @@ timediff(b, a) >= '00:00:03' drop table t2; drop table t1; set global query_cache_size=default; +create table t1 select INET_ATON('255.255.0.1') as `a`; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(21) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 52a5512d070..5cac6c45f65 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -125,4 +125,11 @@ drop table t2; drop table t1; set global query_cache_size=default; +# +# Bug #21466: INET_ATON() returns signed, not unsigned +# + +create table t1 select INET_ATON('255.255.0.1') as `a`; +show create table t1; +drop table t1; --echo End of 5.0 tests diff --git a/sql/item_func.h b/sql/item_func.h index 177daf0311f..0a821733a29 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1289,7 +1289,7 @@ public: Item_func_inet_aton(Item *a) :Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "inet_aton"; } - void fix_length_and_dec() { decimals = 0; max_length = 21; maybe_null=1;} + void fix_length_and_dec() { decimals = 0; max_length = 21; maybe_null=1;unsigned_flag=1;} }; From b57051381a4dbd7c7f933b28582c496047e2f139 Mon Sep 17 00:00:00 2001 From: "jpipes@shakedown.(none)" <> Date: Mon, 2 Oct 2006 11:45:48 -0400 Subject: [PATCH 2/2] Fix for Bug #21412 (client allows DELIMITER with backslash character) --- .bzrignore | 3 +++ client/mysql.cc | 27 ++++++++++++++++++++++++--- mysql-test/r/mysql.result | 4 ++++ mysql-test/t/mysql.test | 18 ++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.bzrignore b/.bzrignore index 7e6c6985e23..810b2f2d03c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -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 diff --git a/client/mysql.cc b/client/mysql.cc index 5e09c309917..95336f4579f 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -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; diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 7dbff4beca5..7df5b72513f 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -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 diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 9e3eabf474b..a2e5c348c60 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -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