Skip to content

Commit bc9102e

Browse files
committed
cleanup: (*order->item) -> item
and minor style fixes
1 parent 7215b00 commit bc9102e

File tree

7 files changed

+44
-42
lines changed

7 files changed

+44
-42
lines changed

mysql-test/main/having.result

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
drop table if exists t1,t2,t3;
21
create table t1 (a int);
32
select count(a) as b from t1 where a=0 having b > 0;
43
b
@@ -880,8 +879,10 @@ h
880879
#
881880
#
882881
drop table t1;
882+
#
883883
# End of 10.3 tests
884884
#
885+
#
885886
# MDEV-18681: AND formula in HAVING with several occurances
886887
# of the same field f in different conjuncts + f=constant
887888
#
@@ -906,4 +907,6 @@ INSERT INTO t VALUES ('a'),('b');
906907
SELECT * FROM t HAVING f = 'foo';
907908
f
908909
DROP TABLE t;
910+
#
909911
# End of 10.4 tests
912+
#

mysql-test/main/having.test

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# test of problems with having (Reported by Mark Rogers)
22
#
33

4-
--disable_warnings
5-
drop table if exists t1,t2,t3;
6-
--enable_warnings
7-
84
create table t1 (a int);
95
select count(a) as b from t1 where a=0 having b > 0;
106
insert into t1 values (null);
@@ -207,7 +203,7 @@ select count(*) from t1 group by col1 having col1 = 10;
207203
select count(*) as count_col1 from t1 group by col1 having col1 = 10;
208204
select count(*) as count_col1 from t1 as tmp1 group by col1 having col1 = 10;
209205
select count(*) from t1 group by col2 having col2 = 'hello';
210-
--error 1054
206+
--error ER_BAD_FIELD_ERROR
211207
select count(*) from t1 group by col2 having col1 = 10;
212208
select col1 as count_col1 from t1 as tmp1 group by col1 having col1 = 10;
213209
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 =
221217
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having count_col1 = 10;
222218
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col2 = 'hello';
223219
select col1 as count_col1,col2 as group_col2 from t1 as tmp1 group by col1,col2 having group_col2 = 'hello';
224-
--error 1064
220+
--error ER_PARSE_ERROR
225221
select sum(col1) as co12 from t1 group by col2 having col2 10;
226222
select sum(col1) as co2, count(col2) as cc from t1 group by col1 having col1 =10;
227-
--error 1054
223+
--error ER_BAD_FIELD_ERROR
228224
select t2.col2 from t2 group by t2.col1, t2.col2 having t1.col1 <= 10;
229225

230226

@@ -273,7 +269,7 @@ having (select col_t1 from t2 where col_t1 = col_t2 order by col_t2 limit 1);
273269

