Skip to content

Commit 3bda7d1

Browse files
committed
Merge from 5.5
2 parents 2cfd682 + 8b1d1cf commit 3bda7d1

11 files changed

Lines changed: 45 additions & 38 deletions

sql/item_cmpfunc.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ static uint collect_cmp_types(Item **items, uint nitems, bool skip_nulls= FALSE)
221221
items[i]->result_type() == ROW_RESULT) &&
222222
cmp_row_type(items[0], items[i]))
223223
return 0;
224-
found_types|= 1<< (uint)item_cmp_type(left_result,
225-
items[i]->result_type());
224+
found_types|= 1U << (uint)item_cmp_type(left_result,
225+
items[i]->result_type());
226226
}
227227
/*
228228
Even if all right-hand items are NULLs and we are skipping them all, we need
229229
at least one type bit in the found_type bitmask.
230230
*/
231231
if (skip_nulls && !found_types)
232-
found_types= 1 << (uint)left_result;
232+
found_types= 1U << (uint)left_result;
233233
return found_types;
234234
}
235235

@@ -3237,12 +3237,12 @@ Item *Item_func_case::find_item(String *str)
32373237
cmp_type= item_cmp_type(left_result_type, args[i]->result_type());
32383238
DBUG_ASSERT(cmp_type != ROW_RESULT);
32393239
DBUG_ASSERT(cmp_items[(uint)cmp_type]);
3240-
if (!(value_added_map & (1<<(uint)cmp_type)))
3240+
if (!(value_added_map & (1U << (uint)cmp_type)))
32413241
{
32423242
cmp_items[(uint)cmp_type]->store_value(args[first_expr_num]);
32433243
if ((null_value=args[first_expr_num]->null_value))
32443244
return else_expr_num != -1 ? args[else_expr_num] : 0;
3245-
value_added_map|= 1<<(uint)cmp_type;
3245+
value_added_map|= 1U << (uint)cmp_type;
32463246
}
32473247
if (!cmp_items[(uint)cmp_type]->cmp(args[i]) && !args[i]->null_value)
32483248
return args[i + 1];
@@ -3503,7 +3503,7 @@ void Item_func_case::fix_length_and_dec()
35033503
nagg++;
35043504
if (!(found_types= collect_cmp_types(agg, nagg)))
35053505
return;
3506-
if (found_types & (1 << STRING_RESULT))
3506+
if (found_types & (1U << STRING_RESULT))
35073507
{
35083508
/*
35093509
If we'll do string comparison, we also need to aggregate
@@ -3543,7 +3543,7 @@ void Item_func_case::fix_length_and_dec()
35433543
}
35443544
for (i= 0; i <= (uint)DECIMAL_RESULT; i++)
35453545
{
3546-
if (found_types & (1 << i) && !cmp_items[i])
3546+
if (found_types & (1U << i) && !cmp_items[i])
35473547
{
35483548
DBUG_ASSERT((Item_result)i != ROW_RESULT);
35493549
if (!(cmp_items[i]=
@@ -4392,7 +4392,7 @@ void Item_func_in::fix_length_and_dec()
43924392
}
43934393
for (i= 0; i <= (uint)DECIMAL_RESULT; i++)
43944394
{
4395-
if (found_types & 1 << i)
4395+
if (found_types & (1U << i))
43964396
{
43974397
(type_cnt)++;
43984398
cmp_type= (Item_result) i;
@@ -4583,7 +4583,7 @@ void Item_func_in::fix_length_and_dec()
45834583
{
45844584
for (i= 0; i <= (uint) DECIMAL_RESULT; i++)
45854585
{
4586-
if (found_types & (1 << i) && !cmp_items[i])
4586+
if (found_types & (1U << i) && !cmp_items[i])
45874587
{
45884588
if ((Item_result)i == STRING_RESULT &&
45894589
agg_arg_charsets_for_comparison(cmp_collation, args, arg_count))
@@ -4673,12 +4673,12 @@ longlong Item_func_in::val_int()
46734673
Item_result cmp_type= item_cmp_type(left_result_type, args[i]->result_type());
46744674
in_item= cmp_items[(uint)cmp_type];
46754675
DBUG_ASSERT(in_item);
4676-
if (!(value_added_map & (1 << (uint)cmp_type)))
4676+
if (!(value_added_map & (1U << (uint)cmp_type)))
46774677
{
46784678
in_item->store_value(args[0]);
46794679
if ((null_value= args[0]->null_value))
46804680
return 0;
4681-
value_added_map|= 1 << (uint)cmp_type;
4681+
value_added_map|= 1U << (uint)cmp_type;
46824682
}
46834683
if (!in_item->cmp(args[i]) && !args[i]->null_value)
46844684
return (longlong) (!negated);

sql/item_subselect.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,8 @@ Item_in_subselect::single_value_transformer(JOIN *join,
15281528
}
15291529

15301530
save_allow_sum_func= thd->lex->allow_sum_func;
1531-
thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
1531+
thd->lex->allow_sum_func|=
1532+
(nesting_map)1 << thd->lex->current_select->nest_level;
15321533
/*
15331534
Item_sum_(max|min) can't substitute other item => we can use 0 as
15341535
reference, also Item_sum_(max|min) can't be fixed after creation, so

sql/item_sum.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
153153
If it is there under a construct where it is not allowed
154154
we report an error.
155155
*/
156-
invalid= !(allow_sum_func & (1 << max_arg_level));
156+
invalid= !(allow_sum_func & ((nesting_map)1 << max_arg_level));
157157
}
158-
else if (max_arg_level >= 0 || !(allow_sum_func & (1 << nest_level)))
158+
else if (max_arg_level >= 0 ||
159+
!(allow_sum_func & ((nesting_map)1 << nest_level)))
159160
{
160161
/*
161162
The set function can be aggregated only in outer subqueries.
@@ -164,7 +165,8 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
164165
*/
165166
if (register_sum_func(thd, ref))
166167
return TRUE;
167-
invalid= aggr_level < 0 && !(allow_sum_func & (1 << nest_level));
168+
invalid= aggr_level < 0 &&
169+
!(allow_sum_func & ((nesting_map)1 << nest_level));
168170
if (!invalid && thd->variables.sql_mode & MODE_ANSI)
169171
invalid= aggr_level < 0 && max_arg_level < nest_level;
170172
}
@@ -312,14 +314,15 @@ bool Item_sum::register_sum_func(THD *thd, Item **ref)
312314
sl && sl->nest_level > max_arg_level;
313315
sl= sl->master_unit()->outer_select() )
314316
{
315-
if (aggr_level < 0 && (allow_sum_func & (1 << sl->nest_level)))
317+
if (aggr_level < 0 &&
318+
(allow_sum_func & ((nesting_map)1 << sl->nest_level)))
316319
{
317320
/* Found the most nested subquery where the function can be aggregated */
318321
aggr_level= sl->nest_level;
319322
aggr_sel= sl;
320323
}
321324
}
322-
if (sl && (allow_sum_func & (1 << sl->nest_level)))
325+
if (sl && (allow_sum_func & ((nesting_map)1 << sl->nest_level)))
323326
{
324327
/*
325328
We reached the subquery of level max_arg_level and checked
@@ -541,7 +544,7 @@ void Item_sum::update_used_tables ()
541544
used_tables_cache&= PSEUDO_TABLE_BITS;
542545

543546
/* the aggregate function is aggregated into its local context */
544-
used_tables_cache |= (1 << aggr_sel->join->tables) - 1;
547+
used_tables_cache|= ((table_map)1 << aggr_sel->join->tables) - 1;
545548
}
546549
}
547550

