summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--myisam/mi_key.c31
-rw-r--r--mysql-test/r/auto_increment.result14
-rw-r--r--mysql-test/t/auto_increment.test12
3 files changed, 47 insertions, 10 deletions
diff --git a/myisam/mi_key.c b/myisam/mi_key.c
index 1688ab74823..06571c570e1 100644
--- a/myisam/mi_key.c
+++ b/myisam/mi_key.c
@@ -255,8 +255,25 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
} /* _mi_pack_key */
- /* Put a key in record */
- /* Used when only-keyread is wanted */
+
+/*
+ Store found key in record
+
+ SYNOPSIS
+ _mi_put_key_in_record()
+ info MyISAM handler
+ keynr Key number that was used
+ record Store key here
+
+ Last read key is in info->lastkey
+
+ NOTES
+ Used when only-keyread is wanted
+
+ RETURN
+ 0 ok
+ 1 error
+*/
static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
byte *record)
@@ -267,14 +284,8 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
byte *blob_ptr;
DBUG_ENTER("_mi_put_key_in_record");
- if (info->s->base.blobs && info->s->keyinfo[keynr].flag & HA_VAR_LENGTH_KEY)
- {
- if (!(blob_ptr=
- mi_alloc_rec_buff(info, info->s->keyinfo[keynr].keylength,
- &info->rec_buff)))
- goto err;
- }
- key=(byte*) info->lastkey;
+ blob_ptr= info->lastkey2; /* Place to put blob parts */
+ key=(byte*) info->lastkey; /* KEy that was read */
key_end=key+info->lastkey_length;
for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++)
{
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result
index 2d6b058d9c5..9345c029127 100644
--- a/mysql-test/r/auto_increment.result
+++ b/mysql-test/r/auto_increment.result
@@ -131,3 +131,17 @@ a
1
2
drop table t1;
+CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
+INSERT INTO t1 (b) VALUES ('aaaa');
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (b) VALUES ('');
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (b) VALUES ('bbbb');
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index c26983b5eec..e699415a838 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -89,3 +89,15 @@ select last_insert_id();
insert into t1 values (NULL);
select * from t1;
drop table t1;
+
+#
+# BUG #10045: Problem with composite AUTO_INCREMENT + BLOB key
+
+CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
+INSERT INTO t1 (b) VALUES ('aaaa');
+CHECK TABLE t1;
+INSERT INTO t1 (b) VALUES ('');
+CHECK TABLE t1;
+INSERT INTO t1 (b) VALUES ('bbbb');
+CHECK TABLE t1;
+DROP TABLE IF EXISTS t1;