From 9aa5a86a801d6af6ed40e1ce16a8b7b1c83ea3e2 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Wed, 31 Aug 2005 14:17:05 +0300 Subject: [PATCH 1/2] ha_innodb.cc: Fix bug #12852 : do not increment the open handle count to a table if the table does not have an .ibd file and InnoDB decides to return an error from the ::open() function; then the table can be dropped even if the user has tried to open it --- sql/ha_innodb.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index e8279982da5..b4e5092ee4a 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1651,6 +1651,8 @@ ha_innobase::open( my_free((char*) upd_buff, MYF(0)); my_errno = ENOENT; + dict_table_decrement_handle_count(ib_table); + DBUG_RETURN(1); } @@ -5439,6 +5441,19 @@ ha_innobase::store_lock( if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) { + if (lock_type == TL_READ && thd->in_lock_tables) { + /* We come here if MySQL is processing LOCK TABLES + ... READ LOCAL. MyISAM under that table lock type + reads the table as it was at the time the lock was + granted (new inserts are allowed, but not seen by the + reader). To get a similar effect on an InnoDB table, + we must use LOCK TABLES ... READ. We convert the lock + type here, so that for InnoDB, READ LOCAL is + equivalent to READ. */ + + lock_type = TL_READ_NO_INSERT; + } + /* If we are not doing a LOCK TABLE or DISCARD/IMPORT TABLESPACE, then allow multiple writers */ From 183feee465e1c159840ff157919649962b2a221e Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Wed, 31 Aug 2005 14:27:44 +0300 Subject: [PATCH 2/2] ha_innodb.cc: Fix bug #12410 : InnoDB was too permissive with LOCK TABLE ... READ LOCAL, and alowed new inserts to the table; we now make READ LOCAL equivalent to READ for InnoDB; note that this will cause slightly more locking in mysqldump, but makes the InnoDB table dumps consistent with MyISAM table dumps; note that the real code change patch was accidentally pushed with my another patch 5 minutes ago --- sql/ha_innodb.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index b4e5092ee4a..b30ddfe8227 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -5449,7 +5449,9 @@ ha_innobase::store_lock( reader). To get a similar effect on an InnoDB table, we must use LOCK TABLES ... READ. We convert the lock type here, so that for InnoDB, READ LOCAL is - equivalent to READ. */ + equivalent to READ. This will change the InnoDB + behavior in mysqldump, so that dumps of InnoDB tables + are consistent with dumps of MyISAM tables. */ lock_type = TL_READ_NO_INSERT; }