cleanup: formatting

also avoid an oxymoron of using `MYSQL_PLUGIN_IMPORT` under
`#ifdef MYSQL_SERVER`, and empty_clex_str is so trivial that a plugin
can define it if needed.
This commit is contained in:
Sergei Golubchik 2021-06-09 18:31:23 +02:00
parent 89342a3bd5
commit 3648b333c7
13 changed files with 65 additions and 90 deletions

View File

@ -1342,15 +1342,13 @@ Type_handler_inet6::character_or_binary_string_to_native(THD *thd,
Inet6_null tmp(*str); Inet6_null tmp(*str);
if (tmp.is_null()) if (tmp.is_null())
thd->push_warning_wrong_value(Sql_condition::WARN_LEVEL_WARN, thd->push_warning_wrong_value(Sql_condition::WARN_LEVEL_WARN,
name().ptr(), name().ptr(), ErrConvString(str).ptr());
ErrConvString(str).ptr());
return tmp.is_null() || tmp.to_native(to); return tmp.is_null() || tmp.to_native(to);
} }
bool bool
Type_handler_inet6::Item_save_in_value(THD *thd, Type_handler_inet6::Item_save_in_value(THD *thd, Item *item,
Item *item,
st_value *value) const st_value *value) const
{ {
value->m_type= DYN_COL_STRING; value->m_type= DYN_COL_STRING;
@ -1366,8 +1364,7 @@ Type_handler_inet6::Item_save_in_value(THD *thd,
FROM t1; FROM t1;
*/ */
thd->push_warning_wrong_value(Sql_condition::WARN_LEVEL_WARN, thd->push_warning_wrong_value(Sql_condition::WARN_LEVEL_WARN,
name().ptr(), name().ptr(), ErrConvString(str).ptr());
ErrConvString(str).ptr());
value->m_type= DYN_COL_NULL; value->m_type= DYN_COL_NULL;
return true; return true;
} }

View File

@ -1891,8 +1891,7 @@ void Field::copy_from_tmp(int row_offset)
bool Field::send(Protocol *protocol) bool Field::send(Protocol *protocol)
{ {
char buff[MAX_FIELD_WIDTH]; StringBuffer<MAX_FIELD_WIDTH> tmp(charset());
String tmp(buff,sizeof(buff),charset());
val_str(&tmp); val_str(&tmp);
return protocol->store(tmp.ptr(), tmp.length(), tmp.charset()); return protocol->store(tmp.ptr(), tmp.length(), tmp.charset());
} }
@ -9401,8 +9400,7 @@ String *Field_set::val_str(String *val_buffer,
{ {
if (val_buffer->length()) if (val_buffer->length())
val_buffer->append(&field_separator, 1, &my_charset_latin1); val_buffer->append(&field_separator, 1, &my_charset_latin1);
String str(typelib->type_names[bitnr], String str(typelib->type_names[bitnr], typelib->type_lengths[bitnr],
typelib->type_lengths[bitnr],
field_charset()); field_charset());
val_buffer->append(str); val_buffer->append(str);
} }

View File

@ -4805,14 +4805,11 @@ private:
class Field_set final :public Field_enum { class Field_set final :public Field_enum {
public: public:
Field_set(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_set(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg, enum utype unireg_check_arg,
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg, const LEX_CSTRING *field_name_arg, uint32 packlength_arg,
uint32 packlength_arg,
const TYPELIB *typelib_arg, const DTCollation &collation) const TYPELIB *typelib_arg, const DTCollation &collation)
:Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
unireg_check_arg, field_name_arg, field_name_arg, packlength_arg, typelib_arg, collation),
packlength_arg,
typelib_arg, collation),
empty_set_string("", 0, collation.collation) empty_set_string("", 0, collation.collation)
{ {
flags=(flags & ~ENUM_FLAG) | SET_FLAG; flags=(flags & ~ENUM_FLAG) | SET_FLAG;

View File

@ -7517,26 +7517,20 @@ public:
Item_type_holder do not need cleanup() because its time of live limited by Item_type_holder do not need cleanup() because its time of live limited by
single SP/PS execution. single SP/PS execution.
*/ */
class Item_type_holder: public Item, class Item_type_holder: public Item, public Type_handler_hybrid_field_type
public Type_handler_hybrid_field_type
{ {
protected: protected:
const TYPELIB *enum_set_typelib; const TYPELIB *enum_set_typelib;
public: public:
Item_type_holder(THD *thd, Item_type_holder(THD *thd, Item *item, const Type_handler *handler,
Item *item, const Type_all_attributes *attr, bool maybe_null_arg)
const Type_handler *handler, :Item(thd), Type_handler_hybrid_field_type(handler),
const Type_all_attributes *attr,
bool maybe_null_arg)
:Item(thd),
Type_handler_hybrid_field_type(handler),
enum_set_typelib(attr->get_typelib()) enum_set_typelib(attr->get_typelib())
{ {
name= item->name; name= item->name;
Type_std_attributes::set(*attr); Type_std_attributes::set(*attr);
set_maybe_null(maybe_null_arg); set_maybe_null(maybe_null_arg);
copy_flags(item, copy_flags(item, item_base_t::IS_EXPLICIT_NAME |
item_base_t::IS_EXPLICIT_NAME |
item_base_t::IS_IN_WITH_CYCLE); item_base_t::IS_IN_WITH_CYCLE);
} }

View File

@ -4532,9 +4532,9 @@ error:
@retval TRUE Failure (OOM). @retval TRUE Failure (OOM).
*/ */
bool DML_prelocking_strategy:: bool DML_prelocking_strategy::handle_routine(THD *thd,
handle_routine(THD *thd, Query_tables_list *prelocking_ctx, Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt,
Sroutine_hash_entry *rt, sp_head *sp, bool *need_prelocking) sp_head *sp, bool *need_prelocking)
{ {
/* /*
We assume that for any "CALL proc(...)" statement sroutines_list will We assume that for any "CALL proc(...)" statement sroutines_list will
@ -4668,8 +4668,8 @@ prepare_fk_prelocking_list(THD *thd, Query_tables_list *prelocking_ctx,
// FK_OPTION_RESTRICT and FK_OPTION_NO_ACTION only need read access // FK_OPTION_RESTRICT and FK_OPTION_NO_ACTION only need read access
thr_lock_type lock_type; thr_lock_type lock_type;
if ((op & (1 << TRG_EVENT_DELETE) && fk_modifies_child(fk->delete_method)) if ((op & trg2bit(TRG_EVENT_DELETE) && fk_modifies_child(fk->delete_method))
|| (op & (1 << TRG_EVENT_UPDATE) && fk_modifies_child(fk->update_method))) || (op & trg2bit(TRG_EVENT_UPDATE) && fk_modifies_child(fk->update_method)))
lock_type= TL_WRITE_ALLOW_WRITE; lock_type= TL_WRITE_ALLOW_WRITE;
else else
lock_type= TL_READ; lock_type= TL_READ;
@ -4715,9 +4715,9 @@ prepare_fk_prelocking_list(THD *thd, Query_tables_list *prelocking_ctx,
@retval TRUE Failure (OOM). @retval TRUE Failure (OOM).
*/ */
bool DML_prelocking_strategy:: bool DML_prelocking_strategy::handle_table(THD *thd,
handle_table(THD *thd, Query_tables_list *prelocking_ctx, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
TABLE_LIST *table_list, bool *need_prelocking) bool *need_prelocking)
{ {
DBUG_ENTER("handle_table"); DBUG_ENTER("handle_table");
TABLE *table= table_list->table; TABLE *table= table_list->table;
@ -4846,9 +4846,9 @@ err:
@retval TRUE Failure (OOM). @retval TRUE Failure (OOM).
*/ */
bool DML_prelocking_strategy:: bool DML_prelocking_strategy::handle_view(THD *thd,
handle_view(THD *thd, Query_tables_list *prelocking_ctx, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
TABLE_LIST *table_list, bool *need_prelocking) bool *need_prelocking)
{ {
if (table_list->view->uses_stored_routines()) if (table_list->view->uses_stored_routines())
{ {
@ -4886,9 +4886,9 @@ handle_view(THD *thd, Query_tables_list *prelocking_ctx,
@retval TRUE Failure (OOM). @retval TRUE Failure (OOM).
*/ */
bool Lock_tables_prelocking_strategy:: bool Lock_tables_prelocking_strategy::handle_table(THD *thd,
handle_table(THD *thd, Query_tables_list *prelocking_ctx, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
TABLE_LIST *table_list, bool *need_prelocking) bool *need_prelocking)
{ {
TABLE_LIST **last= prelocking_ctx->query_tables_last; TABLE_LIST **last= prelocking_ctx->query_tables_last;
@ -4919,9 +4919,9 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
a simple view, but one that uses stored routines. a simple view, but one that uses stored routines.
*/ */
bool Alter_table_prelocking_strategy:: bool Alter_table_prelocking_strategy::handle_routine(THD *thd,
handle_routine(THD *thd, Query_tables_list *prelocking_ctx, Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt,
Sroutine_hash_entry *rt, sp_head *sp, bool *need_prelocking) sp_head *sp, bool *need_prelocking)
{ {
return FALSE; return FALSE;
} }
@ -4945,9 +4945,9 @@ handle_routine(THD *thd, Query_tables_list *prelocking_ctx,
@retval TRUE Failure (OOM). @retval TRUE Failure (OOM).
*/ */
bool Alter_table_prelocking_strategy:: bool Alter_table_prelocking_strategy::handle_table(THD *thd,
handle_table(THD *thd, Query_tables_list *prelocking_ctx, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
TABLE_LIST *table_list, bool *need_prelocking) bool *need_prelocking)
{ {
return FALSE; return FALSE;
} }
@ -4960,9 +4960,9 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
to be materialized. to be materialized.
*/ */
bool Alter_table_prelocking_strategy:: bool Alter_table_prelocking_strategy::handle_view(THD *thd,
handle_view(THD *thd, Query_tables_list *prelocking_ctx, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
TABLE_LIST *table_list, bool *need_prelocking) bool *need_prelocking)
{ {
return FALSE; return FALSE;
} }

View File

@ -2977,8 +2977,8 @@ public:
}; };
bool Delayed_prelocking_strategy:: bool Delayed_prelocking_strategy::handle_table(THD *thd,
handle_table(THD *thd, Query_tables_list *prelocking_ctx, Query_tables_list *prelocking_ctx,
TABLE_LIST *table_list, bool *need_prelocking) TABLE_LIST *table_list, bool *need_prelocking)
{ {
DBUG_ASSERT(table_list->lock_type == TL_WRITE_DELAYED); DBUG_ASSERT(table_list->lock_type == TL_WRITE_DELAYED);
@ -2992,10 +2992,9 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
} }
bool Delayed_prelocking_strategy:: bool Delayed_prelocking_strategy::handle_routine(THD *thd,
handle_routine(THD *thd, Query_tables_list *prelocking_ctx, Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt,
Sroutine_hash_entry *rt, sp_head *sp, sp_head *sp, bool *need_prelocking)
bool *need_prelocking)
{ {
/* LEX used by the delayed insert thread has no routines. */ /* LEX used by the delayed insert thread has no routines. */
DBUG_ASSERT(0); DBUG_ASSERT(0);

View File

@ -388,7 +388,7 @@ void binlog_unsafe_map_init();
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
extern const LEX_STRING empty_lex_str; extern const LEX_STRING empty_lex_str;
extern MYSQL_PLUGIN_IMPORT const LEX_CSTRING empty_clex_str; extern const LEX_CSTRING empty_clex_str;
extern const LEX_CSTRING star_clex_str; extern const LEX_CSTRING star_clex_str;
extern const LEX_CSTRING param_clex_str; extern const LEX_CSTRING param_clex_str;

View File

@ -51,11 +51,11 @@ public:
int level; int level;
String field; String field;
String value; String value;
XML_TAG(int l, String f, String v); XML_TAG(int l, const String &f, const String &v);
}; };
XML_TAG::XML_TAG(int l, String f, String v) XML_TAG::XML_TAG(int l, const String &f, const String &v)
{ {
level= l; level= l;
field.append(f); field.append(f);

View File

@ -10364,10 +10364,8 @@ bool parse_sql(THD *thd, Parser_state *parser_state,
/* Parse the query. */ /* Parse the query. */
bool mysql_parse_status= bool mysql_parse_status= thd->variables.sql_mode & MODE_ORACLE
((thd->variables.sql_mode & MODE_ORACLE) ? ? ORAparse(thd) : MYSQLparse(thd);
ORAparse(thd) :
MYSQLparse(thd)) != 0;
DBUG_ASSERT(opt_bootstrap || mysql_parse_status || DBUG_ASSERT(opt_bootstrap || mysql_parse_status ||
thd->lex->select_stack_top == 0); thd->lex->select_stack_top == 0);
thd->lex->current_select= thd->lex->first_select_lex(); thd->lex->current_select= thd->lex->first_select_lex();

View File

@ -5002,8 +5002,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
/* Allocate query. */ /* Allocate query. */
if (expanded_query->length() && if (expanded_query->length() &&
alloc_query(thd, (char*) expanded_query->ptr(), alloc_query(thd, expanded_query->ptr(), expanded_query->length()))
expanded_query->length()))
{ {
my_error(ER_OUTOFMEMORY, MYF(ME_FATAL), expanded_query->length()); my_error(ER_OUTOFMEMORY, MYF(ME_FATAL), expanded_query->length());
goto error; goto error;
@ -5040,12 +5039,9 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
if (query_cache_send_result_to_client(thd, thd->query(), if (query_cache_send_result_to_client(thd, thd->query(),
thd->query_length()) <= 0) thd->query_length()) <= 0)
{ {
MYSQL_QUERY_EXEC_START(thd->query(), MYSQL_QUERY_EXEC_START(thd->query(), thd->thread_id, thd->get_db(),
thd->thread_id,
thd->get_db(),
&thd->security_ctx->priv_user[0], &thd->security_ctx->priv_user[0],
(char *) thd->security_ctx->host_or_ip, (char *) thd->security_ctx->host_or_ip, 1);
1);
error= mysql_execute_command(thd); error= mysql_execute_command(thd);
MYSQL_QUERY_EXEC_DONE(error); MYSQL_QUERY_EXEC_DONE(error);
} }

View File

@ -848,10 +848,9 @@ bool Binary_string::copy_printable_hhhh(CHARSET_INFO *to_cs,
*/ */
int sortcmp(const String *s,const String *t, CHARSET_INFO *cs) int sortcmp(const Binary_string *s, const Binary_string *t, CHARSET_INFO *cs)
{ {
return cs->strnncollsp(s->ptr(), s->length(), return cs->strnncollsp(s->ptr(), s->length(), t->ptr(), t->length());
t->ptr(), t->length());
} }
@ -873,7 +872,7 @@ int sortcmp(const String *s,const String *t, CHARSET_INFO *cs)
*/ */
int stringcmp(const String *s,const String *t) int stringcmp(const Binary_string *s, const Binary_string *t)
{ {
uint32 s_len=s->length(),t_len=t->length(),len=MY_MIN(s_len,t_len); uint32 s_len=s->length(),t_len=t->length(),len=MY_MIN(s_len,t_len);
int cmp= len ? memcmp(s->ptr(), t->ptr(), len) : 0; int cmp= len ? memcmp(s->ptr(), t->ptr(), len) : 0;

View File

@ -42,10 +42,11 @@ typedef struct st_mem_root MEM_ROOT;
#define ASSERT_LENGTH(A) DBUG_ASSERT(str_length + (uint32) (A) <= Alloced_length) #define ASSERT_LENGTH(A) DBUG_ASSERT(str_length + (uint32) (A) <= Alloced_length)
#include "pack.h" #include "pack.h"
int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); class Binary_string;
int sortcmp(const Binary_string *s, const Binary_string *t, CHARSET_INFO *cs);
int stringcmp(const Binary_string *s, const Binary_string *t);
String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
inline uint32 copy_and_convert(char *to, size_t to_length, inline uint32 copy_and_convert(char *to, size_t to_length, CHARSET_INFO *to_cs,
CHARSET_INFO *to_cs,
const char *from, size_t from_length, const char *from, size_t from_length,
CHARSET_INFO *from_cs, uint *errors) CHARSET_INFO *from_cs, uint *errors)
{ {
@ -787,8 +788,7 @@ class String: public Charset, public Binary_string
{ {
public: public:
String() { } String() { }
String(size_t length_arg) String(size_t length_arg) :Binary_string(length_arg)
:Binary_string(length_arg)
{ } { }
/* /*
NOTE: If one intend to use the c_ptr() method, the following two NOTE: If one intend to use the c_ptr() method, the following two
@ -796,16 +796,13 @@ public:
room for zero termination). room for zero termination).
*/ */
String(const char *str, size_t len, CHARSET_INFO *cs) String(const char *str, size_t len, CHARSET_INFO *cs)
:Charset(cs), :Charset(cs), Binary_string(str, len)
Binary_string(str, len)
{ } { }
String(char *str, size_t len, CHARSET_INFO *cs) String(char *str, size_t len, CHARSET_INFO *cs)
:Charset(cs), :Charset(cs), Binary_string(str, len)
Binary_string(str, len)
{ } { }
String(const String &str) String(const String &str)
:Charset(str), :Charset(str), Binary_string(str)
Binary_string(str)
{ } { }
void set(String &str,size_t offset,size_t arg_length) void set(String &str,size_t offset,size_t arg_length)
@ -994,8 +991,6 @@ public:
} }
void strip_sp(); void strip_sp();
friend int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
friend int stringcmp(const String *a,const String *b);
friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
friend class Field; friend class Field;
uint32 numchars() const uint32 numchars() const

View File

@ -80,6 +80,8 @@ static my_bool g_allow_create_integer_latch = FALSE;
using namespace open_query; using namespace open_query;
static const LEX_CSTRING empty_lex_cstring= {"", 0};
// Table of varchar latch operations. // Table of varchar latch operations.
// In the future this needs to be refactactored to live somewhere else // In the future this needs to be refactactored to live somewhere else
struct oqgraph_latch_op_table { const char *key; int latch; }; struct oqgraph_latch_op_table { const char *key; int latch; };
@ -623,7 +625,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
} }
if (enum open_frm_error err= open_table_from_share(thd, share, if (enum open_frm_error err= open_table_from_share(thd, share,
&empty_clex_str, &empty_lex_cstring,
(uint) (HA_OPEN_KEYFILE | HA_TRY_READ_ONLY), (uint) (HA_OPEN_KEYFILE | HA_TRY_READ_ONLY),
EXTRA_RECORD, EXTRA_RECORD,
thd->open_options, edges, FALSE)) thd->open_options, edges, FALSE))