mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Merge Bug#56716 from 5.1
This commit is contained in:
committed by
Vasil Dimov
parent
f6e5cf3ef4
commit
24b1a89712
4
mysql-test/suite/innodb/r/innodb_bug56716.result
Normal file
4
mysql-test/suite/innodb/r/innodb_bug56716.result
Normal file
@@ -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;
|
10
mysql-test/suite/innodb/t/innodb_bug56716.test
Normal file
10
mysql-test/suite/innodb/t/innodb_bug56716.test
Normal file
@@ -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;
|
@@ -3711,6 +3711,42 @@ release_search_latch_if_needed:
|
|||||||
|
|
||||||
clust_index = dict_table_get_first_index(index->table);
|
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)) {
|
if (UNIV_LIKELY(direction != 0)) {
|
||||||
ibool need_to_process = sel_restore_position_for_mysql(
|
ibool need_to_process = sel_restore_position_for_mysql(
|
||||||
&same_user_rec, BTR_SEARCH_LEAF,
|
&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:
|
rec_loop:
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/* PHASE 4: Look for matching records in a loop */
|
/* PHASE 4: Look for matching records in a loop */
|
||||||
|
Reference in New Issue
Block a user