List:Commits« Previous MessageNext Message »
From:Guilhem Bichot Date:January 11 2011 10:00pm
Subject:bzr commit into mysql-5.5 branch (guilhem:3237) Bug#59432
View as plain text  
#At file:///home/mysql_src/bzrrepos_new/5.5-bugteam/ based on revid:dmitry.shulga@stripped

 3237 Guilhem Bichot	2011-01-11
      Fix for BUG#59432 "--autocommit=on does not work (@@global.autocommit is 0)"
     @ mysql-test/suite/sys_vars/r/autocommit_func4.result
        Before this fix, this test would have shown @@global.autocommit == 0
        in spite of --autocommit=on.
     @ mysql-test/suite/sys_vars/r/autocommit_func5.result
        result unchanged by the fix
     @ sql/mysqld.cc
        atoi(argument) was reliable for =0|1 parameters. Now that boolean options
        must support =on/off/true/false, atoi(argument) is wrong (being always 0
        for those strings). Instead, let the internal logic of my_getopt
        (in particular get_bool_argument()) set a boolean opt_autocommit
        properly, and use that to set global_system_variables.option_bits.

    added:
      mysql-test/suite/sys_vars/r/autocommit_func4.result
      mysql-test/suite/sys_vars/r/autocommit_func5.result
      mysql-test/suite/sys_vars/t/autocommit_func4-master.opt
      mysql-test/suite/sys_vars/t/autocommit_func4.test
      mysql-test/suite/sys_vars/t/autocommit_func5-master.opt
      mysql-test/suite/sys_vars/t/autocommit_func5.test
    modified:
      sql/mysqld.cc
      sql/mysqld.h
=== added file 'mysql-test/suite/sys_vars/r/autocommit_func4.result'
--- a/mysql-test/suite/sys_vars/r/autocommit_func4.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/autocommit_func4.result	2011-01-11 22:00:10 +0000
@@ -0,0 +1,46 @@
+CREATE TABLE t1
+(
+id INT NOT NULL auto_increment,
+PRIMARY KEY (id),
+name varchar(30)
+) ENGINE = INNODB;
+SELECT @@global.autocommit;
+@@global.autocommit
+1
+SELECT @@autocommit;
+@@autocommit
+1
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+set @@global.autocommit = 1-@@global.autocommit;
+set @@autocommit = 1-@@autocommit;
+SELECT @@global.autocommit;
+@@global.autocommit
+0
+SELECT @@autocommit;
+@@autocommit
+0
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+3	Record_1
+4	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+DROP TABLE t1;
+set @@global.autocommit = 1-@@global.autocommit;

=== added file 'mysql-test/suite/sys_vars/r/autocommit_func5.result'
--- a/mysql-test/suite/sys_vars/r/autocommit_func5.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/autocommit_func5.result	2011-01-11 22:00:10 +0000
@@ -0,0 +1,42 @@
+CREATE TABLE t1
+(
+id INT NOT NULL auto_increment,
+PRIMARY KEY (id),
+name varchar(30)
+) ENGINE = INNODB;
+SELECT @@global.autocommit;
+@@global.autocommit
+0
+SELECT @@autocommit;
+@@autocommit
+0
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+1	Record_1
+2	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+set @@global.autocommit = 1-@@global.autocommit;
+set @@autocommit = 1-@@autocommit;
+SELECT @@global.autocommit;
+@@global.autocommit
+1
+SELECT @@autocommit;
+@@autocommit
+1
+INSERT into t1(name) values('Record_1');
+INSERT into t1(name) values('Record_2');
+SELECT * from t1;
+id	name
+3	Record_1
+4	Record_2
+ROLLBACK;
+SELECT * from t1;
+id	name
+3	Record_1
+4	Record_2
+DROP TABLE t1;
+set @@global.autocommit = 1-@@global.autocommit;

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func4-master.opt'
--- a/mysql-test/suite/sys_vars/t/autocommit_func4-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func4-master.opt	2011-01-11 22:00:10 +0000
@@ -0,0 +1 @@
+--autocommit=on

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func4.test'
--- a/mysql-test/suite/sys_vars/t/autocommit_func4.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func4.test	2011-01-11 22:00:10 +0000
@@ -0,0 +1 @@
+--source suite/sys_vars/inc/autocommit_func2.inc

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func5-master.opt'
--- a/mysql-test/suite/sys_vars/t/autocommit_func5-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func5-master.opt	2011-01-11 22:00:10 +0000
@@ -0,0 +1 @@
+--autocommit=off

