parser icon indicating copy to clipboard operation
parser copied to clipboard

Support the SQL:2008 Standard `OFFSET m ROWS FETCH FIRST n ROWS` clause

Open kennytm opened this issue 4 years ago • 2 comments

Feature Request

Is your feature request related to a problem? Please describe:

SQL:2008 introduced the FETCH FIRST clause to unify the LIMIT feature with varying syntax among all RDBMS (CD 9075-2:201X §7.16/6–7). This feature is supported in PostgreSQL, DB2 and Oracle. Users migrating from outside MySQL may find it more natural to use the standard syntax than LIMIT. (see also https://bugs.mysql.com/bug.php?id=78929.)

Describe the feature you'd like:

Parse the clause:

[ OFFSET m { ROW | ROWS } ]
[ FETCH { FIRST | NEXT } [ n ] { ROW | ROWS } ONLY ]

as equivalent to

LIMIT n OFFSET m

(if n is missing it default to 1)

(FIRST and NEXT are synonyms)

Describe alternatives you've considered:

Don't support it.

Teachability, Documentation, Adoption, Migration Strategy:

kennytm avatar Aug 14 '20 06:08 kennytm

Sounds an interesting feature :)

bb7133 avatar Aug 18 '20 09:08 bb7133

After discussion with kennytm, I'll only support FETCH { FIRST | NEXT } [ n ] { ROW | ROWS } ONLY part in #985 for now because it seems very complicated to support the [ OFFSET m { ROW | ROWS } ] part.

time-and-fate avatar Aug 27 '20 07:08 time-and-fate