diff options
author | unknown <bell@laptop.sanja.is.com.ua> | 2003-10-06 20:55:06 +0300 |
---|---|---|
committer | unknown <bell@laptop.sanja.is.com.ua> | 2003-10-06 20:55:06 +0300 |
commit | ff8c8fa1efc4a622e571381c34c5a4575d0f3b5e (patch) | |
tree | f658418875ab7ed1c8c3198dc5135387bf23a7a6 /mysql-test/t/union.test | |
parent | 12b769418af82303239d43447def128ed933b440 (diff) | |
parent | 6fc8b48c4652d404b38146844d17ed2a01a3b327 (diff) | |
download | mariadb-git-ff8c8fa1efc4a622e571381c34c5a4575d0f3b5e.tar.gz |
Merge
mysql-test/r/union.result:
Auto merged
mysql-test/t/union.test:
Auto merged
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_cmpfunc.h:
Auto merged
sql/item_subselect.cc:
Auto merged
sql/item_subselect.h:
Auto merged
sql/item_sum.cc:
Auto merged
sql/item_sum.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_derived.cc:
Auto merged
sql/sql_union.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/subselect.result:
SCCS merged
mysql-test/t/subselect.test:
SCCS merged
Diffstat (limited to 'mysql-test/t/union.test')
-rw-r--r-- | mysql-test/t/union.test | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 8f49f56b991..b64f0b4e2ee 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -194,6 +194,62 @@ select * from t4; drop table t1,t2,t3,t4; # +# Test of SQL_CALC_FOUND_ROW handling +# +create table t1 (a int); +insert into t1 values (1),(2),(3); +create table t2 (a int); +insert into t2 values (3),(4),(5); + +# Test global limits +(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2) LIMIT 1; +select found_rows(); +(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2) LIMIT 2; +select found_rows(); + +# Test cases where found_rows() should return number of returned rows +(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2); +select found_rows(); +(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1); +select found_rows(); +# This used to work in 4.0 but not anymore in 4.1 +--error 1149 +(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1; +#select found_rows(); + +# In these case found_rows() should work +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION all SELECT * FROM t2 LIMIT 2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION all SELECT * FROM t2 LIMIT 2; +select found_rows(); + +# The following examples will not be exact +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 100; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 100 UNION SELECT * FROM t2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION SELECT * FROM t2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION SELECT * FROM t2 LIMIT 2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2,2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 limit 2,2 UNION SELECT * FROM t2; +select found_rows(); + +# Test some limits with ORDER BY +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1; +(SELECT * FROM t1 ORDER by a) UNION ALL (SELECT * FROM t2 ORDER BY a) ORDER BY A desc LIMIT 4; + +# Wrong usage +--error 1234 +(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1; + +drop table t1,t2; + +# # Test for another bug with UNION and LEFT JOIN # CREATE TABLE t1 ( id int(3) unsigned default '0') TYPE=MyISAM; |