=== added file 'mysql-test/suite/sys_vars/t/autocommit_func5.test'
--- a/mysql-test/suite/sys_vars/t/autocommit_func5.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/autocommit_func5.test	2011-01-11 22:00:10 +0000
@@ -0,0 +1 @@
+--source suite/sys_vars/inc/autocommit_func2.inc

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-12-29 00:26:31 +0000
+++ b/sql/mysqld.cc	2011-01-11 22:00:10 +0000
@@ -283,6 +283,7 @@ const char *first_keyword= "first", *bin
 const char *my_localhost= "localhost", *delayed_user= "DELAYED";
 
 bool opt_large_files= sizeof(my_off_t) > 4;
+static my_bool opt_autocommit;
 
 /*
   Used with --help for detailed option
@@ -5655,8 +5656,9 @@ struct my_option my_long_options[]=
     Because Sys_var_bit does not support command-line options, we need to
     explicitely add one for --autocommit
   */
-  {"autocommit", OPT_AUTOCOMMIT, "Set default value for autocommit (0 or 1)",
-   NULL, NULL, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, NULL},
+  {"autocommit", 0, "Set default value for autocommit (0 or 1)",
+   &opt_autocommit, &opt_autocommit, 0,
+   GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, NULL},
   {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to.",
    &my_bind_addr_str, &my_bind_addr_str, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -7111,13 +7113,6 @@ mysqld_get_one_option(int optid,
     if (argument == NULL) /* no argument */
       log_error_file_ptr= const_cast<char*>("");
     break;
-  case OPT_AUTOCOMMIT:
-    const ulonglong turn_bit_on= (argument && (atoi(argument) == 0)) ?
-      OPTION_NOT_AUTOCOMMIT : OPTION_AUTOCOMMIT;
-    global_system_variables.option_bits=
-      (global_system_variables.option_bits &
-       ~(OPTION_NOT_AUTOCOMMIT | OPTION_AUTOCOMMIT)) | turn_bit_on;
-    break;
   }
   return 0;
 }
@@ -7268,10 +7263,12 @@ static int get_options(int *argc_ptr, ch
   else
     global_system_variables.option_bits&= ~OPTION_BIG_SELECTS;
 
-  if (global_system_variables.option_bits & OPTION_AUTOCOMMIT)
-    global_system_variables.option_bits&= ~OPTION_NOT_AUTOCOMMIT;
-  else
-    global_system_variables.option_bits|= OPTION_NOT_AUTOCOMMIT;
+  // Synchronize @@global.autocommit on --autocommit
+  const ulonglong turn_bit_on= opt_autocommit ?
+    OPTION_AUTOCOMMIT : OPTION_NOT_AUTOCOMMIT;
+  global_system_variables.option_bits=
+    (global_system_variables.option_bits &
+     ~(OPTION_NOT_AUTOCOMMIT | OPTION_AUTOCOMMIT)) | turn_bit_on;
 
   global_system_variables.sql_mode=
     expand_sql_mode(global_system_variables.sql_mode);

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2010-12-17 11:11:34 +0000
+++ b/sql/mysqld.h	2011-01-11 22:00:10 +0000
@@ -394,8 +394,7 @@ enum options_mysqld
   OPT_UPDATE_LOG,
   OPT_WANT_CORE,
   OPT_ENGINE_CONDITION_PUSHDOWN,
-  OPT_LOG_ERROR,
-  OPT_AUTOCOMMIT
+  OPT_LOG_ERROR
 };
 
 


Attachment: [text/bzr-bundle] bzr/guilhem@mysql.com-20110111220010-qury47hqbe8k8xma.bundle
Thread
bzr commit into mysql-5.5 branch (guilhem:3237) Bug#59432Guilhem Bichot11 Jan