Skip to content

Commit 9912892

Browse files
committed
Bug#35184353: Refactor order of subquery resolving and transformation
In general, layout of classes has been enhanced. Member variables and functions have been renamed and made private and protected where reasonable. Constructors have been made minimal. Friend declarations are removed when possible. Changes in class Item_subselect - Function init() is renamed as bind() and will now bind subquery with query expression and update parsing_place. It will no longer update query result pointer, which is now done as part of fix_fields(). Notice it will no longer set place = CTX_NONE. This eliminated one case of "Unknown column" in tests like main.subquery_all. - Property functions assigned() are renamed as is_value_assigned(), set_value_assigned() and reset_value_assigned(). - reset_value_registration() is renamed as reset_has_values(). - m_subquery_used_tables is made private and accessor function subquery_used_tables() is added. - Helper pointers "substitution" and "optimizer", and field "changed" have been eliminated. Changes in class Item_singlerow_subselect - Function select_transformer() has been removed and functionality moved to fix_fields(). Changes in class Item_maxmin_subselect - Function reset_value_registration() is renamed as reset_has_values(). Changes in class Item_exists_subselect - Function select_transformer() is renamed as transformer(). Changes in class Item_in_subselect - Field left_expr is moved to base class, which leads to improved generalization. Removed class SubqueryWithResult - Class SubqueryWithResult has been removed as it was redundant. The resolver parts of it is now taken care of by class Item_singlerow_subselect. Preparation of underlying query expression has been moved to Item_subselect::fix_fields(). - Function set_row() has been moved to class Item_singlerow_subselect and renamed to create_row(). It will also update the data type of class Item_singlerow_subselect. - Functionality of function fix_length_and_dec() has been incorporated in Item_singlerow_subselect::fix_fields(). Changes in sequence of operations. - Previously, resolving and transformation of subqueries and predicates over subqueries were intertwined operations. Transformations were started from the function Query_block::resolve_subquery() which was called deep in the call hierarchy from Item_subselect::fix_fields(), just after the query block was resolved. Even worse, for a subquery that contained set operations, the transformer function would be called once for each query block. This has been refactored so that each subquery and subquery predicate is now fully resolved through its fix_fields() function, and possible transformations are performed as the last stage of fix_fields(). This fulfills the goal of performing resolving and transformation in distinct stages. - Item_singlerow_subselect::fix_fields() may transform a subquery that is a single query block and does not have tables, aggregation, WHERE clause nor HAVING clause by completely eliminating the subquery. - Item_exists_subselect::fix_fields() resolves all predicates involving table subqueries. After a complete resolving, it will either perform a direct transformation, or pass the predicate into a queue for later processing. (We cannot process all transformations immediately because some transformations may have to be done in priority order, and transformations that add new Table_ref objects should only be done after the outer query block is fully resolved). - The queue for later processing will contain predicates that are candidates for semijoin transformation and candidates for derived table transformation. The complex conditions for these transformations have been split out into dedicated functions on the class Item_exists_subselect and are called is_semijoin_candidate() and is_derived_candidate(), respectively. - If neither of these apply, the predicate is transformed using a virtual transformer() function. These functions are renamed from select_transformer() and no longer contain a query block argument, as they now handle the transformation of a complete subquery. - Item_exists_subselect::transformer() is called for EXISTS and NOT EXISTS predicates. It only adds a LIMIT 1 clause to the query expression. - Item_in_subselect::transformer() and Item_allany_subselect::transformer() both call quantified_comp_transformer(). This function has a specific transformation for predicates like x IN (SELECT expr), which is converted to a simple equality. Other subqueries are transformed by functions single_value_transformer() and row_value_transformer(). These functions are not changed a lot, except they now perform some general work first and then apply transformations to each contained query block. The latter work is done in functions single_value_in_to_exists_transformer() and row_value_in_to_exists_transformer(). Test changes subquery.inc A query used to report ER_BAD_FIELD_ERROR but is now accepted. The problem was that the parsing place of the inner query expression was CTX_NONE but this has now been corrected to CTX_SELECT_LIST. For another query, error was changed from ER_BAD_FIELD_ERROR to ER_INVALID_GROUP_FUNC_USE. Optimizer trace tests These are all adjusted since the resolving and transformation of subquery predicates are all performed in a different order. i_main.subquery-bug32593846 Error is changed from ER_OPERAND_COLUMNS to ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT because now the UNION is inspected before the subquery LHS. Change-Id: I32d98fa443383d61a12fbd8227d1bf52e93565b0
1 parent da1a9fd commit 9912892

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2117
-2346
lines changed

mysql-test/include/subquery.inc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,9 +2886,9 @@ SELECT
28862886
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
28872887
FROM t1;
28882888

2889-
--error ER_BAD_FIELD_ERROR
2890-
SELECT t1.a as XXA,
2891-
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
2889+
--error ER_INVALID_GROUP_FUNC_USE
2890+
SELECT t1.a as xxa,
2891+
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING xxa < 12) ) FROM t2) )
28922892
FROM t1;
28932893

28942894
DROP TABLE t1,t2;
@@ -3189,7 +3189,6 @@ CREATE TABLE t3 (
31893189
INSERT INTO t3 VALUES (1,null), (2,null);
31903190
--source include/turn_off_only_full_group_by.inc
31913191

3192-
--error ER_BAD_FIELD_ERROR
31933192
SELECT
31943193
IF(t1.f1 = 'R', a1.f2, t2.f2) AS a4,
31953194
IF(t1.f1 = 'R', a1.f3, t2.f3) AS f3,

mysql-test/r/desc_index_innodb.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,8 +1336,8 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
13361336
1 SIMPLE p2 NULL index NULL col_varchar_key 46 NULL 5 100.00 Using where; Using index
13371337
1 SIMPLE c2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; FirstMatch(gp2)
13381338
Warnings:
1339-
Note 1276 Field or reference 'test.gp1.col_int' of SELECT #2 was resolved in SELECT #1
13401339
Note 1276 Field or reference 'test.gp1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
1340+
Note 1276 Field or reference 'test.gp1.col_int' of SELECT #2 was resolved in SELECT #1
13411341
Note 1276 Field or reference 'test.gp1.col_varchar' of SELECT #2 was resolved in SELECT #1
13421342
Note 1003 /* select#1 */ select `test`.`gp1`.`col_varchar` AS `g1` from `test`.`b` `gp1` left join `test`.`bb` `gp2` on((`test`.`gp2`.`col_varchar_key` = `test`.`gp1`.`col_varchar_key`)) semi join (`test`.`bb` `p1` left join `test`.`bb` `p2` on((`test`.`p1`.`col_int` >= `test`.`p2`.`col_int_key`)) join `test`.`b` `c1` left join `test`.`bb` `c2` on((`test`.`c1`.`col_varchar` = `test`.`c2`.`col_varchar`))) where ((`test`.`c1`.`col_int` = `test`.`gp1`.`col_int`) and (`test`.`p1`.`col_int` = `test`.`gp1`.`col_int`) and (`test`.`gp1`.`col_varchar_key` <> 'y') and (`test`.`gp1`.`col_varchar` < 'e') and (`test`.`gp1`.`col_varchar_key` >= 'n')) order by `test`.`gp1`.`col_varchar_key` limit 4
13431343
SELECT gp1 . col_varchar AS g1

mysql-test/r/optimizer_switch.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
573573
4 DEPENDENT SUBQUERY tc NULL ALL NULL NULL NULL NULL 4 25.00 Using where
574574
3 DEPENDENT SUBQUERY tc NULL ALL NULL NULL NULL NULL 4 25.00 Using where
575575
Warnings:
576-
Note 1276 Field or reference 'test.tb.d' of SELECT #3 was resolved in SELECT #2
577576
Note 1276 Field or reference 'test.ta.b' of SELECT #4 was resolved in SELECT #1
577+
Note 1276 Field or reference 'test.tb.d' of SELECT #3 was resolved in SELECT #2
578578
Note 1003 /* select#1 */ select `test`.`ta`.`a` AS `a`,`test`.`ta`.`b` AS `b` from `test`.`t1` `ta` where <in_optimizer>(`test`.`ta`.`a`,<exists>(/* select#2 */ select `test`.`tb`.`c` from `test`.`t2` `tb` where (<nop>(<in_optimizer>((/* select#3 */ select min(`test`.`tc`.`e`) from `test`.`t3` `tc` where (`test`.`tb`.`d` = `test`.`tc`.`e`)),<exists>(/* select#4 */ select `test`.`tc`.`e` from `test`.`t3` `tc` where ((`test`.`ta`.`b` = `test`.`tc`.`e`) and <if>(outer_field_is_not_null, (<cache>((/* select#3 */ select min(`test`.`tc`.`e`) from `test`.`t3` `tc` where (`test`.`tb`.`d` = `test`.`tc`.`e`))) < `test`.`tc`.`e`), true))))) and (<cache>(`test`.`ta`.`a`) = `test`.`tb`.`c`))))
579579
SELECT * FROM t1 AS ta
580580
WHERE ta.a IN (SELECT c FROM t2 AS tb
@@ -596,8 +596,8 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
596596
4 DEPENDENT SUBQUERY tc NULL ALL NULL NULL NULL NULL 4 25.00 Using where
597597
3 DEPENDENT SUBQUERY tc NULL ALL NULL NULL NULL NULL 4 25.00 Using where
598598
Warnings:
599-
Note 1276 Field or reference 'test.tb.d' of SELECT #3 was resolved in SELECT #2
600599
Note 1276 Field or reference 'test.ta.b' of SELECT #4 was resolved in SELECT #1
600+
Note 1276 Field or reference 'test.tb.d' of SELECT #3 was resolved in SELECT #2
601601
Note 1003 /* select#1 */ select `test`.`ta`.`a` AS `a`,`test`.`ta`.`b` AS `b` from `test`.`t1` `ta` semi join (`test`.`t2` `tb`) where ((`test`.`ta`.`a` = `test`.`tb`.`c`) and <nop>(<in_optimizer>((/* select#3 */ select min(`test`.`tc`.`e`) from `test`.`t3` `tc` where (`test`.`tb`.`d` = `test`.`tc`.`e`)),<exists>(/* select#4 */ select `test`.`tc`.`e` from `test`.`t3` `tc` where ((`test`.`ta`.`b` = `test`.`tc`.`e`) and <if>(outer_field_is_not_null, (<cache>((/* select#3 */ select min(`test`.`tc`.`e`) from `test`.`t3` `tc` where (`test`.`tb`.`d` = `test`.`tc`.`e`))) < `test`.`tc`.`e`), true))))))
602602
SELECT * FROM t1 AS ta
603603
WHERE ta.a IN (SELECT c FROM t2 AS tb

mysql-test/r/subquery_all.result

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,13 +2086,13 @@ a
20862086
1
20872087
3
20882088
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a FROM t1 WHERE b = 2);
2089-
ERROR 21000: Operand should contain 1 column(s)
2089+
ERROR 21000: Operand should contain 2 column(s)
20902090
SELECT a FROM t1 WHERE a > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20912091
ERROR 21000: Operand should contain 1 column(s)
20922092
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20932093
ERROR 21000: Operand should contain 1 column(s)
20942094
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a FROM t1 WHERE b = 2);
2095-
ERROR 21000: Operand should contain 1 column(s)
2095+
ERROR 21000: Operand should contain 2 column(s)
20962096
SELECT a FROM t1 WHERE a > ALL (SELECT a,2 FROM t1 WHERE b = 2);
20972097
ERROR 21000: Operand should contain 1 column(s)
20982098
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a,2 FROM t1 WHERE b = 2);
@@ -4125,10 +4125,10 @@ SELECT
41254125
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
41264126
FROM t1;
41274127
ERROR HY000: Invalid use of group function
4128-
SELECT t1.a as XXA,
4129-
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
4128+
SELECT t1.a as xxa,
4129+
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING xxa < 12) ) FROM t2) )
41304130
FROM t1;
4131-
ERROR 42S22: Unknown column 'XXA' in 'having clause'
4131+
ERROR HY000: Invalid use of group function
41324132
DROP TABLE t1,t2;
41334133
CREATE TABLE t1 (a int, b int, KEY (a));
41344134
INSERT INTO t1 VALUES (1,1),(2,1);
@@ -4444,7 +4444,9 @@ t3.f5
44444444
FROM
44454445
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
44464446
GROUP BY a4;
4447-
ERROR 42S22: Unknown column 'a4' in 'where clause'
4447+
a4 f3 a6
4448+
1 NULL NULL
4449+
2 NULL NULL
44484450
DROP TABLE t1, t2, t3, t4;
44494451
create table t1 (a float(5,4) zerofill);
44504452
Warnings:

mysql-test/r/subquery_all_bka.result

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,13 +2087,13 @@ a
20872087
1
20882088
3
20892089
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a FROM t1 WHERE b = 2);
2090-
ERROR 21000: Operand should contain 1 column(s)
2090+
ERROR 21000: Operand should contain 2 column(s)
20912091
SELECT a FROM t1 WHERE a > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20922092
ERROR 21000: Operand should contain 1 column(s)
20932093
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20942094
ERROR 21000: Operand should contain 1 column(s)
20952095
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a FROM t1 WHERE b = 2);
2096-
ERROR 21000: Operand should contain 1 column(s)
2096+
ERROR 21000: Operand should contain 2 column(s)
20972097
SELECT a FROM t1 WHERE a > ALL (SELECT a,2 FROM t1 WHERE b = 2);
20982098
ERROR 21000: Operand should contain 1 column(s)
20992099
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a,2 FROM t1 WHERE b = 2);
@@ -4126,10 +4126,10 @@ SELECT
41264126
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
41274127
FROM t1;
41284128
ERROR HY000: Invalid use of group function
4129-
SELECT t1.a as XXA,
4130-
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
4129+
SELECT t1.a as xxa,
4130+
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING xxa < 12) ) FROM t2) )
41314131
FROM t1;
4132-
ERROR 42S22: Unknown column 'XXA' in 'having clause'
4132+
ERROR HY000: Invalid use of group function
41334133
DROP TABLE t1,t2;
41344134
CREATE TABLE t1 (a int, b int, KEY (a));
41354135
INSERT INTO t1 VALUES (1,1),(2,1);
@@ -4445,7 +4445,9 @@ t3.f5
44454445
FROM
44464446
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
44474447
GROUP BY a4;
4448-
ERROR 42S22: Unknown column 'a4' in 'where clause'
4448+
a4 f3 a6
4449+
1 NULL NULL
4450+
2 NULL NULL
44494451
DROP TABLE t1, t2, t3, t4;
44504452
create table t1 (a float(5,4) zerofill);
44514453
Warnings:

