mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-25441 WITH TIES is not respected with SQL_BUFFER_RESULT and constant in ORDER BY
Pushing LIMIT to temp aggregation table is possible, but not when WITH TIES is used. In a degenerate case with constant ORDER BY, the constant gets removed and the code assumed the limit is push-able. Ensure that if WITH TIES is present, that this does not happen.
This commit is contained in:
@ -3856,10 +3856,16 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
|
||||
when there is ORDER BY or GROUP BY or there is no GROUP BY, but
|
||||
there are aggregate functions, because in all these cases we need
|
||||
all result rows.
|
||||
|
||||
We also can not push limit if the limit is WITH TIES, as we do not know
|
||||
how many rows we will actually have. This can happen if ORDER BY was
|
||||
a constant and removed (during remove_const), thus we have an "unlimited"
|
||||
WITH TIES.
|
||||
*/
|
||||
ha_rows table_rows_limit= ((order == NULL || skip_sort_order) &&
|
||||
!table_group &&
|
||||
!select_lex->with_sum_func) ? select_limit
|
||||
!select_lex->with_sum_func &&
|
||||
!unit->lim.is_with_ties()) ? select_limit
|
||||
: HA_POS_ERROR;
|
||||
|
||||
if (!(tab->tmp_table_param= new TMP_TABLE_PARAM(tmp_table_param)))
|
||||
|
Reference in New Issue
Block a user