274270
# nested queries with HAVING, inner having column resolved in outer FROM clause
275271
# the outer having column is not referenced in GROUP BY which results in an error
276-
--error 1054
272+
--error ER_BAD_FIELD_ERROR
277273
select t1.col1 from t1
278274
where t1.col2 in
279275
(select t2.col2 from t2
@@ -302,7 +298,7 @@ having col_t1 > 10 and
302298
# correlated subqueries - inner having column 't1.col2' resolves to
303299
# the outer FROM clause, which cannot be used because the outer query
304300
# is grouped
305-
--error 1054
301+
--error ER_BAD_FIELD_ERROR
306302
select sum(col1) from t1
307303
group by col_t1
308304
having col_t1 in (select sum(t2.col1) from t2
@@ -318,11 +314,11 @@ having col_t1 in (select sum(t2.col1) from t2
318314
#
319315
# queries with joins and ambiguous column names
320316
#
321-
--error 1052
317+
--error ER_NON_UNIQ_ERROR
322318
select t1.col1, t2.col1 from t1, t2 where t1.col1 = t2.col1
323319
group by t1.col1, t2.col1 having col1 = 2;
324320

325-
--error 1052
321+
--error ER_NON_UNIQ_ERROR
326322
select t1.col1*10+t2.col1 from t1,t2 where t1.col1=t2.col1
327323
group by t1.col1, t2.col1 having col1 = 2;
328324

@@ -352,7 +348,7 @@ select count(s1) from t1 group by s1 having count(1+1)=2;
352348

353349
select count(s1) from t1 group by s1 having s1*0=0;
354350

355-
-- error 1052
351+
-- error ER_NON_UNIQ_ERROR
356352
select * from t1 a, t1 b group by a.s1 having s1 is null;
357353
# ANSI requires: 0 rows
358354
# MySQL returns:
@@ -912,7 +908,9 @@ alter table t1 add column b int default (rand()+1+3);
912908
select default(b) AS h FROM t1 HAVING h > "2";
913909
drop table t1;
914910

911+
--echo #
915912
--echo # End of 10.3 tests
913+
--echo #
916914

917915
--echo #
918916
--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';
930928

931929
DROP TABLE t1,t2;
932930

933-
934931
--echo #
935932
--echo # MDEV-20200: AddressSanitizer: use-after-poison in
936933
--echo # Item_direct_view_ref::get_null_ref_table
@@ -943,4 +940,6 @@ SELECT * FROM t HAVING f = 'foo';
943940
# Cleanup
944941
DROP TABLE t;
945942

943+
--echo #
946944
--echo # End of 10.4 tests
945+
--echo #

mysql-test/main/subselect_innodb.result

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
set @subselect_innodb_tmp=@@optimizer_switch;
22
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
3-
drop table if exists t1,t2,t3;
43
CREATE TABLE t1
54
(
65
FOLDERID VARCHAR(32)BINARY NOT NULL
@@ -154,6 +153,9 @@ EXECUTE my_stmt;
154153
b count(*)
155154
deallocate prepare my_stmt;
156155
drop table t1,t2;
156+
#
157+
# End of 4.1 tests
158+
#
157159
CREATE TABLE t1 (
158160
school_name varchar(45) NOT NULL,
159161
country varchar(45) NOT NULL,
@@ -287,7 +289,6 @@ LIMIT 10;
287289
col_time_key col_datetime_key
288290
DROP TABLE t1;
289291
DROP TABLE t2;
290-
# End of Bug #58756
291292
#
292293
# Bug#60085 crash in Item::save_in_field() with time data type
293294
#
@@ -356,7 +357,9 @@ LIMIT 1;
356357
maxkey
357358
NULL
358359
DROP TABLE t1,t2;
359-
End of 5.1 tests
360+
#
361+
# End of 5.1 tests
362+
#
360363
#
361364
# lp:827416 Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries
362365
#
@@ -663,4 +666,6 @@ a b
663666
execute stmt;
664667
a b
665668
drop table t1,t2;
669+
#
666670
# End of 10.4 tests
671+
#

mysql-test/main/subselect_innodb.test

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# settings are not relevant.
55
set @subselect_innodb_tmp=@@optimizer_switch;
66
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
7-
--disable_warnings
8-
drop table if exists t1,t2,t3;
9-
--enable_warnings
107

118
#
129
# key field overflow test
@@ -164,7 +161,9 @@ EXECUTE my_stmt;
164161
deallocate prepare my_stmt;
165162
drop table t1,t2;
166163

167-
# End of 4.1 tests
164+
--echo #
165+
--echo # End of 4.1 tests
166+
--echo #
168167

169168
CREATE TABLE t1 (
170169
school_name varchar(45) NOT NULL,
@@ -289,8 +288,6 @@ LIMIT 10;
289288
DROP TABLE t1;
290289
DROP TABLE t2;
291290

292-
--echo # End of Bug #58756
293-
294291
--echo #
295292
--echo # Bug#60085 crash in Item::save_in_field() with time data type
296293
--echo #
@@ -354,7 +351,9 @@ eval $query;
354351

355352
DROP TABLE t1,t2;
356353

357-
--echo End of 5.1 tests
354+
--echo #
355+
--echo # End of 5.1 tests
356+
--echo #
358357

359358
--echo #
360359
--echo # lp:827416 Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries
@@ -507,8 +506,6 @@ drop table t1,t2;
507506
--echo # for a subquery from the expression used in ref access
508507
--echo #
509508

510-
--source include/have_innodb.inc
511-
512509
CREATE TABLE t1 (i1 INT PRIMARY KEY) ENGINE=InnoDB;
513510
INSERT INTO t1 VALUES (1),(2);
514511

@@ -661,4 +658,6 @@ execute stmt;
661658

662659
drop table t1,t2;
663660

661+
--echo #
664662
--echo # End of 10.4 tests
663+
--echo #

sql/item.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7874,8 +7874,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
78747874
else if (!ref || ref == not_found_item)
78757875
{
78767876
DBUG_ASSERT(reference_trough_name != 0);
7877-
if (!(ref= resolve_ref_in_select_and_group(thd, this,
7878-
context->select_lex)))
7877+
if (!(ref= resolve_ref_in_select_and_group(thd, this, context->select_lex)))
78797878
goto error; /* Some error occurred (e.g. ambiguous names). */
78807879

78817880
if (ref == not_found_item) /* This reference was not resolved. */
@@ -7888,8 +7887,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
78887887
if (unlikely(!outer_context))
78897888
{
78907889
/* The current reference cannot be resolved in this query. */
7891-
my_error(ER_BAD_FIELD_ERROR,MYF(0),
7892-
this->full_name(), thd->where);
7890+
my_error(ER_BAD_FIELD_ERROR,MYF(0), full_name(), thd->where);
78937891
goto error;
78947892
}
78957893

sql/sql_base.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8453,7 +8453,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
84538453
select_lex->where= *conds;
84548454
}
84558455
thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
8456-
DBUG_RETURN(MY_TEST(thd->is_error()));
8456+
DBUG_RETURN(thd->is_error());
84578457

84588458
err_no_arena:
84598459
select_lex->is_item_list_lookup= save_is_item_list_lookup;

sql/sql_select.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24528,8 +24528,8 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
2452824528
if (find_order_in_list(thd, ref_pointer_array, tables, order, fields,
2452924529
all_fields, false, true, from_window_spec))
2453024530
return 1;
24531-
if ((*order->item)->with_window_func &&
24532-
context_analysis_place != IN_ORDER_BY)
24531+
Item * const item= *order->item;
24532+
if (item->with_window_func && context_analysis_place != IN_ORDER_BY)
2453324533
{
2453424534
my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0));
2453524535
return 1;
@@ -24540,20 +24540,18 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
2454024540
an ORDER BY clause
2454124541
*/
2454224542

24543-
if (for_union &&
24544-
((*order->item)->with_sum_func() ||
24545-
(*order->item)->with_window_func))
24543+
if (for_union && (item->with_sum_func() || item->with_window_func))
2454624544
{
2454724545
my_error(ER_AGGREGATE_ORDER_FOR_UNION, MYF(0), number);
2454824546
return 1;
2454924547
}
2455024548

24551-
if (!(*order->item)->with_sum_func())
24552-
continue;
24553-
24554-
if (from_window_spec && (*order->item)->type() != Item::SUM_FUNC_ITEM)
24555-
(*order->item)->split_sum_func(thd, ref_pointer_array,
24556-
all_fields, SPLIT_SUM_SELECT);
24549+
if (from_window_spec && item->with_sum_func() &&
24550+
item->type() != Item::SUM_FUNC_ITEM)
24551+
{
24552+
item->split_sum_func(thd, ref_pointer_array,
24553+
all_fields, SPLIT_SUM_SELECT);
24554+
}
2455724555
}
2455824556
return 0;
2455924557
}

0 commit comments

Comments
 (0)