From 6eb2e76abdbf903d6b3848961f942c7d41d640a0 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Tue, 24 Jun 2008 19:32:06 +0500 Subject: [PATCH 1/3] Bug #36244: MySQL CLI doesn't recognize standalone -- as a commentary mysql client has been modified to interpret EOL after standalone -- commentary strings like whitespace character (according to http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-comments.html) mysql-test/t/mysql_delimiter.sql: Added test case for bug #36244. --- client/mysql.cc | 9 ++++++++- mysql-test/t/mysql_delimiter.sql | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index a4706a1c580..5348941b92f 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2156,7 +2156,14 @@ static bool add_line(String &buffer,char *line,char *in_string, } else if (!*ml_comment && (!*in_string && (inchar == '#' || inchar == '-' && pos[1] == '-' && - my_isspace(charset_info,pos[2])))) + /* + The third byte is either whitespace or is the + end of the line -- which would occur only + because of the user sending newline -- which is + itself whitespace and should also match. + */ + (my_isspace(charset_info,pos[2]) || + !pos[2])))) { // Flush previously accepted characters if (out != line) diff --git a/mysql-test/t/mysql_delimiter.sql b/mysql-test/t/mysql_delimiter.sql index db679c3b06b..533ac2ce093 100644 --- a/mysql-test/t/mysql_delimiter.sql +++ b/mysql-test/t/mysql_delimiter.sql @@ -59,3 +59,10 @@ source t/mysql_delimiter_19799.sql use test// show tables// delimiter ; # Reset delimiter + +# +# Bug #36244: MySQL CLI doesn't recognize standalone -- as comment +# before DELIMITER statement +# +-- +DELIMITER ; From 2c77798c7439f7464f371932888f6ac54217f981 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Tue, 24 Jun 2008 21:03:17 +0500 Subject: [PATCH 2/3] back-port from 5.1. Bug#33812: mysql client incorrectly parsing DELIMITER Remove unnecessary and incorrect code that tried to pull delimiter commands out of the middle of statements. --- client/mysql.cc | 31 ------------------------------- mysql-test/r/mysql.result | 2 ++ mysql-test/t/mysql_delimiter.sql | 6 ++++++ 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 5348941b92f..b373b9125a0 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2081,37 +2081,6 @@ static bool add_line(String &buffer,char *line,char *in_string, continue; } } - else if (!*ml_comment && !*in_string && - (end_of_line - pos) >= 10 && - !my_strnncoll(charset_info, (uchar*) pos, 10, - (const uchar*) "delimiter ", 10)) - { - // Flush previously accepted characters - if (out != line) - { - buffer.append(line, (uint32) (out - line)); - out= line; - } - - // Flush possible comments in the buffer - if (!buffer.is_empty()) - { - if (com_go(&buffer, 0) > 0) // < 0 is not fatal - DBUG_RETURN(1); - buffer.length(0); - } - - /* - Delimiter wants the get rest of the given line as argument to - allow one to change ';' to ';;' and back - */ - buffer.append(pos); - if (com_delimiter(&buffer, pos) > 0) - DBUG_RETURN(1); - - buffer.length(0); - break; - } else if (!*ml_comment && !*in_string && is_prefix(pos, delimiter)) { // Found a statement. Continue parsing after the delimiter diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index eded1a3fc3b..bc50c686ac6 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -38,6 +38,8 @@ t2 t3 Tables_in_test t1 +delimiter +1 _ Test delimiter : from command line a diff --git a/mysql-test/t/mysql_delimiter.sql b/mysql-test/t/mysql_delimiter.sql index 533ac2ce093..917401275a2 100644 --- a/mysql-test/t/mysql_delimiter.sql +++ b/mysql-test/t/mysql_delimiter.sql @@ -60,6 +60,12 @@ use test// show tables// delimiter ; # Reset delimiter +# +# Bug #33812: mysql client incorrectly parsing DELIMITER +# +select a as delimiter from t1 +delimiter ; # Reset delimiter + # # Bug #36244: MySQL CLI doesn't recognize standalone -- as comment # before DELIMITER statement From c6f67c6fd9140379eab070ffb1e2f2f9270d8fd5 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Tue, 24 Jun 2008 21:05:56 +0500 Subject: [PATCH 3/3] back-port from 5.1. Bug#35480: BOM detection code crashes mysql CLI with zero-sized input MySQL client crashed if no input was passed to it. --- client/mysql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index b373b9125a0..c8d5522628d 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1779,7 +1779,7 @@ static int read_and_execute(bool interactive) the very beginning of a text file when you save the file using "Unicode UTF-8" format. */ - if (!line_number && + if (line && !line_number && (uchar) line[0] == 0xEF && (uchar) line[1] == 0xBB && (uchar) line[2] == 0xBF)