[MDEV-26909] ROW_NUMBER and DELETE/UPDATE with ORDER BY Created: 2021-10-26  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: Data Manipulation - Delete, Data Manipulation - Update
Affects Version/s: 10.7
Fix Version/s: 10.11

Type: Bug Priority: Minor
Reporter: Sergei Golubchik Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-10075 Provide index of error causing error ... Closed
Relates
relates to MDEV-26844 DELETE returns ROW_NUMBER=1 for every... Closed

 Description   

create or replace table t (a varchar(8));
insert into t values ('val1'),('val2'),('100'),('val4');
delete from t where a = 100 order by a;
get diagnostics condition 3 @n = row_number;
select @n;

returns 0.

It gets even more confusing with UPDATE

CREATE TABLE t (a VARCHAR(8), b tinyint);
INSERT INTO t(a) VALUES ('val1'),('val2'),('100'),('val4'),('100');
SELECT * FROM t;
set sql_mode='';
UPDATE t SET b=1234 WHERE a = 100 ORDER BY a;
GET DIAGNOSTICS CONDITION 2 @n2 = ROW_NUMBER;
GET DIAGNOSTICS CONDITION 5 @n5 = ROW_NUMBER;
SELECT @n2, @n5;

shows 2, 2. That is, both second and fifth warnings are claimed to have happened on the second row. But they actually have happened on different "second rows".


Generated at Thu Feb 08 09:48:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.