MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:March 13 2009 4:25pm
Subject:bzr commit into mysql-6.0 branch (alik:2745) Bug#39542
View as plain text  
#At file:///mnt/raid/alik/MySQL/bzr/bug39542/6.0-rt-bug39542/ based on revid:alik@stripped

 2745 Alexander Nozdrin	2009-03-13
      Patch for Bug#39542: main.trigger_compat fails sporadically on windows.
      
      The problem is that the test case used 'grep' and 'mv' UNIX tools,
      which can be not available on Windows.
      
      The fix is to
        - enhance mysqltest set of directive -- introduce 'move_file' directive.
        - replace 'grep' by a perl script.
      modified:
        client/mysqltest.cc
        mysql-test/r/mysqltest.result
        mysql-test/t/mysqltest.test
        mysql-test/t/trigger-compat.test

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2009-02-18 10:23:38 +0000
+++ b/client/mysqltest.cc	2009-03-13 16:25:06 +0000
@@ -282,6 +282,7 @@ enum enum_commands {
   Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
   Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
   Q_RESULT_FORMAT_VERSION,
+  Q_MOVE_FILE,
 
   Q_UNKNOWN,			       /* Unknown command.   */
   Q_COMMENT,			       /* Comments, ignored. */
@@ -377,6 +378,7 @@ const char *command_names[]=
   "send_shutdown",
   "shutdown_server",
   "result_format",
+  "move_file",
 
   0
 };
@@ -1785,7 +1787,7 @@ void check_result()
           log_file.file_name(), reject_file, errno);
 
     show_diff(NULL, result_file_name, reject_file);
-    die(mess);
+    die("%s", mess);
     break;
   }
   default: /* impossible */
