mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-7219 SQL_CALC_FOUND_ROWS yields wrong result
revert the code in filesort that conditionally updated 'found_rows', rely on filesort_limit_arg instead.
This commit is contained in:
@ -166,8 +166,6 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
TABLE_LIST *tab= table->pos_in_table_list;
|
||||
Item_subselect *subselect= tab ? tab->containing_subselect() : 0;
|
||||
|
||||
*found_rows= HA_POS_ERROR;
|
||||
|
||||
MYSQL_FILESORT_START(table->s->db.str, table->s->table_name.str);
|
||||
DEBUG_SYNC(thd, "filesort_start");
|
||||
|
||||
@ -190,6 +188,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
my_b_clear(&buffpek_pointers);
|
||||
buffpek=0;
|
||||
error= 1;
|
||||
*found_rows= HA_POS_ERROR;
|
||||
|
||||
param.init_for_filesort(sortlength(thd, sortorder, s_length,
|
||||
&multi_byte_charset),
|
||||
@ -690,8 +689,7 @@ static ha_rows find_all_keys(Sort_param *param, SQL_SELECT *select,
|
||||
ref_pos= ref_buff;
|
||||
quick_select=select && select->quick;
|
||||
record=0;
|
||||
if (pq) // don't count unless pq is used
|
||||
*found_rows= 0;
|
||||
*found_rows= 0;
|
||||
flag= ((file->ha_table_flags() & HA_REC_NOT_IN_SEQ) || quick_select);
|
||||
if (flag)
|
||||
ref_pos= &file->ref[0];
|
||||
@ -814,14 +812,9 @@ static ha_rows find_all_keys(Sort_param *param, SQL_SELECT *select,
|
||||
|
||||
if (write_record)
|
||||
{
|
||||
++(*found_rows);
|
||||
if (pq)
|
||||
{
|
||||
/*
|
||||
only count rows when pq is used - otherwise there might be
|
||||
other filters *after* the filesort, we don't know the final row
|
||||
count here
|
||||
*/
|
||||
(*found_rows)++;
|
||||
pq->push(ref_pos);
|
||||
idx= pq->num_elements();
|
||||
}
|
||||
|
Reference in New Issue
Block a user