mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-23908: Implement SELECT ... OFFSET ... FETCH ...
This commit implements the standard SQL extension OFFSET start { ROW | ROWS } [FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES }] To achieve this a reserved keyword OFFSET is introduced. The general logic for WITH TIES implies: 1. The number of rows a query returns is no longer known during optimize phase. Adjust optimizations to no longer consider this. 2. During end_send make use of an "order Cached_item"to compare if the ORDER BY columns changed. Keep returning rows until there is a change. This happens only after we reached the row limit. 3. Within end_send_group, the order by clause was eliminated. It is still possible to keep the optimization of using end_send_group for producing the final result set.
This commit is contained in:
@ -826,11 +826,13 @@ class Lex_select_limit
|
||||
public:
|
||||
/* explicit LIMIT clause was used */
|
||||
bool explicit_limit;
|
||||
bool with_ties;
|
||||
Item *select_limit, *offset_limit;
|
||||
|
||||
void clear()
|
||||
{
|
||||
explicit_limit= FALSE; // No explicit limit given by user
|
||||
with_ties= FALSE; // No use of WITH TIES operator
|
||||
select_limit= NULL; // denotes the default limit = HA_POS_ERROR
|
||||
offset_limit= NULL; // denotes the default offset = 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user