diff options
-rw-r--r-- | client/mysql.cc | 2 | ||||
-rw-r--r-- | mysql-test/r/date_formats.result | 6 | ||||
-rw-r--r-- | mysql-test/r/mysql_client.result | 4 | ||||
-rw-r--r-- | mysql-test/t/date_formats.test | 8 | ||||
-rw-r--r-- | mysql-test/t/mysql_client.test | 29 | ||||
-rw-r--r-- | sql/time.cc | 2 |
6 files changed, 48 insertions, 3 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 2f9031b84b8..09818ae27b3 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1052,7 +1052,7 @@ static int read_lines(bool execute_commands) (We want to allow help, print and clear anywhere at line start */ if (execute_commands && (named_cmds || glob_buffer.is_empty()) - && !in_string && (com=find_command(line,0))) + && !ml_comment && !in_string && (com=find_command(line,0))) { if ((*com->func)(&glob_buffer,line) > 0) break; diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 00335d2b1b0..035d98d2b74 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -525,3 +525,9 @@ TIME_FORMAT("24:00:00", '%l %p') SELECT TIME_FORMAT("25:00:00", '%l %p'); TIME_FORMAT("25:00:00", '%l %p') 1 AM +SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896); +DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896) +NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '%Y-%m-%d %H:%i:%s' +"End of 4.1 tests" diff --git a/mysql-test/r/mysql_client.result b/mysql-test/r/mysql_client.result new file mode 100644 index 00000000000..87d09428ff6 --- /dev/null +++ b/mysql-test/r/mysql_client.result @@ -0,0 +1,4 @@ +1 +1 +ERROR 1064 (42000) at line 3: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +ERROR at line 1: USE must be followed by a database name diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 362f4614464..922d047eac8 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -289,7 +289,6 @@ drop table t1; select str_to_date( 1, NULL ); select str_to_date( NULL, 1 ); select str_to_date( 1, IF(1=1,NULL,NULL) ); -# End of 4.1 tests # # Bug#11326 @@ -312,3 +311,10 @@ SELECT TIME_FORMAT("12:00:00", '%l %p'); SELECT TIME_FORMAT("23:00:00", '%l %p'); SELECT TIME_FORMAT("24:00:00", '%l %p'); SELECT TIME_FORMAT("25:00:00", '%l %p'); + +# +# Bug#20729: Bad date_format() call makes mysql server crash +# +SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896); + +--echo "End of 4.1 tests" diff --git a/mysql-test/t/mysql_client.test b/mysql-test/t/mysql_client.test new file mode 100644 index 00000000000..e4b6658b631 --- /dev/null +++ b/mysql-test/t/mysql_client.test @@ -0,0 +1,29 @@ +# This test should work in embedded server after we fix mysqltest +-- source include/not_embedded.inc + +# +# Bug #20432: mysql client interprets commands in comments +# + +# if the client sees the 'use' within the comment, we haven't fixed +--exec echo "/*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql +--exec echo "use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql +--exec echo "*/" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1 + +# SQL can have embedded comments => workie +--exec echo "select /*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql +--exec echo "use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql +--exec echo "*/ 1" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1 + +# client commands on the other hand must be at BOL => error +--exec echo "/*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql +--exec echo "xxx" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql +--exec echo "*/ use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql +--error 1 +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1 + +# client comment recognized, but parameter missing => error +--exec echo "use" > $MYSQLTEST_VARDIR/tmp/bug20432.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1 diff --git a/sql/time.cc b/sql/time.cc index e76b169b336..ef832ac5a70 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -797,7 +797,7 @@ void make_truncated_value_warning(THD *thd, const char *str_val, } sprintf(warn_buff, ER(ER_TRUNCATED_WRONG_VALUE), type_str, str.ptr()); - push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, warn_buff); } |