-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDEV-30469 Support ORDER BY and LIMIT for multi-table DELETE, index h… #3660
base: main
Are you sure you want to change the base?
Conversation
|
Please explain why? I thought its result would be always "N rows deleted" (where N can be 0). What did change with this patch? |
d1dc3c2
to
f228b06
Compare
My change was incorrect. Sanja explained to me what to do on the MDEV, so I fixed my code accordingly. |
f228b06
to
ce280a2
Compare
ce280a2
to
5245b5b
Compare
…ints for single-table DELETE This patch includes a few changes to make the code easier to maintain: - Renamed SQL_I_List::link_in_list to SQL_I_List::insert. link_in_list was ambiguous as it could refer to a link or it could refer to a node - Remove field_name local variable in multi_update::initialize_tables because it is not used when creating the temporary tables - multi_update changes: - Move temp table callocs to init, a more natural location for them, and moved tables_to_update to const member variable so we don't recompute it. - Filter out jtbm tables and tables not in the update map, pushing those that will be updated into an update_targets container. This simplifies checks and loops in initialize_tables.
…ints 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. 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
5245b5b
to
f20608b
Compare
…ints 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.
This patch includes a number of changes that begin to make the code easier to maintain
Other changes:
Limitations: