Loading mysql-test/r/innodb.result +109 −0 Original line number Diff line number Diff line Loading @@ -2663,3 +2663,112 @@ rollback; rollback; drop table t1; drop function f1; create table t1 ( a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; commit; mysql-test/t/innodb.test +116 −0 Original line number Diff line number Diff line Loading @@ -1635,3 +1635,119 @@ drop function f1; disconnect a; disconnect b; # # BUG 14056 Column prefix index on UTF-8 primary key column causes: Can't find record.. # create table t1 ( a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; commit; sql/ha_innodb.cc +65 −7 Original line number Diff line number Diff line Loading @@ -2872,6 +2872,9 @@ ha_innobase::store_key_val_for_row( ulint lenlen; ulint len; byte* data; ulint key_len; CHARSET_INFO* cs; int error=0; if (is_null) { buff += key_part->length + 2; Loading @@ -2890,8 +2893,20 @@ ha_innobase::store_key_val_for_row( /* In a column prefix index, we may need to truncate the stored value: */ if (len > key_part->length) { len = key_part->length; cs = key_part->field->charset(); if (cs->mbmaxlen > 1 && key_part->length > 0) { key_len = (ulint) cs->cset->well_formed_len(cs, (const char *) data, (const char *) data + key_part->length, key_part->length / cs->mbmaxlen, &error); } else { key_len = key_part->length; } if (len > key_len) { len = key_len; } /* The length in a key value is always stored in 2 Loading @@ -2915,6 +2930,11 @@ ha_innobase::store_key_val_for_row( || mysql_type == FIELD_TYPE_BLOB || mysql_type == FIELD_TYPE_LONG_BLOB) { CHARSET_INFO* cs; ulint key_len; ulint len; int error=0; ut_a(key_part->key_part_flag & HA_PART_KEY_SEG); if (is_null) { Loading @@ -2935,8 +2955,21 @@ ha_innobase::store_key_val_for_row( indexes, and we may need to truncate the data to be stored in the key value: */ if (blob_len > key_part->length) { blob_len = key_part->length; cs = key_part->field->charset(); if (cs->mbmaxlen > 1 && key_part->length > 0) { key_len = (ulint) cs->cset->well_formed_len(cs, (const char *) blob_data, (const char *) blob_data + key_part->length, key_part->length / cs->mbmaxlen, &error); } else { key_len = key_part->length; } if (blob_len > key_len) { blob_len = key_len; } /* MySQL reserves 2 bytes for the length and the Loading @@ -2958,15 +2991,40 @@ ha_innobase::store_key_val_for_row( value we store may be also in a column prefix index. */ CHARSET_INFO* cs; ulint len; const mysql_byte* src_start; int error=0; if (is_null) { buff += key_part->length; continue; } memcpy(buff, record + key_part->offset, key_part->length); buff += key_part->length; cs = key_part->field->charset(); src_start = record + key_part->offset; if (key_part->length > 0 && cs->mbmaxlen > 1) { len = (ulint) cs->cset->well_formed_len(cs, src_start, src_start + key_part->length, key_part->length / cs->mbmaxlen, &error); } else { len = key_part->length; } memcpy(buff, src_start, len); buff+=len; /* Pad the unused space with spaces */ if (len < key_part->length) { len = key_part->length - len; memset(buff, ' ', len); buff+=len; } } } Loading Loading
mysql-test/r/innodb.result +109 −0 Original line number Diff line number Diff line Loading @@ -2663,3 +2663,112 @@ rollback; rollback; drop table t1; drop function f1; create table t1 ( a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; commit;
mysql-test/t/innodb.test +116 −0 Original line number Diff line number Diff line Loading @@ -1635,3 +1635,119 @@ drop function f1; disconnect a; disconnect b; # # BUG 14056 Column prefix index on UTF-8 primary key column causes: Can't find record.. # create table t1 ( a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six'); insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven'); insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; create table t1 ( a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2)) ) character set utf8 engine = innodb; create table t2 ( a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2)) ) character set ucs2 engine = innodb; insert into t1 values (1,'abcdefg','abcdefg','one'); insert into t1 values (2,'ijkilmn','ijkilmn','two'); insert into t1 values (3,'qrstuvw','qrstuvw','three'); insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four'); insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five'); insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight'); insert into t2 values (1,'abcdefg','abcdefg','one'); insert into t2 values (2,'ijkilmn','ijkilmn','two'); insert into t2 values (3,'qrstuvw','qrstuvw','three'); insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four'); insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five'); insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six'); insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven'); insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight'); insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten'); insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken'); drop table t1; drop table t2; commit;
sql/ha_innodb.cc +65 −7 Original line number Diff line number Diff line Loading @@ -2872,6 +2872,9 @@ ha_innobase::store_key_val_for_row( ulint lenlen; ulint len; byte* data; ulint key_len; CHARSET_INFO* cs; int error=0; if (is_null) { buff += key_part->length + 2; Loading @@ -2890,8 +2893,20 @@ ha_innobase::store_key_val_for_row( /* In a column prefix index, we may need to truncate the stored value: */ if (len > key_part->length) { len = key_part->length; cs = key_part->field->charset(); if (cs->mbmaxlen > 1 && key_part->length > 0) { key_len = (ulint) cs->cset->well_formed_len(cs, (const char *) data, (const char *) data + key_part->length, key_part->length / cs->mbmaxlen, &error); } else { key_len = key_part->length; } if (len > key_len) { len = key_len; } /* The length in a key value is always stored in 2 Loading @@ -2915,6 +2930,11 @@ ha_innobase::store_key_val_for_row( || mysql_type == FIELD_TYPE_BLOB || mysql_type == FIELD_TYPE_LONG_BLOB) { CHARSET_INFO* cs; ulint key_len; ulint len; int error=0; ut_a(key_part->key_part_flag & HA_PART_KEY_SEG); if (is_null) { Loading @@ -2935,8 +2955,21 @@ ha_innobase::store_key_val_for_row( indexes, and we may need to truncate the data to be stored in the key value: */ if (blob_len > key_part->length) { blob_len = key_part->length; cs = key_part->field->charset(); if (cs->mbmaxlen > 1 && key_part->length > 0) { key_len = (ulint) cs->cset->well_formed_len(cs, (const char *) blob_data, (const char *) blob_data + key_part->length, key_part->length / cs->mbmaxlen, &error); } else { key_len = key_part->length; } if (blob_len > key_len) { blob_len = key_len; } /* MySQL reserves 2 bytes for the length and the Loading @@ -2958,15 +2991,40 @@ ha_innobase::store_key_val_for_row( value we store may be also in a column prefix index. */ CHARSET_INFO* cs; ulint len; const mysql_byte* src_start; int error=0; if (is_null) { buff += key_part->length; continue; } memcpy(buff, record + key_part->offset, key_part->length); buff += key_part->length; cs = key_part->field->charset(); src_start = record + key_part->offset; if (key_part->length > 0 && cs->mbmaxlen > 1) { len = (ulint) cs->cset->well_formed_len(cs, src_start, src_start + key_part->length, key_part->length / cs->mbmaxlen, &error); } else { len = key_part->length; } memcpy(buff, src_start, len); buff+=len; /* Pad the unused space with spaces */ if (len < key_part->length) { len = key_part->length - len; memset(buff, ' ', len); buff+=len; } } } Loading