diff options
author | Alexander Barkov <bar@mariadb.org> | 2017-04-22 16:49:26 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2017-04-22 16:49:26 +0400 |
commit | b7814086017b66f8a8ef1762096ea9394a26aa7a (patch) | |
tree | cb3472e6d3e0db43b8dccbf7a8cb5a815fbf7a4e | |
parent | 33b6a347e433ac3250959986c3955d0daa45839b (diff) | |
download | mariadb-git-b7814086017b66f8a8ef1762096ea9394a26aa7a.tar.gz |
MDEV-9235 Add Type_handler::is_param_long_data_type()
-rw-r--r-- | sql/sql_prepare.cc | 16 | ||||
-rw-r--r-- | sql/sql_type.h | 26 |
2 files changed, 24 insertions, 18 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 3aa6f531e01..5f17cdec049 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -819,18 +819,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. Update the parameter markers by reading data from the packet and @@ -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 */ diff --git a/sql/sql_type.h b/sql/sql_type.h index bd5290ad1fe..43736bddca7 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -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; |