diff options
-rw-r--r-- | mysql-test/main/having.result | 5 | ||||
-rw-r--r-- | mysql-test/main/having.test | 25 | ||||
-rw-r--r-- | mysql-test/main/subselect_innodb.result | 11 | ||||
-rw-r--r-- | mysql-test/main/subselect_innodb.test | 17 | ||||
-rw-r--r-- | sql/item.cc | 6 | ||||
-rw-r--r-- | sql/sql_base.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 20 |
7 files changed, 44 insertions, 42 deletions
diff --git a/mysql-test/main/having.result b/mysql-test/main/having.result index 51b88c5b8d2..8800402dc35 100644 --- a/mysql-test/main/having.result +++ b/mysql-test/main/having.result @@ -1,4 +1,3 @@ -drop table if exists t1,t2,t3; create table t1 (a int); select count(a) as b from t1 where a=0 having b > 0; b @@ -880,8 +879,10 @@ h # # drop table t1; +# # End of 10.3 tests # +# # MDEV-18681: AND formula in HAVING with several occurances # of the same field f in different conjuncts + f=constant # @@ -906,4 +907,6 @@ INSERT INTO t VALUES ('a'),('b'); SELECT * FROM t HAVING f = 'foo'; f DROP TABLE t; +# # End of 10.4 tests +# diff --git a/mysql-test/main/having.test b/mysql-test/main/having.test index 7e0a0439f8e..b3b128684a3 100644 --- a/mysql-test/main/having.test +++ b/mysql-test/main/having.test @@ -1,10 +1,6 @@ # test of problems with having (Reported by Mark Rogers) # ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings - create table t1 (a int); select count(a) as b from t1 where a=0 having b > 0; insert into t1 values (null); @@ -207,7 +203,7 @@ select count(*) from t1 group by col1 having col1 = 10; select count(*) as count_col1 from t1 group by col1 having col1 = 10; select count(*) as count_col1 from t1 as tmp1 group by col1 having col1 = 10; select count(*) from t1 group by col2 having col2 = 'hello'; ---error 1054 +--error ER_BAD_FIELD_ERROR select count(*) from t1 group by col2 having col1 = 10; select col1 as count_col1 from t1 as tmp1 group by col1 having col1 = 10; select col1 as count_col1 from t1 as tmp1 group by col1 having count_col1 = 10; @@ -221,10 +217,10 @@ select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col1 = select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having count_col1 = 10; select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col2 = 'hello'; select col1 as count_col1,col2 as group_col2 from t1 as tmp1 group by col1,col2 having group_col2 = 'hello'; ---error 1064 +--error ER_PARSE_ERROR select sum(col1) as co12 from t1 group by col2 having col2 10; select sum(col1) as co2, count(col2) as cc from t1 group by col1 having col1 =10; ---error 1054 +--error ER_BAD_FIELD_ERROR select t2.col2 from t2 group by t2.col1, t2.col2 having t1.col1 <= 10; @@ -273,7 +269,7 @@ having (select col_t1 from t2 where col_t1 = col_t2 order by col_t2 limit 1); # nested queries with HAVING, inner having column resolved in outer FROM clause # the outer having column is not referenced in GROUP BY which results in an error ---error 1054 +--error ER_BAD_FIELD_ERROR select t1.col1 from t1 where t1.col2 in (select t2.col2 from t2 @@ -302,7 +298,7 @@ having col_t1 > 10 and # correlated subqueries - inner having column 't1.col2' resolves to # the outer FROM clause, which cannot be used because the outer query # is grouped ---error 1054 +--error ER_BAD_FIELD_ERROR select sum(col1) from t1 group by col_t1 having col_t1 in (select sum(t2.col1) from t2 @@ -318,11 +314,11 @@ having col_t1 in (select sum(t2.col1) from t2 # # queries with joins and ambiguous column names # ---error 1052 +--error ER_NON_UNIQ_ERROR select t1.col1, t2.col1 from t1, t2 where t1.col1 = t2.col1 group by t1.col1, t2.col1 having col1 = 2; ---error 1052 +--error ER_NON_UNIQ_ERROR select t1.col1*10+t2.col1 from t1,t2 where t1.col1=t2.col1 group by t1.col1, t2.col1 having col1 = 2; @@ -352,7 +348,7 @@ select count(s1) from t1 group by s1 having count(1+1)=2; select count(s1) from t1 group by s1 having s1*0=0; --- error 1052 +-- error ER_NON_UNIQ_ERROR select * from t1 a, t1 b group by a.s1 having s1 is null; # ANSI requires: 0 rows # MySQL returns: @@ -912,7 +908,9 @@ alter table t1 add column b int default (rand()+1+3); select default(b) AS h FROM t1 HAVING h > "2"; drop table t1; +--echo # --echo # End of 10.3 tests +--echo # --echo # --echo # MDEV-18681: AND formula in HAVING with several occurances @@ -930,7 +928,6 @@ HAVING t.f != 112 AND t.f = 'x' AND t.f != 'a'; DROP TABLE t1,t2; - --echo # --echo # MDEV-20200: AddressSanitizer: use-after-poison in --echo # Item_direct_view_ref::get_null_ref_table @@ -943,4 +940,6 @@ SELECT * FROM t HAVING f = 'foo'; # Cleanup DROP TABLE t; +--echo # --echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/subselect_innodb.result b/mysql-test/main/subselect_innodb.result index f1e07ce09fe..ae22329f62a 100644 --- a/mysql-test/main/subselect_innodb.result +++ b/mysql-test/main/subselect_innodb.result @@ -1,6 +1,5 @@ set @subselect_innodb_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; -drop table if exists t1,t2,t3; CREATE TABLE t1 ( FOLDERID VARCHAR(32)BINARY NOT NULL @@ -154,6 +153,9 @@ EXECUTE my_stmt; b count(*) deallocate prepare my_stmt; drop table t1,t2; +# +# End of 4.1 tests +# CREATE TABLE t1 ( school_name varchar(45) NOT NULL, country varchar(45) NOT NULL, @@ -287,7 +289,6 @@ LIMIT 10; col_time_key col_datetime_key DROP TABLE t1; DROP TABLE t2; -# End of Bug #58756 # # Bug#60085 crash in Item::save_in_field() with time data type # @@ -356,7 +357,9 @@ LIMIT 1; maxkey NULL DROP TABLE t1,t2; -End of 5.1 tests +# +# End of 5.1 tests +# # # lp:827416 Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries # @@ -663,4 +666,6 @@ a b execute stmt; a b drop table t1,t2; +# # End of 10.4 tests +# diff --git a/mysql-test/main/subselect_innodb.test b/mysql-test/main/subselect_innodb.test index 37f8f40200e..e767891c8db 100644 --- a/mysql-test/main/subselect_innodb.test +++ b/mysql-test/main/subselect_innodb.test @@ -4,9 +4,6 @@ # settings are not relevant. set @subselect_innodb_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings # # key field overflow test @@ -164,7 +161,9 @@ EXECUTE my_stmt; deallocate prepare my_stmt; drop table t1,t2; -# End of 4.1 tests +--echo # +--echo # End of 4.1 tests +--echo # CREATE TABLE t1 ( school_name varchar(45) NOT NULL, @@ -289,8 +288,6 @@ LIMIT 10; DROP TABLE t1; DROP TABLE t2; ---echo # End of Bug #58756 - --echo # --echo # Bug#60085 crash in Item::save_in_field() with time data type --echo # @@ -354,7 +351,9 @@ eval $query; DROP TABLE t1,t2; ---echo End of 5.1 tests +--echo # +--echo # End of 5.1 tests +--echo # --echo # --echo # lp:827416 Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries @@ -507,8 +506,6 @@ drop table t1,t2; --echo # for a subquery from the expression used in ref access --echo # ---source include/have_innodb.inc - CREATE TABLE t1 (i1 INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1),(2); @@ -661,4 +658,6 @@ execute stmt; drop table t1,t2; +--echo # --echo # End of 10.4 tests +--echo # diff --git a/sql/item.cc b/sql/item.cc index 8b336334cc0..4c699bb974d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7874,8 +7874,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) else if (!ref || ref == not_found_item) { DBUG_ASSERT(reference_trough_name != 0); - if (!(ref= resolve_ref_in_select_and_group(thd, this, - context->select_lex))) + if (!(ref= resolve_ref_in_select_and_group(thd, this, context->select_lex))) goto error; /* Some error occurred (e.g. ambiguous names). */ if (ref == not_found_item) /* This reference was not resolved. */ @@ -7888,8 +7887,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) if (unlikely(!outer_context)) { /* The current reference cannot be resolved in this query. */ - my_error(ER_BAD_FIELD_ERROR,MYF(0), - this->full_name(), thd->where); + my_error(ER_BAD_FIELD_ERROR,MYF(0), full_name(), thd->where); goto error; } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3ca18bd007d..14b97b43660 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8453,7 +8453,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves, select_lex->where= *conds; } thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; - DBUG_RETURN(MY_TEST(thd->is_error())); + DBUG_RETURN(thd->is_error()); err_no_arena: select_lex->is_item_list_lookup= save_is_item_list_lookup; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d0377838ef0..2b0977aca9f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -24528,8 +24528,8 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, if (find_order_in_list(thd, ref_pointer_array, tables, order, fields, all_fields, false, true, from_window_spec)) return 1; - if ((*order->item)->with_window_func && - context_analysis_place != IN_ORDER_BY) + Item * const item= *order->item; + if (item->with_window_func && context_analysis_place != IN_ORDER_BY) { my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); return 1; @@ -24540,20 +24540,18 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, an ORDER BY clause */ - if (for_union && - ((*order->item)->with_sum_func() || - (*order->item)->with_window_func)) + if (for_union && (item->with_sum_func() || item->with_window_func)) { my_error(ER_AGGREGATE_ORDER_FOR_UNION, MYF(0), number); return 1; } - if (!(*order->item)->with_sum_func()) - continue; - - if (from_window_spec && (*order->item)->type() != Item::SUM_FUNC_ITEM) - (*order->item)->split_sum_func(thd, ref_pointer_array, - all_fields, SPLIT_SUM_SELECT); + if (from_window_spec && item->with_sum_func() && + item->type() != Item::SUM_FUNC_ITEM) + { + item->split_sum_func(thd, ref_pointer_array, + all_fields, SPLIT_SUM_SELECT); + } } return 0; } |