From 26ff92f7ac2dc373769b8053e936e4593a2ee302 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 26 Sep 2017 10:28:00 +0200 Subject: MDEV-13911 Support ORDER BY and LIMIT in multi-table update --- mysql-test/r/multi_update.result | 27 +++++++++++++++++++++++++++ mysql-test/t/multi_update.test | 14 ++++++++++++++ 2 files changed, 41 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index 2a0a6677c6f..339dc35e9c4 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -942,3 +942,30 @@ deallocate prepare stmt1; drop view v3,v2,v1; drop table t1,t2,t3; end of 5.5 tests +create table t1 (c1 int, c3 int); +insert t1(c3) values (1), (2), (3), (4), (5), (6), (7), (8); +create table t2 select * from t1; +update t1, t2 set t1.c1=t2.c3 where t1.c3=t2.c3 order by t1.c3 limit 3; +select * from t1; +c1 c3 +1 1 +2 2 +3 3 +NULL 4 +NULL 5 +NULL 6 +NULL 7 +NULL 8 +update t1 set c1=NULL; +update t1, t2 set t1.c1=t2.c3 where t1.c3=t2.c3 order by t1.c3 desc limit 2; +select * from t1; +c1 c3 +NULL 1 +NULL 2 +NULL 3 +NULL 4 +NULL 5 +NULL 6 +7 7 +8 8 +drop table t1, t2; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 0a7e6b221eb..bd5d7a9768c 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -901,3 +901,17 @@ deallocate prepare stmt1; drop view v3,v2,v1; drop table t1,t2,t3; --echo end of 5.5 tests + +# +# MDEV-13911 Support ORDER BY and LIMIT in multi-table update +# + +create table t1 (c1 int, c3 int); +insert t1(c3) values (1), (2), (3), (4), (5), (6), (7), (8); +create table t2 select * from t1; +update t1, t2 set t1.c1=t2.c3 where t1.c3=t2.c3 order by t1.c3 limit 3; +select * from t1; +update t1 set c1=NULL; +update t1, t2 set t1.c1=t2.c3 where t1.c3=t2.c3 order by t1.c3 desc limit 2; +select * from t1; +drop table t1, t2; -- cgit v1.2.1