MDEV-31992 Automatic conversion from LEX_STRING to LEX_CSTRING
- Adding automatic conversion operator from LEX_STRING to LEX_CSTRING Now a LEX_STRING can be passed directly to any function expecting a LEX_CSTRING parameter passed by value or by reference. - Removing a number of duplicate methods accepting LEX_STRING. Now the code used the LEX_CSTRING version.
This commit is contained in:
parent
9b0b314b17
commit
8951f7d940
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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 &&
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user