MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:msvensson Date:August 16 2005 3:10pm
Subject:bk commit into 4.1 tree (msvensson:1.2328) BUG#10267
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2328 05/08/16 17:10:52 msvensson@neptunus.(none) +3 -0
  BUG#10267 mysqltest, wrong number of loops when a script is sourced within a loop

  mysql-test/t/mysqltest.test
    1.5 05/08/16 17:10:49 msvensson@neptunus.(none) +43 -0
    Added tests for source command inside of while loop

  mysql-test/r/mysqltest.result
    1.5 05/08/16 17:10:49 msvensson@neptunus.(none) +55 -0
    Added tests for source command inside of while loop

  client/mysqltest.c
    1.171 05/08/16 17:10:49 msvensson@neptunus.(none) +7 -1
    Don't open a sourced file more than once as it will already have been read into the q_lines cache

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/bug11316/my41-bug11316

--- 1.4/mysql-test/r/mysqltest.result	2005-07-15 17:51:38 +02:00
+++ 1.5/mysql-test/r/mysqltest.result	2005-08-16 17:10:49 +02:00
@@ -224,6 +224,61 @@
 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

--- 1.4/mysql-test/t/mysqltest.test	2005-07-15 17:51:38 +02:00
+++ 1.5/mysql-test/t/mysqltest.test	2005-08-16 17:10:49 +02:00
@@ -524,6 +524,49 @@
 --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
 # ----------------------------------------------------------------------------

--- 1.170/client/mysqltest.c	2005-07-15 17:51:37 +02:00
+++ 1.171/client/mysqltest.c	2005-08-16 17:10:49 +02:00
@@ -962,7 +962,13 @@
     *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 @@
     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;
Thread
bk commit into 4.1 tree (msvensson:1.2328) BUG#10267msvensson16 Aug