List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:September 28 2010 2:54pm
Subject:bzr push into mysql-next-mr-mtr branch (bjorn.munch:2980 to 2981)
View as plain text  
 2981 Bjorn Munch	2010-09-28 [merge]
      upmerge 56125,56921,57036

    modified:
      client/mysqltest.cc
      mysql-test/mysql-test-run.pl
      mysql-test/r/mysqltest.result
      mysql-test/t/mysqltest.test
 2980 Bjorn Munch	2010-09-21 [merge]
      mysqltest.test fix after 56753

    modified:
      mysql-test/t/mysqltest.test
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-09-21 09:23:17 +0000
+++ b/client/mysqltest.cc	2010-09-28 14:53:13 +0000
@@ -112,6 +112,7 @@ static my_bool parsing_disabled= 0;
 static my_bool display_result_vertically= FALSE, display_result_lower= FALSE,
   display_metadata= FALSE, display_result_sorted= FALSE;
 static my_bool disable_query_log= 0, disable_result_log= 0;
+static my_bool disable_connect_log= 1;
 static my_bool disable_warnings= 0;
 static my_bool disable_info= 1;
 static my_bool abort_on_error= 1;
@@ -227,8 +228,9 @@ typedef struct
   int str_val_len;
   int int_val;
   int alloced_len;
-  int int_dirty; /* do not update string if int is updated until first read */
-  int alloced;
+  bool int_dirty; /* do not update string if int is updated until first read */
+  bool is_int;
+  bool alloced;
 } VAR;
 
 /*Perl/shell-like variable registers */
@@ -284,6 +286,7 @@ enum enum_commands {
   Q_EVAL_RESULT,
   Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
   Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
+  Q_ENABLE_CONNECT_LOG, Q_DISABLE_CONNECT_LOG,
   Q_WAIT_FOR_SLAVE_TO_STOP,
   Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
   Q_ENABLE_INFO, Q_DISABLE_INFO,
@@ -349,6 +352,8 @@ const char *command_names[]=
   /* Enable/disable that the _result_ from a query is logged to result file */
   "enable_result_log",
   "disable_result_log",
+  "enable_connect_log",
+  "disable_connect_log",
   "wait_for_slave_to_stop",
   "enable_warnings",
   "disable_warnings",
@@ -1954,6 +1959,21 @@ static void var_free(void *v)
 
 C_MODE_END
 
+void var_set_int(VAR *v, const char *str)
+{
+  char *endptr;
+  /* Initially assume not a number */
+  v->int_val= 0;
+  v->is_int= false;
+  v->int_dirty= false;
+  if (!str) return;
+  
+  v->int_val = (int) strtol(str, &endptr, 10);
+  /* It is an int if strtol consumed something up to end/space/tab */
+  if (endptr > str && (!*endptr || *endptr == ' ' || *endptr == '\t'))
+    v->is_int= true;
+}
+
 
 VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
               int val_len)
@@ -1988,11 +2008,10 @@ VAR *var_init(VAR *v, const char *name,
     memcpy(tmp_var->str_val, val, val_len);
     tmp_var->str_val[val_len]= 0;
   }
+  var_set_int(tmp_var, val);
   tmp_var->name_len = name_len;
   tmp_var->str_val_len = val_len;
   tmp_var->alloced_len = val_alloc_len;
-  tmp_var->int_val = (val) ? atoi(val) : 0;
-  tmp_var->int_dirty = 0;
   return tmp_var;
 }
 
