summaryrefslogtreecommitdiff
path: root/sql/item_func.h
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/item_func.h
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/item_func.h')
-rw-r--r--sql/item_func.h48
1 files changed, 24 insertions, 24 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index 3fc2586729d..e16b3bd8fa6 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -745,12 +745,12 @@ public:
class Item_func_cursor_int_attr: public Item_int_func
{
protected:
- LEX_STRING m_cursor_name;
+ LEX_CSTRING m_cursor_name;
uint m_cursor_offset;
class sp_cursor *get_open_cursor_or_error();
public:
- Item_func_cursor_int_attr(THD *thd, const LEX_STRING name, uint offset)
- :Item_int_func(thd), m_cursor_name(name), m_cursor_offset(offset)
+ Item_func_cursor_int_attr(THD *thd, const LEX_CSTRING *name, uint offset)
+ :Item_int_func(thd), m_cursor_name(*name), m_cursor_offset(offset)
{ }
bool check_vcol_func_processor(void *arg)
{
@@ -763,7 +763,7 @@ public:
class Item_func_cursor_isopen: public Item_func_cursor_int_attr
{
public:
- Item_func_cursor_isopen(THD *thd, const LEX_STRING name, uint offset)
+ Item_func_cursor_isopen(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_int_attr(thd, name, offset) { }
const char *func_name() const { return "%ISOPEN"; }
void fix_length_and_dec() { max_length= 1; }
@@ -776,7 +776,7 @@ public:
class Item_func_cursor_found: public Item_func_cursor_int_attr
{
public:
- Item_func_cursor_found(THD *thd, const LEX_STRING name, uint offset)
+ Item_func_cursor_found(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_int_attr(thd, name, offset) { }
const char *func_name() const { return "%FOUND"; }
void fix_length_and_dec() { max_length= 1; maybe_null= true; }
@@ -789,7 +789,7 @@ public:
class Item_func_cursor_notfound: public Item_func_cursor_int_attr
{
public:
- Item_func_cursor_notfound(THD *thd, const LEX_STRING name, uint offset)
+ Item_func_cursor_notfound(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_int_attr(thd, name, offset) { }
const char *func_name() const { return "%NOTFOUND"; }
void fix_length_and_dec() { max_length= 1; maybe_null= true; }
@@ -802,7 +802,7 @@ public:
class Item_func_cursor_rowcount: public Item_func_cursor_int_attr
{
public:
- Item_func_cursor_rowcount(THD *thd, const LEX_STRING name, uint offset)
+ Item_func_cursor_rowcount(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_int_attr(thd, name, offset) { }
const char *func_name() const { return "%ROWCOUNT"; }
longlong val_int();
@@ -1534,7 +1534,6 @@ public:
Item_func_rollup_const(THD *thd, Item *a): Item_func(thd, a)
{
name= a->name;
- name_length= a->name_length;
}
double val_real() { return args[0]->val_real(); }
longlong val_int() { return args[0]->val_int(); }
@@ -2187,11 +2186,11 @@ class Item_func_user_var :public Item_hybrid_func
protected:
user_var_entry *m_var_entry;
public:
- LEX_STRING name; // keep it public
- Item_func_user_var(THD *thd, LEX_STRING a)
- :Item_hybrid_func(thd), m_var_entry(NULL), name(a) { }
- Item_func_user_var(THD *thd, LEX_STRING a, Item *b)
- :Item_hybrid_func(thd, b), m_var_entry(NULL), name(a) { }
+ LEX_CSTRING name; // keep it public
+ Item_func_user_var(THD *thd, const LEX_CSTRING *a)
+ :Item_hybrid_func(thd), m_var_entry(NULL), name(*a) { }
+ Item_func_user_var(THD *thd, const LEX_CSTRING *a, Item *b)
+ :Item_hybrid_func(thd, b), m_var_entry(NULL), name(*a) { }
Item_func_user_var(THD *thd, Item_func_user_var *item)
:Item_hybrid_func(thd, item),
m_var_entry(item->m_var_entry), name(item->name) { }
@@ -2225,7 +2224,7 @@ class Item_func_set_user_var :public Item_func_user_var
} save_result;
public:
- Item_func_set_user_var(THD *thd, LEX_STRING a, Item *b):
+ Item_func_set_user_var(THD *thd, const LEX_CSTRING *a, Item *b):
Item_func_user_var(thd, a, b),
entry_thread_id(0)
{}
@@ -2294,10 +2293,10 @@ class Item_func_get_user_var :public Item_func_user_var,
private Settable_routine_parameter
{
public:
- Item_func_get_user_var(THD *thd, LEX_STRING a):
+ Item_func_get_user_var(THD *thd, const LEX_CSTRING *a):
Item_func_user_var(thd, a) {}
enum Functype functype() const { return GUSERVAR_FUNC; }
- LEX_STRING get_name() { return name; }
+ LEX_CSTRING get_name() { return name; }
double val_real();
longlong val_int();
my_decimal *val_decimal(my_decimal*);
@@ -2337,11 +2336,12 @@ public:
*/
class Item_user_var_as_out_param :public Item
{
- LEX_STRING name;
+ LEX_CSTRING name;
user_var_entry *entry;
public:
- Item_user_var_as_out_param(THD *thd, LEX_STRING a): Item(thd), name(a)
- { set_name(thd, a.str, 0, system_charset_info); }
+ Item_user_var_as_out_param(THD *thd, const LEX_CSTRING *a)
+ :Item(thd), name(*a)
+ { set_name(thd, a->str, a->length, system_charset_info); }
/* We should return something different from FIELD_ITEM here */
enum Type type() const { return STRING_ITEM;}
double val_real();
@@ -2369,7 +2369,7 @@ class Item_func_get_system_var :public Item_func
{
sys_var *var;
enum_var_type var_type, orig_var_type;
- LEX_STRING component;
+ LEX_CSTRING component;
longlong cached_llval;
double cached_dval;
String cached_strval;
@@ -2380,7 +2380,7 @@ class Item_func_get_system_var :public Item_func
public:
Item_func_get_system_var(THD *thd, sys_var *var_arg,
enum_var_type var_type_arg,
- LEX_STRING *component_arg, const char *name_arg,
+ LEX_CSTRING *component_arg, const char *name_arg,
size_t name_len_arg);
enum Functype functype() const { return GSYSVAR_FUNC; }
void update_null_value();
@@ -2890,9 +2890,9 @@ public:
};
-Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
- LEX_STRING component);
-extern bool check_reserved_words(LEX_STRING *name);
+Item *get_system_var(THD *thd, enum_var_type var_type, LEX_CSTRING name,
+ LEX_CSTRING component);
+extern bool check_reserved_words(const LEX_CSTRING *name);
Item *find_date_time_item(Item **args, uint nargs, uint col);
double my_double_round(double value, longlong dec, bool dec_unsigned,
bool truncate);