MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:September 30 2005 6:20pm
Subject:bk commit into 5.0 tree (serg:1.2033) BUG#11238
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of serg. When serg 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.2033 05/09/30 20:20:10 serg@stripped +10 -0
  Bug#11238
  "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
  Do not discard lock_type information as handler::start_stmt() may require knowledge.
  (fixed by Antony)

  sql/sql_base.cc
    1.309 05/09/30 20:19:44 serg@stripped +1 -1
    Bug#11238
    "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
    Do not discard lock_type information as handler::start_stmt() may require knowledge.
    (fixed by Antony)

  sql/handler.h
    1.155 05/09/30 20:19:44 serg@stripped +1 -1
    Bug#11238
    "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
    Do not discard lock_type information as handler::start_stmt() may require knowledge.
    (fixed by Antony)

  sql/ha_ndbcluster.h
    1.92 05/09/30 20:19:44 serg@stripped +1 -1
    Bug#11238
    "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
    Do not discard lock_type information as handler::start_stmt() may require knowledge.
    (fixed by Antony)

  sql/ha_ndbcluster.cc
    1.210 05/09/30 20:19:44 serg@stripped +1 -1
    Bug#11238
    "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
    Do not discard lock_type information as handler::start_stmt() may require knowledge.
    (fixed by Antony)

  sql/ha_innodb.h
    1.105 05/09/30 20:19:43 serg@stripped +1 -1
    Bug#11238
    "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
    Do not discard lock_type information as handler::start_stmt() may require knowledge.
    (fixed by Antony)

  sql/ha_innodb.cc
    1.266 05/09/30 20:19:43 serg@stripped +3 -2
    Bug#11238
    "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
    Do not discard lock_type information as handler::start_stmt() may require knowledge.
    (fixed by Antony)

  sql/ha_berkeley.h
    1.73 05/09/30 20:19:43 serg@stripped +1 -1
    Bug#11238
    "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
    Do not discard lock_type information as handler::start_stmt() may require knowledge.
    (fixed by Antony)

  sql/ha_berkeley.cc
    1.157 05/09/30 20:19:43 serg@stripped +1 -1
    Bug#11238
    "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
    Do not discard lock_type information as handler::start_stmt() may require knowledge.
    (fixed by Antony)

  mysql-test/t/innodb.test
    1.115 05/09/30 20:19:43 serg@stripped +44 -13
    Bug#11238
    "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
    Do not discard lock_type information as handler::start_stmt() may require knowledge.
    (fixed by Antony)

  mysql-test/r/innodb.result
    1.143 05/09/30 20:19:43 serg@stripped +37 -18
    Bug#11238
    "SELECT ... FOR UPDATE executed as consistent read inside LOCK TABLES"
    Do not discard lock_type information as handler::start_stmt() may require knowledge.
    (fixed by Antony)

# 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:	serg
# Host:	serg.mylan
# Root:	/usr/home/serg/Abk/mysql-5.0

