mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fixed bug in multiple-table-delete where some rows was not deleted
mysql-test/r/delete.result: Test case for bug in multiple-table-delete where some rows was not deleted mysql-test/t/delete.test: Test case for bug in multiple-table-delete where some rows was not deleted sql/item_subselect.cc: Code cleanup sql/opt_range.cc: Code cleanup sql/sql_delete.cc: Fixed bug in multiple-table-delete where some rows was not deleted This happend when the first table-to-delete-from was not the the table that was scanned. Fixed this by only doing 'delete-on-the-fly' for the first table. Fixed also some wrong error handling in multi-table-delete
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1,t11,t12,t2;
|
||||
drop table if exists t1,t2,t3,t11,t12;
|
||||
--enable_warnings
|
||||
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
|
||||
INSERT INTO t1 VALUES (1,1);
|
||||
@ -152,3 +152,20 @@ INSERT INTO t1 VALUES (0),(1),(2);
|
||||
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1;
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Test of multi-delete where we are not scanning the first table
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a int not null,b int not null);
|
||||
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
|
||||
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b));
|
||||
insert into t1 values (1,1),(2,1),(1,3);
|
||||
insert into t2 values (1,1),(2,2),(3,3);
|
||||
insert into t3 values (1,1),(2,1),(1,3);
|
||||
select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
|
||||
explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
|
||||
delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
|
||||
# This should be empty
|
||||
select * from t3;
|
||||
drop table t1,t2,t3;
|
||||
|
Reference in New Issue
Block a user