Below is the list of changes that have just been committed into a local
5.0 repository of svoj. When svoj does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-09-07 20:03:10+05:00, svoj@stripped +7 -0
BUG#20256 - LOCK WRITE - MyISAM
Only MyISAM tables locked with LOCK TABLES ... WRITE were affected.
A query that is optimized with index_merge doesn't reflect rows
inserted within LOCK TABLES.
MyISAM doesn't flush a state within LOCK TABLES. index_merge
optimization creates a copy of the handler, which thus gets
outdated MyISAM state.
New handler->clone() method is introduced to fix this problem.
For non-MyISAM storage engines it allocates a handler and opens
it with ha_open(). For MyISAM it additionally copies MyISAM state
pointer to cloned handler.
mysql-test/r/index_merge.result@stripped, 2006-09-07 20:03:00+05:00, svoj@stripped +31 -0
A test case for bug#20256.
mysql-test/t/index_merge.test@stripped, 2006-09-07 20:03:01+05:00, svoj@stripped +32 -0
A test case for bug#20256.
sql/ha_myisam.cc@stripped, 2006-09-07 20:03:01+05:00, svoj@stripped +12 -0
clone method added to handler class.
sql/ha_myisam.h@stripped, 2006-09-07 20:03:01+05:00, svoj@stripped +1 -0
clone method added to handler class.
sql/handler.cc@stripped, 2006-09-07 20:03:02+05:00, svoj@stripped +9 -0
clone method added to handler class.
sql/handler.h@stripped, 2006-09-07 20:03:02+05:00, svoj@stripped +1 -0
clone method added to handler class.
sql/opt_range.cc@stripped, 2006-09-07 20:03:02+05:00, svoj@stripped +1 -4
Use handler clone method.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: svoj
# Host: may.pils.ru
# Root: /home/svoj/devel/mysql/BUG20256/mysql-5.0-engines
--- 1.166/sql/ha_myisam.cc 2006-09-07 20:03:18 +05:00
+++ 1.167/sql/ha_myisam.cc 2006-09-07 20:03:18 +05:00
@@ -169,6 +169,18 @@
can_enable_indexes(1)
{}
+handler *ha_myisam::clone(MEM_ROOT *mem_root)
+{
+ ha_myisam *new_handler= new (mem_root) ha_myisam(table);
+ if (new_handler && !new_handler->ha_open(table->s->path,
table->db_stat,
+ HA_OPEN_IGNORE_IF_LOCKED))
+ {
+ new_handler->file->state= file->state;
+ return new_handler;
+ }
+ return NULL;
+}
+
static const char *ha_myisam_exts[] = {
".MYI",
--- 1.68/sql/ha_myisam.h 2006-09-07 20:03:18 +05:00
+++ 1.69/sql/ha_myisam.h 2006-09-07 20:03:18 +05:00
@@ -45,6 +45,7 @@
public:
ha_myisam(TABLE *table_arg);
~ha_myisam() {}
+ handler *clone(MEM_ROOT *mem_root);
const char *table_type() const { return "MyISAM"; }
const char *index_type(uint key_number);
const char **bas_ext() const;
--- 1.215/sql/handler.cc 2006-09-07 20:03:18 +05:00
+++ 1.216/sql/handler.cc 2006-09-07 20:03:18 +05:00
@@ -1372,6 +1372,15 @@
/****************************************************************************
** General handler functions
****************************************************************************/
+handler *handler::clone(MEM_ROOT *mem_root)
+{
+ handler *new_handler= get_new_handler(table, mem_root, table->s->db_type);
+ if (new_handler && !new_handler->ha_open(table->s->path,
table->db_stat,
+ HA_OPEN_IGNORE_IF_LOCKED))
+ return new_handler;
+ return NULL;
+}
+
/* Open database-handler. Try O_RDONLY if can't open as O_RDWR */
/* Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set */
--- 1.177/sql/handler.h 2006-09-07 20:03:18 +05:00
+++ 1.178/sql/handler.h 2006-09-07 20:03:18 +05:00
@@ -563,6 +563,7 @@
pushed_cond(NULL)
{}
virtual ~handler(void) { /* TODO: DBUG_ASSERT(inited == NONE); */ }
+ virtual handler *clone(MEM_ROOT *mem_root);
int ha_open(const char *name, int mode, int test_if_locked);
void adjust_next_insert_id_after_explicit_value(ulonglong nr);
bool update_auto_increment();
--- 1.217/sql/opt_range.cc 2006-09-07 20:03:18 +05:00
+++ 1.218/sql/opt_range.cc 2006-09-07 20:03:18 +05:00
@@ -1033,10 +1033,7 @@
}
THD *thd= current_thd;
- if (!(file= get_new_handler(head, thd->mem_root, head->s->db_type)))
- goto failure;
- DBUG_PRINT("info", ("Allocated new handler %p", file));
- if (file->ha_open(head->s->path, head->db_stat, HA_OPEN_IGNORE_IF_LOCKED))
+ if (!(file= head->file->clone(thd->mem_root)))
{
/* Caller will free the memory */
goto failure;
--- 1.19/mysql-test/r/index_merge.result 2006-09-07 20:03:18 +05:00
+++ 1.20/mysql-test/r/index_merge.result 2006-09-07 20:03:18 +05:00
@@ -424,3 +424,34 @@
1 SIMPLE t3 index_merge a,b a,b 5,5 NULL # Using intersect(a,b); Using where
drop table t3;
drop table t0, t1, t2;
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(1);
+CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b));
+INSERT INTO t2(a,b) VALUES
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(1,2);
+LOCK TABLES t1 WRITE, t2 WRITE;
+INSERT INTO t2(a,b) VALUES(1,2);
+SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1;
+a
+1
+1
+UNLOCK TABLES;
+DROP TABLE t1, t2;
--- 1.14/mysql-test/t/index_merge.test 2006-09-07 20:03:18 +05:00
+++ 1.15/mysql-test/t/index_merge.test 2006-09-07 20:03:18 +05:00
@@ -383,3 +383,35 @@
drop table t3;
drop table t0, t1, t2;
+
+#
+# BUG#20256 - LOCK WRITE - MyISAM
+#
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(1);
+CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b));
+INSERT INTO t2(a,b) VALUES
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(1,2);
+LOCK TABLES t1 WRITE, t2 WRITE;
+INSERT INTO t2(a,b) VALUES(1,2);
+SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1;
+UNLOCK TABLES;
+DROP TABLE t1, t2;
| Thread |
|---|
| • bk commit into 5.0 tree (svoj:1.2241) BUG#20256 | Sergey Vojtovich | 7 Sep |