@@ -2935,6 +2937,42 @@ void do_copy_file(struct st_command *com
 
 /*
   SYNOPSIS
+  do_move_file
+  command	command handle
+
+  DESCRIPTION
+  move_file <from_file> <to_file>
+  Move <from_file> to <to_file>
+*/
+
+void do_move_file(struct st_command *command)
+{
+  int error;
+  static DYNAMIC_STRING ds_from_file;
+  static DYNAMIC_STRING ds_to_file;
+  const struct command_arg move_file_args[] = {
+    { "from_file", ARG_STRING, TRUE, &ds_from_file, "Filename to move from" },
+    { "to_file", ARG_STRING, TRUE, &ds_to_file, "Filename to move to" }
+  };
+  DBUG_ENTER("do_move_file");
+
+  check_command_args(command, command->first_argument,
+                     move_file_args,
+                     sizeof(move_file_args)/sizeof(struct command_arg),
+                     ' ');
+
+  DBUG_PRINT("info", ("Move %s to %s", ds_from_file.str, ds_to_file.str));
+  error= (my_rename(ds_from_file.str, ds_to_file.str,
+                    MYF(0)) != 0);
+  handle_command_error(command, error);
+  dynstr_free(&ds_from_file);
+  dynstr_free(&ds_to_file);
+  DBUG_VOID_RETURN;
+}
+
+
+/*
+  SYNOPSIS
   do_chmod_file
   command	command handle
 
@@ -7716,6 +7754,7 @@ int main(int argc, char **argv)
       case Q_CHANGE_USER: do_change_user(command); break;
       case Q_CAT_FILE: do_cat_file(command); break;
       case Q_COPY_FILE: do_copy_file(command); break;
+      case Q_MOVE_FILE: do_move_file(command); break;
       case Q_CHMOD_FILE: do_chmod_file(command); break;
       case Q_PERL: do_perl(command); break;
       case Q_RESULT_FORMAT_VERSION: do_result_format_version(command); break;

=== modified file 'mysql-test/r/mysqltest.result'
--- a/mysql-test/r/mysqltest.result	2009-01-15 10:26:48 +0000
+++ b/mysql-test/r/mysqltest.result	2009-03-13 16:25:06 +0000
@@ -547,6 +547,8 @@ mysqltest: At line 1: Failed to open fil
 mysqltest: At line 1: Missing required argument 'filename' to command 'file_exists'
 mysqltest: At line 1: Missing required argument 'from_file' to command 'copy_file'
 mysqltest: At line 1: Missing required argument 'to_file' to command 'copy_file'
+mysqltest: At line 1: Missing required argument 'from_file' to command 'move_file'
+mysqltest: At line 1: Missing required argument 'to_file' to command 'move_file'
 mysqltest: At line 1: Missing required argument 'mode' to command 'chmod'
 mysqltest: At line 1: You must write a 4 digit octal number for mode
 mysqltest: At line 1: You must write a 4 digit octal number for mode

=== modified file 'mysql-test/t/mysqltest.test'
--- a/mysql-test/t/mysqltest.test	2009-01-15 10:26:48 +0000
+++ b/mysql-test/t/mysqltest.test	2009-03-13 16:25:06 +0000
@@ -1748,6 +1748,55 @@ remove_file $MYSQLTEST_VARDIR/tmp/file2.
 --error 1
 --exec echo "copy_file from_file;" | $MYSQL_TEST 2>&1
 
+
+# ----------------------------------------------------------------------------
+# test for move_file
+# ----------------------------------------------------------------------------
+
+# - Check that if source file does not exist, nothing will be created.
+
+--error 1
+file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
+--error 1
+file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
+--error 1
+move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
+--error 1
+file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
+--error 1
+file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
+
+# - Check that if source file exists, everything works properly.
+
+--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
+file1
+EOF
+
+move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
+--error 1
+file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
+file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
+
+# - Check that if destination file exists, everything works properly.
+
+--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
+file1
+EOF
+
+move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
+--error 1
+file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
+file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
+remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp;
+
+# - Check usage.
+
+--error 1
+--exec echo "move_file ;" | $MYSQL_TEST 2>&1
+
+--error 1
+--exec echo "move_file from_file;" | $MYSQL_TEST 2>&1
+
 # ----------------------------------------------------------------------------
 # test for chmod
 # ----------------------------------------------------------------------------

=== modified file 'mysql-test/t/trigger-compat.test'
--- a/mysql-test/t/trigger-compat.test	2007-12-12 17:19:24 +0000
+++ b/mysql-test/t/trigger-compat.test	2009-03-13 16:25:06 +0000
@@ -61,8 +61,30 @@ CREATE TRIGGER wl2818_trg1 BEFORE INSERT
 --echo ---> patching t1.TRG...
 
 let $MYSQLD_DATADIR= `select @@datadir`;
---exec grep -v 'definers=' $MYSQLD_DATADIR/mysqltest_db1/t1.TRG > $MYSQLTEST_VARDIR/tmp/t1.TRG
---exec mv $MYSQLTEST_VARDIR/tmp/t1.TRG $MYSQLD_DATADIR/mysqltest_db1/t1.TRG
+--copy_file $MYSQLD_DATADIR/mysqltest_db1/t1.TRG $MYSQLTEST_VARDIR/tmp/t1.src.TRG
+
+--perl EOF
+
+  my $from_file_path = "$ENV{MYSQLTEST_VARDIR}/tmp/t1.src.TRG";
+  my $to_file_path   = "$ENV{MYSQLTEST_VARDIR}/tmp/t1.dst.TRG";
+
+  open(FROM_FH, "<$from_file_path") or
+    die("Can not open '$from_file_path': $!\n");
+
+  open(TO_FH, ">$to_file_path") or
+    die("Can not open '$to_file_path': $!\n");
+
+  while (<FROM_FH>)
+  {
+    chomp;
+    print TO_FH "$_\n" unless /definers=/;
+  }
+
+  close(FROM_FH);
+  close(TO_FH);
+EOF
+
+--move_file $MYSQLTEST_VARDIR/tmp/t1.dst.TRG $MYSQLD_DATADIR/mysqltest_db1/t1.TRG
 
 #
 # Create a new trigger.

Thread
bzr commit into mysql-6.0 branch (alik:2745) Bug#39542Alexander Nozdrin13 Mar