Commit 9b5b5d6f authored by unknown's avatar unknown

BUG#10267 mysqltest, wrong number of loops when a script is sourced within a loop


client/mysqltest.c:
  Don't open a sourced file more than once as it will already have been read into the q_lines cache
mysql-test/r/mysqltest.result:
  Added tests for source command inside of while loop
mysql-test/t/mysqltest.test:
  Added tests for source command inside of while loop
parent d57a0e52
......@@ -962,7 +962,13 @@ int do_source(struct st_query* q)
*p++= 0;
check_eol_junk(p);
}
/* If this file has already been sourced, dont source it again.
It's already available in the q_lines cache */
if (parser.current_line < (parser.read_lines - 1))
return 0;
return open_file(name);
}
......@@ -2378,7 +2384,7 @@ int read_query(struct st_query** q_ptr)
DBUG_PRINT("warning",("too long query"));
DBUG_RETURN(1);
}
DBUG_PRINT("info", ("query: %s", read_query_buf));
DBUG_PRINT("info", ("query: %s", read_query_buf));
if (*p == '#')
{
q->type = Q_COMMENT;
......
......@@ -224,6 +224,61 @@ mysqltest: At line 1: Missing file name in source
mysqltest: At line 1: Could not open file ./non_existingFile
mysqltest: In included file "./var/tmp/recursive.sql": At line 1: Source directives are nesting too deep
mysqltest: In included file "./var/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
2 = outer loop variable after while
here is the sourced script
2 = outer loop variable before dec
1 = outer loop variable after dec
1 = outer loop variable after while
here is the sourced script
1 = outer loop variable before dec
0 = outer loop variable after dec
2 = outer loop variable after while
here is the sourced script
2 = outer loop variable before dec
1 = outer loop variable after dec
1 = outer loop variable after while
here is the sourced script
1 = outer loop variable before dec
0 = outer loop variable after dec
In loop
here is the sourced script
In loop
here is the sourced script
In loop
here is the sourced script
In loop
here is the sourced script
In loop
here is the sourced script
In loop
here is the sourced script
In loop
here is the sourced script
In loop
here is the sourced script
In loop
here is the sourced script
mysqltest: At line 1: Missing argument to sleep
mysqltest: At line 1: Invalid argument to sleep "abc"
1
......
......@@ -524,6 +524,49 @@ echo $1;
--exec echo "source var/tmp/error.sql;" | $MYSQL_TEST 2>&1
# Test execution of source in a while loop
--exec echo "echo here is the sourced script;" > var/tmp/sourced.sql
--disable_query_log
let $outer= 2; # Number of outer loops
while ($outer)
{
eval SELECT '$outer = outer loop variable after while' AS "";
--source var/tmp/sourced.sql
eval SELECT '$outer = outer loop variable before dec' AS "";
dec $outer;
eval SELECT '$outer = outer loop variable after dec' AS "";
}
let $outer= 2; # Number of outer loops
while ($outer)
{
eval SELECT '$outer = outer loop variable after while' AS "";
echo here is the sourced script;
eval SELECT '$outer = outer loop variable before dec' AS "";
dec $outer;
eval SELECT '$outer = outer loop variable after dec' AS "";
}
# Test execution of source in a while loop
--exec echo "--source var/tmp/sourced.sql" > var/tmp/sourced1.sql
--disable_abort_on_error
# Sourcing of a file within while loop, sourced file will
# source other file
let $num= 9;
while ($num)
{
SELECT 'In loop' AS "";
--source var/tmp/sourced1.sql
dec $num;
}
--enable_abort_on_error;
--enable_query_log
# ----------------------------------------------------------------------------
# Test sleep command
# ----------------------------------------------------------------------------
......
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