List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:November 3 2005 1:38am
Subject:bk commit into 5.0 tree (jimw:1.1955) BUG#7955
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1955 05/11/02 16:38:23 jimw@stripped +6 -0
  Fix handling of "SET TRANSACTION ISOLATION LEVEL ...". (Bug #7955)

  sql/sql_yacc.yy
    1.439 05/11/02 16:38:19 jimw@stripped +1 -2
    Make sure that lex->option_type always gets set in 'SET TRANSACTION ...'

  sql/share/errmsg.txt
    1.52 05/11/02 16:38:19 jimw@stripped +2 -0
    Add new error message

  sql/set_var.h
    1.72 05/11/02 16:38:18 jimw@stripped +15 -3
    Support check function for sys_var_thd_enum

  sql/set_var.cc
    1.143 05/11/02 16:38:18 jimw@stripped +17 -2
    Refuse attempts to change tx_isolation while a transaction is in progress.

  mysql-test/t/bdb.test
    1.48 05/11/02 16:38:18 jimw@stripped +21 -0
    Add new test

  mysql-test/r/bdb.result
    1.45 05/11/02 16:38:18 jimw@stripped +18 -0
    Add results

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-7955

--- 1.438/sql/sql_yacc.yy	2005-10-28 03:11:24 -07:00
+++ 1.439/sql/sql_yacc.yy	2005-11-02 16:38:19 -08:00
@@ -8002,8 +8002,7 @@
         | 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,

--- 1.51/sql/share/errmsg.txt	2005-10-27 14:18:11 -07:00
+++ 1.52/sql/share/errmsg.txt	2005-11-02 16:38:19 -08:00
@@ -5421,3 +5421,5 @@
 	eng "Cannot add or update a child row: a foreign key constraint fails (%.192s)"
 ER_SP_BAD_VAR_SHADOW 42000
 	eng "Variable '%-.64s' must be quoted with `...`, or renamed"
+ER_CANT_CHANGE_TX_ISOLATION 25001
+	eng "Transaction isolation level can't be changed while a transaction is in progress"

--- 1.142/sql/set_var.cc	2005-09-21 08:42:26 -07:00
+++ 1.143/sql/set_var.cc	2005-11-02 16:38:18 -08:00
@@ -99,6 +99,7 @@
 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);
@@ -386,7 +387,8 @@
 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",
@@ -1164,10 +1166,23 @@
 
 
 /*
+  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)

--- 1.71/sql/set_var.h	2005-09-13 08:16:05 -07:00
+++ 1.72/sql/set_var.h	2005-11-02 16:38:18 -08:00
@@ -325,19 +325,31 @@
 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);

--- 1.44/mysql-test/r/bdb.result	2005-09-29 20:05:59 -07:00
+++ 1.45/mysql-test/r/bdb.result	2005-11-02 16:38:18 -08:00
@@ -1895,3 +1895,21 @@
 ) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
 drop table t1;
 set storage_engine=MyISAM;
+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;

--- 1.47/mysql-test/t/bdb.test	2005-08-23 08:08:01 -07:00
+++ 1.48/mysql-test/t/bdb.test	2005-11-02 16:38:18 -08:00
@@ -973,3 +973,24 @@
 
 # End varchar test
 eval set storage_engine=$default;
+
+#
+# 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;
+
+# End of 5.0 tests
Thread
bk commit into 5.0 tree (jimw:1.1955) BUG#7955Jim Winstead3 Nov