@@ -2053,7 +2072,7 @@ VAR* var_get(const char *var_name, const
   if (!raw && v->int_dirty)
   {
     sprintf(v->str_val, "%d", v->int_val);
-    v->int_dirty = 0;
+    v->int_dirty= false;
     v->str_val_len = strlen(v->str_val);
   }
   if (var_name_end)
@@ -2115,7 +2134,7 @@ void var_set(const char *var_name, const
     if (v->int_dirty)
     {
       sprintf(v->str_val, "%d", v->int_val);
-      v->int_dirty= 0;
+      v->int_dirty=false;
       v->str_val_len= strlen(v->str_val);
     }
     /* setenv() expects \0-terminated strings */
@@ -2421,6 +2440,7 @@ void var_set_query_get_value(struct st_c
 void var_copy(VAR *dest, VAR *src)
 {
   dest->int_val= src->int_val;
+  dest->is_int= src->is_int;
   dest->int_dirty= src->int_dirty;
 
   /* Alloc/realloc data for str_val in dest */
@@ -2504,9 +2524,7 @@ void eval_expr(VAR *v, const char *p, co
     v->str_val_len = new_val_len;
     memcpy(v->str_val, p, new_val_len);
     v->str_val[new_val_len] = 0;
-    v->int_val=atoi(p);
-    DBUG_PRINT("info", ("atoi on '%s', returns: %d", p, v->int_val));
-    v->int_dirty=0;
+    var_set_int(v, p);
   }
   DBUG_VOID_RETURN;
 }
@@ -2853,6 +2871,8 @@ int do_modify_var(struct st_command *com
     die("The argument to %.*s must be a variable (start with $)",
         command->first_word_len, command->query);
   v= var_get(p, &p, 1, 0);
+  if (! v->is_int)
+    die("Cannot perform inc/dec on a non-numeric value");
   switch (op) {
   case DO_DEC:
     v->int_val--;
@@ -2864,7 +2884,7 @@ int do_modify_var(struct st_command *com
     die("Invalid operator to do_modify_var");
     break;
   }
-  v->int_dirty= 1;
+  v->int_dirty= true;
   command->last_argument= (char*)++p;
   return 0;
 }
@@ -4822,6 +4842,16 @@ void select_connection_name(const char *
 
   set_current_connection(con);
 
+  /* Connection logging if enabled */
+  if (!disable_connect_log && !disable_query_log)
+  {
+    DYNAMIC_STRING *ds= &ds_res;
+
+    dynstr_append_mem(ds, "connection ", 11);
+    replace_dynstr_append(ds, name);
+    dynstr_append_mem(ds, ";\n", 2);
+  }
+
   DBUG_VOID_RETURN;
 }
 
@@ -4909,6 +4939,16 @@ void do_close_connection(struct st_comma
     var_set_string("$CURRENT_CONNECTION", con->name);
   }
 
+  /* Connection logging if enabled */
+  if (!disable_connect_log && !disable_query_log)
+  {
+    DYNAMIC_STRING *ds= &ds_res;
+
+    dynstr_append_mem(ds, "disconnect ", 11);
+    replace_dynstr_append(ds, ds_connection.str);
+    dynstr_append_mem(ds, ";\n", 2);
+  }
+
   DBUG_VOID_RETURN;
 }
 
@@ -5043,6 +5083,13 @@ int connect_n_handle_errors(struct st_co
     dynstr_append_mem(ds, delimiter, delimiter_length);
     dynstr_append_mem(ds, "\n", 1);
   }
+  /* Simlified logging if enabled */
+  if (!disable_connect_log && !disable_query_log)
+  {
+    replace_dynstr_append(ds, command->query);
+    dynstr_append_mem(ds, ";\n", 2);
+  }
+  
   while (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
                           CLIENT_MULTI_STATEMENTS))
   {
@@ -8120,6 +8167,8 @@ int main(int argc, char **argv)
       case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break;
       case Q_ENABLE_RESULT_LOG:  disable_result_log=0; break;
       case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
+      case Q_ENABLE_CONNECT_LOG:   disable_connect_log=0; break;
+      case Q_DISABLE_CONNECT_LOG:  disable_connect_log=1; break;
       case Q_ENABLE_WARNINGS:    disable_warnings=0; break;
       case Q_DISABLE_WARNINGS:   disable_warnings=1; break;
       case Q_ENABLE_INFO:        disable_info=0; break;

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2010-09-02 08:06:12 +0000
+++ b/mysql-test/mysql-test-run.pl	2010-09-28 14:53:13 +0000
@@ -126,12 +126,24 @@ my $path_vardir_trace;          # unix f
 my $opt_tmpdir;                 # Path to use for tmp/ dir
 my $opt_tmpdir_pid;
 
+my $opt_start;
+my $opt_start_dirty;
+my $opt_start_exit;
+my $start_only;
+
 END {
   if ( defined $opt_tmpdir_pid and $opt_tmpdir_pid == $$ )
   {
-    # Remove the tempdir this process has created
-    mtr_verbose("Removing tmpdir '$opt_tmpdir");
-    rmtree($opt_tmpdir);
+    if (!$opt_start_exit)
+    {
+      # Remove the tempdir this process has created
+      mtr_verbose("Removing tmpdir $opt_tmpdir");
+      rmtree($opt_tmpdir);
+    }
+    else
+    {
+      mtr_warning("tmpdir $opt_tmpdir should be removed after the server has finished");
+    }
   }
 }
 
@@ -234,10 +246,6 @@ my $opt_start_timeout   = $ENV{MTR_START
 sub suite_timeout { return $opt_suite_timeout * 60; };
 sub check_timeout { return $opt_testcase_timeout * 6; };
 
-my $opt_start;
-my $opt_start_dirty;
-my $opt_start_exit;
-my $start_only;
 my $opt_wait_all;
 my $opt_user_args;
 my $opt_repeat= 1;

=== modified file 'mysql-test/r/mysqltest.result'
--- a/mysql-test/r/mysqltest.result	2010-09-20 09:11:31 +0000
+++ b/mysql-test/r/mysqltest.result	2010-09-28 14:53:13 +0000
@@ -369,23 +369,24 @@ mysqltest: At line 1: Missing required a
 mysqltest: At line 1: Invalid argument to sleep "abc"
 mysqltest: At line 1: Invalid argument to real_sleep "abc"
 1
-2
 101
-hej
-1
+-99
 mysqltest: At line 1: Missing argument to inc
 mysqltest: At line 1: The argument to inc must be a variable (start with $)
+mysqltest: At line 1: Cannot perform inc/dec on a non-numeric value
 mysqltest: At line 1: End of line junk detected: "1000"
-4
-4
+mysqltest: At line 1: Cannot perform inc/dec on a non-numeric value
+mysqltest: At line 1: Cannot perform inc/dec on a non-numeric value
+-96
+-96
 -1
--2
 99
-hej
--1
 mysqltest: At line 1: Missing argument to dec
 mysqltest: At line 1: The argument to dec must be a variable (start with $)
+mysqltest: At line 1: Cannot perform inc/dec on a non-numeric value
 mysqltest: At line 1: End of line junk detected: "1000"
+mysqltest: At line 1: Cannot perform inc/dec on a non-numeric value
+mysqltest: At line 1: Cannot perform inc/dec on a non-numeric value
 mysqltest: At line 1: Missing arguments to system, nothing to do!
 mysqltest: At line 1: Missing arguments to system, nothing to do!
 system command 'NonExistsinfComamdn 2> /dev/null' failed
@@ -452,12 +453,16 @@ mysqltest: At line 1: Missing required a
 mysqltest: At line 1: query 'connect  con2,localhost,root,,illegal_db' failed: 1049: Unknown database 'illegal_db'
 mysqltest: At line 1: Illegal argument for port: 'illegal_port'
 mysqltest: At line 1: Illegal option to connect: SMTP
-OK
-mysqltest: The test didn't produce any output
+200 connects succeeded
 mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 3: connection 'test_con1' not found in connection pool
 mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 2: Connection test_con1 already exists
 show tables;
 ERROR 3D000: No database selected
+connect  con1,localhost,root,,;
+connection default;
+connection con1;
+disconnect con1;
+connection default;
 Output from mysqltest-x.inc
 Output from mysqltest-x.inc
 Output from mysqltest-x.inc

=== modified file 'mysql-test/t/mysqltest.test'
--- a/mysql-test/t/mysqltest.test	2010-09-21 09:23:17 +0000
+++ b/mysql-test/t/mysqltest.test	2010-09-28 14:53:13 +0000
@@ -1006,16 +1006,13 @@ EOF
 # ----------------------------------------------------------------------------
 # Test inc
 # ----------------------------------------------------------------------------
-inc $i;
-echo $i;
+let $i= 0;
 inc $i;
 echo $i;
 let $i=100;
 inc $i;
 echo $i;
-
-let $i=hej;
-echo $i;
+let $i= -100;
 inc $i;
 echo $i;
 
@@ -1024,7 +1021,13 @@ echo $i;
 --error 1
 --exec echo "inc i;" | $MYSQL_TEST 2>&1
 --error 1
+--exec echo "inc \$i;" | $MYSQL_TEST 2>&1
+--error 1
 --exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "let \$i=text; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "let \$i=10cc; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1
 
 inc $i; inc $i; inc $i; --echo $i
 echo $i;
@@ -1034,25 +1037,25 @@ echo $i;
 # Test dec
 # ----------------------------------------------------------------------------
 
-dec $d;
-echo $d;
+let $d= 0;
 dec $d;
 echo $d;
 let $d=100;
 dec $d;
 echo $d;
 
-let $d=hej;
-echo $d;
-dec $d;
-echo $d;
-
 --error 1
 --exec echo "dec;" | $MYSQL_TEST 2>&1
 --error 1
 --exec echo "dec i;" | $MYSQL_TEST 2>&1
 --error 1
+--exec echo "dec \$i;" | $MYSQL_TEST 2>&1
+--error 1
 --exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "let \$i=text; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "let \$i=10cc; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1
 
 
 # ----------------------------------------------------------------------------
@@ -1467,19 +1470,6 @@ eval select "$long_rep" as x;
 
 # Repeat connect/disconnect
 --write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
-let $i=100;
-while ($i)
-{
-  connect (test_con1,localhost,root,,);
-  disconnect test_con1;
-  dec $i;
-}
-EOF
---exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK; exit;" | $MYSQL_TEST 2>&1
-remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
-
-# Repeat connect/disconnect
---write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
 let $i=200;
 while ($i)
 {
@@ -1487,9 +1477,8 @@ while ($i)
  disconnect test_con1;
  dec $i;
 }
+echo 200 connects succeeded;
 EOF
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---error 1
 --exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
 remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
 
@@ -1530,6 +1519,22 @@ show tables;
 disconnect con2;
 connection default;
 
+# Test enable_connect_log
+--enable_connect_log
+connect (con1,localhost,root,,);
+connection default;
+connection con1;
+--disable_query_log
+# These should not be logged
+connect (con2,localhost,root,,*NO-ONE*);
+connection con2;
+disconnect con2;
+connection con1;
+--enable_query_log
+disconnect con1;
+connection default;
+--disable_connect_log
+
 # ----------------------------------------------------------------------------
 # Test mysqltest arguments
 # ----------------------------------------------------------------------------


Attachment: [text/bzr-bundle] bzr/bjorn.munch@oracle.com-20100928145313-7rfelsuzmjhwants.bundle
Thread
bzr push into mysql-next-mr-mtr branch (bjorn.munch:2980 to 2981) Bjorn Munch28 Sep