summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect.test
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2010-04-28 14:52:24 +0200
committerunknown <knielsen@knielsen-hq.org>2010-04-28 14:52:24 +0200
commitb1e00b6be81c80b09d11085d77d86978e26df988 (patch)
treebb1fdd7363fbf2580572ac9a56dbd4c933cc4c0d /mysql-test/t/subselect.test
parent1f683a7270e63abfadce20c6f51370621ff065e1 (diff)
parentc9cfd2df5f2f58c2cdf716999ebea252c307333f (diff)
downloadmariadb-git-b1e00b6be81c80b09d11085d77d86978e26df988.tar.gz
Merge MySQL 5.1.46 into MariaDB.
Still two test failures to be solved: main.myisam and main.subselect.
Diffstat (limited to 'mysql-test/t/subselect.test')
-rw-r--r--mysql-test/t/subselect.test100
1 files changed, 100 insertions, 0 deletions
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index faaa42f8461..ffbd56c198d 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -3610,4 +3610,104 @@ SELECT 1 FROM t1 WHERE a <> SOME
);
DROP TABLE t1;
+--echo #
+--echo # Bug #45989 take 2 : memory leak after explain encounters an
+--echo # error in the query
+--echo #
+
+CREATE TABLE t1(a LONGTEXT);
+INSERT INTO t1 VALUES (repeat('a',@@global.max_allowed_packet));
+INSERT INTO t1 VALUES (repeat('b',@@global.max_allowed_packet));
+
+--error ER_BAD_FIELD_ERROR
+EXPLAIN EXTENDED SELECT DISTINCT 1 FROM t1,
+(SELECT DISTINCTROW a AS away FROM t1 GROUP BY a WITH ROLLUP) AS d1
+WHERE t1.a = d1.a;
+
+DROP TABLE t1;
+
+
--echo End of 5.1 tests.
+
+#
+# Bug #47904 Incorrect results w/ table subquery, derived SQs, and LEFT JOIN on index
+#
+
+--echo Set up test tables.
+CREATE TABLE t1 (
+ t1_id INT UNSIGNED,
+
+ PRIMARY KEY(t1_id)
+) Engine=MyISAM;
+
+INSERT INTO t1 (t1_id) VALUES (1), (2), (3), (4), (5);
+
+CREATE TABLE t2 SELECT * FROM t1;
+
+CREATE TABLE t3 (
+ t3_id INT UNSIGNED AUTO_INCREMENT,
+ t1_id INT UNSIGNED,
+ amount DECIMAL(16,2),
+
+ PRIMARY KEY(t3_id),
+ KEY(t1_id)
+) Engine=MyISAM;
+
+INSERT INTO t3 (t1_id, t3_id, amount)
+ VALUES (1, 1, 100.00), (2, 2, 200.00), (4, 4, 400.00);
+
+--echo This is the 'inner query' running by itself.
+--echo Produces correct results.
+SELECT
+ t1.t1_id,
+ IFNULL((SELECT SUM(amount) FROM t3 WHERE t3.t1_id=t1.t1_id), 0) AS total_amount
+FROM
+ t1
+ LEFT JOIN t2 ON t2.t1_id=t1.t1_id
+GROUP BY
+ t1.t1_id
+;
+
+--echo SELECT * FROM (the same inner query)
+--echo Produces correct results.
+SELECT * FROM (
+SELECT
+ t1.t1_id,
+ IFNULL((SELECT SUM(amount) FROM t3 WHERE t3.t1_id=t1.t1_id), 0) AS total_amount
+FROM
+ t1
+ LEFT JOIN t2 ON t2.t1_id=t1.t1_id
+GROUP BY
+ t1.t1_id
+) AS t;
+
+--echo Now make t2.t1_id part of a key.
+ALTER TABLE t2 ADD PRIMARY KEY(t1_id);
+
+--echo Same inner query by itself.
+--echo Still correct results.
+SELECT
+ t1.t1_id,
+ IFNULL((SELECT SUM(amount) FROM t3 WHERE t3.t1_id=t1.t1_id), 0) AS total_amount
+FROM
+ t1
+ LEFT JOIN t2 ON t2.t1_id=t1.t1_id
+GROUP BY
+ t1.t1_id;
+
+--echo SELECT * FROM (the same inner query), now with indexes on the LEFT JOIN
+SELECT * FROM (
+SELECT
+ t1.t1_id,
+ IFNULL((SELECT SUM(amount) FROM t3 WHERE t3.t1_id=t1.t1_id), 0) AS total_amount
+FROM
+ t1
+ LEFT JOIN t2 ON t2.t1_id=t1.t1_id
+GROUP BY
+ t1.t1_id
+) AS t;
+
+
+DROP TABLE t3;
+DROP TABLE t2;
+DROP TABLE t1;