summaryrefslogtreecommitdiff
path: root/sql/filesort.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2015-01-19 14:18:44 +0100
committerSergei Golubchik <sergii@pisem.net>2015-01-19 14:18:44 +0100
commit47c844f236fc7e9f6065ba4332facea6b51fe26e (patch)
tree7a4a70cf84dca76777696a8636b7f2a091b30c3d /sql/filesort.cc
parentce0ed977d51e4621fbb241ea7f231ee35db48b39 (diff)
downloadmariadb-git-47c844f236fc7e9f6065ba4332facea6b51fe26e.tar.gz
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.
Diffstat (limited to 'sql/filesort.cc')
-rw-r--r--sql/filesort.cc13
1 files changed, 3 insertions, 10 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 509a7f8e9b3..027437fca67 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -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();
}