mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-30469 Support ORDER BY and LIMIT for multi-table DELETE, index hints for single-table DELETE
We now allow multitable queries with order by and limit, such as: delete t1.*, t2.* from t1, t2 order by t1.id desc limit 3; To predict what rows will be deleted, run the equivalent select: select t1.*, t2.* from t1, t2 order by t1.id desc limit 3; Additionally, index hints are now supported with single table delete statements: delete from t2 use index(xid) order by (id) limit 2; This approach changes the multi_delete SELECT result interceptor to use a temporary table to collect row ids pertaining to the rows that will be deleted, rather than directly deleting rows from the target table(s). Row ids are collected during send_data, then read during send_eof to delete target rows. In the event that the temporary table created in memory is not big enough for all matching rows, it is converted to an aria table. Other changes: - Deleting from a sequence now affects zero rows instead of emitting an error Limitations: - The federated connector does not create implicit row ids, so we to use a key when conditionally deleting. See the change in federated_maybe_16324629.test
This commit is contained in:
@ -202,11 +202,8 @@ CREATE SEQUENCE s;
|
||||
CREATE table t1 (a int);
|
||||
insert into t1 values (1),(2);
|
||||
DELETE s FROM s;
|
||||
ERROR HY000: Storage engine SEQUENCE of the table `test`.`s` doesn't have this option
|
||||
delete t1,s from s,t1;
|
||||
ERROR HY000: Storage engine SEQUENCE of the table `test`.`s` doesn't have this option
|
||||
delete s,t1 from t1,s;
|
||||
ERROR HY000: Storage engine SEQUENCE of the table `test`.`s` doesn't have this option
|
||||
DROP SEQUENCE s;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -177,11 +177,8 @@ drop sequence s1;
|
||||
CREATE SEQUENCE s;
|
||||
CREATE table t1 (a int);
|
||||
insert into t1 values (1),(2);
|
||||
--error ER_ILLEGAL_HA
|
||||
DELETE s FROM s;
|
||||
--error ER_ILLEGAL_HA
|
||||
delete t1,s from s,t1;
|
||||
--error ER_ILLEGAL_HA
|
||||
delete s,t1 from t1,s;
|
||||
DROP SEQUENCE s;
|
||||
DROP TABLE t1;
|
||||
|
Reference in New Issue
Block a user