summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2014-02-05 21:36:16 +0200
committerMichael Widenius <monty@askmonty.org>2014-02-05 21:36:16 +0200
commit1695fc45326434806ea747dd63fee4481e545493 (patch)
tree2150b3050b8a3afdf8c8528ff8d7da0ead136b85 /sql/sql_table.cc
parent0557de84f1eda43e8ba59910ea898253555db13d (diff)
downloadmariadb-git-1695fc45326434806ea747dd63fee4481e545493.tar.gz
MDEV-5602: CREATE OR REPLACE obtains stricter locks than the connection had before
mysql-test/r/create_or_replace.result: Added test case mysql-test/t/create_or_replace.test: Added test case sql/sql_base.cc: Downgrade locks in LOCK TABLES + CREATE TABLE OR REPLACE sql/sql_table.cc: Downgrade locks in LOCK TABLES + CREATE TABLE OR REPLACE
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc26
1 files changed, 17 insertions, 9 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 67d6795ecce..3ba363b91cb 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4882,6 +4882,11 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables);
if (thd->locked_tables_list.reopen_tables(thd))
thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0);
+ else
+ {
+ TABLE *table= pos_in_locked_tables->table;
+ table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE);
+ }
}
err:
@@ -5195,17 +5200,20 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
don't reopen the table when doing statment logging below.
*/
table->table= pos_in_locked_tables->table;
+ table->table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE);
}
}
-
- /*
- Ensure that we have an exclusive lock on target table if we are creating
- non-temporary table.
- */
- DBUG_ASSERT((create_info->tmp_table()) ||
- thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db,
- table->table_name,
- MDL_EXCLUSIVE));
+ else
+ {
+ /*
+ Ensure that we have an exclusive lock on target table if we are creating
+ non-temporary table.
+ */
+ DBUG_ASSERT((create_info->tmp_table()) ||
+ thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db,
+ table->table_name,
+ MDL_EXCLUSIVE));
+ }
DEBUG_SYNC(thd, "create_table_like_before_binlog");