mirror of
https://github.com/MariaDB/server.git
synced 2026-05-18 21:07:24 +02:00
key_copy: fix key_part length calculation for varchars/blobs
This commit is contained in:
parent
0a7ef33510
commit
594c0c55d3
3 changed files with 22 additions and 1 deletions
|
|
@ -267,3 +267,14 @@ Table Op Msg_type Msg_text
|
|||
test.t check Warning Bogus foreign key t_ibfk_1 is skipped.
|
||||
test.t check error Corrupt
|
||||
drop table t;
|
||||
# In a->b relation, `a` key_part can be shorter than `b`
|
||||
create table t (a varchar(1), b varchar(8), key(b),
|
||||
foreign key(a) references t(b)) engine=innodb;
|
||||
set foreign_key_checks = off;
|
||||
insert into t values ('d','dd');
|
||||
set foreign_key_checks = on;
|
||||
check table t extended;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check Warning Cannot add or update a child row: a foreign key constraint fails (Key: t_ibfk_1, record: 'd')
|
||||
test.t check error Corrupt
|
||||
drop table t;
|
||||
|
|
|
|||
|
|
@ -193,3 +193,13 @@ insert into t values ('00:00:00','8000:0020:2020:2020:2020:2020:2020:2020');
|
|||
check table t extended;
|
||||
|
||||
drop table t;
|
||||
|
||||
|
||||
--echo # In a->b relation, `a` key_part can be shorter than `b`
|
||||
create table t (a varchar(1), b varchar(8), key(b),
|
||||
foreign key(a) references t(b)) engine=innodb;
|
||||
set foreign_key_checks = off;
|
||||
insert into t values ('d','dd');
|
||||
set foreign_key_checks = on;
|
||||
check table t extended;
|
||||
drop table t;
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ void key_copy(uchar *to_key, uchar *extra_buff,
|
|||
|
||||
if (to_key_part->is_var_length())
|
||||
key_length-= HA_KEY_BLOB_LENGTH;
|
||||
length= MY_MIN(key_length, key_part->length);
|
||||
length= MY_MIN(key_length, to_key_part->length);
|
||||
uint bytes= field->get_key_image(to_key, length, from_ptr,
|
||||
Field::image_type(to_key_info->algorithm));
|
||||
if (with_zerofill && bytes < length)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue