summaryrefslogtreecommitdiff
path: root/sql/rpl_mi.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2017-04-23 19:39:57 +0300
committerMonty <monty@mariadb.org>2017-04-23 22:35:46 +0300
commit5a759d31f766087d5e135e1d3d3d987693bc9b88 (patch)
tree93c7359e8b211e269bfa73e5f595f34b9dca575a /sql/rpl_mi.cc
parentcba84469eb96481568a9f4ddf3f2989c49c9294c (diff)
downloadmariadb-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/rpl_mi.cc')
-rw-r--r--sql/rpl_mi.cc37
1 files changed, 18 insertions, 19 deletions
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index f30b7e161f2..60c887965fb 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -28,7 +28,7 @@
static void init_master_log_pos(Master_info* mi);
-Master_info::Master_info(LEX_STRING *connection_name_arg,
+Master_info::Master_info(LEX_CSTRING *connection_name_arg,
bool is_slave_recovery)
:Slave_reporting_capability("I/O"),
ssl(0), ssl_verify_server_cert(1), fd(-1), io_thd(0),
@@ -44,6 +44,7 @@ Master_info::Master_info(LEX_STRING *connection_name_arg,
in_start_all_slaves(0), in_stop_all_slaves(0),
users(0), killed(0)
{
+ char *tmp;
host[0] = 0; user[0] = 0; password[0] = 0;
ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0;
ssl_cipher[0]= 0; ssl_key[0]= 0;
@@ -55,16 +56,14 @@ Master_info::Master_info(LEX_STRING *connection_name_arg,
*/
connection_name.length= cmp_connection_name.length=
connection_name_arg->length;
- if ((connection_name.str= (char*) my_malloc(connection_name_arg->length*2+2,
- MYF(MY_WME))))
+ if ((connection_name.str= tmp= (char*)
+ my_malloc(connection_name_arg->length*2+2, MYF(MY_WME))))
{
- cmp_connection_name.str= (connection_name.str +
- connection_name_arg->length+1);
- strmake(connection_name.str, connection_name_arg->str,
- connection_name.length);
- memcpy(cmp_connection_name.str, connection_name_arg->str,
- connection_name.length+1);
- my_casedn_str(system_charset_info, cmp_connection_name.str);
+ strmake(tmp, connection_name_arg->str, connection_name.length);
+ tmp+= connection_name_arg->length+1;
+ cmp_connection_name.str= tmp;
+ memcpy(tmp, connection_name_arg->str, connection_name.length+1);
+ my_casedn_str(system_charset_info, tmp);
}
/*
When MySQL restarted, all Rpl_filter settings which aren't in the my.cnf
@@ -124,7 +123,7 @@ Master_info::~Master_info()
#endif
rpl_filters.delete_element(connection_name.str, connection_name.length,
(void (*)(const char*, uchar*)) free_rpl_filter);
- my_free(connection_name.str);
+ my_free(const_cast<char*>(connection_name.str));
delete_dynamic(&ignore_server_ids);
mysql_mutex_destroy(&run_lock);
mysql_mutex_destroy(&data_lock);
@@ -901,7 +900,7 @@ void free_key_master_info(Master_info *mi)
1 error
*/
-bool check_master_connection_name(LEX_STRING *name)
+bool check_master_connection_name(LEX_CSTRING *name)
{
if (name->length >= MAX_CONNECTION_NAME)
return 1;
@@ -931,7 +930,7 @@ bool check_master_connection_name(LEX_STRING *name)
void create_logfile_name_with_suffix(char *res_file_name, size_t length,
const char *info_file, bool append,
- LEX_STRING *suffix)
+ LEX_CSTRING *suffix)
{
char buff[MAX_CONNECTION_NAME+1],
res[MAX_CONNECTION_NAME * MAX_FILENAME_MBWIDTH+1], *p;
@@ -1124,7 +1123,7 @@ bool Master_info_index::init_all_master_info()
while (!init_strvar_from_file(sign, sizeof(sign),
&index_file, NULL))
{
- LEX_STRING connection_name;
+ LEX_CSTRING connection_name;
Master_info *mi;
char buf_master_info_file[FN_REFLEN];
char buf_relay_log_info_file[FN_REFLEN];
@@ -1253,7 +1252,7 @@ error:
/* Write new master.info to master.info.index File */
-bool Master_info_index::write_master_name_to_index_file(LEX_STRING *name,
+bool Master_info_index::write_master_name_to_index_file(LEX_CSTRING *name,
bool do_sync)
{
DBUG_ASSERT(my_b_inited(&index_file) != 0);
@@ -1290,7 +1289,7 @@ bool Master_info_index::write_master_name_to_index_file(LEX_STRING *name,
WARN_LEVEL_ERROR-> Issue error if not exists
*/
-Master_info *get_master_info(const LEX_STRING *connection_name,
+Master_info *get_master_info(const LEX_CSTRING *connection_name,
Sql_condition::enum_warning_level warning)
{
Master_info *mi;
@@ -1356,7 +1355,7 @@ void Master_info::release()
*/
Master_info *
-Master_info_index::get_master_info(const LEX_STRING *connection_name,
+Master_info_index::get_master_info(const LEX_CSTRING *connection_name,
Sql_condition::enum_warning_level warning)
{
Master_info *mi;
@@ -1387,7 +1386,7 @@ Master_info_index::get_master_info(const LEX_STRING *connection_name,
/* Check Master_host & Master_port is duplicated or not */
-bool Master_info_index::check_duplicate_master_info(LEX_STRING *name_arg,
+bool Master_info_index::check_duplicate_master_info(LEX_CSTRING *name_arg,
const char *host,
uint port)
{
@@ -1917,7 +1916,7 @@ char *Domain_id_filter::as_string(enum_list_type type)
{
ulong domain_id;
get_dynamic(ids, (void *) &domain_id, i);
- cur_len+= my_snprintf(buf + cur_len, sz, " %u", domain_id);
+ cur_len+= my_snprintf(buf + cur_len, sz, " %lu", domain_id);
sz-= cur_len;
}
return buf;