Skip to content
/ server Public

Commit cd02709

Browse files
Olernovsanja-byelkin
authored andcommitted
MDEV-38574 Rename cloning functions of class Item and descendants
Rename `Item::clone_item()` to `clone_constant()`, and do the same for any overloads in descendant items. The function returns non-NULL only for items that represent constant literals.
1 parent f2b48e5 commit cd02709

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

sql/item.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3938,7 +3938,7 @@ void Item_decimal::set_decimal_value(my_decimal *value_par)
39383938
}
39393939

39403940

3941-
Item *Item_decimal::clone_item(THD *thd) const
3941+
Item *Item_decimal::clone_constant(THD *thd) const
39423942
{
39433943
return new (thd->mem_root) Item_decimal(thd, name.str, &decimal_value, decimals,
39443944
max_length);
@@ -3959,7 +3959,7 @@ my_decimal *Item_float::val_decimal(my_decimal *decimal_value)
39593959
}
39603960

39613961

3962-
Item *Item_float::clone_item(THD *thd) const
3962+
Item *Item_float::clone_constant(THD *thd) const
39633963
{
39643964
return new (thd->mem_root) Item_float(thd, name.str, value, decimals,
39653965
max_length);
@@ -4131,7 +4131,7 @@ Item *Item_null::safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
41314131
return this;
41324132
}
41334133

4134-
Item *Item_null::clone_item(THD *thd) const
4134+
Item *Item_null::clone_constant(THD *thd) const
41354135
{
41364136
return new (thd->mem_root) Item_null(thd, name.str);
41374137
}
@@ -4978,7 +4978,7 @@ Item *Item_param::value_clone_item(THD *thd) const
49784978
/* see comments in the header file */
49794979

49804980
Item *
4981-
Item_param::clone_item(THD *thd) const
4981+
Item_param::clone_constant(THD *thd) const
49824982
{
49834983
// There's no "default". See comments in Item_param::save_in_field().
49844984
switch (state) {
@@ -7109,7 +7109,7 @@ int Item_string::save_in_field(Field *field, bool no_conversions)
71097109
}
71107110

71117111

7112-
Item *Item_string::clone_item(THD *thd) const
7112+
Item *Item_string::clone_constant(THD *thd) const
71137113
{
71147114
LEX_CSTRING val;
71157115
str_value.get_value(&val);
@@ -7173,7 +7173,7 @@ int Item_int::save_in_field(Field *field, bool no_conversions)
71737173
}
71747174

71757175

7176-
Item *Item_int::clone_item(THD *thd) const
7176+
Item *Item_int::clone_constant(THD *thd) const
71777177
{
71787178
return new (thd->mem_root) Item_int(thd, name.str, value, max_length, unsigned_flag);
71797179
}
@@ -7202,7 +7202,7 @@ int Item_decimal::save_in_field(Field *field, bool no_conversions)
72027202
}
72037203

72047204

