List:Commits« Previous MessageNext Message »
From:marko.makela Date:October 4 2010 10:38am
Subject:bzr push into mysql-5.5-innodb branch (marko.makela:3227 to 3228) Bug#56716
View as plain text  
 3228 Marko Mäkelä	2010-10-04
      Merge Bug#56716 from 5.1

    added:
      mysql-test/suite/innodb/r/innodb_bug56716.result
      mysql-test/suite/innodb/t/innodb_bug56716.test
    modified:
      storage/innobase/row/row0sel.c
 3227 Vasil Dimov	2010-10-01
      Fix a potential bug when using __sync_lock_test_and_set()
      
      This is a manual merge from mysql-5.1-innodb of:
      
        revision-id: vasil.dimov@stripped9f9ytbytr3eqw9h
        committer: Vasil Dimov <vasil.dimov@stripped>
        timestamp: Thu 2010-09-30 13:26:18 +0300
        message:
          Fix a potential bug when using __sync_lock_test_and_set()
      
          TYPE __sync_lock_test_and_set (TYPE *ptr, TYPE value, ...)
      
          it is not documented what happens if the two arguments are of different
          type like it was before: the first one was lock_word_t (byte) and the
          second one was 1 or 0 (int).
      
          Approved by:	Marko (via IRC)

    modified:
      storage/innobase/include/os0sync.h
=== added file 'mysql-test/suite/innodb/r/innodb_bug56716.result'
--- a/mysql-test/suite/innodb/r/innodb_bug56716.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug56716.result	revid:marko.makela@stripped
@@ -0,0 +1,4 @@
+CREATE TABLE bug56716 (a INT PRIMARY KEY,b INT,c INT,INDEX(b)) ENGINE=InnoDB;
+SELECT * FROM bug56716 WHERE b<=42 ORDER BY b DESC FOR UPDATE;
+a	b	c
+DROP TABLE bug56716;

=== added file 'mysql-test/suite/innodb/t/innodb_bug56716.test'
--- a/mysql-test/suite/innodb/t/innodb_bug56716.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug56716.test	revid:marko.makela@stripped
@@ -0,0 +1,10 @@
+#
+# Bug #56716 InnoDB locks a record gap without locking the table
+#
+-- source include/have_innodb.inc
+
+CREATE TABLE bug56716 (a INT PRIMARY KEY,b INT,c INT,INDEX(b)) ENGINE=InnoDB;
+
+SELECT * FROM bug56716 WHERE b<=42 ORDER BY b DESC FOR UPDATE;
+
+DROP TABLE bug56716;

=== modified file 'storage/innobase/row/row0sel.c'
--- a/storage/innobase/row/row0sel.c	revid:vasil.dimov@oracle.com-20101001115100-94b30mpyzrpxpa1z
+++ b/storage/innobase/row/row0sel.c	revid:marko.makela@stripped03805-c1wux0qfs684x6c8
@@ -3711,6 +3711,42 @@ release_search_latch_if_needed:
 
 	clust_index = dict_table_get_first_index(index->table);
 
+	/* Do some start-of-statement preparations */
+
+	if (!prebuilt->sql_stat_start) {
+		/* No need to set an intention lock or assign a read view */
+
+		if (trx->read_view == NULL
+		    && prebuilt->select_lock_type == LOCK_NONE) {
+
+			fputs("InnoDB: Error: MySQL is trying to"
+			      " perform a consistent read\n"
+			      "InnoDB: but the read view is not assigned!\n",
+			      stderr);
+			trx_print(stderr, trx, 600);
+			fputc('\n', stderr);
+			ut_error;
+		}
+	} else if (prebuilt->select_lock_type == LOCK_NONE) {
+		/* This is a consistent read */
+		/* Assign a read view for the query */
+
+		trx_assign_read_view(trx);
+		prebuilt->sql_stat_start = FALSE;
+	} else {
+		err = lock_table(0, index->table,
+				 prebuilt->select_lock_type == LOCK_S
+				 ? LOCK_IS : LOCK_IX, thr);
+
+		if (err != DB_SUCCESS) {
+
+			goto lock_wait_or_error;
+		}
+		prebuilt->sql_stat_start = FALSE;
+	}
+
+	/* Open or restore index cursor position */
+
 	if (UNIV_LIKELY(direction != 0)) {
 		ibool	need_to_process = sel_restore_position_for_mysql(
 			&same_user_rec, BTR_SEARCH_LEAF,
@@ -3786,42 +3822,6 @@ release_search_latch_if_needed:
 		}
 	}
 
-	if (!prebuilt->sql_stat_start) {
-		/* No need to set an intention lock or assign a read view */
-
-		if (trx->read_view == NULL
-		    && prebuilt->select_lock_type == LOCK_NONE) {
-
-			fputs("InnoDB: Error: MySQL is trying to"
-			      " perform a consistent read\n"
-			      "InnoDB: but the read view is not assigned!\n",
-			      stderr);
-			trx_print(stderr, trx, 600);
-			fputc('\n', stderr);
-			ut_a(0);
-		}
-	} else if (prebuilt->select_lock_type == LOCK_NONE) {
-		/* This is a consistent read */
-		/* Assign a read view for the query */
-
-		trx_assign_read_view(trx);
-		prebuilt->sql_stat_start = FALSE;
-	} else {
-		ulint	lock_mode;
-		if (prebuilt->select_lock_type == LOCK_S) {
-			lock_mode = LOCK_IS;
-		} else {
-			lock_mode = LOCK_IX;
-		}
-		err = lock_table(0, index->table, lock_mode, thr);
-
-		if (err != DB_SUCCESS) {
-
-			goto lock_wait_or_error;
-		}
-		prebuilt->sql_stat_start = FALSE;
-	}
-
 rec_loop:
 	/*-------------------------------------------------------------*/
 	/* PHASE 4: Look for matching records in a loop */

Attachment: [text/bzr-bundle] bzr/marko.makela@oracle.com-20101004103805-c1wux0qfs684x6c8.bundle
Thread
bzr push into mysql-5.5-innodb branch (marko.makela:3227 to 3228) Bug#56716marko.makela4 Oct