Commit c7de7ff0 authored by Magnus Svensson's avatar Magnus Svensson

Bug #32307 mysqltest - does not detect illegal if syntax

parent dacfba06
......@@ -2184,8 +2184,16 @@ void eval_expr(VAR *v, const char *p, const char **p_end)
if (*p == '$')
{
VAR *vp;
const char* expected_end= *p_end; // Remember var end
if ((vp= var_get(p, p_end, 0, 0)))
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;
}
......
......@@ -206,7 +206,7 @@ START TRANSACTION;
-- disable_query_log
-- disable_result_log
let $n=50;
while ($n>3)
while ($n)
{
eval call test.p3($n);
dec $n;
......
-- require r/not_as_root.require
disable_query_log;
eval select "$MYSQL_TEST_ROOT" as running_as_root;
enable_query_log;
if ($MYSQL_TEST_ROOT){
skip Not as root;
}
......@@ -1883,7 +1883,6 @@ sub check_running_as_root () {
# the file will not return 0000
my $file_mode= (stat($test_file))[2] & 07777;
$ENV{'MYSQL_TEST_ROOT'}= "NO";
mtr_verbose("result: $result, file_mode: $file_mode");
if ($result eq "MySQL" && $file_mode == 0)
{
......
......@@ -293,7 +293,7 @@ var5 from query that returns no row
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: 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/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
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;
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;
......@@ -728,4 +728,6 @@ mysqltest: At line 1: change user failed: Access denied for user 'root'@'localho
SELECT 'c:\\a.txt' AS col;
col
z
hej
mysqltest: At line 1: Found junk ' != 143' after $variable in expression
End of tests
......@@ -41,12 +41,19 @@ while ($i)
error 0,1436 //
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,
# and we successfully returned the error. That means that at the stack
# limit, we still have enough space reserved to report an error.
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.
......
......@@ -2131,5 +2131,25 @@ rmdir $MYSQLTEST_VARDIR/tmp/testdir;
--replace_result c:\\a.txt z
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
......@@ -1665,7 +1665,7 @@ DROP PROCEDURE IF EXISTS p1;
let $iterations= 100;
--disable_query_log
--disable_result_log
while ($iterations > 0)
while ($iterations)
{
--error ER_PARSE_ERROR
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