Commit e472b682 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-32839 LONG UNIQUE gives error when used with REPLACE

calculate auto-inc value even if long duplicate check fails -
this is what the engine does for normal uniques.

auto-inc value is needed if it's a REPLACE
parent 81609d86
......@@ -572,5 +572,84 @@ insert into t1 values (1,10),(2,20);
update t1 set b = 30 limit 1;
drop table t1;
#
# MDEV-32839 LONG UNIQUE gives error when used with REPLACE
#
create table t1 (
f1 bigint(20) not null auto_increment primary key,
f2 varchar(30) default null,
f3 varchar(30) default null,
f4 varchar(255) default null,
f5 varchar(30) default null,
f6 varchar(255) default null,
f7 varchar(255) default null,
unique problem_key (f3,f5,f6,f2,f4,f7) using hash
) engine=myisam;
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
select * from t1;
f1 f2 f3 f4 f5 f6 f7
2 00004 0001009089999 netstes psit d
4 00004 0001009089999 netstes psit e
drop table t1;
create table t1 (
f1 bigint(20) not null auto_increment primary key,
f2 varchar(30) default null,
f3 varchar(30) default null,
f4 varchar(255) default null,
f5 varchar(30) default null,
f6 varchar(255) default null,
f7 varchar(255) default null,
unique problem_key (f3,f5,f6,f2,f4,f7) using hash
) engine=innodb;
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
select * from t1;
f1 f2 f3 f4 f5 f6 f7
2 00004 0001009089999 netstes psit d
4 00004 0001009089999 netstes psit e
drop table t1;
create table t1 (
f1 bigint(20) not null auto_increment primary key,
f2 varchar(30) default null,
f3 varchar(30) default null,
f4 varchar(255) default null,
f5 varchar(30) default null,
f6 varchar(255) default null,
f7 varchar(255) default null,
unique problem_key (f3,f5,f6,f2,f4,f7) using hash
) engine=myisam partition by key(f1) partitions 2;
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
select * from t1;
f1 f2 f3 f4 f5 f6 f7
2 00004 0001009089999 netstes psit d
4 00004 0001009089999 netstes psit e
drop table t1;
create table t1 (
f1 bigint(20) not null auto_increment primary key,
f2 varchar(30) default null,
f3 varchar(30) default null,
f4 varchar(255) default null,
f5 varchar(30) default null,
f6 varchar(255) default null,
f7 varchar(255) default null,
unique problem_key (f3,f5,f6,f2,f4,f7) using hash
) engine=innodb partition by key(f1) partitions 2;
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
select * from t1;
f1 f2 f3 f4 f5 f6 f7
2 00004 0001009089999 netstes psit d
4 00004 0001009089999 netstes psit e
drop table t1;
#
# End of 10.5 tests
#
......@@ -563,6 +563,77 @@ insert into t1 values (1,10),(2,20);
update t1 set b = 30 limit 1;
drop table t1;
--echo #
--echo # MDEV-32839 LONG UNIQUE gives error when used with REPLACE
--echo #
create table t1 (
f1 bigint(20) not null auto_increment primary key,
f2 varchar(30) default null,
f3 varchar(30) default null,
f4 varchar(255) default null,
f5 varchar(30) default null,
f6 varchar(255) default null,
f7 varchar(255) default null,
unique problem_key (f3,f5,f6,f2,f4,f7) using hash
) engine=myisam;
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
select * from t1;
drop table t1;
create table t1 (
f1 bigint(20) not null auto_increment primary key,
f2 varchar(30) default null,
f3 varchar(30) default null,
f4 varchar(255) default null,
f5 varchar(30) default null,
f6 varchar(255) default null,
f7 varchar(255) default null,
unique problem_key (f3,f5,f6,f2,f4,f7) using hash
) engine=innodb;
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
select * from t1;
drop table t1;
create table t1 (
f1 bigint(20) not null auto_increment primary key,
f2 varchar(30) default null,
f3 varchar(30) default null,
f4 varchar(255) default null,
f5 varchar(30) default null,
f6 varchar(255) default null,
f7 varchar(255) default null,
unique problem_key (f3,f5,f6,f2,f4,f7) using hash
) engine=myisam partition by key(f1) partitions 2;
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
select * from t1;
drop table t1;
create table t1 (
f1 bigint(20) not null auto_increment primary key,
f2 varchar(30) default null,
f3 varchar(30) default null,
f4 varchar(255) default null,
f5 varchar(30) default null,
f6 varchar(255) default null,
f7 varchar(255) default null,
unique problem_key (f3,f5,f6,f2,f4,f7) using hash
) engine=innodb partition by key(f1) partitions 2;
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'd');
insert t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
replace t1 (f2, f3, f4, f5, f6, f7) values ('00004', '0001009089999', '', 'netstes', 'psit', 'e');
select * from t1;
drop table t1;
--echo #
--echo # End of 10.5 tests
--echo #
......@@ -7263,7 +7263,12 @@ int handler::ha_write_row(const uchar *buf)
{
DBUG_ASSERT(inited == NONE || lookup_handler != this);
if ((error= check_duplicate_long_entries(buf)))
{
if (table->next_number_field && buf == table->record[0])
if (int err= update_auto_increment())
error= err;
DBUG_RETURN(error);
}
}
MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment