diff options
author | igor@olga.mysql.com <> | 2006-07-14 19:28:58 -0700 |
---|---|---|
committer | igor@olga.mysql.com <> | 2006-07-14 19:28:58 -0700 |
commit | 4de3186ae181dee1b0efaa8ae9b76382949558f5 (patch) | |
tree | 374e1718ebb7cdfde2a51621ae6fdb8270508025 /mysql-test/t/subselect.test | |
parent | 10b2590c0b8a0d766f1b15330f3d9681aa41f9aa (diff) | |
download | mariadb-git-4de3186ae181dee1b0efaa8ae9b76382949558f5.tar.gz |
Fixed bug #20519.
The bug was due to a loss happened during a refactoring made
on May 30 2005 that modified the function JOIN::reinit.
As a result of it for any subquery the value of offset_limit_cnt
was not restored for the following executions. Yet the first
execution of the subquery made it equal to 0.
The fix restores this value in the function JOIN::reinit.
Diffstat (limited to 'mysql-test/t/subselect.test')
-rw-r--r-- | mysql-test/t/subselect.test | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 9fc4f8a8d4e..310adcc5323 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2161,3 +2161,43 @@ SELECT t1.i FROM t1 WHERE t1.i = CAST((SELECT MAX(i) FROM t2) AS UNSIGNED); DROP TABLE t1; DROP TABLE t2; + +# +# Bug#20519: subselect with LIMIT M, N +# + +CREATE TABLE t1 ( + id bigint(20) unsigned NOT NULL auto_increment, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); +INSERT INTO t1 VALUES + (1, 'Balazs'), (2, 'Joe'), (3, 'Frank'); + +CREATE TABLE t2 ( + id bigint(20) unsigned NOT NULL auto_increment, + mid bigint(20) unsigned NOT NULL, + date date NOT NULL, + PRIMARY KEY (id) +); +INSERT INTO t2 VALUES + (1, 1, '2006-03-30'), (2, 2, '2006-04-06'), (3, 3, '2006-04-13'), + (4, 2, '2006-04-20'), (5, 1, '2006-05-01'); + +SELECT *, + (SELECT date FROM t2 WHERE mid = t1.id + ORDER BY date DESC LIMIT 0, 1) AS date_last, + (SELECT date FROM t2 WHERE mid = t1.id + ORDER BY date DESC LIMIT 3, 1) AS date_next_to_last + FROM t1; +SELECT *, + (SELECT COUNT(*) FROM t2 WHERE mid = t1.id + ORDER BY date DESC LIMIT 1, 1) AS date_count + FROM t1; +SELECT *, + (SELECT date FROM t2 WHERE mid = t1.id + ORDER BY date DESC LIMIT 0, 1) AS date_last, + (SELECT date FROM t2 WHERE mid = t1.id + ORDER BY date DESC LIMIT 1, 1) AS date_next_to_last + FROM t1; +DROP TABLE t1,t2; |