--- 1.156/sql/ha_berkeley.cc	Mon Sep 19 21:06:18 2005
+++ 1.157/sql/ha_berkeley.cc	Fri Sep 30 20:19:43 2005
@@ -1894,7 +1894,7 @@ int ha_berkeley::external_lock(THD *thd,
   Under LOCK TABLES, each used tables will force a call to start_stmt.
 */
 
-int ha_berkeley::start_stmt(THD *thd)
+int ha_berkeley::start_stmt(THD *thd, thr_lock_type lock_type)
 {
   int error=0;
   DBUG_ENTER("ha_berkeley::start_stmt");

--- 1.72/sql/ha_berkeley.h	Fri Aug 12 12:54:35 2005
+++ 1.73/sql/ha_berkeley.h	Fri Sep 30 20:19:43 2005
@@ -124,7 +124,7 @@ class ha_berkeley: public handler
   int extra(enum ha_extra_function operation);
   int reset(void);
   int external_lock(THD *thd, int lock_type);
-  int start_stmt(THD *thd);
+  int start_stmt(THD *thd, thr_lock_type lock_type);
   void position(byte *record);
   int analyze(THD* thd,HA_CHECK_OPT* check_opt);
   int optimize(THD* thd, HA_CHECK_OPT* check_opt);

--- 1.154/sql/handler.h	Fri Sep 23 01:58:04 2005
+++ 1.155/sql/handler.h	Fri Sep 30 20:19:44 2005
@@ -647,7 +647,7 @@ public:
   virtual int reset() { return extra(HA_EXTRA_RESET); }
   virtual int external_lock(THD *thd, int lock_type) { return 0; }
   virtual void unlock_row() {}
-  virtual int start_stmt(THD *thd) {return 0;}
+  virtual int start_stmt(THD *thd, thr_lock_type lock_type) {return 0;}
   /*
     This is called to delete all rows in a table
     If the handler don't support this, then this function will

--- 1.308/sql/sql_base.cc	Fri Sep 30 09:37:50 2005
+++ 1.309/sql/sql_base.cc	Fri Sep 30 20:19:44 2005
@@ -2148,7 +2148,7 @@ static bool check_lock_and_start_stmt(TH
     my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE, MYF(0),table->alias);
     DBUG_RETURN(1);
   }
-  if ((error=table->file->start_stmt(thd)))
+  if ((error=table->file->start_stmt(thd, lock_type)))
   {
     table->file->print_error(error,MYF(0));
     DBUG_RETURN(1);

--- 1.209/sql/ha_ndbcluster.cc	Wed Sep 28 11:34:49 2005
+++ 1.210/sql/ha_ndbcluster.cc	Fri Sep 30 20:19:44 2005
@@ -3400,7 +3400,7 @@ int ha_ndbcluster::external_lock(THD *th
   startTransaction for each transaction/statement.
 */
 
-int ha_ndbcluster::start_stmt(THD *thd)
+int ha_ndbcluster::start_stmt(THD *thd, thr_lock_type lock_type)
 {
   int error=0;
   DBUG_ENTER("start_stmt");

--- 1.91/sql/ha_ndbcluster.h	Tue Sep 20 10:25:25 2005
+++ 1.92/sql/ha_ndbcluster.h	Fri Sep 30 20:19:44 2005
@@ -501,7 +501,7 @@ class ha_ndbcluster: public handler
   int extra(enum ha_extra_function operation);
   int extra_opt(enum ha_extra_function operation, ulong cache_size);
   int external_lock(THD *thd, int lock_type);
-  int start_stmt(THD *thd);
+  int start_stmt(THD *thd, thr_lock_type lock_type);
   const char * table_type() const;
   const char ** bas_ext() const;
   ulong table_flags(void) const;

--- 1.142/mysql-test/r/innodb.result	Fri Sep 30 11:08:17 2005
+++ 1.143/mysql-test/r/innodb.result	Fri Sep 30 20:19:43 2005
@@ -2616,31 +2616,50 @@ SET FOREIGN_KEY_CHECKS=1;
 INSERT INTO t2 VALUES(3);
 ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
 DROP TABLE t2;
-create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into test_checksum values (1),(2);
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2);
 set autocommit=0;
-checksum table test_checksum;
+checksum table t1;
 Table	Checksum
-test.test_checksum	1531596814
-insert into test_checksum values(3);
-checksum table test_checksum;
+test.t1	1531596814
+insert into t1 values(3);
+checksum table t1;
 Table	Checksum
-test.test_checksum	2605035534
+test.t1	2605035534
 commit;
-checksum table test_checksum;
+checksum table t1;
 Table	Checksum
-test.test_checksum	127268899
+test.t1	127268899
 commit;
-drop table test_checksum;
-create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into test_checksum values (1),(2);
+drop table t1;
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2);
 set autocommit=1;
-checksum table test_checksum;
+checksum table t1;
 Table	Checksum
-test.test_checksum	1531596814
+test.t1	1531596814
 set autocommit=1;
-insert into test_checksum values(3);
-checksum table test_checksum;
+insert into t1 values(3);
+checksum table t1;
 Table	Checksum
-test.test_checksum	127268899
-drop table test_checksum;
+test.t1	127268899
+drop table t1;
+create table t1 (col1 integer primary key, col2 integer) engine=innodb;
+insert t1 values (1,100);
+create function f1 () returns integer begin
+declare var1 int;
+select col2 into var1 from t1 where col1=1 for update;
+return var1;
+end|
+start transaction;
+select f1();
+f1()
+100
+ update t1 set col2=0 where col1=1;
+select * from t1;
+col1	col2
+1	100
+rollback;
+rollback;
+drop table t1;
+drop function f1;

--- 1.114/mysql-test/t/innodb.test	Thu Sep 29 12:50:16 2005
+++ 1.115/mysql-test/t/innodb.test	Fri Sep 30 20:19:43 2005
@@ -1571,36 +1571,67 @@ DROP TABLE t2;
 connect (a,localhost,root,,);
 connect (b,localhost,root,,);
 connection a;
-create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into test_checksum values (1),(2);
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2);
 set autocommit=0;
