diff options
author | Monty <monty@mariadb.org> | 2017-04-23 19:39:57 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2017-04-23 22:35:46 +0300 |
commit | 5a759d31f766087d5e135e1d3d3d987693bc9b88 (patch) | |
tree | 93c7359e8b211e269bfa73e5f595f34b9dca575a /sql/structs.h | |
parent | cba84469eb96481568a9f4ddf3f2989c49c9294c (diff) | |
download | mariadb-git-5a759d31f766087d5e135e1d3d3d987693bc9b88.tar.gz |
Changing field::field_name and Item::name to LEX_CSTRING
Benefits of this patch:
- Removed a lot of calls to strlen(), especially for field_string
- Strings generated by parser are now const strings, less chance of
accidently changing a string
- Removed a lot of calls with LEX_STRING as parameter (changed to pointer)
- More uniform code
- Item::name_length was not kept up to date. Now fixed
- Several bugs found and fixed (Access to null pointers,
access of freed memory, wrong arguments to printf like functions)
- Removed a lot of casts from (const char*) to (char*)
Changes:
- This caused some ABI changes
- lex_string_set now uses LEX_CSTRING
- Some fucntions are now taking const char* instead of char*
- Create_field::change and after changed to LEX_CSTRING
- handler::connect_string, comment and engine_name() changed to LEX_CSTRING
- Checked printf() related calls to find bugs. Found and fixed several
errors in old code.
- A lot of changes from LEX_STRING to LEX_CSTRING, especially related to
parsing and events.
- Some changes from LEX_STRING and LEX_STRING & to LEX_CSTRING*
- Some changes for char* to const char*
- Added printf argument checking for my_snprintf()
- Introduced null_clex_str, star_clex_string, temp_lex_str to simplify
code
- Added item_empty_name and item_used_name to be able to distingush between
items that was given an empty name and items that was not given a name
This is used in sql_yacc.yy to know when to give an item a name.
- select table_name."*' is not anymore same as table_name.*
- removed not used function Item::rename()
- Added comparision of item->name_length before some calls to
my_strcasecmp() to speed up comparison
- Moved Item_sp_variable::make_field() from item.h to item.cc
- Some minimal code changes to avoid copying to const char *
- Fixed wrong error message in wsrep_mysql_parse()
- Fixed wrong code in find_field_in_natural_join() where real_item() was
set when it shouldn't
- ER_ERROR_ON_RENAME was used with extra arguments.
- Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already
give the error.
TODO:
- Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c
- Change code to not modify LEX_CSTRING for database name
(as part of lower_case_table_names)
Diffstat (limited to 'sql/structs.h')
-rw-r--r-- | sql/structs.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sql/structs.h b/sql/structs.h index 1b3c0b7a7f2..1a143602eea 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -124,10 +124,10 @@ typedef struct st_key { union { plugin_ref parser; /* Fulltext [pre]parser */ - LEX_STRING *parser_name; /* Fulltext [pre]parser name */ + LEX_CSTRING *parser_name; /* Fulltext [pre]parser name */ }; KEY_PART_INFO *key_part; - char *name; /* Name of key */ + const char *name; /* Name of key */ /* Unique name for cache; db + \0 + table_name + \0 + key_name + \0 */ uchar *cache_name; /* @@ -152,7 +152,7 @@ typedef struct st_key { int bdb_return_if_eq; } handler; TABLE *table; - LEX_STRING comment; + LEX_CSTRING comment; /** reference to the list of options or NULL */ engine_option_value *option_list; ha_index_option_struct *option_struct; /* structure with parsed options */ @@ -204,21 +204,24 @@ extern const char *show_comp_option_name[]; typedef int *(*update_var)(THD *, struct st_mysql_show_var *); typedef struct st_lex_user { - LEX_STRING user, host, plugin, auth; - LEX_STRING pwtext, pwhash; + LEX_CSTRING user, host, plugin, auth; + LEX_CSTRING pwtext, pwhash; bool is_role() const { return user.str[0] && !host.str[0]; } - void set_lex_string(LEX_STRING *l, char *buf) + void set_lex_string(LEX_CSTRING *l, char *buf) { if (is_role()) *l= user; else - l->length= strxmov(l->str= buf, user.str, "@", host.str, NullS) - buf; + { + l->str= buf; + l->length= strxmov(buf, user.str, "@", host.str, NullS) - buf; + } } void reset_auth() { pwtext.length= pwhash.length= plugin.length= auth.length= 0; pwtext.str= pwhash.str= 0; - plugin.str= auth.str= const_cast<char*>(""); + plugin.str= auth.str= ""; } } LEX_USER; @@ -708,7 +711,7 @@ public: }; -struct Lex_string_with_pos_st: public LEX_STRING +struct Lex_string_with_pos_st: public LEX_CSTRING { const char *m_pos; }; |