summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-06-09 18:31:23 +0200
committerSergei Golubchik <serg@mariadb.org>2021-06-11 13:02:55 +0200
commit3648b333c74b5c36776db30a4370bafa28a73ef0 (patch)
treeafb09a4efa03f67bf264b913cd5caa0a5418a0c6
parent89342a3bd5e127a9060ec2a938cf36479388fcb1 (diff)
downloadmariadb-git-3648b333c74b5c36776db30a4370bafa28a73ef0.tar.gz
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.
-rw-r--r--plugin/type_inet/sql_type_inet.cc9
-rw-r--r--sql/field.cc6
-rw-r--r--sql/field.h11
-rw-r--r--sql/item.h18
-rw-r--r--sql/sql_base.cc46
-rw-r--r--sql/sql_insert.cc11
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_load.cc4
-rw-r--r--sql/sql_parse.cc6
-rw-r--r--sql/sql_prepare.cc10
-rw-r--r--sql/sql_string.cc7
-rw-r--r--sql/sql_string.h21
-rw-r--r--storage/oqgraph/ha_oqgraph.cc4
13 files changed, 65 insertions, 90 deletions
diff --git a/plugin/type_inet/sql_type_inet.cc b/plugin/type_inet/sql_type_inet.cc
index 822502053e0..8ae6fbfaeee 100644
--- a/plugin/type_inet/sql_type_inet.cc
+++ b/plugin/type_inet/sql_type_inet.cc
@@ -1342,15 +1342,13 @@ Type_handler_inet6::character_or_binary_string_to_native(THD *thd,
Inet6_null tmp(*str);
if (tmp.is_null())
thd->push_warning_wrong_value(Sql_condition::WARN_LEVEL_WARN,
- name().ptr(),
- ErrConvString(str).ptr());
+ name().ptr(), ErrConvString(str).ptr());
return tmp.is_null() || tmp.to_native(to);
}
bool
-Type_handler_inet6::Item_save_in_value(THD *thd,
- Item *item,
+Type_handler_inet6::Item_save_in_value(THD *thd, Item *item,
st_value *value) const
{
value->m_type= DYN_COL_STRING;
@@ -1366,8 +1364,7 @@ Type_handler_inet6::Item_save_in_value(THD *thd,
FROM t1;
*/
thd->push_warning_wrong_value(Sql_condition::WARN_LEVEL_WARN,
- name().ptr(),
- ErrConvString(str).ptr());
+ name().ptr(), ErrConvString(str).ptr());
value->m_type= DYN_COL_NULL;
return true;
}
diff --git a/sql/field.cc b/sql/field.cc
index 38c3e1ea70e..1ad945a97b6 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1891,8 +1891,7 @@ void Field::copy_from_tmp(int row_offset)
bool Field::send(Protocol *protocol)
{
- char buff[MAX_FIELD_WIDTH];
- String tmp(buff,sizeof(buff),charset());
+ StringBuffer<MAX_FIELD_WIDTH> tmp(charset());
val_str(&tmp);
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())
val_buffer->append(&field_separator, 1, &my_charset_latin1);
- String str(typelib->type_names[bitnr],
- typelib->type_lengths[bitnr],
+ String str(typelib->type_names[bitnr], typelib->type_lengths[bitnr],
field_charset());
val_buffer->append(str);
}
diff --git a/sql/field.h b/sql/field.h
index 08a334e5a6f..e5f47300ca7 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -4805,14 +4805,11 @@ private:
class Field_set final :public Field_enum {
public:
Field_set(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
- uchar null_bit_arg,
- enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
- uint32 packlength_arg,
+ uchar null_bit_arg, enum utype unireg_check_arg,
+ const LEX_CSTRING *field_name_arg, uint32 packlength_arg,
const TYPELIB *typelib_arg, const DTCollation &collation)
- :Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
- unireg_check_arg, field_name_arg,
- packlength_arg,
- typelib_arg, collation),
+ :Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
+ field_name_arg, packlength_arg, typelib_arg, collation),
empty_set_string("", 0, collation.collation)
{
flags=(flags & ~ENUM_FLAG) | SET_FLAG;
diff --git a/sql/item.h b/sql/item.h
index 8aede90e988..8ab4c8a3bd1 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -7517,27 +7517,21 @@ public:
Item_type_holder do not need cleanup() because its time of live limited by
single SP/PS execution.
*/
-class Item_type_holder: public Item,
- public Type_handler_hybrid_field_type
+class Item_type_holder: public Item, public Type_handler_hybrid_field_type
{
protected:
const TYPELIB *enum_set_typelib;
public:
- Item_type_holder(THD *thd,
- Item *item,
- const Type_handler *handler,
- const Type_all_attributes *attr,
- bool maybe_null_arg)
- :Item(thd),
- Type_handler_hybrid_field_type(handler),
+ Item_type_holder(THD *thd, Item *item, const Type_handler *handler,
+ const Type_all_attributes *attr, bool maybe_null_arg)
+ :Item(thd), Type_handler_hybrid_field_type(handler),
enum_set_typelib(attr->get_typelib())
{
name= item->name;
Type_std_attributes::set(*attr);
set_maybe_null(maybe_null_arg);
- copy_flags(item,
- item_base_t::IS_EXPLICIT_NAME |
- item_base_t::IS_IN_WITH_CYCLE);
+ copy_flags(item, item_base_t::IS_EXPLICIT_NAME |
+ item_base_t::IS_IN_WITH_CYCLE);
}
const Type_handler *type_handler() const override
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 68524cbb1f2..1ba01671201 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4532,9 +4532,9 @@ error:
@retval TRUE Failure (OOM).
*/
-bool DML_prelocking_strategy::
-handle_routine(THD *thd, Query_tables_list *prelocking_ctx,
- Sroutine_hash_entry *rt, sp_head *sp, bool *need_prelocking)
+bool DML_prelocking_strategy::handle_routine(THD *thd,
+ Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt,
+ sp_head *sp, bool *need_prelocking)
{
/*
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
thr_lock_type lock_type;
- if ((op & (1 << TRG_EVENT_DELETE) && fk_modifies_child(fk->delete_method))
- || (op & (1 << TRG_EVENT_UPDATE) && fk_modifies_child(fk->update_method)))
+ if ((op & trg2bit(TRG_EVENT_DELETE) && fk_modifies_child(fk->delete_method))
+ || (op & trg2bit(TRG_EVENT_UPDATE) && fk_modifies_child(fk->update_method)))
lock_type= TL_WRITE_ALLOW_WRITE;
else
lock_type= TL_READ;
@@ -4715,9 +4715,9 @@ prepare_fk_prelocking_list(THD *thd, Query_tables_list *prelocking_ctx,
@retval TRUE Failure (OOM).
*/
-bool DML_prelocking_strategy::
-handle_table(THD *thd, Query_tables_list *prelocking_ctx,
- TABLE_LIST *table_list, bool *need_prelocking)
+bool DML_prelocking_strategy::handle_table(THD *thd,
+ Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
+ bool *need_prelocking)
{
DBUG_ENTER("handle_table");
TABLE *table= table_list->table;
@@ -4846,9 +4846,9 @@ err:
@retval TRUE Failure (OOM).
*/
-bool DML_prelocking_strategy::
-handle_view(THD *thd, Query_tables_list *prelocking_ctx,
- TABLE_LIST *table_list, bool *need_prelocking)
+bool DML_prelocking_strategy::handle_view(THD *thd,
+ Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
+ bool *need_prelocking)
{
if (table_list->view->uses_stored_routines())
{
@@ -4886,9 +4886,9 @@ handle_view(THD *thd, Query_tables_list *prelocking_ctx,
@retval TRUE Failure (OOM).
*/
-bool Lock_tables_prelocking_strategy::
-handle_table(THD *thd, Query_tables_list *prelocking_ctx,
- TABLE_LIST *table_list, bool *need_prelocking)
+bool Lock_tables_prelocking_strategy::handle_table(THD *thd,
+ Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
+ bool *need_prelocking)
{
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.
*/
-bool Alter_table_prelocking_strategy::
-handle_routine(THD *thd, Query_tables_list *prelocking_ctx,
- Sroutine_hash_entry *rt, sp_head *sp, bool *need_prelocking)
+bool Alter_table_prelocking_strategy::handle_routine(THD *thd,
+ Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt,
+ sp_head *sp, bool *need_prelocking)
{
return FALSE;
}
@@ -4945,9 +4945,9 @@ handle_routine(THD *thd, Query_tables_list *prelocking_ctx,
@retval TRUE Failure (OOM).
*/
-bool Alter_table_prelocking_strategy::
-handle_table(THD *thd, Query_tables_list *prelocking_ctx,
- TABLE_LIST *table_list, bool *need_prelocking)
+bool Alter_table_prelocking_strategy::handle_table(THD *thd,
+ Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
+ bool *need_prelocking)
{
return FALSE;
}
@@ -4960,9 +4960,9 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
to be materialized.
*/
-bool Alter_table_prelocking_strategy::
-handle_view(THD *thd, Query_tables_list *prelocking_ctx,
- TABLE_LIST *table_list, bool *need_prelocking)
+bool Alter_table_prelocking_strategy::handle_view(THD *thd,
+ Query_tables_list *prelocking_ctx, TABLE_LIST *table_list,
+ bool *need_prelocking)
{
return FALSE;
}
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 9bdd40010df..24ffad7368a 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2977,8 +2977,8 @@ public:
};
-bool Delayed_prelocking_strategy::
-handle_table(THD *thd, Query_tables_list *prelocking_ctx,
+bool Delayed_prelocking_strategy::handle_table(THD *thd,
+ Query_tables_list *prelocking_ctx,
TABLE_LIST *table_list, bool *need_prelocking)
{
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::
-handle_routine(THD *thd, Query_tables_list *prelocking_ctx,
- Sroutine_hash_entry *rt, sp_head *sp,
- bool *need_prelocking)
+bool Delayed_prelocking_strategy::handle_routine(THD *thd,
+ Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt,
+ sp_head *sp, bool *need_prelocking)
{
/* LEX used by the delayed insert thread has no routines. */
DBUG_ASSERT(0);
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 94575c074ef..45e5f2381bd 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -388,7 +388,7 @@ void binlog_unsafe_map_init();
#ifdef MYSQL_SERVER
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 param_clex_str;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 0e3cdaac569..49de7f73cab 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -51,11 +51,11 @@ public:
int level;
String field;
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;
field.append(f);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 04af54ae8d9..c99d3fb3e75 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -10364,10 +10364,8 @@ bool parse_sql(THD *thd, Parser_state *parser_state,
/* Parse the query. */
- bool mysql_parse_status=
- ((thd->variables.sql_mode & MODE_ORACLE) ?
- ORAparse(thd) :
- MYSQLparse(thd)) != 0;
+ bool mysql_parse_status= thd->variables.sql_mode & MODE_ORACLE
+ ? ORAparse(thd) : MYSQLparse(thd);
DBUG_ASSERT(opt_bootstrap || mysql_parse_status ||
thd->lex->select_stack_top == 0);
thd->lex->current_select= thd->lex->first_select_lex();
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 1db04c4656f..2b6cbce98e1 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -5002,8 +5002,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
/* Allocate query. */
if (expanded_query->length() &&
- alloc_query(thd, (char*) expanded_query->ptr(),
- expanded_query->length()))
+ alloc_query(thd, expanded_query->ptr(), expanded_query->length()))
{
my_error(ER_OUTOFMEMORY, MYF(ME_FATAL), expanded_query->length());
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(),
thd->query_length()) <= 0)
{
- MYSQL_QUERY_EXEC_START(thd->query(),
- thd->thread_id,
- thd->get_db(),
+ MYSQL_QUERY_EXEC_START(thd->query(), thd->thread_id, thd->get_db(),
&thd->security_ctx->priv_user[0],
- (char *) thd->security_ctx->host_or_ip,
- 1);
+ (char *) thd->security_ctx->host_or_ip, 1);
error= mysql_execute_command(thd);
MYSQL_QUERY_EXEC_DONE(error);
}
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 053591d8c4e..ff81a5f5ca4 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -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(),
- t->ptr(), t->length());
+ return cs->strnncollsp(s->ptr(), s->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);
int cmp= len ? memcmp(s->ptr(), t->ptr(), len) : 0;
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 76079f99f8d..d7661605492 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -42,10 +42,11 @@ typedef struct st_mem_root MEM_ROOT;
#define ASSERT_LENGTH(A) DBUG_ASSERT(str_length + (uint32) (A) <= Alloced_length)
#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);
-inline uint32 copy_and_convert(char *to, size_t to_length,
- CHARSET_INFO *to_cs,
+inline uint32 copy_and_convert(char *to, size_t to_length, CHARSET_INFO *to_cs,
const char *from, size_t from_length,
CHARSET_INFO *from_cs, uint *errors)
{
@@ -787,8 +788,7 @@ class String: public Charset, public Binary_string
{
public:
String() { }
- String(size_t length_arg)
- :Binary_string(length_arg)
+ String(size_t length_arg) :Binary_string(length_arg)
{ }
/*
NOTE: If one intend to use the c_ptr() method, the following two
@@ -796,16 +796,13 @@ public:
room for zero termination).
*/
String(const char *str, size_t len, CHARSET_INFO *cs)
- :Charset(cs),
- Binary_string(str, len)
+ :Charset(cs), Binary_string(str, len)
{ }
String(char *str, size_t len, CHARSET_INFO *cs)
- :Charset(cs),
- Binary_string(str, len)
+ :Charset(cs), Binary_string(str, len)
{ }
String(const String &str)
- :Charset(str),
- Binary_string(str)
+ :Charset(str), Binary_string(str)
{ }
void set(String &str,size_t offset,size_t arg_length)
@@ -994,8 +991,6 @@ public:
}
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 class Field;
uint32 numchars() const
diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc
index c2f52e2e5a2..39d10699d32 100644
--- a/storage/oqgraph/ha_oqgraph.cc
+++ b/storage/oqgraph/ha_oqgraph.cc
@@ -80,6 +80,8 @@ static my_bool g_allow_create_integer_latch = FALSE;
using namespace open_query;
+static const LEX_CSTRING empty_lex_cstring= {"", 0};
+
// Table of varchar latch operations.
// In the future this needs to be refactactored to live somewhere else
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,
- &empty_clex_str,
+ &empty_lex_cstring,
(uint) (HA_OPEN_KEYFILE | HA_TRY_READ_ONLY),
EXTRA_RECORD,
thd->open_options, edges, FALSE))