7205-
Item *Item_int_with_ref::clone_item(THD *thd) const
7205+
Item *Item_int_with_ref::clone_constant(THD *thd) const
72067206
{
72077207
DBUG_ASSERT(ref->const_item());
72087208
/*
@@ -7298,7 +7298,7 @@ Item *Item_uint::neg(THD *thd)
72987298
}
72997299

73007300

7301-
Item *Item_uint::clone_item(THD *thd) const
7301+
Item *Item_uint::clone_constant(THD *thd) const
73027302
{
73037303
return new (thd->mem_root) Item_uint(thd, name.str, value, max_length);
73047304
}
@@ -7536,7 +7536,7 @@ void Item_date_literal::print(String *str, enum_query_type query_type)
75367536
}
75377537

75387538

7539-
Item *Item_date_literal::clone_item(THD *thd) const
7539+
Item *Item_date_literal::clone_constant(THD *thd) const
75407540
{
75417541
return new (thd->mem_root) Item_date_literal(thd, &cached_time);
75427542
}
@@ -7561,7 +7561,7 @@ void Item_datetime_literal::print(String *str, enum_query_type query_type)
75617561
}
75627562

75637563

7564-
Item *Item_datetime_literal::clone_item(THD *thd) const
7564+
Item *Item_datetime_literal::clone_constant(THD *thd) const
75657565
{
75667566
return new (thd->mem_root) Item_datetime_literal(thd, &cached_time, decimals);
75677567
}
@@ -7586,7 +7586,7 @@ void Item_time_literal::print(String *str, enum_query_type query_type)
75867586
}
75877587

75887588

7589-
Item *Item_time_literal::clone_item(THD *thd) const
7589+
Item *Item_time_literal::clone_constant(THD *thd) const
75907590
{
75917591
return new (thd->mem_root) Item_time_literal(thd, &cached_time, decimals);
75927592
}
@@ -10564,7 +10564,7 @@ void Item_cache_temporal::store_packed(longlong val_arg, Item *example_arg)
1056410564
}
1056510565

1056610566

10567-
Item *Item_cache_temporal::clone_item(THD *thd) const
10567+
Item *Item_cache_temporal::clone_constant(THD *thd) const
1056810568
{
1056910569
Item_cache *tmp= type_handler()->Item_get_cache(thd, this);
1057010570
Item_cache_temporal *item= static_cast<Item_cache_temporal*>(tmp);

sql/item.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,7 @@ class Item :public Value_source,
19351935
For real clones look at deep_copy_with_checks()/shallow_copy_with_checks()
19361936
methods
19371937
*/
1938-
virtual Item *clone_item(THD *thd) const { return nullptr; }
1938+
virtual Item *clone_constant(THD *thd) const { return nullptr; }
19391939

19401940
virtual cond_result eq_cmp_result() const { return COND_OK; }
19411941
inline uint float_length(uint decimals_par) const
@@ -4011,7 +4011,7 @@ class Item_null :public Item_basic_constant
40114011
const Type_handler *type_handler() const override
40124012
{ return &type_handler_null; }
40134013
bool basic_const_item() const override { return true; }
4014-
Item *clone_item(THD *thd) const override;
4014+
Item *clone_constant(THD *thd) const override;
40154015
bool const_is_null() const override { return true; }
40164016
bool is_null() override { return true; }
40174017

@@ -4465,7 +4465,7 @@ class Item_param :public Item_basic_value,
44654465
basic_const_item returned TRUE.
44664466
*/
44674467
Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) override;
4468-
Item *clone_item(THD *thd) const override;
4468+
Item *clone_constant(THD *thd) const override;
44694469
void set_param_type_and_swap_value(Item_param *from);
44704470

44714471
Rewritable_query_parameter *get_rewritable_query_parameter() override
@@ -4575,7 +4575,7 @@ class Item_int :public Item_num
45754575
String *val_str(String*) override;
45764576
int save_in_field(Field *field, bool no_conversions) override;
45774577
bool is_order_clause_position() const override { return true; }
4578-
Item *clone_item(THD *thd) const override;
4578+
Item *clone_constant(THD *thd) const override;
45794579
void print(String *str, enum_query_type query_type) override;
45804580
Item *neg(THD *thd) override;
45814581
decimal_digits_t decimal_precision() const override
@@ -4647,7 +4647,7 @@ class Item_uint :public Item_int
46474647
Item_uint(THD *thd, ulonglong i): Item_int(thd, i, 10) {}
46484648
Item_uint(THD *thd, const char *str_arg, longlong i, uint length);
46494649
double val_real() override { return ulonglong2double((ulonglong)value); }
4650-
Item *clone_item(THD *thd) const override;
4650+
Item *clone_constant(THD *thd) const override;
46514651
Item *neg(THD *thd) override;
46524652
decimal_digits_t decimal_precision() const override
46534653
{ return decimal_digits_t(max_length); }
@@ -4709,7 +4709,7 @@ class Item_decimal :public Item_num
47094709
const my_decimal *const_ptr_my_decimal() const override
47104710
{ return &decimal_value; }
47114711
int save_in_field(Field *field, bool no_conversions) override;
4712-
Item *clone_item(THD *thd) const override;
4712+
Item *clone_constant(THD *thd) const override;
47134713
void print(String *str, enum_query_type query_type) override
47144714
{
47154715
decimal_value.to_string(&str_value);
@@ -4768,7 +4768,7 @@ class Item_float :public Item_num
47684768
}
47694769
String *val_str(String*) override;
47704770
my_decimal *val_decimal(my_decimal *) override;
4771-
Item *clone_item(THD *thd) const override;
4771+
Item *clone_constant(THD *thd) const override;
47724772
Item *neg(THD *thd) override;
47734773
void print(String *str, enum_query_type query_type) override;
47744774

@@ -4897,7 +4897,7 @@ class Item_string :public Item_literal
48974897
int save_in_field(Field *field, bool no_conversions) override;
48984898
const Type_handler *type_handler() const override
48994899
{ return &type_handler_varchar; }
4900-
Item *clone_item(THD *thd) const override;
4900+
Item *clone_constant(THD *thd) const override;
49014901
Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) override
49024902
{
49034903
return const_charset_converter(thd, tocs, true);
@@ -5367,7 +5367,7 @@ class Item_date_literal: public Item_temporal_literal
53675367
{
53685368
return cached_time.get_mysql_time();
53695369
}
5370-
Item *clone_item(THD *thd) const override;
5370+
Item *clone_constant(THD *thd) const override;
53715371
bool val_bool() override
53725372
{
53735373
return update_null() ? false : cached_time.to_bool();
@@ -5425,7 +5425,7 @@ class Item_time_literal final: public Item_temporal_literal
54255425
{
54265426
return cached_time.get_mysql_time();
54275427
}
5428-
Item *clone_item(THD *thd) const override;
5428+
Item *clone_constant(THD *thd) const override;
54295429
bool val_bool() override
54305430
{
54315431
return cached_time.to_bool();
@@ -5490,7 +5490,7 @@ class Item_datetime_literal: public Item_temporal_literal
54905490
{
54915491
return cached_time.get_mysql_time();
54925492
}
5493-
Item *clone_item(THD *thd) const override;
5493+
Item *clone_constant(THD *thd) const override;
54945494
bool val_bool() override
54955495
{
54965496
return update_null() ? false : cached_time.to_bool();
@@ -6671,7 +6671,7 @@ class Item_int_with_ref :public Item_int
66716671
{
66726672
return ref->save_in_field(field, no_conversions);
66736673
}
6674-
Item *clone_item(THD *thd) const override;
6674+
Item *clone_constant(THD *thd) const override;
66756675
Item *real_item() override { return ref; }
66766676
protected:
66776677
Item *shallow_copy(THD *thd) const override
@@ -7668,11 +7668,11 @@ class Item_cache_temporal: public Item_cache_int
76687668
}
76697669
void store_packed(longlong val_arg, Item *example);
76707670
/*
7671-
Having a clone_item method tells optimizer that this object
7671+
Having a clone_constant method tells optimizer that this object
76727672
is a constant and need not be optimized further.
76737673
Important when storing packed datetime values.
76747674
*/
7675-
Item *clone_item(THD *thd) const override;
7675+
Item *clone_constant(THD *thd) const override;
76767676
Item *convert_to_basic_const_item(THD *thd) override;
76777677
virtual Item *make_literal(THD *) =0;
76787678
};

sql/sql_select.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17802,7 +17802,7 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
1780217802
if (can_change_cond_ref_to_const(func, right_item, left_item,
1780317803
field_value_owner, field, value))
1780417804
{
17805-
Item *tmp=value->clone_item(thd);
17805+
Item *tmp=value->clone_constant(thd);
1780617806
if (tmp)
1780717807
{
1780817808
tmp->collation.set(right_item->collation);
@@ -17832,7 +17832,7 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
1783217832
else if (can_change_cond_ref_to_const(func, left_item, right_item,
1783317833
field_value_owner, field, value))
1783417834
{
17835-
Item *tmp= value->clone_item(thd);
17835+
Item *tmp= value->clone_constant(thd);
1783617836
if (tmp)
1783717837
{
1783817838
tmp->collation.set(left_item->collation);

0 commit comments

Comments
 (0)