Commit 6b99859f authored by Sergei Golubchik's avatar Sergei Golubchik

after-merge fix for a7ed4644

(10.0+ changes, as specified in the MDEV)

and remove unused variable (compiler warning)
parent 89dc445a
......@@ -7121,9 +7121,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
3
ERROR 42000: Can't group on 'sq'
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2
3
......@@ -7131,9 +7132,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*)
1
delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
NULL
ERROR 42000: Can't group on 'sq'
drop view v2;
drop table t1,t2;
#
......
......@@ -7121,9 +7121,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
3
ERROR 42000: Can't group on 'sq'
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2
3
......@@ -7131,9 +7132,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*)
1
delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
NULL
ERROR 42000: Can't group on 'sq'
drop view v2;
drop table t1,t2;
#
......@@ -7147,6 +7149,28 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2
foo bar
DROP TABLE t1;
#
# MDEV-10146: Wrong result (or questionable result and behavior)
# with aggregate function in uncorrelated SELECT subquery
#
CREATE TABLE t1 (f1 INT);
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 int);
INSERT INTO t2 VALUES (3);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
( SELECT MAX(f1) FROM t2 )
2
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
( SELECT MAX(f1) FROM t2 )
2
INSERT INTO t2 VALUES (4);
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
ERROR 21000: Subquery returns more than 1 row
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
ERROR 21000: Subquery returns more than 1 row
drop view v1;
drop table t1,t2;
set optimizer_switch=default;
select @@optimizer_switch like '%exists_to_in=off%';
@@optimizer_switch like '%exists_to_in=off%'
......
......@@ -7114,9 +7114,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
3
ERROR 42000: Can't group on 'sq'
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2
3
......@@ -7124,9 +7125,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*)
1
delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
NULL
ERROR 42000: Can't group on 'sq'
drop view v2;
drop table t1,t2;
#
......
......@@ -7112,9 +7112,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
3
ERROR 42000: Can't group on 'sq'
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2
3
......@@ -7122,9 +7123,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*)
1
delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
NULL
ERROR 42000: Can't group on 'sq'
drop view v2;
drop table t1,t2;
#
......
......@@ -7127,9 +7127,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
3
ERROR 42000: Can't group on 'sq'
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2
3
......@@ -7137,9 +7138,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*)
1
delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
NULL
ERROR 42000: Can't group on 'sq'
drop view v2;
drop table t1,t2;
#
......
......@@ -7112,9 +7112,10 @@ INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (f2 INT, KEY(f2));
INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
3
ERROR 42000: Can't group on 'sq'
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
f2
3
......@@ -7122,9 +7123,10 @@ SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
count(*)
1
delete from t1;
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
ERROR 42000: Can't group on 'sq'
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
sq
NULL
ERROR 42000: Can't group on 'sq'
drop view v2;
drop table t1,t2;
#
......
......@@ -6002,11 +6002,17 @@ INSERT INTO t2 VALUES (3);
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
--error ER_WRONG_GROUP_FIELD
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
--error ER_WRONG_GROUP_FIELD
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
SELECT * FROM v2 where ( SELECT MIN(v2.f2) FROM t1 ) > 0;
SELECT count(*) FROM v2 group by ( SELECT MIN(v2.f2) FROM t1 );
delete from t1;
--error ER_WRONG_GROUP_FIELD
SELECT ( SELECT MIN(t2.f2) FROM t1 ) AS sq FROM t2 GROUP BY sq;
--error ER_WRONG_GROUP_FIELD
SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
drop view v2;
......
......@@ -4991,7 +4991,6 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
if (thd->lex->in_sum_func &&
thd->lex->in_sum_func->nest_level >= select->nest_level)
{
Item::Type ref_type= (*reference)->type();
set_if_bigger(thd->lex->in_sum_func->max_arg_level,
select->nest_level);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment