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/sql_trigger.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/sql_trigger.h')
-rw-r--r-- | sql/sql_trigger.h | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 9d1c79cc7cf..8847680c7b2 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -71,7 +71,7 @@ struct st_trg_execution_order Trigger name referenced in the FOLLOWS/PRECEDES clause of the CREATE TRIGGER statement. */ - LEX_STRING anchor_trigger_name; + LEX_CSTRING anchor_trigger_name; }; @@ -99,15 +99,15 @@ public: grouped by event and action_time. */ Item_trigger_field *trigger_fields; - LEX_STRING name; - LEX_STRING on_table_name; /* Raw table name */ - LEX_STRING definition; - LEX_STRING definer; + LEX_CSTRING name; + LEX_CSTRING on_table_name; /* Raw table name */ + LEX_CSTRING definition; + LEX_CSTRING definer; /* Character sets used */ - LEX_STRING client_cs_name; - LEX_STRING connection_cl_name; - LEX_STRING db_cl_name; + LEX_CSTRING client_cs_name; + LEX_CSTRING connection_cl_name; + LEX_CSTRING db_cl_name; GRANT_INFO subject_table_grants; sql_mode_t sql_mode; @@ -118,7 +118,7 @@ public: uint action_order; bool is_fields_updated_in_trigger(MY_BITMAP *used_fields); - void get_trigger_info(LEX_STRING *stmt, LEX_STRING *body, + void get_trigger_info(LEX_CSTRING *stmt, LEX_CSTRING *body, LEX_STRING *definer); /* Functions executed over each active trigger */ bool change_on_table_name(void* param_arg); @@ -189,7 +189,7 @@ public: Field responsible for storing triggers definitions in file. It have to be public because we are using it directly from parser. */ - List<LEX_STRING> definitions_list; + List<LEX_CSTRING> definitions_list; /** List of sql modes for triggers */ @@ -197,13 +197,13 @@ public: /** Create times for triggers */ List<ulonglong> create_times; - List<LEX_STRING> definers_list; + List<LEX_CSTRING> definers_list; /* Character set context, used for parsing and executing triggers. */ - List<LEX_STRING> client_cs_names; - List<LEX_STRING> connection_cl_names; - List<LEX_STRING> db_cl_names; + List<LEX_CSTRING> client_cs_names; + List<LEX_CSTRING> connection_cl_names; + List<LEX_CSTRING> db_cl_names; /* End of character ser context. */ @@ -227,7 +227,8 @@ public: static bool check_n_load(THD *thd, const char *db, const char *table_name, TABLE *table, bool names_only); - static bool drop_all_triggers(THD *thd, char *db, char *table_name); + static bool drop_all_triggers(THD *thd, const char *db, + const char *table_name); static bool change_table_name(THD *thd, const char *db, const char *old_alias, const char *old_table, @@ -236,7 +237,7 @@ public: void add_trigger(trg_event_type event_type, trg_action_time_type action_time, trigger_order_type ordering_clause, - LEX_STRING *anchor_trigger_name, + LEX_CSTRING *anchor_trigger_name, Trigger *trigger); Trigger *get_trigger(trg_event_type event_type, trg_action_time_type action_time) @@ -279,7 +280,7 @@ public: bzero(extra_null_bitmap, null_bytes); } - Trigger *find_trigger(const LEX_STRING *name, bool remove_from_list); + Trigger *find_trigger(const LEX_CSTRING *name, bool remove_from_list); Trigger* for_all_triggers(Triggers_processor func, void *arg); @@ -287,13 +288,13 @@ private: bool prepare_record_accessors(TABLE *table); Trigger *change_table_name_in_trignames(const char *old_db_name, const char *new_db_name, - LEX_STRING *new_table_name, + LEX_CSTRING *new_table_name, Trigger *trigger); bool change_table_name_in_triggers(THD *thd, const char *old_db_name, const char *new_db_name, - LEX_STRING *old_table_name, - LEX_STRING *new_table_name); + LEX_CSTRING *old_table_name, + LEX_CSTRING *new_table_name); bool check_for_broken_triggers() { @@ -324,8 +325,8 @@ bool check_trn_exists(const LEX_STRING *trn_path); bool load_table_name_for_trigger(THD *thd, const sp_name *trg_name, - const LEX_STRING *trn_path, - LEX_STRING *tbl_name); + const LEX_CSTRING *trn_path, + LEX_CSTRING *tbl_name); bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create); extern const char * const TRG_EXT; |