diff options
author | Konstantin Osipov <kostja@sun.com> | 2009-12-01 01:13:06 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2009-12-01 01:13:06 +0300 |
commit | cf45b61a6a611415161e6176b8c8ae85a51e9349 (patch) | |
tree | dfab0cc24f138936eeae5dd70d68cbd515324a87 /sql/sql_trigger.cc | |
parent | 0dcead9f61ede536f0f4b4f2d291800f82fb5043 (diff) | |
download | mariadb-git-cf45b61a6a611415161e6176b8c8ae85a51e9349.tar.gz |
Backport of:
------------------------------------------------------------
revno: 2630.4.16
committer: Dmitry Lenev <dlenev@mysql.com>
branch nick: mysql-6.0-3726-w
timestamp: Thu 2008-05-29 09:45:02 +0400
message:
WL#3726 "DDL locking for all metadata objects".
After review changes in progress.
Tweaked some comments and did some renames to
avoid ambiguites.
sql/mysql_priv.h:
Removed name_lock_locked_table() function.
sql/sql_base.cc:
Got rid of name_lock_locked_table() function after replacing
the only call to it with its body.
Simplified open_table() code by making "action" argument
mandatory (i.e. one now should always pass non-0 pointer
in this argument).
Renamed TABLE_LIST::open_table_type to open_type to
avoid confusing it with type of table.
Adjusted comments according to review.
sql/sql_handler.cc:
Added comment clarifying in which cases we can have TABLE::mdl_lock
set to 0.
sql/sql_insert.cc:
Now the 4th argument of open_table() is mandatory (it makes
no sense to complicate open_table() code when we can simply
pass dummy variable).
sql/sql_parse.cc:
Renamed TABLE_LIST::open_table_type to open_type to
avoid confusing it with type of table.
sql/sql_prepare.cc:
Renamed TABLE_LIST::open_table_type to open_type to
avoid confusing it with type of table.
sql/sql_table.cc:
Now the 4th argument of open_table() is mandatory (it makes
no sense to complicate open_table() code when we can simply
pass dummy variable).
sql/sql_trigger.cc:
Replaced the only call to name_lock_locked_table() function
with its body.
sql/sql_view.cc:
Renamed TABLE_LIST::open_table_type to open_type to
avoid confusing it with type of table.
sql/table.h:
Renamed TABLE_LIST::open_table_type to open_type (to
avoid confusing it with type of table) and improved
comments describing this member.
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r-- | sql/sql_trigger.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index a7a4d48b593..4e2b77292d8 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -446,8 +446,17 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) if (thd->locked_tables) { - if (name_lock_locked_table(thd, tables)) + /* Under LOCK TABLES we must only accept write locked tables. */ + if (!(tables->table= find_write_locked_table(thd->open_tables, tables->db, + tables->table_name))) goto end; + /* + Ensure that table is opened only by this thread and that no other + statement will open this table. + */ + if (wait_while_table_is_used(thd, tables->table, HA_EXTRA_FORCE_REOPEN)) + goto end; + pthread_mutex_lock(&LOCK_open); } else |