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/handler.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/handler.h')
-rw-r--r-- | sql/handler.h | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/sql/handler.h b/sql/handler.h index f85b7c26284..b379f4e8b4d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1341,7 +1341,7 @@ struct handlerton Returns 0 on success and 1 on error. */ - int (*discover_table_names)(handlerton *hton, LEX_STRING *db, MY_DIR *dir, + int (*discover_table_names)(handlerton *hton, LEX_CSTRING *db, MY_DIR *dir, discovered_list *result); /* @@ -1387,7 +1387,7 @@ struct handlerton }; -static inline LEX_STRING *hton_name(const handlerton *hton) +static inline LEX_CSTRING *hton_name(const handlerton *hton) { return &(hton2plugin[hton->slot]->name); } @@ -1670,9 +1670,9 @@ struct Table_scope_and_contents_source_st { CHARSET_INFO *table_charset; LEX_CUSTRING tabledef_version; - LEX_STRING connect_string; + LEX_CSTRING connect_string; + LEX_CSTRING comment; const char *password, *tablespace; - LEX_STRING comment; const char *data_file_name, *index_file_name; const char *alias; ulonglong max_rows,min_rows; @@ -2167,8 +2167,8 @@ typedef struct st_key_create_information { enum ha_key_alg algorithm; ulong block_size; - LEX_STRING parser_name; - LEX_STRING comment; + LEX_CSTRING parser_name; + LEX_CSTRING comment; /** A flag to determine if we will check for duplicate indexes. This typically means that the key information was specified @@ -3523,7 +3523,7 @@ public: cached */ - virtual my_bool register_query_cache_table(THD *thd, char *table_key, + virtual my_bool register_query_cache_table(THD *thd, const char *table_key, uint key_length, qc_engine_callback *engine_callback, @@ -3952,7 +3952,7 @@ public: return 0; } - virtual LEX_STRING *engine_name(); + virtual LEX_CSTRING *engine_name(); TABLE* get_table() { return table; } TABLE_SHARE* get_table_share() { return table_share; } @@ -4256,7 +4256,7 @@ extern const char *myisam_stats_method_names[]; extern ulong total_ha, total_ha_2pc; /* lookups */ -plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name, bool tmp_table); +plugin_ref ha_resolve_by_name(THD *thd, const LEX_CSTRING *name, bool tmp_table); plugin_ref ha_lock_engine(THD *thd, const handlerton *hton); handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type); handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc, @@ -4324,11 +4324,11 @@ class Discovered_table_list: public handlerton::discovered_list const char *wild, *wend; bool with_temps; // whether to include temp tables in the result public: - Dynamic_array<LEX_STRING*> *tables; + Dynamic_array<LEX_CSTRING*> *tables; - Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_STRING*> *tables_arg, - const LEX_STRING *wild_arg); - Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_STRING*> *tables_arg) + Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_CSTRING*> *tables_arg, + const LEX_CSTRING *wild_arg); + Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_CSTRING*> *tables_arg) : thd(thd_arg), wild(NULL), with_temps(true), tables(tables_arg) {} ~Discovered_table_list() {} @@ -4340,7 +4340,7 @@ public: }; int ha_discover_table(THD *thd, TABLE_SHARE *share); -int ha_discover_table_names(THD *thd, LEX_STRING *db, MY_DIR *dirp, +int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp, Discovered_table_list *result, bool reusable); bool ha_table_exists(THD *thd, const char *db, const char *table_name, handlerton **hton= 0, bool *is_sequence= 0); @@ -4423,5 +4423,5 @@ void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag); void print_keydup_error(TABLE *table, KEY *key, myf errflag); int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info); -int del_global_table_stat(THD *thd, LEX_STRING *db, LEX_STRING *table); +int del_global_table_stat(THD *thd, LEX_CSTRING *db, LEX_CSTRING *table); #endif /* HANDLER_INCLUDED */ |