1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-9235 Add Type_handler::is_param_long_data_type()

This commit is contained in:
Alexander Barkov
2017-04-22 16:49:26 +04:00
parent 33b6a347e4
commit b781408601
2 changed files with 24 additions and 18 deletions

View File

@ -818,18 +818,6 @@ static void setup_one_conversion_function(THD *thd, Item_param *param,
#ifndef EMBEDDED_LIBRARY
/**
Check whether this parameter data type is compatible with long data.
Used to detect whether a long data stream has been supplied to a
incompatible data type.
*/
inline bool is_param_long_data_type(Item_param *param)
{
return ((param->field_type() >= MYSQL_TYPE_TINY_BLOB) &&
(param->field_type() <= MYSQL_TYPE_STRING));
}
/**
Routines to assign parameters from data supplied by the client.
@ -907,7 +895,7 @@ static bool insert_params_with_log(Prepared_statement *stmt, uchar *null_array,
type (the types are supplied at execute). Check that the
supplied type of placeholder can accept a data stream.
*/
else if (! is_param_long_data_type(param))
else if (!param->type_handler()->is_param_long_data_type())
DBUG_RETURN(1);
if (acc.append(param))
@ -954,7 +942,7 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array,
type (the types are supplied at execute). Check that the
supplied type of placeholder can accept a data stream.
*/
else if (! is_param_long_data_type(param))
else if (!param->type_handler()->is_param_long_data_type())
DBUG_RETURN(1);
if (param->convert_str_value(stmt->thd))
DBUG_RETURN(1); /* out of memory */

View File

@ -367,6 +367,13 @@ public:
virtual enum_field_types real_field_type() const { return field_type(); }
virtual Item_result result_type() const= 0;
virtual Item_result cmp_type() const= 0;
/**
Prepared statement long data:
Check whether this parameter data type is compatible with long data.
Used to detect whether a long data stream has been supplied to a
incompatible data type.
*/
virtual bool is_param_long_data_type() const { return false; }
virtual const Type_handler *type_handler_for_comparison() const= 0;
virtual CHARSET_INFO *charset_for_protocol(const Item *item) const;
virtual const Type_handler*
@ -1433,6 +1440,7 @@ public:
virtual ~Type_handler_string() {}
const Name name() const { return m_name_char; }
enum_field_types field_type() const { return MYSQL_TYPE_STRING; }
bool is_param_long_data_type() const { return true; }
Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const;
};
@ -1445,12 +1453,21 @@ public:
virtual ~Type_handler_varchar() {}
const Name name() const { return m_name_varchar; }
enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
bool is_param_long_data_type() const { return true; }
Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const;
};
class Type_handler_tiny_blob: public Type_handler_string_result
class Type_handler_blob_common: public Type_handler_string_result
{
public:
virtual ~Type_handler_blob_common() { }
bool is_param_long_data_type() const { return true; }
};
class Type_handler_tiny_blob: public Type_handler_blob_common
{
static const Name m_name_tinyblob;
public:
@ -1462,7 +1479,7 @@ public:
};
class Type_handler_medium_blob: public Type_handler_string_result
class Type_handler_medium_blob: public Type_handler_blob_common
{
static const Name m_name_mediumblob;
public:
@ -1474,7 +1491,7 @@ public:
};
class Type_handler_long_blob: public Type_handler_string_result
class Type_handler_long_blob: public Type_handler_blob_common
{
static const Name m_name_longblob;
public:
@ -1486,7 +1503,7 @@ public:
};
class Type_handler_blob: public Type_handler_string_result
class Type_handler_blob: public Type_handler_blob_common
{
static const Name m_name_blob;
public:
@ -1506,6 +1523,7 @@ public:
virtual ~Type_handler_geometry() {}
const Name name() const { return m_name_geometry; }
enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; }
bool is_param_long_data_type() const { return true; }
const Type_handler *type_handler_for_comparison() const;
Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const;