Details
-
Bug
-
Status: Stalled (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.3.27, 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11, 11.0(EOL), 11.1(EOL), 11.2(EOL)
-
None
-
Debian
Description
In this script, the ORDER BY AP.prio is not considered:
CREATE TABLE AP (
|
prid int not null,
|
prio int not null
|
);
|
|
CREATE TABLE APD (
|
prid int not null,
|
info varchar(64)
|
);
|
|
INSERT INTO AP VALUES (1,3), (2,3), (3,2), (4,2), (5,1), (6,1);
|
INSERT INTO APD (prid) VALUES (1), (2), (3), (4), (5), (6);
|
|
SELECT * FROM AP;
|
SELECT * FROM APD;
|
|
# The SELECT returns the correct values for prid (prid 3,5,6)
|
SELECT APD.prid, AP.prio FROM AP INNER JOIN APD ON AP.prid = APD.prid
|
ORDER BY AP.prio, AP.prid
|
LIMIT 3;
|
|
# The UPDATE with identical ORDER updates the columns with prid 1,2,3
|
UPDATE AP INNER JOIN APD ON AP.prid = APD.prid
|
SET info = 'UPDATED'
|
ORDER BY AP.prio, AP.prid
|
LIMIT 3;
|
|
SELECT * FROM APD;
|
The script returns this output:
+------+------+
|
| prid | prio |
|
+------+------+
|
| 1 | 3 |
|
| 2 | 3 |
|
| 3 | 2 |
|
| 4 | 2 |
|
| 5 | 1 |
|
| 6 | 1 |
|
+------+------+
|
6 rows in set (0.001 sec)
|
 |
+------+------+
|
| prid | info |
|
+------+------+
|
| 1 | NULL |
|
| 2 | NULL |
|
| 3 | NULL |
|
| 4 | NULL |
|
| 5 | NULL |
|
| 6 | NULL |
|
+------+------+
|
6 rows in set (0.000 sec)
|
 |
+------+------+
|
| prid | prio |
|
+------+------+
|
| 5 | 1 |
|
| 6 | 1 |
|
| 3 | 2 |
|
+------+------+
|
3 rows in set (0.000 sec)
|
 |
Query OK, 3 rows affected (0.001 sec)
|
Rows matched: 3 Changed: 3 Warnings: 0
|
 |
+------+---------+
|
| prid | info |
|
+------+---------+
|
| 1 | UPDATED |
|
| 2 | UPDATED |
|
| 3 | UPDATED |
|
| 4 | NULL |
|
| 5 | NULL |
|
| 6 | NULL |
|
+------+---------+
|
|
Attachments
Issue Links
- relates to
-
MDEV-13911 Support ORDER BY and LIMIT in multi-table update
- Closed
-
MDEV-31828 Multi-table update with `order by` gives wrong results
- Open