summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-04-16 16:59:19 -0700
committerIgor Babaev <igor@askmonty.org>2018-04-16 16:59:19 -0700
commit5e61e1716e763315009318081fba5994b8910242 (patch)
tree4e587d23f540686146db5ef7685bcd32ccf04885 /mysql-test/t
parent88ac368fea2182447284d6bacff4d93ef1acb865 (diff)
downloadmariadb-git-5e61e1716e763315009318081fba5994b8910242.tar.gz
MDEV-14515 ifnull result depends on number of rows in joined table
Any expensive WHERE condition for a table-less query with implicit aggregation was lost. As a result the used aggregate functions were calculated over a non-empty set of rows even in the case when the condition was false.
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/subselect4.test23
1 files changed, 23 insertions, 0 deletions
diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test
index 673dc9be0b4..2b53b55b735 100644
--- a/mysql-test/t/subselect4.test
+++ b/mysql-test/t/subselect4.test
@@ -2045,3 +2045,26 @@ SELECT 2 IN (SELECT 2 from DUAL WHERE 1 != 1);
SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size;
+
+--echo #
+--echo # mfrv-14515: Wrong results for tableless query with subquery in WHERE
+--echo # and implicit aggregation
+--echo #
+
+create table t1 (i1 int, i2 int);
+insert into t1 values (1314, 1084),(1330, 1084),(1401, 1084),(580, 1084);
+
+create table t2 (cd int);
+insert into t2 values
+ (1330), (1330), (1330), (1330), (1330), (1330), (1330), (1330),
+ (1330), (1330), (1330), (1330), (1330), (1330), (1330), (1330);
+
+select max(10) from dual
+ where exists (select 1 from t2 join t1 on t1.i1 = t2.cd and t1.i2 = 345);
+
+insert into t2 select * from t2;
+
+select max(10) from dual
+ where exists (select 1 from t2 join t1 on t1.i1 = t2.cd and t1.i2 = 345);
+
+DROP TABLE t1,t2;