diff options
author | unknown <jimw@mysql.com> | 2006-02-17 11:03:34 -0800 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2006-02-17 11:03:34 -0800 |
commit | bdf18f433188ccccec916f5c23abfbe7f2dd0bb1 (patch) | |
tree | 5823f1009fef763217e28e43e56976f3d23ab876 | |
parent | 1b587ced223f6f4d2a7d683c3062d622019c9fb8 (diff) | |
parent | d68354d56703a236e20ea4af1d3a835aa39f1941 (diff) | |
download | mariadb-git-bdf18f433188ccccec916f5c23abfbe7f2dd0bb1.tar.gz |
Merge mysql.com:/home/jimw/my/mysql-5.0-7955
into mysql.com:/home/jimw/my/mysql-5.1-clean
sql/set_var.cc:
Auto merged
sql/set_var.h:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/bdb.result:
Resolve conflict
mysql-test/t/bdb.test:
Resolve conflict
sql/share/errmsg.txt:
Resolve conflict
-rw-r--r-- | mysql-test/r/bdb.result | 19 | ||||
-rw-r--r-- | mysql-test/t/bdb.test | 21 | ||||
-rw-r--r-- | sql/set_var.cc | 19 | ||||
-rw-r--r-- | sql/set_var.h | 18 | ||||
-rw-r--r-- | sql/share/errmsg.txt | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 3 |
6 files changed, 75 insertions, 7 deletions
diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index ba6ed396f93..bab945ccf50 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1963,3 +1963,22 @@ commit; alter table t1 add primary key(a); drop table t1; End of 5.0 tests +create table t1 (a int) engine=bdb; +set session transaction isolation level repeatable read; +set transaction isolation level serializable; +begin; +select @@tx_isolation; +@@tx_isolation +SERIALIZABLE +insert into t1 values (1); +set transaction isolation level read committed; +ERROR 25001: Transaction isolation level can't be changed while a transaction is in progress +rollback; +begin; +select @@tx_isolation; +@@tx_isolation +REPEATABLE-READ +insert into t1 values (1); +rollback; +drop table t1; +End of 5.1 tests diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test index 60e0129e58a..dbf5559943a 100644 --- a/mysql-test/t/bdb.test +++ b/mysql-test/t/bdb.test @@ -1046,3 +1046,24 @@ alter table t1 add primary key(a); drop table t1; --echo End of 5.0 tests + +# +# Bug #7955: SET TRANSACTION ISIOLATION LEVEL lives longer than next +# transaciton +# +create table t1 (a int) engine=bdb; +set session transaction isolation level repeatable read; +set transaction isolation level serializable; +begin; +select @@tx_isolation; +insert into t1 values (1); +--error ER_CANT_CHANGE_TX_ISOLATION +set transaction isolation level read committed; +rollback; +begin; +select @@tx_isolation; +insert into t1 values (1); +rollback; +drop table t1; + +--echo End of 5.1 tests diff --git a/sql/set_var.cc b/sql/set_var.cc index c9feea49618..6dcff0ee738 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -142,6 +142,7 @@ static bool set_log_update(THD *thd, set_var *var); static int check_pseudo_thread_id(THD *thd, set_var *var); static bool set_log_bin(THD *thd, set_var *var); static void fix_low_priority_updates(THD *thd, enum_var_type type); +static int check_tx_isolation(THD *thd, set_var *var); static void fix_tx_isolation(THD *thd, enum_var_type type); static int check_completion_type(THD *thd, set_var *var); static void fix_completion_type(THD *thd, enum_var_type type); @@ -449,7 +450,8 @@ sys_var_long_ptr sys_thread_cache_size("thread_cache_size", sys_var_thd_enum sys_tx_isolation("tx_isolation", &SV::tx_isolation, &tx_isolation_typelib, - fix_tx_isolation); + fix_tx_isolation, + check_tx_isolation); sys_var_thd_ulong sys_tmp_table_size("tmp_table_size", &SV::tmp_table_size); sys_var_bool_ptr sys_timed_mutexes("timed_mutexes", @@ -1127,10 +1129,23 @@ static void fix_max_join_size(THD *thd, enum_var_type type) /* + Can't change the 'next' tx_isolation while we are already in + a transaction +*/ +static int check_tx_isolation(THD *thd, set_var *var) +{ + if (var->type == OPT_DEFAULT && (thd->server_status & SERVER_STATUS_IN_TRANS)) + { + my_error(ER_CANT_CHANGE_TX_ISOLATION, MYF(0)); + return 1; + } + return 0; +} + +/* If one doesn't use the SESSION modifier, the isolation level is only active for the next command */ - static void fix_tx_isolation(THD *thd, enum_var_type type) { if (type == OPT_SESSION) diff --git a/sql/set_var.h b/sql/set_var.h index 75c36176f91..0961f6d4325 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -334,19 +334,31 @@ class sys_var_thd_enum :public sys_var_thd protected: ulong SV::*offset; TYPELIB *enum_names; + sys_check_func check_func; public: sys_var_thd_enum(const char *name_arg, ulong SV::*offset_arg, TYPELIB *typelib) - :sys_var_thd(name_arg), offset(offset_arg), enum_names(typelib) + :sys_var_thd(name_arg), offset(offset_arg), enum_names(typelib), + check_func(0) {} sys_var_thd_enum(const char *name_arg, ulong SV::*offset_arg, TYPELIB *typelib, sys_after_update_func func) - :sys_var_thd(name_arg,func), offset(offset_arg), enum_names(typelib) + :sys_var_thd(name_arg,func), offset(offset_arg), enum_names(typelib), + check_func(0) + {} + sys_var_thd_enum(const char *name_arg, ulong SV::*offset_arg, + TYPELIB *typelib, sys_after_update_func func, + sys_check_func check) + :sys_var_thd(name_arg,func), offset(offset_arg), enum_names(typelib), + check_func(check) {} bool check(THD *thd, set_var *var) { - return check_enum(thd, var, enum_names); + int ret= 0; + if (check_func) + ret= (*check_func)(thd, var); + return ret ? ret : check_enum(thd, var, enum_names); } bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index aa9cefd78b7..c8daae724c7 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5808,3 +5808,5 @@ ER_TABLE_NEEDS_UPGRADE eng "Table upgrade required. Please do \"REPAIR TABLE `%-.32s`\" to fix it!" ER_ILLEGAL_HA_CREATE_OPTION eng "Table storage engine '%-.64s' does not support the create option '%.64s'" +ER_CANT_CHANGE_TX_ISOLATION 25001 + eng "Transaction isolation level can't be changed while a transaction is in progress" diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2993cee0bc3..8f39bfd0f9d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -9785,8 +9785,7 @@ sys_option_value: | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types { LEX *lex=Lex; - if ($1) - lex->option_type= $1; + lex->option_type= $1; lex->var_list.push_back(new set_var(lex->option_type, find_sys_var("tx_isolation"), &null_lex_str, |