diff options
Diffstat (limited to 'mysql-test/t/select_found.test')
-rw-r--r-- | mysql-test/t/select_found.test | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test index e043ec4d143..33613697722 100644 --- a/mysql-test/t/select_found.test +++ b/mysql-test/t/select_found.test @@ -195,3 +195,95 @@ SELECT FOUND_ROWS(); DROP TABLE t1; # End of 4.1 tests + +# +# MDEV-5549 Wrong row counter in found_rows() result +# +create table t1 (f1 int primary key, f2 tinyint) engine=myisam; +insert t1 values (10,3),(11,2),(12,3); +create table t2 (f3 int primary key) engine=myisam; +insert t2 values (11),(12),(13); +#explain select f1 from t1,t2 where f1=f3 and f2=3 order by f1; +select f1 from t1,t2 where f1=f3 and f2=3 order by f1; +select found_rows(); +drop table t1, t2; + +# +# MDEV-5898 FOUND_ROWS() return incorrect value when using DISTINCT +# +create table t1 (a1 int auto_increment primary key, c1 int); + +insert t1 (a1) values (null); +insert t1 (a1) select null from t1; +insert t1 (a1) select null from t1; +insert t1 (a1) select null from t1; +insert t1 (a1) select null from t1; +insert t1 (a1) select null from t1; +insert t1 (a1) select null from t1; +insert t1 (a1) select null from t1; +insert t1 (a1) select null from t1; +insert t1 (a1) select null from t1; +update t1 set c1=a1 % 2; + +create table t2 (a2 int, b2 int, c2 char(16) default '', primary key (a2, b2)); + +insert t2 select a1, 1, 'ok' from t1; +insert t2 select a1, 2, 'ko' from t1; +insert t2 select a1, 3, 'ko' from t1; +insert t2 select a1, 4, 'ok' from t1; +insert t2 select a1, 5, 'ok' from t1; + +--disable_result_log ONCE +select sql_calc_found_rows distinct a1,c2 from t1 join t2 on a2=a1 + where a1 <= 256 and c1=0 and c2='ok' order by a1 desc limit 46; + +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; + +# +# MDEV-7219 SQL_CALC_FOUND_ROWS yields wrong result +# +create table t1 (i int, v varchar(64), key (i)); + +--disable_query_log +let $1=150; +while ($1) +{ + eval insert into t1 values ($1 % 2, 'foo'); + dec $1; +} +--enable_query_log + +select sql_calc_found_rows * from t1 where i = 0 order by v limit 59,2; +select found_rows(); +select sql_calc_found_rows * from t1 ignore index (i) where i = 0 order by v limit 59,2; +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; |