mirror of
https://github.com/MariaDB/server.git
synced 2025-07-20 10:18:13 +02:00

Multi-delete code invokes ha_rnd_end after applying deferred deletes, following the pattern as in multi-update. The CSV engine batches deletes made via calls to delete_row, then applies them all at once during ha_rnd_end. For each row batched, the CSV engine decrements an internal counter of the total rows in the table. The multi-delete code was not calling ha_rnd_end, so this internal counter was not consistent with the total number of rows in the table, triggering the assertion. In the CSV engine, explicitly delete the destination file before renaming the source file over it. This avoids a file rename problem on Windows. This change would have been necessary before the latest multi-delete changes, had this test case existed at that point in time, because the end_read_record call in do_table_deletes swallowed the rename failure on Windows.
233 lines
7.3 KiB
Text
233 lines
7.3 KiB
Text
#
|
|
# MDEV-30469 Support ORDER BY and LIMIT for multi-table DELETE, index hints for single-table DELETE.
|
|
#
|
|
|
|
--source include/have_innodb.inc
|
|
--source include/have_csv.inc
|
|
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (4,1),(3,2),(2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(3,2),(2,3),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
delete t1.*, t2.* from t1, t2 order by t1.id desc limit 3;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
drop table if exists t1, t2;
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (4,1),(3,2),(2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(3,2),(2,3),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
delete t1.*, t2.* from t1, t2 order by t1.id desc;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
drop table if exists t1, t2;
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (4,1),(3,2),(2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(3,2),(2,3),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
delete t1.*, t2.* from t1, t2 limit 2;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
create table t3 (a int primary key, b text);
|
|
insert into t3 (a, b) values (1, 'hello');
|
|
delete from t3 where b = '';
|
|
drop table t3;
|
|
|
|
drop table if exists t1, t2;
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (4,1),(3,2),(2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(3,2),(2,3),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
delete t1.*, t2.* from t1, t2 where t1.id=t2.id;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
drop table if exists t1;
|
|
create table t1(a INT);
|
|
insert into t1 values (1),(2),(3);
|
|
set session sql_buffer_result=1;
|
|
delete t1 from (select sum(a) a from t1) x,t1;
|
|
set session sql_buffer_result=default;
|
|
select * from t1;
|
|
drop table t1;
|
|
|
|
drop table if exists t1, t2;
|
|
create table t1(id1 smallint(5), field char(5));
|
|
create table t2(id2 smallint(5), field char(5));
|
|
insert into t1 values (1, 'a'), (2, 'aa');
|
|
insert into t2 values (1, 'b'), (2, 'bb');
|
|
update t2 inner join t1 on t1.id1=t2.id2 set t2.field=t1.field where 0=1;
|
|
update t2, t1 set t2.field=t1.field where t1.id1=t2.id2 and 0=1;
|
|
delete t1, t2 from t2 inner join t1 on t1.id1=t2.id2 where 0=1;
|
|
drop table t1, t2;
|
|
|
|
|
|
set session sql_buffer_result=1;
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (4,1),(3,2),(2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(3,2),(2,3),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
delete t1.*, t2.* from t1, t2 order by t1.id desc limit 3;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
drop table if exists t1, t2;
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (4,1),(3,2),(2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(3,2),(2,3),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
delete t1.*, t2.* from t1, t2 order by t1.id desc;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
drop table if exists t1, t2;
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (4,1),(3,2),(2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(3,2),(2,3),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
delete t1.*, t2.* from t1, t2 limit 2;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
create table t3 (a int primary key, b text);
|
|
insert into t3 (a, b) values (1, 'hello');
|
|
delete from t3 where b = '';
|
|
drop table t3;
|
|
|
|
drop table if exists t1, t2;
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (4,1),(3,2),(2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(3,2),(2,3),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
delete t1.*, t2.* from t1, t2 where t1.id=t2.id;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
drop table if exists t1, t2;
|
|
create table t1(id1 smallint(5), field char(5));
|
|
create table t2(id2 smallint(5), field char(5));
|
|
insert into t1 values (1, 'a'), (2, 'aa');
|
|
insert into t2 values (1, 'b'), (2, 'bb');
|
|
update t2 inner join t1 on t1.id1=t2.id2 set t2.field=t1.field where 0=1;
|
|
update t2, t1 set t2.field=t1.field where t1.id1=t2.id2 and 0=1;
|
|
delete t1, t2 from t2 inner join t1 on t1.id1=t2.id2 where 0=1;
|
|
|
|
drop table t1, t2;
|
|
set session sql_buffer_result=default;
|
|
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
select t1.*, t2.* from t1, t2 order by t1.id, t2.id limit 1;
|
|
delete t1.*, t2.* from t1, t2 order by t1.id, t2.id limit 1;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
drop table t1, t2;
|
|
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
select t1.*, t2.* from t1, t2 order by t1.id, t2.id limit 2;
|
|
delete t1.*, t2.* from t1, t2 order by t1.id, t2.id limit 2;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
drop table t1, t2;
|
|
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
insert into t1 (id, v) values (2,3),(1,4);
|
|
insert into t2 (id, v) values (5,5),(6,6);
|
|
select * from t1;
|
|
select * from t2;
|
|
select t1.*, t2.* from t1, t2 order by t1.id, t2.id limit 3;
|
|
delete t1.*, t2.* from t1, t2 order by t1.id, t2.id limit 3;
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
drop table t1, t2;
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
create table t3 (id int primary key, v int);
|
|
insert into t1 (id, v) values (1, 1000), (2, 2000), (3, 3000), (4, 4000), (5, 5000);
|
|
insert into t2 (id, v) values (10, 100), (20, 200), (30, 300), (40, 400), (50, 500);
|
|
insert into t3 (id, v) values (11, 111), (22, 222), (33, 333), (44, 444), (55, 555);
|
|
select * from t1;
|
|
select * from t2;
|
|
select * from t3;
|
|
select t1.*, t2.*, t3.* from t1, t2, t3 order by t1.id, t2.id, t3.id limit 3;
|
|
delete t1.*, t2.*, t3.* from t1, t2, t3 order by t1.id, t2.id, t3.id limit 3;
|
|
select * from t1;
|
|
select * from t2;
|
|
select * from t3;
|
|
|
|
drop table t1, t2, t3;
|
|
|
|
create table t1 (id int primary key, v int);
|
|
create table t2 (id int primary key, v int);
|
|
create table t3 (id int primary key, v int);
|
|
insert into t1 (id, v) values (1, 1000), (2, 2000), (3, 3000), (4, 4000), (5, 5000);
|
|
insert into t2 (id, v) values (10, 100), (20, 200), (30, 300), (40, 400), (50, 500);
|
|
insert into t3 (id, v) values (11, 111), (22, 222), (33, 333), (44, 444), (55, 555);
|
|
select * from t1;
|
|
select * from t2;
|
|
select * from t3;
|
|
delete t1.*, t2.*, t3.* from t1, t2, t3;
|
|
select * from t1;
|
|
select * from t2;
|
|
select * from t3;
|
|
|
|
drop table t1, t2, t3;
|
|
|
|
--echo #
|
|
--echo # Begin 11.8 tests
|
|
--echo #
|
|
|
|
--echo #
|
|
--echo # MDEV-36997 Assertion failed in ha_tina::delete_row on multi delete
|
|
--echo #
|
|
SET sql_mode='';
|
|
CREATE TABLE t1 (v INT (1) NOT NULL) ENGINE=CSV;
|
|
INSERT INTO t1 SELECT 1 away;
|
|
SELECT COUNT(*) from t1;
|
|
DELETE FROM a3,a1 USING t1 AS a1 JOIN t1 AS a2 JOIN t1 AS a3;
|
|
SELECT COUNT(*) from t1;
|
|
DROP TABLE t1;
|
|
|
|
SET sql_mode='';
|
|
CREATE TABLE t1 (v VECTOR (1) NOT NULL) ENGINE=CSV;
|
|
INSERT INTO t1 SELECT 1 away;
|
|
SELECT COUNT(*) from t1;
|
|
DELETE FROM a3,a1 USING t1 AS a1 JOIN t1 AS a2 JOIN t1 AS a3;
|
|
SELECT COUNT(*) from t1;
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # End 11.8 tests
|
|
--echo #
|