Commit d531eb62 authored by Magnus Svensson's avatar Magnus Svensson

Bug #32307 mysqltest - does not detect illegal if syntax

parent b636f8f0
...@@ -2184,8 +2184,16 @@ void eval_expr(VAR *v, const char *p, const char **p_end) ...@@ -2184,8 +2184,16 @@ void eval_expr(VAR *v, const char *p, const char **p_end)
if (*p == '$') if (*p == '$')
{ {
VAR *vp; VAR *vp;
const char* expected_end= *p_end; // Remember var end
if ((vp= var_get(p, p_end, 0, 0))) if ((vp= var_get(p, p_end, 0, 0)))
var_copy(v, vp); var_copy(v, vp);
/* Make sure there was just a $variable and nothing else */
const char* end= *p_end + 1;
if (end < expected_end)
die("Found junk '%.*s' after $variable in expression",
expected_end - end - 1, end);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -206,7 +206,7 @@ START TRANSACTION; ...@@ -206,7 +206,7 @@ START TRANSACTION;
-- disable_query_log -- disable_query_log
-- disable_result_log -- disable_result_log
let $n=50; let $n=50;
while ($n>3) while ($n)
{ {
eval call test.p3($n); eval call test.p3($n);
dec $n; dec $n;
......
-- require r/not_as_root.require if ($MYSQL_TEST_ROOT){
disable_query_log; skip Not as root;
eval select "$MYSQL_TEST_ROOT" as running_as_root; }
enable_query_log;
...@@ -1883,7 +1883,6 @@ sub check_running_as_root () { ...@@ -1883,7 +1883,6 @@ sub check_running_as_root () {
# the file will not return 0000 # the file will not return 0000
my $file_mode= (stat($test_file))[2] & 07777; my $file_mode= (stat($test_file))[2] & 07777;
$ENV{'MYSQL_TEST_ROOT'}= "NO";
mtr_verbose("result: $result, file_mode: $file_mode"); mtr_verbose("result: $result, file_mode: $file_mode");
if ($result eq "MySQL" && $file_mode == 0) if ($result eq "MySQL" && $file_mode == 0)
{ {
......
...@@ -293,7 +293,7 @@ var5 from query that returns no row ...@@ -293,7 +293,7 @@ var5 from query that returns no row
failing query in let failing query in let
mysqltest: At line 1: Error running query 'failing query': 1064 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 'failing query' at line 1 mysqltest: At line 1: Error running query 'failing query': 1064 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 'failing query' at line 1
mysqltest: At line 1: Missing required argument 'filename' to command 'source' mysqltest: At line 1: Missing required argument 'filename' to command 'source'
mysqltest: At line 1: Could not open './non_existingFile' for reading mysqltest: At line 1: Could not open './non_existingFile' for reading, errno: 2
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql": At line 1: query 'garbage ' failed: 1064: 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 'garbage' at line 1 mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql": At line 1: query 'garbage ' failed: 1064: 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 'garbage' at line 1
...@@ -443,7 +443,7 @@ ERROR 3D000: No database selected ...@@ -443,7 +443,7 @@ ERROR 3D000: No database selected
Output from mysqltest-x.inc Output from mysqltest-x.inc
Output from mysqltest-x.inc Output from mysqltest-x.inc
Output from mysqltest-x.inc Output from mysqltest-x.inc
mysqltest: Could not open './non_existing_file.inc' for reading: errno = 2 mysqltest: Could not open './non_existing_file.inc' for reading, errno: 2
failing_statement; failing_statement;
ERROR 42000: 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 'failing_statement' at line 1 ERROR 42000: 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 'failing_statement' at line 1
failing_statement; failing_statement;
...@@ -728,4 +728,6 @@ mysqltest: At line 1: change user failed: Access denied for user 'root'@'localho ...@@ -728,4 +728,6 @@ mysqltest: At line 1: change user failed: Access denied for user 'root'@'localho
SELECT 'c:\\a.txt' AS col; SELECT 'c:\\a.txt' AS col;
col col
z z
hej
mysqltest: At line 1: Found junk ' != 143' after $variable in expression
End of tests End of tests
...@@ -41,12 +41,19 @@ while ($i) ...@@ -41,12 +41,19 @@ while ($i)
error 0,1436 // error 0,1436 //
eval $query_head 0 $query_tail// eval $query_head 0 $query_tail//
if ($mysql_errno != 1436) if ($mysql_errno)
{ {
# We reached the place where we reported an error about the stack limit, # We reached the place where we reported an error about the stack limit,
# and we successfully returned the error. That means that at the stack # and we successfully returned the error. That means that at the stack
# limit, we still have enough space reserved to report an error. # limit, we still have enough space reserved to report an error.
let $i = 1// let $i = 1//
# Check that mysql_errno is 1436
if (`select $mysql_errno != 1436`)
{
die Wrong error triggered, expected 1436 but got $mysql_errno//
}
} }
# Multiplying by three stack frames should be fine enough resolution. # Multiplying by three stack frames should be fine enough resolution.
......
...@@ -2131,5 +2131,25 @@ rmdir $MYSQLTEST_VARDIR/tmp/testdir; ...@@ -2131,5 +2131,25 @@ rmdir $MYSQLTEST_VARDIR/tmp/testdir;
--replace_result c:\\a.txt z --replace_result c:\\a.txt z
SELECT 'c:\\a.txt' AS col; SELECT 'c:\\a.txt' AS col;
#
# Bug #32307 mysqltest - does not detect illegal if syntax
#
let $test= 1;
if ($test){
echo hej;
}
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
if ($mysql_errno != 1436)
{
echo ^ Should not be allowed!
}
EOF
--error 1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
--echo End of tests --echo End of tests
...@@ -1665,7 +1665,7 @@ DROP PROCEDURE IF EXISTS p1; ...@@ -1665,7 +1665,7 @@ DROP PROCEDURE IF EXISTS p1;
let $iterations= 100; let $iterations= 100;
--disable_query_log --disable_query_log
--disable_result_log --disable_result_log
while ($iterations > 0) while ($iterations)
{ {
--error ER_PARSE_ERROR --error ER_PARSE_ERROR
PREPARE stmt FROM "CREATE PROCEDURE p1()"; PREPARE stmt FROM "CREATE PROCEDURE p1()";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment