1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-14494 Move set_param_xxx() in sql_prepare.cc to methods in Item_param and Type_handler

- sql_prepare.cc: Moving functions set_param_xxx() as
  methods to Item_param

- Replacing a pointer to a function Item_param::set_param_func
  to Type_handler based implementation:
  Item_param::value now derives from Type_handler_hybrid_field_type.
  Adding new virtual methods Type_handler::Item_param_setup_conversion()
  and Type_handler::Item_param_set_param_func()

- Moving declaration of some Item_param members  from "public:" to "private:"
  (CONVERSION_INFO, value, decimal_value)

- Adding a new method Item_param::set_limit_clause_param(),
  to share duplicate code, as well as to encapsulate
  Item_param::value.

- Adding Item_param::setup_conversion_string() and
  Item_param::setup_conversion_blob() to share
  the code for binding from a client value
  (mysql_stmt_bind_param), and for binding from
  an expression (Item).

- Removing two different functions set_param_str_or_null()
  and set_param_str(). Adding a common method Item_param::set_param_str().
  Item_param::m_empty_string_is_null, used by Item_param::set_param_str().

- Removing the call for setup_one_conversion_function() from
  insert_params_from_actual_params_with_log(). It's not needed,
  because the call for ps_param->save_in_param() makes sure
  to initialized all data type dependent members properly,
  by calling setup_conversion_string() from
  Type_handler_string_result::Item_param_set_from_value()
  and by calling setup_conversion_blob() from
  Type_handler_blob_common::Item_param_set_from_value()

- Cleanup: removing multiplication to MY_CHARSET_BIN_MB_MAXLEN
  in a few places. It's 1 anyway, and will never change.
This commit is contained in:
Alexander Barkov
2017-11-24 12:40:00 +04:00
parent a18f6009e3
commit 6aedbf40e0
5 changed files with 297 additions and 189 deletions

View File

@ -805,6 +805,9 @@ public:
virtual uint32 max_display_length(const Item *item) const= 0;
virtual uint32 calc_pack_length(uint32 length) const= 0;
virtual bool Item_save_in_value(Item *item, st_value *value) const= 0;
virtual void Item_param_setup_conversion(THD *thd, Item_param *) const {}
virtual void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
virtual bool Item_param_set_from_value(THD *thd,
Item_param *param,
const Type_all_attributes *attr,
@ -1423,6 +1426,8 @@ public:
const Type_cast_attributes &attr) const;
uint Item_decimal_precision(const Item *item) const;
bool Item_save_in_value(Item *item, st_value *value) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
bool Item_param_set_from_value(THD *thd,
Item_param *param,
const Type_all_attributes *attr,
@ -1659,6 +1664,9 @@ public:
}
uint Item_decimal_precision(const Item *item) const;
bool Item_save_in_value(Item *item, st_value *value) const;
void Item_param_setup_conversion(THD *thd, Item_param *) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
bool Item_param_set_from_value(THD *thd,
Item_param *param,
const Type_all_attributes *attr,
@ -1785,6 +1793,8 @@ public:
const Record_addr &addr,
const Type_all_attributes &attr,
TABLE *table) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};
@ -1812,6 +1822,8 @@ public:
const Record_addr &addr,
const Type_all_attributes &attr,
TABLE *table) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};
@ -1842,6 +1854,8 @@ public:
const Record_addr &addr,
const Type_all_attributes &attr,
TABLE *table) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};
@ -1873,6 +1887,8 @@ public:
const Record_addr &addr,
const Type_all_attributes &attr,
TABLE *table) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};
@ -1996,6 +2012,8 @@ public:
const Record_addr &addr,
const Type_all_attributes &attr,
TABLE *table) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};
@ -2026,6 +2044,8 @@ public:
const Record_addr &addr,
const Type_all_attributes &attr,
TABLE *table) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};
@ -2070,6 +2090,8 @@ public:
bool set_comparator_func(Arg_comparator *cmp) const;
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const;
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};
@ -2153,6 +2175,8 @@ public:
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};
class Type_handler_date: public Type_handler_date_common
@ -2227,6 +2251,8 @@ public:
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};
@ -2307,6 +2333,8 @@ public:
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems) const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};
@ -2567,6 +2595,7 @@ public:
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems) const;
void Item_param_setup_conversion(THD *thd, Item_param *) const;
};
@ -2660,6 +2689,8 @@ public:
{
return false; // Materialization does not work with GEOMETRY columns
}
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
bool Item_param_set_from_value(THD *thd,
Item_param *param,
const Type_all_attributes *attr,
@ -2739,6 +2770,8 @@ public:
const handler *file,
const Schema_specification_st *schema)
const;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const;
};