summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Svensson <msvensson@mysql.com>2008-08-04 12:38:50 +0200
committerMagnus Svensson <msvensson@mysql.com>2008-08-04 12:38:50 +0200
commitc7de7ff0bd262e2a43a1e545ad513b1ccff1238c (patch)
tree11c91878e4017691a0abd037b32526d53a1ee32a
parentdacfba06f8397b81da45897e504a44ec3f1af7fc (diff)
downloadmariadb-git-c7de7ff0bd262e2a43a1e545ad513b1ccff1238c.tar.gz
Bug #32307 mysqltest - does not detect illegal if syntax
-rw-r--r--client/mysqltest.c8
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_sp002.test2
-rw-r--r--mysql-test/include/not_as_root.inc7
-rwxr-xr-xmysql-test/mysql-test-run.pl1
-rw-r--r--mysql-test/r/mysqltest.result6
-rw-r--r--mysql-test/r/not_as_root.require2
-rw-r--r--mysql-test/t/execution_constants.test9
-rw-r--r--mysql-test/t/mysqltest.test20
-rw-r--r--mysql-test/t/ps.test2
9 files changed, 45 insertions, 12 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index f700ea9479d..09d6292f0a0 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -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;
}
diff --git a/mysql-test/extra/rpl_tests/rpl_row_sp002.test b/mysql-test/extra/rpl_tests/rpl_row_sp002.test
index 47afcce875b..5a2ab1912b8 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_sp002.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_sp002.test
@@ -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;
diff --git a/mysql-test/include/not_as_root.inc b/mysql-test/include/not_as_root.inc
index e0277ea593e..6c88051d632 100644
--- a/mysql-test/include/not_as_root.inc
+++ b/mysql-test/include/not_as_root.inc
@@ -1,4 +1,3 @@
--- 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;
+}
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 87aeff437d6..af62536e462 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -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)
{
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index adf99185d89..fc1dc5c0863 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -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
diff --git a/mysql-test/r/not_as_root.require b/mysql-test/r/not_as_root.require
deleted file mode 100644
index d9ea5244efc..00000000000
--- a/mysql-test/r/not_as_root.require
+++ /dev/null
@@ -1,2 +0,0 @@
-running_as_root
-NO
diff --git a/mysql-test/t/execution_constants.test b/mysql-test/t/execution_constants.test
index 4930164d3fa..e61d79f5249 100644
--- a/mysql-test/t/execution_constants.test
+++ b/mysql-test/t/execution_constants.test
@@ -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.
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index b41f033d2af..1bc6a4a625a 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -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
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 3e1a41d32c8..91cb6eef8ad 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -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()";