mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
b6fe4713fe
mysql-test/r/group_by.result: Added test that showed problems that no_rows_in_results() didn't work for expressions mysql-test/r/subselect4.result: Test case for LP#612894 mysql-test/t/group_by.test: Added test that showed problems that no_rows_in_results() didn't work for expressions mysql-test/t/subselect4.test: Test case for LP#612894 sql/item.h: Added restore_to_before_no_rows_in_result() Added function processor for no_rows_in_results() and restore_to_before_no_rows_in_results() to ensure it works with functions Fix that above functions are handled by Item_ref() sql/item_func.h: Ensure that no_rows_in_results() and restore_to_before_no_rows_in_result() are called for all function arguments sql/item_sum.cc: Added restore_to_before_no_rows_in_result() to restore settings after Item_sum_hybrid::no_rows_in_result() was called. This is needed to handle the case where we have made 'make_const()' on the item in opt_sum(), but the item will be reused again in a sub query. Ignore multiple calls to no_rows_in_result() as Item_ref is calling it twice. sql/item_sum.h: Added restore_to_before_no_rows_in_result(); sql/sql_select.cc: Added reset of no_rows_in_result() for JOIN::reinit() sql/sql_select.h: Added marker if no_rows_in_result() is called.
90 lines
2.4 KiB
Text
90 lines
2.4 KiB
Text
# General purpose bug fix tests go here : subselect.test too large
|
|
|
|
|
|
--echo #
|
|
--echo # Bug #46791: Assertion failed:(table->key_read==0),function unknown
|
|
--echo # function,file sql_base.cc
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (a INT, b INT, KEY(a));
|
|
INSERT INTO t1 VALUES (1,1),(2,2);
|
|
CREATE TABLE t2 LIKE t1;
|
|
INSERT INTO t2 VALUES (1,1),(2,2);
|
|
CREATE TABLE t3 LIKE t1;
|
|
|
|
--echo # should have 1 impossible where and 2 dependent subqueries
|
|
EXPLAIN
|
|
SELECT 1 FROM t1
|
|
WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3))
|
|
ORDER BY count(*);
|
|
|
|
--echo # should not crash the next statement
|
|
SELECT 1 FROM t1
|
|
WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3))
|
|
ORDER BY count(*);
|
|
|
|
--echo # should not crash: the crash is caused by the previous statement
|
|
SELECT 1;
|
|
|
|
DROP TABLE t1,t2,t3;
|
|
|
|
--echo #
|
|
--echo # Bug #47106: Crash / segfault on adding EXPLAIN to a non-crashing
|
|
--echo # query
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (
|
|
a INT,
|
|
b INT,
|
|
PRIMARY KEY (a),
|
|
KEY b (b)
|
|
);
|
|
INSERT INTO t1 VALUES (1, 1), (2, 1);
|
|
|
|
CREATE TABLE t2 LIKE t1;
|
|
INSERT INTO t2 SELECT * FROM t1;
|
|
|
|
CREATE TABLE t3 LIKE t1;
|
|
INSERT INTO t3 SELECT * FROM t1;
|
|
|
|
--echo # Should not crash.
|
|
--echo # Should have 1 impossible where and 2 dependent subqs.
|
|
EXPLAIN
|
|
SELECT
|
|
(SELECT 1 FROM t1,t2 WHERE t2.b > t3.b)
|
|
FROM t3 WHERE 1 = 0 GROUP BY 1;
|
|
|
|
--echo # should return 0 rows
|
|
SELECT
|
|
(SELECT 1 FROM t1,t2 WHERE t2.b > t3.b)
|
|
FROM t3 WHERE 1 = 0 GROUP BY 1;
|
|
|
|
DROP TABLE t1,t2,t3;
|
|
|
|
--echo End of 5.0 tests.
|
|
|
|
#
|
|
# Fix for LP#612894
|
|
# Some aggregate functions (such as MIN MAX) work incorrectly in subqueries
|
|
# after getting NULL value
|
|
#
|
|
|
|
CREATE TABLE t1 (col_int_nokey int(11) NOT NULL, col_varchar_nokey varchar(1) NOT NULL) engine=myisam;
|
|
INSERT INTO t1 VALUES (2,'s'),(0,'v'),(2,'s');
|
|
CREATE TABLE t2 (
|
|
pk int(11) NOT NULL AUTO_INCREMENT,
|
|
`col_int_key` int(11) NOT NULL,
|
|
col_varchar_key varchar(1) NOT NULL,
|
|
PRIMARY KEY (pk),
|
|
KEY `col_int_key` (`col_int_key`),
|
|
KEY `col_varchar_key` (`col_varchar_key`)
|
|
) ENGINE=MyISAM;
|
|
INSERT INTO t2 VALUES (4,10,'g'), (5,20,'v');
|
|
|
|
SELECT t1.col_int_nokey,(SELECT MIN( t2_a.col_int_key ) FROM t2 t2_a, t2 t2_b, t1 t1_a WHERE t1_a.col_varchar_nokey = t2_b.col_varchar_key and t1.col_int_nokey ) as sub FROM t1;
|
|
|
|
SELECT t1.col_int_nokey,(SELECT MIN( t2_a.col_int_key ) +1 FROM t2 t2_a, t2 t2_b, t1 t1_a WHERE t1_a.col_varchar_nokey = t2_b.col_varchar_key and t1.col_int_nokey ) as sub FROM t1;
|
|
|
|
DROP TABLE t1,t2;
|
|
|
|
--echo End of 5.1 tests.
|