diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 4ede09a0d41..e13acc715d4 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -301,18 +301,22 @@ void my_sha512_input(void *context, const unsigned char *buf, size_t len); void my_sha512_result(void *context, unsigned char *digest); } extern "C" { -struct st_mysql_lex_string -{ - char *str; - size_t length; -}; -typedef struct st_mysql_lex_string MYSQL_LEX_STRING; struct st_mysql_const_lex_string { const char *str; size_t length; }; typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING; +struct st_mysql_lex_string +{ + char *str; + size_t length; + operator struct st_mysql_const_lex_string() const + { + return {str, length}; + } +}; +typedef struct st_mysql_lex_string MYSQL_LEX_STRING; extern struct thd_alloc_service_st { void *(*thd_alloc_func)(const THD*, size_t); void *(*thd_calloc_func)(const THD*, size_t); diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index ab32177fbb0..442eeb9c048 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -301,18 +301,22 @@ void my_sha512_input(void *context, const unsigned char *buf, size_t len); void my_sha512_result(void *context, unsigned char *digest); } extern "C" { -struct st_mysql_lex_string -{ - char *str; - size_t length; -}; -typedef struct st_mysql_lex_string MYSQL_LEX_STRING; struct st_mysql_const_lex_string { const char *str; size_t length; }; typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING; +struct st_mysql_lex_string +{ + char *str; + size_t length; + operator struct st_mysql_const_lex_string() const + { + return {str, length}; + } +}; +typedef struct st_mysql_lex_string MYSQL_LEX_STRING; extern struct thd_alloc_service_st { void *(*thd_alloc_func)(const THD*, size_t); void *(*thd_calloc_func)(const THD*, size_t); diff --git a/include/mysql/plugin_data_type.h.pp b/include/mysql/plugin_data_type.h.pp index 34b8dadd75e..5d5812e50fc 100644 --- a/include/mysql/plugin_data_type.h.pp +++ b/include/mysql/plugin_data_type.h.pp @@ -301,18 +301,22 @@ void my_sha512_input(void *context, const unsigned char *buf, size_t len); void my_sha512_result(void *context, unsigned char *digest); } extern "C" { -struct st_mysql_lex_string -{ - char *str; - size_t length; -}; -typedef struct st_mysql_lex_string MYSQL_LEX_STRING; struct st_mysql_const_lex_string { const char *str; size_t length; }; typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING; +struct st_mysql_lex_string +{ + char *str; + size_t length; + operator struct st_mysql_const_lex_string() const + { + return {str, length}; + } +}; +typedef struct st_mysql_lex_string MYSQL_LEX_STRING; extern struct thd_alloc_service_st { void *(*thd_alloc_func)(const THD*, size_t); void *(*thd_calloc_func)(const THD*, size_t); diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp index 449ee46d585..fc6c8a708c1 100644 --- a/include/mysql/plugin_encryption.h.pp +++ b/include/mysql/plugin_encryption.h.pp @@ -301,18 +301,22 @@ void my_sha512_input(void *context, const unsigned char *buf, size_t len); void my_sha512_result(void *context, unsigned char *digest); } extern "C" { -struct st_mysql_lex_string -{ - char *str; - size_t length; -}; -typedef struct st_mysql_lex_string MYSQL_LEX_STRING; struct st_mysql_const_lex_string { const char *str; size_t length; }; typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING; +struct st_mysql_lex_string +{ + char *str; + size_t length; + operator struct st_mysql_const_lex_string() const + { + return {str, length}; + } +}; +typedef struct st_mysql_lex_string MYSQL_LEX_STRING; extern struct thd_alloc_service_st { void *(*thd_alloc_func)(const THD*, size_t); void *(*thd_calloc_func)(const THD*, size_t); diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 42c3e093150..85c73919bfd 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -301,18 +301,22 @@ void my_sha512_input(void *context, const unsigned char *buf, size_t len); void my_sha512_result(void *context, unsigned char *digest); } extern "C" { -struct st_mysql_lex_string -{ - char *str; - size_t length; -}; -typedef struct st_mysql_lex_string MYSQL_LEX_STRING; struct st_mysql_const_lex_string { const char *str; size_t length; }; typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING; +struct st_mysql_lex_string +{ + char *str; + size_t length; + operator struct st_mysql_const_lex_string() const + { + return {str, length}; + } +}; +typedef struct st_mysql_lex_string MYSQL_LEX_STRING; extern struct thd_alloc_service_st { void *(*thd_alloc_func)(const THD*, size_t); void *(*thd_calloc_func)(const THD*, size_t); diff --git a/include/mysql/plugin_function.h.pp b/include/mysql/plugin_function.h.pp index 2e78d23ae2e..1abb2f47ede 100644 --- a/include/mysql/plugin_function.h.pp +++ b/include/mysql/plugin_function.h.pp @@ -301,18 +301,22 @@ void my_sha512_input(void *context, const unsigned char *buf, size_t len); void my_sha512_result(void *context, unsigned char *digest); } extern "C" { -struct st_mysql_lex_string -{ - char *str; - size_t length; -}; -typedef struct st_mysql_lex_string MYSQL_LEX_STRING; struct st_mysql_const_lex_string { const char *str; size_t length; }; typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING; +struct st_mysql_lex_string +{ + char *str; + size_t length; + operator struct st_mysql_const_lex_string() const + { + return {str, length}; + } +}; +typedef struct st_mysql_lex_string MYSQL_LEX_STRING; extern struct thd_alloc_service_st { void *(*thd_alloc_func)(const THD*, size_t); void *(*thd_calloc_func)(const THD*, size_t); diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp index 138422e2b3e..1284a3b0135 100644 --- a/include/mysql/plugin_password_validation.h.pp +++ b/include/mysql/plugin_password_validation.h.pp @@ -301,18 +301,22 @@ void my_sha512_input(void *context, const unsigned char *buf, size_t len); void my_sha512_result(void *context, unsigned char *digest); } extern "C" { -struct st_mysql_lex_string -{ - char *str; - size_t length; -}; -typedef struct st_mysql_lex_string MYSQL_LEX_STRING; struct st_mysql_const_lex_string { const char *str; size_t length; }; typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING; +struct st_mysql_lex_string +{ + char *str; + size_t length; + operator struct st_mysql_const_lex_string() const + { + return {str, length}; + } +}; +typedef struct st_mysql_lex_string MYSQL_LEX_STRING; extern struct thd_alloc_service_st { void *(*thd_alloc_func)(const THD*, size_t); void *(*thd_calloc_func)(const THD*, size_t); diff --git a/include/mysql/service_thd_alloc.h b/include/mysql/service_thd_alloc.h index e85a8e8c4e0..014277b5d00 100644 --- a/include/mysql/service_thd_alloc.h +++ b/include/mysql/service_thd_alloc.h @@ -35,13 +35,6 @@ extern "C" { #endif -struct st_mysql_lex_string -{ - char *str; - size_t length; -}; -typedef struct st_mysql_lex_string MYSQL_LEX_STRING; - struct st_mysql_const_lex_string { const char *str; @@ -49,6 +42,20 @@ struct st_mysql_const_lex_string }; typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING; +struct st_mysql_lex_string +{ + char *str; + size_t length; +#ifdef __cplusplus + // Allow automatic cast from LEX_STRING to LEX_CSTRING in c++. + operator struct st_mysql_const_lex_string() const + { + return {str, length}; + } +#endif +}; +typedef struct st_mysql_lex_string MYSQL_LEX_STRING; + extern struct thd_alloc_service_st { void *(*thd_alloc_func)(const MYSQL_THD, size_t); void *(*thd_calloc_func)(const MYSQL_THD, size_t); diff --git a/plugin/metadata_lock_info/metadata_lock_info.cc b/plugin/metadata_lock_info/metadata_lock_info.cc index a85048de47f..35b9b507513 100644 --- a/plugin/metadata_lock_info/metadata_lock_info.cc +++ b/plugin/metadata_lock_info/metadata_lock_info.cc @@ -70,7 +70,7 @@ int i_s_metadata_lock_info_fill_row( DBUG_RETURN(0); table->field[0]->store((longlong) mdl_ctx->get_thread_id(), TRUE); table->field[1]->set_notnull(); - table->field[1]->store(mdl_ticket->get_type_name(), system_charset_info); + table->field[1]->store(*mdl_ticket->get_type_name(), system_charset_info); table->field[2]->set_null(); table->field[3]->set_notnull(); table->field[3]->store( diff --git a/sql/field.h b/sql/field.h index edf6cc3400f..ed7ded2f5c1 100644 --- a/sql/field.h +++ b/sql/field.h @@ -981,11 +981,6 @@ public: enum_check_fields check_level); int store_text(const char *to, size_t length, CHARSET_INFO *cs, enum_check_fields check_level); - int store(const LEX_STRING *ls, CHARSET_INFO *cs) - { - DBUG_ASSERT(ls->length < UINT_MAX32); - return store(ls->str, (uint) ls->length, cs); - } int store(const LEX_CSTRING *ls, CHARSET_INFO *cs) { DBUG_ASSERT(ls->length < UINT_MAX32); diff --git a/sql/sp_instr.h b/sql/sp_instr.h index 8a7ad48d145..f71030eadfe 100644 --- a/sql/sp_instr.h +++ b/sql/sp_instr.h @@ -514,7 +514,7 @@ public: protected: LEX_CSTRING get_expr_query() const override { - return LEX_CSTRING{m_query.str, m_query.length}; + return m_query; } bool on_after_expr_parsing(THD *) override diff --git a/sql/sql_cmd.h b/sql/sql_cmd.h index 985be776713..bedd7e118f0 100644 --- a/sql/sql_cmd.h +++ b/sql/sql_cmd.h @@ -133,11 +133,6 @@ public: Storage_engine_name(const LEX_CSTRING &name) :m_storage_engine_name(name) { } - Storage_engine_name(const LEX_STRING &name) - { - m_storage_engine_name.str= name.str; - m_storage_engine_name.length= name.length; - } bool resolve_storage_engine_with_error(THD *thd, handlerton **ha, bool tmp_table); diff --git a/sql/sql_string.h b/sql/sql_string.h index d112a8842b9..1f21df619bf 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -1052,13 +1052,6 @@ public: } // Append with optional character set conversion from ASCII (e.g. to UCS2) - bool append(const LEX_STRING *ls) - { - DBUG_ASSERT(ls->length < UINT_MAX32 && - ((ls->length == 0 && !ls->str) || - ls->length == strlen(ls->str))); - return append(ls->str, (uint32) ls->length); - } bool append(const LEX_CSTRING *ls) { DBUG_ASSERT(ls->length < UINT_MAX32 && diff --git a/sql/vers_string.h b/sql/vers_string.h index c5be9c359e3..93740ea8523 100644 --- a/sql/vers_string.h +++ b/sql/vers_string.h @@ -57,9 +57,6 @@ public: Lex_cstring_with_compare(const char *_str, size_t _len) : Lex_cstring(_str, _len) { } - Lex_cstring_with_compare(const LEX_STRING src) : - Lex_cstring(src.str, src.length) - { } Lex_cstring_with_compare(const LEX_CSTRING src) : Lex_cstring(src.str, src.length) { } Lex_cstring_with_compare(const char *_str) : Lex_cstring(_str, strlen(_str)) diff --git a/storage/spider/spd_malloc.cc b/storage/spider/spd_malloc.cc index 56f8218853b..9b87560d218 100644 --- a/storage/spider/spd_malloc.cc +++ b/storage/spider/spd_malloc.cc @@ -861,7 +861,7 @@ bool spider_string::append( DBUG_ASSERT(mem_calc_inited); DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || current_alloc_mem == str.alloced_length()); - bool res = str.append(ls); + bool res = str.append(*ls); SPIDER_STRING_CALC_MEM; DBUG_RETURN(res); }