mysql-test/r/subquery_all_bka_nobnl.result

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,13 +2087,13 @@ a
20872087
1
20882088
3
20892089
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a FROM t1 WHERE b = 2);
2090-
ERROR 21000: Operand should contain 1 column(s)
2090+
ERROR 21000: Operand should contain 2 column(s)
20912091
SELECT a FROM t1 WHERE a > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20922092
ERROR 21000: Operand should contain 1 column(s)
20932093
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20942094
ERROR 21000: Operand should contain 1 column(s)
20952095
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a FROM t1 WHERE b = 2);
2096-
ERROR 21000: Operand should contain 1 column(s)
2096+
ERROR 21000: Operand should contain 2 column(s)
20972097
SELECT a FROM t1 WHERE a > ALL (SELECT a,2 FROM t1 WHERE b = 2);
20982098
ERROR 21000: Operand should contain 1 column(s)
20992099
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a,2 FROM t1 WHERE b = 2);
@@ -4126,10 +4126,10 @@ SELECT
41264126
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
41274127
FROM t1;
41284128
ERROR HY000: Invalid use of group function
4129-
SELECT t1.a as XXA,
4130-
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
4129+
SELECT t1.a as xxa,
4130+
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING xxa < 12) ) FROM t2) )
41314131
FROM t1;
4132-
ERROR 42S22: Unknown column 'XXA' in 'having clause'
4132+
ERROR HY000: Invalid use of group function
41334133
DROP TABLE t1,t2;
41344134
CREATE TABLE t1 (a int, b int, KEY (a));
41354135
INSERT INTO t1 VALUES (1,1),(2,1);
@@ -4445,7 +4445,9 @@ t3.f5
44454445
FROM
44464446
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
44474447
GROUP BY a4;
4448-
ERROR 42S22: Unknown column 'a4' in 'where clause'
4448+
a4 f3 a6
4449+
1 NULL NULL
4450+
2 NULL NULL
44494451
DROP TABLE t1, t2, t3, t4;
44504452
create table t1 (a float(5,4) zerofill);
44514453
Warnings:

