Backport of revno: 2617.68.9
Bug #43272 HANDLER SQL command does not work under LOCK TABLES HANDLER commands are now explicitly disallowed in LOCK TABLES mode. Before, HANDLER OPEN gave the misleading error message: "Table x was not locked with LOCK TABLES". This patch changes HANDLER OPEN/READ/CLOSE to give ER_LOCK_OR_ACTIVE_TRANSACTION "Can't execute the given command because you have active locked tables or an active transaction" in LOCK TABLES mode. Test case added to lock.test.
This commit is contained in:
parent
f28f985922
commit
9e1cb3fe1b
@ -319,6 +319,21 @@ alter table t1 add column j int;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
#
|
||||
# Bug #43272 HANDLER SQL command does not work under LOCK TABLES
|
||||
#
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (a INT);
|
||||
LOCK TABLE t1 WRITE;
|
||||
# HANDLER commands are not allowed in LOCK TABLES mode
|
||||
HANDLER t1 OPEN;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
HANDLER t1 READ FIRST;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
HANDLER t1 CLOSE;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
UNLOCK TABLES;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#45066 FLUSH TABLES WITH READ LOCK deadlocks against
|
||||
# LOCK TABLE
|
||||
#
|
||||
|
@ -385,6 +385,30 @@ alter table t1 add column j int;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug #43272 HANDLER SQL command does not work under LOCK TABLES
|
||||
--echo #
|
||||
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t1;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
LOCK TABLE t1 WRITE;
|
||||
|
||||
--echo # HANDLER commands are not allowed in LOCK TABLES mode
|
||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||
HANDLER t1 OPEN;
|
||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||
HANDLER t1 READ FIRST;
|
||||
--error ER_LOCK_OR_ACTIVE_TRANSACTION
|
||||
HANDLER t1 CLOSE;
|
||||
|
||||
UNLOCK TABLES;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug#45066 FLUSH TABLES WITH READ LOCK deadlocks against
|
||||
--echo # LOCK TABLE
|
||||
|
@ -201,6 +201,11 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
|
||||
tables->db, tables->table_name, tables->alias,
|
||||
(int) reopen));
|
||||
|
||||
if (thd->locked_tables_mode)
|
||||
{
|
||||
my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (tables->schema_table)
|
||||
{
|
||||
my_error(ER_WRONG_USAGE, MYF(0), "HANDLER OPEN",
|
||||
@ -386,6 +391,11 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables)
|
||||
DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
|
||||
tables->db, tables->table_name, tables->alias));
|
||||
|
||||
if (thd->locked_tables_mode)
|
||||
{
|
||||
my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if ((hash_tables= (TABLE_LIST*) my_hash_search(&thd->handler_tables_hash,
|
||||
(uchar*) tables->alias,
|
||||
strlen(tables->alias) + 1)))
|
||||
@ -448,6 +458,12 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
|
||||
DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
|
||||
tables->db, tables->table_name, tables->alias));
|
||||
|
||||
if (thd->locked_tables_mode)
|
||||
{
|
||||
my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
thd->lex->select_lex.context.resolve_in_table_list_only(tables);
|
||||
list.push_front(new Item_field(&thd->lex->select_lex.context,
|
||||
NULL, NULL, "*"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user