-checksum table test_checksum;
+checksum table t1;
 connection b;
-insert into test_checksum values(3);
+insert into t1 values(3);
 connection a;
 #
 # Here checksum should not see insert
 #
-checksum table test_checksum;
+checksum table t1;
 connection a;
 commit;
-checksum table test_checksum;
+checksum table t1;
 commit;
-drop table test_checksum;
+drop table t1;
 #
 # autocommit = 1
 #
 connection a;
-create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into test_checksum values (1),(2);
+create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
+insert into t1 values (1),(2);
 set autocommit=1;
-checksum table test_checksum;
+checksum table t1;
 connection b;
 set autocommit=1;
-insert into test_checksum values(3);
+insert into t1 values(3);
 connection a;
 #
 # Here checksum sees insert
 #
-checksum table test_checksum;
-drop table test_checksum;
+checksum table t1;
+drop table t1;
+
+#
+# BUG#11238 - in prelocking mode SELECT .. FOR UPDATE is changed to
+# non-blocking SELECT
+#
+create table t1 (col1 integer primary key, col2 integer) engine=innodb;
+insert t1 values (1,100);
+delimiter |;
+create function f1 () returns integer begin
+declare var1 int;
+select col2 into var1 from t1 where col1=1 for update;
+return var1;
+end|
+delimiter ;|
+start transaction;
+select f1();
+connection b;
+send update t1 set col2=0 where col1=1;
+connection default;
+select * from t1;
+connection a;
+rollback;
+connection b;
+reap;
+rollback;
+connection default;
+drop table t1;
+drop function f1;
+disconnect a;
+disconnect b;
+

--- 1.265/sql/ha_innodb.cc	Thu Sep 29 12:14:59 2005
+++ 1.266/sql/ha_innodb.cc	Fri Sep 30 20:19:43 2005
@@ -6000,7 +6000,8 @@ int
 ha_innobase::start_stmt(
 /*====================*/
 	              /* out: 0 or error code */
-	THD*    thd)  /* in: handle to the user thread */
+	THD*    thd,  /* in: handle to the user thread */
+        thr_lock_type lock_type)
 {
 	row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
 	trx_t*		trx;
@@ -6041,7 +6042,7 @@ ha_innobase::start_stmt(
 	} else {
 		if (trx->isolation_level != TRX_ISO_SERIALIZABLE
 		    && thd->lex->sql_command == SQLCOM_SELECT
-		    && thd->lex->lock_option == TL_READ) {
+		    && lock_type == TL_READ) {
 	
 			/* For other than temporary tables, we obtain
 			no lock for consistent read (plain SELECT). */

--- 1.104/sql/ha_innodb.h	Fri Sep 23 15:22:23 2005
+++ 1.105/sql/ha_innodb.h	Fri Sep 30 20:19:43 2005
@@ -150,7 +150,7 @@ class ha_innobase: public handler
   	int extra(enum ha_extra_function operation);
   	int external_lock(THD *thd, int lock_type);
 	int transactional_table_lock(THD *thd, int lock_type);
-	int start_stmt(THD *thd);
+        int start_stmt(THD *thd, thr_lock_type lock_type);
 
   	void position(byte *record);
   	ha_rows records_in_range(uint inx, key_range *min_key, key_range
Thread
bk commit into 5.0 tree (serg:1.2033) BUG#11238Sergei Golubchik30 Sep