MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:January 20 2010 1:18pm
Subject:bzr commit into mysql-5.1-mtr branch (Bjorn.Munch:2879) Bug#49878
View as plain text  
#At file:///home/bm136801/my/ifdelim-51/ based on revid:bernhard.ocklin@stripped

 2879 Bjorn Munch	2010-01-20
      Bug #49878 delimiter under false 'if' makes mysqltest test fail with 'Missing end of block'
      delimiter not executed so does not recognize end of block
      Always execute delimiter command, revert after false if() block.

    modified:
      client/mysqltest.cc
      mysql-test/r/mysqltest.result
      mysql-test/t/mysqltest.test
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-01-20 11:54:55 +0000
+++ b/client/mysqltest.cc	2010-01-20 13:18:27 +0000
@@ -132,6 +132,7 @@ struct st_block
   int             line; /* Start line of block */
   my_bool         ok;   /* Should block be executed */
   enum block_cmd  cmd;  /* Command owning the block */
+  char            delim[MAX_DELIMITER_LENGTH];  /* Delimiter before block */
 };
 
 static struct st_block block_stack[32];
@@ -5142,6 +5143,12 @@ int do_done(struct st_command *command)
   }
   else
   {
+    if (*cur_block->delim) 
+    {
+      /* Restore "old" delimiter after false if block */
+      strcpy (delimiter, cur_block->delim);
+      delimiter_length= strlen(delimiter);
+    }
     /* Pop block from stack, goto next line */
     cur_block--;
     parser.current_line++;
@@ -5200,6 +5207,7 @@ void do_block(enum block_cmd cmd, struct
     cur_block++;
     cur_block->cmd= cmd;
     cur_block->ok= FALSE;
+    cur_block->delim[0]= '\0';
     DBUG_VOID_RETURN;
   }
 
@@ -5236,6 +5244,15 @@ void do_block(enum block_cmd cmd, struct
   if (not_expr)
     cur_block->ok = !cur_block->ok;
 
+  if (cur_block->ok) 
+  {
+    cur_block->delim[0]= '\0';
+  } else
+  {
+    /* Remember "old" delimiter if entering a false if block */
+    strcpy (cur_block->delim, delimiter);
+  }
+  
   DBUG_PRINT("info", ("OK: %d", cur_block->ok));
 
   var_free(&v);
@@ -7798,7 +7815,8 @@ int main(int argc, char **argv)
       command->type= Q_COMMENT;
     }
 
-    my_bool ok_to_do= cur_block->ok;
+    /* delimiter needs to be executed so we can continue to parse */
+    my_bool ok_to_do= cur_block->ok || command->type == Q_DELIMITER;
     /*
       Some commands need to be "done" the first time if they may get
       re-iterated over in a true context. This can only happen if there's 

=== modified file 'mysql-test/r/mysqltest.result'
--- a/mysql-test/r/mysqltest.result	2010-01-07 10:22:45 +0000
+++ b/mysql-test/r/mysqltest.result	2010-01-20 13:18:27 +0000
@@ -377,6 +377,10 @@ test
 test2
 test3
 test4
+outer
+true-inner
+true-inner again
+true-outer
 Counter is greater than 0, (counter=10)
 Counter is not 0, (counter=0)
 1

=== modified file 'mysql-test/t/mysqltest.test'
--- a/mysql-test/t/mysqltest.test	2010-01-07 10:22:45 +0000
+++ b/mysql-test/t/mysqltest.test	2010-01-20 13:18:27 +0000
@@ -1006,6 +1006,37 @@ echo test3stop
 --delimiter ;
 echo test4;
 
+# ----------------------------------------------------------------------------
+# Test that delimiter within if() works in in various combinations
+# ----------------------------------------------------------------------------
+
+if (0)
+{
+  delimiter ||;
+  echo false-inner||
+  if (0)
+  {
+    delimiter *||
+    echo false-innerer*
+    delimiter ||*
+  }
+  echo false-inner again||
+}
+echo outer;
+if (1)
+{
+  delimiter /;
+  echo true-inner/
+  if (0)
+  {
+    delimiter %/
+    echo true-innerer%
+  }
+  echo true-inner again/
+}
+echo true-outer/
+delimiter ;/
+
 
 # ----------------------------------------------------------------------------
 # Test if


Attachment: [text/bzr-bundle] bzr/bjorn.munch@sun.com-20100120131827-3bockyh5a0rfjsgj.bundle
Thread
bzr commit into mysql-5.1-mtr branch (Bjorn.Munch:2879) Bug#49878Bjorn Munch20 Jan