mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-12779 Oracle/DB2 Compatibility Implicit Ordering for ROW_NUMBER OVER
Users expect window functions to produce a certain ordering of rows in the final result set. Although the standard does not require this, we already have the filesort result done for when we computed the window function. If there is no ORDER BY attached to the query, just keep it till the SELECT is completely evaluated and use that to print the result. Update test cases as many did not take care to guarantee a stable result.
This commit is contained in:
@ -26649,9 +26649,10 @@ AGGR_OP::end_send()
|
||||
|
||||
// Update ref array
|
||||
join_tab->join->set_items_ref_array(*join_tab->ref_array);
|
||||
bool keep_last_filesort_result = join_tab->filesort ? false : true;
|
||||
if (join_tab->window_funcs_step)
|
||||
{
|
||||
if (join_tab->window_funcs_step->exec(join))
|
||||
if (join_tab->window_funcs_step->exec(join, keep_last_filesort_result))
|
||||
return NESTED_LOOP_ERROR;
|
||||
}
|
||||
|
||||
@ -26705,6 +26706,12 @@ AGGR_OP::end_send()
|
||||
}
|
||||
}
|
||||
|
||||
if (keep_last_filesort_result)
|
||||
{
|
||||
delete join_tab->filesort_result;
|
||||
join_tab->filesort_result= NULL;
|
||||
}
|
||||
|
||||
// Finish rnd scn after sending records
|
||||
if (join_tab->table->file->inited)
|
||||
join_tab->table->file->ha_rnd_end();
|
||||
|
Reference in New Issue
Block a user