mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
Bug#20432: mysql client interprets commands in comments
do not look for client-specific commands while inside a multi-line comment. we will allow multi-comments pretty much anywhere within SQL-statements, but client-specific commands (help, use, print, ...) must be the first token in the input.
This commit is contained in:
parent
22485908ce
commit
4be51e1644
3 changed files with 34 additions and 1 deletions
|
@ -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;
|
||||
|
|
4
mysql-test/r/mysql_client.result
Normal file
4
mysql-test/r/mysql_client.result
Normal file
|
@ -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
|
29
mysql-test/t/mysql_client.test
Normal file
29
mysql-test/t/mysql_client.test
Normal file
|
@ -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
|
Loading…
Reference in a new issue