1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-26693 ROW_NUMBER is wrong upon INSERT or UPDATE on Spider table

in case of a bulk insert the server sends all rows to the engine, and
then the engine replies that there was ER_DUP_ENTRY somewhere.

the exact number of the row that caused the error is unknown.
This commit is contained in:
Sergei Golubchik
2021-10-07 18:19:56 +02:00
parent 9bbd328254
commit 5c0b63458b
3 changed files with 89 additions and 2 deletions

View File

@ -1158,8 +1158,13 @@ values_loop_end:
table->file->ha_release_auto_increment();
if (using_bulk_insert)
{
if (unlikely(table->file->ha_end_bulk_insert()) &&
!error)
/*
if my_error() wasn't called yet on some specific row, end_bulk_insert()
can still do it, but the error shouldn't be for any specific row number
*/
if (!error)
thd->get_stmt_da()->reset_current_row_for_warning(0);
if (unlikely(table->file->ha_end_bulk_insert()) && !error)
{
table->file->print_error(my_errno,MYF(0));
error=1;

View File

@ -0,0 +1,45 @@
#
# MDEV-26693 ROW_NUMBER is wrong upon INSERT or UPDATE on Spider table
#
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
connection child2_1;
create database auto_test_remote;
use auto_test_remote;
create table ta_r (id int primary key);
connection master_1;
create table spd (id int primary key) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
insert into spd values (1),(2),(1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
get diagnostics condition 1 @n = row_number;
select @n;
@n
0
delete from spd;
insert into spd values (1),(2),(3),(13);
update spd set id = id + 10;
ERROR 23000: Duplicate entry '13' for key 'PRIMARY'
get diagnostics condition 1 @n = row_number;
select @n;
@n
0
drop table spd;
connection child2_1;
drop database auto_test_remote;
connection master_1;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3

View File

@ -0,0 +1,37 @@
--echo #
--echo # MDEV-26693 ROW_NUMBER is wrong upon INSERT or UPDATE on Spider table
--echo #
--disable_query_log
--disable_result_log
--source test_init.inc
--enable_result_log
--enable_query_log
--connection child2_1
create database auto_test_remote;
use auto_test_remote;
create table ta_r (id int primary key);
--connection master_1
evalp create table spd (id int primary key) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
--error ER_DUP_ENTRY
insert into spd values (1),(2),(1);
get diagnostics condition 1 @n = row_number;
select @n;
delete from spd;
insert into spd values (1),(2),(3),(13);
--error ER_DUP_ENTRY
update spd set id = id + 10;
get diagnostics condition 1 @n = row_number;
select @n;
drop table spd;
--connection child2_1
drop database auto_test_remote;
--connection master_1
--disable_query_log
--disable_result_log
--source test_deinit.inc