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/sp_pcontext.cc | |
| 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/sp_pcontext.cc')
| -rw-r--r-- | sql/sp_pcontext.cc | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 93d7bc11281..d98f8005945 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -199,7 +199,7 @@ uint sp_pcontext::diff_cursors(const sp_pcontext *ctx, bool exclusive) const } -sp_variable *sp_pcontext::find_variable(LEX_STRING name, +sp_variable *sp_pcontext::find_variable(const LEX_CSTRING *name, bool current_scope_only) const { uint i= m_vars.elements() - m_pboundary; @@ -209,7 +209,7 @@ sp_variable *sp_pcontext::find_variable(LEX_STRING name, sp_variable *p= m_vars.at(i); if (my_strnncoll(system_charset_info, - (const uchar *)name.str, name.length, + (const uchar *)name->str, name->length, (const uchar *)p->name.str, p->name.length) == 0) { return p; @@ -269,7 +269,7 @@ sp_variable *sp_pcontext::find_variable(uint offset) const } -sp_variable *sp_pcontext::add_variable(THD *thd, LEX_STRING name) +sp_variable *sp_pcontext::add_variable(THD *thd, const LEX_CSTRING *name) { sp_variable *p= new (thd->mem_root) sp_variable(name, m_var_offset + m_max_var_index); @@ -282,7 +282,7 @@ sp_variable *sp_pcontext::add_variable(THD *thd, LEX_STRING name) return m_vars.append(p) ? NULL : p; } -sp_label *sp_pcontext::push_label(THD *thd, LEX_STRING name, uint ip, +sp_label *sp_pcontext::push_label(THD *thd, const LEX_CSTRING *name, uint ip, sp_label::enum_type type, List<sp_label> *list) { @@ -297,14 +297,14 @@ sp_label *sp_pcontext::push_label(THD *thd, LEX_STRING name, uint ip, return label; } -sp_label *sp_pcontext::find_goto_label(const LEX_STRING name, bool recusive) +sp_label *sp_pcontext::find_goto_label(const LEX_CSTRING *name, bool recusive) { List_iterator_fast<sp_label> li(m_goto_labels); sp_label *lab; while ((lab= li++)) { - if (my_strcasecmp(system_charset_info, name.str, lab->name.str) == 0) + if (my_strcasecmp(system_charset_info, name->str, lab->name.str) == 0) return lab; } @@ -334,14 +334,14 @@ sp_label *sp_pcontext::find_goto_label(const LEX_STRING name, bool recusive) } -sp_label *sp_pcontext::find_label(const LEX_STRING name) +sp_label *sp_pcontext::find_label(const LEX_CSTRING *name) { List_iterator_fast<sp_label> li(m_labels); sp_label *lab; while ((lab= li++)) { - if (my_strcasecmp(system_charset_info, name.str, lab->name.str) == 0) + if (my_strcasecmp(system_charset_info, name->str, lab->name.str) == 0) return lab; } @@ -377,7 +377,7 @@ sp_label *sp_pcontext::find_label_current_loop_start() bool sp_pcontext::add_condition(THD *thd, - LEX_STRING name, + const LEX_CSTRING *name, sp_condition_value *value) { sp_condition *p= new (thd->mem_root) sp_condition(name, value); @@ -389,7 +389,7 @@ bool sp_pcontext::add_condition(THD *thd, } -sp_condition_value *sp_pcontext::find_condition(const LEX_STRING name, +sp_condition_value *sp_pcontext::find_condition(const LEX_CSTRING *name, bool current_scope_only) const { uint i= m_conditions.elements(); @@ -431,7 +431,7 @@ static sp_condition sp_predefined_conditions[]= sp_condition_value * -sp_pcontext::find_predefined_condition(const LEX_STRING name) const +sp_pcontext::find_predefined_condition(const LEX_CSTRING *name) const { for (uint i= 0; i < array_elements(sp_predefined_conditions) ; i++) { @@ -589,7 +589,7 @@ sp_pcontext::find_handler(const Sql_condition_identity &value) const } -bool sp_pcontext::add_cursor(const LEX_STRING name, sp_pcontext *param_ctx, +bool sp_pcontext::add_cursor(const LEX_CSTRING *name, sp_pcontext *param_ctx, sp_lex_cursor *lex) { if (m_cursors.elements() == m_max_cursor_index) @@ -599,7 +599,7 @@ bool sp_pcontext::add_cursor(const LEX_STRING name, sp_pcontext *param_ctx, } -const sp_pcursor *sp_pcontext::find_cursor(const LEX_STRING name, +const sp_pcursor *sp_pcontext::find_cursor(const LEX_CSTRING *name, uint *poff, bool current_scope_only) const { @@ -607,10 +607,10 @@ const sp_pcursor *sp_pcontext::find_cursor(const LEX_STRING name, while (i--) { - LEX_STRING n= m_cursors.at(i); + LEX_CSTRING n= m_cursors.at(i); if (my_strnncoll(system_charset_info, - (const uchar *) name.str, name.length, + (const uchar *) name->str, name->length, (const uchar *) n.str, n.length) == 0) { *poff= m_cursor_offset + i; @@ -695,7 +695,7 @@ bool sp_pcursor::check_param_count_with_error(uint param_count) const if (param_count != (m_param_context ? m_param_context->context_var_count() : 0)) { - my_error(ER_WRONG_PARAMCOUNT_TO_CURSOR, MYF(0), LEX_STRING::str); + my_error(ER_WRONG_PARAMCOUNT_TO_CURSOR, MYF(0), LEX_CSTRING::str); return true; } return false; @@ -703,20 +703,20 @@ bool sp_pcursor::check_param_count_with_error(uint param_count) const const Spvar_definition * -sp_variable::find_row_field(const LEX_STRING &var_name, - const LEX_STRING &field_name, +sp_variable::find_row_field(const LEX_CSTRING *var_name, + const LEX_CSTRING *field_name, uint *row_field_offset) { if (!field_def.is_row()) { my_printf_error(ER_UNKNOWN_ERROR, - "'%s' is not a row variable", MYF(0), var_name.str); + "'%s' is not a row variable", MYF(0), var_name->str); return NULL; } const Spvar_definition *def; - if ((def= field_def.find_row_field_by_name(field_name.str, row_field_offset))) + if ((def= field_def.find_row_field_by_name(field_name, row_field_offset))) return def; my_error(ER_ROW_VARIABLE_DOES_NOT_HAVE_FIELD, MYF(0), - var_name.str, field_name.str); + var_name->str, field_name->str); return NULL; } |
