Window Functions final ordering of result set (MDEV-10879)

[MDEV-12779] Oracle/DB2 Compatibility Implicit Ordering for ROW_NUMBER OVER Created: 2017-05-11  Updated: 2020-08-25  Resolved: 2018-11-01

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Affects Version/s: 10.2
Fix Version/s: 10.3.11, 10.2.19

Type: Technical task Priority: Critical
Reporter: Chris Calender (Inactive) Assignee: Vicențiu Ciorbaru
Resolution: Fixed Votes: 2
Labels: None

Issue Links:
Relates
relates to MDEV-12743 Wrong results with ROW_NUMBER OVER Closed

 Description   

Feature request for Oracle/DB2 migration compatibility:

We are using the window function "ROW_NUMBER() OVER()" to generate the row sequence number required for pagination across the pages. For example:

SELECT ROW_NUMBER() OVER() as RN, COL1, COL2 FROM MYTABLE;

Since there is no expression given in the OVER() clause, DB2 will just assign sequential numbers to the output. The column RN returned from the query will have numbers in perfect order.

However, MariaDB does not guarantee the numbers in order without an explicit ORDER BY.

This will require query re-writing in order to migrate.



 Comments   
Comment by Sergei Petrunia [ 2017-05-11 ]

(I assume "ROW_NUMBER() ORDER()" had a typo, changed it to be "ROW_NUMBER() OVER()" )

Comment by Vicențiu Ciorbaru [ 2018-11-01 ]

Window Functions will now force the result set to use the last ordering that the server used to compute their values. This only happens if there is no specific ORDER BY for the SELECT statement.

Generated at Thu Feb 08 08:00:24 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.