sql/opt_range.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11449,7 +11449,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
1144911449
cur_parts have bits set for only used keyparts.
1145011450
*/
1145111451
ulonglong all_parts, cur_parts;
11452-
all_parts= (1<<max_key_part) - 1;
11452+
all_parts= (1ULL << max_key_part) - 1;
1145311453
cur_parts= used_key_parts_map.to_ulonglong() >> 1;
1145411454
if (all_parts != cur_parts)
1145511455
goto next_index;

sql/sql_base.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8143,7 +8143,8 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
81438143
thd->mark_used_columns= mark_used_columns;
81448144
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
81458145
if (allow_sum_func)
8146-
thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
8146+
thd->lex->allow_sum_func|=
8147+
(nesting_map)1 << thd->lex->current_select->nest_level;
81478148
thd->where= THD::DEFAULT_WHERE;
81488149
save_is_item_list_lookup= thd->lex->current_select->is_item_list_lookup;
81498150
thd->lex->current_select->is_item_list_lookup= 0;

sql/sql_optimizer.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4094,7 +4094,7 @@ static void add_not_null_conds(JOIN *join)
40944094
{
40954095
for (uint keypart= 0; keypart < tab->ref.key_parts; keypart++)
40964096
{
4097-
if (tab->ref.null_rejecting & (1 << keypart))
4097+
if (tab->ref.null_rejecting & ((key_part_map)1 << keypart))
40984098
{
40994099
Item *item= tab->ref.items[keypart];
41004100
Item *notnull;
@@ -4363,7 +4363,7 @@ static bool find_eq_ref_candidate(TABLE *table, table_map sj_inner_tables)
43634363
if (!(keyuse->used_tables & sj_inner_tables) &&
43644364
!(keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL))
43654365
{
4366-
bound_parts |= 1 << keyuse->keypart;
4366+
bound_parts|= (key_part_map)1 << keyuse->keypart;
43674367
}
43684368
keyuse++;
43694369
} while (keyuse->key == key && keyuse->table == table);
@@ -8855,7 +8855,7 @@ static Item_cond_and *create_cond_for_const_ref(THD *thd, JOIN_TAB *join_tab)
88558855
Item *item= new Item_field(field);
88568856
if (!item)
88578857
DBUG_RETURN(NULL);
8858-
item= join_tab->ref.null_rejecting & (1 << i) ?
8858+
item= join_tab->ref.null_rejecting & ((key_part_map)1 << i) ?
88598859
(Item *)new Item_func_eq(item, value) :
88608860
(Item *)new Item_func_equal(item, value);
88618861
if (!item)

sql/sql_planner.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,8 @@ void Optimize_table_order::best_access_path(
633633
in ReuseRangeEstimateForRef-3.
634634
*/
635635
if (table->quick_keys.is_set(key) &&
636-
(const_part & ((1 << table->quick_key_parts[key])-1)) ==
636+
(const_part &
637+
(((key_part_map)1 << table->quick_key_parts[key])-1)) ==
637638
(((key_part_map)1 << table->quick_key_parts[key])-1) &&
638639
table->quick_n_ranges[key] == 1 &&
639640
records > (double) table->quick_rows[key])
@@ -807,7 +808,8 @@ void Optimize_table_order::best_access_path(
807808
*/
808809
if (table->quick_keys.is_set(key) &&
809810
table->quick_key_parts[key] <= max_key_part &&
810-
const_part & (1 << table->quick_key_parts[key]) &&
811+
const_part &
812+
((key_part_map)1 << table->quick_key_parts[key]) &&
811813
table->quick_n_ranges[key] == 1 + test(ref_or_null_part &
812814
const_part) &&
813815
records > (double) table->quick_rows[key])

sql/sql_resolver.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ JOIN::prepare(TABLE_LIST *tables_init,
175175
{
176176
nesting_map save_allow_sum_func= thd->lex->allow_sum_func;
177177
thd->where="having clause";
178-
thd->lex->allow_sum_func|= 1 << select_lex_arg->nest_level;
178+
thd->lex->allow_sum_func|= (nesting_map)1 << select_lex_arg->nest_level;
179179
select_lex->having_fix_field= 1;
180180
select_lex->resolve_place= st_select_lex::RESOLVE_HAVING;
181181
bool having_fix_rc= (!having->fixed &&
@@ -892,22 +892,22 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array,
892892
ORDER *group, bool *hidden_group_fields)
893893
{
894894
int res;
895-
nesting_map save_allow_sum_func=thd->lex->allow_sum_func ;
895+
st_select_lex *const select= thd->lex->current_select;
896+
nesting_map save_allow_sum_func=thd->lex->allow_sum_func;
896897
/*
897898
Need to save the value, so we can turn off only any new non_agg_field_used
898899
additions coming from the WHERE
899900
*/
900-
const bool saved_non_agg_field_used=
901-
thd->lex->current_select->non_agg_field_used();
901+
const bool saved_non_agg_field_used= select->non_agg_field_used();
902902
DBUG_ENTER("setup_without_group");
903903

904-
thd->lex->allow_sum_func&= ~(1 << thd->lex->current_select->nest_level);
904+
thd->lex->allow_sum_func&= ~((nesting_map)1 << select->nest_level);
905905
res= setup_conds(thd, tables, leaves, conds);
906906

907907
/* it's not wrong to have non-aggregated columns in a WHERE */
908-
thd->lex->current_select->set_non_agg_field_used(saved_non_agg_field_used);
908+
select->set_non_agg_field_used(saved_non_agg_field_used);
909909

910-
thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
910+
thd->lex->allow_sum_func|= (nesting_map)1 << select->nest_level;
911911

912912
int all_fields_count= all_fields.elements;
913913

@@ -917,7 +917,7 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array,
917917
const int hidden_order_fields_count= all_fields.elements - all_fields_count;
918918
all_fields_count= all_fields.elements;
919919

920-
thd->lex->allow_sum_func&= ~(1 << thd->lex->current_select->nest_level);
920+
thd->lex->allow_sum_func&= ~((nesting_map)1 << select->nest_level);
921921

922922
res= res || setup_group(thd, ref_pointer_array, tables, fields, all_fields,
923923
group);

sql/sql_select.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ bool create_ref_for_key(JOIN *join, JOIN_TAB *j, Key_use *org_keyuse,
16991699
j->ref.items[part_no]=keyuse->val; // Save for cond removal
17001700
j->ref.cond_guards[part_no]= keyuse->cond_guard;
17011701
if (keyuse->null_rejecting)
1702-
j->ref.null_rejecting |= 1 << part_no;
1702+
j->ref.null_rejecting|= (key_part_map)1 << part_no;
17031703
keyuse_uses_no_tables= keyuse_uses_no_tables && !keyuse->used_tables;
17041704

17051705
store_key* key= get_store_key(thd,

sql/sql_tmp_table.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -888,11 +888,11 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
888888
}
889889
else
890890
{
891-
recinfo->null_bit= 1 << (null_count & 7);
891+
recinfo->null_bit= (uint8)1 << (null_count & 7);
892892
recinfo->null_pos= null_count/8;
893893
}
894894
field->move_field(pos,null_flags+null_count/8,
895-
1 << (null_count & 7));
895+
(uint8)1 << (null_count & 7));
896896
null_count++;
897897
}
898898
else
@@ -1546,7 +1546,7 @@ TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list)
15461546
{
15471547
cur_field->move_field(field_pos, (uchar*) null_pos, null_bit);
15481548
null_bit<<= 1;
1549-
if (null_bit == (1 << 8))
1549+
if (null_bit == (uint8)1 << 8)
15501550
{
15511551
++null_pos;
15521552
null_bit= 1;

0 commit comments

Comments
 (0)