Commit b7814086 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-9235 Add Type_handler::is_param_long_data_type()

parent 33b6a347
...@@ -818,18 +818,6 @@ static void setup_one_conversion_function(THD *thd, Item_param *param, ...@@ -818,18 +818,6 @@ static void setup_one_conversion_function(THD *thd, Item_param *param,
#ifndef EMBEDDED_LIBRARY #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. 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, ...@@ -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 type (the types are supplied at execute). Check that the
supplied type of placeholder can accept a data stream. 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); DBUG_RETURN(1);
if (acc.append(param)) if (acc.append(param))
...@@ -954,7 +942,7 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array, ...@@ -954,7 +942,7 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array,
type (the types are supplied at execute). Check that the type (the types are supplied at execute). Check that the
supplied type of placeholder can accept a data stream. 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); DBUG_RETURN(1);
if (param->convert_str_value(stmt->thd)) if (param->convert_str_value(stmt->thd))
DBUG_RETURN(1); /* out of memory */ DBUG_RETURN(1); /* out of memory */
......
...@@ -367,6 +367,13 @@ class Type_handler ...@@ -367,6 +367,13 @@ class Type_handler
virtual enum_field_types real_field_type() const { return field_type(); } virtual enum_field_types real_field_type() const { return field_type(); }
virtual Item_result result_type() const= 0; virtual Item_result result_type() const= 0;
virtual Item_result cmp_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 const Type_handler *type_handler_for_comparison() const= 0;
virtual CHARSET_INFO *charset_for_protocol(const Item *item) const; virtual CHARSET_INFO *charset_for_protocol(const Item *item) const;
virtual const Type_handler* virtual const Type_handler*
...@@ -1433,6 +1440,7 @@ class Type_handler_string: public Type_handler_string_result ...@@ -1433,6 +1440,7 @@ class Type_handler_string: public Type_handler_string_result
virtual ~Type_handler_string() {} virtual ~Type_handler_string() {}
const Name name() const { return m_name_char; } const Name name() const { return m_name_char; }
enum_field_types field_type() const { return MYSQL_TYPE_STRING; } 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, Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const; const Field *target) const;
}; };
...@@ -1445,12 +1453,21 @@ class Type_handler_varchar: public Type_handler_string_result ...@@ -1445,12 +1453,21 @@ class Type_handler_varchar: public Type_handler_string_result
virtual ~Type_handler_varchar() {} virtual ~Type_handler_varchar() {}
const Name name() const { return m_name_varchar; } const Name name() const { return m_name_varchar; }
enum_field_types field_type() const { return MYSQL_TYPE_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, Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const; 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; static const Name m_name_tinyblob;
public: public:
...@@ -1462,7 +1479,7 @@ class Type_handler_tiny_blob: public Type_handler_string_result ...@@ -1462,7 +1479,7 @@ class Type_handler_tiny_blob: public Type_handler_string_result
}; };
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; static const Name m_name_mediumblob;
public: public:
...@@ -1474,7 +1491,7 @@ class Type_handler_medium_blob: public Type_handler_string_result ...@@ -1474,7 +1491,7 @@ class Type_handler_medium_blob: public Type_handler_string_result
}; };
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; static const Name m_name_longblob;
public: public:
...@@ -1486,7 +1503,7 @@ class Type_handler_long_blob: public Type_handler_string_result ...@@ -1486,7 +1503,7 @@ class Type_handler_long_blob: public Type_handler_string_result
}; };
class Type_handler_blob: public Type_handler_string_result class Type_handler_blob: public Type_handler_blob_common
{ {
static const Name m_name_blob; static const Name m_name_blob;
public: public:
...@@ -1506,6 +1523,7 @@ class Type_handler_geometry: public Type_handler_string_result ...@@ -1506,6 +1523,7 @@ class Type_handler_geometry: public Type_handler_string_result
virtual ~Type_handler_geometry() {} virtual ~Type_handler_geometry() {}
const Name name() const { return m_name_geometry; } const Name name() const { return m_name_geometry; }
enum_field_types field_type() const { return MYSQL_TYPE_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; const Type_handler *type_handler_for_comparison() const;
Field *make_conversion_table_field(TABLE *, uint metadata, Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const; const Field *target) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment