1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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)
This commit is contained in:
Monty
2017-04-23 19:39:57 +03:00
parent cba84469eb
commit 5a759d31f7
233 changed files with 4155 additions and 3794 deletions

View File

@ -251,10 +251,10 @@ bool Foreign_key::validate(List<Create_field> &table_fields)
while ((sql_field= it++) &&
my_strcasecmp(system_charset_info,
column->field_name.str,
sql_field->field_name)) {}
sql_field->field_name.str)) {}
if (!sql_field)
{
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name);
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str);
DBUG_RETURN(TRUE);
}
if (type == Key::FOREIGN_KEY && sql_field->vcol_info)
@ -566,8 +566,8 @@ char *thd_get_error_context_description(THD *thd, char *buffer,
const char *proc_info= thd->proc_info;
len= my_snprintf(header, sizeof(header),
"MySQL thread id %lu, OS thread handle 0x%lx, query id %lu",
thd->thread_id, (ulong) thd->real_id, (ulong) thd->query_id);
"MySQL thread id %lu, OS thread handle %p, query id %lu",
(ulong) thd->thread_id, (void*) thd->real_id, (ulong) thd->query_id);
str.length(0);
str.append(header, len);
@ -1193,11 +1193,11 @@ char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size)
}
extern "C"
LEX_STRING *thd_make_lex_string(THD *thd, LEX_STRING *lex_str,
LEX_CSTRING *thd_make_lex_string(THD *thd, LEX_CSTRING *lex_str,
const char *str, unsigned int size,
int allocate_lex_string)
{
return allocate_lex_string ? thd->make_lex_string(str, size)
return allocate_lex_string ? thd->make_clex_string(str, size)
: thd->make_lex_string(lex_str, str, size);
}
@ -1263,7 +1263,7 @@ void THD::init(void)
variables.pseudo_thread_id= thread_id;
variables.default_master_connection.str= default_master_connection_buff;
::strmake(variables.default_master_connection.str,
::strmake(default_master_connection_buff,
global_system_variables.default_master_connection.str,
variables.default_master_connection.length);
@ -2705,7 +2705,7 @@ static String default_field_term("\t",default_charset_info);
static String default_enclosed_and_line_start("", default_charset_info);
static String default_xml_row_term("<row>", default_charset_info);
sql_exchange::sql_exchange(char *name, bool flag,
sql_exchange::sql_exchange(const char *name, bool flag,
enum enum_filetype filetype_arg)
:file_name(name), opt_enclosed(0), dumpfile(flag), skip_lines(0)
{
@ -3867,7 +3867,7 @@ Statement_map::~Statement_map()
bool my_var_user::set(THD *thd, Item *item)
{
Item_func_set_user_var *suv= new (thd->mem_root) Item_func_set_user_var(thd, name, item);
Item_func_set_user_var *suv= new (thd->mem_root) Item_func_set_user_var(thd, &name, item);
suv->save_item_result(item);
return suv->fix_fields(thd, 0) || suv->update();
}
@ -4119,7 +4119,7 @@ void Security_context::destroy()
}
if (user != delayed_user)
{
my_free(user);
my_free((char*) user);
user= NULL;
}
@ -4129,7 +4129,7 @@ void Security_context::destroy()
user= NULL;
}
my_free(ip);
my_free((char*) ip);
ip= NULL;
}
@ -4145,7 +4145,7 @@ void Security_context::skip_grants()
bool Security_context::set_user(char *user_arg)
{
my_free(user);
my_free((char*) user);
user= my_strdup(user_arg, MYF(0));
return user == 0;
}
@ -4203,9 +4203,9 @@ bool Security_context::set_user(char *user_arg)
bool
Security_context::
change_security_context(THD *thd,
LEX_STRING *definer_user,
LEX_STRING *definer_host,
LEX_STRING *db,
LEX_CSTRING *definer_user,
LEX_CSTRING *definer_host,
LEX_CSTRING *db,
Security_context **backup)
{
bool needs_change;
@ -5341,7 +5341,7 @@ void THD::get_definer(LEX_USER *definer, bool role)
if (slave_thread && has_invoker())
#endif
{
definer->user = invoker_user;
definer->user= invoker_user;
definer->host= invoker_host;
definer->reset_auth();
}