Commit 2d2697ea authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-6221 SQL_CALC_FOUND_ROWS yields wrong result again

replace another old "was there a filesort?" test with
a correct "did filesort calculate found_rows?" test.
parent fde6ee61
......@@ -315,3 +315,20 @@ select found_rows();
found_rows()
128
drop table t1, t2;
create table t1 (i1 int, v1 int, primary key(i1,v1));
insert into t1 values (1,1),(2,2),(3,3);
create table t2 (i2 int primary key, v2 int);
insert into t2 values (1,5),(2,5),(3,10);
select 1 as res from t1 left join t2 on i1 = i2 where v2 = 5 or v1 = 5 or v1 = 10 order by v1;
res
1
1
select sql_calc_found_rows 1 as res from t1 left join t2 on i1 = i2 where v2 = 5 or v1 = 5 or v1 = 10 order by v1 limit 1;
select found_rows() as count;
count
2
select sql_calc_found_rows 1 as res from t1 left join t2 on i1 = i2 where v2 = 5 order by v1 limit 1;
select found_rows() as count;
count
2
drop table t1, t2;
......@@ -241,3 +241,19 @@ select found_rows();
drop table t1, t2;
#
# MDEV-6221 SQL_CALC_FOUND_ROWS yields wrong result again
#
create table t1 (i1 int, v1 int, primary key(i1,v1));
insert into t1 values (1,1),(2,2),(3,3);
create table t2 (i2 int primary key, v2 int);
insert into t2 values (1,5),(2,5),(3,10);
select 1 as res from t1 left join t2 on i1 = i2 where v2 = 5 or v1 = 5 or v1 = 10 order by v1;
--disable_result_log ONCE
select sql_calc_found_rows 1 as res from t1 left join t2 on i1 = i2 where v2 = 5 or v1 = 5 or v1 = 10 order by v1 limit 1;
select found_rows() as count;
--disable_result_log ONCE
select sql_calc_found_rows 1 as res from t1 left join t2 on i1 = i2 where v2 = 5 order by v1 limit 1;
select found_rows() as count;
drop table t1, t2;
......@@ -18724,8 +18724,7 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
TABLE *table=jt->table;
join->select_options ^= OPTION_FOUND_ROWS;
if (table->sort.record_pointers ||
(table->sort.io_cache && my_b_inited(table->sort.io_cache)))
if (join->filesort_found_rows)
{
/* Using filesort */
join->send_records= table->sort.found_records;
......
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