Commit cdd6bc9b authored by unknown's avatar unknown
Browse files

Fixed wrong buffer usage for auto-increment key with blob part that caused...

Fixed wrong buffer usage for auto-increment key with blob part that caused CHECK TABLE to report that the table was wrong. (Bug #10045)


myisam/mi_key.c:
  Fixed wrong buffer usage for auto-increment key with blob part that caused
  CHECK TABLE to report that the table was wrong. (Bug #10045)
mysql-test/r/auto_increment.result:
  New test case
mysql-test/t/auto_increment.test:
  New test case
parent 7c441dd1
Loading
Loading
Loading
Loading
+21 −10
Original line number Diff line number Diff line
@@ -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++)
  {
+14 −0
Original line number Diff line number Diff line
@@ -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;
+12 −0
Original line number Diff line number Diff line
@@ -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;