Commit 9630eda0 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-9390 Function found_rows() gives incorrect result where the previous...

MDEV-9390 Function found_rows() gives incorrect result where the previous SELECT contains ORDER BY clause

use the raw found_rows value only when SQL_CALC_FOUND_ROWS was specified
parent 38b89a61
......@@ -348,3 +348,18 @@ select found_rows();
found_rows()
75
drop table t1;
create table t1(c1 int);
insert into t1 values(1),(2),(3),(4),(5);
select * from t1 order by c1 limit 2,1;
c1
3
select found_rows();
found_rows()
3
select sql_calc_found_rows * from t1 order by c1 limit 2,1;
c1
3
select found_rows();
found_rows()
5
drop table t1;
......@@ -277,3 +277,13 @@ select sql_calc_found_rows * from t1 ignore index (i) where i = 0 order by v lim
select found_rows();
drop table t1;
#
# MDEV-9390 Function found_rows() gives incorrect result where the previous SELECT contains ORDER BY clause
#
create table t1(c1 int);
insert into t1 values(1),(2),(3),(4),(5);
select * from t1 order by c1 limit 2,1;
select found_rows();
select sql_calc_found_rows * from t1 order by c1 limit 2,1;
select found_rows();
drop table t1;
......@@ -20813,7 +20813,7 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
select, filesort_limit, 0,
&examined_rows, &found_rows);
table->sort.found_records= filesort_retval;
tab->records= found_rows; // For SQL_CALC_ROWS
tab->records= join->select_options & OPTION_FOUND_ROWS ? found_rows : filesort_retval;
if (quick_created)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment