Hi Guilhem,
Thanks for making an alternative patch for implementing this. I prefer
this patch over the first you committed.
The patch looks good and I have only one request:
* Consider updating the "help text" for autocommit from "autocommit"
to something more descriptive, e.g. "Set default value for auto commit
(0 or 1)".
OK to push.
Olav
On 05/11/2010 10:24, Guilhem Bichot wrote:
> #At file:///home/mysql_src/bzrrepos_new/5.5-bugteam/ based on
> revid:georgi.kodinov@stripped
>
> 3115 Guilhem Bichot 2010-11-05
> Fix for BUG#57316 "It is not clear how to disable autocommit"
> add boolean command-line option --autocommit.
> @ mysql-test/mysql-test-run.pl
> do in --gdb like in --ddd: to let the developer debug the startup
> phase (like command-line options parsing), don't "run".
> It's the third time I do this change, it was previously lost
> by merges, port of 6.0 to next-mr...
> @ mysql-test/r/mysqld--help-notwin.result
> new command-line option
> @ mysql-test/r/mysqld--help-win.result
> a Linux user's best guess at what the Windows result should be
> @ mysql-test/suite/sys_vars/inc/autocommit_func2.inc
> new test
> @ mysql-test/suite/sys_vars/t/autocommit_func2-master.opt
> test new option
> @ mysql-test/suite/sys_vars/t/autocommit_func3-master.opt
> test new option
> @ sql/mysqld.cc
> new --autocommit
> @ sql/mysqld.h
> new --autocommit
> @ sql/sql_partition.cc
> What matters to this partitioning quote is to have
> the OPTION_QUOTE_SHOW_CREATE flag down, it's all
> that append_identifier() uses. So we make it explicit.
>
> added:
> mysql-test/suite/sys_vars/inc/autocommit_func2.inc
> mysql-test/suite/sys_vars/r/autocommit_func2.result
> mysql-test/suite/sys_vars/r/autocommit_func3.result
> mysql-test/suite/sys_vars/t/autocommit_func2-master.opt
> mysql-test/suite/sys_vars/t/autocommit_func2.test
> mysql-test/suite/sys_vars/t/autocommit_func3-master.opt
> mysql-test/suite/sys_vars/t/autocommit_func3.test
> modified:
> mysql-test/mysql-test-run.pl
> mysql-test/r/mysqld--help-notwin.result
> mysql-test/r/mysqld--help-win.result
> sql/mysqld.cc
> sql/mysqld.h
> sql/sql_partition.cc
> === modified file 'mysql-test/mysql-test-run.pl'
> --- a/mysql-test/mysql-test-run.pl 2010-10-26 06:31:22 +0000
> +++ b/mysql-test/mysql-test-run.pl 2010-11-05 09:24:40 +0000
> @@ -5317,8 +5317,7 @@ sub gdb_arguments {
> "break mysql_parse\n" .
> "commands 1\n" .
> "disable 1\n" .
> - "end\n" .
> - "run");
> + "end\n");
> }
>
> if ( $opt_manual_gdb )
>
> === modified file 'mysql-test/r/mysqld--help-notwin.result'
> --- a/mysql-test/r/mysqld--help-notwin.result 2010-09-30 13:52:39 +0000
> +++ b/mysql-test/r/mysqld--help-notwin.result 2010-11-05 09:24:40 +0000
> @@ -19,6 +19,7 @@ The following options may be given as th
> --auto-increment-offset[=#]
> Offset added to Auto-increment columns. Used when
> auto-increment-increment != 1
> + --autocommit autocommit
> --automatic-sp-privileges
> Creating and dropping stored procedures alters ACLs
> (Defaults to on; use --skip-automatic-sp-privileges to disable.)
>
> === modified file 'mysql-test/r/mysqld--help-win.result'
> --- a/mysql-test/r/mysqld--help-win.result 2010-10-05 12:26:49 +0000
> +++ b/mysql-test/r/mysqld--help-win.result 2010-11-05 09:24:40 +0000
> @@ -19,6 +19,7 @@ The following options may be given as th
> --auto-increment-offset[=#]
> Offset added to Auto-increment columns. Used when
> auto-increment-increment != 1
> + --autocommit autocommit
> --automatic-sp-privileges
> Creating and dropping stored procedures alters ACLs
> (Defaults to on; use --skip-automatic-sp-privileges to disable.)
>
> === added file 'mysql-test/suite/sys_vars/inc/autocommit_func2.inc'
> --- a/mysql-test/suite/sys_vars/inc/autocommit_func2.inc 1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/sys_vars/inc/autocommit_func2.inc 2010-11-05 09:24:40 +0000
> @@ -0,0 +1,29 @@
> +--source include/have_innodb.inc
> +
> +CREATE TABLE t1
> +(
> +id INT NOT NULL auto_increment,
> +PRIMARY KEY (id),
> +name varchar(30)
> +) ENGINE = INNODB;
> +
> +SELECT @@global.autocommit;
> +SELECT @@autocommit;
> +INSERT into t1(name) values('Record_1');
> +INSERT into t1(name) values('Record_2');
> +SELECT * from t1;
> +ROLLBACK;
> +SELECT * from t1;
> +
> +set @@global.autocommit = 1-@@global.autocommit;
> +set @@autocommit = 1-@@autocommit;
> +SELECT @@global.autocommit;
> +SELECT @@autocommit;
> +INSERT into t1(name) values('Record_1');
> +INSERT into t1(name) values('Record_2');
> +SELECT * from t1;
> +ROLLBACK;
> +SELECT * from t1;
> +
> +DROP TABLE t1;
> +set @@global.autocommit = 1-@@global.autocommit;
>
> === added file 'mysql-test/suite/sys_vars/r/autocommit_func2.result'
> --- a/mysql-test/suite/sys_vars/r/autocommit_func2.result 1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/sys_vars/r/autocommit_func2.result 2010-11-05 09:24:40 +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_func3.result'
> --- a/mysql-test/suite/sys_vars/r/autocommit_func3.result 1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/sys_vars/r/autocommit_func3.result 2010-11-05 09:24:40 +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_func2-master.opt'
> --- a/mysql-test/suite/sys_vars/t/autocommit_func2-master.opt 1970-01-01 00:00:00
> +0000
> +++ b/mysql-test/suite/sys_vars/t/autocommit_func2-master.opt 2010-11-05 09:24:40
> +0000
> @@ -0,0 +1 @@
> +--autocommit=1
>
> === added file 'mysql-test/suite/sys_vars/t/autocommit_func2.test'
> --- a/mysql-test/suite/sys_vars/t/autocommit_func2.test 1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/sys_vars/t/autocommit_func2.test 2010-11-05 09:24:40 +0000
> @@ -0,0 +1 @@
> +--source suite/sys_vars/inc/autocommit_func2.inc
>
> === added file 'mysql-test/suite/sys_vars/t/autocommit_func3-master.opt'
> --- a/mysql-test/suite/sys_vars/t/autocommit_func3-master.opt 1970-01-01 00:00:00
> +0000
> +++ b/mysql-test/suite/sys_vars/t/autocommit_func3-master.opt 2010-11-05 09:24:40
> +0000
> @@ -0,0 +1 @@
> +--autocommit=0
>
> === added file 'mysql-test/suite/sys_vars/t/autocommit_func3.test'
> --- a/mysql-test/suite/sys_vars/t/autocommit_func3.test 1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/sys_vars/t/autocommit_func3.test 2010-11-05 09:24:40 +0000
> @@ -0,0 +1 @@
> +--source suite/sys_vars/inc/autocommit_func2.inc
>
> === modified file 'sql/mysqld.cc'
> --- a/sql/mysqld.cc 2010-10-08 14:52:39 +0000
> +++ b/sql/mysqld.cc 2010-11-05 09:24:40 +0000
> @@ -5662,6 +5662,12 @@ struct my_option my_long_options[]=
> {"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax. This mode "
> "will also set transaction isolation level 'serializable'.", 0, 0, 0,
> GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
> + /*
> + Because Sys_var_bit does not support command-line options, we need to
> + explicitely add one for --autocommit
> + */
> + {"autocommit", OPT_AUTOCOMMIT, "autocommit", NULL, NULL,
> + 0, GET_BOOL, OPT_ARG, 0, 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},
> @@ -7114,6 +7120,13 @@ 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;
> }
>
> === modified file 'sql/mysqld.h'
> --- a/sql/mysqld.h 2010-08-30 14:07:40 +0000
> +++ b/sql/mysqld.h 2010-11-05 09:24:40 +0000
> @@ -391,7 +391,8 @@ enum options_mysqld
> OPT_UPDATE_LOG,
> OPT_WANT_CORE,
> OPT_ENGINE_CONDITION_PUSHDOWN,
> - OPT_LOG_ERROR
> + OPT_LOG_ERROR,
> + OPT_AUTOCOMMIT
> };
>
>
>
> === modified file 'sql/sql_partition.cc'
> --- a/sql/sql_partition.cc 2010-10-27 07:32:26 +0000
> +++ b/sql/sql_partition.cc 2010-11-05 09:24:40 +0000
> @@ -1997,7 +1997,7 @@ static int add_part_field_list(File fptr
> String field_string("", 0, system_charset_info);
> THD *thd= current_thd;
> ulonglong save_options= thd->variables.option_bits;
> - thd->variables.option_bits= 0;
> + thd->variables.option_bits&= ~OPTION_QUOTE_SHOW_CREATE;
> append_identifier(thd,&field_string, field_str,
> strlen(field_str));
> thd->variables.option_bits= save_options;
> @@ -2016,8 +2016,7 @@ static int add_name_string(File fptr, co
> String name_string("", 0, system_charset_info);
> THD *thd= current_thd;
> ulonglong save_options= thd->variables.option_bits;
> -
> - thd->variables.option_bits= 0;
> + thd->variables.option_bits&= ~OPTION_QUOTE_SHOW_CREATE;
> append_identifier(thd,&name_string, name,
> strlen(name));
> thd->variables.option_bits= save_options;
>
>
>
>
>
>