summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect4.test
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2010-12-02 21:54:40 +0200
committerunknown <timour@askmonty.org>2010-12-02 21:54:40 +0200
commit620aea4fde7d40f3870bebdcfd66d2b0b556db2f (patch)
tree5c288f309731af09ad66a281b33039d1ca88f5c4 /mysql-test/t/subselect4.test
parent1b3336dc30cf97283cca6071f089df992c425eb2 (diff)
downloadmariadb-git-620aea4fde7d40f3870bebdcfd66d2b0b556db2f.tar.gz
Fix LP BUG#682683
Analysis: The fix for LP BUG#680846 avoids evaluation of constant expressions with subqueries in the GROUP/ORDER clauses in the procedure remove_const(). The purpose of remove_const is to remove constant expressions in the GROUP/ORDER clauses. In order delay until execution the evaluation of such subqueries, they were not removed in the GROUP/ORDER clause. As a result temp table creation during execution attempted to create a column in the temp table for each constant GROUP/ORDER expression. However, the logic in create_tmp_table is to not create temp table columns for constant items. The crash was due to a group Item without a corresponding column in the temp table for GROUP BY. Solution: The patch adds back removal of constant expressions with subqueries. In order for such expressions to be evaluated, so that the server can ensure that such subquries return 1 row, the evaluation of these expressions is delayed until execution.
Diffstat (limited to 'mysql-test/t/subselect4.test')
-rw-r--r--mysql-test/t/subselect4.test30
1 files changed, 30 insertions, 0 deletions
diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test
index fea5d8a2106..cc183db8d87 100644
--- a/mysql-test/t/subselect4.test
+++ b/mysql-test/t/subselect4.test
@@ -559,6 +559,36 @@ ORDER BY f9;
drop table t1,t2;
--echo #
+--echo # LP BUG#682683 Crash in create_tmp_table called from
+--echo # JOIN::init_execution
+--echo #
+
+CREATE TABLE t2 (f1 int) ;
+INSERT INTO t2 VALUES (1),(2);
+
+CREATE TABLE t1 (f1 int) ;
+
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+
+INSERT INTO t1 VALUES (1),(2);
+
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+--error ER_SUBQUERY_NO_1_ROW
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+--error ER_SUBQUERY_NO_1_ROW
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+
+drop table t1,t2;
+
+--echo #
--echo # LP BUG#680943 Assertion `!table || (!table->read_set ||
--echo # bitmap_is_set(table->read_set, field_index))' failed with subquery
--echo #