#At file:///Users/mattiasj/clones/bzrroot/b46639-51-bugteam/ based on revid:joro@stripped
3072 Mattias Jonsson 2009-08-18
Bug#46639: 1030 (HY000): Got error 124 from storage engine on
INSERT ... SELECT ...
Problem was that when bulk insert is used on an empty
table/partition, it disables the indexes for better
performance, but in this specific case it also tries
to read from that partition using an index, which is
not possible since it has been disabled.
Solution was to allow index reads on disabled indexes
if there are no records.
@ mysql-test/r/partition.result
Bug#46639: 1030 (HY000): Got error 124 from storage engine on
INSERT ... SELECT ...
updated result file
@ mysql-test/t/partition.test
Bug#46639: 1030 (HY000): Got error 124 from storage engine on
INSERT ... SELECT ...
Added testcase
@ storage/myisam/mi_search.c
Bug#46639: 1030 (HY000): Got error 124 from storage engine on
INSERT ... SELECT ...
Return KEY_NOT_FOUND instead of WRONG_INDEX when
there are no rows.
modified:
mysql-test/r/partition.result
mysql-test/t/partition.test
storage/myisam/mi_search.c
=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result 2009-08-12 10:03:05 +0000
+++ b/mysql-test/r/partition.result 2009-08-18 14:07:41 +0000
@@ -1,5 +1,19 @@
drop table if exists t1, t2;
CREATE TABLE t1 (
+a int NOT NULL,
+b int NOT NULL);
+CREATE TABLE t2 (
+a int NOT NULL,
+b int NOT NULL,
+INDEX(b)
+)
+PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 VALUES (399, 22);
+INSERT INTO t2 VALUES (1, 22), (1, 42);
+INSERT INTO t2 SELECT 1, 399 FROM t2, t1
+WHERE t1.b = t2.b;
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
b varchar(10),
PRIMARY KEY (a)
=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test 2009-08-12 10:03:05 +0000
+++ b/mysql-test/t/partition.test 2009-08-18 14:07:41 +0000
@@ -15,6 +15,28 @@ drop table if exists t1, t2;
--enable_warnings
#
+# Bug#46639: 1030 (HY000): Got error 124 from storage engine on
+# INSERT ... SELECT ...
+CREATE TABLE t1 (
+ a int NOT NULL,
+ b int NOT NULL);
+
+CREATE TABLE t2 (
+ a int NOT NULL,
+ b int NOT NULL,
+ INDEX(b)
+)
+PARTITION BY HASH(a) PARTITIONS 2;
+
+INSERT INTO t1 VALUES (399, 22);
+INSERT INTO t2 VALUES (1, 22), (1, 42);
+
+INSERT INTO t2 SELECT 1, 399 FROM t2, t1
+WHERE t1.b = t2.b;
+
+DROP TABLE t1, t2;
+
+#
# Bug#46478: timestamp field incorrectly defaulted when partition is reorganized
#
CREATE TABLE t1 (
=== modified file 'storage/myisam/mi_search.c'
--- a/storage/myisam/mi_search.c 2009-02-13 16:41:47 +0000
+++ b/storage/myisam/mi_search.c 2009-08-18 14:07:41 +0000
@@ -28,11 +28,19 @@ int _mi_check_index(MI_INFO *info, int i
{
if (inx == -1) /* Use last index */
inx=info->lastinx;
- if (inx < 0 || ! mi_is_key_active(info->s->state.key_map, inx))
+ if (inx < 0)
{
my_errno=HA_ERR_WRONG_INDEX;
return -1;
}
+ if (! mi_is_key_active(info->s->state.key_map, inx))
+ {
+ if (info->s->state.state.records == 0)
+ my_errno=HA_ERR_KEY_NOT_FOUND;
+ else
+ my_errno=HA_ERR_WRONG_INDEX;
+ return -1;
+ }
if (info->lastinx != inx) /* Index changed */
{
info->lastinx = inx;
Attachment: [text/bzr-bundle]