diff options
author | Jon Olav Hauglid <jon.hauglid@sun.com> | 2009-12-08 15:56:06 +0100 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@sun.com> | 2009-12-08 15:56:06 +0100 |
commit | 19ff2445b156a11cbd76e7c741ed05e4eb33dc62 (patch) | |
tree | dff4eda1ae5790913638b8b5813d2e84203f4127 /sql/sql_handler.cc | |
parent | c0b78cc47a2da2710cdf580ddbb3b31f5f691a23 (diff) | |
download | mariadb-git-19ff2445b156a11cbd76e7c741ed05e4eb33dc62.tar.gz |
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.
Diffstat (limited to 'sql/sql_handler.cc')
-rw-r--r-- | sql/sql_handler.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 1b7e45cec5d..5bdf8611f5e 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -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, "*")); |