mysql-test/r/subquery_bugs.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
15231523
2 DEPENDENT SUBQUERY sq1_t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(sq2_t3)
15241524
Warnings:
15251525
Note 1276 Field or reference 'test.table1.col_tinyint_key' of SELECT #3 was resolved in SELECT #1
1526-
Note 1003 /* select#1 */ select count(`test`.`table1`.`col_datetime`) AS `field1` from `test`.`t1` `table2` join `test`.`t1` `table1` where ((<in_optimizer>(`test`.`table1`.`col_char_key`,<exists>(/* select#2 */ select `test`.`sq2_t1`.`col_real_key` from `test`.`t2` `sq2_t1` join `test`.`t3` `sq2_t2` join `test`.`t1` `sq2_t3` semi join (`test`.`t1` `sq1_t1` join `test`.`t1` `sq1_t2`) where ((`test`.`sq2_t3`.`col_varchar_key` = `test`.`sq2_t2`.`col_varchar_key`) and (<cache>(`test`.`table1`.`col_char_key`) = `test`.`sq2_t1`.`col_real_key`) and (cast(`test`.`sq2_t1`.`col_mediumint` as double) = cast(`test`.`sq1_t1`.`col_varchar_key` as double)) and (`test`.`table1`.`col_tinyint_key` = `test`.`sq1_t2`.`col_tinyint_key`) and (cast(locate('K',`test`.`sq2_t3`.`col_tinyint`) as double) = cast(`test`.`sq2_t2`.`col_varchar` as double))))) or (rtrim(`test`.`table1`.`col_tinyint_key`) is not null)) and (`test`.`table1`.`col_varchar_key` = `test`.`table2`.`col_char`))
1526+
Note 1003 /* select#1 */ select count(`test`.`table1`.`col_datetime`) AS `field1` from `test`.`t1` `table2` join `test`.`t1` `table1` where ((<in_optimizer>(`test`.`table1`.`col_char_key`,<exists>(/* select#2 */ select `test`.`sq2_t1`.`col_real_key` from `test`.`t2` `sq2_t1` join `test`.`t3` `sq2_t2` join `test`.`t1` `sq2_t3` semi join (`test`.`t1` `sq1_t1` join `test`.`t1` `sq1_t2`) where ((`test`.`sq2_t3`.`col_varchar_key` = `test`.`sq2_t2`.`col_varchar_key`) and (cast(`test`.`sq2_t1`.`col_mediumint` as double) = cast(`test`.`sq1_t1`.`col_varchar_key` as double)) and (`test`.`table1`.`col_tinyint_key` = `test`.`sq1_t2`.`col_tinyint_key`) and (<cache>(`test`.`table1`.`col_char_key`) = `test`.`sq2_t1`.`col_real_key`) and (cast(locate('K',`test`.`sq2_t3`.`col_tinyint`) as double) = cast(`test`.`sq2_t2`.`col_varchar` as double))))) or (rtrim(`test`.`table1`.`col_tinyint_key`) is not null)) and (`test`.`table1`.`col_varchar_key` = `test`.`table2`.`col_char`))
15271527
SELECT COUNT(table1.col_datetime) AS field1
15281528
FROM t1 AS table1 RIGHT JOIN t1 AS table2
15291529
ON table1.col_varchar_key = table2.col_char

mysql-test/r/subquery_nomat_nosj.result

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,13 +2086,13 @@ a
20862086
1
20872087
3
20882088
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a FROM t1 WHERE b = 2);
2089-
ERROR 21000: Operand should contain 1 column(s)
2089+
ERROR 21000: Operand should contain 2 column(s)
20902090
SELECT a FROM t1 WHERE a > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20912091
ERROR 21000: Operand should contain 1 column(s)
20922092
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20932093
ERROR 21000: Operand should contain 1 column(s)
20942094
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a FROM t1 WHERE b = 2);
2095-
ERROR 21000: Operand should contain 1 column(s)
2095+
ERROR 21000: Operand should contain 2 column(s)
20962096
SELECT a FROM t1 WHERE a > ALL (SELECT a,2 FROM t1 WHERE b = 2);
20972097
ERROR 21000: Operand should contain 1 column(s)
20982098
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a,2 FROM t1 WHERE b = 2);
@@ -4125,10 +4125,10 @@ SELECT
41254125
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
41264126
FROM t1;
41274127
ERROR HY000: Invalid use of group function
4128-
SELECT t1.a as XXA,
4129-
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
4128+
SELECT t1.a as xxa,
4129+
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING xxa < 12) ) FROM t2) )
41304130
FROM t1;
4131-
ERROR 42S22: Unknown column 'XXA' in 'having clause'
4131+
ERROR HY000: Invalid use of group function
41324132
DROP TABLE t1,t2;
41334133
CREATE TABLE t1 (a int, b int, KEY (a));
41344134
INSERT INTO t1 VALUES (1,1),(2,1);
@@ -4444,7 +4444,9 @@ t3.f5
44444444
FROM
44454445
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
44464446
GROUP BY a4;
4447-
ERROR 42S22: Unknown column 'a4' in 'where clause'
4447+
a4 f3 a6
4448+
1 NULL NULL
4449+
2 NULL NULL
44484450
DROP TABLE t1, t2, t3, t4;
44494451
create table t1 (a float(5,4) zerofill);
44504452
Warnings:

