Below is the list of changes that have just been committed into a local
4.1 repository of mydev. When mydev 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
1.2274 05/05/18 19:40:39 ingo@stripped +6 -0
Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY
UPDATE
After review version.
Added a condition for MERGE tables. These do not have unique
indexes. But every key could be a unique key on the underlying
MyISAM table. So get the maximum key length for MERGE tables
instead of the maximum unique key length. This is used for
buffer allocation in write_record().
sql/table.cc
1.129 05/05/18 19:40:35 ingo@stripped +6 -1
Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY
UPDATE
Added a condition for MERGE tables. These do not have unique
indexes. But every key could be a unique key on the underlying
MyISAM table. So get the maximum key length for MERGE tables
instead of the maximum unique key length. This is used for
buffer allocation in write_record().
sql/sql_insert.cc
1.162 05/05/18 19:40:35 ingo@stripped +1 -1
Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY
UPDATE
Changed the freeing of the memory to be symmetric to its
allocation (my_safe_alloc -> my_safe_afree).
This is not directly related to the bug.
sql/handler.h
1.140 05/05/18 19:40:35 ingo@stripped +1 -0
Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY
UPDATE
Added a new table_flag telling that any index
might be unique without being specified as such.
sql/ha_myisammrg.h
1.38 05/05/18 19:40:35 ingo@stripped +1 -1
Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY
UPDATE
Set a table_flag for the MERGE engine telling that any index
might be unique without being specified as such.
mysql-test/t/merge.test
1.31 05/05/18 19:40:35 ingo@stripped +12 -0
Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY
UPDATE
The test case does not in all cases show the problem
without the bugfix. The improper memory allocation
might get through undetected in many cases.
mysql-test/r/merge.result
1.35 05/05/18 19:40:35 ingo@stripped +10 -0
Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY
UPDATE
The test result.
# 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: ingo
# Host: chilla.local
# Root: /home/mydev/mysql-4.1-4100
--- 1.37/sql/ha_myisammrg.h Wed May 4 15:05:53 2005
+++ 1.38/sql/ha_myisammrg.h Wed May 18 19:40:35 2005
@@ -37,7 +37,7 @@
{
return (HA_REC_NOT_IN_SEQ | HA_AUTO_PART_KEY | HA_READ_RND_SAME |
HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED |
- HA_CAN_INSERT_DELAYED);
+ HA_CAN_INSERT_DELAYED | HA_ANY_INDEX_MAY_BE_UNIQUE);
}
ulong index_flags(uint inx, uint part, bool all_parts) const
{
--- 1.139/sql/handler.h Fri May 13 22:34:05 2005
+++ 1.140/sql/handler.h Wed May 18 19:40:35 2005
@@ -73,6 +73,7 @@
#define HA_HAS_CHECKSUM (1 << 24)
/* Table data are stored in separate files (for lower_case_table_names) */
#define HA_FILE_BASED (1 << 26)
+#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
/* bits in index_flags(index_number) for what you can do with index */
--- 1.161/sql/sql_insert.cc Sat May 7 14:31:15 2005
+++ 1.162/sql/sql_insert.cc Wed May 18 19:40:35 2005
@@ -682,7 +682,7 @@
err:
if (key)
- my_afree(key);
+ my_safe_afree(key,table->max_unique_length,MAX_KEY_LENGTH);
info->last_errno= error;
table->file->print_error(error,MYF(0));
DBUG_RETURN(1);
--- 1.128/sql/table.cc Sat May 7 22:54:07 2005
+++ 1.129/sql/table.cc Wed May 18 19:40:35 2005
@@ -688,7 +688,12 @@
set_if_bigger(outparam->max_key_length,keyinfo->key_length+
keyinfo->key_parts);
outparam->total_key_length+= keyinfo->key_length;
- if (keyinfo->flags & HA_NOSAME)
+ /*
+ MERGE tables do not have unique indexes. But every key could be
+ an unique index on the underlying MyISAM table. (Bug #10400)
+ */
+ if ((keyinfo->flags & HA_NOSAME) ||
+ (ha_option & HA_ANY_INDEX_MAY_BE_UNIQUE))
set_if_bigger(outparam->max_unique_length,keyinfo->key_length);
}
if (primary_key < MAX_KEY &&
--- 1.34/mysql-test/r/merge.result Mon Dec 27 13:01:59 2004
+++ 1.35/mysql-test/r/merge.result Wed May 18 19:40:35 2005
@@ -681,3 +681,13 @@
t3 1 a 2 b A NULL NULL NULL YES BTREE
t3 1 a 3 c A NULL NULL NULL YES BTREE
drop table t1, t2, t3;
+CREATE TABLE t1 ( a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(10), UNIQUE (b) )
+ENGINE=MyISAM;
+CREATE TABLE t2 ( a INT AUTO_INCREMENT, b VARCHAR(10), INDEX (a), INDEX (b) )
+ENGINE=MERGE UNION (t1) INSERT_METHOD=FIRST;
+INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=2;
+INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=3;
+SELECT b FROM t2;
+b
+3
+DROP TABLE t1, t2;
--- 1.30/mysql-test/t/merge.test Mon Dec 27 13:01:59 2004
+++ 1.31/mysql-test/t/merge.test Wed May 18 19:40:35 2005
@@ -306,3 +306,15 @@
drop table t1, t2, t3;
+#
+# Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY
UPDATE
+#
+CREATE TABLE t1 ( a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(10), UNIQUE (b) )
+ ENGINE=MyISAM;
+CREATE TABLE t2 ( a INT AUTO_INCREMENT, b VARCHAR(10), INDEX (a), INDEX (b) )
+ ENGINE=MERGE UNION (t1) INSERT_METHOD=FIRST;
+INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=2;
+INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=3;
+SELECT b FROM t2;
+DROP TABLE t1, t2;
+
| Thread |
|---|
| • bk commit into 4.1 tree (ingo:1.2274) BUG#10400 | ingo | 18 May |