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
This commit is contained in:
parent
38b89a61c3
commit
9630eda0de
@ -348,3 +348,18 @@ select found_rows();
|
|||||||
found_rows()
|
found_rows()
|
||||||
75
|
75
|
||||||
drop table t1;
|
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();
|
select found_rows();
|
||||||
drop table t1;
|
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,
|
select, filesort_limit, 0,
|
||||||
&examined_rows, &found_rows);
|
&examined_rows, &found_rows);
|
||||||
table->sort.found_records= filesort_retval;
|
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)
|
if (quick_created)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user