mysql-test/r/subquery_nomat_nosj_bka.result

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,13 +2087,13 @@ a
20872087
1
20882088
3
20892089
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a FROM t1 WHERE b = 2);
2090-
ERROR 21000: Operand should contain 1 column(s)
2090+
ERROR 21000: Operand should contain 2 column(s)
20912091
SELECT a FROM t1 WHERE a > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20922092
ERROR 21000: Operand should contain 1 column(s)
20932093
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20942094
ERROR 21000: Operand should contain 1 column(s)
20952095
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a FROM t1 WHERE b = 2);
2096-
ERROR 21000: Operand should contain 1 column(s)
2096+
ERROR 21000: Operand should contain 2 column(s)
20972097
SELECT a FROM t1 WHERE a > ALL (SELECT a,2 FROM t1 WHERE b = 2);
20982098
ERROR 21000: Operand should contain 1 column(s)
20992099
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a,2 FROM t1 WHERE b = 2);
@@ -4126,10 +4126,10 @@ SELECT
41264126
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
41274127
FROM t1;
41284128
ERROR HY000: Invalid use of group function
4129-
SELECT t1.a as XXA,
4130-
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
4129+
SELECT t1.a as xxa,
4130+
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING xxa < 12) ) FROM t2) )
41314131
FROM t1;
4132-
ERROR 42S22: Unknown column 'XXA' in 'having clause'
4132+
ERROR HY000: Invalid use of group function
41334133
DROP TABLE t1,t2;
41344134
CREATE TABLE t1 (a int, b int, KEY (a));
41354135
INSERT INTO t1 VALUES (1,1),(2,1);
@@ -4445,7 +4445,9 @@ t3.f5
44454445
FROM
44464446
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
44474447
GROUP BY a4;
4448-
ERROR 42S22: Unknown column 'a4' in 'where clause'
4448+
a4 f3 a6
4449+
1 NULL NULL
4450+
2 NULL NULL
44494451
DROP TABLE t1, t2, t3, t4;
44504452
create table t1 (a float(5,4) zerofill);
44514453
Warnings:

mysql-test/r/subquery_nomat_nosj_bka_nobnl.result

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,13 +2087,13 @@ a
20872087
1
20882088
3
20892089
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a FROM t1 WHERE b = 2);
2090-
ERROR 21000: Operand should contain 1 column(s)
2090+
ERROR 21000: Operand should contain 2 column(s)
20912091
SELECT a FROM t1 WHERE a > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20922092
ERROR 21000: Operand should contain 1 column(s)
20932093
SELECT a FROM t1 WHERE (1,2) > ANY (SELECT a,2 FROM t1 WHERE b = 2);
20942094
ERROR 21000: Operand should contain 1 column(s)
20952095
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a FROM t1 WHERE b = 2);
2096-
ERROR 21000: Operand should contain 1 column(s)
2096+
ERROR 21000: Operand should contain 2 column(s)
20972097
SELECT a FROM t1 WHERE a > ALL (SELECT a,2 FROM t1 WHERE b = 2);
20982098
ERROR 21000: Operand should contain 1 column(s)
20992099
SELECT a FROM t1 WHERE (1,2) > ALL (SELECT a,2 FROM t1 WHERE b = 2);
@@ -4126,10 +4126,10 @@ SELECT
41264126
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
41274127
FROM t1;
41284128
ERROR HY000: Invalid use of group function
4129-
SELECT t1.a as XXA,
4130-
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
4129+
SELECT t1.a as xxa,
4130+
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING xxa < 12) ) FROM t2) )
41314131
FROM t1;
4132-
ERROR 42S22: Unknown column 'XXA' in 'having clause'
4132+
ERROR HY000: Invalid use of group function
41334133
DROP TABLE t1,t2;
41344134
CREATE TABLE t1 (a int, b int, KEY (a));
41354135
INSERT INTO t1 VALUES (1,1),(2,1);
@@ -4445,7 +4445,9 @@ t3.f5
44454445
FROM
44464446
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
44474447
GROUP BY a4;
4448-
ERROR 42S22: Unknown column 'a4' in 'where clause'
4448+
a4 f3 a6
4449+
1 NULL NULL
4450+
2 NULL NULL
44494451
DROP TABLE t1, t2, t3, t4;
44504452
create table t1 (a float(5,4) zerofill);
44514453
Warnings:

0 commit comments

Comments
 (0)