mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +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:
140
sql/sql_type.cc
140
sql/sql_type.cc
@ -5053,7 +5053,7 @@ bool Type_handler_string_result::
|
||||
const st_value *val) const
|
||||
{
|
||||
param->unsigned_flag= false;
|
||||
param->value.cs_info.set(thd, attr->collation.collation);
|
||||
param->setup_conversion_string(thd, attr->collation.collation);
|
||||
/*
|
||||
Exact value of max_length is not known unless data is converted to
|
||||
charset of connection, so we have to set it later.
|
||||
@ -5086,7 +5086,7 @@ bool Type_handler_geometry::
|
||||
const st_value *val) const
|
||||
{
|
||||
param->unsigned_flag= false;
|
||||
param->value.cs_info.set(thd, &my_charset_bin);
|
||||
param->setup_conversion_blob(thd);
|
||||
param->set_handler(&type_handler_geometry);
|
||||
param->set_geometry_type(attr->uint_geometry_type());
|
||||
return param->set_str(val->m_string.ptr(), val->m_string.length(),
|
||||
@ -5476,3 +5476,139 @@ Item *Type_handler_long_blob::
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
void Type_handler_string_result::Item_param_setup_conversion(THD *thd,
|
||||
Item_param *param)
|
||||
const
|
||||
{
|
||||
param->setup_conversion_string(thd, thd->variables.character_set_client);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_blob_common::Item_param_setup_conversion(THD *thd,
|
||||
Item_param *param)
|
||||
const
|
||||
{
|
||||
param->setup_conversion_blob(thd);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_tiny::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos, ulong len) const
|
||||
{
|
||||
param->set_param_tiny(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_short::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos, ulong len) const
|
||||
{
|
||||
param->set_param_short(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_long::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos, ulong len) const
|
||||
{
|
||||
param->set_param_int32(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_longlong::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_param_int64(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_float::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_param_float(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_double::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_param_double(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_decimal_result::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_param_decimal(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_string_result::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_param_str(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_time_common::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_param_time(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_date_common::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_param_date(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_datetime_common::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_param_datetime(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_timestamp_common::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_param_datetime(pos, len);
|
||||
}
|
||||
|
||||
|
||||
void Type_handler::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_null(); // Not possible type code in the client-server protocol
|
||||
}
|
||||
|
||||
|
||||
void Type_handler_typelib::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_null(); // Not possible type code in the client-server protocol
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_SPATIAL
|
||||
void Type_handler_geometry::Item_param_set_param_func(Item_param *param,
|
||||
uchar **pos,
|
||||
ulong len) const
|
||||
{
|
||||
param->set_null(); // Not possible type code in the client-server protocol
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
Reference in New Issue
Block a user