#At file:///Users/kgeorge/mysql/work/B31060-5.0-bugteam/ based on revid:aelkin@stripped
2760 Georgi Kodinov 2009-02-24
Bug #31060: MySQL CLI parser bug 2
There was a problem when a DELIMITER COMMAND is not the first
command on the line. I this case an extra line feed was added
to the glob buffer and this was causing subsequent attempts
to enter this delimiter to fail.
Fixed by not adding a new line to the glob buffer if the
command being added is a DELIMITER
@ client/mysql.cc
Bug #31060: Don't add a new line if DELIMTER is added to
the glob buffer
@ mysql-test/r/mysql.result
Bug #31060: test case
@ mysql-test/t/mysql.test
Bug #31060: test case
modified:
client/mysql.cc
mysql-test/r/mysql.result
mysql-test/t/mysql.test
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc 2009-02-19 03:58:10 +0000
+++ b/client/mysql.cc 2009-02-24 13:06:28 +0000
@@ -2222,8 +2222,22 @@ static bool add_line(String &buffer,char
}
if (out != line || !buffer.is_empty())
{
- *out++='\n';
uint length=(uint) (out-line);
+
+ if (length < 9 ||
+ my_strnncoll (charset_info,
+ (uchar *)line, 9, (const uchar *) "delimiter", 9))
+ {
+ /*
+ Don't add a new line in case there's a DELIMITER command to be
+ added to the glob buffer (e.g. on processing a line like
+ "<command>;DELIMITER <non-eof>") : similar to how a new line is
+ not added in the case when the DELIMITER is the first command
+ entered with an empty glob buffer.
+ */
+ *out++='\n';
+ length++;
+ }
if (buffer.length() + length >= buffer.alloced_length())
buffer.realloc(buffer.length()+length+IO_SIZE);
if ((!*ml_comment || preserve_comments) && buffer.append(line, length))
=== modified file 'mysql-test/r/mysql.result'
--- a/mysql-test/r/mysql.result 2009-01-09 11:50:18 +0000
+++ b/mysql-test/r/mysql.result 2009-02-24 13:06:28 +0000
@@ -188,4 +188,8 @@ delimiter
2
@z:='1' @z=database()
1 NULL
+1
+1
+1
+1
End of 5.0 tests
=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test 2009-01-09 11:50:18 +0000
+++ b/mysql-test/t/mysql.test 2009-02-24 13:06:28 +0000
@@ -314,4 +314,21 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug381
#
--exec $MYSQL -e "select @z:='1',@z=database()"
+
+#
+# Bug #31060: MySQL CLI parser bug 2
+#
+
+--write_file $MYSQLTEST_VARDIR/tmp/bug31060.sql
+;DELIMITER DELIMITER
+;
+SELECT 1DELIMITER
+DELIMITER ;
+SELECT 1;
+EOF
+
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug31060.sql 2>&1
+
+remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql;
+
--echo End of 5.0 tests
Attachment: [text/bzr-bundle] bzr/kgeorge@mysql.com-20090224130628-ingwis6mrztwzo8n.bundle
| Thread |
|---|
| • bzr commit into mysql-5.0-bugteam branch (kgeorge:2760) Bug#31060 | Georgi Kodinov | 25 Feb |