summaryrefslogtreecommitdiff
path: root/sql
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
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')
-rw-r--r--sql/create_options.cc10
-rw-r--r--sql/create_options.h18
-rw-r--r--sql/datadict.cc12
-rw-r--r--sql/datadict.h2
-rw-r--r--sql/event_data_objects.cc53
-rw-r--r--sql/event_data_objects.h35
-rw-r--r--sql/event_db_repository.cc59
-rw-r--r--sql/event_db_repository.h20
-rw-r--r--sql/event_parse_data.cc11
-rw-r--r--sql/event_parse_data.h8
-rw-r--r--sql/event_queue.cc28
-rw-r--r--sql/event_queue.h14
-rw-r--r--sql/event_scheduler.cc2
-rw-r--r--sql/events.cc63
-rw-r--r--sql/events.h15
-rw-r--r--sql/field.cc116
-rw-r--r--sql/field.h197
-rw-r--r--sql/field_conv.cc2
-rw-r--r--sql/filesort.cc6
-rw-r--r--sql/ha_partition.cc24
-rw-r--r--sql/ha_partition.h5
-rw-r--r--sql/ha_sequence.cc7
-rw-r--r--sql/ha_sequence.h2
-rw-r--r--sql/handler.cc48
-rw-r--r--sql/handler.h30
-rw-r--r--sql/item.cc425
-rw-r--r--sql/item.h150
-rw-r--r--sql/item_create.cc338
-rw-r--r--sql/item_create.h13
-rw-r--r--sql/item_func.cc72
-rw-r--r--sql/item_func.h48
-rw-r--r--sql/item_geofunc.cc2
-rw-r--r--sql/item_strfunc.cc2
-rw-r--r--sql/item_subselect.cc58
-rw-r--r--sql/item_sum.cc38
-rw-r--r--sql/item_sum.h2
-rw-r--r--sql/item_windowfunc.cc4
-rw-r--r--sql/item_windowfunc.h4
-rw-r--r--sql/item_xmlfunc.cc8
-rw-r--r--sql/keycaches.cc8
-rw-r--r--sql/keycaches.h4
-rw-r--r--sql/log.cc2
-rw-r--r--sql/log_event.cc39
-rw-r--r--sql/log_event.h12
-rw-r--r--sql/mysqld.cc11
-rw-r--r--sql/mysqld.h3
-rw-r--r--sql/opt_range.cc6
-rw-r--r--sql/opt_subselect.cc17
-rw-r--r--sql/opt_table_elimination.cc4
-rw-r--r--sql/parse_file.cc15
-rw-r--r--sql/parse_file.h17
-rw-r--r--sql/partition_element.h16
-rw-r--r--sql/partition_info.cc23
-rw-r--r--sql/partition_info.h6
-rw-r--r--sql/procedure.cc2
-rw-r--r--sql/procedure.h3
-rw-r--r--sql/protocol.cc6
-rw-r--r--sql/rpl_gtid.cc28
-rw-r--r--sql/rpl_gtid.h4
-rw-r--r--sql/rpl_mi.cc37
-rw-r--r--sql/rpl_mi.h18
-rw-r--r--sql/rpl_record.cc18
-rw-r--r--sql/rpl_record_old.cc4
-rw-r--r--sql/rpl_utility.cc12
-rw-r--r--sql/session_tracker.cc12
-rw-r--r--sql/set_var.cc24
-rw-r--r--sql/set_var.h27
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/slave.h2
-rw-r--r--sql/sp.cc52
-rw-r--r--sql/sp.h8
-rw-r--r--sql/sp_head.cc67
-rw-r--r--sql/sp_head.h66
-rw-r--r--sql/sp_pcontext.cc42
-rw-r--r--sql/sp_pcontext.h86
-rw-r--r--sql/sp_rcontext.cc8
-rw-r--r--sql/sql_acl.cc230
-rw-r--r--sql/sql_acl.h21
-rw-r--r--sql/sql_admin.cc8
-rw-r--r--sql/sql_admin.h2
-rw-r--r--sql/sql_alter.cc20
-rw-r--r--sql/sql_alter.h20
-rw-r--r--sql/sql_analyse.cc2
-rw-r--r--sql/sql_base.cc107
-rw-r--r--sql/sql_base.h4
-rw-r--r--sql/sql_cache.cc2
-rw-r--r--sql/sql_cache.h4
-rw-r--r--sql/sql_class.cc32
-rw-r--r--sql/sql_class.h180
-rw-r--r--sql/sql_connect.cc4
-rw-r--r--sql/sql_cte.cc9
-rw-r--r--sql/sql_cte.h10
-rw-r--r--sql/sql_db.cc74
-rw-r--r--sql/sql_db.h13
-rw-r--r--sql/sql_digest.cc2
-rw-r--r--sql/sql_error.cc2
-rw-r--r--sql/sql_error.h2
-rw-r--r--sql/sql_explain.cc5
-rw-r--r--sql/sql_handler.cc7
-rw-r--r--sql/sql_handler.h5
-rw-r--r--sql/sql_help.cc10
-rw-r--r--sql/sql_insert.cc6
-rw-r--r--sql/sql_lex.cc345
-rw-r--r--sql/sql_lex.h216
-rw-r--r--sql/sql_list.h4
-rw-r--r--sql/sql_load.cc16
-rw-r--r--sql/sql_parse.cc142
-rw-r--r--sql/sql_parse.h23
-rw-r--r--sql/sql_partition.cc40
-rw-r--r--sql/sql_partition.h2
-rw-r--r--sql/sql_partition_admin.cc28
-rw-r--r--sql/sql_plugin.cc77
-rw-r--r--sql/sql_plugin.h18
-rw-r--r--sql/sql_plugin_compat.h2
-rw-r--r--sql/sql_prepare.cc29
-rw-r--r--sql/sql_profile.cc4
-rw-r--r--sql/sql_reload.cc2
-rw-r--r--sql/sql_rename.cc19
-rw-r--r--sql/sql_repl.cc9
-rw-r--r--sql/sql_select.cc55
-rw-r--r--sql/sql_select.h2
-rw-r--r--sql/sql_sequence.cc27
-rw-r--r--sql/sql_servers.cc4
-rw-r--r--sql/sql_show.cc368
-rw-r--r--sql/sql_show.h12
-rw-r--r--sql/sql_statistics.cc41
-rw-r--r--sql/sql_statistics.h14
-rw-r--r--sql/sql_string.h4
-rw-r--r--sql/sql_table.cc188
-rw-r--r--sql/sql_table.h2
-rw-r--r--sql/sql_test.cc7
-rw-r--r--sql/sql_time.cc42
-rw-r--r--sql/sql_time.h2
-rw-r--r--sql/sql_trigger.cc144
-rw-r--r--sql/sql_trigger.h45
-rw-r--r--sql/sql_truncate.cc6
-rw-r--r--sql/sql_type.cc68
-rw-r--r--sql/sql_udf.cc28
-rw-r--r--sql/sql_udf.h8
-rw-r--r--sql/sql_union.cc3
-rw-r--r--sql/sql_update.cc7
-rw-r--r--sql/sql_view.cc71
-rw-r--r--sql/sql_view.h2
-rw-r--r--sql/sql_window.cc10
-rw-r--r--sql/sql_window.h19
-rw-r--r--sql/sql_yacc.yy425
-rw-r--r--sql/sql_yacc_ora.yy468
-rw-r--r--sql/strfunc.cc16
-rw-r--r--sql/strfunc.h9
-rw-r--r--sql/structs.h21
-rw-r--r--sql/sys_vars.cc28
-rw-r--r--sql/sys_vars.ic108
-rw-r--r--sql/table.cc103
-rw-r--r--sql/table.h95
-rw-r--r--sql/transaction.cc8
-rw-r--r--sql/transaction.h6
-rw-r--r--sql/unireg.cc19
-rw-r--r--sql/wsrep_mysqld.cc16
-rw-r--r--sql/wsrep_mysqld.h2
-rw-r--r--sql/wsrep_thd.cc3
-rw-r--r--sql/wsrep_var.cc4
161 files changed, 3606 insertions, 3323 deletions
diff --git a/sql/create_options.cc b/sql/create_options.cc
index e6d86860afd..a56357db588 100644
--- a/sql/create_options.cc
+++ b/sql/create_options.cc
@@ -119,7 +119,7 @@ static bool report_unknown_option(THD *thd, engine_option_value *val,
#define value_ptr(STRUCT,OPT) ((char*)(STRUCT) + (OPT)->offset)
static bool set_one_value(ha_create_table_option *opt,
- THD *thd, const LEX_STRING *value, void *base,
+ THD *thd, const LEX_CSTRING *value, void *base,
bool suppress_warning,
MEM_ROOT *root)
{
@@ -311,7 +311,7 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg,
}
if (!seen || (opt->var && !last->value.str))
{
- LEX_STRING default_val= null_lex_str;
+ LEX_CSTRING default_val= null_clex_str;
/*
Okay, here's the logic for sysvar options:
@@ -348,9 +348,9 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg,
{
char buf[256];
String sbuf(buf, sizeof(buf), system_charset_info), *str;
- if ((str= sysvar->val_str(&sbuf, thd, OPT_SESSION, &null_lex_str)))
+ if ((str= sysvar->val_str(&sbuf, thd, OPT_SESSION, &null_clex_str)))
{
- LEX_STRING name= { const_cast<char*>(opt->name), opt->name_length };
+ LEX_CSTRING name= { opt->name, opt->name_length };
default_val.str= strmake_root(root, str->ptr(), str->length());
default_val.length= str->length();
val= new (root) engine_option_value(name, default_val,
@@ -688,7 +688,7 @@ uchar *engine_option_value::frm_read(const uchar *buff, const uchar *buff_end,
engine_option_value **start,
engine_option_value **end, MEM_ROOT *root)
{
- LEX_STRING name, value;
+ LEX_CSTRING name, value;
uint len;
#define need_buff(N) if (buff + (N) >= buff_end) return NULL
diff --git a/sql/create_options.h b/sql/create_options.h
index 191ec88750a..41e8abcb232 100644
--- a/sql/create_options.h
+++ b/sql/create_options.h
@@ -29,8 +29,8 @@ enum { ENGINE_OPTION_MAX_LENGTH=32767 };
class engine_option_value: public Sql_alloc
{
public:
- LEX_STRING name;
- LEX_STRING value;
+ LEX_CSTRING name;
+ LEX_CSTRING value;
engine_option_value *next; ///< parser puts them in a FIFO linked list
bool parsed; ///< to detect unrecognized options
bool quoted_value; ///< option=VAL vs. option='VAL'
@@ -42,28 +42,30 @@ class engine_option_value: public Sql_alloc
{
link(start, end);
}
- engine_option_value(LEX_STRING &name_arg, LEX_STRING &value_arg, bool quoted,
+ engine_option_value(LEX_CSTRING &name_arg, LEX_CSTRING &value_arg,
+ bool quoted,
engine_option_value **start, engine_option_value **end) :
name(name_arg), value(value_arg),
next(NULL), parsed(false), quoted_value(quoted)
{
link(start, end);
}
- engine_option_value(LEX_STRING &name_arg,
+ engine_option_value(LEX_CSTRING &name_arg,
engine_option_value **start, engine_option_value **end) :
- name(name_arg), value(null_lex_str),
+ name(name_arg), value(null_clex_str),
next(NULL), parsed(false), quoted_value(false)
{
link(start, end);
}
- engine_option_value(LEX_STRING &name_arg, ulonglong value_arg,
+ engine_option_value(LEX_CSTRING &name_arg, ulonglong value_arg,
engine_option_value **start, engine_option_value **end,
MEM_ROOT *root) :
name(name_arg), next(NULL), parsed(false), quoted_value(false)
{
- if ((value.str= (char *)alloc_root(root, 22)))
+ char *str;
+ if ((value.str= str= (char *)alloc_root(root, 22)))
{
- value.length= longlong10_to_str(value_arg, value.str, 10) - value.str;
+ value.length= longlong10_to_str(value_arg, str, 10) - str;
link(start, end);
}
}
diff --git a/sql/datadict.cc b/sql/datadict.cc
index 1093f2cdd09..b5a6a6794ce 100644
--- a/sql/datadict.cc
+++ b/sql/datadict.cc
@@ -44,7 +44,7 @@ static int read_string(File file, uchar**to, size_t length)
@param[in] path path to FRM file.
@param[in/out] engine_name table engine name (length < NAME_CHAR_LEN)
- engine_name is a LEX_STRING, where engine_name->str must point to
+ engine_name is a LEX_CSTRING, where engine_name->str must point to
a buffer of at least NAME_CHAR_LEN+1 bytes.
@param[out] is_sequence 1 if table is a SEQUENCE, 0 otherwise
@@ -55,7 +55,7 @@ static int read_string(File file, uchar**to, size_t length)
@retval TABLE_TYPE_VIEW view
*/
-Table_type dd_frm_type(THD *thd, char *path, LEX_STRING *engine_name,
+Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
bool *is_sequence)
{
File file;
@@ -132,8 +132,14 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_STRING *engine_name,
{
uint len= uint2korr(next_chunk);
if (len <= NAME_CHAR_LEN)
- strmake(engine_name->str, (char*)next_chunk + 2,
+ {
+ /*
+ The following cast is safe as the caller has allocated buffer
+ and it's up to this function to generate the name.
+ */
+ strmake((char*) engine_name->str, (char*)next_chunk + 2,
engine_name->length= len);
+ }
}
}
diff --git a/sql/datadict.h b/sql/datadict.h
index 46dac394f07..e102618c2f7 100644
--- a/sql/datadict.h
+++ b/sql/datadict.h
@@ -38,7 +38,7 @@ enum Table_type
To check whether it's an frm of a view, use dd_frm_is_view().
*/
-enum Table_type dd_frm_type(THD *thd, char *path, LEX_STRING *engine_name,
+enum Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
bool *is_sequence);
static inline bool dd_frm_is_view(THD *thd, char *path)
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 9e1ee6f30f9..86bdadabc17 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -171,13 +171,13 @@ Event_creation_ctx::load_from_db(THD *thd,
*/
bool
-Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n)
+Event_queue_element_for_exec::init(LEX_CSTRING db, LEX_CSTRING n)
{
if (!(dbname.str= my_strndup(db.str, dbname.length= db.length, MYF(MY_WME))))
return TRUE;
if (!(name.str= my_strndup(n.str, name.length= n.length, MYF(MY_WME))))
{
- my_free(dbname.str);
+ my_free(const_cast<char*>(dbname.str));
return TRUE;
}
return FALSE;
@@ -193,8 +193,8 @@ Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n)
Event_queue_element_for_exec::~Event_queue_element_for_exec()
{
- my_free(dbname.str);
- my_free(name.str);
+ my_free(const_cast<char*>(dbname.str));
+ my_free(const_cast<char*>(name.str));
}
@@ -233,7 +233,7 @@ Event_basic::~Event_basic()
/*
- Short function to load a char column into a LEX_STRING
+ Short function to load a char column into a LEX_CSTRING
SYNOPSIS
Event_basic::load_string_field()
@@ -249,7 +249,7 @@ Event_basic::load_string_fields(Field **fields, ...)
bool ret= FALSE;
va_list args;
enum enum_events_table_field field_name;
- LEX_STRING *field_value;
+ LEX_CSTRING *field_value;
DBUG_ENTER("Event_basic::load_string_fields");
@@ -257,7 +257,7 @@ Event_basic::load_string_fields(Field **fields, ...)
field_name= (enum enum_events_table_field) va_arg(args, int);
while (field_name < ET_FIELD_COUNT)
{
- field_value= va_arg(args, LEX_STRING *);
+ field_value= va_arg(args, LEX_CSTRING *);
if ((field_value->str= get_field(&mem_root, fields[field_name])) == NullS)
{
ret= TRUE;
@@ -274,9 +274,9 @@ Event_basic::load_string_fields(Field **fields, ...)
bool
-Event_basic::load_time_zone(THD *thd, const LEX_STRING tz_name)
+Event_basic::load_time_zone(THD *thd, const LEX_CSTRING *tz_name)
{
- String str(tz_name.str, &my_charset_latin1);
+ String str(tz_name->str, &my_charset_latin1);
time_zone= my_tz_find(thd, &str);
return (time_zone == NULL);
@@ -391,9 +391,9 @@ Event_timed::init()
bool
Event_job_data::load_from_row(THD *thd, TABLE *table)
{
- char *ptr;
+ const char *ptr;
size_t len;
- LEX_STRING tz_name;
+ LEX_CSTRING tz_name;
DBUG_ENTER("Event_job_data::load_from_row");
@@ -412,7 +412,7 @@ Event_job_data::load_from_row(THD *thd, TABLE *table)
ET_FIELD_COUNT))
DBUG_RETURN(TRUE);
- if (load_time_zone(thd, tz_name))
+ if (load_time_zone(thd, &tz_name))
DBUG_RETURN(TRUE);
Event_creation_ctx::load_from_db(thd, &mem_root, dbname.str, name.str, table,
@@ -452,9 +452,9 @@ Event_job_data::load_from_row(THD *thd, TABLE *table)
bool
Event_queue_element::load_from_row(THD *thd, TABLE *table)
{
- char *ptr;
+ const char *ptr;
MYSQL_TIME time;
- LEX_STRING tz_name;
+ LEX_CSTRING tz_name;
DBUG_ENTER("Event_queue_element::load_from_row");
@@ -472,7 +472,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
ET_FIELD_COUNT))
DBUG_RETURN(TRUE);
- if (load_time_zone(thd, tz_name))
+ if (load_time_zone(thd, &tz_name))
DBUG_RETURN(TRUE);
starts_null= table->field[ET_FIELD_STARTS]->is_null();
@@ -519,7 +519,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
int i;
char buff[MAX_FIELD_WIDTH];
String str(buff, sizeof(buff), &my_charset_bin);
- LEX_STRING tmp;
+ LEX_CSTRING tmp;
table->field[ET_FIELD_TRANSIENT_INTERVAL]->val_str(&str);
if (!(tmp.length= str.length()))
@@ -590,7 +590,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
bool
Event_timed::load_from_row(THD *thd, TABLE *table)
{
- char *ptr;
+ const char *ptr;
size_t len;
DBUG_ENTER("Event_timed::load_from_row");
@@ -1203,7 +1203,7 @@ Event_timed::get_create_event(THD *thd, String *buf)
buf->append(STRING_WITH_LEN(" ON SCHEDULE EVERY "));
buf->append(expr_buf);
buf->append(' ');
- LEX_STRING *ival= &interval_type_to_name[interval];
+ LEX_CSTRING *ival= &interval_type_to_name[interval];
buf->append(ival->str, ival->length);
if (!starts_null)
@@ -1249,7 +1249,7 @@ Event_timed::get_create_event(THD *thd, String *buf)
bool
Event_job_data::construct_sp_sql(THD *thd, String *sp_sql)
{
- LEX_STRING buffer;
+ LEX_CSTRING buffer;
const uint STATIC_SQL_LENGTH= 44;
DBUG_ENTER("Event_job_data::construct_sp_sql");
@@ -1298,7 +1298,7 @@ Event_job_data::construct_sp_sql(THD *thd, String *sp_sql)
bool
Event_job_data::construct_drop_event_sql(THD *thd, String *sp_sql)
{
- LEX_STRING buffer;
+ LEX_CSTRING buffer;
const uint STATIC_SQL_LENGTH= 14;
DBUG_ENTER("Event_job_data::construct_drop_event_sql");
@@ -1478,7 +1478,7 @@ end:
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
}
- ret= Events::drop_event(thd, dbname, name, FALSE);
+ ret= Events::drop_event(thd, &dbname, &name, FALSE);
WSREP_TO_ISOLATION_END;
@@ -1519,9 +1519,9 @@ end:
*/
bool
-event_basic_db_equal(LEX_STRING db, Event_basic *et)
+event_basic_db_equal(const LEX_CSTRING *db, Event_basic *et)
{
- return !sortcmp_lex_string(et->dbname, db, system_charset_info);
+ return !sortcmp_lex_string(&et->dbname, db, system_charset_info);
}
@@ -1540,10 +1540,11 @@ event_basic_db_equal(LEX_STRING db, Event_basic *et)
*/
bool
-event_basic_identifier_equal(LEX_STRING db, LEX_STRING name, Event_basic *b)
+event_basic_identifier_equal(const LEX_CSTRING *db, const LEX_CSTRING *name,
+ Event_basic *b)
{
- return !sortcmp_lex_string(name, b->name, system_charset_info) &&
- !sortcmp_lex_string(db, b->dbname, system_charset_info);
+ return !sortcmp_lex_string(name, &b->name, system_charset_info) &&
+ !sortcmp_lex_string(db, &b->dbname, system_charset_info);
}
/**
diff --git a/sql/event_data_objects.h b/sql/event_data_objects.h
index 7ad8191f4d2..884bbd7d701 100644
--- a/sql/event_data_objects.h
+++ b/sql/event_data_objects.h
@@ -37,10 +37,10 @@ public:
~Event_queue_element_for_exec();
bool
- init(LEX_STRING dbname, LEX_STRING name);
+ init(LEX_CSTRING dbname, LEX_CSTRING name);
- LEX_STRING dbname;
- LEX_STRING name;
+ LEX_CSTRING dbname;
+ LEX_CSTRING name;
bool dropped;
THD *thd;
@@ -58,9 +58,9 @@ protected:
public:
- LEX_STRING dbname;
- LEX_STRING name;
- LEX_STRING definer;// combination of user and host
+ LEX_CSTRING dbname;
+ LEX_CSTRING name;
+ LEX_CSTRING definer;// combination of user and host
Time_zone *time_zone;
@@ -75,7 +75,7 @@ protected:
load_string_fields(Field **fields, ...);
bool
- load_time_zone(THD *thd, const LEX_STRING tz_name);
+ load_time_zone(THD *thd, const LEX_CSTRING *tz_name);
};
@@ -122,12 +122,12 @@ class Event_timed : public Event_queue_element
void operator=(Event_timed &);
public:
- LEX_STRING body;
+ LEX_CSTRING body;
- LEX_STRING definer_user;
- LEX_STRING definer_host;
+ LEX_CSTRING definer_user;
+ LEX_CSTRING definer_host;
- LEX_STRING comment;
+ LEX_CSTRING comment;
ulonglong created;
ulonglong modified;
@@ -135,7 +135,7 @@ public:
sql_mode_t sql_mode;
class Stored_program_creation_ctx *creation_ctx;
- LEX_STRING body_utf8;
+ LEX_CSTRING body_utf8;
Event_timed();
virtual ~Event_timed();
@@ -154,9 +154,9 @@ public:
class Event_job_data : public Event_basic
{
public:
- LEX_STRING body;
- LEX_STRING definer_user;
- LEX_STRING definer_host;
+ LEX_CSTRING body;
+ LEX_CSTRING definer_user;
+ LEX_CSTRING definer_host;
sql_mode_t sql_mode;
@@ -182,11 +182,12 @@ private:
/* Compares only the schema part of the identifier */
bool
-event_basic_db_equal(LEX_STRING db, Event_basic *et);
+event_basic_db_equal(const LEX_CSTRING *db, Event_basic *et);
/* Compares the whole identifier*/
bool
-event_basic_identifier_equal(LEX_STRING db, LEX_STRING name, Event_basic *b);
+event_basic_identifier_equal(const LEX_CSTRING *db, const LEX_CSTRING *name,
+ Event_basic *b);
/**
@} (End of group Event_Scheduler)
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index ca4d93eb240..e71cfdc1e16 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -368,14 +368,14 @@ mysql_event_fill_row(THD *thd,
if (rs)
{
- my_error(ER_EVENT_STORE_FAILED, MYF(0), fields[f_num]->field_name, rs);
+ my_error(ER_EVENT_STORE_FAILED, MYF(0), fields[f_num]->field_name.str, rs);
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
err_truncate:
- my_error(ER_EVENT_DATA_TOO_LONG, MYF(0), fields[f_num]->field_name);
+ my_error(ER_EVENT_DATA_TOO_LONG, MYF(0), fields[f_num]->field_name.str);
DBUG_RETURN(TRUE);
}
@@ -670,7 +670,7 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
parse_data->name.str));
DBUG_PRINT("info", ("check existance of an event with the same name"));
- if (!find_named_event(parse_data->dbname, parse_data->name, table))
+ if (!find_named_event(&parse_data->dbname, &parse_data->name, table))
{
if (thd->lex->create_info.or_replace())
{
@@ -768,8 +768,8 @@ end:
bool
Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
- LEX_STRING *new_dbname,
- LEX_STRING *new_name)
+ LEX_CSTRING *new_dbname,
+ LEX_CSTRING *new_name)
{
CHARSET_INFO *scs= system_charset_info;
TABLE *table= NULL;
@@ -802,7 +802,7 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
if (new_name)
{
DBUG_PRINT("info", ("rename to: %s@%s", new_dbname->str, new_name->str));
- if (!find_named_event(*new_dbname, *new_name, table))
+ if (!find_named_event(new_dbname, new_name, table))
{
my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), new_name->str);
goto end;
@@ -814,7 +814,7 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
overwrite the key and SE will tell us that it cannot find the already found
row (copied into record[1] later
*/
- if (find_named_event(parse_data->dbname, parse_data->name, table))
+ if (find_named_event(&parse_data->dbname, &parse_data->name, table))
{
my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), parse_data->name.str);
goto end;
@@ -878,7 +878,8 @@ end:
*/
bool
-Event_db_repository::drop_event(THD *thd, LEX_STRING db, LEX_STRING name,
+Event_db_repository::drop_event(THD *thd, const LEX_CSTRING *db,
+ const LEX_CSTRING *name,
bool drop_if_exists)
{
TABLE *table= NULL;
@@ -891,7 +892,7 @@ Event_db_repository::drop_event(THD *thd, LEX_STRING db, LEX_STRING name,
int ret= 1;
DBUG_ENTER("Event_db_repository::drop_event");
- DBUG_PRINT("enter", ("%s@%s", db.str, name.str));
+ DBUG_PRINT("enter", ("%s@%s", db->str, name->str));
if (open_event_table(thd, TL_WRITE, &table))
goto end;
@@ -906,13 +907,13 @@ Event_db_repository::drop_event(THD *thd, LEX_STRING db, LEX_STRING name,
/* Event not found */
if (!drop_if_exists)
{
- my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), name.str);
+ my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), name->str);
goto end;
}
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_SP_DOES_NOT_EXIST, ER_THD(thd, ER_SP_DOES_NOT_EXIST),
- "Event", name.str);
+ "Event", name->str);
ret= 0;
end:
@@ -939,12 +940,13 @@ end:
*/
bool
-Event_db_repository::find_named_event(LEX_STRING db, LEX_STRING name,
+Event_db_repository::find_named_event(const LEX_CSTRING *db,
+ const LEX_CSTRING *name,
TABLE *table)
{
uchar key[MAX_KEY_LENGTH];
DBUG_ENTER("Event_db_repository::find_named_event");
- DBUG_PRINT("enter", ("name: %.*s", (int) name.length, name.str));
+ DBUG_PRINT("enter", ("name: %.*s", (int) name->length, name->str));
/*
Create key to find row. We have to use field->store() to be able to
@@ -953,16 +955,16 @@ Event_db_repository::find_named_event(LEX_STRING db, LEX_STRING name,
'db' and 'name' and the first key is the primary key over the
same fields.
*/
- if (db.length > table->field[ET_FIELD_DB]->field_length ||
- name.length > table->field[ET_FIELD_NAME]->field_length ||
+ if (db->length > table->field[ET_FIELD_DB]->field_length ||
+ name->length > table->field[ET_FIELD_NAME]->field_length ||
table->s->keys == 0 ||
table->key_info[0].user_defined_key_parts != 2 ||
table->key_info[0].key_part[0].fieldnr != ET_FIELD_DB+1 ||
table->key_info[0].key_part[1].fieldnr != ET_FIELD_NAME+1)
DBUG_RETURN(TRUE);
- table->field[ET_FIELD_DB]->store(db.str, db.length, &my_charset_bin);
- table->field[ET_FIELD_NAME]->store(name.str, name.length, &my_charset_bin);
+ table->field[ET_FIELD_DB]->store(db->str, db->length, &my_charset_bin);
+ table->field[ET_FIELD_NAME]->store(name->str, name->length, &my_charset_bin);
key_copy(key, table->record[0], table->key_info, table->key_info->key_length);
@@ -989,7 +991,7 @@ Event_db_repository::find_named_event(LEX_STRING db, LEX_STRING name,
*/
void
-Event_db_repository::drop_schema_events(THD *thd, LEX_STRING schema)
+Event_db_repository::drop_schema_events(THD *thd, const LEX_CSTRING *schema)
{
int ret= 0;
TABLE *table= NULL;
@@ -997,7 +999,7 @@ Event_db_repository::drop_schema_events(THD *thd, LEX_STRING schema)
enum enum_events_table_field field= ET_FIELD_DB;
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
DBUG_ENTER("Event_db_repository::drop_schema_events");
- DBUG_PRINT("enter", ("field=%d schema=%s", field, schema.str));
+ DBUG_PRINT("enter", ("field: %d schema: %s", field, schema->str));
if (open_event_table(thd, TL_WRITE, &table))
DBUG_VOID_RETURN;
@@ -1013,12 +1015,12 @@ Event_db_repository::drop_schema_events(THD *thd, LEX_STRING schema)
/* et_field may be NULL if the table is corrupted or out of memory */
if (et_field)
{
- LEX_STRING et_field_lex= { et_field, strlen(et_field) };
+ LEX_CSTRING et_field_lex= { et_field, strlen(et_field) };
DBUG_PRINT("info", ("Current event %s name=%s", et_field,
get_field(thd->mem_root,
table->field[ET_FIELD_NAME])));
- if (!sortcmp_lex_string(et_field_lex, schema, system_charset_info))
+ if (!sortcmp_lex_string(&et_field_lex, schema, system_charset_info))
{
DBUG_PRINT("info", ("Dropping"));
if ((ret= table->file->ha_delete_row(table->record[0])))
@@ -1051,8 +1053,9 @@ end:
*/
bool
-Event_db_repository::load_named_event(THD *thd, LEX_STRING dbname,
- LEX_STRING name, Event_basic *etn)
+Event_db_repository::load_named_event(THD *thd, const LEX_CSTRING *dbname,
+ const LEX_CSTRING *name,
+ Event_basic *etn)
{
bool ret;
ulonglong saved_mode= thd->variables.sql_mode;
@@ -1061,7 +1064,7 @@ Event_db_repository::load_named_event(THD *thd, LEX_STRING dbname,
DBUG_ENTER("Event_db_repository::load_named_event");
DBUG_PRINT("enter",("thd: 0x%lx name: %*s", (long) thd,
- (int) name.length, name.str));
+ (int) name->length, name->str));
event_table.init_one_table("mysql", 5, "event", 5, "event", TL_READ);
@@ -1084,7 +1087,7 @@ Event_db_repository::load_named_event(THD *thd, LEX_STRING dbname,
}
if ((ret= find_named_event(dbname, name, event_table.table)))
- my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), name.str);
+ my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), name->str);
else if ((ret= etn->load_from_row(thd, event_table.table)))
my_error(ER_CANNOT_LOAD_FROM_TABLE_V2, MYF(0), "mysql", "event");
@@ -1106,8 +1109,8 @@ Event_db_repository::load_named_event(THD *thd, LEX_STRING dbname,
bool
Event_db_repository::
update_timing_fields_for_event(THD *thd,
- LEX_STRING event_db_name,
- LEX_STRING event_name,
+ const LEX_CSTRING *event_db_name,
+ const LEX_CSTRING *event_name,
my_time_t last_executed,
ulonglong status)
{
@@ -1211,7 +1214,7 @@ Event_db_repository::check_system_tables(THD *thd)
else
{
if (tables.table->s->fields < event_priv_column_position ||
- strncmp(tables.table->field[event_priv_column_position]->field_name,
+ strncmp(tables.table->field[event_priv_column_position]->field_name.str,
STRING_WITH_LEN("Event_priv")))
{
sql_print_error("mysql.user has no `Event_priv` column at position %d",
diff --git a/sql/event_db_repository.h b/sql/event_db_repository.h
index e7b52bacc2a..34de3ec2c45 100644
--- a/sql/event_db_repository.h
+++ b/sql/event_db_repository.h
@@ -77,20 +77,24 @@ public:
create_event(THD *thd, Event_parse_data *parse_data,
bool *event_already_exists);
bool
- update_event(THD *thd, Event_parse_data *parse_data, LEX_STRING *new_dbname,
- LEX_STRING *new_name);
+ update_event(THD *thd, Event_parse_data *parse_data, LEX_CSTRING *new_dbname,
+ LEX_CSTRING *new_name);
bool
- drop_event(THD *thd, LEX_STRING db, LEX_STRING name, bool drop_if_exists);
+ drop_event(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *name,
+ bool drop_if_exists);
void
- drop_schema_events(THD *thd, LEX_STRING schema);
+ drop_schema_events(THD *thd, const LEX_CSTRING *schema);
bool
- find_named_event(LEX_STRING db, LEX_STRING name, TABLE *table);
+ find_named_event(const LEX_CSTRING *db, const LEX_CSTRING *name,
+ TABLE *table);
bool
- load_named_event(THD *thd, LEX_STRING dbname, LEX_STRING name, Event_basic *et);
+ load_named_event(THD *thd, const LEX_CSTRING *dbname,
+ const LEX_CSTRING *name,
+ Event_basic *et);
static bool
open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table);
@@ -100,8 +104,8 @@ public:
bool
update_timing_fields_for_event(THD *thd,
- LEX_STRING event_db_name,
- LEX_STRING event_name,
+ const LEX_CSTRING *event_db_name,
+ const LEX_CSTRING *event_name,
my_time_t last_executed,
ulonglong status);
public:
diff --git a/sql/event_parse_data.cc b/sql/event_parse_data.cc
index 2cd8f5c1b59..7932f228309 100644
--- a/sql/event_parse_data.cc
+++ b/sql/event_parse_data.cc
@@ -528,7 +528,7 @@ Event_parse_data::init_definer(THD *thd)
const char *definer_host= thd->lex->definer->host.str;
size_t definer_user_len= thd->lex->definer->user.length;
size_t definer_host_len= thd->lex->definer->host.length;
-
+ char *tmp;
DBUG_PRINT("info",("init definer_user thd->mem_root: 0x%lx "
"definer_user: 0x%lx", (long) thd->mem_root,
(long) definer_user));
@@ -536,15 +536,14 @@ Event_parse_data::init_definer(THD *thd)
/* + 1 for @ */
DBUG_PRINT("info",("init definer as whole"));
definer.length= definer_user_len + definer_host_len + 1;
- definer.str= (char*) thd->alloc(definer.length + 1);
+ definer.str= tmp= (char*) thd->alloc(definer.length + 1);
DBUG_PRINT("info",("copy the user"));
- memcpy(definer.str, definer_user, definer_user_len);
- definer.str[definer_user_len]= '@';
+ strmake(tmp, definer_user, definer_user_len);
+ tmp[definer_user_len]= '@';
DBUG_PRINT("info",("copy the host"));
- memcpy(definer.str + definer_user_len + 1, definer_host, definer_host_len);
- definer.str[definer.length]= '\0';
+ strmake(tmp + definer_user_len + 1, definer_host, definer_host_len);
DBUG_PRINT("info",("definer [%s] initted", definer.str));
DBUG_VOID_RETURN;
diff --git a/sql/event_parse_data.h b/sql/event_parse_data.h
index 3ca7fcaab72..e1aed36aa01 100644
--- a/sql/event_parse_data.h
+++ b/sql/event_parse_data.h
@@ -66,10 +66,10 @@ public:
bool body_changed;
- LEX_STRING dbname;
- LEX_STRING name;
- LEX_STRING definer;// combination of user and host
- LEX_STRING comment;
+ LEX_CSTRING dbname;
+ LEX_CSTRING name;
+ LEX_CSTRING definer;// combination of user and host
+ LEX_CSTRING comment;
Item* item_starts;
Item* item_ends;
diff --git a/sql/event_queue.cc b/sql/event_queue.cc
index ae8ba258717..9ffb9935634 100644
--- a/sql/event_queue.cc
+++ b/sql/event_queue.cc
@@ -238,11 +238,13 @@ Event_queue::create_event(THD *thd, Event_queue_element *new_element,
*/
void
-Event_queue::update_event(THD *thd, LEX_STRING dbname, LEX_STRING name,
+Event_queue::update_event(THD *thd, const LEX_CSTRING *dbname,
+ const LEX_CSTRING *name,
Event_queue_element *new_element)
{
DBUG_ENTER("Event_queue::update_event");
- DBUG_PRINT("enter", ("thd: 0x%lx et=[%s.%s]", (long) thd, dbname.str, name.str));
+ DBUG_PRINT("enter", ("thd: %p et: [%s.%s]", thd, dbname->str,
+ name->str));
if ((new_element->status == Event_parse_data::DISABLED) ||
(new_element->status == Event_parse_data::SLAVESIDE_DISABLED))
@@ -287,11 +289,12 @@ Event_queue::update_event(THD *thd, LEX_STRING dbname, LEX_STRING name,
*/
void
-Event_queue::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name)
+Event_queue::drop_event(THD *thd, const LEX_CSTRING *dbname,
+ const LEX_CSTRING *name)
{
DBUG_ENTER("Event_queue::drop_event");
- DBUG_PRINT("enter", ("thd: 0x%lx db :%s name: %s", (long) thd,
- dbname.str, name.str));
+ DBUG_PRINT("enter", ("thd: %p db: %s name: %s", thd,
+ dbname->str, name->str));
LOCK_QUEUE_DATA();
find_n_remove_event(dbname, name);
@@ -325,12 +328,12 @@ Event_queue::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name)
*/
void
-Event_queue::drop_matching_events(THD *thd, LEX_STRING pattern,
- bool (*comparator)(LEX_STRING, Event_basic *))
+Event_queue::drop_matching_events(THD *thd, const LEX_CSTRING *pattern,
+ bool (*comparator)(const LEX_CSTRING *, Event_basic *))
{
uint i;
DBUG_ENTER("Event_queue::drop_matching_events");
- DBUG_PRINT("enter", ("pattern=%s", pattern.str));
+ DBUG_PRINT("enter", ("pattern: %s", pattern->str));
for (i= queue_first_element(&queue) ;
i <= queue_last_element(&queue) ;
@@ -380,7 +383,7 @@ Event_queue::drop_matching_events(THD *thd, LEX_STRING pattern,
*/
void
-Event_queue::drop_schema_events(THD *thd, LEX_STRING schema)
+Event_queue::drop_schema_events(THD *thd, const LEX_CSTRING *schema)
{
DBUG_ENTER("Event_queue::drop_schema_events");
LOCK_QUEUE_DATA();
@@ -404,7 +407,8 @@ Event_queue::drop_schema_events(THD *thd, LEX_STRING schema)
*/
void
-Event_queue::find_n_remove_event(LEX_STRING db, LEX_STRING name)
+Event_queue::find_n_remove_event(const LEX_CSTRING *db,
+ const LEX_CSTRING *name)
{
uint i;
DBUG_ENTER("Event_queue::find_n_remove_event");
@@ -414,7 +418,7 @@ Event_queue::find_n_remove_event(LEX_STRING db, LEX_STRING name)
i++)
{
Event_queue_element *et= (Event_queue_element *) queue_element(&queue, i);
- DBUG_PRINT("info", ("[%s.%s]==[%s.%s]?", db.str, name.str,
+ DBUG_PRINT("info", ("[%s.%s]==[%s.%s]?", db->str, name->str,
et->dbname.str, et->name.str));
if (event_basic_identifier_equal(db, name, et))
{
@@ -683,7 +687,7 @@ end:
Event_db_repository *db_repository= Events::get_db_repository();
(void) db_repository->update_timing_fields_for_event(thd,
- (*event_name)->dbname, (*event_name)->name,
+ &(*event_name)->dbname, &(*event_name)->name,
last_executed, (ulonglong) status);
}
diff --git a/sql/event_queue.h b/sql/event_queue.h
index fdd5937ee17..ad3809fe086 100644
--- a/sql/event_queue.h
+++ b/sql/event_queue.h
@@ -31,7 +31,7 @@ extern PSI_cond_key key_COND_queue_state;
#endif /* HAVE_PSI_INTERFACE */
#include "queues.h" // QUEUE
-#include "sql_string.h" /* LEX_STRING */
+#include "sql_string.h" /* LEX_CSTRING */
#include "my_time.h" /* my_time_t, interval_type */
class Event_basic;
@@ -60,14 +60,14 @@ public:
bool *created);
void
- update_event(THD *thd, LEX_STRING dbname, LEX_STRING name,
+ update_event(THD *thd, const LEX_CSTRING *dbname, const LEX_CSTRING *name,
Event_queue_element *new_element);
void
- drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name);
+ drop_event(THD *thd, const LEX_CSTRING *dbname, const LEX_CSTRING *name);
void
- drop_schema_events(THD *thd, LEX_STRING schema);
+ drop_schema_events(THD *thd, const LEX_CSTRING *schema);
void
recalculate_activation_times(THD *thd);
@@ -98,12 +98,12 @@ private:
const char *src_func, const char *src_file, uint src_line);
void
- find_n_remove_event(LEX_STRING db, LEX_STRING name);
+ find_n_remove_event(const LEX_CSTRING *db, const LEX_CSTRING *name);
void
- drop_matching_events(THD *thd, LEX_STRING pattern,
- bool (*)(LEX_STRING, Event_basic *));
+ drop_matching_events(THD *thd, const LEX_CSTRING *pattern,
+ bool (*)(const LEX_CSTRING*, Event_basic *));
void
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index 8ed5901b69a..c889cbeba67 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -301,7 +301,7 @@ Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
if (res)
goto end;
- if ((res= db_repository->load_named_event(thd, event->dbname, event->name,
+ if ((res= db_repository->load_named_event(thd, &event->dbname, &event->name,
&job_data)))
{
DBUG_PRINT("error", ("Got error from load_named_event"));
diff --git a/sql/events.cc b/sql/events.cc
index 2daf99abffc..978a1ebc710 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -99,10 +99,11 @@ ulong Events::inited;
1 s > t
*/
-int sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs)
+int sortcmp_lex_string(const LEX_CSTRING *s, const LEX_CSTRING *t,
+ const CHARSET_INFO *cs)
{
- return cs->coll->strnncollsp(cs, (uchar *) s.str,s.length,
- (uchar *) t.str,t.length);
+ return cs->coll->strnncollsp(cs, (uchar *) s->str, s->length,
+ (uchar *) t->str, t->length);
}
@@ -352,7 +353,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
save_binlog_format= thd->set_current_stmt_binlog_format_stmt();
if (thd->lex->create_info.or_replace() && event_queue)
- event_queue->drop_event(thd, parse_data->dbname, parse_data->name);
+ event_queue->drop_event(thd, &parse_data->dbname, &parse_data->name);
/* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->create_event(thd, parse_data,
@@ -365,12 +366,12 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
{
if (!(new_element= new Event_queue_element()))
ret= TRUE; // OOM
- else if ((ret= db_repository->load_named_event(thd, parse_data->dbname,
- parse_data->name,
+ else if ((ret= db_repository->load_named_event(thd, &parse_data->dbname,
+ &parse_data->name,
new_element)))
{
- if (!db_repository->drop_event(thd, parse_data->dbname,
- parse_data->name, TRUE))
+ if (!db_repository->drop_event(thd, &parse_data->dbname,
+ &parse_data->name, TRUE))
dropped= 1;
delete new_element;
}
@@ -438,7 +439,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
bool
Events::update_event(THD *thd, Event_parse_data *parse_data,
- LEX_STRING *new_dbname, LEX_STRING *new_name)
+ LEX_CSTRING *new_dbname, LEX_CSTRING *new_name)
{
int ret;
enum_binlog_format save_binlog_format;
@@ -468,9 +469,9 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
if (new_dbname) /* It's a rename */
{
/* Check that the new and the old names differ. */
- if ( !sortcmp_lex_string(parse_data->dbname, *new_dbname,
+ if ( !sortcmp_lex_string(&parse_data->dbname, new_dbname,
system_charset_info) &&
- !sortcmp_lex_string(parse_data->name, *new_name,
+ !sortcmp_lex_string(&parse_data->name, new_name,
system_charset_info))
{
my_error(ER_EVENT_SAME_NAME, MYF(0));
@@ -511,12 +512,12 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
if (!(ret= db_repository->update_event(thd, parse_data,
new_dbname, new_name)))
{
- LEX_STRING dbname= new_dbname ? *new_dbname : parse_data->dbname;
- LEX_STRING name= new_name ? *new_name : parse_data->name;
+ LEX_CSTRING dbname= new_dbname ? *new_dbname : parse_data->dbname;
+ LEX_CSTRING name= new_name ? *new_name : parse_data->name;
if (!(new_element= new Event_queue_element()))
ret= TRUE; // OOM
- else if ((ret= db_repository->load_named_event(thd, dbname, name,
+ else if ((ret= db_repository->load_named_event(thd, &dbname, &name,
new_element)))
delete new_element;
else
@@ -528,7 +529,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
it right away.
*/
if (event_queue)
- event_queue->update_event(thd, parse_data->dbname, parse_data->name,
+ event_queue->update_event(thd, &parse_data->dbname, &parse_data->name,
new_element);
/* Binlog the alter event. */
DBUG_ASSERT(thd->query() && thd->query_length());
@@ -566,7 +567,8 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
*/
bool
-Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
+Events::drop_event(THD *thd, const LEX_CSTRING *dbname,
+ const LEX_CSTRING *name, bool if_exists)
{
int ret;
enum_binlog_format save_binlog_format;
@@ -575,7 +577,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
if (check_if_system_tables_error())
DBUG_RETURN(TRUE);
- if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0))
+ if (check_access(thd, EVENT_ACL, dbname->str, NULL, NULL, 0, 0))
DBUG_RETURN(TRUE);
/*
@@ -585,7 +587,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
save_binlog_format= thd->set_current_stmt_binlog_format_stmt();
if (lock_object_name(thd, MDL_key::EVENT,
- dbname.str, name.str))
+ dbname->str, name->str))
DBUG_RETURN(TRUE);
/* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->drop_event(thd, dbname, name, if_exists)))
@@ -614,9 +616,9 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
*/
void
-Events::drop_schema_events(THD *thd, char *db)
+Events::drop_schema_events(THD *thd, const char *db)
{
- LEX_STRING const db_lex= { db, strlen(db) };
+ const LEX_CSTRING db_lex= { db, strlen(db) };
DBUG_ENTER("Events::drop_schema_events");
DBUG_PRINT("enter", ("dropping events from %s", db));
@@ -628,8 +630,8 @@ Events::drop_schema_events(THD *thd, char *db)
are damaged, as intended.
*/
if (event_queue)
- event_queue->drop_schema_events(thd, db_lex);
- db_repository->drop_schema_events(thd, db_lex);
+ event_queue->drop_schema_events(thd, &db_lex);
+ db_repository->drop_schema_events(thd, &db_lex);
DBUG_VOID_RETURN;
}
@@ -646,7 +648,7 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol)
char show_str_buf[10 * STRING_BUFFER_USUAL_SIZE];
String show_str(show_str_buf, sizeof(show_str_buf), system_charset_info);
List<Item> field_list;
- LEX_STRING sql_mode;
+ LEX_CSTRING sql_mode;
const String *tz_name;
MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("send_show_create_event");
@@ -729,18 +731,19 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol)
*/
bool
-Events::show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name)
+Events::show_create_event(THD *thd, const LEX_CSTRING *dbname,
+ const LEX_CSTRING *name)
{
Event_timed et;
bool ret;
DBUG_ENTER("Events::show_create_event");
- DBUG_PRINT("enter", ("name: %s@%s", dbname.str, name.str));
+ DBUG_PRINT("enter", ("name: %s@%s", dbname->str, name->str));
if (check_if_system_tables_error())
DBUG_RETURN(TRUE);
- if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0))
+ if (check_access(thd, EVENT_ACL, dbname->str, NULL, NULL, 0, 0))
DBUG_RETURN(TRUE);
/*
@@ -781,8 +784,9 @@ Events::show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name)
int
Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
{
- char *db= NULL;
+ const char *db= NULL;
int ret;
+ char db_tmp[SAFE_NAME_LEN];
DBUG_ENTER("Events::fill_schema_events");
/*
@@ -806,10 +810,7 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
check_access(thd, EVENT_ACL, thd->lex->select_lex.db,
NULL, NULL, 0, 0))
DBUG_RETURN(1);
- db= thd->lex->select_lex.db;
-
- if (lower_case_table_names)
- my_casedn_str(system_charset_info, db);
+ db= normalize_db_name(thd->lex->select_lex.db, db_tmp, sizeof(db_tmp));
}
ret= db_repository->fill_schema_events(thd, tables, db);
diff --git a/sql/events.h b/sql/events.h
index 368aa9a05d5..4b4505b6a02 100644
--- a/sql/events.h
+++ b/sql/events.h
@@ -36,7 +36,7 @@ extern PSI_stage_info stage_waiting_on_empty_queue;
extern PSI_stage_info stage_waiting_for_next_activation;
extern PSI_stage_info stage_waiting_for_scheduler_to_stop;
-#include "sql_string.h" /* LEX_STRING */
+#include "sql_string.h" /* LEX_CSTRING */
#include "my_time.h" /* interval_type */
class Event_db_repository;
@@ -48,7 +48,8 @@ class THD;
typedef class Item COND;
int
-sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs);
+sortcmp_lex_string(const LEX_CSTRING *s, const LEX_CSTRING *t,
+ const CHARSET_INFO *cs);
/**
@brief A facade to the functionality of the Event Scheduler.
@@ -109,16 +110,18 @@ public:
static bool
update_event(THD *thd, Event_parse_data *parse_data,
- LEX_STRING *new_dbname, LEX_STRING *new_name);
+ LEX_CSTRING *new_dbname, LEX_CSTRING *new_name);
static bool
- drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists);
+ drop_event(THD *thd, const LEX_CSTRING *dbname, const LEX_CSTRING *name,
+ bool if_exists);
static void
- drop_schema_events(THD *thd, char *db);
+ drop_schema_events(THD *thd, const char *db);
static bool
- show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name);
+ show_create_event(THD *thd, const LEX_CSTRING *dbname,
+ const LEX_CSTRING *name);
/* Needed for both SHOW CREATE EVENT and INFORMATION_SCHEMA */
static int
diff --git a/sql/field.cc b/sql/field.cc
index 812c4dbb639..9215a6b8e60 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -51,6 +51,7 @@
*****************************************************************************/
static const char *zero_timestamp="0000-00-00 00:00:00.000000";
+LEX_CSTRING temp_lex_str= {"temp", 4};
/* number of bytes to store second_part part of the TIMESTAMP(N) */
static uint sec_part_bytes[MAX_DATETIME_PRECISION+1]= { 0, 1, 1, 2, 2, 3, 3 };
@@ -1297,7 +1298,7 @@ warn:
*/
Field_num::Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg),
@@ -1627,9 +1628,9 @@ String *Field::val_int_as_str(String *val_buffer, bool unsigned_val)
/// This is used as a table name when the table structure is not set up
Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
uchar null_bit_arg,
- utype unireg_check_arg, const char *field_name_arg)
+ utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
:ptr(ptr_arg), null_ptr(null_ptr_arg), table(0), orig_table(0),
- table_name(0), field_name(field_name_arg), option_list(0),
+ table_name(0), field_name(*field_name_arg), option_list(0),
option_struct(0), key_start(0), part_of_key(0),
part_of_key_not_clustered(0), part_of_sortkey(0),
unireg_check(unireg_check_arg), field_length(length_arg),
@@ -1888,7 +1889,7 @@ void Field::make_field(Send_field *field)
else
{
field->table_name= "";
- field->org_col_name= "";
+ field->org_col_name= empty_clex_str;
}
field->col_name= field_name;
field->length=field_length;
@@ -1995,13 +1996,14 @@ bool Field_num::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
longlong nr= val_int();
bool neg= !(flags & UNSIGNED_FLAG) && nr < 0;
return int_to_datetime_with_warn(neg, neg ? -nr : nr, ltime, fuzzydate,
- field_name);
+ field_name.str);
}
Field_str::Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg, CHARSET_INFO *charset_arg)
+ const LEX_CSTRING *field_name_arg,
+ CHARSET_INFO *charset_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
{
@@ -2896,7 +2898,7 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg,
uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
uint8 dec_arg,bool zero_arg,
bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
@@ -2912,7 +2914,7 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg,
Field_new_decimal::Field_new_decimal(uint32 len_arg,
bool maybe_null_arg,
- const char *name,
+ const LEX_CSTRING *name,
uint8 dec_arg,
bool unsigned_arg)
:Field_num((uchar*) 0, len_arg,
@@ -2932,7 +2934,6 @@ Field *Field_new_decimal::create_from_item(MEM_ROOT *mem_root, Item *item)
uint8 dec= item->decimals;
uint8 intg= item->decimal_precision() - dec;
uint32 len= item->max_char_length();
-
DBUG_ASSERT (item->result_type() == DECIMAL_RESULT);
/*
@@ -2967,7 +2968,7 @@ Field *Field_new_decimal::create_from_item(MEM_ROOT *mem_root, Item *item)
len= required_length;
}
return new (mem_root)
- Field_new_decimal(len, item->maybe_null, item->name,
+ Field_new_decimal(len, item->maybe_null, &item->name,
dec, item->unsigned_flag);
}
@@ -3272,7 +3273,7 @@ bool Field_new_decimal::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
my_decimal value;
return decimal_to_datetime_with_warn(val_decimal(&value),
- ltime, fuzzydate, field_name);
+ ltime, fuzzydate, field_name.str);
}
@@ -3442,7 +3443,8 @@ Item *Field_new_decimal::get_equal_const_item(THD *thd, const Context &ctx,
Field_time::get_equal_const_item().
*/
my_decimal_round(E_DEC_FATAL_ERROR, val, decimals(), true, &val_buffer2);
- return new (thd->mem_root) Item_decimal(thd, field_name, &val_buffer2,
+ return new (thd->mem_root) Item_decimal(thd, field_name.str,
+ &val_buffer2,
decimals(), field_length);
}
break;
@@ -4734,7 +4736,7 @@ bool Field_real::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
{
ASSERT_COLUMN_MARKED_FOR_READ;
double nr= val_real();
- return double_to_datetime_with_warn(nr, ltime, fuzzydate, field_name);
+ return double_to_datetime_with_warn(nr, ltime, fuzzydate, field_name.str);
}
@@ -4889,7 +4891,7 @@ void Field_double::sql_type(String &res) const
Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share)
:Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
@@ -5849,7 +5851,7 @@ bool Field_time::check_zero_in_date_with_warn(ulonglong fuzzydate)
THD *thd= get_thd();
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE,
- ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE), field_name,
+ ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE), field_name.str,
thd->get_stmt_da()->current_row_for_warning());
return true;
}
@@ -6230,7 +6232,7 @@ bool Field_year::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
if (tmp || field_length != 4)
tmp+= 1900;
return int_to_datetime_with_warn(false, tmp * 10000,
- ltime, fuzzydate, field_name);
+ ltime, fuzzydate, field_name.str);
}
@@ -7086,7 +7088,7 @@ check_field_for_37426(const void *param_arg)
Check_field_param *param= (Check_field_param*) param_arg;
DBUG_ASSERT(param->field->real_type() == MYSQL_TYPE_STRING);
DBUG_PRINT("debug", ("Field %s - type: %d, size: %d",
- param->field->field_name,
+ param->field->field_name.str,
param->field->real_type(),
param->field->row_pack_length()));
return param->field->row_pack_length() > 255;
@@ -7168,7 +7170,8 @@ uchar *Field_string::pack(uchar *to, const uchar *from, uint max_length)
{
uint length= MY_MIN(field_length,max_length);
uint local_char_length= max_length/field_charset->mbmaxlen;
- DBUG_PRINT("debug", ("Packing field '%s' - length: %u ", field_name, length));
+ DBUG_PRINT("debug", ("Packing field '%s' - length: %u ", field_name.str,
+ length));
if (length > local_char_length)
local_char_length= my_charpos(field_charset, from, from+length,
@@ -7340,7 +7343,7 @@ Field *Field_string::make_new_field(MEM_ROOT *root, TABLE *new_table,
if (type() != MYSQL_TYPE_VAR_STRING || keep_type)
field= Field::make_new_field(root, new_table, keep_type);
else if ((field= new (root) Field_varstring(field_length, maybe_null(),
- field_name,
+ &field_name,
new_table->s, charset())))
{
/*
@@ -7811,7 +7814,8 @@ void Field_varstring::hash(ulong *nr, ulong *nr2)
****************************************************************************/
Field_blob::Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg,
+ const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint blob_pack_length,
CHARSET_INFO *cs)
:Field_longstr(ptr_arg, BLOB_PACK_LENGTH_TO_MAX_LENGH(blob_pack_length),
@@ -8165,8 +8169,10 @@ Field *Field_blob::new_key_field(MEM_ROOT *root, TABLE *new_table,
uchar *new_null_ptr, uint new_null_bit)
{
Field_varstring *res= new (root) Field_varstring(new_ptr, length, 2,
- new_null_ptr, new_null_bit, Field::NONE,
- field_name, table->s, charset());
+ new_null_ptr,
+ new_null_bit, Field::NONE,
+ &field_name,
+ table->s, charset());
res->init(new_table);
return res;
}
@@ -8517,7 +8523,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
my_error(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, MYF(0),
Geometry::ci_collection[geom_type]->m_name.str,
Geometry::ci_collection[wkb_type]->m_name.str,
- field_name,
+ field_name.str,
(ulong) table->in_use->get_stmt_da()->
current_row_for_warning());
goto err_exit;
@@ -9104,7 +9110,8 @@ bool Field_enum::can_optimize_keypart_ref(const Item_bool_func *cond,
Field_bit::Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
- enum utype unireg_check_arg, const char *field_name_arg)
+ enum utype unireg_check_arg,
+ const LEX_CSTRING *field_name_arg)
: Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg),
bit_ptr(bit_ptr_arg), bit_ofs(bit_ofs_arg), bit_len(len_arg & 7),
@@ -9619,7 +9626,7 @@ void Field_bit::set_default()
Field_bit_as_char::Field_bit_as_char(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg)
+ const LEX_CSTRING *field_name_arg)
:Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, 0, 0,
unireg_check_arg, field_name_arg)
{
@@ -9880,7 +9887,7 @@ void Column_definition::create_length_to_internal_length(void)
}
-bool check_expression(Virtual_column_info *vcol, const char *name,
+bool check_expression(Virtual_column_info *vcol, LEX_CSTRING *name,
enum_vcol_info_type type)
{
@@ -9888,7 +9895,7 @@ bool check_expression(Virtual_column_info *vcol, const char *name,
Item::vcol_func_processor_result res;
if (!vcol->name.length)
- vcol->name.str= const_cast<char*>(name);
+ vcol->name= *name;
/*
Walk through the Item tree checking if all items are valid
@@ -9905,7 +9912,7 @@ bool check_expression(Virtual_column_info *vcol, const char *name,
if (ret || (res.errors & filter))
{
my_error(ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), res.name,
- vcol_type_name(type), name);
+ vcol_type_name(type), name->str);
return TRUE;
}
/*
@@ -9930,19 +9937,19 @@ bool Column_definition::check(THD *thd)
{
DBUG_ASSERT(vcol_info->expr);
vcol_info->set_field_type(sql_type);
- if (check_expression(vcol_info, field_name, vcol_info->stored_in_db
+ if (check_expression(vcol_info, &field_name, vcol_info->stored_in_db
? VCOL_GENERATED_STORED : VCOL_GENERATED_VIRTUAL))
DBUG_RETURN(TRUE);
}
if (check_constraint &&
- check_expression(check_constraint, field_name, VCOL_CHECK_FIELD))
+ check_expression(check_constraint, &field_name, VCOL_CHECK_FIELD))
DBUG_RETURN(1);
if (default_value)
{
Item *def_expr= default_value->expr;
- if (check_expression(default_value, field_name, VCOL_DEFAULT))
+ if (check_expression(default_value, &field_name, VCOL_DEFAULT))
DBUG_RETURN(TRUE);
/* Constant's are stored in the 'empty_record', except for blobs */
@@ -9953,7 +9960,7 @@ bool Column_definition::check(THD *thd)
default_value= 0;
if ((flags & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG)
{
- my_error(ER_INVALID_DEFAULT, MYF(0), field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), field_name.str);
DBUG_RETURN(1);
}
}
@@ -9962,7 +9969,7 @@ bool Column_definition::check(THD *thd)
if (default_value && (flags & AUTO_INCREMENT_FLAG))
{
- my_error(ER_INVALID_DEFAULT, MYF(0), field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), field_name.str);
DBUG_RETURN(1);
}
@@ -9988,7 +9995,7 @@ bool Column_definition::check(THD *thd)
if (mysql_type_to_time_type(sql_type) != MYSQL_TIMESTAMP_DATETIME ||
on_update->decimals < length)
{
- my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name);
+ my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name.str);
DBUG_RETURN(TRUE);
}
unireg_check= unireg_check == Field::NONE ? Field::TIMESTAMP_UN_FIELD
@@ -10031,19 +10038,19 @@ bool Column_definition::check(THD *thd)
if (decimals >= NOT_FIXED_DEC)
{
my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals),
- field_name, static_cast<ulong>(NOT_FIXED_DEC - 1));
+ field_name.str, static_cast<uint>(NOT_FIXED_DEC - 1));
DBUG_RETURN(TRUE);
}
my_decimal_trim(&length, &decimals);
if (length > DECIMAL_MAX_PRECISION)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name,
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name.str,
DECIMAL_MAX_PRECISION);
DBUG_RETURN(TRUE);
}
if (length < decimals)
{
- my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name);
+ my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name.str);
DBUG_RETURN(TRUE);
}
length=
@@ -10083,13 +10090,13 @@ bool Column_definition::check(THD *thd)
if (length < decimals &&
decimals != NOT_FIXED_DEC)
{
- my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name);
+ my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name.str);
DBUG_RETURN(TRUE);
}
if (decimals != NOT_FIXED_DEC && decimals >= FLOATING_POINT_DECIMALS)
{
my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals),
- field_name, static_cast<ulong>(FLOATING_POINT_DECIMALS-1));
+ field_name.str, static_cast<uint>(FLOATING_POINT_DECIMALS-1));
DBUG_RETURN(TRUE);
}
break;
@@ -10103,13 +10110,13 @@ bool Column_definition::check(THD *thd)
if (length < decimals &&
decimals != NOT_FIXED_DEC)
{
- my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name);
+ my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name.str);
DBUG_RETURN(TRUE);
}
if (decimals != NOT_FIXED_DEC && decimals >= FLOATING_POINT_DECIMALS)
{
my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals),
- field_name, static_cast<ulong>(FLOATING_POINT_DECIMALS-1));
+ field_name.str, static_cast<uint>(FLOATING_POINT_DECIMALS-1));
DBUG_RETURN(TRUE);
}
break;
@@ -10117,7 +10124,7 @@ bool Column_definition::check(THD *thd)
case MYSQL_TYPE_TIMESTAMP2:
if (length > MAX_DATETIME_PRECISION)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name,
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name.str,
MAX_DATETIME_PRECISION);
DBUG_RETURN(TRUE);
}
@@ -10135,7 +10142,7 @@ bool Column_definition::check(THD *thd)
case MYSQL_TYPE_TIME2:
if (length > MAX_DATETIME_PRECISION)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name,
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name.str,
MAX_DATETIME_PRECISION);
DBUG_RETURN(TRUE);
}
@@ -10145,7 +10152,7 @@ bool Column_definition::check(THD *thd)
case MYSQL_TYPE_DATETIME2:
if (length > MAX_DATETIME_PRECISION)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name,
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name.str,
MAX_DATETIME_PRECISION);
DBUG_RETURN(TRUE);
}
@@ -10167,7 +10174,7 @@ bool Column_definition::check(THD *thd)
length= 1;
if (length > MAX_BIT_FIELD_LENGTH)
{
- my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name,
+ my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name.str,
static_cast<ulong>(MAX_BIT_FIELD_LENGTH));
DBUG_RETURN(TRUE);
}
@@ -10213,18 +10220,19 @@ bool Column_definition::check(THD *thd)
sql_type == MYSQL_TYPE_STRING) ? ER_TOO_BIG_FIELDLENGTH :
ER_TOO_BIG_DISPLAYWIDTH,
MYF(0),
- field_name, max_field_charlength); /* purecov: inspected */
+ field_name.str, max_field_charlength); /* purecov: inspected */
DBUG_RETURN(TRUE);
}
else if (length > MAX_FIELD_BLOBLENGTH)
{
- my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name, MAX_FIELD_BLOBLENGTH);
+ my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name.str,
+ MAX_FIELD_BLOBLENGTH);
DBUG_RETURN(1);
}
if ((~allowed_type_modifier) & flags & conditional_type_modifiers)
{
- my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name);
+ my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name.str);
DBUG_RETURN(TRUE);
}
@@ -10327,7 +10335,7 @@ Field *make_field(TABLE_SHARE *share,
Field::geometry_type geom_type, uint srid,
Field::utype unireg_check,
TYPELIB *interval,
- const char *field_name)
+ const LEX_CSTRING *field_name)
{
uchar *UNINIT_VAR(bit_ptr);
uchar UNINIT_VAR(bit_offset);
@@ -10806,7 +10814,7 @@ Field::set_warning(Sql_condition::enum_warning_level level, uint code,
if (thd->count_cuted_fields)
{
thd->cuted_fields+= cut_increment;
- push_warning_printf(thd, level, code, ER_THD(thd, code), field_name,
+ push_warning_printf(thd, level, code, ER_THD(thd, code), field_name.str,
thd->get_stmt_da()->current_row_for_warning());
return 0;
}
@@ -10839,7 +10847,7 @@ void Field::set_datetime_warning(Sql_condition::enum_warning_level level,
{
THD *thd= get_thd();
if (thd->really_abort_on_warning() && level >= Sql_condition::WARN_LEVEL_WARN)
- make_truncated_value_warning(thd, level, str, ts_type, field_name);
+ make_truncated_value_warning(thd, level, str, ts_type, field_name.str);
else
set_warning(level, code, cuted_increment);
}
@@ -10852,7 +10860,7 @@ void Field::set_warning_truncated_wrong_value(const char *type_arg,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
ER_THD(thd, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
- type_arg, value, field_name,
+ type_arg, value, field_name.str,
static_cast<ulong>(thd->get_stmt_da()->
current_row_for_warning()));
}
@@ -10921,7 +10929,7 @@ bool Field::validate_value_in_record_with_warn(THD *thd, const uchar *record)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_INVALID_DEFAULT_VALUE_FOR_FIELD,
ER_THD(thd, ER_INVALID_DEFAULT_VALUE_FOR_FIELD),
- ErrConvString(&tmp).ptr(), field_name);
+ ErrConvString(&tmp).ptr(), field_name.str);
}
dbug_tmp_restore_column_map(table->read_set, old_map);
return rc;
@@ -10956,7 +10964,7 @@ bool Field::save_in_field_default_value(bool view_error_processing)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_FIELD,
ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD),
- field_name);
+ field_name.str);
}
return 1;
}
diff --git a/sql/field.h b/sql/field.h
index 9559ba789b1..e62b98936b7 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -608,7 +608,7 @@ public:
bool stored_in_db;
bool utf8; /* Already in utf8 */
Item *expr;
- LEX_STRING name; /* Name of constraint */
+ LEX_CSTRING name; /* Name of constraint */
uint flags;
Virtual_column_info()
@@ -686,12 +686,12 @@ public:
*/
TABLE *table; // Pointer for table
TABLE *orig_table; // Pointer to original table
- const char * const *table_name;
- const char *field_name;
+ const char * const *table_name; // Pointer to alias in TABLE
+ LEX_CSTRING field_name;
+ LEX_CSTRING comment;
/** reference to the list of options or NULL */
engine_option_value *option_list;
ha_field_option_struct *option_struct; /* structure with parsed options */
- LEX_STRING comment;
/* Field is part of the following keys */
key_map key_start, part_of_key, part_of_key_not_clustered;
@@ -780,7 +780,7 @@ public:
Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg);
+ const LEX_CSTRING *field_name_arg);
virtual ~Field() {}
DTCollation dtcollation() const
@@ -824,6 +824,8 @@ public:
enum_check_fields check_level);
int store(const LEX_STRING *ls, CHARSET_INFO *cs)
{ return store(ls->str, ls->length, cs); }
+ int store(const LEX_CSTRING *ls, CHARSET_INFO *cs)
+ { return store(ls->str, ls->length, cs); }
virtual double val_real(void)=0;
virtual longlong val_int(void)=0;
virtual bool val_bool(void)= 0;
@@ -1310,7 +1312,7 @@ protected:
{
return set_warning(Sql_condition::WARN_LEVEL_NOTE, code, cuted_increment);
}
- void set_datetime_warning(Sql_condition::enum_warning_level, uint code,
+ void set_datetime_warning(Sql_condition::enum_warning_level, uint code,
const ErrConv *str, timestamp_type ts_type,
int cuted_increment) const;
void set_datetime_warning(uint code,
@@ -1526,7 +1528,7 @@ protected:
return to + size;
}
- const uchar *unpack_int(uchar* to, const uchar *from,
+ const uchar *unpack_int(uchar* to, const uchar *from,
const uchar *from_end, size_t size)
{
if (from + size > from_end)
@@ -1585,7 +1587,7 @@ public:
bool zerofill,unsigned_flag; // Purify cannot handle bit fields
Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg);
enum Item_result result_type () const { return INT_RESULT; }
enum Derivation derivation(void) const { return DERIVATION_NUMERIC; }
@@ -1649,7 +1651,7 @@ public:
const Item_equal *item_equal);
Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg, CHARSET_INFO *charset);
+ const LEX_CSTRING *field_name_arg, CHARSET_INFO *charset);
Item_result result_type () const { return STRING_RESULT; }
uint decimals() const { return NOT_FIXED_DEC; }
int save_in_field(Field *to) { return save_in_field_str(to); }
@@ -1717,7 +1719,7 @@ protected:
public:
Field_longstr(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg, CHARSET_INFO *charset_arg)
+ const LEX_CSTRING *field_name_arg, CHARSET_INFO *charset_arg)
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, charset_arg)
{}
@@ -1752,7 +1754,7 @@ public:
Field_real(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, dec_arg, zero_arg, unsigned_arg),
@@ -1789,7 +1791,7 @@ class Field_decimal :public Field_real {
public:
Field_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
@@ -1837,10 +1839,11 @@ public:
*/
Field_new_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg,
+ const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg);
Field_new_decimal(uint32 len_arg, bool maybe_null_arg,
- const char *field_name_arg, uint8 dec_arg,
+ const LEX_CSTRING *field_name_arg, uint8 dec_arg,
bool unsigned_arg);
enum_field_types type() const { return MYSQL_TYPE_NEWDECIMAL;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
@@ -1903,7 +1906,7 @@ class Field_tiny :public Field_num {
public:
Field_tiny(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
@@ -1947,13 +1950,14 @@ class Field_short :public Field_num {
public:
Field_short(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg)
{}
- Field_short(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_short(uint32 len_arg,bool maybe_null_arg,
+ const LEX_CSTRING *field_name_arg,
bool unsigned_arg)
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, 0, 0, unsigned_arg)
@@ -1987,7 +1991,7 @@ class Field_medium :public Field_num {
public:
Field_medium(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
@@ -2021,13 +2025,14 @@ class Field_long :public Field_num {
public:
Field_long(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg)
{}
- Field_long(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_long(uint32 len_arg,bool maybe_null_arg,
+ const LEX_CSTRING *field_name_arg,
bool unsigned_arg)
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg,0,0,unsigned_arg)
@@ -2066,15 +2071,15 @@ class Field_longlong :public Field_num {
public:
Field_longlong(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg)
{}
Field_longlong(uint32 len_arg,bool maybe_null_arg,
- const char *field_name_arg,
- bool unsigned_arg)
+ const LEX_CSTRING *field_name_arg,
+ bool unsigned_arg)
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg,0,0,unsigned_arg)
{}
@@ -2115,7 +2120,7 @@ class Field_float :public Field_real {
public:
Field_float(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
@@ -2124,8 +2129,8 @@ public:
if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC;
}
- Field_float(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
- uint8 dec_arg)
+ Field_float(uint32 len_arg, bool maybe_null_arg,
+ const LEX_CSTRING *field_name_arg, uint8 dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0)
{
@@ -2156,7 +2161,7 @@ class Field_double :public Field_real {
public:
Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
@@ -2165,15 +2170,16 @@ public:
if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC;
}
- Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
- uint8 dec_arg)
+ Field_double(uint32 len_arg, bool maybe_null_arg,
+ const LEX_CSTRING *field_name_arg, uint8 dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0)
{
if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC;
}
- Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
+ Field_double(uint32 len_arg, bool maybe_null_arg,
+ const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool not_fixed_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0)
@@ -2214,7 +2220,7 @@ class Field_null :public Field_str {
static uchar null[1];
public:
Field_null(uchar *ptr_arg, uint32 len_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
CHARSET_INFO *cs)
:Field_str(ptr_arg, len_arg, null, 1,
unireg_check_arg, field_name_arg, cs)
@@ -2265,7 +2271,7 @@ protected:
public:
Field_temporal(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg)
+ const LEX_CSTRING *field_name_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg)
{ flags|= BINARY_FLAG; }
@@ -2344,7 +2350,7 @@ public:
Field_temporal_with_date(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
utype unireg_check_arg,
- const char *field_name_arg)
+ const LEX_CSTRING *field_name_arg)
:Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
{}
@@ -2364,7 +2370,8 @@ protected:
public:
Field_timestamp(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg,
+ const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share);
enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
@@ -2433,7 +2440,7 @@ public:
Field_timestamp_with_dec(uchar *ptr_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint dec_arg) :
Field_timestamp(ptr_arg,
MAX_DATETIME_WIDTH + dec_arg + MY_TEST(dec_arg), null_ptr_arg,
@@ -2467,7 +2474,7 @@ public:
Field_timestamp_hires(uchar *ptr_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint dec_arg) :
Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, share, dec_arg)
@@ -2495,7 +2502,7 @@ public:
Field_timestampf(uchar *ptr_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint dec_arg) :
Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, share, dec_arg)
@@ -2527,7 +2534,7 @@ class Field_year :public Field_tiny {
public:
Field_year(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg)
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
:Field_tiny(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, 1, 1)
{}
@@ -2573,7 +2580,7 @@ class Field_date :public Field_temporal_with_date {
bool get_TIME(MYSQL_TIME *ltime, const uchar *pos, ulonglong fuzzydate) const;
public:
Field_date(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg)
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
:Field_temporal_with_date(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg) {}
enum_field_types type() const { return MYSQL_TYPE_DATE;}
@@ -2608,7 +2615,7 @@ class Field_newdate :public Field_temporal_with_date {
bool get_TIME(MYSQL_TIME *ltime, const uchar *pos, ulonglong fuzzydate) const;
public:
Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg)
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
:Field_temporal_with_date(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
{}
@@ -2647,7 +2654,7 @@ protected:
public:
Field_time(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg,
- const char *field_name_arg)
+ const LEX_CSTRING *field_name_arg)
:Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg), curdays(0)
{}
@@ -2699,7 +2706,8 @@ protected:
uint dec;
public:
Field_time_with_dec(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg,
+ const LEX_CSTRING *field_name_arg,
uint dec_arg)
:Field_time(ptr_arg, MIN_TIME_WIDTH + dec_arg + MY_TEST(dec_arg),
null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg),
@@ -2723,7 +2731,7 @@ class Field_time_hires :public Field_time_with_dec {
void store_TIME(MYSQL_TIME *ltime);
public:
Field_time_hires(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint dec_arg)
:Field_time_with_dec(ptr_arg, null_ptr_arg,
null_bit_arg, unireg_check_arg, field_name_arg,
@@ -2754,7 +2762,7 @@ class Field_timef :public Field_time_with_dec {
}
public:
Field_timef(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint dec_arg)
:Field_time_with_dec(ptr_arg, null_ptr_arg,
null_bit_arg, unireg_check_arg, field_name_arg,
@@ -2796,7 +2804,7 @@ class Field_datetime :public Field_temporal_with_date {
public:
Field_datetime(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg,
- const char *field_name_arg)
+ const LEX_CSTRING *field_name_arg)
:Field_temporal_with_date(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
{
@@ -2853,7 +2861,7 @@ protected:
public:
Field_datetime_with_dec(uchar *ptr_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg,
- const char *field_name_arg, uint dec_arg)
+ const LEX_CSTRING *field_name_arg, uint dec_arg)
:Field_datetime(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + MY_TEST(dec_arg),
null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg), dec(dec_arg)
@@ -2889,7 +2897,7 @@ class Field_datetime_hires :public Field_datetime_with_dec {
public:
Field_datetime_hires(uchar *ptr_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg,
- const char *field_name_arg, uint dec_arg)
+ const LEX_CSTRING *field_name_arg, uint dec_arg)
:Field_datetime_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, dec_arg)
{
@@ -2917,7 +2925,7 @@ class Field_datetimef :public Field_datetime_with_dec {
public:
Field_datetimef(uchar *ptr_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg,
- const char *field_name_arg, uint dec_arg)
+ const LEX_CSTRING *field_name_arg, uint dec_arg)
:Field_datetime_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, dec_arg)
{}
@@ -2947,7 +2955,8 @@ public:
static inline Field_timestamp *
new_Field_timestamp(MEM_ROOT *root,uchar *ptr, uchar *null_ptr, uchar null_bit,
- enum Field::utype unireg_check, const char *field_name,
+ enum Field::utype unireg_check,
+ const LEX_CSTRING *field_name,
TABLE_SHARE *share, uint dec)
{
if (dec==0)
@@ -2963,7 +2972,7 @@ new_Field_timestamp(MEM_ROOT *root,uchar *ptr, uchar *null_ptr, uchar null_bit,
static inline Field_time *
new_Field_time(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit,
- enum Field::utype unireg_check, const char *field_name,
+ enum Field::utype unireg_check, const LEX_CSTRING *field_name,
uint dec)
{
if (dec == 0)
@@ -2979,7 +2988,7 @@ new_Field_time(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit,
static inline Field_datetime *
new_Field_datetime(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit,
enum Field::utype unireg_check,
- const char *field_name, uint dec)
+ const LEX_CSTRING *field_name, uint dec)
{
if (dec == 0)
return new (root)
@@ -3002,12 +3011,13 @@ public:
bool can_alter_field_type;
Field_string(uchar *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
CHARSET_INFO *cs)
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, cs),
can_alter_field_type(1) {};
- Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_string(uint32 len_arg,bool maybe_null_arg,
+ const LEX_CSTRING *field_name_arg,
CHARSET_INFO *cs)
:Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs),
@@ -3091,7 +3101,7 @@ public:
Field_varstring(uchar *ptr_arg,
uint32 len_arg, uint length_bytes_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, CHARSET_INFO *cs)
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, cs),
@@ -3100,7 +3110,7 @@ public:
share->varchar_fields++;
}
Field_varstring(uint32 len_arg,bool maybe_null_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, CHARSET_INFO *cs)
:Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs),
@@ -3168,6 +3178,8 @@ private:
};
+extern LEX_CSTRING temp_lex_str;
+
class Field_blob :public Field_longstr {
protected:
/**
@@ -3190,9 +3202,9 @@ protected:
static void do_conv_blob(Copy_field *copy);
public:
Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint blob_pack_length, CHARSET_INFO *cs);
- Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_blob(uint32 len_arg,bool maybe_null_arg, const LEX_CSTRING *field_name_arg,
CHARSET_INFO *cs)
:Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs),
@@ -3200,7 +3212,8 @@ public:
{
flags|= BLOB_FLAG;
}
- Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_blob(uint32 len_arg,bool maybe_null_arg,
+ const LEX_CSTRING *field_name_arg,
CHARSET_INFO *cs, bool set_packlength)
:Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs)
@@ -3215,7 +3228,8 @@ public:
}
}
Field_blob(uint32 packlength_arg)
- :Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, "temp", system_charset_info),
+ :Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, &temp_lex_str,
+ system_charset_info),
packlength(packlength_arg) {}
/* Note that the default copy constructor is used, in clone() */
enum_field_types type() const { return MYSQL_TYPE_BLOB;}
@@ -3397,13 +3411,13 @@ public:
enum storage_type storage;
Field_geom(uchar *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint blob_pack_length,
enum geometry_type geom_type_arg, uint field_srid)
- :Field_blob(ptr_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
+ :Field_blob(ptr_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, share, blob_pack_length, &my_charset_bin)
{ geom_type= geom_type_arg; srid= field_srid; }
- Field_geom(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_geom(uint32 len_arg,bool maybe_null_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, enum geometry_type geom_type_arg)
:Field_blob(len_arg, maybe_null_arg, field_name_arg, &my_charset_bin)
{ geom_type= geom_type_arg; srid= 0; }
@@ -3454,7 +3468,7 @@ public:
TYPELIB *typelib;
Field_enum(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint packlength_arg,
TYPELIB *typelib_arg,
CHARSET_INFO *charset_arg)
@@ -3551,7 +3565,7 @@ class Field_set :public Field_enum {
public:
Field_set(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint32 packlength_arg,
TYPELIB *typelib_arg, CHARSET_INFO *charset_arg)
:Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
@@ -3600,7 +3614,7 @@ public:
uint bytes_in_rec;
Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
- enum utype unireg_check_arg, const char *field_name_arg);
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg);
enum_field_types type() const { return MYSQL_TYPE_BIT; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BIT; }
uint32 key_length() const { return (uint32) (field_length + 7) / 8; }
@@ -3736,7 +3750,7 @@ class Field_bit_as_char: public Field_bit {
public:
Field_bit_as_char(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg);
+ enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg);
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
uint size_of() const { return sizeof(*this); }
int store(const char *to, uint length, CHARSET_INFO *charset);
@@ -3747,8 +3761,7 @@ public:
};
-extern const LEX_STRING null_lex_str;
-
+extern const LEX_CSTRING null_clex_str;
Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root,
uchar *ptr, uint32 field_length,
@@ -3757,7 +3770,7 @@ Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root,
CHARSET_INFO *cs,
Field::geometry_type geom_type, uint srid,
Field::utype unireg_check,
- TYPELIB *interval, const char *field_name);
+ TYPELIB *interval, const LEX_CSTRING *field_name);
/*
Create field class for CREATE TABLE
@@ -3803,8 +3816,8 @@ class Column_definition: public Sql_alloc
}
}
public:
- const char *field_name;
- LEX_STRING comment; // Comment for field
+ LEX_CSTRING field_name;
+ LEX_CSTRING comment; // Comment for field
Item *on_update; // ON UPDATE NOW()
enum enum_field_types sql_type;
/*
@@ -3839,7 +3852,7 @@ public:
*check_constraint; // Check constraint
Column_definition():
- comment(null_lex_str),
+ comment(null_clex_str),
on_update(NULL), sql_type(MYSQL_TYPE_NULL), length(0), decimals(0),
flags(0), pack_length(0), key_length(0), unireg_check(Field::NONE),
interval(0), charset(&my_charset_bin),
@@ -3850,9 +3863,9 @@ public:
interval_list.empty();
}
- Column_definition(const char *name, enum_field_types type):
- field_name(name),
- comment(null_lex_str),
+ Column_definition(LEX_CSTRING *name, enum_field_types type):
+ field_name(*name),
+ comment(null_clex_str),
on_update(NULL), sql_type(type), length(0), decimals(0),
flags(0), pack_length(0), key_length(0), unireg_check(Field::NONE),
interval(0), charset(&my_charset_bin),
@@ -3926,7 +3939,7 @@ public:
Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root,
uchar *ptr, uchar *null_pos, uchar null_bit,
- const char *field_name_arg) const
+ const LEX_CSTRING *field_name_arg) const
{
return ::make_field(share, mem_root, ptr,
(uint32)length, null_pos, null_bit,
@@ -3935,7 +3948,7 @@ public:
field_name_arg);
}
Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root,
- const char *field_name_arg)
+ const LEX_CSTRING *field_name_arg)
{
return make_field(share, mem_root, (uchar *) 0, (uchar *) "", 0,
field_name_arg);
@@ -3964,7 +3977,7 @@ public:
class Row_definition_list: public List<class Spvar_definition>
{
public:
- inline bool eq_name(const Spvar_definition *def, const char *name) const;
+ inline bool eq_name(const Spvar_definition *def, const LEX_CSTRING *name) const;
/**
Find a ROW field by name.
@param [IN] name - the name
@@ -3972,7 +3985,7 @@ public:
@retval NULL - the ROW field was not found
@retval !NULL - the pointer to the found ROW field
*/
- Spvar_definition *find_row_field_by_name(const char *name, uint *offset) const
+ Spvar_definition *find_row_field_by_name(const LEX_CSTRING *name, uint *offset) const
{
// Cast-off the "const" qualifier
List_iterator<Spvar_definition> it(*((List<Spvar_definition>*)this));
@@ -4061,7 +4074,7 @@ public:
Find a ROW field by name.
See Row_field_list::find_row_field_by_name() for details.
*/
- Spvar_definition *find_row_field_by_name(const char *name, uint *offset) const
+ Spvar_definition *find_row_field_by_name(const LEX_CSTRING *name, uint *offset) const
{
DBUG_ASSERT(m_row_field_definitions);
return m_row_field_definitions->find_row_field_by_name(name, offset);
@@ -4089,17 +4102,17 @@ public:
inline bool Row_definition_list::eq_name(const Spvar_definition *def,
- const char *name) const
+ const LEX_CSTRING *name) const
{
- return my_strcasecmp(system_charset_info, def->field_name, name) == 0;
+ return def->field_name.length == name->length && my_strcasecmp(system_charset_info, def->field_name.str, name->str) == 0;
}
class Create_field :public Column_definition
{
public:
- const char *change; // If done with alter table
- const char *after; // Put column after this one
+ LEX_CSTRING change; // If done with alter table
+ LEX_CSTRING after; // Put column after this one
Field *field; // For alter table
TYPELIB *save_interval; // Temporary copy for the above
// Used only for UCS2 intervals
@@ -4111,16 +4124,20 @@ public:
bool create_if_not_exists; // Used in ALTER TABLE IF NOT EXISTS
Create_field():
- Column_definition(), change(0), after(0),
+ Column_definition(),
field(0), option_struct(NULL),
create_if_not_exists(false)
- { }
+ {
+ change= after= null_clex_str;
+ }
Create_field(THD *thd, Field *old_field, Field *orig_field):
Column_definition(thd, old_field, orig_field),
- change(old_field->field_name), after(0),
+ change(old_field->field_name),
field(old_field), option_struct(old_field->option_struct),
create_if_not_exists(false)
- { }
+ {
+ after= null_clex_str;
+ }
/* Used to make a clone of this object for ALTER/CREATE TABLE */
Create_field *clone(MEM_ROOT *mem_root) const;
};
@@ -4134,7 +4151,7 @@ class Send_field :public Sql_alloc {
public:
const char *db_name;
const char *table_name,*org_table_name;
- const char *col_name,*org_col_name;
+ LEX_CSTRING col_name, org_col_name;
ulong length;
uint flags, decimals;
enum_field_types type;
@@ -4188,7 +4205,7 @@ uint32 calc_pack_length(enum_field_types type,uint32 length);
int set_field_to_null(Field *field);
int set_field_to_null_with_conversions(Field *field, bool no_conversions);
int convert_null_to_field_value_or_error(Field *field);
-bool check_expression(Virtual_column_info *vcol, const char *name,
+bool check_expression(Virtual_column_info *vcol, LEX_CSTRING *name,
enum_vcol_info_type type);
/*
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 85101fd5f0a..a744af76626 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -125,7 +125,7 @@ static int set_bad_null_error(Field *field, int err)
return 0;
case CHECK_FIELD_ERROR_FOR_NULL:
if (!field->table->in_use->no_errors)
- my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name);
+ my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name.str);
return -1;
}
DBUG_ASSERT(0); // impossible
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 58092a15ee9..007216b392f 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -569,7 +569,8 @@ const char* dbug_print_table_row(TABLE *table)
else
output.append(",");
- output.append((*pfield)->field_name? (*pfield)->field_name: "NULL");
+ output.append((*pfield)->field_name.str ?
+ (*pfield)->field_name.str: "NULL");
}
output.append(")=(");
@@ -620,7 +621,8 @@ static void dbug_print_record(TABLE *table, bool print_rowid)
fprintf(DBUG_FILE, "record (");
for (pfield= table->field; *pfield ; pfield++)
- fprintf(DBUG_FILE, "%s%s", (*pfield)->field_name, (pfield[1])? ", ":"");
+ fprintf(DBUG_FILE, "%s%s", (*pfield)->field_name.str,
+ (pfield[1])? ", ":"");
fprintf(DBUG_FILE, ") = ");
fprintf(DBUG_FILE, "(");
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 79b49eb1edb..6ce17090efd 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -1512,8 +1512,8 @@ int ha_partition::prepare_new_partition(TABLE *tbl,
That file name may be different from part_name, which will be
attached in append_file_to_dir().
*/
- truncate_partition_filename(p_elem->data_file_name);
- truncate_partition_filename(p_elem->index_file_name);
+ truncate_partition_filename((char*) p_elem->data_file_name);
+ truncate_partition_filename((char*) p_elem->index_file_name);
if ((error= set_up_table_before_create(tbl, part_name, create_info, p_elem)))
goto error_create;
@@ -2086,7 +2086,7 @@ void ha_partition::update_create_info(HA_CREATE_INFO *create_info)
my_bool from_alter = (create_info->data_file_name == (const char*) -1);
create_info->data_file_name= create_info->index_file_name = NULL;
- create_info->connect_string= null_lex_str;
+ create_info->connect_string= null_clex_str;
/*
We do not need to update the individual partition DATA DIRECTORY settings
@@ -2957,27 +2957,29 @@ bool ha_partition::read_par_file(const char *name)
m_file_buffer= file_buffer; // Will be freed in clear_handler_file()
m_name_buffer_ptr= (char*) (tot_name_len_offset + PAR_WORD_SIZE);
- if (!(m_connect_string= (LEX_STRING*)
- alloc_root(&m_mem_root, m_tot_parts * sizeof(LEX_STRING))))
+ if (!(m_connect_string= (LEX_CSTRING*)
+ alloc_root(&m_mem_root, m_tot_parts * sizeof(LEX_CSTRING))))
goto err2;
- bzero(m_connect_string, m_tot_parts * sizeof(LEX_STRING));
+ bzero(m_connect_string, m_tot_parts * sizeof(LEX_CSTRING));
/* Read connection arguments (for federated X engine) */
for (i= 0; i < m_tot_parts; i++)
{
- LEX_STRING connect_string;
+ LEX_CSTRING connect_string;
uchar buffer[4];
+ char *tmp;
if (my_read(file, buffer, 4, MYF(MY_NABP)))
{
/* No extra options; Probably not a federatedx engine */
break;
}
connect_string.length= uint4korr(buffer);
- connect_string.str= (char*) alloc_root(&m_mem_root, connect_string.length+1);
+ connect_string.str= tmp= (char*) alloc_root(&m_mem_root,
+ connect_string.length+1);
if (my_read(file, (uchar*) connect_string.str, connect_string.length,
MYF(MY_NABP)))
break;
- connect_string.str[connect_string.length]= 0;
+ tmp[connect_string.length]= 0;
m_connect_string[i]= connect_string;
}
@@ -7951,7 +7953,7 @@ void ha_partition::append_row_to_str(String &str)
{
Field *field= key_part->field;
str.append(" ");
- str.append(field->field_name);
+ str.append(&field->field_name);
str.append(":");
field_unpack(&str, field, rec, 0, false);
}
@@ -7971,7 +7973,7 @@ void ha_partition::append_row_to_str(String &str)
{
Field *field= *field_ptr;
str.append(" ");
- str.append(field->field_name);
+ str.append(&field->field_name);
str.append(":");
field_unpack(&str, field, rec, 0, false);
}
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index 46fca544279..f403d123e3a 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -144,7 +144,7 @@ private:
handler **m_new_file; // Array of references to new handlers
handler **m_reorged_file; // Reorganised partitions
handler **m_added_file; // Added parts kept for errors
- LEX_STRING *m_connect_string;
+ LEX_CSTRING *m_connect_string;
partition_info *m_part_info; // local reference to partition
Field **m_part_field_array; // Part field array locally to save acc
uchar *m_ordered_rec_buffer; // Row and key buffer for ord. idx scan
@@ -429,7 +429,8 @@ public:
virtual THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to,
enum thr_lock_type lock_type);
virtual int external_lock(THD * thd, int lock_type);
- LEX_STRING *engine_name() { return hton_name(table->part_info->default_engine_type); }
+ LEX_CSTRING *engine_name()
+ { return hton_name(table->part_info->default_engine_type); }
/*
When table is locked a statement is started by calling start_stmt
instead of external_lock
diff --git a/sql/ha_sequence.cc b/sql/ha_sequence.cc
index 70d16516241..25a1a6e71c4 100644
--- a/sql/ha_sequence.cc
+++ b/sql/ha_sequence.cc
@@ -304,8 +304,8 @@ int ha_sequence::external_lock(THD *thd, int lock_type)
void ha_sequence::print_error(int error, myf errflag)
{
- char *sequence_db= table_share->db.str;
- char *sequence_name= table_share->table_name.str;
+ const char *sequence_db= table_share->db.str;
+ const char *sequence_name= table_share->table_name.str;
DBUG_ENTER("ha_sequence::print_error");
switch (error) {
@@ -321,8 +321,7 @@ void ha_sequence::print_error(int error, myf errflag)
DBUG_VOID_RETURN;
}
case HA_ERR_WRONG_COMMAND:
- my_error(ER_ILLEGAL_HA, MYF(0), "SEQUENCE", table_share->db.str,
- table_share->table_name.str);
+ my_error(ER_ILLEGAL_HA, MYF(0), "SEQUENCE", sequence_db, sequence_name);
DBUG_VOID_RETURN;
}
file->print_error(error, errflag);
diff --git a/sql/ha_sequence.h b/sql/ha_sequence.h
index ff8e4263692..3aacd62c5cb 100644
--- a/sql/ha_sequence.h
+++ b/sql/ha_sequence.h
@@ -82,7 +82,7 @@ public:
{ return HA_CACHE_TBL_NOCACHE; }
void print_error(int error, myf errflag);
int info(uint);
- LEX_STRING *engine_name() { return hton_name(file->ht); }
+ LEX_CSTRING *engine_name() { return hton_name(file->ht); }
int external_lock(THD *thd, int lock_type);
/* Functions that are directly mapped to the underlying handler */
diff --git a/sql/handler.cc b/sql/handler.cc
index fb4384a8bc5..a5832be30e1 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -76,12 +76,12 @@ ulong total_ha_2pc= 0;
/* size of savepoint storage area (see ha_init) */
ulong savepoint_alloc_size= 0;
-static const LEX_STRING sys_table_aliases[]=
+static const LEX_CSTRING sys_table_aliases[]=
{
- { C_STRING_WITH_LEN("INNOBASE") }, { C_STRING_WITH_LEN("INNODB") },
- { C_STRING_WITH_LEN("HEAP") }, { C_STRING_WITH_LEN("MEMORY") },
- { C_STRING_WITH_LEN("MERGE") }, { C_STRING_WITH_LEN("MRG_MYISAM") },
- { C_STRING_WITH_LEN("Maria") }, { C_STRING_WITH_LEN("Aria") },
+ { STRING_WITH_LEN("INNOBASE") }, { STRING_WITH_LEN("INNODB") },
+ { STRING_WITH_LEN("HEAP") }, { STRING_WITH_LEN("MEMORY") },
+ { STRING_WITH_LEN("MERGE") }, { STRING_WITH_LEN("MRG_MYISAM") },
+ { STRING_WITH_LEN("Maria") }, { STRING_WITH_LEN("Aria") },
{NullS, 0}
};
@@ -160,9 +160,10 @@ handlerton *ha_default_tmp_handlerton(THD *thd)
RETURN
pointer to storage engine plugin handle
*/
-plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name, bool tmp_table)
+plugin_ref ha_resolve_by_name(THD *thd, const LEX_CSTRING *name,
+ bool tmp_table)
{
- const LEX_STRING *table_alias;
+ const LEX_CSTRING *table_alias;
plugin_ref plugin;
redo:
@@ -405,7 +406,7 @@ static int full_discover_for_existence(handlerton *, const char *, const char *)
static int ext_based_existence(handlerton *, const char *, const char *)
{ return 0; }
-static int hton_ext_based_table_discovery(handlerton *hton, LEX_STRING *db,
+static int hton_ext_based_table_discovery(handlerton *hton, LEX_CSTRING *db,
MY_DIR *dir, handlerton::discovered_list *result)
{
/*
@@ -2429,7 +2430,7 @@ err:
return NULL;
}
-LEX_STRING *handler::engine_name()
+LEX_CSTRING *handler::engine_name()
{
return hton_name(ht);
}
@@ -3601,7 +3602,7 @@ void handler::print_error(int error, myf errflag)
break;
case HA_ERR_AUTOINC_ERANGE:
textno= error;
- my_error(textno, errflag, table->next_number_field->field_name,
+ my_error(textno, errflag, table->next_number_field->field_name.str,
table->in_use->get_stmt_da()->current_row_for_warning());
DBUG_VOID_RETURN;
break;
@@ -5080,11 +5081,12 @@ bool ha_table_exists(THD *thd, const char *db, const char *table_name,
if (hton)
{
char engine_buf[NAME_CHAR_LEN + 1];
- LEX_STRING engine= { engine_buf, 0 };
+ LEX_CSTRING engine= { engine_buf, 0 };
if (dd_frm_type(thd, path, &engine, is_sequence) != TABLE_TYPE_VIEW)
{
- plugin_ref p= plugin_lock_by_name(thd, &engine, MYSQL_STORAGE_ENGINE_PLUGIN);
+ plugin_ref p= plugin_lock_by_name(thd, &engine,
+ MYSQL_STORAGE_ENGINE_PLUGIN);
*hton= p ? plugin_hton(p) : NULL;
if (*hton)
// verify that the table really exists
@@ -5146,7 +5148,7 @@ static int cmp_file_names(const void *a, const void *b)
return my_strnncoll(cs, (uchar*)aa, strlen(aa), (uchar*)bb, strlen(bb));
}
-static int cmp_table_names(LEX_STRING * const *a, LEX_STRING * const *b)
+static int cmp_table_names(LEX_CSTRING * const *a, LEX_CSTRING * const *b)
{
return my_strnncoll(&my_charset_bin, (uchar*)((*a)->str), (*a)->length,
(uchar*)((*b)->str), (*b)->length);
@@ -5155,8 +5157,8 @@ static int cmp_table_names(LEX_STRING * const *a, LEX_STRING * const *b)
}
Discovered_table_list::Discovered_table_list(THD *thd_arg,
- Dynamic_array<LEX_STRING*> *tables_arg,
- const LEX_STRING *wild_arg) :
+ Dynamic_array<LEX_CSTRING*> *tables_arg,
+ const LEX_CSTRING *wild_arg) :
thd(thd_arg), with_temps(false), tables(tables_arg)
{
if (wild_arg->str && wild_arg->str[0])
@@ -5180,7 +5182,7 @@ bool Discovered_table_list::add_table(const char *tname, size_t tlen)
wild_prefix, wild_one, wild_many))
return 0;
- LEX_STRING *name= thd->make_lex_string(tname, tlen);
+ LEX_CSTRING *name= thd->make_clex_string(tname, tlen);
if (!name || tables->append(name))
return 1;
return 0;
@@ -5206,11 +5208,11 @@ void Discovered_table_list::sort()
void Discovered_table_list::remove_duplicates()
{
- LEX_STRING **src= tables->front();
- LEX_STRING **dst= src;
+ LEX_CSTRING **src= tables->front();
+ LEX_CSTRING **dst= src;
while (++dst <= tables->back())
{
- LEX_STRING *s= *src, *d= *dst;
+ LEX_CSTRING *s= *src, *d= *dst;
DBUG_ASSERT(strncmp(s->str, d->str, MY_MIN(s->length, d->length)) <= 0);
if ((s->length != d->length || strncmp(s->str, d->str, d->length)))
{
@@ -5224,7 +5226,7 @@ void Discovered_table_list::remove_duplicates()
struct st_discover_names_args
{
- LEX_STRING *db;
+ LEX_CSTRING *db;
MY_DIR *dirp;
Discovered_table_list *result;
uint possible_duplicates;
@@ -5269,7 +5271,7 @@ static my_bool discover_names(THD *thd, plugin_ref plugin,
for DROP DATABASE (as it needs to know and delete non-table files).
*/
-int ha_discover_table_names(THD *thd, LEX_STRING *db, MY_DIR *dirp,
+int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp,
Discovered_table_list *result, bool reusable)
{
int error;
@@ -5619,7 +5621,7 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
{
if (db_type->state != SHOW_OPTION_YES)
{
- const LEX_STRING *name= hton_name(db_type);
+ const LEX_CSTRING *name= hton_name(db_type);
result= stat_print(thd, name->str, name->length,
"", 0, "DISABLED", 8) ? 1 : 0;
}
@@ -6497,7 +6499,7 @@ int del_global_index_stats_for_table(THD *thd, uchar* cache_key, uint cache_key_
/* Remove a table from global table statistics */
-int del_global_table_stat(THD *thd, LEX_STRING *db, LEX_STRING *table)
+int del_global_table_stat(THD *thd, LEX_CSTRING *db, LEX_CSTRING *table)
{
TABLE_STATS *table_stats;
int res = 0;
diff --git a/sql/handler.h b/sql/handler.h
index f85b7c26284..b379f4e8b4d 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1341,7 +1341,7 @@ struct handlerton
Returns 0 on success and 1 on error.
*/
- int (*discover_table_names)(handlerton *hton, LEX_STRING *db, MY_DIR *dir,
+ int (*discover_table_names)(handlerton *hton, LEX_CSTRING *db, MY_DIR *dir,
discovered_list *result);
/*
@@ -1387,7 +1387,7 @@ struct handlerton
};
-static inline LEX_STRING *hton_name(const handlerton *hton)
+static inline LEX_CSTRING *hton_name(const handlerton *hton)
{
return &(hton2plugin[hton->slot]->name);
}
@@ -1670,9 +1670,9 @@ struct Table_scope_and_contents_source_st
{
CHARSET_INFO *table_charset;
LEX_CUSTRING tabledef_version;
- LEX_STRING connect_string;
+ LEX_CSTRING connect_string;
+ LEX_CSTRING comment;
const char *password, *tablespace;
- LEX_STRING comment;
const char *data_file_name, *index_file_name;
const char *alias;
ulonglong max_rows,min_rows;
@@ -2167,8 +2167,8 @@ typedef struct st_key_create_information
{
enum ha_key_alg algorithm;
ulong block_size;
- LEX_STRING parser_name;
- LEX_STRING comment;
+ LEX_CSTRING parser_name;
+ LEX_CSTRING comment;
/**
A flag to determine if we will check for duplicate indexes.
This typically means that the key information was specified
@@ -3523,7 +3523,7 @@ public:
cached
*/
- virtual my_bool register_query_cache_table(THD *thd, char *table_key,
+ virtual my_bool register_query_cache_table(THD *thd, const char *table_key,
uint key_length,
qc_engine_callback
*engine_callback,
@@ -3952,7 +3952,7 @@ public:
return 0;
}
- virtual LEX_STRING *engine_name();
+ virtual LEX_CSTRING *engine_name();
TABLE* get_table() { return table; }
TABLE_SHARE* get_table_share() { return table_share; }
@@ -4256,7 +4256,7 @@ extern const char *myisam_stats_method_names[];
extern ulong total_ha, total_ha_2pc;
/* lookups */
-plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name, bool tmp_table);
+plugin_ref ha_resolve_by_name(THD *thd, const LEX_CSTRING *name, bool tmp_table);
plugin_ref ha_lock_engine(THD *thd, const handlerton *hton);
handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
@@ -4324,11 +4324,11 @@ class Discovered_table_list: public handlerton::discovered_list
const char *wild, *wend;
bool with_temps; // whether to include temp tables in the result
public:
- Dynamic_array<LEX_STRING*> *tables;
+ Dynamic_array<LEX_CSTRING*> *tables;
- Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_STRING*> *tables_arg,
- const LEX_STRING *wild_arg);
- Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_STRING*> *tables_arg)
+ Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_CSTRING*> *tables_arg,
+ const LEX_CSTRING *wild_arg);
+ Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_CSTRING*> *tables_arg)
: thd(thd_arg), wild(NULL), with_temps(true), tables(tables_arg) {}
~Discovered_table_list() {}
@@ -4340,7 +4340,7 @@ public:
};
int ha_discover_table(THD *thd, TABLE_SHARE *share);
-int ha_discover_table_names(THD *thd, LEX_STRING *db, MY_DIR *dirp,
+int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp,
Discovered_table_list *result, bool reusable);
bool ha_table_exists(THD *thd, const char *db, const char *table_name,
handlerton **hton= 0, bool *is_sequence= 0);
@@ -4423,5 +4423,5 @@ void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag);
void print_keydup_error(TABLE *table, KEY *key, myf errflag);
int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info);
-int del_global_table_stat(THD *thd, LEX_STRING *db, LEX_STRING *table);
+int del_global_table_stat(THD *thd, LEX_CSTRING *db, LEX_CSTRING *table);
#endif /* HANDLER_INCLUDED */
diff --git a/sql/item.cc b/sql/item.cc
index f5ef8f30dff..d5d8e39ea54 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -45,6 +45,15 @@
const String my_null_string("NULL", 4, default_charset_info);
const String my_default_string("DEFAULT", 7, default_charset_info);
+/*
+ item_empty_name is used when calling Item::set_name with NULL
+ pointer, to make it easier to use the name in printf.
+ item_used_name is used when calling Item::set_name with a 0 length
+ string.
+*/
+const char *item_empty_name="";
+const char *item_used_name= "\0";
+
static int save_field_in_field(Field *, bool *, Field *, bool);
@@ -471,7 +480,7 @@ int Item::save_str_value_in_field(Field *field, String *result)
Item::Item(THD *thd):
- is_expensive_cache(-1), rsize(0), name(0), orig_name(0), name_length(0),
+ is_expensive_cache(-1), rsize(0), name(null_clex_str), orig_name(0),
fixed(0), is_autogenerated_name(TRUE)
{
DBUG_ASSERT(thd);
@@ -516,7 +525,6 @@ Item::Item(THD *thd, Item *item):
str_value(item->str_value),
name(item->name),
orig_name(item->orig_name),
- name_length(item->name_length),
marker(item->marker),
maybe_null(item->maybe_null),
in_rollup(item->in_rollup),
@@ -577,11 +585,12 @@ void Item::print_item_w_name(String *str, enum_query_type query_type)
{
print(str, query_type);
- if (name)
+ if (name.str)
{
+ DBUG_ASSERT(name.length == strlen(name.str));
THD *thd= current_thd;
str->append(STRING_WITH_LEN(" AS "));
- append_identifier(thd, str, name, (uint) strlen(name));
+ append_identifier(thd, str, name.str, name.length);
}
}
@@ -620,7 +629,10 @@ void Item::cleanup()
marker= 0;
join_tab_idx= MAX_TABLES;
if (orig_name)
- name= orig_name;
+ {
+ name.str= orig_name;
+ name.length= strlen(orig_name);
+ }
DBUG_VOID_RETURN;
}
@@ -640,24 +652,6 @@ bool Item::cleanup_processor(void *arg)
/**
- rename item (used for views, cleanup() return original name).
-
- @param new_name new name of item;
-*/
-
-void Item::rename(char *new_name)
-{
- /*
- we can compare pointers to names here, because if name was not changed,
- pointer will be same
- */
- if (!orig_name && new_name != name)
- orig_name= name;
- name= new_name;
-}
-
-
-/**
Traverse item tree possibly transforming it (replacing items).
This function is designed to ease transformation of Item trees.
@@ -726,29 +720,31 @@ Item* Item::set_expr_cache(THD *thd)
Item_ident::Item_ident(THD *thd, Name_resolution_context *context_arg,
const char *db_name_arg,const char *table_name_arg,
- const char *field_name_arg)
+ const LEX_CSTRING *field_name_arg)
:Item_result_field(thd), orig_db_name(db_name_arg),
orig_table_name(table_name_arg),
- orig_field_name(field_name_arg), context(context_arg),
+ orig_field_name(*field_name_arg), context(context_arg),
db_name(db_name_arg), table_name(table_name_arg),
- field_name(field_name_arg),
+ field_name(*field_name_arg),
alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
cached_table(0), depended_from(0), can_be_depended(TRUE)
{
- name = (char*) field_name_arg;
+ name= *field_name_arg;
}
-Item_ident::Item_ident(THD *thd, TABLE_LIST *view_arg, const char *field_name_arg)
+Item_ident::Item_ident(THD *thd, TABLE_LIST *view_arg,
+ const LEX_CSTRING *field_name_arg)
:Item_result_field(thd), orig_db_name(NullS),
orig_table_name(view_arg->table_name),
- orig_field_name(field_name_arg), context(&view_arg->view->select_lex.context),
+ orig_field_name(*field_name_arg),
+ context(&view_arg->view->select_lex.context),
db_name(NullS), table_name(view_arg->alias),
- field_name(field_name_arg),
+ field_name(*field_name_arg),
alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
cached_table(NULL), depended_from(NULL), can_be_depended(TRUE)
{
- name = (char*) field_name_arg;
+ name= *field_name_arg;
}
@@ -839,7 +835,8 @@ bool Item_ident::collect_outer_ref_processor(void *param)
bool Item_field::collect_item_field_processor(void *arg)
{
DBUG_ENTER("Item_field::collect_item_field_processor");
- DBUG_PRINT("info", ("%s", field->field_name ? field->field_name : "noname"));
+ DBUG_PRINT("info", ("%s", field->field_name.str ?
+ field->field_name.str : "noname"));
List<Item_field> *item_list= (List<Item_field>*) arg;
List_iterator<Item_field> item_list_it(*item_list);
Item_field *curr_item;
@@ -856,7 +853,8 @@ bool Item_field::collect_item_field_processor(void *arg)
bool Item_field::add_field_to_set_processor(void *arg)
{
DBUG_ENTER("Item_field::add_field_to_set_processor");
- DBUG_PRINT("info", ("%s", field->field_name ? field->field_name : "noname"));
+ DBUG_PRINT("info", ("%s", field->field_name.str ? field->field_name.str :
+ "noname"));
TABLE *table= (TABLE *) arg;
if (field->table == table)
bitmap_set_bit(&table->tmp_set, field->field_index);
@@ -978,7 +976,7 @@ bool Item_field::check_field_expression_processor(void *arg)
{
my_error(ER_EXPRESSION_REFERS_TO_UNINIT_FIELD,
MYF(0),
- org_field->field_name, field->field_name);
+ org_field->field_name.str, field->field_name.str);
return 1;
}
if ((field->default_value && field->default_value->flags) || field->vcol_info)
@@ -991,7 +989,7 @@ bool Item_field::check_field_expression_processor(void *arg)
{
my_error(ER_EXPRESSION_REFERS_TO_UNINIT_FIELD,
MYF(0),
- org_field->field_name, field->field_name);
+ org_field->field_name.str, field->field_name.str);
return 1;
}
}
@@ -1021,14 +1019,18 @@ bool Item::check_cols(uint c)
return 0;
}
-
void Item::set_name(THD *thd, const char *str, uint length, CHARSET_INFO *cs)
{
if (!length)
{
- /* Empty string, used by AS or internal function like last_insert_id() */
- name= (char*) str;
- name_length= 0;
+ /*
+ Null string are replaced by item_empty_name. This is used by AS or
+ internal function like last_insert_id() to detect if we need to
+ change the name later.
+ Used by sql_yacc.yy in select_alias handling
+ */
+ name.str= str ? item_used_name : item_empty_name;
+ name.length= 0;
return;
}
@@ -1070,13 +1072,13 @@ void Item::set_name(THD *thd, const char *str, uint length, CHARSET_INFO *cs)
if (!my_charset_same(cs, system_charset_info))
{
size_t res_length;
- name= sql_strmake_with_convert(thd, str, length, cs,
- MAX_ALIAS_NAME, system_charset_info,
- &res_length);
- name_length= res_length;
+ name.str= sql_strmake_with_convert(thd, str, length, cs,
+ MAX_ALIAS_NAME, system_charset_info,
+ &res_length);
+ name.length= res_length;
}
else
- name= thd->strmake(str, (name_length= MY_MIN(length,MAX_ALIAS_NAME)));
+ name.str= thd->strmake(str, (name.length= MY_MIN(length,MAX_ALIAS_NAME)));
}
@@ -1086,13 +1088,13 @@ void Item::set_name_no_truncate(THD *thd, const char *str, uint length,
if (!my_charset_same(cs, system_charset_info))
{
size_t res_length;
- name= sql_strmake_with_convert(thd, str, length, cs,
- UINT_MAX, system_charset_info,
- &res_length);
- name_length= res_length;
+ name.str= sql_strmake_with_convert(thd, str, length, cs,
+ UINT_MAX, system_charset_info,
+ &res_length);
+ name.length= res_length;
}
else
- name= thd->strmake(str, (name_length= length));
+ name.str= thd->strmake(str, (name.length= length));
}
@@ -1110,8 +1112,9 @@ bool Item::eq(const Item *item, bool binary_cmp) const
for all basic constants we have special checks, and Item_param's
type() can be only among basic constant types.
*/
- return type() == item->type() && name && item->name &&
- !my_strcasecmp(system_charset_info,name,item->name);
+ return type() == item->type() && name.str && item->name.str &&
+ name.length == item->name.length &&
+ !my_strcasecmp(system_charset_info, name.str, item->name.str);
}
@@ -1453,15 +1456,12 @@ bool mark_unsupported_function(const char *w1, const char *w2,
Item_sp_variable methods
*****************************************************************************/
-Item_sp_variable::Item_sp_variable(THD *thd, char *sp_var_name_str,
- uint sp_var_name_length):
- Item(thd), m_thd(0)
+Item_sp_variable::Item_sp_variable(THD *thd, const LEX_CSTRING *sp_var_name)
+ :Item(thd), m_thd(0), m_name(*sp_var_name)
#ifndef DBUG_OFF
, m_sp(0)
#endif
{
- m_name.str= sp_var_name_str;
- m_name.length= sp_var_name_length;
}
@@ -1552,16 +1552,26 @@ bool Item_sp_variable::is_null()
return this_item()->is_null();
}
+void Item_sp_variable::make_field(THD *thd, Send_field *field)
+{
+ Item *it= this_item();
+
+ it->make_field(thd, field);
+ if (name.str)
+ field->col_name= name;
+ else
+ field->col_name= m_name;
+}
/*****************************************************************************
Item_splocal methods
*****************************************************************************/
-Item_splocal::Item_splocal(THD *thd, const LEX_STRING &sp_var_name,
+Item_splocal::Item_splocal(THD *thd, const LEX_CSTRING *sp_var_name,
uint sp_var_idx,
enum_field_types sp_var_type,
uint pos_in_q, uint len_in_q):
- Item_sp_variable(thd, sp_var_name.str, sp_var_name.length),
+ Item_sp_variable(thd, sp_var_name),
Rewritable_query_parameter(pos_in_q, len_in_q),
m_var_idx(sp_var_idx)
{
@@ -1793,8 +1803,10 @@ bool Item_splocal_row_field_by_name::set_value(THD *thd, sp_rcontext *ctx, Item
Item_case_expr methods
*****************************************************************************/
+LEX_CSTRING str_case_expr= { STRING_WITH_LEN("case_expr") };
+
Item_case_expr::Item_case_expr(THD *thd, uint case_expr_id):
- Item_sp_variable(thd, C_STRING_WITH_LEN("case_expr")),
+ Item_sp_variable(thd, &str_case_expr),
m_case_expr_id(case_expr_id)
{
}
@@ -1974,7 +1986,7 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref)
}
if (is_autogenerated_name)
{
- set_name(thd, item_name->ptr(), (uint) item_name->length(),
+ set_name(thd, item_name->c_ptr(), (uint) item_name->length(),
system_charset_info);
}
collation.set(value_item->collation.collation, DERIVATION_IMPLICIT);
@@ -2005,7 +2017,7 @@ class Item_aggregate_ref : public Item_ref
public:
Item_aggregate_ref(THD *thd, Name_resolution_context *context_arg,
Item **item, const char *table_name_arg,
- const char *field_name_arg):
+ const LEX_CSTRING *field_name_arg):
Item_ref(thd, context_arg, item, table_name_arg, field_name_arg) {}
virtual inline void print (String *str, enum_query_type query_type)
@@ -2119,14 +2131,14 @@ void Item::split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array,
already a reference.
*/
Item *real_itm= real_item();
-
ref_pointer_array[el]= real_itm;
if (type() == WINDOW_FUNC_ITEM)
{
if (!(item_ref= (new (thd->mem_root)
Item_direct_ref(thd,
- &thd->lex->current_select->context,
- &ref_pointer_array[el], 0, name))))
+ &thd->lex->current_select->context,
+ &ref_pointer_array[el], 0,
+ &name))))
return; // fatal_error is set
}
else if (type() == FUNC_ITEM &&
@@ -2137,7 +2149,8 @@ void Item::split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array,
if (!(item_ref= (new (thd->mem_root)
Item_aggregate_ref(thd,
&thd->lex->current_select->context,
- &ref_pointer_array[el], 0, name))))
+ &ref_pointer_array[el], 0,
+ &name))))
return; // fatal_error is set
}
if (type() == SUM_FUNC_ITEM)
@@ -2561,7 +2574,7 @@ void Item_ident_for_show::make_field(THD *thd, Send_field *tmp_field)
/**********************************************/
Item_field::Item_field(THD *thd, Field *f)
- :Item_ident(thd, 0, NullS, *f->table_name, f->field_name),
+ :Item_ident(thd, 0, NullS, *f->table_name, &f->field_name),
item_equal(0),
have_privileges(0), any_privileges(0)
{
@@ -2570,7 +2583,8 @@ Item_field::Item_field(THD *thd, Field *f)
field_name and table_name should not point to garbage
if this item is to be reused
*/
- orig_table_name= orig_field_name= "";
+ orig_table_name= "";
+ orig_field_name= null_clex_str;
with_field= 1;
}
@@ -2584,7 +2598,8 @@ Item_field::Item_field(THD *thd, Field *f)
Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
Field *f)
- :Item_ident(thd, context_arg, f->table->s->db.str, *f->table_name, f->field_name),
+ :Item_ident(thd, context_arg, f->table->s->db.str, *f->table_name,
+ &f->field_name),
item_equal(0),
have_privileges(0), any_privileges(0)
{
@@ -2610,14 +2625,15 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
orig_db_name= thd->strdup(db_name);
if (table_name)
orig_table_name= thd->strdup(table_name);
- if (field_name)
- orig_field_name= thd->strdup(field_name);
+ if (field_name.str)
+ thd->make_lex_string(&orig_field_name, field_name.str,
+ field_name.length);
/*
We don't restore 'name' in cleanup because it's not changed
during execution. Still we need it to point to persistent
memory if this item is to be reused.
*/
- name= (char*) orig_field_name;
+ name= orig_field_name;
}
set_field(f);
with_field= 1;
@@ -2626,7 +2642,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
const char *db_arg,const char *table_name_arg,
- const char *field_name_arg)
+ const LEX_CSTRING *field_name_arg)
:Item_ident(thd, context_arg, db_arg, table_name_arg, field_name_arg),
field(0), item_equal(0),
have_privileges(0), any_privileges(0)
@@ -2736,7 +2752,7 @@ void Item_field::reset_field(Field *f)
{
set_field(f);
/* 'name' is pointing at field->field_name of old field */
- name= (char*) f->field_name;
+ name= f->field_name;
}
@@ -2775,15 +2791,15 @@ bool Item_field::switch_to_nullable_fields_processor(void *arg)
const char *Item_ident::full_name() const
{
char *tmp;
- if (!table_name || !field_name)
- return field_name ? field_name : name ? name : "tmp_field";
+ if (!table_name || !field_name.str)
+ return field_name.str ? field_name.str : name.str ? name.str : "tmp_field";
if (db_name && db_name[0])
{
THD *thd= current_thd;
tmp=(char*) thd->alloc((uint) strlen(db_name)+(uint) strlen(table_name)+
- (uint) strlen(field_name)+3);
- strxmov(tmp,db_name,".",table_name,".",field_name,NullS);
+ (uint) field_name.length+3);
+ strxmov(tmp,db_name,".",table_name,".",field_name.str,NullS);
}
else
{
@@ -2791,11 +2807,11 @@ const char *Item_ident::full_name() const
{
THD *thd= current_thd;
tmp= (char*) thd->alloc((uint) strlen(table_name) +
- (uint) strlen(field_name) + 2);
- strxmov(tmp, table_name, ".", field_name, NullS);
+ field_name.length + 2);
+ strxmov(tmp, table_name, ".", field_name.str, NullS);
}
else
- tmp= (char*) field_name;
+ return field_name.str;
}
return tmp;
}
@@ -2833,7 +2849,7 @@ void Item_ident::print(String *str, enum_query_type query_type)
use_table_name= false;
}
- if (!field_name || !field_name[0])
+ if (!field_name.str || !field_name.str[0])
{
append_identifier(thd, str, STRING_WITH_LEN("tmp_field"));
return;
@@ -2867,7 +2883,7 @@ void Item_ident::print(String *str, enum_query_type query_type)
append_identifier(thd, str, t_name, (uint) strlen(t_name));
str->append('.');
}
- append_identifier(thd, str, field_name, (uint) strlen(field_name));
+ append_identifier(thd, str, field_name.str, field_name.length);
}
/* ARGSUSED */
@@ -2998,8 +3014,8 @@ bool Item_field::eq(const Item *item, bool binary_cmp) const
(In cases where we would choose wrong we would have to generate a
ER_NON_UNIQ_ERROR).
*/
- return (!my_strcasecmp(system_charset_info, item_field->name,
- field_name) &&
+ return (!my_strcasecmp(system_charset_info, item_field->name.str,
+ field_name.str) &&
(!item_field->table_name || !table_name ||
(!my_strcasecmp(table_alias_charset, item_field->table_name,
table_name) &&
@@ -3126,7 +3142,12 @@ Item_int::Item_int(THD *thd, const char *str_arg, uint length):
int error;
value= my_strtoll10(str_arg, &end_ptr, &error);
max_length= (uint) (end_ptr - str_arg);
- name= (char*) str_arg;
+ name.str= str_arg;
+ /*
+ We can't trust max_length as in show_routine_code we are using "Pos" as
+ the field name.
+ */
+ name.length= !str_arg[max_length] ? max_length : strlen(str_arg);
fixed= 1;
}
@@ -3156,7 +3177,7 @@ void Item_int::print(String *str, enum_query_type query_type)
Item *Item_bool::neg_transformer(THD *thd)
{
value= !value;
- name= 0;
+ name= null_clex_str;
return this;
}
@@ -3197,7 +3218,8 @@ Item_decimal::Item_decimal(THD *thd, const char *str_arg, uint length,
Item_num(thd)
{
str2my_decimal(E_DEC_FATAL_ERROR, str_arg, length, charset, &decimal_value);
- name= (char*) str_arg;
+ name.str= str_arg;
+ name.length= safe_strlen(str_arg);
decimals= (uint8) decimal_value.frac;
fixed= 1;
max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
@@ -3237,7 +3259,8 @@ Item_decimal::Item_decimal(THD *thd, const char *str, const my_decimal *val_arg,
Item_num(thd)
{
my_decimal2decimal(val_arg, &decimal_value);
- name= (char*) str;
+ name.str= str;
+ name.length= safe_strlen(str);
decimals= (uint8) decimal_par;
max_length= length;
fixed= 1;
@@ -3329,7 +3352,7 @@ void Item_decimal::set_decimal_value(my_decimal *value_par)
Item *Item_decimal::clone_item(THD *thd)
{
- return new (thd->mem_root) Item_decimal(thd, name, &decimal_value, decimals,
+ return new (thd->mem_root) Item_decimal(thd, name.str, &decimal_value, decimals,
max_length);
}
@@ -3354,7 +3377,7 @@ my_decimal *Item_float::val_decimal(my_decimal *decimal_value)
Item *Item_float::clone_item(THD *thd)
{
- return new (thd->mem_root) Item_float(thd, name, value, decimals,
+ return new (thd->mem_root) Item_float(thd, name.str, value, decimals,
max_length);
}
@@ -3465,7 +3488,7 @@ Item *Item_null::safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
Item *Item_null::clone_item(THD *thd)
{
- return new (thd->mem_root) Item_null(thd, name);
+ return new (thd->mem_root) Item_null(thd, name.str);
}
/*********************** Item_param related ******************************/
@@ -3484,7 +3507,7 @@ default_set_param_func(Item_param *param,
}
-Item_param::Item_param(THD *thd, char *name_arg,
+Item_param::Item_param(THD *thd, const LEX_CSTRING *name_arg,
uint pos_in_query_arg, uint len_in_query_arg):
Item_basic_value(thd),
Rewritable_query_parameter(pos_in_query_arg, len_in_query_arg),
@@ -3504,8 +3527,8 @@ Item_param::Item_param(THD *thd, char *name_arg,
*/
m_is_settable_routine_parameter(true)
{
- name= name_arg;
- /*
+ name= *name_arg;
+ /*
Since we can't say whenever this item can be NULL or cannot be NULL
before mysql_stmt_execute(), so we assuming that it can be NULL until
value is set.
@@ -4196,19 +4219,19 @@ Item_param::clone_item(THD *thd)
invalid_default_param();
// fall through
case NULL_VALUE:
- return new (mem_root) Item_null(thd, name);
+ return new (mem_root) Item_null(thd, name.str);
case INT_VALUE:
return (unsigned_flag ?
- new (mem_root) Item_uint(thd, name, value.integer, max_length) :
- new (mem_root) Item_int(thd, name, value.integer, max_length));
+ new (mem_root) Item_uint(thd, name.str, value.integer, max_length) :
+ new (mem_root) Item_int(thd, name.str, value.integer, max_length));
case REAL_VALUE:
- return new (mem_root) Item_float(thd, name, value.real, decimals,
+ return new (mem_root) Item_float(thd, name.str, value.real, decimals,
max_length);
case DECIMAL_VALUE:
return 0; // Should create Item_decimal. See MDEV-11361.
case STRING_VALUE:
case LONG_DATA_VALUE:
- return new (mem_root) Item_string(thd, name, str_value.c_ptr_quick(),
+ return new (mem_root) Item_string(thd, name.str, str_value.c_ptr_quick(),
str_value.length(), str_value.charset(),
collation.derivation,
collation.repertoire);
@@ -4841,7 +4864,7 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
ER_THD(thd,ER_WARN_FIELD_RESOLVED),
db_name, (db_name[0] ? "." : ""),
table_name, (table_name [0] ? "." : ""),
- resolved_item->field_name,
+ resolved_item->field_name.str,
current->select_number, last->select_number);
}
DBUG_RETURN(FALSE);
@@ -4931,7 +4954,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
{
const char *db_name;
const char *table_name;
- const char *field_name;
+ LEX_CSTRING *field_name;
ORDER *found_group= NULL;
int found_match_degree= 0;
char name_buff[SAFE_NAME_LEN+1];
@@ -4941,7 +4964,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
{
db_name= ((Item_ident*) find_item)->db_name;
table_name= ((Item_ident*) find_item)->table_name;
- field_name= ((Item_ident*) find_item)->field_name;
+ field_name= &((Item_ident*) find_item)->field_name;
}
else
return NULL;
@@ -4954,17 +4977,17 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
db_name= name_buff;
}
- DBUG_ASSERT(field_name != 0);
+ DBUG_ASSERT(field_name->str != 0);
for (ORDER *cur_group= group_list ; cur_group ; cur_group= cur_group->next)
{
int cur_match_degree= 0;
/* SELECT list element with explicit alias */
- if ((*(cur_group->item))->name &&
+ if ((*(cur_group->item))->name.str &&
!(*(cur_group->item))->is_autogenerated_name &&
!my_strcasecmp(system_charset_info,
- (*(cur_group->item))->name, field_name))
+ (*(cur_group->item))->name.str, field_name->str))
{
++cur_match_degree;
}
@@ -4975,12 +4998,12 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
Item_ident *cur_field= (Item_ident*) *cur_group->item;
const char *l_db_name= cur_field->db_name;
const char *l_table_name= cur_field->table_name;
- const char *l_field_name= cur_field->field_name;
+ LEX_CSTRING *l_field_name= &cur_field->field_name;
- DBUG_ASSERT(l_field_name != 0);
+ DBUG_ASSERT(l_field_name->str != 0);
if (!my_strcasecmp(system_charset_info,
- l_field_name, field_name))
+ l_field_name->str, field_name->str))
++cur_match_degree;
else
continue;
@@ -5116,7 +5139,7 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select)
the strict mode is enabled.
*/
my_error(ER_NON_GROUPING_FIELD_USED, MYF(0),
- ref->name, "HAVING");
+ ref->name.str, "HAVING");
return NULL;
}
if (select_ref != not_found_item || group_by_ref)
@@ -5127,7 +5150,7 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select)
if (!select->ref_pointer_array[counter])
{
my_error(ER_ILLEGAL_REFERENCE, MYF(0),
- ref->name, "forward reference in item list");
+ ref->name.str, "forward reference in item list");
return NULL;
}
DBUG_ASSERT((*select_ref)->fixed);
@@ -5454,15 +5477,15 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
*ref= NULL; // Don't call set_properties()
rf= (place == IN_HAVING ?
new (thd->mem_root)
- Item_ref(thd, context, ref, (char*) table_name,
- (char*) field_name, alias_name_used) :
+ Item_ref(thd, context, ref, table_name,
+ &field_name, alias_name_used) :
(!select->group_list.elements ?
new (thd->mem_root)
- Item_direct_ref(thd, context, ref, (char*) table_name,
- (char*) field_name, alias_name_used) :
+ Item_direct_ref(thd, context, ref, table_name,
+ &field_name, alias_name_used) :
new (thd->mem_root)
- Item_outer_ref(thd, context, ref, (char*) table_name,
- (char*) field_name, alias_name_used)));
+ Item_outer_ref(thd, context, ref, table_name,
+ &field_name, alias_name_used)));
*ref= save;
if (!rf)
return -1;
@@ -5506,9 +5529,10 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
if (last_checked_context->select_lex->having_fix_field)
{
Item_ref *rf;
- rf= new (thd->mem_root) Item_ref(thd, context, (*from_field)->table->s->db.str,
- (*from_field)->table->alias.c_ptr(),
- (char*) field_name);
+ rf= new (thd->mem_root) Item_ref(thd, context,
+ (*from_field)->table->s->db.str,
+ (*from_field)->table->alias.c_ptr(),
+ &field_name);
if (!rf)
return -1;
thd->change_item_tree(reference, rf);
@@ -5626,7 +5650,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
if (new_field == NULL)
{
/* The column to which we link isn't valid. */
- my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name,
+ my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name.str,
thd->where);
return(1);
}
@@ -5647,8 +5671,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
Item_field created by the parser with the new Item_ref.
*/
Item_ref *rf= new (thd->mem_root)
- Item_ref(thd, context, db_name, table_name,
- field_name);
+ Item_ref(thd, context, db_name, table_name, &field_name);
if (!rf)
return 1;
bool err= rf->fix_fields(thd, (Item **) &rf) || rf->check_cols(1);
@@ -5746,16 +5769,16 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (any_privileges)
{
- char *db, *tab;
+ const char *db, *tab;
db= field->table->s->db.str;
tab= field->table->s->table_name.str;
if (!(have_privileges= (get_column_grant(thd, &field->table->grant,
- db, tab, field_name) &
+ db, tab, field_name.str) &
VIEW_ANY_ACL)))
{
my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
"ANY", thd->security_ctx->priv_user,
- thd->security_ctx->host_or_ip, field_name, tab);
+ thd->security_ctx->host_or_ip, field_name.str, tab);
goto error;
}
}
@@ -6043,12 +6066,11 @@ Item *Item_field::replace_equal_field(THD *thd, uchar *arg)
void Item::init_make_field(Send_field *tmp_field,
enum enum_field_types field_type_arg)
{
- char *empty_name= (char*) "";
- tmp_field->db_name= empty_name;
- tmp_field->org_table_name= empty_name;
- tmp_field->org_col_name= empty_name;
- tmp_field->table_name= empty_name;
- tmp_field->col_name= name;
+ tmp_field->db_name= "";
+ tmp_field->org_table_name= "";
+ tmp_field->org_col_name= empty_clex_str;
+ tmp_field->table_name= "";
+ tmp_field->col_name= name;
tmp_field->flags= (maybe_null ? 0 : NOT_NULL_FLAG) |
(my_binary_compare(charset_for_protocol()) ?
BINARY_FLAG : 0);
@@ -6215,7 +6237,6 @@ Field *Item::make_string_field(TABLE *table)
{
Field *field;
MEM_ROOT *mem_root= table->in_use->mem_root;
-
DBUG_ASSERT(collation.collation);
/*
Note: the following check is repeated in
@@ -6223,17 +6244,17 @@ Field *Item::make_string_field(TABLE *table)
*/
if (too_big_for_varchar())
field= new (mem_root)
- Field_blob(max_length, maybe_null, name,
+ Field_blob(max_length, maybe_null, &name,
collation.collation, TRUE);
/* Item_type_holder holds the exact type, do not change it */
else if (max_length > 0 &&
(type() != Item::TYPE_HOLDER || field_type() != MYSQL_TYPE_STRING))
field= new (mem_root)
- Field_varstring(max_length, maybe_null, name, table->s,
+ Field_varstring(max_length, maybe_null, &name, table->s,
collation.collation);
else
field= new (mem_root)
- Field_string(max_length, maybe_null, name, collation.collation);
+ Field_string(max_length, maybe_null, &name, collation.collation);
if (field)
field->init(table);
return field;
@@ -6274,64 +6295,66 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table,
case MYSQL_TYPE_TINY:
field= new (mem_root)
Field_tiny((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, 0, unsigned_flag);
+ &name, 0, unsigned_flag);
break;
case MYSQL_TYPE_SHORT:
field= new (mem_root)
Field_short((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, 0, unsigned_flag);
+ &name, 0, unsigned_flag);
break;
case MYSQL_TYPE_LONG:
field= new (mem_root)
Field_long((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, 0, unsigned_flag);
+ &name, 0, unsigned_flag);
break;
#ifdef HAVE_LONG_LONG
case MYSQL_TYPE_LONGLONG:
field= new (mem_root)
Field_longlong((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, 0, unsigned_flag);
+ &name, 0, unsigned_flag);
break;
#endif
case MYSQL_TYPE_FLOAT:
field= new (mem_root)
Field_float((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, decimals, 0, unsigned_flag);
+ &name, decimals, 0, unsigned_flag);
break;
case MYSQL_TYPE_DOUBLE:
field= new (mem_root)
Field_double((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, decimals, 0, unsigned_flag);
+ &name, decimals, 0, unsigned_flag);
break;
case MYSQL_TYPE_INT24:
field= new (mem_root)
Field_medium((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, 0, unsigned_flag);
+ &name, 0, unsigned_flag);
break;
case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_DATE:
field= new (mem_root)
- Field_newdate(0, null_ptr, 0, Field::NONE, name);
+ Field_newdate(0, null_ptr, 0, Field::NONE, &name);
break;
case MYSQL_TYPE_TIME:
- field= new_Field_time(mem_root, 0, null_ptr, 0, Field::NONE, name,
+ field= new_Field_time(mem_root, 0, null_ptr, 0, Field::NONE, &name,
decimals);
break;
case MYSQL_TYPE_TIMESTAMP:
field= new_Field_timestamp(mem_root, 0, null_ptr, 0,
- Field::NONE, name, 0, decimals);
+ Field::NONE, &name, 0, decimals);
break;
case MYSQL_TYPE_DATETIME:
- field= new_Field_datetime(mem_root, 0, null_ptr, 0, Field::NONE, name,
- decimals);
+ field= new_Field_datetime(mem_root, 0, null_ptr, 0, Field::NONE,
+ &name, decimals);
break;
case MYSQL_TYPE_YEAR:
field= new (mem_root)
- Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name);
+ Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
+ &name);
break;
case MYSQL_TYPE_BIT:
field= new (mem_root)
- Field_bit_as_char(NULL, max_length, null_ptr, 0, Field::NONE, name);
+ Field_bit_as_char(NULL, max_length, null_ptr, 0, Field::NONE,
+ &name);
break;
default:
/* This case should never be chosen */
@@ -6342,7 +6365,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table,
if (fixed_length && !too_big_for_varchar())
{
field= new (mem_root)
- Field_string(max_length, maybe_null, name, collation.collation);
+ Field_string(max_length, maybe_null, &name, collation.collation);
break;
}
/* Fall through to make_string_field() */
@@ -6356,13 +6379,14 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table,
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
field= new (mem_root)
- Field_blob(max_length, maybe_null, name,
+ Field_blob(max_length, maybe_null, &name,
collation.collation, set_blob_packlength);
break; // Blob handled outside of case
#ifdef HAVE_SPATIAL
case MYSQL_TYPE_GEOMETRY:
field= new (mem_root)
- Field_geom(max_length, maybe_null, name, table->s, get_geometry_type());
+ Field_geom(max_length, maybe_null, &name, table->s,
+ get_geometry_type());
#endif /* HAVE_SPATIAL */
}
if (field)
@@ -6376,8 +6400,11 @@ void Item_field::make_field(THD *thd, Send_field *tmp_field)
{
field->make_field(tmp_field);
DBUG_ASSERT(tmp_field->table_name != 0);
- if (name)
- tmp_field->col_name=name; // Use user supplied name
+ if (name.str)
+ {
+ DBUG_ASSERT(name.length == strlen(name.str));
+ tmp_field->col_name= name; // Use user supplied name
+ }
if (table_name)
tmp_field->table_name= table_name;
if (db_name)
@@ -6602,7 +6629,7 @@ int Item_string::save_in_field(Field *field, bool no_conversions)
Item *Item_string::clone_item(THD *thd)
{
return new (thd->mem_root)
- Item_string(thd, name, str_value.ptr(),
+ Item_string(thd, name.str, str_value.ptr(),
str_value.length(), collation.collation);
}
@@ -6625,7 +6652,7 @@ int Item_int::save_in_field(Field *field, bool no_conversions)
Item *Item_int::clone_item(THD *thd)
{
- return new (thd->mem_root) Item_int(thd, name, value, max_length);
+ return new (thd->mem_root) Item_int(thd, name.str, value, max_length);
}
@@ -6661,9 +6688,9 @@ Item *Item_int_with_ref::clone_item(THD *thd)
*/
return (ref->unsigned_flag ?
new (thd->mem_root)
- Item_uint(thd, ref->name, ref->val_int(), ref->max_length) :
+ Item_uint(thd, ref->name.str, ref->val_int(), ref->max_length) :
new (thd->mem_root)
- Item_int(thd, ref->name, ref->val_int(), ref->max_length));
+ Item_int(thd, ref->name.str, ref->val_int(), ref->max_length));
}
@@ -6691,7 +6718,7 @@ Item *Item_int::neg(THD *thd)
else if (value < 0 && max_length)
max_length--;
value= -value;
- name= 0;
+ name= null_clex_str;
return this;
}
@@ -6699,7 +6726,7 @@ Item *Item_decimal::neg(THD *thd)
{
my_decimal_neg(&decimal_value);
unsigned_flag= 0;
- name= 0;
+ name= null_clex_str;
max_length= my_decimal_precision_to_length_no_truncation(
decimal_value.intg + decimals, decimals, unsigned_flag);
return this;
@@ -6712,7 +6739,8 @@ Item *Item_float::neg(THD *thd)
else if (value < 0 && max_length)
max_length--;
value= -value;
- name= presentation= 0 ;
+ presentation= 0;
+ name= null_clex_str;
return this;
}
@@ -6731,7 +6759,7 @@ Item *Item_uint::neg(THD *thd)
Item *Item_uint::clone_item(THD *thd)
{
- return new (thd->mem_root) Item_uint(thd, name, value, max_length);
+ return new (thd->mem_root) Item_uint(thd, name.str, value, max_length);
}
static uint nr_of_decimals(const char *str, const char *end)
@@ -6801,7 +6829,8 @@ Item_float::Item_float(THD *thd, const char *str_arg, uint length):
my_snprintf(tmp, sizeof(tmp), "%.*s", length, str_arg);
my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "double", tmp);
}
- presentation= name=(char*) str_arg;
+ presentation= name.str= str_arg;
+ name.length= strlen(str_arg);
decimals=(uint8) nr_of_decimals(str_arg, str_arg+length);
max_length=length;
fixed= 1;
@@ -7287,7 +7316,7 @@ Item *Item_field::update_value_transformer(THD *thd, uchar *select_arg)
all_fields->push_front((Item*)this, thd->mem_root);
ref= new (thd->mem_root)
Item_ref(thd, &select->context, &ref_pointer_array[el],
- table_name, field_name);
+ table_name, &field_name);
return ref;
}
return this;
@@ -7305,7 +7334,7 @@ Item *Item_field::derived_field_transformer_for_having(THD *thd, uchar *arg)
Item_ref *rf=
new (thd->mem_root) Item_ref(thd, &sl->context,
NullS, NullS,
- ((Item_field*) this)->field_name);
+ &((Item_field*) this)->field_name);
if (!rf)
return 0;
return rf;
@@ -7323,7 +7352,8 @@ Item *Item_field::derived_field_transformer_for_having(THD *thd, uchar *arg)
Item_ref *rf=
new (thd->mem_root) Item_ref(thd, &sl->context,
NullS, NullS,
- ((Item_field*) (item->real_item()))->field_name);
+ &((Item_field*) (item->real_item()))->
+ field_name);
if (!rf)
return 0;
return rf;
@@ -7422,15 +7452,15 @@ void Item_field::print(String *str, enum_query_type query_type)
bool Item_field_row::element_index_by_name(uint *idx,
- const LEX_STRING &name) const
+ const LEX_CSTRING &name) const
{
Field *field;
for (uint i= 0; (field= get_row_field(i)); i++)
{
// Use the same comparison style with sp_context::find_variable()
if (!my_strnncoll(system_charset_info,
- (const uchar *) field->field_name,
- strlen(field->field_name),
+ (const uchar *) field->field_name.str,
+ field->field_name.length,
(const uchar *) name.str, name.length))
{
*idx= i;
@@ -7453,7 +7483,7 @@ void Item_temptable_field::print(String *str, enum_query_type query_type)
Item_ref::Item_ref(THD *thd, Name_resolution_context *context_arg,
Item **item, const char *table_name_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
bool alias_name_used_arg):
Item_ident(thd, context_arg, NullS, table_name_arg, field_name_arg),
ref(item), reference_trough_name(0)
@@ -7498,7 +7528,8 @@ public:
};
Item_ref::Item_ref(THD *thd, TABLE_LIST *view_arg, Item **item,
- const char *field_name_arg, bool alias_name_used_arg):
+ const LEX_CSTRING *field_name_arg,
+ bool alias_name_used_arg):
Item_ident(thd, view_arg, field_name_arg),
ref(item), reference_trough_name(0)
{
@@ -7780,13 +7811,13 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
*/
if (!((*ref)->type() == REF_ITEM &&
((Item_ref *)(*ref))->ref_type() == OUTER_REF) &&
- (((*ref)->with_sum_func && name &&
+ (((*ref)->with_sum_func && name.str &&
!(current_sel->linkage != GLOBAL_OPTIONS_TYPE &&
current_sel->having_fix_field)) ||
!(*ref)->fixed))
{
my_error(ER_ILLEGAL_REFERENCE, MYF(0),
- name, ((*ref)->with_sum_func?
+ name.str, ((*ref)->with_sum_func?
"reference to group function":
"forward reference in item list"));
goto error;
@@ -7928,11 +7959,11 @@ void Item_ref::print(String *str, enum_query_type query_type)
if (ref)
{
if ((*ref)->type() != Item::CACHE_ITEM && ref_type() != VIEW_REF &&
- !table_name && name && alias_name_used)
+ !table_name && name.str && alias_name_used)
{
THD *thd= current_thd;
- append_identifier(thd, str, (*ref)->real_item()->name,
- strlen((*ref)->real_item()->name));
+ append_identifier(thd, str, (*ref)->real_item()->name.str,
+ (*ref)->real_item()->name.length);
}
else
(*ref)->print(str, query_type);
@@ -8129,13 +8160,13 @@ void Item_ref::make_field(THD *thd, Send_field *field)
{
(*ref)->make_field(thd, field);
/* Non-zero in case of a view */
- if (name)
+ if (name.str)
field->col_name= name;
if (table_name)
field->table_name= table_name;
if (db_name)
field->db_name= db_name;
- if (orig_field_name)
+ if (orig_field_name.str)
field->org_col_name= orig_field_name;
if (orig_table_name)
field->org_table_name= orig_table_name;
@@ -8241,7 +8272,6 @@ Item_cache_wrapper::Item_cache_wrapper(THD *thd, Item *item_arg):
with_sum_func= orig_item->with_sum_func;
with_field= orig_item->with_field;
name= item_arg->name;
- name_length= item_arg->name_length;
with_subselect= orig_item->with_subselect;
if ((expr_value= orig_item->get_cache(thd)))
@@ -8929,7 +8959,8 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
field_arg= (Item_field *)real_arg;
if ((field_arg->field->flags & NO_DEFAULT_VALUE_FLAG))
{
- my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), field_arg->field->field_name);
+ my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0),
+ field_arg->field->field_name.str);
goto error;
}
if (!(def_field= (Field*) thd->alloc(field_arg->field->size_of())))
@@ -9170,7 +9201,7 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items)
{
Field *tmp_field= field_arg->field;
/* charset doesn't matter here, it's to avoid sigsegv only */
- tmp_field= new Field_null(0, 0, Field::NONE, field_arg->field->field_name,
+ tmp_field= new Field_null(0, 0, Field::NONE, &field_arg->field->field_name,
&my_charset_bin);
if (tmp_field)
{
@@ -9227,7 +9258,7 @@ void Item_trigger_field::setup_field(THD *thd, TABLE *table,
Try to find field by its name and if it will be found
set field_idx properly.
*/
- (void)find_field_in_table(thd, table, field_name, (uint) strlen(field_name),
+ (void)find_field_in_table(thd, table, field_name.str, field_name.length,
0, &field_idx);
thd->mark_used_columns= save_mark_used_columns;
triggers= table->triggers;
@@ -9239,8 +9270,8 @@ bool Item_trigger_field::eq(const Item *item, bool binary_cmp) const
{
return item->type() == TRIGGER_FIELD_ITEM &&
row_version == ((Item_trigger_field *)item)->row_version &&
- !my_strcasecmp(system_charset_info, field_name,
- ((Item_trigger_field *)item)->field_name);
+ !my_strcasecmp(system_charset_info, field_name.str,
+ ((Item_trigger_field *)item)->field_name.str);
}
@@ -9306,9 +9337,11 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items)
{
table_grants->want_privilege= want_privilege;
- if (check_grant_column(thd, table_grants, triggers->trigger_table->s->db.str,
- triggers->trigger_table->s->table_name.str, field_name,
- strlen(field_name), thd->security_ctx))
+ if (check_grant_column(thd, table_grants,
+ triggers->trigger_table->s->db.str,
+ triggers->trigger_table->s->table_name.str,
+ field_name.str, field_name.length,
+ thd->security_ctx))
return TRUE;
}
#endif // NO_EMBEDDED_ACCESS_CHECKS
@@ -9320,7 +9353,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items)
return FALSE;
}
- my_error(ER_BAD_FIELD_ERROR, MYF(0), field_name,
+ my_error(ER_BAD_FIELD_ERROR, MYF(0), field_name.str,
(row_version == NEW_ROW) ? "NEW" : "OLD");
return TRUE;
}
@@ -9330,14 +9363,14 @@ void Item_trigger_field::print(String *str, enum_query_type query_type)
{
str->append((row_version == NEW_ROW) ? "NEW" : "OLD", 3);
str->append('.');
- str->append(field_name);
+ str->append(&field_name);
}
bool Item_trigger_field::check_vcol_func_processor(void *arg)
{
const char *ver= row_version == NEW_ROW ? "NEW." : "OLD.";
- return mark_unsupported_function(ver, field_name, arg, VCOL_IMPOSSIBLE);
+ return mark_unsupported_function(ver, field_name.str, arg, VCOL_IMPOSSIBLE);
}
@@ -9377,7 +9410,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
Item *new_item= NULL;
Item_result res_type= item_cmp_type(comp_item, item);
- char *name= item->name; // Alloced on THD::mem_root
+ const char *name= item->name.str; // Alloced on THD::mem_root
MEM_ROOT *mem_root= thd->mem_root;
switch (res_type) {
@@ -10222,7 +10255,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
DBUG_ENTER("Item_type_holder::join_types");
DBUG_PRINT("info:", ("was type %s len %d, dec %d name %s",
real_type_handler()->name().ptr(), max_length, decimals,
- (name ? name : "<NULL>")));
+ (name.str ? name.str : "<NULL>")));
DBUG_PRINT("info:", ("in type %s len %d, dec %d",
item->real_type_handler()->name().ptr(),
item->max_length, item->decimals));
@@ -10368,23 +10401,27 @@ Field *Item_type_holder::make_field_by_type(TABLE *table)
switch (Item_type_holder::real_type_handler()->real_field_type()) {
case MYSQL_TYPE_ENUM:
+ {
DBUG_ASSERT(enum_set_typelib);
field= new Field_enum((uchar *) 0, max_length, null_ptr, 0,
- Field::NONE, name,
+ Field::NONE, &name,
get_enum_pack_length(enum_set_typelib->count),
enum_set_typelib, collation.collation);
if (field)
field->init(table);
return field;
+ }
case MYSQL_TYPE_SET:
+ {
DBUG_ASSERT(enum_set_typelib);
field= new Field_set((uchar *) 0, max_length, null_ptr, 0,
- Field::NONE, name,
+ Field::NONE, &name,
get_set_pack_length(enum_set_typelib->count),
enum_set_typelib, collation.collation);
if (field)
field->init(table);
return field;
+ }
case MYSQL_TYPE_NULL:
return make_string_field(table);
default:
diff --git a/sql/item.h b/sql/item.h
index 6c6714a5351..e3d6c4e365f 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -111,6 +111,7 @@ bool mark_unsupported_function(const char *w1, const char *w2,
#define FULL_EXTRACTION_FL (1 << 7)
#define EXTRACTION_MASK (NO_EXTRACTION_FL | FULL_EXTRACTION_FL)
+extern const char *item_empty_name;
void dummy_error_processor(THD *thd, void *data);
@@ -376,7 +377,7 @@ class Rewritable_query_parameter
/*
Byte length of parameter name in the statement. This is not
- Item::name_length because name_length contains byte length of UTF8-encoded
+ Item::name.length because name.length contains byte length of UTF8-encoded
name, but the query string is in the client charset.
*/
uint len_in_query;
@@ -591,9 +592,9 @@ public:
*/
String *val_str() { return val_str(&str_value); }
- char * name; /* Name from select */
+ LEX_CSTRING name; /* Name of item */
/* Original item name (if it was renamed)*/
- char * orig_name;
+ const char *orig_name;
/**
Intrusive list pointer for free list. If not null, points to the next
Item on some Query_arena's free list. For instance, stored procedures
@@ -602,12 +603,6 @@ public:
@see Query_arena::free_list
*/
Item *next;
- /*
- TODO: convert name and name_length fields into LEX_STRING to keep them in
- sync (see bug #11829681/60295 etc). Then also remove some strlen(name)
- calls.
- */
- uint name_length; /* Length of name */
int marker;
bool maybe_null; /* If item may be null */
bool in_rollup; /* If used in GROUP BY list
@@ -639,13 +634,13 @@ public:
virtual ~Item()
{
#ifdef EXTRA_DEBUG
- name=0;
+ name.str= 0;
+ name.length= 0;
#endif
} /*lint -e1509 */
void set_name(THD *thd, const char *str, uint length, CHARSET_INFO *cs);
void set_name_no_truncate(THD *thd, const char *str, uint length,
CHARSET_INFO *cs);
- void rename(char *new_name);
void init_make_field(Send_field *tmp_field,enum enum_field_types type);
virtual void cleanup();
virtual void make_field(THD *thd, Send_field *field);
@@ -1091,9 +1086,9 @@ public:
virtual Field *get_tmp_table_field() { return 0; }
virtual Field *create_field_for_create_select(TABLE *table);
virtual Field *create_field_for_schema(THD *thd, TABLE *table);
- virtual const char *full_name() const { return name ? name : "???"; }
+ virtual const char *full_name() const { return name.str ? name.str : "???"; }
const char *field_name_or_null()
- { return real_item()->type() == Item::FIELD_ITEM ? name : NULL; }
+ { return real_item()->type() == Item::FIELD_ITEM ? name.str : NULL; }
/*
*result* family of methods is analog of *val* family (see above) but
@@ -1629,7 +1624,7 @@ public:
// Row emulation
virtual uint cols() { return 1; }
virtual Item* element_index(uint i) { return this; }
- virtual bool element_index_by_name(uint *idx, const LEX_STRING &name) const
+ virtual bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const
{
return true; // Error
}
@@ -2076,7 +2071,10 @@ public:
done again between subsequent executions of a prepared statement.
*/
if (orig_name)
- name= orig_name;
+ {
+ name.str= orig_name;
+ name.length= strlen(orig_name);
+ }
}
};
@@ -2099,7 +2097,7 @@ protected:
bool fix_fields_from_item(THD *thd, Item **, const Item *);
public:
- LEX_STRING m_name;
+ LEX_CSTRING m_name;
public:
#ifndef DBUG_OFF
@@ -2111,7 +2109,7 @@ public:
#endif
public:
- Item_sp_variable(THD *thd, char *sp_var_name_str, uint sp_var_name_length);
+ Item_sp_variable(THD *thd, const LEX_CSTRING *sp_var_name);
public:
bool fix_fields(THD *thd, Item **)= 0;
@@ -2123,7 +2121,7 @@ public:
bool is_null();
public:
- inline void make_field(THD *thd, Send_field *field);
+ void make_field(THD *thd, Send_field *field);
inline bool const_item() const;
@@ -2139,17 +2137,6 @@ public:
Item_sp_variable inline implementation.
*****************************************************************************/
-inline void Item_sp_variable::make_field(THD *thd, Send_field *field)
-{
- Item *it= this_item();
-
- if (name)
- it->set_name(thd, name, (uint) strlen(name), system_charset_info);
- else
- it->set_name(thd, m_name.str, (uint) m_name.length, system_charset_info);
- it->make_field(thd, field);
-}
-
inline bool Item_sp_variable::const_item() const
{
return TRUE;
@@ -2183,7 +2170,7 @@ protected:
bool append_value_for_log(THD *thd, String *str);
public:
- Item_splocal(THD *thd, const LEX_STRING &sp_var_name, uint sp_var_idx,
+ Item_splocal(THD *thd, const LEX_CSTRING *sp_var_name, uint sp_var_idx,
enum_field_types sp_var_type,
uint pos_in_q= 0, uint len_in_q= 0);
@@ -2195,7 +2182,7 @@ public:
virtual void print(String *str, enum_query_type query_type);
public:
- inline const LEX_STRING *my_name() const;
+ inline const LEX_CSTRING *my_name() const;
inline uint get_var_idx() const;
@@ -2234,7 +2221,7 @@ public:
class Item_splocal_row: public Item_splocal
{
public:
- Item_splocal_row(THD *thd, const LEX_STRING &sp_var_name,
+ Item_splocal_row(THD *thd, const LEX_CSTRING *sp_var_name,
uint sp_var_idx, uint pos_in_q, uint len_in_q)
:Item_splocal(thd, sp_var_name, sp_var_idx, MYSQL_TYPE_NULL,
pos_in_q, len_in_q)
@@ -2253,7 +2240,7 @@ class Item_splocal_with_delayed_data_type: public Item_splocal
{
public:
Item_splocal_with_delayed_data_type(THD *thd,
- const LEX_STRING &sp_var_name,
+ const LEX_CSTRING *sp_var_name,
uint sp_var_idx,
uint pos_in_q, uint len_in_q)
:Item_splocal(thd, sp_var_name, sp_var_idx, MYSQL_TYPE_NULL,
@@ -2287,19 +2274,19 @@ public:
class Item_splocal_row_field :public Item_splocal
{
protected:
- LEX_STRING m_field_name;
+ LEX_CSTRING m_field_name;
uint m_field_idx;
bool set_value(THD *thd, sp_rcontext *ctx, Item **it);
public:
Item_splocal_row_field(THD *thd,
- const LEX_STRING &sp_var_name,
- const LEX_STRING &sp_field_name,
+ const LEX_CSTRING *sp_var_name,
+ const LEX_CSTRING *sp_field_name,
uint sp_var_idx, uint sp_field_idx,
enum_field_types sp_var_type,
uint pos_in_q= 0, uint len_in_q= 0)
:Item_splocal(thd, sp_var_name, sp_var_idx, sp_var_type,
pos_in_q, len_in_q),
- m_field_name(sp_field_name),
+ m_field_name(*sp_field_name),
m_field_idx(sp_field_idx)
{ }
bool fix_fields(THD *thd, Item **);
@@ -2316,8 +2303,8 @@ class Item_splocal_row_field_by_name :public Item_splocal_row_field
bool set_value(THD *thd, sp_rcontext *ctx, Item **it);
public:
Item_splocal_row_field_by_name(THD *thd,
- const LEX_STRING &sp_var_name,
- const LEX_STRING &sp_field_name,
+ const LEX_CSTRING *sp_var_name,
+ const LEX_CSTRING *sp_field_name,
uint sp_var_idx,
enum_field_types sp_var_type,
uint pos_in_q= 0, uint len_in_q= 0)
@@ -2334,7 +2321,7 @@ public:
Item_splocal inline implementation.
*****************************************************************************/
-inline const LEX_STRING *Item_splocal::my_name() const
+inline const LEX_CSTRING *Item_splocal::my_name() const
{
return &m_name;
}
@@ -2512,13 +2499,13 @@ protected:
*/
const char *orig_db_name;
const char *orig_table_name;
- const char *orig_field_name;
+ LEX_CSTRING orig_field_name;
public:
Name_resolution_context *context;
const char *db_name;
const char *table_name;
- const char *field_name;
+ LEX_CSTRING field_name;
bool alias_name_used; /* true if item was resolved against alias */
/*
Cached value of index for this field in table->field array, used by prep.
@@ -2548,9 +2535,9 @@ public:
bool can_be_depended;
Item_ident(THD *thd, Name_resolution_context *context_arg,
const char *db_name_arg, const char *table_name_arg,
- const char *field_name_arg);
+ const LEX_CSTRING *field_name_arg);
Item_ident(THD *thd, Item_ident *item);
- Item_ident(THD *thd, TABLE_LIST *view_arg, const char *field_name_arg);
+ Item_ident(THD *thd, TABLE_LIST *view_arg, const LEX_CSTRING *field_name_arg);
const char *full_name() const;
void cleanup();
st_select_lex *get_depended_from() const;
@@ -2611,7 +2598,7 @@ public:
bool any_privileges;
Item_field(THD *thd, Name_resolution_context *context_arg,
const char *db_arg,const char *table_name_arg,
- const char *field_name_arg);
+ const LEX_CSTRING *field_name_arg);
/*
Constructor needed to process subselect with temporary tables (see Item)
*/
@@ -2735,7 +2722,7 @@ public:
bool check_vcol_func_processor(void *arg)
{
context= 0;
- return mark_unsupported_function(field_name, arg, VCOL_FIELD_REF);
+ return mark_unsupported_function(field_name.str, arg, VCOL_FIELD_REF);
}
void cleanup();
Item_equal *get_item_equal() { return item_equal; }
@@ -2793,7 +2780,7 @@ public:
Item_result result_type() const{ return ROW_RESULT ; }
Item_result cmp_type() const { return ROW_RESULT; }
uint cols() { return arg_count; }
- bool element_index_by_name(uint *idx, const LEX_STRING &name) const;
+ bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const;
Item* element_index(uint i) { return arg_count ? args[i] : this; }
Item** addr(uint i) { return arg_count ? args + i : NULL; }
bool check_cols(uint c)
@@ -2851,12 +2838,13 @@ public:
class Item_null :public Item_basic_constant
{
public:
- Item_null(THD *thd, char *name_par=0, CHARSET_INFO *cs= &my_charset_bin):
+ Item_null(THD *thd, const char *name_par=0, CHARSET_INFO *cs= &my_charset_bin):
Item_basic_constant(thd)
{
maybe_null= null_value= TRUE;
max_length= 0;
- name= name_par ? name_par : (char*) "NULL";
+ name.str= name_par ? name_par : "NULL";
+ name.length= strlen(name.str);
fixed= 1;
collation.set(cs, DERIVATION_IGNORABLE, MY_REPERTOIRE_ASCII);
}
@@ -3056,7 +3044,7 @@ public:
enum Item_result cmp_type () const
{ return Type_handler_hybrid_field_type::cmp_type(); }
- Item_param(THD *thd, char *name_arg,
+ Item_param(THD *thd, const LEX_CSTRING *name_arg,
uint pos_in_query_arg, uint len_in_query_arg);
enum Type type() const
@@ -3182,7 +3170,11 @@ public:
{ max_length=length; fixed= 1; unsigned_flag= 1; }
Item_int(THD *thd, const char *str_arg,longlong i,uint length):
Item_num(thd), value(i)
- { max_length=length; name=(char*) str_arg; fixed= 1; }
+ {
+ max_length=length;
+ name.str= str_arg; name.length= safe_strlen(name.str);
+ fixed= 1;
+ }
Item_int(THD *thd, const char *str_arg, uint length=64);
enum Type type() const { return INT_ITEM; }
enum Item_result result_type () const { return INT_RESULT; }
@@ -3288,16 +3280,17 @@ public:
class Item_float :public Item_num
{
- char *presentation;
+ const char *presentation;
public:
double value;
Item_float(THD *thd, const char *str_arg, uint length);
Item_float(THD *thd, const char *str, double val_arg, uint decimal_par,
uint length): Item_num(thd), value(val_arg)
{
- presentation= name=(char*) str;
+ presentation= name.str= str;
+ name.length= safe_strlen(str);
decimals=(uint8) decimal_par;
- max_length=length;
+ max_length= length;
fixed= 1;
}
Item_float(THD *thd, double value_par, uint decimal_par):
@@ -3423,7 +3416,7 @@ public:
{
str_value.set_or_copy_aligned(str, length, cs);
fix_from_value(dv, Metadata(&str_value));
- set_name(thd, name_par, 0, system_charset_info);
+ set_name(thd, name_par, safe_strlen(name_par), system_charset_info);
}
Item_string(THD *thd, const char *name_par, const char *str, uint length,
CHARSET_INFO *cs, Derivation dv, uint repertoire):
@@ -3431,7 +3424,7 @@ public:
{
str_value.set_or_copy_aligned(str, length, cs);
fix_from_value(dv, Metadata(&str_value, repertoire));
- set_name(thd, name_par, 0, system_charset_info);
+ set_name(thd, name_par, safe_strlen(name_par), system_charset_info);
}
void print_value(String *to) const
{
@@ -3459,7 +3452,7 @@ public:
{
return const_charset_converter(thd, tocs, true);
}
- inline void append(char *str, uint length)
+ inline void append(const char *str, uint length)
{
str_value.append(str, length);
max_length= str_value.numchars() * collation.collation->mbmaxlen;
@@ -3494,7 +3487,7 @@ public:
String *check_well_formed_result(bool send_error)
{ return Item::check_well_formed_result(&str_value, send_error); }
- enum_field_types odbc_temporal_literal_type(const LEX_STRING *type_str) const
+ enum_field_types odbc_temporal_literal_type(const LEX_CSTRING *type_str) const
{
/*
If string is a reasonably short pure ASCII string literal,
@@ -3641,7 +3634,7 @@ class Item_blob :public Item_partition_func_safe_string
{
public:
Item_blob(THD *thd, const char *name_arg, uint length):
- Item_partition_func_safe_string(thd, name_arg, strlen(name_arg), &my_charset_bin)
+ Item_partition_func_safe_string(thd, name_arg, safe_strlen(name_arg), &my_charset_bin)
{ max_length= length; }
enum Type type() const { return TYPE_HOLDER; }
enum_field_types field_type() const { return MYSQL_TYPE_BLOB; }
@@ -3669,7 +3662,11 @@ public:
CHARSET_INFO *cs= NULL):
Item_partition_func_safe_string(thd, "", 0,
cs ? cs : &my_charset_utf8_general_ci)
- { name=(char*) header; max_length= length * collation.collation->mbmaxlen; }
+ {
+ name.str= header;
+ name.length= strlen(name.str);
+ max_length= length * collation.collation->mbmaxlen;
+ }
void make_field(THD *thd, Send_field *field);
};
@@ -4237,7 +4234,7 @@ public:
bool reference_trough_name;
Item_ref(THD *thd, Name_resolution_context *context_arg,
const char *db_arg, const char *table_name_arg,
- const char *field_name_arg):
+ const LEX_CSTRING *field_name_arg):
Item_ident(thd, context_arg, db_arg, table_name_arg, field_name_arg),
set_properties_only(0), ref(0), reference_trough_name(1) {}
/*
@@ -4255,10 +4252,10 @@ public:
with Bar, and if we have a more broader set of problems like this.
*/
Item_ref(THD *thd, Name_resolution_context *context_arg, Item **item,
- const char *table_name_arg, const char *field_name_arg,
+ const char *table_name_arg, const LEX_CSTRING *field_name_arg,
bool alias_name_used_arg= FALSE);
Item_ref(THD *thd, TABLE_LIST *view_arg, Item **item,
- const char *field_name_arg, bool alias_name_used_arg= FALSE);
+ const LEX_CSTRING *field_name_arg, bool alias_name_used_arg= FALSE);
/* Constructor need to process subselect with temporary tables (see Item) */
Item_ref(THD *thd, Item_ref *item)
@@ -4436,7 +4433,7 @@ class Item_direct_ref :public Item_ref
public:
Item_direct_ref(THD *thd, Name_resolution_context *context_arg, Item **item,
const char *table_name_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
bool alias_name_used_arg= FALSE):
Item_ref(thd, context_arg, item, table_name_arg,
field_name_arg, alias_name_used_arg)
@@ -4444,7 +4441,7 @@ public:
/* Constructor need to process subselect with temporary tables (see Item) */
Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {}
Item_direct_ref(THD *thd, TABLE_LIST *view_arg, Item **item,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
bool alias_name_used_arg= FALSE):
Item_ref(thd, view_arg, item, field_name_arg,
alias_name_used_arg)
@@ -4482,7 +4479,7 @@ class Item_direct_ref_to_ident :public Item_direct_ref
public:
Item_direct_ref_to_ident(THD *thd, Item_ident *item):
Item_direct_ref(thd, item->context, (Item**)&item, item->table_name,
- item->field_name, FALSE)
+ &item->field_name, FALSE)
{
ident= item;
ref= (Item**)&ident;
@@ -4669,7 +4666,7 @@ public:
Item_direct_view_ref(THD *thd, Name_resolution_context *context_arg,
Item **item,
const char *table_name_arg,
- const char *field_name_arg,
+ LEX_CSTRING *field_name_arg,
TABLE_LIST *view_arg):
Item_direct_ref(thd, context_arg, item, table_name_arg, field_name_arg),
item_equal(0), view(view_arg),
@@ -4821,7 +4818,7 @@ public:
Item_outer_ref(THD *thd, Name_resolution_context *context_arg,
Item_field *outer_field_arg):
Item_direct_ref(thd, context_arg, 0, outer_field_arg->table_name,
- outer_field_arg->field_name),
+ &outer_field_arg->field_name),
outer_ref(outer_field_arg), in_sum_func(0),
found_in_select_list(0), found_in_group_by(0)
{
@@ -4830,7 +4827,7 @@ public:
fixed= 0; /* reset flag set in set_properties() */
}
Item_outer_ref(THD *thd, Name_resolution_context *context_arg, Item **item,
- const char *table_name_arg, const char *field_name_arg,
+ const char *table_name_arg, LEX_CSTRING *field_name_arg,
bool alias_name_used_arg):
Item_direct_ref(thd, context_arg, item, table_name_arg, field_name_arg,
alias_name_used_arg),
@@ -4871,7 +4868,8 @@ protected:
public:
Item_ref_null_helper(THD *thd, Name_resolution_context *context_arg,
Item_in_subselect* master, Item **item,
- const char *table_name_arg, const char *field_name_arg):
+ const char *table_name_arg,
+ const LEX_CSTRING *field_name_arg):
Item_ref(thd, context_arg, item, table_name_arg, field_name_arg),
owner(master) {}
void save_val(Field *to);
@@ -4974,7 +4972,7 @@ protected:
item= i;
null_value=maybe_null=item->maybe_null;
Type_std_attributes::set(item);
- name=item->name;
+ name= item->name;
set_handler_by_field_type(item->field_type());
fixed= item->fixed;
}
@@ -5263,15 +5261,15 @@ public:
Item *arg;
Item_default_value(THD *thd, Name_resolution_context *context_arg)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
- (const char *)NULL),
+ &null_clex_str),
arg(NULL) {}
Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
- (const char *)NULL),
+ &null_clex_str),
arg(a) {}
Item_default_value(THD *thd, Name_resolution_context *context_arg, Field *a)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
- (const char *)NULL),
+ &null_clex_str),
arg(NULL) {}
enum Type type() const { return DEFAULT_VALUE_ITEM; }
bool eq(const Item *item, bool binary_cmp) const;
@@ -5354,7 +5352,7 @@ public:
Item *arg;
Item_insert_value(THD *thd, Name_resolution_context *context_arg, Item *a)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
- (const char *)NULL),
+ &null_clex_str),
arg(a) {}
bool eq(const Item *item, bool binary_cmp) const;
bool fix_fields(THD *, Item **);
@@ -5415,7 +5413,7 @@ public:
Item_trigger_field(THD *thd, Name_resolution_context *context_arg,
row_version_type row_ver_arg,
- const char *field_name_arg,
+ const LEX_CSTRING *field_name_arg,
ulong priv, const bool ro)
:Item_field(thd, context_arg,
(const char *)NULL, (const char *)NULL, field_name_arg),
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 6eb0aac3e4c..305f62a04b1 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -44,8 +44,8 @@
static const char* item_name(Item *a, String *str)
{
- if (a->name)
- return a->name;
+ if (a->name.str)
+ return a->name.str;
str->length(0);
a->print(str, QT_ORDINARY);
return str->c_ptr_safe();
@@ -115,7 +115,8 @@ bool get_length_and_scale(ulonglong length, ulonglong decimals,
class Create_native_func : public Create_func
{
public:
- virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_func(THD *thd, LEX_CSTRING *name,
+ List<Item> *item_list);
/**
Builder method, with no arguments.
@@ -124,7 +125,7 @@ public:
@param item_list The function parameters, none of which are named
@return An item representing the function call
*/
- virtual Item *create_native(THD *thd, LEX_STRING name,
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list) = 0;
protected:
@@ -142,7 +143,8 @@ protected:
class Create_func_arg0 : public Create_func
{
public:
- virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_func(THD *thd, LEX_CSTRING *name,
+ List<Item> *item_list);
/**
Builder method, with no arguments.
@@ -166,7 +168,7 @@ protected:
class Create_func_arg1 : public Create_func
{
public:
- virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
/**
Builder method, with one argument.
@@ -191,7 +193,7 @@ protected:
class Create_func_arg2 : public Create_func
{
public:
- virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
/**
Builder method, with two arguments.
@@ -217,7 +219,7 @@ protected:
class Create_func_arg3 : public Create_func
{
public:
- virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
/**
Builder method, with three arguments.
@@ -244,7 +246,7 @@ protected:
class Create_sp_func : public Create_qfunc
{
public:
- virtual Item *create_with_db(THD *thd, LEX_STRING db, LEX_STRING name,
+ virtual Item *create_with_db(THD *thd, LEX_CSTRING *db, LEX_CSTRING *name,
bool use_explicit_name, List<Item> *item_list);
static Create_sp_func s_singleton;
@@ -267,7 +269,7 @@ protected:
class Create_func_no_geom : public Create_func
{
public:
- virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
/** Singleton. */
static Create_func_no_geom s_singleton;
@@ -413,7 +415,7 @@ protected:
class Create_func_atan : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_atan s_singleton;
@@ -634,7 +636,7 @@ protected:
class Create_func_concat : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_concat s_singleton;
@@ -647,7 +649,7 @@ protected:
class Create_func_concat_operator_oracle : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_concat_operator_oracle s_singleton;
@@ -673,7 +675,7 @@ protected:
class Create_func_concat_ws : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_concat_ws s_singleton;
@@ -911,7 +913,7 @@ protected:
class Create_func_des_decrypt : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_des_decrypt s_singleton;
@@ -924,7 +926,7 @@ protected:
class Create_func_des_encrypt : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_des_encrypt s_singleton;
@@ -993,7 +995,7 @@ class Create_func_distance : public Create_func_arg2
class Create_func_elt : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_elt s_singleton;
@@ -1019,7 +1021,7 @@ protected:
class Create_func_encrypt : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_encrypt s_singleton;
@@ -1115,7 +1117,7 @@ protected:
class Create_func_export_set : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_export_set s_singleton;
@@ -1143,7 +1145,7 @@ protected:
class Create_func_field : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_field s_singleton;
@@ -1182,7 +1184,7 @@ protected:
class Create_func_format : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_format s_singleton;
@@ -1234,7 +1236,7 @@ protected:
class Create_func_from_unixtime : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_from_unixtime s_singleton;
@@ -1248,7 +1250,7 @@ protected:
class Create_func_geometry_from_text : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_geometry_from_text s_singleton;
@@ -1263,7 +1265,7 @@ protected:
class Create_func_geometry_from_wkb : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_geometry_from_wkb s_singleton;
@@ -1278,7 +1280,7 @@ protected:
class Create_func_geometry_from_json : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_geometry_from_json s_singleton;
@@ -1291,7 +1293,7 @@ protected:
class Create_func_as_geojson : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_as_geojson s_singleton;
@@ -1378,7 +1380,7 @@ protected:
class Create_func_greatest : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_greatest s_singleton;
@@ -1804,7 +1806,7 @@ protected:
class Create_func_json_detailed: public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_detailed s_singleton;
@@ -1869,7 +1871,7 @@ protected:
class Create_func_json_keys: public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_keys s_singleton;
@@ -1882,7 +1884,7 @@ protected:
class Create_func_json_contains: public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_contains s_singleton;
@@ -1895,7 +1897,7 @@ protected:
class Create_func_json_contains_path : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_contains_path s_singleton;
@@ -1908,7 +1910,7 @@ protected:
class Create_func_json_extract : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_extract s_singleton;
@@ -1921,7 +1923,7 @@ protected:
class Create_func_json_search : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_search s_singleton;
@@ -1934,7 +1936,7 @@ protected:
class Create_func_json_array : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_array s_singleton;
@@ -1947,7 +1949,7 @@ protected:
class Create_func_json_array_append : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_array_append s_singleton;
@@ -1960,7 +1962,7 @@ protected:
class Create_func_json_array_insert : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_array_insert s_singleton;
@@ -1973,7 +1975,7 @@ protected:
class Create_func_json_insert : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_insert s_singleton;
@@ -1986,7 +1988,7 @@ protected:
class Create_func_json_set : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_set s_singleton;
@@ -1999,7 +2001,7 @@ protected:
class Create_func_json_replace : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_replace s_singleton;
@@ -2012,7 +2014,7 @@ protected:
class Create_func_json_remove : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_remove s_singleton;
@@ -2025,7 +2027,7 @@ protected:
class Create_func_json_object : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_object s_singleton;
@@ -2038,7 +2040,7 @@ protected:
class Create_func_json_length : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_length s_singleton;
@@ -2051,7 +2053,7 @@ protected:
class Create_func_json_merge : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_json_merge s_singleton;
@@ -2103,7 +2105,7 @@ protected:
class Create_func_last_insert_id : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_last_insert_id s_singleton;
@@ -2129,7 +2131,7 @@ protected:
class Create_func_least : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_least s_singleton;
@@ -2209,7 +2211,7 @@ protected:
class Create_func_locate : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_locate s_singleton;
@@ -2222,7 +2224,7 @@ protected:
class Create_func_log : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_log s_singleton;
@@ -2313,7 +2315,7 @@ protected:
class Create_func_make_set : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_make_set s_singleton;
@@ -2326,7 +2328,7 @@ protected:
class Create_func_master_pos_wait : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_master_pos_wait s_singleton;
@@ -2339,7 +2341,7 @@ protected:
class Create_func_master_gtid_wait : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_master_gtid_wait s_singleton;
@@ -2635,7 +2637,7 @@ protected:
class Create_func_rand : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_rand s_singleton;
@@ -2674,7 +2676,7 @@ protected:
class Create_func_round : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_round s_singleton;
@@ -3069,7 +3071,7 @@ protected:
class Create_func_unix_timestamp : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_unix_timestamp s_singleton;
@@ -3231,7 +3233,7 @@ protected:
class Create_func_year_week : public Create_native_func
{
public:
- virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
static Create_func_year_week s_singleton;
@@ -3275,7 +3277,7 @@ Create_func_no_geom Create_func_no_geom::s_singleton;
Item*
Create_func_no_geom::create_func(THD * /* unused */,
- LEX_STRING /* unused */,
+ LEX_CSTRING /* unused */,
List<Item> * /* unused */)
{
/* FIXME: error message can't be translated. */
@@ -3287,9 +3289,9 @@ Create_func_no_geom::create_func(THD * /* unused */,
Item*
-Create_qfunc::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
+Create_qfunc::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
- LEX_STRING db;
+ LEX_CSTRING db;
if (! thd->db && ! thd->lex->sphead)
{
@@ -3305,14 +3307,14 @@ Create_qfunc::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
the case when a default database exist, see Create_sp_func::create().
*/
my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
- "FUNCTION", name.str);
+ "FUNCTION", name->str);
return NULL;
}
if (thd->lex->copy_db_to(&db.str, &db.length))
return NULL;
- return create_with_db(thd, db, name, false, item_list);
+ return create_with_db(thd, &db, name, false, item_list);
}
@@ -3320,9 +3322,9 @@ Create_qfunc::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
Create_udf_func Create_udf_func::s_singleton;
Item*
-Create_udf_func::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
+Create_udf_func::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
- udf_func *udf= find_udf(name.str, name.length);
+ udf_func *udf= find_udf(name->str, name->length);
DBUG_ASSERT(udf);
return create(thd, udf, item_list);
}
@@ -3430,7 +3432,7 @@ Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list)
Create_sp_func Create_sp_func::s_singleton;
Item*
-Create_sp_func::create_with_db(THD *thd, LEX_STRING db, LEX_STRING name,
+Create_sp_func::create_with_db(THD *thd, LEX_CSTRING *db, LEX_CSTRING *name,
bool use_explicit_name, List<Item> *item_list)
{
int arg_count= 0;
@@ -3449,7 +3451,7 @@ Create_sp_func::create_with_db(THD *thd, LEX_STRING db, LEX_STRING name,
because it can refer to a User Defined Function call.
For a Stored Function however, this has no semantic.
*/
- my_error(ER_WRONG_PARAMETERS_TO_STORED_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMETERS_TO_STORED_FCT, MYF(0), name->str);
return NULL;
}
@@ -3471,11 +3473,11 @@ Create_sp_func::create_with_db(THD *thd, LEX_STRING db, LEX_STRING name,
Item*
-Create_native_func::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
+Create_native_func::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
if (has_named_parameters(item_list))
{
- my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -3484,7 +3486,7 @@ Create_native_func::create_func(THD *thd, LEX_STRING name, List<Item> *item_list
Item*
-Create_func_arg0::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
+Create_func_arg0::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
int arg_count= 0;
@@ -3493,7 +3495,7 @@ Create_func_arg0::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
if (arg_count != 0)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -3502,7 +3504,7 @@ Create_func_arg0::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
Item*
-Create_func_arg1::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
+Create_func_arg1::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
int arg_count= 0;
@@ -3511,7 +3513,7 @@ Create_func_arg1::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
if (arg_count != 1)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -3519,7 +3521,7 @@ Create_func_arg1::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
if (! param_1->is_autogenerated_name)
{
- my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -3528,7 +3530,7 @@ Create_func_arg1::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
Item*
-Create_func_arg2::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
+Create_func_arg2::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
int arg_count= 0;
@@ -3537,7 +3539,7 @@ Create_func_arg2::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
if (arg_count != 2)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -3547,7 +3549,7 @@ Create_func_arg2::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
if ( (! param_1->is_autogenerated_name)
|| (! param_2->is_autogenerated_name))
{
- my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -3556,7 +3558,7 @@ Create_func_arg2::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
Item*
-Create_func_arg3::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
+Create_func_arg3::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
int arg_count= 0;
@@ -3565,7 +3567,7 @@ Create_func_arg3::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
if (arg_count != 3)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -3577,7 +3579,7 @@ Create_func_arg3::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
|| (! param_2->is_autogenerated_name)
|| (! param_3->is_autogenerated_name))
{
- my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -3675,7 +3677,7 @@ Create_func_asin::create_1_arg(THD *thd, Item *arg1)
Create_func_atan Create_func_atan::s_singleton;
Item*
-Create_func_atan::create_native(THD *thd, LEX_STRING name,
+Create_func_atan::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item* func= NULL;
@@ -3700,7 +3702,7 @@ Create_func_atan::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -3856,7 +3858,7 @@ Create_func_dyncol_json::create_1_arg(THD *thd, Item *arg1)
Create_func_concat Create_func_concat::s_singleton;
Item*
-Create_func_concat::create_native(THD *thd, LEX_STRING name,
+Create_func_concat::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
int arg_count= 0;
@@ -3866,7 +3868,7 @@ Create_func_concat::create_native(THD *thd, LEX_STRING name,
if (arg_count < 1)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -3879,7 +3881,7 @@ Create_func_concat_operator_oracle
Create_func_concat_operator_oracle::s_singleton;
Item*
-Create_func_concat_operator_oracle::create_native(THD *thd, LEX_STRING name,
+Create_func_concat_operator_oracle::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
int arg_count= 0;
@@ -3889,7 +3891,7 @@ Create_func_concat_operator_oracle::create_native(THD *thd, LEX_STRING name,
if (arg_count < 1)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -3907,7 +3909,7 @@ Create_func_decode_histogram::create_2_arg(THD *thd, Item *arg1, Item *arg2)
Create_func_concat_ws Create_func_concat_ws::s_singleton;
Item*
-Create_func_concat_ws::create_native(THD *thd, LEX_STRING name,
+Create_func_concat_ws::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
int arg_count= 0;
@@ -3918,7 +3920,7 @@ Create_func_concat_ws::create_native(THD *thd, LEX_STRING name,
/* "WS" stands for "With Separator": this function takes 2+ arguments */
if (arg_count < 2)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -4103,7 +4105,7 @@ Create_func_degrees::create_1_arg(THD *thd, Item *arg1)
Create_func_des_decrypt Create_func_des_decrypt::s_singleton;
Item*
-Create_func_des_decrypt::create_native(THD *thd, LEX_STRING name,
+Create_func_des_decrypt::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -4128,7 +4130,7 @@ Create_func_des_decrypt::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -4140,7 +4142,7 @@ Create_func_des_decrypt::create_native(THD *thd, LEX_STRING name,
Create_func_des_encrypt Create_func_des_encrypt::s_singleton;
Item*
-Create_func_des_encrypt::create_native(THD *thd, LEX_STRING name,
+Create_func_des_encrypt::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -4165,7 +4167,7 @@ Create_func_des_encrypt::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -4219,7 +4221,7 @@ Create_func_distance::create_2_arg(THD *thd, Item *arg1, Item *arg2)
Create_func_elt Create_func_elt::s_singleton;
Item*
-Create_func_elt::create_native(THD *thd, LEX_STRING name,
+Create_func_elt::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
int arg_count= 0;
@@ -4229,7 +4231,7 @@ Create_func_elt::create_native(THD *thd, LEX_STRING name,
if (arg_count < 2)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -4249,7 +4251,7 @@ Create_func_encode::create_2_arg(THD *thd, Item *arg1, Item *arg2)
Create_func_encrypt Create_func_encrypt::s_singleton;
Item*
-Create_func_encrypt::create_native(THD *thd, LEX_STRING name,
+Create_func_encrypt::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -4275,7 +4277,7 @@ Create_func_encrypt::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -4350,7 +4352,7 @@ Create_func_exp::create_1_arg(THD *thd, Item *arg1)
Create_func_export_set Create_func_export_set::s_singleton;
Item*
-Create_func_export_set::create_native(THD *thd, LEX_STRING name,
+Create_func_export_set::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -4391,7 +4393,7 @@ Create_func_export_set::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -4415,7 +4417,7 @@ Create_func_exteriorring::create_1_arg(THD *thd, Item *arg1)
Create_func_field Create_func_field::s_singleton;
Item*
-Create_func_field::create_native(THD *thd, LEX_STRING name,
+Create_func_field::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
int arg_count= 0;
@@ -4425,7 +4427,7 @@ Create_func_field::create_native(THD *thd, LEX_STRING name,
if (arg_count < 2)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -4454,7 +4456,7 @@ Create_func_floor::create_1_arg(THD *thd, Item *arg1)
Create_func_format Create_func_format::s_singleton;
Item*
-Create_func_format::create_native(THD *thd, LEX_STRING name,
+Create_func_format::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -4477,7 +4479,7 @@ Create_func_format::create_native(THD *thd, LEX_STRING name,
break;
}
default:
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
@@ -4519,7 +4521,7 @@ Create_func_from_days::create_1_arg(THD *thd, Item *arg1)
Create_func_from_unixtime Create_func_from_unixtime::s_singleton;
Item*
-Create_func_from_unixtime::create_native(THD *thd, LEX_STRING name,
+Create_func_from_unixtime::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -4545,7 +4547,7 @@ Create_func_from_unixtime::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -4558,7 +4560,7 @@ Create_func_from_unixtime::create_native(THD *thd, LEX_STRING name,
Create_func_geometry_from_text Create_func_geometry_from_text::s_singleton;
Item*
-Create_func_geometry_from_text::create_native(THD *thd, LEX_STRING name,
+Create_func_geometry_from_text::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -4584,7 +4586,7 @@ Create_func_geometry_from_text::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -4598,7 +4600,7 @@ Create_func_geometry_from_text::create_native(THD *thd, LEX_STRING name,
Create_func_geometry_from_wkb Create_func_geometry_from_wkb::s_singleton;
Item*
-Create_func_geometry_from_wkb::create_native(THD *thd, LEX_STRING name,
+Create_func_geometry_from_wkb::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -4624,7 +4626,7 @@ Create_func_geometry_from_wkb::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -4638,7 +4640,7 @@ Create_func_geometry_from_wkb::create_native(THD *thd, LEX_STRING name,
Create_func_geometry_from_json Create_func_geometry_from_json::s_singleton;
Item*
-Create_func_geometry_from_json::create_native(THD *thd, LEX_STRING name,
+Create_func_geometry_from_json::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -4673,7 +4675,7 @@ Create_func_geometry_from_json::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -4685,7 +4687,7 @@ Create_func_geometry_from_json::create_native(THD *thd, LEX_STRING name,
Create_func_as_geojson Create_func_as_geojson::s_singleton;
Item*
-Create_func_as_geojson::create_native(THD *thd, LEX_STRING name,
+Create_func_as_geojson::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -4719,7 +4721,7 @@ Create_func_as_geojson::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -4788,7 +4790,7 @@ Create_func_glength::create_1_arg(THD *thd, Item *arg1)
Create_func_greatest Create_func_greatest::s_singleton;
Item*
-Create_func_greatest::create_native(THD *thd, LEX_STRING name,
+Create_func_greatest::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
int arg_count= 0;
@@ -4798,7 +4800,7 @@ Create_func_greatest::create_native(THD *thd, LEX_STRING name,
if (arg_count < 2)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -5080,7 +5082,7 @@ Create_func_json_exists::create_2_arg(THD *thd, Item *arg1, Item *arg2)
Create_func_json_detailed Create_func_json_detailed::s_singleton;
Item*
-Create_func_json_detailed::create_native(THD *thd, LEX_STRING name,
+Create_func_json_detailed::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5091,7 +5093,7 @@ Create_func_json_detailed::create_native(THD *thd, LEX_STRING name,
if (arg_count < 1 || arg_count > 2 /* json_doc, [path]...*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5197,7 +5199,7 @@ Create_func_last_day::create_1_arg(THD *thd, Item *arg1)
Create_func_json_array Create_func_json_array::s_singleton;
Item*
-Create_func_json_array::create_native(THD *thd, LEX_STRING name,
+Create_func_json_array::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func;
@@ -5218,7 +5220,7 @@ Create_func_json_array::create_native(THD *thd, LEX_STRING name,
Create_func_json_array_append Create_func_json_array_append::s_singleton;
Item*
-Create_func_json_array_append::create_native(THD *thd, LEX_STRING name,
+Create_func_json_array_append::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5229,7 +5231,7 @@ Create_func_json_array_append::create_native(THD *thd, LEX_STRING name,
if (arg_count < 3 || (arg_count & 1) == 0 /*is even*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5243,7 +5245,7 @@ Create_func_json_array_append::create_native(THD *thd, LEX_STRING name,
Create_func_json_array_insert Create_func_json_array_insert::s_singleton;
Item*
-Create_func_json_array_insert::create_native(THD *thd, LEX_STRING name,
+Create_func_json_array_insert::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5254,7 +5256,7 @@ Create_func_json_array_insert::create_native(THD *thd, LEX_STRING name,
if (arg_count < 3 || (arg_count & 1) == 0 /*is even*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5268,7 +5270,7 @@ Create_func_json_array_insert::create_native(THD *thd, LEX_STRING name,
Create_func_json_insert Create_func_json_insert::s_singleton;
Item*
-Create_func_json_insert::create_native(THD *thd, LEX_STRING name,
+Create_func_json_insert::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5279,7 +5281,7 @@ Create_func_json_insert::create_native(THD *thd, LEX_STRING name,
if (arg_count < 3 || (arg_count & 1) == 0 /*is even*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5294,7 +5296,7 @@ Create_func_json_insert::create_native(THD *thd, LEX_STRING name,
Create_func_json_set Create_func_json_set::s_singleton;
Item*
-Create_func_json_set::create_native(THD *thd, LEX_STRING name,
+Create_func_json_set::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5305,7 +5307,7 @@ Create_func_json_set::create_native(THD *thd, LEX_STRING name,
if (arg_count < 3 || (arg_count & 1) == 0 /*is even*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5320,7 +5322,7 @@ Create_func_json_set::create_native(THD *thd, LEX_STRING name,
Create_func_json_replace Create_func_json_replace::s_singleton;
Item*
-Create_func_json_replace::create_native(THD *thd, LEX_STRING name,
+Create_func_json_replace::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5331,7 +5333,7 @@ Create_func_json_replace::create_native(THD *thd, LEX_STRING name,
if (arg_count < 3 || (arg_count & 1) == 0 /*is even*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5346,7 +5348,7 @@ Create_func_json_replace::create_native(THD *thd, LEX_STRING name,
Create_func_json_remove Create_func_json_remove::s_singleton;
Item*
-Create_func_json_remove::create_native(THD *thd, LEX_STRING name,
+Create_func_json_remove::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5357,7 +5359,7 @@ Create_func_json_remove::create_native(THD *thd, LEX_STRING name,
if (arg_count < 2 /*json_doc, path [,path]*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5371,7 +5373,7 @@ Create_func_json_remove::create_native(THD *thd, LEX_STRING name,
Create_func_json_object Create_func_json_object::s_singleton;
Item*
-Create_func_json_object::create_native(THD *thd, LEX_STRING name,
+Create_func_json_object::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func;
@@ -5382,7 +5384,7 @@ Create_func_json_object::create_native(THD *thd, LEX_STRING name,
arg_count= item_list->elements;
if ((arg_count & 1) != 0 /*is odd*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
func= NULL;
}
else
@@ -5403,7 +5405,7 @@ Create_func_json_object::create_native(THD *thd, LEX_STRING name,
Create_func_json_length Create_func_json_length::s_singleton;
Item*
-Create_func_json_length::create_native(THD *thd, LEX_STRING name,
+Create_func_json_length::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func;
@@ -5412,7 +5414,7 @@ Create_func_json_length::create_native(THD *thd, LEX_STRING name,
if (item_list == NULL ||
(arg_count= item_list->elements) == 0)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
func= NULL;
}
else
@@ -5427,7 +5429,7 @@ Create_func_json_length::create_native(THD *thd, LEX_STRING name,
Create_func_json_merge Create_func_json_merge::s_singleton;
Item*
-Create_func_json_merge::create_native(THD *thd, LEX_STRING name,
+Create_func_json_merge::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func;
@@ -5436,7 +5438,7 @@ Create_func_json_merge::create_native(THD *thd, LEX_STRING name,
if (item_list == NULL ||
(arg_count= item_list->elements) < 2) // json, json
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
func= NULL;
}
else
@@ -5451,7 +5453,7 @@ Create_func_json_merge::create_native(THD *thd, LEX_STRING name,
Create_func_json_contains Create_func_json_contains::s_singleton;
Item*
-Create_func_json_contains::create_native(THD *thd, LEX_STRING name,
+Create_func_json_contains::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5466,7 +5468,7 @@ Create_func_json_contains::create_native(THD *thd, LEX_STRING name,
}
else
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
return func;
@@ -5476,7 +5478,7 @@ Create_func_json_contains::create_native(THD *thd, LEX_STRING name,
Create_func_json_keys Create_func_json_keys::s_singleton;
Item*
-Create_func_json_keys::create_native(THD *thd, LEX_STRING name,
+Create_func_json_keys::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5487,7 +5489,7 @@ Create_func_json_keys::create_native(THD *thd, LEX_STRING name,
if (arg_count < 1 || arg_count > 2 /* json_doc, [path]...*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5501,7 +5503,7 @@ Create_func_json_keys::create_native(THD *thd, LEX_STRING name,
Create_func_json_contains_path Create_func_json_contains_path::s_singleton;
Item*
-Create_func_json_contains_path::create_native(THD *thd, LEX_STRING name,
+Create_func_json_contains_path::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5512,7 +5514,7 @@ Create_func_json_contains_path::create_native(THD *thd, LEX_STRING name,
if (arg_count < 3 /* json_doc, one_or_all, path, [path]...*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5526,7 +5528,7 @@ Create_func_json_contains_path::create_native(THD *thd, LEX_STRING name,
Create_func_json_extract Create_func_json_extract::s_singleton;
Item*
-Create_func_json_extract::create_native(THD *thd, LEX_STRING name,
+Create_func_json_extract::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5537,7 +5539,7 @@ Create_func_json_extract::create_native(THD *thd, LEX_STRING name,
if (arg_count < 2 /* json_doc, path, [path]...*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5551,7 +5553,7 @@ Create_func_json_extract::create_native(THD *thd, LEX_STRING name,
Create_func_json_search Create_func_json_search::s_singleton;
Item*
-Create_func_json_search::create_native(THD *thd, LEX_STRING name,
+Create_func_json_search::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5562,7 +5564,7 @@ Create_func_json_search::create_native(THD *thd, LEX_STRING name,
if (arg_count < 3 /* json_doc, one_or_all, search_str, [escape_char[, path]...*/)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
else
{
@@ -5576,7 +5578,7 @@ Create_func_json_search::create_native(THD *thd, LEX_STRING name,
Create_func_last_insert_id Create_func_last_insert_id::s_singleton;
Item*
-Create_func_last_insert_id::create_native(THD *thd, LEX_STRING name,
+Create_func_last_insert_id::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5601,7 +5603,7 @@ Create_func_last_insert_id::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -5622,7 +5624,7 @@ Create_func_lcase::create_1_arg(THD *thd, Item *arg1)
Create_func_least Create_func_least::s_singleton;
Item*
-Create_func_least::create_native(THD *thd, LEX_STRING name,
+Create_func_least::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
int arg_count= 0;
@@ -5632,7 +5634,7 @@ Create_func_least::create_native(THD *thd, LEX_STRING name,
if (arg_count < 2)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -5693,7 +5695,7 @@ Create_func_load_file::create_1_arg(THD *thd, Item *arg1)
Create_func_locate Create_func_locate::s_singleton;
Item*
-Create_func_locate::create_native(THD *thd, LEX_STRING name,
+Create_func_locate::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5722,7 +5724,7 @@ Create_func_locate::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -5734,7 +5736,7 @@ Create_func_locate::create_native(THD *thd, LEX_STRING name,
Create_func_log Create_func_log::s_singleton;
Item*
-Create_func_log::create_native(THD *thd, LEX_STRING name,
+Create_func_log::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5759,7 +5761,7 @@ Create_func_log::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -5825,7 +5827,7 @@ Create_func_maketime::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3)
Create_func_make_set Create_func_make_set::s_singleton;
Item*
-Create_func_make_set::create_native(THD *thd, LEX_STRING name,
+Create_func_make_set::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
int arg_count= 0;
@@ -5835,7 +5837,7 @@ Create_func_make_set::create_native(THD *thd, LEX_STRING name,
if (arg_count < 2)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
@@ -5846,7 +5848,7 @@ Create_func_make_set::create_native(THD *thd, LEX_STRING name,
Create_func_master_pos_wait Create_func_master_pos_wait::s_singleton;
Item*
-Create_func_master_pos_wait::create_native(THD *thd, LEX_STRING name,
+Create_func_master_pos_wait::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
@@ -5860,7 +5862,7 @@ Create_func_master_pos_wait::create_native(THD *thd, LEX_STRING name,
if (arg_count < 2 || arg_count > 4)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return func;
}
@@ -5897,7 +5899,7 @@ Create_func_master_pos_wait::create_native(THD *thd, LEX_STRING name,
Create_func_master_gtid_wait Create_func_master_gtid_wait::s_singleton;
Item*
-Create_func_master_gtid_wait::create_native(THD *thd, LEX_STRING name,
+Create_func_master_gtid_wait::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -5910,7 +5912,7 @@ Create_func_master_gtid_wait::create_native(THD *thd, LEX_STRING name,
if (arg_count < 1 || arg_count > 2)
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return func;
}
@@ -6143,7 +6145,7 @@ Create_func_radians::create_1_arg(THD *thd, Item *arg1)
Create_func_rand Create_func_rand::s_singleton;
Item*
-Create_func_rand::create_native(THD *thd, LEX_STRING name,
+Create_func_rand::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -6181,7 +6183,7 @@ Create_func_rand::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -6213,7 +6215,7 @@ Create_func_reverse::create_1_arg(THD *thd, Item *arg1)
Create_func_round Create_func_round::s_singleton;
Item*
-Create_func_round::create_native(THD *thd, LEX_STRING name,
+Create_func_round::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -6239,7 +6241,7 @@ Create_func_round::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -6522,7 +6524,7 @@ Create_func_unhex::create_1_arg(THD *thd, Item *arg1)
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
Item*
-Create_func_unix_timestamp::create_native(THD *thd, LEX_STRING name,
+Create_func_unix_timestamp::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -6546,7 +6548,7 @@ Create_func_unix_timestamp::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -6677,7 +6679,7 @@ Create_func_y::create_1_arg(THD *thd, Item *arg1)
Create_func_year_week Create_func_year_week::s_singleton;
Item*
-Create_func_year_week::create_native(THD *thd, LEX_STRING name,
+Create_func_year_week::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
Item *func= NULL;
@@ -6703,7 +6705,7 @@ Create_func_year_week::create_native(THD *thd, LEX_STRING name,
}
default:
{
- my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
break;
}
}
@@ -6714,7 +6716,7 @@ Create_func_year_week::create_native(THD *thd, LEX_STRING name,
struct Native_func_registry
{
- LEX_STRING name;
+ LEX_CSTRING name;
Create_func *builder;
};
@@ -7143,15 +7145,15 @@ void item_create_cleanup()
}
Create_func *
-find_native_function_builder(THD *thd, LEX_STRING name)
+find_native_function_builder(THD *thd, const LEX_CSTRING *name)
{
Native_func_registry *func;
Create_func *builder= NULL;
/* Thread safe */
- func= (Native_func_registry*) my_hash_search(& native_functions_hash,
- (uchar*) name.str,
- name.length);
+ func= (Native_func_registry*) my_hash_search(&native_functions_hash,
+ (uchar*) name->str,
+ name->length);
if (func)
{
diff --git a/sql/item_create.h b/sql/item_create.h
index 05fe48f656a..a2d985dd3e8 100644
--- a/sql/item_create.h
+++ b/sql/item_create.h
@@ -56,7 +56,7 @@ public:
@param item_list The list of arguments to the function, can be NULL
@return An item representing the parsed function call, or NULL
*/
- virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list) = 0;
+ virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list) = 0;
protected:
/** Constructor */
@@ -83,7 +83,8 @@ public:
@param item_list The list of arguments to the function, can be NULL
@return An item representing the parsed function call
*/
- virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_func(THD *thd, LEX_CSTRING *name,
+ List<Item> *item_list);
/**
The builder create method, for qualified functions.
@@ -94,7 +95,7 @@ public:
@param item_list The list of arguments to the function, can be NULL
@return An item representing the parsed function call
*/
- virtual Item *create_with_db(THD *thd, LEX_STRING db, LEX_STRING name,
+ virtual Item *create_with_db(THD *thd, LEX_CSTRING *db, LEX_CSTRING *name,
bool use_explicit_name,
List<Item> *item_list) = 0;
@@ -112,7 +113,8 @@ protected:
@param name The native function name
@return The native function builder associated with the name, or NULL
*/
-extern Create_func * find_native_function_builder(THD *thd, LEX_STRING name);
+extern Create_func *find_native_function_builder(THD *thd,
+ const LEX_CSTRING *name);
/**
@@ -131,7 +133,8 @@ extern Create_qfunc * find_qualified_function_builder(THD *thd);
class Create_udf_func : public Create_func
{
public:
- virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
+ virtual Item *create_func(THD *thd, LEX_CSTRING *name,
+ List<Item> *item_list);
/**
The builder create method, for User Defined Functions.
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 96057ec31f5..4f3cc54b42e 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -59,7 +59,7 @@
#define sp_restore_security_context(A,B) while (0) {}
#endif
-bool check_reserved_words(LEX_STRING *name)
+bool check_reserved_words(const LEX_CSTRING *name)
{
if (!my_strcasecmp(system_charset_info, name->str, "GLOBAL") ||
!my_strcasecmp(system_charset_info, name->str, "LOCAL") ||
@@ -1106,7 +1106,7 @@ err:
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE,
ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE),
- name, 1L);
+ name.str, 1L);
return dec;
}
@@ -1149,7 +1149,7 @@ double Item_double_typecast::val_real()
Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE,
ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE),
- name, 1);
+ name.str, (ulong) 1);
if (error < 0)
{
null_value= 1; // Illegal value
@@ -3291,7 +3291,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
!(f_args.maybe_null= (char*) thd->alloc(arg_count * sizeof(char))) ||
!(num_buffer= (char*) thd->alloc(arg_count *
ALIGN_SIZE(sizeof(double)))) ||
- !(f_args.attributes= (char**) thd->alloc(arg_count *
+ !(f_args.attributes= (const char**) thd->alloc(arg_count *
sizeof(char *))) ||
!(f_args.attribute_lengths= (ulong*) thd->alloc(arg_count *
sizeof(long))))
@@ -3321,8 +3321,8 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
f_args.lengths[i]= arguments[i]->max_length;
f_args.maybe_null[i]= (char) arguments[i]->maybe_null;
- f_args.attributes[i]= arguments[i]->name;
- f_args.attribute_lengths[i]= arguments[i]->name_length;
+ f_args.attributes[i]= arguments[i]->name.str;
+ f_args.attribute_lengths[i]= arguments[i]->name.length;
if (arguments[i]->const_item())
{
@@ -3690,7 +3690,7 @@ longlong Item_master_pos_wait::val_int()
longlong pos = (ulong)args[1]->val_int();
longlong timeout = (arg_count>=3) ? args[2]->val_int() : 0 ;
String connection_name_buff;
- LEX_STRING connection_name;
+ LEX_CSTRING connection_name;
Master_info *mi= NULL;
if (arg_count >= 4)
{
@@ -3698,7 +3698,7 @@ longlong Item_master_pos_wait::val_int()
if (!(con= args[3]->val_str(&connection_name_buff)))
goto err;
- connection_name.str= (char*) con->ptr();
+ connection_name.str= con->ptr();
connection_name.length= con->length();
if (check_master_connection_name(&connection_name))
{
@@ -4398,16 +4398,16 @@ bool Item_func_user_var::check_vcol_func_processor(void *arg)
#define extra_size sizeof(double)
-user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
- bool create_if_not_exists)
+user_var_entry *get_variable(HASH *hash, LEX_CSTRING *name,
+ bool create_if_not_exists)
{
user_var_entry *entry;
- if (!(entry = (user_var_entry*) my_hash_search(hash, (uchar*) name.str,
- name.length)) &&
+ if (!(entry = (user_var_entry*) my_hash_search(hash, (uchar*) name->str,
+ name->length)) &&
create_if_not_exists)
{
- uint size=ALIGN_SIZE(sizeof(user_var_entry))+name.length+1+extra_size;
+ uint size=ALIGN_SIZE(sizeof(user_var_entry))+name->length+1+extra_size;
if (!my_hash_inited(hash))
return 0;
if (!(entry = (user_var_entry*) my_malloc(size,
@@ -4416,7 +4416,7 @@ user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
return 0;
entry->name.str=(char*) entry+ ALIGN_SIZE(sizeof(user_var_entry))+
extra_size;
- entry->name.length=name.length;
+ entry->name.length=name->length;
entry->value=0;
entry->length=0;
entry->update_query_id=0;
@@ -4434,7 +4434,7 @@ user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
*/
entry->used_query_id=current_thd->query_id;
entry->type=STRING_RESULT;
- memcpy(entry->name.str, name.str, name.length+1);
+ memcpy((char*) entry->name.str, name->str, name->length+1);
if (my_hash_insert(hash,(uchar*) entry))
{
my_free(entry);
@@ -4456,7 +4456,7 @@ bool Item_func_set_user_var::set_entry(THD *thd, bool create_if_not_exists)
{
if (m_var_entry && thd->thread_id == entry_thread_id)
goto end; // update entry->update_query_id for PS
- if (!(m_var_entry= get_variable(&thd->user_vars, name, create_if_not_exists)))
+ if (!(m_var_entry= get_variable(&thd->user_vars, &name, create_if_not_exists)))
{
entry_thread_id= 0;
return TRUE;
@@ -5090,8 +5090,8 @@ void Item_func_set_user_var::make_field(THD *thd, Send_field *tmp_field)
{
result_field->make_field(tmp_field);
DBUG_ASSERT(tmp_field->table_name != 0);
- if (Item::name)
- tmp_field->col_name=Item::name; // Use user supplied name
+ if (Item::name.str)
+ tmp_field->col_name= Item::name; // Use user supplied name
}
else
Item::make_field(thd, tmp_field);
@@ -5259,7 +5259,7 @@ longlong Item_func_get_user_var::val_int()
static int
get_var_with_binlog(THD *thd, enum_sql_command sql_command,
- LEX_STRING &name, user_var_entry **out_entry)
+ LEX_CSTRING *name, user_var_entry **out_entry)
{
BINLOG_USER_VAR_EVENT *user_var_event;
user_var_entry *var_entry;
@@ -5385,7 +5385,7 @@ void Item_func_get_user_var::fix_length_and_dec()
decimals=NOT_FIXED_DEC;
max_length=MAX_BLOB_WIDTH;
- error= get_var_with_binlog(thd, thd->lex->sql_command, name, &m_var_entry);
+ error= get_var_with_binlog(thd, thd->lex->sql_command, &name, &m_var_entry);
/*
If the variable didn't exist it has been created as a STRING-type.
@@ -5462,7 +5462,8 @@ bool Item_func_get_user_var::eq(const Item *item, bool binary_cmp) const
bool Item_func_get_user_var::set_value(THD *thd,
sp_rcontext * /*ctx*/, Item **it)
{
- Item_func_set_user_var *suv= new (thd->mem_root) Item_func_set_user_var(thd, get_name(), *it);
+ LEX_CSTRING tmp_name= get_name();
+ Item_func_set_user_var *suv= new (thd->mem_root) Item_func_set_user_var(thd, &tmp_name, *it);
/*
Item_func_set_user_var is not fixed after construction, call
fix_fields().
@@ -5476,7 +5477,7 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref)
DBUG_ASSERT(fixed == 0);
DBUG_ASSERT(thd->lex->exchange);
if (Item::fix_fields(thd, ref) ||
- !(entry= get_variable(&thd->user_vars, name, 1)))
+ !(entry= get_variable(&thd->user_vars, &name, 1)))
return TRUE;
entry->type= STRING_RESULT;
/*
@@ -5543,7 +5544,7 @@ void Item_user_var_as_out_param::print_for_load(THD *thd, String *str)
Item_func_get_system_var::
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):
Item_func(thd), var(var_arg), var_type(var_type_arg),
orig_var_type(var_type_arg), component(*component_arg), cache_present(0)
@@ -5650,8 +5651,8 @@ void Item_func_get_system_var::fix_length_and_dec()
void Item_func_get_system_var::print(String *str, enum_query_type query_type)
{
- if (name_length)
- str->append(name, name_length);
+ if (name.length)
+ str->append(name.str, name.length);
else
{
str->append(STRING_WITH_LEN("@@"));
@@ -6211,11 +6212,11 @@ longlong Item_func_bit_xor::val_int()
*/
-Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
- LEX_STRING component)
+Item *get_system_var(THD *thd, enum_var_type var_type, LEX_CSTRING name,
+ LEX_CSTRING component)
{
sys_var *var;
- LEX_STRING *base_name, *component_name;
+ LEX_CSTRING *base_name, *component_name;
if (component.str)
{
@@ -6318,7 +6319,7 @@ Item_func_sp::func_name() const
}
-void my_missing_function_error(const LEX_STRING &token, const char *func_name)
+void my_missing_function_error(const LEX_CSTRING &token, const char *func_name)
{
if (token.length && is_lex_native_function (&token))
my_error(ER_FUNC_INEXISTENT_NAME_COLLISION, MYF(0), func_name);
@@ -6348,7 +6349,6 @@ void my_missing_function_error(const LEX_STRING &token, const char *func_name)
bool
Item_func_sp::init_result_field(THD *thd)
{
- LEX_STRING empty_name= { C_STRING_WITH_LEN("") };
TABLE_SHARE *share;
DBUG_ENTER("Item_func_sp::init_result_field");
@@ -6374,11 +6374,10 @@ Item_func_sp::init_result_field(THD *thd)
dummy_table->maybe_null = maybe_null;
dummy_table->in_use= thd;
dummy_table->copy_blobs= TRUE;
- share->table_cache_key = empty_name;
- share->table_name = empty_name;
+ share->table_cache_key= empty_clex_str;
+ share->table_name= empty_clex_str;
- if (!(sp_result_field= m_sp->create_result_field(max_length, name,
- dummy_table)))
+ if (!(sp_result_field= m_sp->create_result_field(max_length, &name, dummy_table)))
{
DBUG_RETURN(TRUE);
}
@@ -6531,8 +6530,11 @@ Item_func_sp::make_field(THD *thd, Send_field *tmp_field)
DBUG_ENTER("Item_func_sp::make_field");
DBUG_ASSERT(sp_result_field);
sp_result_field->make_field(tmp_field);
- if (name)
+ if (name.str)
+ {
+ DBUG_ASSERT(name.length == strlen(name.str));
tmp_field->col_name= name;
+ }
DBUG_VOID_RETURN;
}
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);
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 7ac2e054e8c..e361793f77d 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -43,7 +43,7 @@
Field *Item_geometry_func::create_field_for_create_select(TABLE *t_arg)
{
Field *result;
- if ((result= new Field_geom(max_length, maybe_null, name, t_arg->s,
+ if ((result= new Field_geom(max_length, maybe_null, &name, t_arg->s,
get_geometry_type())))
result->init(t_arg);
return result;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 215bc288f36..0468e990a0d 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -450,7 +450,7 @@ String *Item_func_from_base64::val_str(String *str)
THD *thd= current_thd;
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_BAD_BASE64_DATA, ER_THD(thd, ER_BAD_BASE64_DATA),
- end_ptr - res->ptr());
+ (int) (end_ptr - res->ptr()));
goto err;
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index b04c88e9cd8..8c2afe79d9b 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -44,7 +44,7 @@
double get_post_group_estimate(JOIN* join, double join_op_rows);
-const char *exists_outer_expr_name= "<exists outer expr>";
+LEX_CSTRING exists_outer_expr_name= { STRING_WITH_LEN("<exists outer expr>") };
int check_and_do_in_subquery_rewrites(JOIN *join);
@@ -290,7 +290,6 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
(*ref)= substitution;
substitution->name= name;
- substitution->name_length= name_length;
if (have_to_be_excluded)
engine->exclude();
substitution= 0;
@@ -1879,8 +1878,8 @@ Item_in_subselect::single_value_transformer(JOIN *join)
*/
expr= new (thd->mem_root) Item_direct_ref(thd, &select_lex->context,
(Item**)optimizer->get_cache(),
- (char *)"<no matter>",
- (char *)in_left_expr_name);
+ "<no matter>",
+ &in_left_expr_name);
}
DBUG_RETURN(false);
@@ -2103,6 +2102,8 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
if (join_having || select_lex->with_sum_func ||
select_lex->group_list.elements)
{
+ const char *tmp= this->full_name();
+ LEX_CSTRING field_name= {tmp, safe_strlen(tmp)};
Item *item= func->create(thd, expr,
new (thd->mem_root) Item_ref_null_helper(
thd,
@@ -2111,7 +2112,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
&select_lex->
ref_pointer_array[0],
(char *)"<ref>",
- this->full_name()));
+ &field_name));
if (!abort_on_null && left_expr->maybe_null)
{
/*
@@ -2123,7 +2124,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
}
if (!join_having)
- item->name= (char*) in_having_cond;
+ item->name= in_having_cond;
if (fix_having(item, select_lex))
DBUG_RETURN(true);
*having_item= item;
@@ -2148,7 +2149,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
get_cond_guard(0))))
DBUG_RETURN(true);
}
- having->name= (char*) in_having_cond;
+ having->name= in_having_cond;
if (fix_having(having, select_lex))
DBUG_RETURN(true);
*having_item= having;
@@ -2173,7 +2174,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
single_value_transformer but there is no corresponding action in
row_value_transformer?
*/
- item->name= (char *) in_additional_cond;
+ item->name= in_additional_cond;
if (!item->fixed && item->fix_fields(thd, 0))
DBUG_RETURN(true);
*where_item= item;
@@ -2182,6 +2183,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
{
if (select_lex->master_unit()->is_unit_op())
{
+ LEX_CSTRING field_name= {STRING_WITH_LEN("<result>") };
Item *new_having=
func->create(thd, expr,
new (thd->mem_root) Item_ref_null_helper(thd,
@@ -2189,7 +2191,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
this,
&select_lex->ref_pointer_array[0],
(char *)"<no matter>",
- (char *)"<result>"));
+ &field_name));
if (!abort_on_null && left_expr->maybe_null)
{
disable_cond_guard_for_const_null_left_expr(0);
@@ -2198,7 +2200,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
DBUG_RETURN(true);
}
- new_having->name= (char*) in_having_cond;
+ new_having->name= in_having_cond;
if (fix_having(new_having, select_lex))
DBUG_RETURN(true);
*having_item= new_having;
@@ -2345,7 +2347,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
bool is_having_used= (join_having || select_lex->with_sum_func ||
select_lex->group_list.first ||
!select_lex->table_list.elements);
-
+ LEX_CSTRING list_ref= { STRING_WITH_LEN("<list ref>")};
DBUG_ENTER("Item_in_subselect::create_row_in_to_exists_cond");
DBUG_ASSERT(thd == join->thd);
@@ -2367,6 +2369,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->element_index(i)->cols()))
DBUG_RETURN(true);
+
Item *item_eq=
new (thd->mem_root)
Item_func_eq(thd, new (thd->mem_root)
@@ -2374,12 +2377,12 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
(*optimizer->get_cache())->
addr(i),
(char *)"<no matter>",
- (char *)in_left_expr_name),
+ &in_left_expr_name),
new (thd->mem_root)
Item_ref(thd, &select_lex->context,
&select_lex->ref_pointer_array[i],
(char *)"<no matter>",
- (char *)"<list ref>"));
+ &list_ref));
Item *item_isnull=
new (thd->mem_root)
Item_func_isnull(thd,
@@ -2387,7 +2390,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
Item_ref(thd, &select_lex->context,
&select_lex->ref_pointer_array[i],
(char *)"<no matter>",
- (char *)"<list ref>"));
+ &list_ref));
Item *col_item= new (thd->mem_root)
Item_cond_or(thd, item_eq, item_isnull);
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
@@ -2407,7 +2410,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
&select_lex->
ref_pointer_array[i],
(char *)"<no matter>",
- (char *)"<list ref>"));
+ &list_ref));
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
{
disable_cond_guard_for_const_null_left_expr(i);
@@ -2441,13 +2444,13 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
(*optimizer->get_cache())->
addr(i),
(char *)"<no matter>",
- (char *)in_left_expr_name),
+ &in_left_expr_name),
new (thd->mem_root)
Item_direct_ref(thd, &select_lex->context,
&select_lex->
ref_pointer_array[i],
(char *)"<no matter>",
- (char *)"<list ref>"));
+ &list_ref));
if (!abort_on_null && select_lex->ref_pointer_array[i]->maybe_null)
{
Item *having_col_item=
@@ -2457,8 +2460,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
Item_ref(thd, &select_lex->context,
&select_lex->ref_pointer_array[i],
(char *)"<no matter>",
- (char *)"<list ref>"));
-
+ &list_ref));
item_isnull= new (thd->mem_root)
Item_func_isnull(thd,
@@ -2467,7 +2469,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
&select_lex->
ref_pointer_array[i],
(char *)"<no matter>",
- (char *)"<list ref>"));
+ &list_ref));
item= new (thd->mem_root) Item_cond_or(thd, item, item_isnull);
if (left_expr->element_index(i)->maybe_null)
{
@@ -2501,7 +2503,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
if (*having_item)
{
if (!join_having)
- (*having_item)->name= (char*) in_having_cond;
+ (*having_item)->name= in_having_cond;
if (fix_having(*having_item, select_lex))
DBUG_RETURN(true);
(*having_item)->top_level_item();
@@ -2976,7 +2978,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
Item_direct_ref(thd, &first_select->context,
(Item**)optimizer->get_cache(),
(char *)"<no matter>",
- (char *)in_left_expr_name);
+ &in_left_expr_name);
if (in_subs->fix_fields(thd, optimizer->arguments() + 1))
{
res= TRUE;
@@ -3047,7 +3049,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
&unit->outer_select()->context,
optimizer->arguments(),
(char *)"<no matter>",
- (char *)exists_outer_expr_name)),
+ &exists_outer_expr_name)),
optimizer) :
(Item *)optimizer);
}
@@ -3071,7 +3073,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
&unit->outer_select()->context,
optimizer->arguments()[0]->addr(i),
(char *)"<no matter>",
- (char *)exists_outer_expr_name)),
+ &exists_outer_expr_name)),
thd->mem_root);
}
}
@@ -4333,7 +4335,7 @@ void subselect_union_engine::print(String *str, enum_query_type query_type)
void subselect_uniquesubquery_engine::print(String *str,
enum_query_type query_type)
{
- char *table_name= tab->table->s->table_name.str;
+ const char *table_name= tab->table->s->table_name.str;
str->append(STRING_WITH_LEN("<primary_index_lookup>("));
tab->ref.items[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" in "));
@@ -4890,7 +4892,7 @@ bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id)
DBUG_RETURN(TRUE);
char buf[32];
- uint len= my_snprintf(buf, sizeof(buf), "<subquery%d>", subquery_id);
+ uint len= my_snprintf(buf, sizeof(buf), "<subquery%u>", subquery_id);
char *name;
if (!(name= (char*)thd->alloc(len + 1)))
DBUG_RETURN(TRUE);
@@ -5933,10 +5935,10 @@ void Ordered_key::print(String *str)
str->append(", (");
for (i= 0; i < key_column_count - 1; i++)
{
- str->append(key_columns[i]->field->field_name);
+ str->append(&key_columns[i]->field->field_name);
str->append(", ");
}
- str->append(key_columns[i]->field->field_name);
+ str->append(&key_columns[i]->field->field_name);
str->append("), ");
str->append("null_bitmap: (bits=");
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index b1c797c4ee3..d95240d6d6d 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1208,9 +1208,8 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table)
if (args[0]->type() == Item::FIELD_ITEM)
{
field= ((Item_field*) args[0])->field;
-
- if ((field= create_tmp_field_from_field(table->in_use, field, name, table,
- NULL)))
+ if ((field= create_tmp_field_from_field(table->in_use, field, &name,
+ table, NULL)))
field->flags&= ~NOT_NULL_FLAG;
return field;
}
@@ -1223,18 +1222,25 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table)
mem_root= table->in_use->mem_root;
switch (args[0]->field_type()) {
case MYSQL_TYPE_DATE:
+ {
field= new (mem_root)
- Field_newdate(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE, name);
+ Field_newdate(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE,
+ &name);
break;
+ }
case MYSQL_TYPE_TIME:
+ {
field= new_Field_time(mem_root, 0, maybe_null ? (uchar*)"" : 0, 0,
- Field::NONE, name, decimals);
+ Field::NONE, &name, decimals);
break;
+ }
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
+ {
field= new_Field_datetime(mem_root, 0, maybe_null ? (uchar*)"" : 0, 0,
- Field::NONE, name, decimals);
+ Field::NONE, &name, decimals);
break;
+ }
default:
return Item_sum::create_tmp_field(group, table);
}
@@ -1676,13 +1682,15 @@ Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table)
field= new (mem_root)
Field_string(((Item_sum_avg::result_type() == DECIMAL_RESULT) ?
dec_bin_size : sizeof(double)) + sizeof(longlong),
- 0, name, &my_charset_bin);
+ 0, &name, &my_charset_bin);
}
else if (Item_sum_avg::result_type() == DECIMAL_RESULT)
field= Field_new_decimal::create_from_item(mem_root, this);
else
- field= new (mem_root) Field_double(max_length, maybe_null, name, decimals,
- TRUE);
+ {
+ field= new (mem_root) Field_double(max_length, maybe_null, &name,
+ decimals, TRUE);
+ }
if (field)
field->init(table);
return field;
@@ -1910,10 +1918,12 @@ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table)
The easiest way is to do this is to store both value in a string
and unpack on access.
*/
- field= new Field_string(sizeof(double)*2 + sizeof(longlong), 0, name, &my_charset_bin);
+ field= new Field_string(sizeof(double)*2 + sizeof(longlong), 0,
+ &name, &my_charset_bin);
}
else
- field= new Field_double(max_length, maybe_null, name, decimals, TRUE);
+ field= new Field_double(max_length, maybe_null, &name, decimals,
+ TRUE);
if (field != NULL)
field->init(table);
@@ -3356,13 +3366,13 @@ Field *Item_func_group_concat::make_string_field(TABLE *table_arg)
{
Field *field;
DBUG_ASSERT(collation.collation);
+
if (too_big_for_varchar())
field= new Field_blob(max_length,
- maybe_null, name, collation.collation, TRUE);
+ maybe_null, &name, collation.collation, TRUE);
else
field= new Field_varstring(max_length,
- maybe_null, name, table_arg->s,
- collation.collation);
+ maybe_null, &name, table_arg->s, collation.collation);
if (field)
field->init(table_arg);
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 98b027de41d..039ae0de1a8 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1239,7 +1239,7 @@ public:
void save_in_result_field(bool no_conversions) { DBUG_ASSERT(0); }
bool check_vcol_func_processor(void *arg)
{
- return mark_unsupported_function(name, arg, VCOL_IMPOSSIBLE);
+ return mark_unsupported_function(name.str, arg, VCOL_IMPOSSIBLE);
}
};
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index a89d0f84cef..01b591e7919 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -13,7 +13,7 @@ Item_window_func::resolve_window_name(THD *thd)
return false;
}
DBUG_ASSERT(window_name != NULL && window_spec == NULL);
- char *ref_name= window_name->str;
+ const char *ref_name= window_name->str;
/* !TODO: Add the code to resolve ref_name in outer queries */
/*
@@ -26,7 +26,7 @@ Item_window_func::resolve_window_name(THD *thd)
Window_spec *win_spec;
while((win_spec= it++))
{
- char *win_spec_name= win_spec->name();
+ const char *win_spec_name= win_spec->name();
if (win_spec_name &&
my_strcasecmp(system_charset_info, ref_name, win_spec_name) == 0)
{
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h
index 193ac04b315..1690d147b26 100644
--- a/sql/item_windowfunc.h
+++ b/sql/item_windowfunc.h
@@ -690,12 +690,12 @@ class Item_window_func : public Item_func_or_sum
{
/* Window function parameters as we've got them from the parser */
public:
- LEX_STRING *window_name;
+ LEX_CSTRING *window_name;
public:
Window_spec *window_spec;
public:
- Item_window_func(THD *thd, Item_sum *win_func, LEX_STRING *win_name)
+ Item_window_func(THD *thd, Item_sum *win_func, LEX_CSTRING *win_name)
: Item_func_or_sum(thd, (Item *) win_func),
window_name(win_name), window_spec(NULL),
force_return_blank(true),
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index 4d848a0f737..90df6e27f6c 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -2594,7 +2594,7 @@ my_xpath_parse_QName(MY_XPATH *xpath)
static int
my_xpath_parse_VariableReference(MY_XPATH *xpath)
{
- LEX_STRING name;
+ LEX_CSTRING name;
int user_var;
const char *dollar_pos;
THD *thd= xpath->thd;
@@ -2609,7 +2609,7 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath)
name.str= (char*) xpath->prevtok.beg;
if (user_var)
- xpath->item= new (thd->mem_root) Item_func_get_user_var(thd, name);
+ xpath->item= new (thd->mem_root) Item_func_get_user_var(thd, &name);
else
{
sp_variable *spv;
@@ -2617,10 +2617,10 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath)
LEX *lex;
if ((lex= thd->lex) &&
(spc= lex->spcont) &&
- (spv= spc->find_variable(name, false)))
+ (spv= spc->find_variable(&name, false)))
{
Item_splocal *splocal= new (thd->mem_root)
- Item_splocal(thd, name, spv->offset, spv->sql_type(), 0);
+ Item_splocal(thd, &name, spv->offset, spv->sql_type(), 0);
#ifndef DBUG_OFF
if (splocal)
splocal->m_sp= lex->sphead;
diff --git a/sql/keycaches.cc b/sql/keycaches.cc
index 78e64ebac72..336f2611a7e 100644
--- a/sql/keycaches.cc
+++ b/sql/keycaches.cc
@@ -99,11 +99,11 @@ void NAMED_ILIST::delete_elements(void (*free_element)(const char *name, uchar*)
/* Key cache functions */
-LEX_STRING default_key_cache_base= {C_STRING_WITH_LEN("default")};
+LEX_CSTRING default_key_cache_base= {C_STRING_WITH_LEN("default")};
KEY_CACHE zero_key_cache; ///< @@nonexistent_cache.param->value_ptr() points here
-KEY_CACHE *get_key_cache(const LEX_STRING *cache_name)
+KEY_CACHE *get_key_cache(const LEX_CSTRING *cache_name)
{
if (!cache_name || ! cache_name->length)
cache_name= &default_key_cache_base;
@@ -145,10 +145,10 @@ KEY_CACHE *create_key_cache(const char *name, uint length)
KEY_CACHE *get_or_create_key_cache(const char *name, uint length)
{
- LEX_STRING key_cache_name;
+ LEX_CSTRING key_cache_name;
KEY_CACHE *key_cache;
- key_cache_name.str= (char *) name;
+ key_cache_name.str= name;
key_cache_name.length= length;
if (!(key_cache= get_key_cache(&key_cache_name)))
key_cache= create_key_cache(name, length);
diff --git a/sql/keycaches.h b/sql/keycaches.h
index fff48d51c6f..1b58dccfe34 100644
--- a/sql/keycaches.h
+++ b/sql/keycaches.h
@@ -35,12 +35,12 @@ class NAMED_ILIST: public I_List<NAMED_ILINK>
};
/* For key cache */
-extern LEX_STRING default_key_cache_base;
+extern LEX_CSTRING default_key_cache_base;
extern KEY_CACHE zero_key_cache;
extern NAMED_ILIST key_caches;
KEY_CACHE *create_key_cache(const char *name, uint length);
-KEY_CACHE *get_key_cache(const LEX_STRING *cache_name);
+KEY_CACHE *get_key_cache(const LEX_CSTRING *cache_name);
KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
void free_key_cache(const char *name, KEY_CACHE *key_cache);
bool process_key_caches(process_key_cache_t func, void *param);
diff --git a/sql/log.cc b/sql/log.cc
index ab6d9031004..83e1724b195 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1012,7 +1012,7 @@ int Log_to_csv_event_handler::
{
TABLE_LIST table_list;
TABLE *table;
- LEX_STRING *UNINIT_VAR(log_name);
+ LEX_CSTRING *UNINIT_VAR(log_name);
int result;
Open_tables_backup open_tables_backup;
diff --git a/sql/log_event.cc b/sql/log_event.cc
index f1f9e65098d..1dca656ee08 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -587,7 +587,7 @@ pretty_print_str(String *packet, const char *str, int len)
*/
static char *load_data_tmp_prefix(char *name,
- LEX_STRING *connection_name)
+ LEX_CSTRING *connection_name)
{
name= strmov(name, PREFIX_SQL_LOAD);
if (connection_name->length)
@@ -623,7 +623,7 @@ static char *load_data_tmp_prefix(char *name,
static char *slave_load_file_stem(char *buf, uint file_id,
int event_server_id, const char *ext,
- LEX_STRING *connection_name)
+ LEX_CSTRING *connection_name)
{
char *res;
res= buf+ unpack_dirname(buf, slave_load_tmpdir);
@@ -644,7 +644,7 @@ static char *slave_load_file_stem(char *buf, uint file_id,
Delete all temporary files used for SQL_LOAD.
*/
-static void cleanup_load_tmpdir(LEX_STRING *connection_name)
+static void cleanup_load_tmpdir(LEX_CSTRING *connection_name)
{
MY_DIR *dirp;
FILEINFO *file;
@@ -3821,8 +3821,8 @@ bool Query_log_event::write()
if (thd && thd->need_binlog_invoker())
{
- LEX_STRING user;
- LEX_STRING host;
+ LEX_CSTRING user;
+ LEX_CSTRING host;
memset(&user, 0, sizeof(user));
memset(&host, 0, sizeof(host));
@@ -3845,7 +3845,7 @@ bool Query_log_event::write()
else
{
user.str= ctx->priv_role;
- host= empty_lex_str;
+ host= empty_clex_str;
}
user.length= strlen(user.str);
}
@@ -4499,22 +4499,20 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
if (user.length)
{
- copy_str_and_move((const char **)&(user.str), &start, user.length);
+ copy_str_and_move(&user.str, &start, user.length);
}
else
{
- user.str= (char *) start++;
- user.str[0]= '\0';
+ user.str= (char*) start;
+ *(start++)= 0;
}
if (host.length)
- {
- copy_str_and_move((const char **)&(host.str), &start, host.length);
- }
+ copy_str_and_move(&host.str, &start, host.length);
else
{
- host.str= (char *) start++;
- host.str[0]= '\0';
+ host.str= (char*) start;
+ *(start++)= 0;
}
/**
@@ -6559,9 +6557,9 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
while ((item = li++))
{
num_fields++;
- uchar len = (uchar) strlen(item->name);
+ uchar len= (uchar) item->name.length;
field_block_len += len + 1;
- fields_buf.append(item->name, len + 1);
+ fields_buf.append(item->name.str, len + 1);
field_lens_buf.append((char*)&len, 1);
}
@@ -6787,9 +6785,10 @@ void Load_log_event::set_fields(const char* affected_db,
const char* field = fields;
for (i= 0; i < num_fields; i++)
{
+ LEX_CSTRING field_name= {field, field_lens[i] };
field_list.push_back(new (thd->mem_root)
Item_field(thd, context, affected_db, table_name,
- field),
+ &field_name),
thd->mem_root);
field+= field_lens[i] + 1;
}
@@ -8906,7 +8905,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
if (!(charset= get_charset(charset_number, MYF(MY_WME))))
DBUG_RETURN(1);
- LEX_STRING user_var_name;
+ LEX_CSTRING user_var_name;
user_var_name.str= name;
user_var_name.length= name_len;
double real_val;
@@ -8949,7 +8948,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
}
}
- Item_func_set_user_var *e= new (thd->mem_root) Item_func_set_user_var(thd, user_var_name, it);
+ Item_func_set_user_var *e= new (thd->mem_root) Item_func_set_user_var(thd, &user_var_name, it);
/*
Item_func_set_user_var can't substitute something else on its place =>
0 can be passed as last argument (reference on item)
@@ -8966,7 +8965,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
a single record and with a single column. Thus, like
a column value, it could always have IMPLICIT derivation.
*/
- e->update_hash(val, val_len, type, charset,
+ e->update_hash((void*) val, val_len, type, charset,
(flags & User_var_log_event::UNSIGNED_F));
if (!is_deferred())
free_root(thd->mem_root, 0);
diff --git a/sql/log_event.h b/sql/log_event.h
index 57692803b5b..e79c88c28f1 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -2013,8 +2013,8 @@ protected:
*/
class Query_log_event: public Log_event
{
- LEX_STRING user;
- LEX_STRING host;
+ LEX_CSTRING user;
+ LEX_CSTRING host;
protected:
Log_event::Byte* data_buf;
public:
@@ -3041,9 +3041,9 @@ public:
UNDEF_F= 0,
UNSIGNED_F= 1
};
- char *name;
+ const char *name;
uint name_len;
- char *val;
+ const char *val;
ulong val_len;
Item_result type;
uint charset_number;
@@ -3052,8 +3052,8 @@ public:
#ifdef MYSQL_SERVER
bool deferred;
query_id_t query_id;
- User_var_log_event(THD* thd_arg, char *name_arg, uint name_len_arg,
- char *val_arg, ulong val_len_arg, Item_result type_arg,
+ User_var_log_event(THD* thd_arg, const char *name_arg, uint name_len_arg,
+ const char *val_arg, ulong val_len_arg, Item_result type_arg,
uint charset_number_arg, uchar flags_arg,
bool using_trans, bool direct)
:Log_event(thd_arg, 0, using_trans),
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index c497a41673e..915387d6ba9 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -297,6 +297,7 @@ static TYPELIB tc_heuristic_recover_typelib=
const char *first_keyword= "first", *binary_keyword= "BINARY";
const char *my_localhost= "localhost", *delayed_user= "DELAYED";
+const char *quoted_string= "%`s";
bool opt_large_files= sizeof(my_off_t) > 4;
static my_bool opt_autocommit; ///< for --autocommit command-line option
@@ -629,10 +630,10 @@ my_bool encrypt_binlog;
my_bool encrypt_tmp_disk_tables, encrypt_tmp_files;
/** name of reference on left expression in rewritten IN subquery */
-const char *in_left_expr_name= "<left expr>";
+const LEX_CSTRING in_left_expr_name= {STRING_WITH_LEN("<left expr>") };
/** name of additional condition */
-const char *in_additional_cond= "<IN COND>";
-const char *in_having_cond= "<IN HAVING>";
+const LEX_CSTRING in_having_cond= {STRING_WITH_LEN("<IN HAVING>") };
+const LEX_CSTRING in_additional_cond= {STRING_WITH_LEN("<IN COND>") };
/** Number of connection errors when selecting on the listening port */
ulong connection_errors_select= 0;
@@ -4884,7 +4885,7 @@ static int init_default_storage_engine_impl(const char *opt_name,
return 0;
}
- LEX_STRING name= { engine_name, strlen(engine_name) };
+ LEX_CSTRING name= { engine_name, strlen(engine_name) };
plugin_ref plugin;
handlerton *hton;
if ((plugin= ha_resolve_by_name(0, &name, false)))
@@ -5323,7 +5324,7 @@ static int init_server_components()
else
{
/* fall back to the log files if tables are not present */
- LEX_STRING csv_name={C_STRING_WITH_LEN("csv")};
+ LEX_CSTRING csv_name={STRING_WITH_LEN("csv")};
if (!plugin_is_ready(&csv_name, MYSQL_STORAGE_ENGINE_PLUGIN))
{
/* purecov: begin inspected */
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 9f9e9a3ae66..edda7e530fe 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -237,7 +237,7 @@ extern const char *first_keyword, *delayed_user, *binary_keyword;
extern MYSQL_PLUGIN_IMPORT const char *my_localhost;
extern MYSQL_PLUGIN_IMPORT const char **errmesg; /* Error messages */
extern const char *myisam_recover_options_str;
-extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
+extern const LEX_CSTRING in_left_expr_name, in_additional_cond, in_having_cond;
extern SHOW_VAR status_vars[];
extern struct system_variables max_system_variables;
extern struct system_status_var global_status_var;
@@ -270,6 +270,7 @@ extern my_bool encrypt_binlog;
extern my_bool encrypt_tmp_disk_tables, encrypt_tmp_files;
extern ulong encryption_algorithm;
extern const char *encryption_algorithm_names[];
+extern const char *quoted_string;
#ifdef HAVE_PSI_INTERFACE
#ifdef HAVE_MMAP
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index fbdbf76ffd9..881e6de6085 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -4398,7 +4398,7 @@ static void print_partitioning_index(KEY_PART *parts, KEY_PART *parts_end)
fprintf(DBUG_FILE, "partitioning INDEX(");
for (KEY_PART *p=parts; p != parts_end; p++)
{
- fprintf(DBUG_FILE, "%s%s", p==parts?"":" ,", p->field->field_name);
+ fprintf(DBUG_FILE, "%s%s", p==parts?"":" ,", p->field->field_name.str);
}
fputs(");\n", DBUG_FILE);
DBUG_UNLOCK_FILE;
@@ -4437,7 +4437,7 @@ static void dbug_print_segment_range(SEL_ARG *arg, KEY_PART *part)
fputs(" <= ", DBUG_FILE);
}
- fprintf(DBUG_FILE, "%s", part->field->field_name);
+ fprintf(DBUG_FILE, "%s", part->field->field_name.str);
if (!(arg->max_flag & NO_MAX_RANGE))
{
@@ -4476,7 +4476,7 @@ static void dbug_print_singlepoint_range(SEL_ARG **start, uint num)
for (SEL_ARG **arg= start; arg != end; arg++)
{
Field *field= (*arg)->field;
- fprintf(DBUG_FILE, "%s%s=", (arg==start)?"":", ", field->field_name);
+ fprintf(DBUG_FILE, "%s%s=", (arg==start)?"":", ", field->field_name.str);
dbug_print_field(field);
}
fputs("\n", DBUG_FILE);
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 1c621c1c833..b5808ea9315 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -4019,12 +4019,13 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd)
/* Create the field */
{
+ LEX_CSTRING field_name= {STRING_WITH_LEN("rowids") };
/*
For the sake of uniformity, always use Field_varstring (altough we could
use Field_string for shorter keys)
*/
- field= new Field_varstring(uniq_tuple_length_arg, FALSE, "rowids", share,
- &my_charset_bin);
+ field= new Field_varstring(uniq_tuple_length_arg, FALSE, &field_name,
+ share, &my_charset_bin);
if (!field)
DBUG_RETURN(0);
field->table= table;
@@ -4894,7 +4895,7 @@ int rewrite_to_index_subquery_engine(JOIN *join)
{
Item *where= join->conds;
if (join_tab[0].type == JT_EQ_REF &&
- join_tab[0].ref.items[0]->name == in_left_expr_name)
+ join_tab[0].ref.items[0]->name.str == in_left_expr_name.str)
{
remove_subq_pushed_predicates(join, &where);
save_index_subquery_explain_info(join_tab, where);
@@ -4908,7 +4909,7 @@ int rewrite_to_index_subquery_engine(JOIN *join)
where)));
}
else if (join_tab[0].type == JT_REF &&
- join_tab[0].ref.items[0]->name == in_left_expr_name)
+ join_tab[0].ref.items[0]->name.str == in_left_expr_name.str)
{
remove_subq_pushed_predicates(join, &where);
save_index_subquery_explain_info(join_tab, where);
@@ -4924,8 +4925,8 @@ int rewrite_to_index_subquery_engine(JOIN *join)
0)));
}
} else if (join_tab[0].type == JT_REF_OR_NULL &&
- join_tab[0].ref.items[0]->name == in_left_expr_name &&
- join->having->name == in_having_cond)
+ join_tab[0].ref.items[0]->name.str == in_left_expr_name.str &&
+ join->having->name.str == in_having_cond.str)
{
join_tab[0].type= JT_INDEX_SUBQUERY;
join->error= 0;
@@ -4956,7 +4957,7 @@ int rewrite_to_index_subquery_engine(JOIN *join)
static Item *remove_additional_cond(Item* conds)
{
- if (conds->name == in_additional_cond)
+ if (conds->name.str == in_additional_cond.str)
return 0;
if (conds->type() == Item::COND_ITEM)
{
@@ -4965,7 +4966,7 @@ static Item *remove_additional_cond(Item* conds)
Item *item;
while ((item= li++))
{
- if (item->name == in_additional_cond)
+ if (item->name.str == in_additional_cond.str)
{
li.remove();
if (cnd->argument_list()->elements == 1)
diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc
index b7010d1f8ed..d3d1bc97a70 100644
--- a/sql/opt_table_elimination.cc
+++ b/sql/opt_table_elimination.cc
@@ -1843,7 +1843,7 @@ void Dep_analysis_context::dbug_print_deps()
(long)(eq_mod - equality_mods),
str.c_ptr(),
eq_mod->field->table->table->alias.c_ptr(),
- eq_mod->field->field->field_name);
+ eq_mod->field->field->field_name.str);
}
else
{
@@ -1867,7 +1867,7 @@ void Dep_analysis_context::dbug_print_deps()
{
fprintf(DBUG_FILE, " field %s.%s ->",
table_dep->table->alias.c_ptr(),
- field_dep->field->field_name);
+ field_dep->field->field_name.str);
uint ofs= field_dep->bitmap_offset;
for (uint bit= ofs; bit < ofs + n_equality_mods; bit++)
{
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index 1cd294c1c7a..b091259d273 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -136,7 +136,7 @@ static ulonglong view_algo_from_frm(ulonglong val)
static my_bool
-write_parameter(IO_CACHE *file, uchar* base, File_option *parameter)
+write_parameter(IO_CACHE *file, const uchar* base, File_option *parameter)
{
char num_buf[20]; // buffer for numeric operations
// string for numeric operations
@@ -248,8 +248,9 @@ write_parameter(IO_CACHE *file, uchar* base, File_option *parameter)
my_bool
-sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
- const LEX_STRING *type,
+sql_create_definition_file(const LEX_CSTRING *dir,
+ const LEX_CSTRING *file_name,
+ const LEX_CSTRING *type,
uchar* base, File_option *parameters)
{
File handler;
@@ -399,7 +400,7 @@ my_bool rename_in_schema_file(THD *thd,
*/
File_parser *
-sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
+sql_parse_prepare(const LEX_CSTRING *file_name, MEM_ROOT *mem_root,
bool bad_format_errors)
{
MY_STAT stat_info;
@@ -598,13 +599,13 @@ read_escaped_string(const char *ptr, const char *eol, LEX_STRING *str)
const char *
parse_escaped_string(const char *ptr, const char *end, MEM_ROOT *mem_root,
- LEX_STRING *str)
+ LEX_CSTRING *str)
{
const char *eol= strchr(ptr, '\n');
if (eol == 0 || eol >= end ||
!(str->str= (char*) alloc_root(mem_root, (eol - ptr) + 1)) ||
- read_escaped_string(ptr, eol, str))
+ read_escaped_string(ptr, eol, (LEX_STRING*) str))
return 0;
return eol+1;
@@ -802,7 +803,7 @@ File_parser::parse(uchar* base, MEM_ROOT *mem_root,
case FILE_OPTIONS_ESTRING:
{
if (!(ptr= parse_escaped_string(ptr, end, mem_root,
- (LEX_STRING *)
+ (LEX_CSTRING *)
(base + parameter->offset))))
{
my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
diff --git a/sql/parse_file.h b/sql/parse_file.h
index 87917dbd71b..3f48b2072db 100644
--- a/sql/parse_file.h
+++ b/sql/parse_file.h
@@ -42,7 +42,7 @@ enum file_opt_type {
struct File_option
{
- LEX_STRING name; /**< Name of the option */
+ LEX_CSTRING name; /**< Name of the option */
my_ptrdiff_t offset; /**< offset to base address of value */
file_opt_type type; /**< Option type */
};
@@ -82,15 +82,16 @@ bool get_file_options_ulllist(const char *&ptr, const char *end,
const char *
parse_escaped_string(const char *ptr, const char *end, MEM_ROOT *mem_root,
- LEX_STRING *str);
+ LEX_CSTRING *str);
class File_parser;
-File_parser *sql_parse_prepare(const LEX_STRING *file_name,
+File_parser *sql_parse_prepare(const LEX_CSTRING *file_name,
MEM_ROOT *mem_root, bool bad_format_errors);
my_bool
-sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
- const LEX_STRING *type,
+sql_create_definition_file(const LEX_CSTRING *dir,
+ const LEX_CSTRING *file_name,
+ const LEX_CSTRING *type,
uchar* base, File_option *parameters);
my_bool rename_in_schema_file(THD *thd,
const char *schema, const char *old_name,
@@ -99,19 +100,19 @@ my_bool rename_in_schema_file(THD *thd,
class File_parser: public Sql_alloc
{
char *start, *end;
- LEX_STRING file_type;
+ LEX_CSTRING file_type;
bool content_ok;
public:
File_parser() :start(0), end(0), content_ok(0)
{ file_type.str= 0; file_type.length= 0; }
bool ok() { return content_ok; }
- const LEX_STRING *type() const { return &file_type; }
+ const LEX_CSTRING *type() const { return &file_type; }
my_bool parse(uchar* base, MEM_ROOT *mem_root,
struct File_option *parameters, uint required,
Unknown_key_hook *hook) const;
- friend File_parser *sql_parse_prepare(const LEX_STRING *file_name,
+ friend File_parser *sql_parse_prepare(const LEX_CSTRING *file_name,
MEM_ROOT *mem_root,
bool bad_format_errors);
};
diff --git a/sql/partition_element.h b/sql/partition_element.h
index b979b7a58e6..c774994b7f5 100644
--- a/sql/partition_element.h
+++ b/sql/partition_element.h
@@ -96,14 +96,14 @@ public:
ha_rows part_max_rows;
ha_rows part_min_rows;
longlong range_value;
- char *partition_name;
- char *tablespace_name;
+ const char *partition_name;
+ const char *tablespace_name;
struct st_ddl_log_memory_entry *log_entry;
- char* part_comment;
- char* data_file_name;
- char* index_file_name;
+ const char* part_comment;
+ const char* data_file_name;
+ const char* index_file_name;
handlerton *engine_type;
- LEX_STRING connect_string;
+ LEX_CSTRING connect_string;
enum partition_state part_state;
uint16 nodegroup_id;
bool has_null_value;
@@ -115,7 +115,7 @@ public:
partition_name(NULL), tablespace_name(NULL),
log_entry(NULL), part_comment(NULL),
data_file_name(NULL), index_file_name(NULL),
- engine_type(NULL), connect_string(null_lex_str), part_state(PART_NORMAL),
+ engine_type(NULL), connect_string(null_clex_str), part_state(PART_NORMAL),
nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE),
signed_flag(FALSE), max_value(FALSE)
{
@@ -129,7 +129,7 @@ public:
data_file_name(part_elem->data_file_name),
index_file_name(part_elem->index_file_name),
engine_type(part_elem->engine_type),
- connect_string(null_lex_str),
+ connect_string(null_clex_str),
part_state(part_elem->part_state),
nodegroup_id(part_elem->nodegroup_id),
has_null_value(FALSE)
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 24506434a76..ab4a1cc0360 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -562,10 +562,11 @@ bool partition_info::set_up_defaults_for_partitioning(THD *thd, handler *file,
Check that the user haven't defined the same field twice in
key or column list partitioning.
*/
-char* partition_info::find_duplicate_field()
+
+const char* partition_info::find_duplicate_field()
{
- char *field_name_outer, *field_name_inner;
- List_iterator<char> it_outer(part_field_list);
+ const char *field_name_outer, *field_name_inner;
+ List_iterator<const char> it_outer(part_field_list);
uint num_fields= part_field_list.elements;
uint i,j;
DBUG_ENTER("partition_info::find_duplicate_field");
@@ -573,7 +574,7 @@ char* partition_info::find_duplicate_field()
for (i= 0; i < num_fields; i++)
{
field_name_outer= it_outer++;
- List_iterator<char> it_inner(part_field_list);
+ List_iterator<const char> it_inner(part_field_list);
for (j= 0; j < num_fields; j++)
{
field_name_inner= it_inner++;
@@ -1382,7 +1383,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
handlerton *table_engine= default_engine_type;
uint i, tot_partitions;
bool result= TRUE, table_engine_set;
- char *same_name;
+ const char *same_name;
DBUG_ENTER("partition_info::check_partition_info");
DBUG_ASSERT(default_engine_type != partition_hton);
@@ -2649,9 +2650,9 @@ bool partition_info::has_same_partitioning(partition_info *new_part_info)
}
/* Check that it will use the same fields in KEY (fields) list. */
- List_iterator<char> old_field_name_it(part_field_list);
- List_iterator<char> new_field_name_it(new_part_info->part_field_list);
- char *old_name, *new_name;
+ List_iterator<const char> old_field_name_it(part_field_list);
+ List_iterator<const char> new_field_name_it(new_part_info->part_field_list);
+ const char *old_name, *new_name;
while ((old_name= old_field_name_it++))
{
new_name= new_field_name_it++;
@@ -2664,9 +2665,9 @@ bool partition_info::has_same_partitioning(partition_info *new_part_info)
if (is_sub_partitioned())
{
/* Check that it will use the same fields in KEY subpart fields list. */
- List_iterator<char> old_field_name_it(subpart_field_list);
- List_iterator<char> new_field_name_it(new_part_info->subpart_field_list);
- char *old_name, *new_name;
+ List_iterator<const char> old_field_name_it(subpart_field_list);
+ List_iterator<const char> new_field_name_it(new_part_info->subpart_field_list);
+ const char *old_name, *new_name;
while ((old_name= old_field_name_it++))
{
new_name= new_field_name_it++;
diff --git a/sql/partition_info.h b/sql/partition_info.h
index d4c180ddcdd..d723b5bf466 100644
--- a/sql/partition_info.h
+++ b/sql/partition_info.h
@@ -43,8 +43,8 @@ public:
List<partition_element> partitions;
List<partition_element> temp_partitions;
- List<char> part_field_list;
- List<char> subpart_field_list;
+ List<const char> part_field_list;
+ List<const char> subpart_field_list;
/*
If there is no subpartitioning, use only this func to get partition ids.
@@ -306,7 +306,7 @@ public:
bool set_up_defaults_for_partitioning(THD *thd, handler *file,
HA_CREATE_INFO *info,
uint start_no);
- char *find_duplicate_field();
+ const char *find_duplicate_field();
char *find_duplicate_name();
bool check_engine_mix(handlerton *engine_type, bool default_engine);
bool check_range_constants(THD *thd);
diff --git a/sql/procedure.cc b/sql/procedure.cc
index 8f9d6c0a7f3..3d36b7adfa3 100644
--- a/sql/procedure.cc
+++ b/sql/procedure.cc
@@ -89,7 +89,7 @@ setup_procedure(THD *thd,ORDER *param,select_result *result,
for (i=0 ; i < array_elements(sql_procs) ; i++)
{
if (!my_strcasecmp(system_charset_info,
- (*param->item)->name,sql_procs[i].name))
+ (*param->item)->name.str, sql_procs[i].name))
{
Procedure *proc=(*sql_procs[i].init)(thd,param,result,field_list);
*error= !proc;
diff --git a/sql/procedure.h b/sql/procedure.h
index b9d5066bb3d..4c087bfb3b2 100644
--- a/sql/procedure.h
+++ b/sql/procedure.h
@@ -40,7 +40,8 @@ class Item_proc :public Item
public:
Item_proc(THD *thd, const char *name_par): Item(thd)
{
- this->name=(char*) name_par;
+ this->name.str= name_par;
+ this->name.length= strlen(name_par);
}
enum Type type() const { return Item::PROC_ITEM; }
virtual void set(double nr)=0;
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 0c3ff2792c0..340b3a2176a 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -840,9 +840,9 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
cs, thd_charset) ||
prot.store(field.org_table_name, (uint) strlen(field.org_table_name),
cs, thd_charset) ||
- prot.store(field.col_name, (uint) strlen(field.col_name),
+ prot.store(field.col_name.str, (uint) field.col_name.length,
cs, thd_charset) ||
- prot.store(field.org_col_name, (uint) strlen(field.org_col_name),
+ prot.store(field.org_col_name.str, (uint) field.org_col_name.length,
cs, thd_charset) ||
local_packet->realloc(local_packet->length()+12))
goto err;
@@ -898,7 +898,7 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
{
if (prot.store(field.table_name, (uint) strlen(field.table_name),
cs, thd_charset) ||
- prot.store(field.col_name, (uint) strlen(field.col_name),
+ prot.store(field.col_name.str, (uint) field.col_name.length,
cs, thd_charset) ||
local_packet->realloc(local_packet->length()+10))
goto err;
diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc
index 1d9cb39075b..a2617de2757 100644
--- a/sql/rpl_gtid.cc
+++ b/sql/rpl_gtid.cc
@@ -981,24 +981,24 @@ rpl_slave_state::domain_to_gtid(uint32 domain_id, rpl_gtid *out_gtid)
Returns 0 on ok, non-zero on parse error.
*/
static int
-gtid_parser_helper(char **ptr, char *end, rpl_gtid *out_gtid)
+gtid_parser_helper(const char **ptr, const char *end, rpl_gtid *out_gtid)
{
char *q;
- char *p= *ptr;
+ const char *p= *ptr;
uint64 v1, v2, v3;
int err= 0;
- q= end;
+ q= (char*) end;
v1= (uint64)my_strtoll10(p, &q, &err);
if (err != 0 || v1 > (uint32)0xffffffff || q == end || *q != '-')
return 1;
p= q+1;
- q= end;
+ q= (char*) end;
v2= (uint64)my_strtoll10(p, &q, &err);
if (err != 0 || v2 > (uint32)0xffffffff || q == end || *q != '-')
return 1;
p= q+1;
- q= end;
+ q= (char*) end;
v3= (uint64)my_strtoll10(p, &q, &err);
if (err != 0)
return 1;
@@ -1014,8 +1014,8 @@ gtid_parser_helper(char **ptr, char *end, rpl_gtid *out_gtid)
rpl_gtid *
gtid_parse_string_to_list(const char *str, size_t str_len, uint32 *out_len)
{
- char *p= const_cast<char *>(str);
- char *end= p + str_len;
+ const char *p= const_cast<char *>(str);
+ const char *end= p + str_len;
uint32 len= 0, alloc_len= 5;
rpl_gtid *list= NULL;
@@ -1060,10 +1060,10 @@ gtid_parse_string_to_list(const char *str, size_t str_len, uint32 *out_len)
Returns 0 if ok, non-zero if error.
*/
int
-rpl_slave_state::load(THD *thd, char *state_from_master, size_t len,
+rpl_slave_state::load(THD *thd, const char *state_from_master, size_t len,
bool reset, bool in_statement)
{
- char *end= state_from_master + len;
+ const char *end= state_from_master + len;
if (reset)
{
@@ -1500,7 +1500,7 @@ rpl_binlog_state::read_from_iocache(IO_CACHE *src)
{
/* 10-digit - 10-digit - 20-digit \n \0 */
char buf[10+1+10+1+20+1+1];
- char *p, *end;
+ const char *p, *end;
rpl_gtid gtid;
int res= 0;
@@ -1763,9 +1763,9 @@ slave_connection_state::~slave_connection_state()
*/
int
-slave_connection_state::load(char *slave_request, size_t len)
+slave_connection_state::load(const char *slave_request, size_t len)
{
- char *p, *end;
+ const char *p, *end;
uchar *rec;
rpl_gtid *gtid;
const entry *e;
@@ -1779,7 +1779,7 @@ slave_connection_state::load(char *slave_request, size_t len)
{
if (!(rec= (uchar *)my_malloc(sizeof(entry), MYF(MY_WME))))
{
- my_error(ER_OUTOFMEMORY, MYF(0), sizeof(*gtid));
+ my_error(ER_OUTOFMEMORY, MYF(0), (int) sizeof(*gtid));
return 1;
}
gtid= &((entry *)rec)->gtid;
@@ -2399,7 +2399,7 @@ gtid_waiting::get_entry(uint32 domain_id)
if (!(e= (hash_element *)my_malloc(sizeof(*e), MYF(MY_WME))))
{
- my_error(ER_OUTOFMEMORY, MYF(0), sizeof(*e));
+ my_error(ER_OUTOFMEMORY, MYF(0), (int) sizeof(*e));
return NULL;
}
diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h
index f8a13d7bf3f..5dfac7a3c6f 100644
--- a/sql/rpl_gtid.h
+++ b/sql/rpl_gtid.h
@@ -181,7 +181,7 @@ struct rpl_slave_state
bool sort);
int tostring(String *dest, rpl_gtid *extra_gtids, uint32 num_extra);
bool domain_to_gtid(uint32 domain_id, rpl_gtid *out_gtid);
- int load(THD *thd, char *state_from_master, size_t len, bool reset,
+ int load(THD *thd, const char *state_from_master, size_t len, bool reset,
bool in_statement);
bool is_empty();
@@ -287,7 +287,7 @@ struct slave_connection_state
~slave_connection_state();
void reset() { my_hash_reset(&hash); }
- int load(char *slave_request, size_t len);
+ int load(const char *slave_request, size_t len);
int load(const rpl_gtid *gtid_list, uint32 count);
int load(rpl_slave_state *state, rpl_gtid *extra_gtids, uint32 num_extra);
rpl_gtid *find(uint32 domain_id);
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;
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index 31c0f280ac1..535abd25f6d 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -172,7 +172,7 @@ class Master_info : public Slave_reporting_capability
USE_GTID_NO= 0, USE_GTID_CURRENT_POS= 1, USE_GTID_SLAVE_POS= 2
};
- Master_info(LEX_STRING *connection_name, bool is_slave_recovery);
+ Master_info(LEX_CSTRING *connection_name, bool is_slave_recovery);
~Master_info();
bool shall_ignore_server_id(ulong s_id);
void clear_in_memory_info(bool all);
@@ -197,8 +197,8 @@ class Master_info : public Slave_reporting_capability
char host[HOSTNAME_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1];
char user[USERNAME_LENGTH+1];
char password[MAX_PASSWORD_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1];
- LEX_STRING connection_name; /* User supplied connection name */
- LEX_STRING cmp_connection_name; /* Connection name in lower case */
+ LEX_CSTRING connection_name; /* User supplied connection name */
+ LEX_CSTRING cmp_connection_name; /* Connection name in lower case */
bool ssl; // enables use of SSL connection if true
char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN];
char ssl_cipher[FN_REFLEN], ssl_key[FN_REFLEN];
@@ -342,14 +342,14 @@ public:
HASH master_info_hash;
bool init_all_master_info();
- bool write_master_name_to_index_file(LEX_STRING *connection_name,
+ bool write_master_name_to_index_file(LEX_CSTRING *connection_name,
bool do_sync);
- bool check_duplicate_master_info(LEX_STRING *connection_name,
+ bool check_duplicate_master_info(LEX_CSTRING *connection_name,
const char *host, uint port);
bool add_master_info(Master_info *mi, bool write_to_file);
bool remove_master_info(Master_info *mi);
- 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);
bool start_all_slaves(THD *thd);
bool stop_all_slaves(THD *thd);
@@ -366,13 +366,13 @@ public:
};
-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);
-bool check_master_connection_name(LEX_STRING *name);
+bool check_master_connection_name(LEX_CSTRING *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);
uchar *get_key_master_info(Master_info *mi, size_t *length,
my_bool not_used __attribute__((unused)));
diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc
index 0ef13c2cbb7..c07fe0464a1 100644
--- a/sql/rpl_record.cc
+++ b/sql/rpl_record.cc
@@ -107,7 +107,7 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
field->max_data_length());
DBUG_PRINT("debug", ("field: %s; real_type: %d, pack_ptr: 0x%lx;"
" pack_ptr':0x%lx; bytes: %d",
- field->field_name, field->real_type(),
+ field->field_name.str, field->real_type(),
(ulong) old_pack_ptr, (ulong) pack_ptr,
(int) (pack_ptr - old_pack_ptr)));
DBUG_DUMP("packed_data", old_pack_ptr, pack_ptr - old_pack_ptr);
@@ -254,7 +254,7 @@ unpack_row(rpl_group_info *rgi,
conv_field ? conv_field : *field_ptr;
DBUG_PRINT("debug", ("Conversion %srequired for field '%s' (#%ld)",
conv_field ? "" : "not ",
- (*field_ptr)->field_name,
+ (*field_ptr)->field_name.str,
(long) (field_ptr - begin_ptr)));
DBUG_ASSERT(f != NULL);
@@ -305,7 +305,7 @@ unpack_row(rpl_group_info *rgi,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_BAD_NULL_ERROR,
ER_THD(thd, ER_BAD_NULL_ERROR),
- f->field_name);
+ f->field_name.str);
}
}
else
@@ -323,7 +323,7 @@ unpack_row(rpl_group_info *rgi,
pack_ptr= f->unpack(f->ptr, pack_ptr, row_end, metadata);
DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;"
" pack_ptr: 0x%lx; pack_ptr': 0x%lx; bytes: %d",
- f->field_name, metadata,
+ f->field_name.str, metadata,
(ulong) old_pack_ptr, (ulong) pack_ptr,
(int) (pack_ptr - old_pack_ptr)));
if (!pack_ptr)
@@ -338,7 +338,7 @@ unpack_row(rpl_group_info *rgi,
WSREP_WARN("ROW event unpack field: %s metadata: 0x%x;"
" pack_ptr: 0x%lx; conv_table %p conv_field %p table %s"
" row_end: 0x%lx",
- f->field_name, metadata,
+ f->field_name.str, metadata,
(ulong) old_pack_ptr, conv_table, conv_field,
(table_found) ? "found" : "not found", (ulong)row_end
);
@@ -347,7 +347,7 @@ unpack_row(rpl_group_info *rgi,
rgi->rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT,
rgi->gtid_info(),
"Could not read field '%s' of table '%s.%s'",
- f->field_name, table->s->db.str,
+ f->field_name.str, table->s->db.str,
table->s->table_name.str);
DBUG_RETURN(HA_ERR_CORRUPT_EVENT);
}
@@ -370,7 +370,7 @@ unpack_row(rpl_group_info *rgi,
conv_field->sql_type(source_type);
conv_field->val_str(&value_string);
DBUG_PRINT("debug", ("Copying field '%s' of type '%s' with value '%s'",
- (*field_ptr)->field_name,
+ (*field_ptr)->field_name.str,
source_type.c_ptr_safe(), value_string.c_ptr_safe()));
#endif
copy.set(*field_ptr, f, TRUE);
@@ -381,7 +381,7 @@ unpack_row(rpl_group_info *rgi,
(*field_ptr)->sql_type(target_type);
(*field_ptr)->val_str(&value_string);
DBUG_PRINT("debug", ("Value of field '%s' of type '%s' is now '%s'",
- (*field_ptr)->field_name,
+ (*field_ptr)->field_name.str,
target_type.c_ptr_safe(), value_string.c_ptr_safe()));
#endif
}
@@ -489,7 +489,7 @@ int prepare_record(TABLE *const table, const uint skip, const bool check)
Sql_condition::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_FIELD,
ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD),
- f->field_name);
+ f->field_name.str);
}
}
diff --git a/sql/rpl_record_old.cc b/sql/rpl_record_old.cc
index 5b876373b9c..a252bbff0f5 100644
--- a/sql/rpl_record_old.cc
+++ b/sql/rpl_record_old.cc
@@ -143,7 +143,7 @@ unpack_row_old(rpl_group_info *rgi,
{
rgi->rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT, NULL,
"Could not read field `%s` of table `%s`.`%s`",
- f->field_name, table->s->db.str,
+ f->field_name.str, table->s->db.str,
table->s->table_name.str);
return(ER_SLAVE_CORRUPT_EVENT);
}
@@ -186,7 +186,7 @@ unpack_row_old(rpl_group_info *rgi,
rgi->rli->report(ERROR_LEVEL, ER_NO_DEFAULT_FOR_FIELD, NULL,
"Field `%s` of table `%s`.`%s` "
"has no default value and cannot be NULL",
- (*field_ptr)->field_name, table->s->db.str,
+ (*field_ptr)->field_name.str, table->s->db.str,
table->s->table_name.str);
error = ER_NO_DEFAULT_FOR_FIELD;
}
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index bdf5b7dea80..9a984c5c953 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -825,7 +825,7 @@ table_def::compatible_with(THD *thd, rpl_group_info *rgi,
{
DBUG_PRINT("debug", ("Checking column %d -"
" field '%s' can be converted - order: %d",
- col, field->field_name, order));
+ col, field->field_name.str, order));
DBUG_ASSERT(order >= -1 && order <= 1);
/*
@@ -855,7 +855,7 @@ table_def::compatible_with(THD *thd, rpl_group_info *rgi,
{
DBUG_PRINT("debug", ("Checking column %d -"
" field '%s' can not be converted",
- col, field->field_name));
+ col, field->field_name.str));
DBUG_ASSERT(col < size() && col < table->s->fields);
DBUG_ASSERT(table->s->db.str && table->s->table_name.str);
DBUG_ASSERT(table->in_use);
@@ -891,7 +891,7 @@ table_def::compatible_with(THD *thd, rpl_group_info *rgi,
table->field[col]->sql_type(target_type);
DBUG_PRINT("debug", ("Field %s - conversion required."
" Source type: '%s', Target type: '%s'",
- tmp_table->field[col]->field_name,
+ tmp_table->field[col]->field_name.str,
source_type.c_ptr_safe(), target_type.c_ptr_safe()));
}
}
@@ -928,7 +928,7 @@ public:
(int) sql_type,
target_field->table->s->db.str,
target_field->table->s->table_name.str,
- target_field->field_name);
+ target_field->field_name.str);
return true;
}
Field *tmp= handler->make_conversion_table_field(this, metadata,
@@ -938,7 +938,7 @@ public:
Virtual_tmp_table::add(tmp);
DBUG_PRINT("debug", ("sql_type: %d, target_field: '%s', max_length: %d, decimals: %d,"
" maybe_null: %d, unsigned_flag: %d, pack_length: %u",
- sql_type, target_field->field_name,
+ sql_type, target_field->field_name.str,
tmp->field_length, tmp->decimals(), TRUE,
tmp->flags, tmp->pack_length()));
return false;
@@ -980,7 +980,7 @@ TABLE *table_def::create_conversion_table(THD *thd, rpl_group_info *rgi,
DBUG_PRINT("debug", ("binlog_type: %d, metadata: %04X, target_field: '%s'"
" make_conversion_table_field() failed",
binlog_type(col), field_metadata(col),
- target_table->field[col]->field_name));
+ target_table->field[col]->field_name.str));
goto err;
}
}
diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc
index 03d4b150434..61680fb17f6 100644
--- a/sql/session_tracker.cc
+++ b/sql/session_tracker.cc
@@ -396,7 +396,7 @@ bool Session_sysvars_tracker::vars_list::parse_var_list(THD *thd,
return false;
}
- if(!strcmp(var_list.str,(const char *)"*"))
+ if(!strcmp(var_list.str, "*"))
{
track_all= true;
buffer_length= 2;
@@ -418,7 +418,7 @@ bool Session_sysvars_tracker::vars_list::parse_var_list(THD *thd,
for (;;)
{
sys_var *svar;
- LEX_STRING var;
+ LEX_CSTRING var;
uint not_used;
lasts= (char *) memchr(token, separator, rest);
@@ -435,7 +435,7 @@ bool Session_sysvars_tracker::vars_list::parse_var_list(THD *thd,
/* Remove leading/trailing whitespace. */
trim_whitespace(char_set, &var, &not_used);
- if(!strcmp(var.str,(const char *)"*"))
+ if(!strcmp(var.str, "*"))
{
track_all= true;
}
@@ -483,7 +483,7 @@ bool Session_sysvars_tracker::check_var_list(THD *thd,
size_t rest= var_list.length;
if (!var_list.str || var_list.length == 0 ||
- !strcmp(var_list.str,(const char *)"*"))
+ !strcmp(var_list.str, "*"))
{
return false;
}
@@ -500,7 +500,7 @@ bool Session_sysvars_tracker::check_var_list(THD *thd,
mysql_mutex_lock(&LOCK_plugin);
for (;;)
{
- LEX_STRING var;
+ LEX_CSTRING var;
uint not_used;
lasts= (char *) memchr(token, separator, rest);
@@ -517,7 +517,7 @@ bool Session_sysvars_tracker::check_var_list(THD *thd,
/* Remove leading/trailing whitespace. */
trim_whitespace(char_set, &var, &not_used);
- if(!strcmp(var.str,(const char *)"*") &&
+ if(!strcmp(var.str, "*") &&
!find_sys_var_ex(thd, var.str, var.length, throw_error, true))
{
if (throw_error && take_mutex && thd)
diff --git a/sql/set_var.cc b/sql/set_var.cc
index a5b80e34993..15f6bbdafc5 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -233,12 +233,12 @@ bool sys_var::update(THD *thd, set_var *var)
}
}
-uchar *sys_var::session_value_ptr(THD *thd, const LEX_STRING *base)
+uchar *sys_var::session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
return session_var_ptr(thd);
}
-uchar *sys_var::global_value_ptr(THD *thd, const LEX_STRING *base)
+uchar *sys_var::global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
return global_var_ptr();
}
@@ -271,7 +271,8 @@ bool sys_var::check(THD *thd, set_var *var)
return false;
}
-uchar *sys_var::value_ptr(THD *thd, enum_var_type type, const LEX_STRING *base)
+uchar *sys_var::value_ptr(THD *thd, enum_var_type type,
+ const LEX_CSTRING *base)
{
DBUG_ASSERT(base);
if (type == OPT_GLOBAL || scope() == GLOBAL)
@@ -327,7 +328,8 @@ do { \
break
longlong sys_var::val_int(bool *is_null,
- THD *thd, enum_var_type type, const LEX_STRING *base)
+ THD *thd, enum_var_type type,
+ const LEX_CSTRING *base)
{
LEX_STRING sval;
AutoWLock lock(&PLock_global_system_variables);
@@ -382,7 +384,7 @@ String *sys_var::val_str_nolock(String *str, THD *thd, const uchar *value)
String *sys_var::val_str(String *str,
- THD *thd, enum_var_type type, const LEX_STRING *base)
+ THD *thd, enum_var_type type, const LEX_CSTRING *base)
{
AutoWLock lock(&PLock_global_system_variables);
const uchar *value= value_ptr(thd, type, base);
@@ -391,7 +393,7 @@ String *sys_var::val_str(String *str,
double sys_var::val_real(bool *is_null,
- THD *thd, enum_var_type type, const LEX_STRING *base)
+ THD *thd, enum_var_type type, const LEX_CSTRING *base)
{
LEX_STRING sval;
AutoWLock lock(&PLock_global_system_variables);
@@ -691,7 +693,7 @@ bool find_sys_var_null_base(THD *thd, struct sys_var_with_base *tmp)
tmp->var= find_sys_var(thd, tmp->base_name.str, tmp->base_name.length);
if (tmp->var != NULL)
- tmp->base_name= null_lex_str;
+ tmp->base_name= null_clex_str;
return thd->is_error();
}
@@ -838,7 +840,7 @@ int set_var::update(THD *thd)
set_var::set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg,
- const LEX_STRING *base_name_arg, Item *value_arg)
+ const LEX_CSTRING *base_name_arg, Item *value_arg)
:var(var_arg), type(type_arg), base(*base_name_arg)
{
/*
@@ -849,7 +851,9 @@ set_var::set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg,
{
Item_field *item= (Item_field*) value_arg;
// names are utf8
- if (!(value= new (thd->mem_root) Item_string_sys(thd, item->field_name)))
+ if (!(value= new (thd->mem_root) Item_string_sys(thd,
+ item->field_name.str,
+ item->field_name.length)))
value=value_arg; /* Give error message later */
}
else
@@ -1061,7 +1065,7 @@ static void store_var(Field *field, sys_var *var, enum_var_type scope,
return;
store_value_ptr(field, var, str,
- var->value_ptr(field->table->in_use, scope, &null_lex_str));
+ var->value_ptr(field->table->in_use, scope, &null_clex_str));
}
int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond)
diff --git a/sql/set_var.h b/sql/set_var.h
index ddd6a225eb8..17d1ff93ebc 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -112,7 +112,7 @@ public:
virtual sys_var_pluginvar *cast_pluginvar() { return 0; }
bool check(THD *thd, set_var *var);
- uchar *value_ptr(THD *thd, enum_var_type type, const LEX_STRING *base);
+ uchar *value_ptr(THD *thd, enum_var_type type, const LEX_CSTRING *base);
/**
Update the system variable with the default value from either
@@ -123,9 +123,9 @@ public:
bool update(THD *thd, set_var *var);
String *val_str_nolock(String *str, THD *thd, const uchar *value);
- longlong val_int(bool *is_null, THD *thd, enum_var_type type, const LEX_STRING *base);
- String *val_str(String *str, THD *thd, enum_var_type type, const LEX_STRING *base);
- double val_real(bool *is_null, THD *thd, enum_var_type type, const LEX_STRING *base);
+ longlong val_int(bool *is_null, THD *thd, enum_var_type type, const LEX_CSTRING *base);
+ String *val_str(String *str, THD *thd, enum_var_type type, const LEX_CSTRING *base);
+ double val_real(bool *is_null, THD *thd, enum_var_type type, const LEX_CSTRING *base);
SHOW_TYPE show_type() { return show_val_type; }
int scope() const { return flags & SCOPE_MASK; }
@@ -229,8 +229,8 @@ protected:
It must be of show_val_type type (my_bool for SHOW_MY_BOOL,
int for SHOW_INT, longlong for SHOW_LONGLONG, etc).
*/
- virtual uchar *session_value_ptr(THD *thd, const LEX_STRING *base);
- virtual uchar *global_value_ptr(THD *thd, const LEX_STRING *base);
+ virtual uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base);
+ virtual uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base);
/**
A pointer to a storage area of the variable, to the raw data.
@@ -290,10 +290,10 @@ public:
LEX_STRING string_value; ///< for Sys_var_charptr and others
const void *ptr; ///< for Sys_var_struct
} save_result;
- LEX_STRING base; /**< for structured variables, like keycache_name.variable_name */
+ LEX_CSTRING base; /**< for structured variables, like keycache_name.variable_name */
set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg,
- const LEX_STRING *base_name_arg, Item *value_arg);
+ const LEX_CSTRING *base_name_arg, Item *value_arg);
virtual bool is_system() { return 1; }
int check(THD *thd);
int update(THD *thd);
@@ -330,10 +330,10 @@ public:
class set_var_role: public set_var_base
{
- LEX_STRING role;
+ LEX_CSTRING role;
ulonglong access;
public:
- set_var_role(LEX_STRING role_arg) : role(role_arg) {}
+ set_var_role(LEX_CSTRING role_arg) : role(role_arg) {}
int check(THD *thd);
int update(THD *thd);
};
@@ -343,9 +343,9 @@ public:
class set_var_default_role: public set_var_base
{
LEX_USER *user, *real_user;
- LEX_STRING role;
+ LEX_CSTRING role;
public:
- set_var_default_role(LEX_USER *user_arg, LEX_STRING role_arg) :
+ set_var_default_role(LEX_USER *user_arg, LEX_CSTRING role_arg) :
user(user_arg), role(role_arg) {}
int check(THD *thd);
int update(THD *thd);
@@ -412,7 +412,8 @@ inline bool IS_SYSVAR_AUTOSIZE(void *ptr)
bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type);
sql_mode_t expand_sql_mode(sql_mode_t sql_mode);
-bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode, LEX_STRING *ls);
+bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode,
+ LEX_CSTRING *ls);
int default_regex_flags_pcre(const THD *thd);
extern sys_var *Sys_autocommit_ptr;
diff --git a/sql/slave.cc b/sql/slave.cc
index fbdb78b5c5d..3ebd1b2ec46 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -82,7 +82,7 @@ ulonglong opt_read_binlog_speed_limit = 0;
const char *relay_log_index= 0;
const char *relay_log_basename= 0;
-LEX_STRING default_master_connection_name= { (char*) "", 0 };
+LEX_CSTRING default_master_connection_name= { (char*) "", 0 };
/*
When slave thread exits, we need to remember the temporary tables so we
diff --git a/sql/slave.h b/sql/slave.h
index ded9d76e49d..431e6847abe 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -273,7 +273,7 @@ extern bool volatile abort_loop;
extern Master_info *active_mi; /* active_mi for multi-master */
extern Master_info *default_master_info; /* To replace active_mi */
extern Master_info_index *master_info_index;
-extern LEX_STRING default_master_connection_name;
+extern LEX_CSTRING default_master_connection_name;
extern my_bool replicate_same_server_id;
extern int disconnect_slave_event_count, abort_slave_event_count ;
diff --git a/sql/sp.cc b/sql/sp.cc
index 140406c1075..aa353f8d594 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -42,7 +42,8 @@ db_load_routine(THD *thd, stored_procedure_type type, const sp_name *name,
sp_head **sphp,
sql_mode_t sql_mode, const char *params, const char *returns,
const char *body, st_sp_chistics &chistics,
- LEX_STRING *definer_user_name, LEX_STRING *definer_host_name,
+ LEX_CSTRING *definer_user_name,
+ LEX_CSTRING *definer_host_name,
longlong created, longlong modified,
Stored_program_creation_ctx *creation_ctx);
@@ -542,9 +543,9 @@ db_find_routine(THD *thd, stored_procedure_type type, const sp_name *name,
Open_tables_backup open_tables_state_backup;
Stored_program_creation_ctx *creation_ctx;
char definer_user_name_holder[USERNAME_LENGTH + 1];
- LEX_STRING definer_user_name= { definer_user_name_holder, USERNAME_LENGTH };
+ LEX_CSTRING definer_user_name= { definer_user_name_holder, USERNAME_LENGTH };
char definer_host_name_holder[HOSTNAME_LENGTH + 1];
- LEX_STRING definer_host_name= { definer_host_name_holder, HOSTNAME_LENGTH };
+ LEX_CSTRING definer_host_name= { definer_host_name_holder, HOSTNAME_LENGTH };
DBUG_ENTER("db_find_routine");
DBUG_PRINT("enter", ("type: %d name: %.*s",
@@ -654,9 +655,10 @@ db_find_routine(THD *thd, stored_procedure_type type, const sp_name *name,
close_system_tables(thd, &open_tables_state_backup);
table= 0;
+ /* It's ok to cast to char* here as the pointers are to local buffers */
if (parse_user(definer, strlen(definer),
- definer_user_name.str, &definer_user_name.length,
- definer_host_name.str, &definer_host_name.length) &&
+ (char*) definer_user_name.str, &definer_user_name.length,
+ (char*) definer_host_name.str, &definer_host_name.length) &&
definer_user_name.length && !definer_host_name.length)
{
// 'user@' -> 'user@%'
@@ -812,7 +814,8 @@ db_load_routine(THD *thd, stored_procedure_type type,
const sp_name *name, sp_head **sphp,
sql_mode_t sql_mode, const char *params, const char *returns,
const char *body, st_sp_chistics &chistics,
- LEX_STRING *definer_user_name, LEX_STRING *definer_host_name,
+ LEX_CSTRING *definer_user_name,
+ LEX_CSTRING *definer_host_name,
longlong created, longlong modified,
Stored_program_creation_ctx *creation_ctx)
{
@@ -884,7 +887,9 @@ db_load_routine(THD *thd, stored_procedure_type type,
generate an error.
*/
- if (cur_db_changed && mysql_change_db(thd, &saved_cur_db_name, TRUE))
+ if (cur_db_changed && mysql_change_db(thd,
+ (LEX_CSTRING*) &saved_cur_db_name,
+ TRUE))
{
ret= SP_INTERNAL_ERROR;
goto end;
@@ -1023,7 +1028,7 @@ sp_create_routine(THD *thd, stored_procedure_type type, sp_head *sp)
bool ret= TRUE;
TABLE *table;
char definer_buf[USER_HOST_BUFF_SIZE];
- LEX_STRING definer;
+ LEX_CSTRING definer;
sql_mode_t saved_mode= thd->variables.sql_mode;
MDL_key::enum_mdl_namespace mdl_type= type == TYPE_ENUM_FUNCTION ?
MDL_key::FUNCTION : MDL_key::PROCEDURE;
@@ -1501,7 +1506,7 @@ public:
cases.
*/
-bool lock_db_routines(THD *thd, char *db)
+bool lock_db_routines(THD *thd, const char *db)
{
TABLE *table;
uint key_len;
@@ -1587,7 +1592,7 @@ bool lock_db_routines(THD *thd, char *db)
*/
int
-sp_drop_db_routines(THD *thd, char *db)
+sp_drop_db_routines(THD *thd, const char *db)
{
TABLE *table;
int ret;
@@ -1840,13 +1845,12 @@ sp_exist_routines(THD *thd, TABLE_LIST *routines, bool is_proc)
for (routine= routines; routine; routine= routine->next_global)
{
sp_name *name;
- LEX_STRING lex_db;
- LEX_STRING lex_name;
- lex_db.length= strlen(routine->db);
- lex_name.length= strlen(routine->table_name);
- lex_db.str= thd->strmake(routine->db, lex_db.length);
- lex_name.str= thd->strmake(routine->table_name, lex_name.length);
- name= new sp_name(lex_db, lex_name, true);
+ LEX_CSTRING lex_db;
+ LEX_CSTRING lex_name;
+ thd->make_lex_string(&lex_db, routine->db, strlen(routine->db));
+ thd->make_lex_string(&lex_name, routine->table_name,
+ strlen(routine->table_name));
+ name= new sp_name(&lex_db, &lex_name, true);
sp_object_found= is_proc ? sp_find_routine(thd, TYPE_ENUM_PROCEDURE,
name, &thd->sp_proc_cache,
FALSE) != NULL :
@@ -2198,8 +2202,8 @@ show_create_sp(THD *thd, String *buf,
const char *returns, ulong returnslen,
const char *body, ulong bodylen,
st_sp_chistics *chistics,
- const LEX_STRING *definer_user,
- const LEX_STRING *definer_host,
+ const LEX_CSTRING *definer_user,
+ const LEX_CSTRING *definer_host,
sql_mode_t sql_mode)
{
sql_mode_t old_sql_mode= thd->variables.sql_mode;
@@ -2300,10 +2304,10 @@ sp_load_for_information_schema(THD *thd, TABLE *proc_table, String *db,
const char *sp_body;
String defstr;
struct st_sp_chistics sp_chistics;
- const LEX_STRING definer_user= {(char*)STRING_WITH_LEN("")};
- const LEX_STRING definer_host= {(char*)STRING_WITH_LEN("")};
- LEX_STRING sp_db_str;
- LEX_STRING sp_name_str;
+ const LEX_CSTRING definer_user= {STRING_WITH_LEN("")};
+ const LEX_CSTRING definer_host= {STRING_WITH_LEN("")};
+ LEX_CSTRING sp_db_str;
+ LEX_CSTRING sp_name_str;
sp_head *sp;
sp_cache **spc= ((type == TYPE_ENUM_PROCEDURE) ?
&thd->sp_proc_cache : &thd->sp_func_cache);
@@ -2311,7 +2315,7 @@ sp_load_for_information_schema(THD *thd, TABLE *proc_table, String *db,
sp_db_str.length= db->length();
sp_name_str.str= name->c_ptr();
sp_name_str.length= name->length();
- sp_name sp_name_obj(sp_db_str, sp_name_str, true);
+ sp_name sp_name_obj(&sp_db_str, &sp_name_str, true);
*free_sp_head= 0;
if ((sp= sp_cache_lookup(spc, &sp_name_obj)))
{
diff --git a/sql/sp.h b/sql/sp.h
index 3544e446411..748610c1a9c 100644
--- a/sql/sp.h
+++ b/sql/sp.h
@@ -107,7 +107,7 @@ enum
/* Drop all routines in database 'db' */
int
-sp_drop_db_routines(THD *thd, char *db);
+sp_drop_db_routines(THD *thd, const char *db);
/**
Acquires exclusive metadata lock on all stored routines in the
@@ -119,7 +119,7 @@ sp_drop_db_routines(THD *thd, char *db);
@retval false Success
@retval true Failure
*/
-bool lock_db_routines(THD *thd, char *db);
+bool lock_db_routines(THD *thd, const char *db);
sp_head *
sp_find_routine(THD *thd, stored_procedure_type type, const sp_name *name,
@@ -241,7 +241,7 @@ bool show_create_sp(THD *thd, String *buf,
const char *returns, ulong returnslen,
const char *body, ulong bodylen,
st_sp_chistics *chistics,
- const LEX_STRING *definer_user,
- const LEX_STRING *definer_host,
+ const LEX_CSTRING *definer_user,
+ const LEX_CSTRING *definer_host,
sql_mode_t sql_mode);
#endif /* _SP_H_ */
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index aeaca82649f..eea93f53b01 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -454,8 +454,8 @@ error:
*/
sp_name::sp_name(const MDL_key *key, char *qname_buff)
- :Database_qualified_name((char*)key->db_name(), key->db_name_length(),
- (char*)key->name(), key->name_length()),
+ :Database_qualified_name(key->db_name(), key->db_name_length(),
+ key->name(), key->name_length()),
m_explicit_name(false)
{
if (m_db.length)
@@ -479,7 +479,7 @@ sp_name::sp_name(const MDL_key *key, char *qname_buff)
*/
bool
-check_routine_name(LEX_STRING *ident)
+check_routine_name(LEX_CSTRING *ident)
{
DBUG_ASSERT(ident);
DBUG_ASSERT(ident->str);
@@ -541,7 +541,7 @@ sp_head::operator delete(void *ptr, size_t size) throw()
sp_head::sp_head()
:Query_arena(&main_mem_root, STMT_INITIALIZED_FOR_SP),
- Database_qualified_name(null_lex_str, null_lex_str),
+ Database_qualified_name(&null_clex_str, &null_clex_str),
m_flags(0),
m_sp_cache_version(0),
m_creation_ctx(0),
@@ -560,7 +560,7 @@ sp_head::sp_head()
be rewritten soon. Remove the else part and replace 'if' with
an assert when this is done.
*/
- m_qname= null_lex_str;
+ m_qname= null_clex_str;
DBUG_ENTER("sp_head::sp_head");
@@ -750,10 +750,11 @@ sp_head::~sp_head()
*/
Field *
-sp_head::create_result_field(uint field_max_length, const char *field_name,
+sp_head::create_result_field(uint field_max_length, const LEX_CSTRING *field_name,
TABLE *table)
{
Field *field;
+ LEX_CSTRING name;
DBUG_ENTER("sp_head::create_result_field");
@@ -796,11 +797,13 @@ sp_head::create_result_field(uint field_max_length, const char *field_name,
(m_return_field_def.pack_flag &
(FIELDFLAG_BLOB|FIELDFLAG_GEOM))));
+ if (field_name)
+ name= *field_name;
+ else
+ name= m_name;
field= m_return_field_def.make_field(table->s, /* TABLE_SHARE ptr */
table->in_use->mem_root,
- field_name ?
- field_name :
- (const char *) m_name.str);
+ &name);
field->vcol_info= m_return_field_def.vcol_info;
if (field)
@@ -1359,7 +1362,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
NULL. In this case, mysql_change_db() would generate an error.
*/
- err_status|= mysql_change_db(thd, &saved_cur_db_name, TRUE);
+ err_status|= mysql_change_db(thd, (LEX_CSTRING*) &saved_cur_db_name, TRUE);
}
m_flags&= ~IS_INVOKED;
DBUG_PRINT("info",
@@ -1513,8 +1516,8 @@ sp_rcontext *sp_head::rcontext_create(THD *thd, bool is_proc, Field *ret_value)
bool
sp_head::execute_trigger(THD *thd,
- const LEX_STRING *db_name,
- const LEX_STRING *table_name,
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name,
GRANT_INFO *grant_info)
{
sp_rcontext *octx = thd->spcont;
@@ -2108,8 +2111,8 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
out_param_info->db_name= m_db.str;
out_param_info->table_name= m_name.str;
out_param_info->org_table_name= m_name.str;
- out_param_info->col_name= spvar->name.str;
- out_param_info->org_col_name= spvar->name.str;
+ out_param_info->col_name= spvar->name;
+ out_param_info->org_col_name= spvar->name;
srp->set_out_param_info(out_param_info);
}
@@ -2383,7 +2386,7 @@ sp_head::check_unresolved_goto()
{
if ((bp->instr_type == GOTO))
{
- my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "GOTO", bp->lab->name);
+ my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "GOTO", bp->lab->name.str);
has_unresolved_label=true;
}
}
@@ -2465,13 +2468,13 @@ void
sp_head::set_definer(const char *definer, uint definerlen)
{
char user_name_holder[USERNAME_LENGTH + 1];
- LEX_STRING user_name= { user_name_holder, USERNAME_LENGTH };
+ LEX_CSTRING user_name= { user_name_holder, USERNAME_LENGTH };
char host_name_holder[HOSTNAME_LENGTH + 1];
- LEX_STRING host_name= { host_name_holder, HOSTNAME_LENGTH };
+ LEX_CSTRING host_name= { host_name_holder, HOSTNAME_LENGTH };
- if (parse_user(definer, definerlen, user_name.str, &user_name.length,
- host_name.str, &host_name.length) &&
+ if (parse_user(definer, definerlen, user_name_holder, &user_name.length,
+ host_name_holder, &host_name.length) &&
user_name.length && !host_name.length)
{
// 'user@' -> 'user@%'
@@ -2483,7 +2486,7 @@ sp_head::set_definer(const char *definer, uint definerlen)
void
-sp_head::set_definer(const LEX_STRING *user_name, const LEX_STRING *host_name)
+sp_head::set_definer(const LEX_CSTRING *user_name, const LEX_CSTRING *host_name)
{
m_definer_user.str= strmake_root(mem_root, user_name->str, user_name->length);
m_definer_user.length= user_name->length;
@@ -2661,7 +2664,7 @@ sp_head::show_create_routine(THD *thd, int type)
Protocol *protocol= thd->protocol;
List<Item> fields;
- LEX_STRING sql_mode;
+ LEX_CSTRING sql_mode;
bool full_access;
MEM_ROOT *mem_root= thd->mem_root;
@@ -3439,13 +3442,13 @@ sp_instr_set_row_field::print(String *str)
var->field_def.row_field_definitions()->elem(m_field_offset);
DBUG_ASSERT(def);
- rsrv+= var->name.length + strlen(def->field_name);
+ rsrv+= var->name.length + def->field_name.length;
if (str->reserve(rsrv))
return;
str->qs_append(STRING_WITH_LEN("set "));
str->qs_append(var->name.str, var->name.length);
str->qs_append('.');
- str->qs_append(def->field_name);
+ str->qs_append(def->field_name.str, def->field_name.length);
str->qs_append('@');
str->qs_append(m_offset);
str->qs_append('[');
@@ -3966,7 +3969,7 @@ sp_instr_cpush::execute(THD *thd, uint *nextp)
void
sp_instr_cpush::print(String *str)
{
- const LEX_STRING *cursor_name= m_ctx->find_cursor(m_cursor);
+ const LEX_CSTRING *cursor_name= m_ctx->find_cursor(m_cursor);
/* cpush name@offset */
uint rsrv= SP_INSTR_UINT_MAXLEN+7;
@@ -4054,7 +4057,7 @@ sp_instr_copen::exec_core(THD *thd, uint *nextp)
void
sp_instr_copen::print(String *str)
{
- const LEX_STRING *cursor_name= m_ctx->find_cursor(m_cursor);
+ const LEX_CSTRING *cursor_name= m_ctx->find_cursor(m_cursor);
/* copen name@offset */
uint rsrv= SP_INSTR_UINT_MAXLEN+7;
@@ -4096,7 +4099,7 @@ sp_instr_cclose::execute(THD *thd, uint *nextp)
void
sp_instr_cclose::print(String *str)
{
- const LEX_STRING *cursor_name= m_ctx->find_cursor(m_cursor);
+ const LEX_CSTRING *cursor_name= m_ctx->find_cursor(m_cursor);
/* cclose name@offset */
uint rsrv= SP_INSTR_UINT_MAXLEN+8;
@@ -4139,7 +4142,7 @@ sp_instr_cfetch::print(String *str)
{
List_iterator_fast<sp_variable> li(m_varlist);
sp_variable *pv;
- const LEX_STRING *cursor_name= m_ctx->find_cursor(m_cursor);
+ const LEX_CSTRING *cursor_name= m_ctx->find_cursor(m_cursor);
/* cfetch name@offset vars... */
uint rsrv= SP_INSTR_UINT_MAXLEN+8;
@@ -4235,11 +4238,11 @@ void
sp_instr_cursor_copy_struct::print(String *str)
{
sp_variable *var= m_ctx->find_variable(m_var);
- const LEX_STRING *name= m_lex_keeper.cursor_name();
+ const LEX_CSTRING *name= m_lex_keeper.cursor_name();
str->append(STRING_WITH_LEN("cursor_copy_struct "));
- str->append(name->str, name->length);
+ str->append(name);
str->append(' ');
- str->append(var->name.str, var->name.length);
+ str->append(&var->name);
str->append('@');
str->append_ulonglong(m_var);
}
@@ -4664,7 +4667,7 @@ sp_head::set_local_variable_row_field(THD *thd, sp_pcontext *spcont,
bool
sp_head::set_local_variable_row_field_by_name(THD *thd, sp_pcontext *spcont,
sp_variable *spv,
- const LEX_STRING &field_name,
+ const LEX_CSTRING *field_name,
Item *val, LEX *lex)
{
if (!(val= adjust_assignment_source(thd, val, NULL)))
@@ -4674,7 +4677,7 @@ sp_head::set_local_variable_row_field_by_name(THD *thd, sp_pcontext *spcont,
new (thd->mem_root) sp_instr_set_row_field_by_name(instructions(),
spcont,
spv->offset,
- field_name,
+ *field_name,
val,
lex, true);
return sp_set == NULL || add_instr(sp_set);
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 78ec6e0e5b0..bb516187a57 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -113,14 +113,15 @@ class sp_name : public Sql_alloc,
public:
bool m_explicit_name; /**< Prepend the db name? */
- sp_name(LEX_STRING db, LEX_STRING name, bool use_explicit_name)
+ sp_name(const LEX_CSTRING *db, const LEX_CSTRING *name,
+ bool use_explicit_name)
: Database_qualified_name(db, name), m_explicit_name(use_explicit_name)
{
if (lower_case_table_names && m_db.str)
- m_db.length= my_casedn_str(files_charset_info, m_db.str);
+ m_db.length= my_casedn_str(files_charset_info, (char*) m_db.str);
}
- /** Create temporary sp_name object from MDL key. */
+ /** Create temporary sp_name object from MDL key. Store in qname_buff */
sp_name(const MDL_key *key, char *qname_buff);
~sp_name()
@@ -129,7 +130,7 @@ public:
bool
-check_routine_name(LEX_STRING *ident);
+check_routine_name(LEX_CSTRING *ident);
class sp_head :private Query_arena,
public Database_qualified_name
@@ -180,14 +181,14 @@ public:
const char *m_tmp_query; ///< Temporary pointer to sub query string
st_sp_chistics *m_chistics;
sql_mode_t m_sql_mode; ///< For SHOW CREATE and execution
- LEX_STRING m_qname; ///< db.name
- bool m_explicit_name; ///< Prepend the db name? */
- LEX_STRING m_params;
- LEX_STRING m_body;
- LEX_STRING m_body_utf8;
- LEX_STRING m_defstr;
- LEX_STRING m_definer_user;
- LEX_STRING m_definer_host;
+ bool m_explicit_name; /**< Prepend the db name? */
+ LEX_CSTRING m_qname; ///< db.name
+ LEX_CSTRING m_params;
+ LEX_CSTRING m_body;
+ LEX_CSTRING m_body_utf8;
+ LEX_CSTRING m_defstr;
+ LEX_CSTRING m_definer_user;
+ LEX_CSTRING m_definer_host;
/**
Is this routine being executed?
@@ -325,8 +326,8 @@ public:
bool
execute_trigger(THD *thd,
- const LEX_STRING *db_name,
- const LEX_STRING *table_name,
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name,
GRANT_INFO *grant_info);
bool
@@ -382,7 +383,7 @@ public:
Item *val, LEX *lex);
bool set_local_variable_row_field_by_name(THD *thd, sp_pcontext *spcont,
sp_variable *spv,
- const LEX_STRING &field_name,
+ const LEX_CSTRING *field_name,
Item *val, LEX *lex);
private:
/**
@@ -602,16 +603,12 @@ public:
/// Add cpush instructions for all cursors declared in the current frame
bool sp_add_instr_cpush_for_cursors(THD *thd, sp_pcontext *pcontext);
- char *name(uint *lenp = 0) const
- {
- if (lenp)
- *lenp= (uint) m_name.length;
- return m_name.str;
- }
+ const LEX_CSTRING *name() const
+ { return &m_name; }
char *create_string(THD *thd, ulong *lenp);
- Field *create_result_field(uint field_max_length, const char *field_name,
+ Field *create_result_field(uint field_max_length, const LEX_CSTRING *field_name,
TABLE *table);
@@ -657,9 +654,10 @@ public:
def->pack_flag|= FIELDFLAG_MAYBE_NULL;
return false;
}
- bool fill_spvar_definition(THD *thd, Column_definition *def, const char *name)
+ bool fill_spvar_definition(THD *thd, Column_definition *def,
+ LEX_CSTRING *name)
{
- def->field_name= name;
+ def->field_name= *name;
return fill_spvar_definition(thd, def);
}
/**
@@ -669,7 +667,7 @@ public:
Qualified_column_ident *ref)
{
spvar->field_def.set_column_type_ref(ref);
- spvar->field_def.field_name= spvar->name.str;
+ spvar->field_def.field_name= spvar->name;
m_flags|= sp_head::HAS_COLUMN_TYPE_REFS;
}
@@ -677,7 +675,7 @@ public:
st_sp_chistics *chistics, sql_mode_t sql_mode);
void set_definer(const char *definer, uint definerlen);
- void set_definer(const LEX_STRING *user_name, const LEX_STRING *host_name);
+ void set_definer(const LEX_CSTRING *user_name, const LEX_CSTRING *host_name);
void reset_thd_mem_root(THD *thd);
@@ -763,7 +761,7 @@ public:
DBUG_PRINT("info", ("lex->get_stmt_unsafe_flags(): 0x%x",
prelocking_ctx->get_stmt_unsafe_flags()));
DBUG_PRINT("info", ("sp_head(0x%p=%s)->unsafe_flags: 0x%x",
- this, name(), unsafe_flags));
+ this, name()->str, unsafe_flags));
prelocking_ctx->set_stmt_unsafe_flags(unsafe_flags);
DBUG_VOID_RETURN;
}
@@ -837,12 +835,12 @@ private:
class sp_lex_cursor: public sp_lex_local, public Query_arena
{
- LEX_STRING m_cursor_name;
+ LEX_CSTRING m_cursor_name;
public:
sp_lex_cursor(THD *thd, const LEX *oldlex, MEM_ROOT *mem_root_arg)
:sp_lex_local(thd, oldlex),
Query_arena(mem_root_arg, STMT_INITIALIZED_FOR_SP),
- m_cursor_name(null_lex_str)
+ m_cursor_name(null_clex_str)
{ }
sp_lex_cursor(THD *thd, const LEX *oldlex)
:sp_lex_local(thd, oldlex),
@@ -870,8 +868,8 @@ public:
thd->free_list= NULL;
return false;
}
- const LEX_STRING *cursor_name() const { return &m_cursor_name; }
- void set_cursor_name(const LEX_STRING &name) { m_cursor_name= name; }
+ const LEX_CSTRING *cursor_name() const { return &m_cursor_name; }
+ void set_cursor_name(const LEX_CSTRING *name) { m_cursor_name= *name; }
};
@@ -1045,7 +1043,7 @@ public:
m_lex->safe_to_cache_query= 0;
}
- const LEX_STRING *cursor_name() const
+ const LEX_CSTRING *cursor_name() const
{
return m_lex->cursor_name();
}
@@ -1197,12 +1195,12 @@ class sp_instr_set_row_field_by_name : public sp_instr_set
// Prevent use of this
sp_instr_set_row_field_by_name(const sp_instr_set_row_field &);
void operator=(sp_instr_set_row_field_by_name &);
- const LEX_STRING m_field_name;
+ const LEX_CSTRING m_field_name;
public:
sp_instr_set_row_field_by_name(uint ip, sp_pcontext *ctx,
- uint offset, const LEX_STRING &field_name,
+ uint offset, const LEX_CSTRING &field_name,
Item *val,
LEX *lex, bool lex_resp)
: sp_instr_set(ip, ctx, offset, val, lex, lex_resp),
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;
}
diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h
index c6c8084fee2..841ea8526a5 100644
--- a/sql/sp_pcontext.h
+++ b/sql/sp_pcontext.h
@@ -41,7 +41,7 @@ public:
};
/// Name of the SP-variable.
- LEX_STRING name;
+ LEX_CSTRING name;
/// Mode of the SP-variable.
enum_mode mode;
@@ -65,11 +65,11 @@ public:
const Type_handler *type_handler() const { return field_def.type_handler(); }
public:
- sp_variable(LEX_STRING _name, uint _offset)
+ sp_variable(const LEX_CSTRING *name_arg, uint offset_arg)
:Sql_alloc(),
- name(_name),
+ name(*name_arg),
mode(MODE_IN),
- offset(_offset),
+ offset(offset_arg),
default_value(NULL)
{ }
/*
@@ -83,8 +83,8 @@ public:
with the given name, or a non-null pointer otherwise.
row_field_offset[0] is set only when the method returns !NULL.
*/
- const Spvar_definition *find_row_field(const LEX_STRING &var_name,
- const LEX_STRING &field_name,
+ const Spvar_definition *find_row_field(const LEX_CSTRING *var_name,
+ const LEX_CSTRING *field_name,
uint *row_field_offset);
};
@@ -117,7 +117,7 @@ public:
};
/// Name of the label.
- LEX_STRING name;
+ LEX_CSTRING name;
/// Instruction pointer of the label.
uint ip;
@@ -129,10 +129,10 @@ public:
class sp_pcontext *ctx;
public:
- sp_label(const LEX_STRING _name,
+ sp_label(const LEX_CSTRING *_name,
uint _ip, enum_type _type, sp_pcontext *_ctx)
:Sql_alloc(),
- name(_name),
+ name(*_name),
ip(_ip),
type(_type),
ctx(_ctx)
@@ -243,29 +243,29 @@ class sp_condition : public Sql_alloc
{
public:
/// Name of the condition.
- LEX_STRING name;
+ LEX_CSTRING name;
/// Value of the condition.
sp_condition_value *value;
public:
- sp_condition(const LEX_STRING _name, sp_condition_value *_value)
+ sp_condition(const LEX_CSTRING *name_arg, sp_condition_value *value_arg)
:Sql_alloc(),
- name(_name),
- value(_value)
+ name(*name_arg),
+ value(value_arg)
{ }
sp_condition(const char *name_arg, size_t name_length_arg,
sp_condition_value *value_arg)
:value(value_arg)
{
- name.str= (char *) name_arg;
+ name.str= name_arg;
name.length= name_length_arg;
}
- bool eq_name(const LEX_STRING str) const
+ bool eq_name(const LEX_CSTRING *str) const
{
return my_strnncoll(system_charset_info,
(const uchar *) name.str, name.length,
- (const uchar *) str.str, str.length) == 0;
+ (const uchar *) str->str, str->length) == 0;
}
};
@@ -288,14 +288,14 @@ public:
Note, m_param_context can be not NULL, but have no variables.
This is also means a cursor with no parameters (similar to NULL).
*/
-class sp_pcursor: public LEX_STRING
+class sp_pcursor: public LEX_CSTRING
{
class sp_pcontext *m_param_context; // Formal parameters
class sp_lex_cursor *m_lex; // The cursor statement LEX
public:
- sp_pcursor(const LEX_STRING &name, class sp_pcontext *param_ctx,
+ sp_pcursor(const LEX_CSTRING *name, class sp_pcontext *param_ctx,
class sp_lex_cursor *lex)
- :LEX_STRING(name), m_param_context(param_ctx), m_lex(lex)
+ :LEX_CSTRING(*name), m_param_context(param_ctx), m_lex(lex)
{ }
class sp_pcontext *param_context() const { return m_param_context; }
class sp_lex_cursor *lex() const { return m_lex; }
@@ -462,7 +462,7 @@ public:
/// @param name Name of the SP-variable.
///
/// @return instance of newly added SP-variable.
- sp_variable *add_variable(THD *thd, LEX_STRING name);
+ sp_variable *add_variable(THD *thd, const LEX_CSTRING *name);
/// Retrieve full type information about SP-variables in this parsing
/// context and its children.
@@ -481,7 +481,7 @@ public:
/// @param current_scope_only A flag if we search only in current scope.
///
/// @return instance of found SP-variable, or NULL if not found.
- sp_variable *find_variable(LEX_STRING name, bool current_scope_only) const;
+ sp_variable *find_variable(const LEX_CSTRING *name, bool current_scope_only) const;
/// Find SP-variable by the offset in the root parsing context.
///
@@ -524,28 +524,28 @@ public:
// Labels.
/////////////////////////////////////////////////////////////////////////
- sp_label *push_label(THD *thd, const LEX_STRING name, uint ip,
+ sp_label *push_label(THD *thd, const LEX_CSTRING *name, uint ip,
sp_label::enum_type type, List<sp_label> * list);
- sp_label *push_label(THD *thd, LEX_STRING name, uint ip,
- sp_label::enum_type type)
+ sp_label *push_label(THD *thd, const LEX_CSTRING *name, uint ip,
+ sp_label::enum_type type)
{ return push_label(thd, name, ip, type, &m_labels); }
- sp_label *push_goto_label(THD *thd, LEX_STRING name, uint ip,
- sp_label::enum_type type)
+ sp_label *push_goto_label(THD *thd, const LEX_CSTRING *name, uint ip,
+ sp_label::enum_type type)
{ return push_label(thd, name, ip, type, &m_goto_labels); }
- sp_label *push_label(THD *thd, const LEX_STRING name, uint ip)
+ sp_label *push_label(THD *thd, const LEX_CSTRING *name, uint ip)
{ return push_label(thd, name, ip, sp_label::IMPLICIT); }
- sp_label *push_goto_label(THD *thd, const LEX_STRING name, uint ip)
+ sp_label *push_goto_label(THD *thd, const LEX_CSTRING *name, uint ip)
{ return push_goto_label(thd, name, ip, sp_label::GOTO); }
- sp_label *find_label(const LEX_STRING name);
+ sp_label *find_label(const LEX_CSTRING *name);
- sp_label *find_goto_label(const LEX_STRING name, bool recusive);
+ sp_label *find_goto_label(const LEX_CSTRING *name, bool recusive);
- sp_label *find_goto_label(const LEX_STRING name)
+ sp_label *find_goto_label(const LEX_CSTRING *name)
{ return find_goto_label(name, true); }
sp_label *find_label_current_loop_start();
@@ -568,12 +568,12 @@ public:
sp_label *pop_label()
{ return m_labels.pop(); }
- bool block_label_declare(LEX_STRING label)
+ bool block_label_declare(LEX_CSTRING *label)
{
sp_label *lab= find_label(label);
if (lab)
{
- my_error(ER_SP_LABEL_REDEFINE, MYF(0), label.str);
+ my_error(ER_SP_LABEL_REDEFINE, MYF(0), label->str);
return true;
}
return false;
@@ -583,15 +583,15 @@ public:
// Conditions.
/////////////////////////////////////////////////////////////////////////
- bool add_condition(THD *thd, const LEX_STRING name,
+ bool add_condition(THD *thd, const LEX_CSTRING *name,
sp_condition_value *value);
/// See comment for find_variable() above.
- sp_condition_value *find_condition(const LEX_STRING name,
+ sp_condition_value *find_condition(const LEX_CSTRING *name,
bool current_scope_only) const;
sp_condition_value *
- find_declared_or_predefined_condition(const LEX_STRING name) const
+ find_declared_or_predefined_condition(const LEX_CSTRING *name) const
{
sp_condition_value *p= find_condition(name, false);
if (p)
@@ -599,12 +599,12 @@ public:
return find_predefined_condition(name);
}
- bool declare_condition(THD *thd, const LEX_STRING name,
+ bool declare_condition(THD *thd, const LEX_CSTRING *name,
sp_condition_value *val)
{
if (find_condition(name, true))
{
- my_error(ER_SP_DUP_COND, MYF(0), name.str);
+ my_error(ER_SP_DUP_COND, MYF(0), name->str);
return true;
}
return add_condition(thd, name, val);
@@ -646,21 +646,21 @@ public:
// Cursors.
/////////////////////////////////////////////////////////////////////////
- bool add_cursor(const LEX_STRING name, sp_pcontext *param_ctx,
+ bool add_cursor(const LEX_CSTRING *name, sp_pcontext *param_ctx,
class sp_lex_cursor *lex);
/// See comment for find_variable() above.
- const sp_pcursor *find_cursor(const LEX_STRING name,
+ const sp_pcursor *find_cursor(const LEX_CSTRING *name,
uint *poff, bool current_scope_only) const;
- const sp_pcursor *find_cursor_with_error(const LEX_STRING name,
+ const sp_pcursor *find_cursor_with_error(const LEX_CSTRING *name,
uint *poff,
bool current_scope_only) const
{
const sp_pcursor *pcursor= find_cursor(name, poff, current_scope_only);
if (!pcursor)
{
- my_error(ER_SP_CURSOR_MISMATCH, MYF(0), name.str);
+ my_error(ER_SP_CURSOR_MISMATCH, MYF(0), name->str);
return NULL;
}
return pcursor;
@@ -704,7 +704,7 @@ private:
sp_pcontext(const sp_pcontext &);
void operator=(sp_pcontext &);
- sp_condition_value *find_predefined_condition(const LEX_STRING name) const;
+ sp_condition_value *find_predefined_condition(const LEX_CSTRING *name) const;
private:
/// m_max_var_index -- number of variables (including all types of arguments)
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 10329040357..3ceba42b0e4 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -171,7 +171,7 @@ bool sp_rcontext::resolve_type_ref(THD *thd, Column_definition *def,
!open_tables_only_view_structure(thd, table_list,
thd->mdl_context.has_locks()))
{
- if ((src= lex.query_tables->table->find_field_by_name(ref->m_column.str)))
+ if ((src= lex.query_tables->table->find_field_by_name(&ref->m_column)))
{
if (!(rc= check_column_grant_for_type_ref(thd, table_list,
ref->m_column.str,
@@ -237,14 +237,14 @@ bool sp_rcontext::resolve_table_rowtype_ref(THD *thd,
as the table will be closed and freed soon,
in the end of this method.
*/
- LEX_CSTRING tmp= {src[0]->field_name, strlen(src[0]->field_name)};
+ LEX_CSTRING tmp= src[0]->field_name;
Spvar_definition *def;
if ((rc= check_column_grant_for_type_ref(thd, table_list,
tmp.str, tmp.length)) ||
- (rc= !(src[0]->field_name= thd->strmake(tmp.str, tmp.length))) ||
+ (rc= !(src[0]->field_name.str= thd->strmake(tmp.str, tmp.length))) ||
(rc= !(def= new (thd->mem_root) Spvar_definition(thd, *src))))
break;
- src[0]->field_name= tmp.str; // Restore field name, just in case.
+ src[0]->field_name.str= tmp.str; // Restore field name, just in case.
def->flags&= (uint) ~NOT_NULL_FLAG;
if ((rc= def->sp_prepare_create_field(thd, thd->mem_root)))
break;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 09781f4bbe3..d6cdb252a85 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -176,30 +176,30 @@ TABLE_FIELD_TYPE mysql_db_table_fields[MYSQL_DB_FIELD_COUNT] = {
const TABLE_FIELD_DEF
mysql_db_table_def= {MYSQL_DB_FIELD_COUNT, mysql_db_table_fields, 0, (uint*) 0 };
-static LEX_STRING native_password_plugin_name= {
- C_STRING_WITH_LEN("mysql_native_password")
+static LEX_CSTRING native_password_plugin_name= {
+ STRING_WITH_LEN("mysql_native_password")
};
-static LEX_STRING old_password_plugin_name= {
- C_STRING_WITH_LEN("mysql_old_password")
+static LEX_CSTRING old_password_plugin_name= {
+ STRING_WITH_LEN("mysql_old_password")
};
/// @todo make it configurable
-LEX_STRING *default_auth_plugin_name= &native_password_plugin_name;
+LEX_CSTRING *default_auth_plugin_name= &native_password_plugin_name;
/*
Wildcard host, matches any hostname
*/
-LEX_STRING host_not_specified= { C_STRING_WITH_LEN("%") };
+LEX_CSTRING host_not_specified= { STRING_WITH_LEN("%") };
/*
Constants, used in the SHOW GRANTS command.
Their actual string values are irrelevant, they're always compared
as pointers to these string constants.
*/
-LEX_STRING current_user= { C_STRING_WITH_LEN("*current_user") };
-LEX_STRING current_role= { C_STRING_WITH_LEN("*current_role") };
-LEX_STRING current_user_and_current_role= { C_STRING_WITH_LEN("*current_user_and_current_role") };
+LEX_CSTRING current_user= { STRING_WITH_LEN("*current_user") };
+LEX_CSTRING current_role= { STRING_WITH_LEN("*current_role") };
+LEX_CSTRING current_user_and_current_role= { STRING_WITH_LEN("*current_user_and_current_role") };
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -244,7 +244,7 @@ public:
{ return (void*) alloc_root(mem_root, size); }
uchar flags; // field used to store various state information
- LEX_STRING user;
+ LEX_CSTRING user;
/* list to hold references to granted roles (ACL_ROLE instances) */
DYNAMIC_ARRAY role_grants;
};
@@ -259,9 +259,9 @@ public:
uint8 salt_len; // 0 - no password, 4 - 3.20, 8 - 4.0, 20 - 4.1.1
enum SSL_type ssl_type;
const char *ssl_cipher, *x509_issuer, *x509_subject;
- LEX_STRING plugin;
- LEX_STRING auth_string;
- LEX_STRING default_rolename;
+ LEX_CSTRING plugin;
+ LEX_CSTRING auth_string;
+ LEX_CSTRING default_rolename;
ACL_USER *copy(MEM_ROOT *root)
{
@@ -338,7 +338,7 @@ class ACL_DB :public ACL_ACCESS
{
public:
acl_host_and_ip host;
- char *user,*db;
+ const char *user,*db;
ulong initial_access; /* access bits present in the table */
};
@@ -530,10 +530,10 @@ public:
}
static int store_pk(TABLE *table,
- const LEX_STRING *host,
- const LEX_STRING *user,
- const LEX_STRING *proxied_host,
- const LEX_STRING *proxied_user)
+ const LEX_CSTRING *host,
+ const LEX_CSTRING *user,
+ const LEX_CSTRING *proxied_host,
+ const LEX_CSTRING *proxied_user)
{
DBUG_ENTER("ACL_PROXY_USER::store_pk");
DBUG_PRINT("info", ("host=%s, user=%s, proxied_host=%s, proxied_user=%s",
@@ -560,10 +560,10 @@ public:
}
static int store_data_record(TABLE *table,
- const LEX_STRING *host,
- const LEX_STRING *user,
- const LEX_STRING *proxied_host,
- const LEX_STRING *proxied_user,
+ const LEX_CSTRING *host,
+ const LEX_CSTRING *user,
+ const LEX_CSTRING *proxied_host,
+ const LEX_CSTRING *proxied_user,
bool with_grant,
const char *grantor)
{
@@ -616,8 +616,8 @@ struct ROLE_GRANT_PAIR : public Sql_alloc
LEX_STRING hashkey;
bool with_admin;
- bool init(MEM_ROOT *mem, char *username, char *hostname, char *rolename,
- bool with_admin_option);
+ bool init(MEM_ROOT *mem, const char *username, const char *hostname,
+ const char *rolename, bool with_admin_option);
};
static uchar* acl_role_map_get_key(ROLE_GRANT_PAIR *entry, size_t *length,
@@ -627,8 +627,8 @@ static uchar* acl_role_map_get_key(ROLE_GRANT_PAIR *entry, size_t *length,
return (uchar*) entry->hashkey.str;
}
-bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, char *username,
- char *hostname, char *rolename,
+bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, const char *username,
+ const char *hostname, const char *rolename,
bool with_admin_option)
{
size_t uname_l = safe_strlen(username);
@@ -736,7 +736,7 @@ static void rebuild_role_grants(void);
static ACL_USER *find_user_exact(const char *host, const char *user);
static ACL_USER *find_user_wild(const char *host, const char *user, const char *ip= 0);
static ACL_ROLE *find_acl_role(const char *user);
-static ROLE_GRANT_PAIR *find_role_grant_pair(const LEX_STRING *u, const LEX_STRING *h, const LEX_STRING *r);
+static ROLE_GRANT_PAIR *find_role_grant_pair(const LEX_CSTRING *u, const LEX_CSTRING *h, const LEX_CSTRING *r);
static ACL_USER_BASE *find_acl_user_base(const char *user, const char *host);
static bool update_user_table(THD *, const User_table &, const char *, const char *, const
char *, uint);
@@ -1487,7 +1487,7 @@ static bool has_validation_plugins()
MariaDB_PASSWORD_VALIDATION_PLUGIN, NULL);
}
-struct validation_data { LEX_STRING *user, *password; };
+struct validation_data { LEX_CSTRING *user, *password; };
static my_bool do_validate(THD *, plugin_ref plugin, void *arg)
{
@@ -1504,7 +1504,7 @@ static bool validate_password(LEX_USER *user, THD *thd)
{
struct validation_data data= { &user->user,
user->pwtext.str ? &user->pwtext :
- const_cast<LEX_STRING *>(&empty_lex_str) };
+ const_cast<LEX_CSTRING *>(&empty_clex_str) };
if (plugin_foreach(NULL, do_validate,
MariaDB_PASSWORD_VALIDATION_PLUGIN, &data))
{
@@ -1553,7 +1553,7 @@ set_user_salt(ACL_USER *acl_user, const char *password, uint password_len)
acl_user->salt_len= 0;
}
-static char *fix_plugin_ptr(char *name)
+static const char *fix_plugin_ptr(const char *name)
{
if (my_strcasecmp(system_charset_info, name,
native_password_plugin_name.str) == 0)
@@ -1645,13 +1645,13 @@ static bool fix_lex_user(THD *thd, LEX_USER *user)
if (user->plugin.length)
{
user->pwhash= user->auth;
- user->plugin= empty_lex_str;
- user->auth= empty_lex_str;
+ user->plugin= empty_clex_str;
+ user->auth= empty_clex_str;
}
if (user->pwhash.length && user->pwhash.length != check_length)
{
- my_error(ER_PASSWD_LENGTH, MYF(0), check_length);
+ my_error(ER_PASSWD_LENGTH, MYF(0), (int) check_length);
return true;
}
@@ -2138,12 +2138,13 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
while (!(read_record_info.read_record(&read_record_info)))
{
ACL_DB db;
+ char *db_name;
db.user=get_field(&acl_memroot, db_table.user());
const char *hostname= get_field(&acl_memroot, db_table.host());
if (!hostname && find_acl_role(db.user))
hostname= "";
update_hostname(&db.host, hostname);
- db.db=get_field(&acl_memroot, db_table.db());
+ db.db= db_name= get_field(&acl_memroot, db_table.db());
if (!db.db)
{
sql_print_warning("Found an entry in the 'db' table with empty database name; Skipped");
@@ -2171,8 +2172,8 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
sql_print_warning(ER_THD(thd, ER_WRONG_DB_NAME), db.db);
continue;
}
- my_casedn_str(files_charset_info, db.db);
- if (strcmp(db.db, tmp_name) != 0)
+ my_casedn_str(files_charset_info, db_name);
+ if (strcmp(db_name, tmp_name) != 0)
{
sql_print_warning("'db' entry '%s %s@%s' had database in mixed "
"case that has been forced to lowercase because "
@@ -2496,8 +2497,8 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b)
TRUE Error
*/
-bool acl_getroot(Security_context *sctx, char *user, char *host,
- char *ip, char *db)
+bool acl_getroot(Security_context *sctx, const char *user, const char *host,
+ const char *ip, const char *db)
{
int res= 1;
uint i;
@@ -2610,7 +2611,7 @@ static int check_user_can_set_role(const char *user, const char *host,
acl_user= find_user_wild(host, user, ip);
if (acl_user == NULL)
{
- my_error(ER_INVALID_CURRENT_USER, MYF(0), rolename);
+ my_error(ER_INVALID_CURRENT_USER, MYF(0));
result= -1;
}
else if (access)
@@ -2660,7 +2661,7 @@ end:
}
-int acl_check_setrole(THD *thd, char *rolename, ulonglong *access)
+int acl_check_setrole(THD *thd, const char *rolename, ulonglong *access)
{
/* Yes! priv_user@host. Don't ask why - that's what check_access() does. */
return check_user_can_set_role(thd->security_ctx->priv_user,
@@ -2668,7 +2669,7 @@ int acl_check_setrole(THD *thd, char *rolename, ulonglong *access)
}
-int acl_setrole(THD *thd, char *rolename, ulonglong access)
+int acl_setrole(THD *thd, const char *rolename, ulonglong access)
{
/* merge the privileges */
Security_context *sctx= thd->security_ctx;
@@ -2714,8 +2715,8 @@ static void acl_update_user(const char *user, const char *host,
const char *x509_subject,
USER_RESOURCES *mqh,
ulong privileges,
- const LEX_STRING *plugin,
- const LEX_STRING *auth)
+ const LEX_CSTRING *plugin,
+ const LEX_CSTRING *auth)
{
mysql_mutex_assert_owner(&acl_cache->lock);
@@ -2792,8 +2793,8 @@ static void acl_insert_user(const char *user, const char *host,
const char *x509_subject,
USER_RESOURCES *mqh,
ulong privileges,
- const LEX_STRING *plugin,
- const LEX_STRING *auth)
+ const LEX_CSTRING *plugin,
+ const LEX_CSTRING *auth)
{
ACL_USER acl_user;
@@ -3998,7 +3999,7 @@ static int replace_user_table(THD *thd, const User_table &user_table,
}
}
else
- combo.pwhash= empty_lex_str;
+ combo.pwhash= empty_clex_str;
/* if the user table is not up to date, we can't handle role updates */
if (!user_table.is_role() && handle_as_role)
@@ -4401,8 +4402,8 @@ abort:
@param revoke_grant true for REVOKE, false for GRANT
*/
static int
-replace_roles_mapping_table(TABLE *table, LEX_STRING *user, LEX_STRING *host,
- LEX_STRING *role, bool with_admin,
+replace_roles_mapping_table(TABLE *table, LEX_CSTRING *user, LEX_CSTRING *host,
+ LEX_CSTRING *role, bool with_admin,
ROLE_GRANT_PAIR *existing, bool revoke_grant)
{
DBUG_ENTER("replace_roles_mapping_table");
@@ -4483,7 +4484,7 @@ table_error:
@param revoke_grant true for REVOKE, false for GRANT
*/
static int
-update_role_mapping(LEX_STRING *user, LEX_STRING *host, LEX_STRING *role,
+update_role_mapping(LEX_CSTRING *user, LEX_CSTRING *host, LEX_CSTRING *role,
bool with_admin, ROLE_GRANT_PAIR *existing, bool revoke_grant)
{
if (revoke_grant)
@@ -5823,7 +5824,8 @@ static int db_name_sort(ACL_DB * const *db1, ACL_DB * const *db2)
2 - ACL_DB was added
4 - ACL_DB was deleted
*/
-static int update_role_db(ACL_DB *merged, ACL_DB **first, ulong access, char *role)
+static int update_role_db(ACL_DB *merged, ACL_DB **first, ulong access,
+ const char *role)
{
if (!first)
return 0;
@@ -6043,8 +6045,8 @@ static int update_role_columns(GRANT_TABLE *merged,
4 - GRANT_TABLE was deleted
*/
static int update_role_table_columns(GRANT_TABLE *merged,
- GRANT_TABLE **first, GRANT_TABLE **last,
- ulong privs, ulong cols, char *role)
+ GRANT_TABLE **first, GRANT_TABLE **last,
+ ulong privs, ulong cols, const char *role)
{
if (!first)
return 0;
@@ -6173,7 +6175,7 @@ static int routine_name_sort(GRANT_NAME * const *r1, GRANT_NAME * const *r2)
4 - GRANT_NAME was deleted
*/
static int update_role_routines(GRANT_NAME *merged, GRANT_NAME **first,
- ulong privs, char *role, HASH *hash)
+ ulong privs, const char *role, HASH *hash)
{
if (!first)
return 0;
@@ -6392,7 +6394,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
List_iterator <LEX_USER> str_list (user_list);
LEX_USER *Str, *tmp_Str;
bool create_new_users=0;
- char *db_name, *table_name;
+ const char *db_name, *table_name;
DBUG_ENTER("mysql_table_grant");
if (rights & ~TABLE_ACLS)
@@ -6642,7 +6644,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
List_iterator <LEX_USER> str_list (user_list);
LEX_USER *Str, *tmp_Str;
bool create_new_users= 0, result;
- char *db_name, *table_name;
+ const char *db_name, *table_name;
DBUG_ENTER("mysql_routine_grant");
if (rights & ~PROC_ACLS)
@@ -6752,7 +6754,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
append a user or role name to a buffer that will be later used as an error message
*/
static void append_user(THD *thd, String *str,
- const LEX_STRING *u, const LEX_STRING *h)
+ const LEX_CSTRING *u, const LEX_CSTRING *h)
{
if (str->length())
str->append(',');
@@ -6795,11 +6797,11 @@ static int can_grant_role_callback(ACL_USER_BASE *grantee,
return 0; // keep searching
if (grantee->flags & IS_ROLE)
- pair= find_role_grant_pair(&grantee->user, &empty_lex_str, &role->user);
+ pair= find_role_grant_pair(&grantee->user, &empty_clex_str, &role->user);
else
{
ACL_USER *user= (ACL_USER *)grantee;
- LEX_STRING host= { user->host.hostname, user->hostname_length };
+ LEX_CSTRING host= { user->host.hostname, user->hostname_length };
pair= find_role_grant_pair(&user->user, &host, &role->user);
}
if (!pair->with_admin)
@@ -6844,9 +6846,9 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
bool create_new_user, no_auto_create_user;
String wrong_users;
LEX_USER *user, *granted_role;
- LEX_STRING rolename;
- LEX_STRING username;
- LEX_STRING hostname;
+ LEX_CSTRING rolename;
+ LEX_CSTRING username;
+ LEX_CSTRING hostname;
ACL_ROLE *role, *role_as_user;
List_iterator <LEX_USER> user_list(list);
@@ -6900,9 +6902,9 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
}
if (!(role_as_user= find_acl_role(thd->security_ctx->priv_role)))
{
- LEX_STRING ls= { thd->security_ctx->priv_role,
- strlen(thd->security_ctx->priv_role) };
- append_user(thd, &wrong_users, &ls, &empty_lex_str);
+ LEX_CSTRING ls= { thd->security_ctx->priv_role,
+ strlen(thd->security_ctx->priv_role) };
+ append_user(thd, &wrong_users, &ls, &empty_clex_str);
result= 1;
continue;
}
@@ -6910,13 +6912,13 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
/* can not grant current_role to current_role */
if (granted_role->user.str == current_role.str)
{
- append_user(thd, &wrong_users, &role_as_user->user, &empty_lex_str);
+ append_user(thd, &wrong_users, &role_as_user->user, &empty_clex_str);
result= 1;
continue;
}
username.str= thd->security_ctx->priv_role;
username.length= strlen(username.str);
- hostname= empty_lex_str;
+ hostname= empty_clex_str;
}
else if (user->user.str == current_user.str)
{
@@ -6932,12 +6934,12 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
hostname= user->host;
else
if ((role_as_user= find_acl_role(user->user.str)))
- hostname= empty_lex_str;
+ hostname= empty_clex_str;
else
{
if (is_invalid_role_name(username.str))
{
- append_user(thd, &wrong_users, &username, &empty_lex_str);
+ append_user(thd, &wrong_users, &username, &empty_clex_str);
result= 1;
continue;
}
@@ -6999,7 +7001,7 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
if (role_as_user &&
traverse_role_graph_down(role, 0, 0, 0) == ROLE_CYCLE_FOUND)
{
- append_user(thd, &wrong_users, &username, &empty_lex_str);
+ append_user(thd, &wrong_users, &username, &empty_clex_str);
result= 1;
undo_add_role_user_mapping(grantee, role);
continue;
@@ -7034,7 +7036,7 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
thd->lex->with_admin_option,
hash_entry, revoke))
{
- append_user(thd, &wrong_users, &username, &empty_lex_str);
+ append_user(thd, &wrong_users, &username, &empty_clex_str);
result= 1;
if (!revoke)
{
@@ -7887,7 +7889,7 @@ bool check_grant_all_columns(THD *thd, ulong want_access_arg,
for (; !fields->end_of_fields(); fields->next())
{
- const char *field_name= fields->name();
+ LEX_CSTRING *field_name= fields->name();
if (table_name != fields->get_table_name())
{
@@ -7924,16 +7926,15 @@ bool check_grant_all_columns(THD *thd, ulong want_access_arg,
if (grant_table)
{
GRANT_COLUMN *grant_column=
- column_hash_search(grant_table, field_name,
- (uint) strlen(field_name));
+ column_hash_search(grant_table, field_name->str, field_name->length);
if (grant_column)
have_access= grant_column->rights;
}
if (grant_table_role)
{
GRANT_COLUMN *grant_column=
- column_hash_search(grant_table_role, field_name,
- (uint) strlen(field_name));
+ column_hash_search(grant_table_role, field_name->str,
+ field_name->length);
if (grant_column)
have_access|= grant_column->rights;
}
@@ -7965,7 +7966,7 @@ err:
command,
sctx->priv_user,
sctx->host_or_ip,
- fields->name(),
+ fields->name()->str,
table_name);
return 1;
}
@@ -8466,8 +8467,9 @@ static bool print_grants_for_role(THD *thd, ACL_ROLE * role)
that a role can never happen here, so *rolename will never
be assigned to
*/
-static bool check_show_access(THD *thd, LEX_USER *lex_user, char **username,
- char **hostname, char **rolename)
+static bool check_show_access(THD *thd, LEX_USER *lex_user,
+ const char **username,
+ const char **hostname, const char **rolename)
{
DBUG_ENTER("check_show_access");
@@ -8516,26 +8518,26 @@ static bool check_show_access(THD *thd, LEX_USER *lex_user, char **username,
bool mysql_show_create_user(THD *thd, LEX_USER *lex_user)
{
- char *username= NULL, *hostname= NULL;
+ const char *username= NULL, *hostname= NULL;
char buff[1024]; //Show create user should not take more than 1024 bytes.
Protocol *protocol= thd->protocol;
bool error= false;
ACL_USER *acl_user;
+ uint head_length;
DBUG_ENTER("mysql_show_create_user");
if (check_show_access(thd, lex_user, &username, &hostname, NULL))
DBUG_RETURN(TRUE);
List<Item> field_list;
- strxmov(buff, "CREATE USER for ", username, "@", hostname, NullS);
+ head_length= (uint) (strxmov(buff, "CREATE USER for ", username, "@",
+ hostname, NullS) - buff);
Item_string *field = new (thd->mem_root) Item_string_ascii(thd, "", 0);
if (!field)
- {
- my_error(ER_OUTOFMEMORY, MYF(0));
DBUG_RETURN(true);
- }
- field->name= buff;
+ field->name.str= buff;
+ field->name.length= head_length;
field->max_length= sizeof(buff);
field_list.push_back(field, thd->mem_root);
if (protocol->send_result_set_metadata(&field_list,
@@ -8590,10 +8592,12 @@ static int show_grants_callback(ACL_USER_BASE *role, void *data)
}
void mysql_show_grants_get_fields(THD *thd, List<Item> *fields,
- const char *name)
+ const char *name, size_t length)
{
Item_string *field=new (thd->mem_root) Item_string_ascii(thd, "", 0);
- field->name= (char *) name;
+ /* Set name explicit to avoid character set conversions */
+ field->name.str= name;
+ field->name.length= length;
field->max_length=1024;
fields->push_back(field, thd->mem_root);
}
@@ -8613,7 +8617,7 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
ACL_ROLE *acl_role= NULL;
char buff[1024];
Protocol *protocol= thd->protocol;
- char *username= NULL, *hostname= NULL, *rolename= NULL;
+ const char *username= NULL, *hostname= NULL, *rolename= NULL, *end;
DBUG_ENTER("mysql_show_grants");
if (!initialized)
@@ -8628,11 +8632,11 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
List<Item> field_list;
if (!username)
- strxmov(buff,"Grants for ",rolename, NullS);
+ end= strxmov(buff,"Grants for ",rolename, NullS);
else
- strxmov(buff,"Grants for ",username,"@",hostname, NullS);
+ end= strxmov(buff,"Grants for ",username,"@",hostname, NullS);
- mysql_show_grants_get_fields(thd, &field_list, buff);
+ mysql_show_grants_get_fields(thd, &field_list, buff, (uint) (end-buff));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -8713,9 +8717,9 @@ end:
DBUG_RETURN(error);
}
-static ROLE_GRANT_PAIR *find_role_grant_pair(const LEX_STRING *u,
- const LEX_STRING *h,
- const LEX_STRING *r)
+static ROLE_GRANT_PAIR *find_role_grant_pair(const LEX_CSTRING *u,
+ const LEX_CSTRING *h,
+ const LEX_CSTRING *r)
{
char buf[1024];
String pair_key(buf, sizeof(buf), &my_charset_bin);
@@ -8736,7 +8740,7 @@ static bool show_role_grants(THD *thd, const char *username,
{
uint counter;
Protocol *protocol= thd->protocol;
- LEX_STRING host= {const_cast<char*>(hostname), strlen(hostname)};
+ LEX_CSTRING host= {const_cast<char*>(hostname), strlen(hostname)};
String grant(buff,sizeof(buff),system_charset_info);
for (counter= 0; counter < acl_entry->role_grants.elements; counter++)
@@ -9547,7 +9551,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
DBUG_RETURN(1);
/* this calls for a role update */
- char *old_key= acl_role->user.str;
+ const char *old_key= acl_role->user.str;
size_t old_key_length= acl_role->user.length;
if (drop)
{
@@ -11108,8 +11112,8 @@ static int enabled_roles_insert(ACL_USER_BASE *role, void *context_data)
struct APPLICABLE_ROLES_DATA
{
TABLE *table;
- const LEX_STRING host;
- const LEX_STRING user_and_host;
+ const LEX_CSTRING host;
+ const LEX_CSTRING user_and_host;
ACL_USER *user;
};
@@ -11120,9 +11124,9 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr)
CHARSET_INFO *cs= system_charset_info;
TABLE *table= data->table;
bool is_role= grantee != data->user;
- const LEX_STRING *user_and_host= is_role ? &grantee->user
+ const LEX_CSTRING *user_and_host= is_role ? &grantee->user
: &data->user_and_host;
- const LEX_STRING *host= is_role ? &empty_lex_str : &data->host;
+ const LEX_CSTRING *host= is_role ? &empty_clex_str : &data->host;
restore_record(table, s->default_values);
table->field[0]->store(user_and_host->str, user_and_host->length, cs);
@@ -11786,7 +11790,7 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock)
if (lock)
mysql_mutex_lock(&acl_cache->lock);
if (find_acl_role(dup->user.str))
- dup->host= empty_lex_str;
+ dup->host= empty_clex_str;
else
dup->host= host_not_specified;
if (lock)
@@ -11801,7 +11805,7 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock)
struct ACL_internal_schema_registry_entry
{
- const LEX_STRING *m_name;
+ const LEX_CSTRING *m_name;
const ACL_internal_schema_access *m_access;
};
@@ -11822,7 +11826,7 @@ static uint m_registry_array_size= 0;
@param access the schema ACL specific rules
*/
void ACL_internal_schema_registry::register_schema
- (const LEX_STRING *name, const ACL_internal_schema_access *access)
+ (const LEX_CSTRING *name, const ACL_internal_schema_access *access)
{
DBUG_ASSERT(m_registry_array_size < array_elements(registry_array));
@@ -11929,10 +11933,11 @@ struct MPVIO_EXT :public MYSQL_PLUGIN_VIO
MYSQL_SERVER_AUTH_INFO auth_info;
ACL_USER *acl_user; ///< a copy, independent from acl_users array
plugin_ref plugin; ///< what plugin we're under
- LEX_STRING db; ///< db name from the handshake packet
+ LEX_CSTRING db; ///< db name from the handshake packet
/** when restarting a plugin this caches the last client reply */
struct {
- char *plugin, *pkt; ///< pointers into NET::buff
+ const char *plugin;
+ char *pkt; ///< pointer into NET::buff
uint pkt_len;
} cached_client_reply;
/** this caches the first plugin packet for restart request on the client */
@@ -12425,7 +12430,7 @@ static bool parse_com_change_user_packet(MPVIO_EXT *mpvio, uint packet_length)
if (find_mpvio_user(mpvio))
DBUG_RETURN(1);
- char *client_plugin;
+ const char *client_plugin;
if (thd->client_capabilities & CLIENT_PLUGIN_AUTH)
{
if (next_field >= end)
@@ -12612,10 +12617,13 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
db_len= safe_strlen(db);
char *next_field;
- char *client_plugin= next_field= passwd + passwd_len + (db ? db_len + 1 : 0);
+ const char *client_plugin= next_field= passwd + passwd_len + (db ? db_len + 1 : 0);
- /* Since 4.1 all database names are stored in utf8 */
- if (thd->copy_with_error(system_charset_info, &mpvio->db,
+ /*
+ Since 4.1 all database names are stored in utf8
+ The cast is ok as copy_with_error will create a new area for db
+ */
+ if (thd->copy_with_error(system_charset_info, (LEX_STRING*) &mpvio->db,
thd->charset(), db, db_len))
return packet_error;
@@ -12642,7 +12650,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
Security_context *sctx= thd->security_ctx;
- my_free(sctx->user);
+ my_free((char*) sctx->user);
if (!(sctx->user= my_strndup(user, user_len, MYF(MY_WME))))
return packet_error; /* The error is set by my_strdup(). */
@@ -13003,7 +13011,7 @@ static bool acl_check_ssl(THD *thd, const ACL_USER *acl_user)
}
-static int do_auth_once(THD *thd, const LEX_STRING *auth_plugin_name,
+static int do_auth_once(THD *thd, const LEX_CSTRING *auth_plugin_name,
MPVIO_EXT *mpvio)
{
int res= CR_OK, old_status= MPVIO_EXT::FAILURE;
@@ -13085,7 +13093,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
{
int res= CR_OK;
MPVIO_EXT mpvio;
- const LEX_STRING *auth_plugin_name= default_auth_plugin_name;
+ const LEX_CSTRING *auth_plugin_name= default_auth_plugin_name;
enum enum_server_command command= com_change_user_pkt_len ? COM_CHANGE_USER
: COM_CONNECT;
DBUG_ENTER("acl_authenticate");
diff --git a/sql/sql_acl.h b/sql/sql_acl.h
index daa36f6c32a..f9646649c93 100644
--- a/sql/sql_acl.h
+++ b/sql/sql_acl.h
@@ -182,10 +182,10 @@ enum mysql_db_table_field
extern const TABLE_FIELD_DEF mysql_db_table_def;
extern bool mysql_user_table_is_in_short_password_format;
-extern LEX_STRING host_not_specified;
-extern LEX_STRING current_user;
-extern LEX_STRING current_role;
-extern LEX_STRING current_user_and_current_role;
+extern LEX_CSTRING host_not_specified;
+extern LEX_CSTRING current_user;
+extern LEX_CSTRING current_role;
+extern LEX_CSTRING current_user_and_current_role;
static inline int access_denied_error_code(int passwd_used)
@@ -194,7 +194,6 @@ static inline int access_denied_error_code(int passwd_used)
: ER_ACCESS_DENIED_ERROR;
}
-
/* prototypes */
bool hostname_requires_resolving(const char *hostname);
@@ -204,8 +203,8 @@ void acl_free(bool end=0);
ulong acl_get(const char *host, const char *ip,
const char *user, const char *db, my_bool db_is_pattern);
bool acl_authenticate(THD *thd, uint com_change_user_pkt_len);
-bool acl_getroot(Security_context *sctx, char *user, char *host,
- char *ip, char *db);
+bool acl_getroot(Security_context *sctx, const char *user, const char *host,
+ const char *ip, const char *db);
bool acl_check_host(const char *host, const char *ip);
bool check_change_password(THD *thd, LEX_USER *user);
bool change_password(THD *thd, LEX_USER *user);
@@ -243,7 +242,7 @@ ulong get_column_grant(THD *thd, GRANT_INFO *grant,
const char *db_name, const char *table_name,
const char *field_name);
void mysql_show_grants_get_fields(THD *thd, List<Item> *fields,
- const char *name);
+ const char *name, size_t length);
bool mysql_show_grants(THD *thd, LEX_USER *user);
bool mysql_show_create_user(THD *thd, LEX_USER *user);
int fill_schema_enabled_roles(THD *thd, TABLE_LIST *tables, COND *cond);
@@ -385,7 +384,7 @@ public:
class ACL_internal_schema_registry
{
public:
- static void register_schema(const LEX_STRING *name,
+ static void register_schema(const LEX_CSTRING *name,
const ACL_internal_schema_access *access);
static const ACL_internal_schema_access *lookup(const char *name);
};
@@ -401,8 +400,8 @@ get_cached_table_access(GRANT_INTERNAL_INFO *grant_internal_info,
bool acl_check_proxy_grant_access (THD *thd, const char *host, const char *user,
bool with_grant);
-int acl_setrole(THD *thd, char *rolename, ulonglong access);
-int acl_check_setrole(THD *thd, char *rolename, ulonglong *access);
+int acl_setrole(THD *thd, const char *rolename, ulonglong access);
+int acl_check_setrole(THD *thd, const char *rolename, ulonglong *access);
int acl_check_set_default_role(THD *thd, const char *host, const char *user);
int acl_set_default_role(THD *thd, const char *host, const char *user,
const char *rolename);
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index f9452077d36..f3ecee89a79 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -189,7 +189,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
if (!mysql_file_stat(key_file_misc, from, &stat_info, MYF(0)))
goto end; // Can't use USE_FRM flag
- my_snprintf(tmp, sizeof(tmp), "%s-%lx_%lx",
+ my_snprintf(tmp, sizeof(tmp), "%s-%lx_%llx",
from, current_pid, thd->thread_id);
if (table_list->table)
@@ -489,7 +489,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
for (table= tables; table; table= table->next_local)
{
char table_name[SAFE_NAME_LEN*2+2];
- char* db = table->db;
+ const char *db= table->db;
bool fatal_error=0;
bool open_error;
bool collect_eis= FALSE;
@@ -842,7 +842,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_NO_EIS_FOR_FIELD,
ER_THD(thd, ER_NO_EIS_FOR_FIELD),
- (*field_ptr)->field_name);
+ (*field_ptr)->field_name.str);
}
}
else
@@ -1234,7 +1234,7 @@ err2:
*/
bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
- LEX_STRING *key_cache_name)
+ const LEX_CSTRING *key_cache_name)
{
HA_CHECK_OPT check_opt;
KEY_CACHE *key_cache;
diff --git a/sql/sql_admin.h b/sql/sql_admin.h
index 96594fad0cb..e7f4086540a 100644
--- a/sql/sql_admin.h
+++ b/sql/sql_admin.h
@@ -20,7 +20,7 @@
#define SQL_ADMIN_MSG_TEXT_SIZE (128 * 1024)
bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list,
- LEX_STRING *key_cache_name);
+ const LEX_CSTRING *key_cache_name);
bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list);
int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache,
KEY_CACHE *dst_cache);
diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc
index 3592fa3cfbd..0194f26d217 100644
--- a/sql/sql_alter.cc
+++ b/sql/sql_alter.cc
@@ -50,7 +50,7 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
}
-bool Alter_info::set_requested_algorithm(const LEX_STRING *str)
+bool Alter_info::set_requested_algorithm(const LEX_CSTRING *str)
{
// To avoid adding new keywords to the grammar, we match strings here.
if (!my_strcasecmp(system_charset_info, str->str, "INPLACE"))
@@ -65,7 +65,7 @@ bool Alter_info::set_requested_algorithm(const LEX_STRING *str)
}
-bool Alter_info::set_requested_lock(const LEX_STRING *str)
+bool Alter_info::set_requested_lock(const LEX_CSTRING *str)
{
// To avoid adding new keywords to the grammar, we match strings here.
if (!my_strcasecmp(system_charset_info, str->str, "NONE"))
@@ -95,10 +95,15 @@ Alter_table_ctx::Alter_table_ctx()
{
}
+/*
+ TODO: new_name_arg changes if lower case table names.
+ Should be copied or converted before call
+*/
Alter_table_ctx::Alter_table_ctx(THD *thd, TABLE_LIST *table_list,
uint tables_opened_arg,
- char *new_db_arg, char *new_name_arg)
+ const char *new_db_arg,
+ const char *new_name_arg)
: datetime_field(NULL), error_if_not_empty(false),
tables_opened(tables_opened_arg),
new_db(new_db_arg), new_name(new_name_arg),
@@ -126,13 +131,14 @@ Alter_table_ctx::Alter_table_ctx(THD *thd, TABLE_LIST *table_list,
if (lower_case_table_names == 1) // Convert new_name/new_alias to lower case
{
- my_casedn_str(files_charset_info, new_name);
+ my_casedn_str(files_charset_info, (char*) new_name);
new_alias= new_name;
}
else if (lower_case_table_names == 2) // Convert new_name to lower case
{
- strmov(new_alias= new_alias_buff, new_name);
- my_casedn_str(files_charset_info, new_name);
+ new_alias= new_alias_buff;
+ strmov(new_alias_buff, new_name);
+ my_casedn_str(files_charset_info, (char*) new_name);
}
else
new_alias= new_name; // LCTN=0 => case sensitive + case preserving
@@ -154,7 +160,7 @@ Alter_table_ctx::Alter_table_ctx(THD *thd, TABLE_LIST *table_list,
new_name= table_name;
}
- my_snprintf(tmp_name, sizeof(tmp_name), "%s-%lx_%lx", tmp_file_prefix,
+ my_snprintf(tmp_name, sizeof(tmp_name), "%s-%lx_%llx", tmp_file_prefix,
current_pid, thd->thread_id);
/* Safety fix for InnoDB */
if (lower_case_table_names)
diff --git a/sql/sql_alter.h b/sql/sql_alter.h
index 4650e2b6a25..beec5090343 100644
--- a/sql/sql_alter.h
+++ b/sql/sql_alter.h
@@ -156,7 +156,7 @@ public:
// Enable or disable keys.
enum_enable_or_disable keys_onoff;
// List of partitions.
- List<char> partition_names;
+ List<const char> partition_names;
// Number of partitions.
uint num_parts;
// Type of ALTER TABLE algorithm.
@@ -216,7 +216,7 @@ public:
@retval false Supported value found, state updated
@retval true Not supported value, no changes made
*/
- bool set_requested_algorithm(const LEX_STRING *str);
+ bool set_requested_algorithm(const LEX_CSTRING *str);
/**
@@ -229,7 +229,7 @@ public:
@retval true Not supported value, no changes made
*/
- bool set_requested_lock(const LEX_STRING *str);
+ bool set_requested_lock(const LEX_CSTRING *str);
private:
Alter_info &operator=(const Alter_info &rhs); // not implemented
@@ -244,7 +244,7 @@ public:
Alter_table_ctx();
Alter_table_ctx(THD *thd, TABLE_LIST *table_list, uint tables_opened_arg,
- char *new_db_arg, char *new_name_arg);
+ const char *new_db_arg, const char *new_name_arg);
/**
@return true if the table is moved to another database, false otherwise.
@@ -306,12 +306,12 @@ public:
Create_field *datetime_field;
bool error_if_not_empty;
uint tables_opened;
- char *db;
- char *table_name;
- char *alias;
- char *new_db;
- char *new_name;
- char *new_alias;
+ const char *db;
+ const char *table_name;
+ const char *alias;
+ const char *new_db;
+ const char *new_name;
+ const char *new_alias;
char tmp_name[80];
/**
Indicates that if a row is deleted during copying of data from old version
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 91a80c552cb..d6af0410ad2 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -72,7 +72,7 @@ Procedure *
proc_analyse_init(THD *thd, ORDER *param, select_result *result,
List<Item> &field_list)
{
- char *proc_name = (*param->item)->name;
+ const char *proc_name = (*param->item)->name.str;
analyse *pc = new analyse(result);
field_info **f_info;
DBUG_ENTER("proc_analyse_init");
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index b0d42be6ad3..5e13d7cd759 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -502,7 +502,7 @@ err_with_reopen:
struct close_cached_connection_tables_arg
{
THD *thd;
- LEX_STRING *connection;
+ LEX_CSTRING *connection;
TABLE_LIST *tables;
};
@@ -547,7 +547,7 @@ end:
}
-bool close_cached_connection_tables(THD *thd, LEX_STRING *connection)
+bool close_cached_connection_tables(THD *thd, LEX_CSTRING *connection)
{
close_cached_connection_tables_arg argument;
DBUG_ENTER("close_cached_connections");
@@ -1481,7 +1481,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
TABLE *table;
const char *key;
uint key_length;
- char *alias= table_list->alias;
+ const char *alias= table_list->alias;
uint flags= ot_ctx->get_flags();
MDL_ticket *mdl_ticket;
TABLE_SHARE *share;
@@ -4174,8 +4174,9 @@ handle_routine(THD *thd, Query_tables_list *prelocking_ctx,
@note this can be changed to use a hash, instead of scanning the linked
list, if the performance of this function will ever become an issue
*/
-static bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_STRING *db,
- LEX_STRING *table, thr_lock_type lock_type)
+static bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_CSTRING *db,
+ LEX_CSTRING *table,
+ thr_lock_type lock_type)
{
for (; tl; tl= tl->next_global )
{
@@ -5246,7 +5247,7 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
for (; !field_it.end_of_fields(); field_it.next())
{
- if (!my_strcasecmp(system_charset_info, field_it.name(), name))
+ if (!my_strcasecmp(system_charset_info, field_it.name()->str, name))
{
// in PS use own arena or data will be freed after prepare
if (register_tree_change &&
@@ -5270,7 +5271,7 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
the replacing item.
*/
if (*ref && !(*ref)->is_autogenerated_name)
- item->set_name(thd, (*ref)->name, (*ref)->name_length,
+ item->set_name(thd, (*ref)->name.str, (*ref)->name.length,
system_charset_info);
if (register_tree_change)
thd->change_item_tree(ref, item);
@@ -5331,7 +5332,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name,
for (nj_col= NULL, curr_nj_col= field_it++; curr_nj_col;
curr_nj_col= field_it++)
{
- if (!my_strcasecmp(system_charset_info, curr_nj_col->name(), name))
+ if (!my_strcasecmp(system_charset_info, curr_nj_col->name()->str, name))
{
if (nj_col)
{
@@ -5358,15 +5359,10 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name,
*ref != NULL means that *ref contains the item that we need to
replace. If the item was aliased by the user, set the alias to
the replacing item.
- We need to set alias on both ref itself and on ref real item.
*/
if (*ref && !(*ref)->is_autogenerated_name)
- {
- item->set_name(thd, (*ref)->name, (*ref)->name_length,
+ item->set_name(thd, (*ref)->name.str, (*ref)->name.length,
system_charset_info);
- item->real_item()->set_name(thd, (*ref)->name, (*ref)->name_length,
- system_charset_info);
- }
if (register_tree_change && arena)
thd->restore_active_arena(arena, &backup);
@@ -5403,7 +5399,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name,
nj_col->table_field->fix_fields(thd, &ref))
{
DBUG_PRINT("info", ("column '%s' was dropped by the concurrent connection",
- nj_col->table_field->name));
+ nj_col->table_field->name.str));
DBUG_RETURN(NULL);
}
DBUG_ASSERT(ref == 0); // Should not have changed
@@ -5451,7 +5447,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
/* We assume here that table->field < NO_CACHED_FIELD_INDEX = UINT_MAX */
if (cached_field_index < table->s->fields &&
!my_strcasecmp(system_charset_info,
- table->field[cached_field_index]->field_name, name))
+ table->field[cached_field_index]->field_name.str, name))
field_ptr= table->field + cached_field_index;
else if (table->s->name_hash.records)
{
@@ -5471,7 +5467,8 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
if (!(field_ptr= table->field))
DBUG_RETURN((Field *)0);
for (; *field_ptr; ++field_ptr)
- if (!my_strcasecmp(system_charset_info, (*field_ptr)->field_name, name))
+ if (!my_strcasecmp(system_charset_info, (*field_ptr)->field_name.str,
+ name))
break;
}
@@ -5734,7 +5731,8 @@ Field *find_field_in_table_sef(TABLE *table, const char *name)
if (!(field_ptr= table->field))
return (Field *)0;
for (; *field_ptr; ++field_ptr)
- if (!my_strcasecmp(system_charset_info, (*field_ptr)->field_name, name))
+ if (!my_strcasecmp(system_charset_info, (*field_ptr)->field_name.str,
+ name))
break;
}
if (field_ptr)
@@ -5787,8 +5785,8 @@ find_field_in_tables(THD *thd, Item_ident *item,
Field *found=0;
const char *db= item->db_name;
const char *table_name= item->table_name;
- const char *name= item->field_name;
- uint length=(uint) strlen(name);
+ const char *name= item->field_name.str;
+ uint length= item->field_name.length;
char name_buff[SAFE_NAME_LEN+1];
TABLE_LIST *cur_table= first_table;
TABLE_LIST *actual_table;
@@ -5835,7 +5833,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
#endif
}
else
- found= find_field_in_table_ref(thd, table_ref, name, length, item->name,
+ found= find_field_in_table_ref(thd, table_ref, name, length, item->name.str,
NULL, NULL, ref, check_privileges,
TRUE, &(item->cached_field_index),
register_tree_change,
@@ -5903,7 +5901,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
cur_table= cur_table->next_name_resolution_table)
{
Field *cur_field= find_field_in_table_ref(thd, cur_table, name, length,
- item->name, db, table_name, ref,
+ item->name.str, db, table_name, ref,
(thd->lex->sql_command ==
SQLCOM_SHOW_FIELDS)
? false : check_privileges,
@@ -5920,7 +5918,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
thd->clear_error();
cur_field= find_field_in_table_ref(thd, cur_table, name, length,
- item->name, db, table_name, ref,
+ item->name.str, db, table_name, ref,
false,
allow_rowid,
&(item->cached_field_index),
@@ -5929,7 +5927,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
if (cur_field)
{
Field *nf=new Field_null(NULL,0,Field::NONE,
- cur_field->field_name,
+ &cur_field->field_name,
&my_charset_bin);
nf->init(cur_table->table);
cur_field= nf;
@@ -6045,7 +6043,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
uint n_items= limit == 0 ? items.elements : limit;
Item **found=0, **found_unaliased= 0, *item;
const char *db_name=0;
- const char *field_name=0;
+ const LEX_CSTRING *field_name= 0;
const char *table_name=0;
bool found_unaliased_non_uniq= 0;
/*
@@ -6061,7 +6059,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
find->type() == Item::REF_ITEM);
if (is_ref_by_name)
{
- field_name= ((Item_ident*) find)->field_name;
+ field_name= &((Item_ident*) find)->field_name;
table_name= ((Item_ident*) find)->table_name;
db_name= ((Item_ident*) find)->db_name;
}
@@ -6069,7 +6067,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
for (uint i= 0; i < n_items; i++)
{
item= li++;
- if (field_name &&
+ if (field_name && field_name->str &&
(item->real_item()->type() == Item::FIELD_ITEM ||
((item->type() == Item::REF_ITEM) &&
(((Item_ref *)item)->ref_type() == Item_ref::VIEW_REF))))
@@ -6082,7 +6080,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
(if this field created from expression argument of group_concat()),
=> we have to check presence of name before compare
*/
- if (!item_field->name)
+ if (!item_field->name.str)
continue;
if (table_name)
@@ -6103,9 +6101,9 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
item_field->field_name and item_field->table_name can be 0x0 if
item is not fix_field()'ed yet.
*/
- if (item_field->field_name && item_field->table_name &&
- !my_strcasecmp(system_charset_info, item_field->field_name,
- field_name) &&
+ if (item_field->field_name.str && item_field->table_name &&
+ !my_strcasecmp(system_charset_info, item_field->field_name.str,
+ field_name->str) &&
!my_strcasecmp(table_alias_charset, item_field->table_name,
table_name) &&
(!db_name || (item_field->db_name &&
@@ -6135,10 +6133,10 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
else
{
int fname_cmp= my_strcasecmp(system_charset_info,
- item_field->field_name,
- field_name);
+ item_field->field_name.str,
+ field_name->str);
if (!my_strcasecmp(system_charset_info,
- item_field->name,field_name))
+ item_field->name.str,field_name->str))
{
/*
If table name was not given we should scan through aliases
@@ -6182,8 +6180,9 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
}
else if (!table_name)
{
- if (is_ref_by_name && find->name && item->name &&
- !my_strcasecmp(system_charset_info,item->name,find->name))
+ if (is_ref_by_name && find->name.str && item->name.str &&
+ find->name.length == item->name.length &&
+ !my_strcasecmp(system_charset_info,item->name.str, find->name.str))
{
found= li.ref();
*counter= i;
@@ -6357,17 +6356,17 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
for (it_1.set(table_ref_1); !it_1.end_of_fields(); it_1.next())
{
bool found= FALSE;
- const char *field_name_1;
+ const LEX_CSTRING *field_name_1;
/* true if field_name_1 is a member of using_fields */
bool is_using_column_1;
if (!(nj_col_1= it_1.get_or_create_column_ref(thd, leaf_1)))
goto err;
field_name_1= nj_col_1->name();
is_using_column_1= using_fields &&
- test_if_string_in_list(field_name_1, using_fields);
+ test_if_string_in_list(field_name_1->str, using_fields);
DBUG_PRINT ("info", ("field_name_1=%s.%s",
nj_col_1->table_name() ? nj_col_1->table_name() : "",
- field_name_1));
+ field_name_1->str));
/*
Find a field with the same name in table_ref_2.
@@ -6380,14 +6379,14 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
for (it_2.set(table_ref_2); !it_2.end_of_fields(); it_2.next())
{
Natural_join_column *cur_nj_col_2;
- const char *cur_field_name_2;
+ const LEX_CSTRING *cur_field_name_2;
if (!(cur_nj_col_2= it_2.get_or_create_column_ref(thd, leaf_2)))
goto err;
cur_field_name_2= cur_nj_col_2->name();
DBUG_PRINT ("info", ("cur_field_name_2=%s.%s",
cur_nj_col_2->table_name() ?
cur_nj_col_2->table_name() : "",
- cur_field_name_2));
+ cur_field_name_2->str));
/*
Compare the two columns and check for duplicate common fields.
@@ -6400,13 +6399,14 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
here. These columns must be checked only on unqualified reference
by name (e.g. in SELECT list).
*/
- if (!my_strcasecmp(system_charset_info, field_name_1, cur_field_name_2))
+ if (!my_strcasecmp(system_charset_info, field_name_1->str,
+ cur_field_name_2->str))
{
DBUG_PRINT ("info", ("match c1.is_common=%d", nj_col_1->is_common));
if (cur_nj_col_2->is_common ||
(found && (!using_fields || is_using_column_1)))
{
- my_error(ER_NON_UNIQ_ERROR, MYF(0), field_name_1, thd->where);
+ my_error(ER_NON_UNIQ_ERROR, MYF(0), field_name_1->str, thd->where);
goto err;
}
nj_col_2= cur_nj_col_2;
@@ -6497,10 +6497,10 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
DBUG_PRINT ("info", ("%s.%s and %s.%s are common",
nj_col_1->table_name() ?
nj_col_1->table_name() : "",
- nj_col_1->name(),
+ nj_col_1->name()->str,
nj_col_2->table_name() ?
nj_col_2->table_name() : "",
- nj_col_2->name()));
+ nj_col_2->name()->str));
if (field_1)
{
@@ -6638,7 +6638,7 @@ store_natural_using_join_columns(THD *thd, TABLE_LIST *natural_using_join,
goto err;
}
if (!my_strcasecmp(system_charset_info,
- common_field->name(), using_field_name_ptr))
+ common_field->name()->str, using_field_name_ptr))
break; // Found match
}
}
@@ -6965,8 +6965,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
while (wild_num && (item= it++))
{
if (item->type() == Item::FIELD_ITEM &&
- ((Item_field*) item)->field_name &&
- ((Item_field*) item)->field_name[0] == '*' &&
+ ((Item_field*) item)->field_name.str == star_clex_str.str &&
!((Item_field*) item)->field)
{
uint elem= fields.elements;
@@ -7584,7 +7583,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
!(fld->have_privileges=
(get_column_grant(thd, field_iterator.grant(),
field_iterator.get_db_name(),
- field_table_name, fld->field_name) &
+ field_table_name, fld->field_name.str) &
VIEW_ANY_ACL)))
{
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), "ANY",
@@ -7913,7 +7912,7 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
fld= (Item_field*)f++;
if (!(field= fld->field_for_view_update()))
{
- my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name.str);
goto err;
}
DBUG_ASSERT(field->field->table == table_arg);
@@ -7925,7 +7924,7 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
{
if (!(field= fld->field_for_view_update()))
{
- my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name.str);
goto err;
}
value=v++;
@@ -7943,7 +7942,7 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,
ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
- rfield->field_name, table->s->table_name.str);
+ rfield->field_name.str, table->s->table_name.str);
}
if (rfield->stored_in_db() &&
(value->save_in_field(rfield, 0)) < 0 && !ignore_errors)
@@ -8188,7 +8187,7 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,
ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
- field->field_name, table->s->table_name.str);
+ field->field_name.str, table->s->table_name.str);
}
}
@@ -8452,7 +8451,7 @@ int init_ftfuncs(THD *thd, SELECT_LEX *select_lex, bool no_order)
}
-bool is_equal(const LEX_STRING *a, const LEX_STRING *b)
+bool is_equal(const LEX_CSTRING *a, const LEX_CSTRING *b)
{
return a->length == b->length && !strncmp(a->str, b->str, a->length);
}
diff --git a/sql/sql_base.h b/sql/sql_base.h
index 96bb1fb24cd..7a8d27c9147 100644
--- a/sql/sql_base.h
+++ b/sql/sql_base.h
@@ -261,7 +261,7 @@ int decide_logging_format(THD *thd, TABLE_LIST *tables);
void close_thread_table(THD *thd, TABLE **table_ptr);
TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
bool check_alias);
-bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
+bool is_equal(const LEX_CSTRING *a, const LEX_CSTRING *b);
class Open_tables_backup;
/* Functions to work with system tables. */
@@ -279,7 +279,7 @@ void close_performance_schema_table(THD *thd, Open_tables_state *backup);
bool close_cached_tables(THD *thd, TABLE_LIST *tables,
bool wait_for_refresh, ulong timeout);
-bool close_cached_connection_tables(THD *thd, LEX_STRING *connect_string);
+bool close_cached_connection_tables(THD *thd, LEX_CSTRING *connect_string);
void close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
ha_extra_function extra,
TABLE *skip_table);
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 0bf83915ba8..b2927c89fda 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -2336,7 +2336,7 @@ void Query_cache::invalidate(THD *thd, const char *key, uint32 key_length,
Remove all cached queries that uses the given database.
*/
-void Query_cache::invalidate(THD *thd, char *db)
+void Query_cache::invalidate(THD *thd, const char *db)
{
DBUG_ENTER("Query_cache::invalidate (db)");
if (is_disabled())
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index 945de307ffb..21f9c66dc4f 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -78,7 +78,7 @@ struct Query_cache_tls;
struct LEX;
class THD;
-typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
+typedef my_bool (*qc_engine_callback)(THD *thd, const char *table_key,
uint key_length,
ulonglong *engine_data);
@@ -482,7 +482,7 @@ protected:
my_bool using_transactions);
/* Remove all queries that uses any of the tables in following database */
- void invalidate(THD *thd, char *db);
+ void invalidate(THD *thd, const char *db);
/* Remove all queries that uses any of the listed following table */
void invalidate_by_MyISAM_filename(const char *filename);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index abd680d749f..f61e1f0885e 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -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();
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 52d2d12ae43..cc855c723e2 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -234,14 +234,11 @@ typedef struct st_copy_info {
class Key_part_spec :public Sql_alloc {
public:
- LEX_STRING field_name;
+ LEX_CSTRING field_name;
uint length;
- Key_part_spec(const LEX_STRING &name, uint len)
- : field_name(name), length(len)
+ Key_part_spec(const LEX_CSTRING *name, uint len)
+ : field_name(*name), length(len)
{}
- Key_part_spec(const char *name, const size_t name_len, uint len)
- : length(len)
- { field_name.str= (char *)name; field_name.length= name_len; }
bool operator==(const Key_part_spec& other) const;
/**
Construct a copy of this Key_part_spec. field_name is copied
@@ -304,37 +301,26 @@ public:
enum Keytype type;
KEY_CREATE_INFO key_create_info;
List<Key_part_spec> columns;
- LEX_STRING name;
+ LEX_CSTRING name;
engine_option_value *option_list;
bool generated;
- Key(enum Keytype type_par, const LEX_STRING &name_arg,
+ Key(enum Keytype type_par, const LEX_CSTRING *name_arg,
ha_key_alg algorithm_arg, bool generated_arg, DDL_options_st ddl_options)
:DDL_options(ddl_options),
type(type_par), key_create_info(default_key_create_info),
- name(name_arg), option_list(NULL), generated(generated_arg)
+ name(*name_arg), option_list(NULL), generated(generated_arg)
{
key_create_info.algorithm= algorithm_arg;
}
- Key(enum Keytype type_par, const LEX_STRING &name_arg,
+ Key(enum Keytype type_par, const LEX_CSTRING *name_arg,
KEY_CREATE_INFO *key_info_arg,
- bool generated_arg, List<Key_part_spec> &cols,
+ bool generated_arg, List<Key_part_spec> *cols,
engine_option_value *create_opt, DDL_options_st ddl_options)
:DDL_options(ddl_options),
- type(type_par), key_create_info(*key_info_arg), columns(cols),
- name(name_arg), option_list(create_opt), generated(generated_arg)
+ type(type_par), key_create_info(*key_info_arg), columns(*cols),
+ name(*name_arg), option_list(create_opt), generated(generated_arg)
{}
- Key(enum Keytype type_par, const char *name_arg, size_t name_len_arg,
- KEY_CREATE_INFO *key_info_arg, bool generated_arg,
- List<Key_part_spec> &cols,
- engine_option_value *create_opt, DDL_options_st ddl_options)
- :DDL_options(ddl_options),
- type(type_par), key_create_info(*key_info_arg), columns(cols),
- option_list(create_opt), generated(generated_arg)
- {
- name.str= (char *)name_arg;
- name.length= name_len_arg;
- }
Key(const Key &rhs, MEM_ROOT *mem_root);
virtual ~Key() {}
/* Equality comparison of keys (ignoring name) */
@@ -352,19 +338,18 @@ class Foreign_key: public Key {
public:
enum fk_match_opt { FK_MATCH_UNDEF, FK_MATCH_FULL,
FK_MATCH_PARTIAL, FK_MATCH_SIMPLE};
-
- LEX_STRING ref_db;
- LEX_STRING ref_table;
+ LEX_CSTRING ref_db;
+ LEX_CSTRING ref_table;
List<Key_part_spec> ref_columns;
uint delete_opt, update_opt, match_opt;
- Foreign_key(const LEX_STRING &name_arg, List<Key_part_spec> &cols,
- const LEX_STRING &ref_db_arg, const LEX_STRING &ref_table_arg,
- List<Key_part_spec> &ref_cols,
+ Foreign_key(const LEX_CSTRING *name_arg, List<Key_part_spec> *cols,
+ const LEX_CSTRING *ref_db_arg, const LEX_CSTRING *ref_table_arg,
+ List<Key_part_spec> *ref_cols,
uint delete_opt_arg, uint update_opt_arg, uint match_opt_arg,
DDL_options ddl_options)
:Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols, NULL,
ddl_options),
- ref_db(ref_db_arg), ref_table(ref_table_arg), ref_columns(ref_cols),
+ ref_db(*ref_db_arg), ref_table(*ref_table_arg), ref_columns(*ref_cols),
delete_opt(delete_opt_arg), update_opt(update_opt_arg),
match_opt(match_opt_arg)
{
@@ -668,7 +653,7 @@ typedef struct system_variables
CHARSET_INFO *collation_connection;
/* Names. These will be allocated in buffers in thd */
- LEX_STRING default_master_connection;
+ LEX_CSTRING default_master_connection;
/* Error messages */
MY_LOCALE *lc_messages;
@@ -1049,7 +1034,7 @@ public:
*/
enum enum_mark_columns mark_used_columns;
- LEX_STRING name; /* name for named prepared statements */
+ LEX_CSTRING name; /* name for named prepared statements */
LEX *lex; // parse tree descriptor
/*
Points to the query associated with this statement. It's const, but
@@ -1147,7 +1132,7 @@ public:
int insert(THD *thd, Statement *statement);
- Statement *find_by_name(LEX_STRING *name)
+ Statement *find_by_name(LEX_CSTRING *name)
{
Statement *stmt;
stmt= (Statement*)my_hash_search(&names_hash, (uchar*)name->str,
@@ -1230,7 +1215,7 @@ public:
ip - client IP
*/
const char *host;
- char *user, *ip;
+ const char *user, *ip;
char priv_user[USERNAME_LENGTH];
char proxy_user[USERNAME_LENGTH + MAX_HOSTNAME + 5];
/* The host privilege we are using */
@@ -1257,9 +1242,9 @@ public:
#ifndef NO_EMBEDDED_ACCESS_CHECKS
bool
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);
void
@@ -2880,7 +2865,7 @@ public:
If this is a slave, the name of the connection stored here.
This is used for taging error messages in the log files.
*/
- LEX_STRING connection_name;
+ LEX_CSTRING connection_name;
char default_master_connection_buff[MAX_CONNECTION_NAME+1];
uint8 password; /* 0, 1 or 2 */
uint8 failed_com_change_user;
@@ -3358,7 +3343,20 @@ public:
LEX_STRING *make_lex_string(LEX_STRING *lex_str, const char* str, uint length)
{
if (!(lex_str->str= strmake_root(mem_root, str, length)))
+ {
+ lex_str->length= 0;
+ return 0;
+ }
+ lex_str->length= length;
+ return lex_str;
+ }
+ LEX_CSTRING *make_lex_string(LEX_CSTRING *lex_str, const char* str, uint length)
+ {
+ if (!(lex_str->str= strmake_root(mem_root, str, length)))
+ {
+ lex_str->length= 0;
return 0;
+ }
lex_str->length= length;
return lex_str;
}
@@ -3371,6 +3369,14 @@ public:
return make_lex_string(lex_str, str, length);
}
+ LEX_CSTRING *make_clex_string(const char* str, uint length)
+ {
+ LEX_CSTRING *lex_str;
+ if (!(lex_str= (LEX_CSTRING *)alloc_root(mem_root, sizeof(LEX_CSTRING))))
+ return 0;
+ return make_lex_string(lex_str, str, length);
+ }
+
// Allocate LEX_STRING for character set conversion
bool alloc_lex_string(LEX_STRING *dst, uint length)
{
@@ -3806,7 +3812,7 @@ public:
allocate memory for a deep copy: current database may be freed after
a statement is parsed but before it's executed.
*/
- bool copy_db_to(char **p_db, size_t *p_db_length)
+ bool copy_db_to(const char **p_db, size_t *p_db_length)
{
if (db == NULL)
{
@@ -3912,11 +3918,11 @@ public:
}
void parse_error(uint err_number, const char *yytext= 0)
{
- return parse_error(ER_THD(this, err_number), yytext);
+ parse_error(ER_THD(this, err_number), yytext);
}
void parse_error()
{
- return parse_error(ER_SYNTAX_ERROR);
+ parse_error(ER_SYNTAX_ERROR);
}
private:
/*
@@ -4057,13 +4063,13 @@ public:
void binlog_invoker(bool role) { m_binlog_invoker= role ? INVOKER_ROLE : INVOKER_USER; }
enum need_invoker need_binlog_invoker() { return m_binlog_invoker; }
void get_definer(LEX_USER *definer, bool role);
- void set_invoker(const LEX_STRING *user, const LEX_STRING *host)
+ void set_invoker(const LEX_CSTRING *user, const LEX_CSTRING *host)
{
invoker_user= *user;
invoker_host= *host;
}
- LEX_STRING get_invoker_user() { return invoker_user; }
- LEX_STRING get_invoker_host() { return invoker_host; }
+ LEX_CSTRING get_invoker_user() { return invoker_user; }
+ LEX_CSTRING get_invoker_host() { return invoker_host; }
bool has_invoker() { return invoker_user.length > 0; }
void print_aborted_warning(uint threshold, const char *reason)
@@ -4163,8 +4169,8 @@ private:
TRIGGER or VIEW statements or current user in account management
statements if it is not NULL.
*/
- LEX_STRING invoker_user;
- LEX_STRING invoker_host;
+ LEX_CSTRING invoker_user;
+ LEX_CSTRING invoker_host;
public:
#ifndef EMBEDDED_LIBRARY
@@ -4459,13 +4465,13 @@ class sql_exchange :public Sql_alloc
{
public:
enum enum_filetype filetype; /* load XML, Added by Arnold & Erik */
- char *file_name;
+ const char *file_name;
String *field_term,*enclosed,*line_term,*line_start,*escaped;
bool opt_enclosed;
bool dumpfile;
ulong skip_lines;
CHARSET_INFO *cs;
- sql_exchange(char *name, bool dumpfile_flag,
+ sql_exchange(const char *name, bool dumpfile_flag,
enum_filetype filetype_arg= FILETYPE_CSV);
bool escaped_given(void);
};
@@ -5337,22 +5343,23 @@ typedef struct st_sort_buffer {
class Table_ident :public Sql_alloc
{
public:
- LEX_STRING db;
- LEX_STRING table;
+ LEX_CSTRING db;
+ LEX_CSTRING table;
SELECT_LEX_UNIT *sel;
- inline Table_ident(THD *thd, LEX_STRING db_arg, LEX_STRING table_arg,
+ inline Table_ident(THD *thd, const LEX_CSTRING *db_arg,
+ const LEX_CSTRING *table_arg,
bool force)
- :table(table_arg), sel((SELECT_LEX_UNIT *)0)
+ :table(*table_arg), sel((SELECT_LEX_UNIT *)0)
{
if (!force && (thd->client_capabilities & CLIENT_NO_SCHEMA))
- db.str=0;
+ db= null_clex_str;
else
- db= db_arg;
+ db= *db_arg;
}
- inline Table_ident(LEX_STRING table_arg)
- :table(table_arg), sel((SELECT_LEX_UNIT *)0)
+ inline Table_ident(const LEX_CSTRING *table_arg)
+ :table(*table_arg), sel((SELECT_LEX_UNIT *)0)
{
- db.str=0;
+ db= null_clex_str;
}
/*
This constructor is used only for the case when we create a derived
@@ -5369,9 +5376,9 @@ public:
table.length=1;
}
bool is_derived_table() const { return MY_TEST(sel); }
- inline void change_db(char *db_name)
+ inline void change_db(LEX_CSTRING *db_name)
{
- db.str= db_name; db.length= (uint) strlen(db_name);
+ db= *db_name;
}
};
@@ -5379,22 +5386,22 @@ public:
class Qualified_column_ident: public Table_ident
{
public:
- LEX_STRING m_column;
+ LEX_CSTRING m_column;
public:
- Qualified_column_ident(const LEX_STRING column)
- :Table_ident(null_lex_str),
- m_column(column)
+ Qualified_column_ident(const LEX_CSTRING *column)
+ :Table_ident(&null_clex_str),
+ m_column(*column)
{ }
- Qualified_column_ident(const LEX_STRING table, const LEX_STRING column)
+ Qualified_column_ident(const LEX_CSTRING *table, const LEX_CSTRING *column)
:Table_ident(table),
- m_column(column)
+ m_column(*column)
{ }
Qualified_column_ident(THD *thd,
- const LEX_STRING db,
- const LEX_STRING table,
- const LEX_STRING column)
+ const LEX_CSTRING *db,
+ const LEX_CSTRING *table,
+ const LEX_CSTRING *column)
:Table_ident(thd, db, table, false),
- m_column(column)
+ m_column(*column)
{ }
};
@@ -5405,7 +5412,7 @@ class user_var_entry
CHARSET_INFO *m_charset;
public:
user_var_entry() {} /* Remove gcc warning */
- LEX_STRING name;
+ LEX_CSTRING name;
char *value;
ulong length;
query_id_t update_query_id, used_query_id;
@@ -5420,7 +5427,7 @@ class user_var_entry
void set_charset(CHARSET_INFO *cs) { m_charset= cs; }
};
-user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
+user_var_entry *get_variable(HASH *hash, LEX_CSTRING *name,
bool create_if_not_exists);
class SORT_INFO;
@@ -5508,10 +5515,10 @@ public:
class my_var : public Sql_alloc {
public:
- const LEX_STRING name;
+ const LEX_CSTRING name;
enum type { SESSION_VAR, LOCAL_VAR, PARAM_VAR };
type scope;
- my_var(const LEX_STRING& j, enum type s) : name(j), scope(s) { }
+ my_var(const LEX_CSTRING *j, enum type s) : name(*j), scope(s) { }
virtual ~my_var() {}
virtual bool set(THD *thd, Item *val) = 0;
virtual class my_var_sp *get_my_var_sp() { return NULL; }
@@ -5526,7 +5533,7 @@ public:
runtime context is used for variable handling.
*/
sp_head *sp;
- my_var_sp(const LEX_STRING& j, uint o, const Type_handler *type_handler,
+ my_var_sp(const LEX_CSTRING *j, uint o, const Type_handler *type_handler,
sp_head *s)
: my_var(j, LOCAL_VAR), m_type_handler(type_handler), offset(o), sp(s) { }
~my_var_sp() { }
@@ -5543,7 +5550,7 @@ class my_var_sp_row_field: public my_var_sp
{
uint m_field_offset;
public:
- my_var_sp_row_field(const LEX_STRING &varname, const LEX_STRING &fieldname,
+ my_var_sp_row_field(const LEX_CSTRING *varname, const LEX_CSTRING *fieldname,
uint var_idx, uint field_idx, sp_head *s)
:my_var_sp(varname, var_idx, &type_handler_double/*Not really used*/, s),
m_field_offset(field_idx)
@@ -5553,7 +5560,7 @@ public:
class my_var_user: public my_var {
public:
- my_var_user(const LEX_STRING& j)
+ my_var_user(const LEX_CSTRING *j)
: my_var(j, SESSION_VAR) { }
~my_var_user() { }
bool set(THD *thd, Item *val);
@@ -5915,13 +5922,13 @@ class Sql_mode_save
class Database_qualified_name
{
public:
- LEX_STRING m_db;
- LEX_STRING m_name;
- Database_qualified_name(const LEX_STRING db, const LEX_STRING name)
- :m_db(db), m_name(name)
+ LEX_CSTRING m_db;
+ LEX_CSTRING m_name;
+ Database_qualified_name(const LEX_CSTRING *db, const LEX_CSTRING *name)
+ :m_db(*db), m_name(*name)
{ }
- Database_qualified_name(char *db, size_t db_length,
- char *name, size_t name_length)
+ Database_qualified_name(const char *db, size_t db_length,
+ const char *name, size_t name_length)
{
m_db.str= db;
m_db.length= db_length;
@@ -5952,14 +5959,15 @@ public:
(int) m_name.length, m_name.str);
}
// Export db and name as a qualified name string, allocate on mem_root.
- bool make_qname(THD *thd, LEX_STRING *dst) const
+ bool make_qname(THD *thd, LEX_CSTRING *dst) const
{
const uint dot= !!m_db.length;
+ char *tmp;
/* format: [database + dot] + name + '\0' */
dst->length= m_db.length + dot + m_name.length;
- if (!(dst->str= (char*) thd->alloc(dst->length + 1)))
+ if (!(dst->str= tmp= (char*) thd->alloc(dst->length + 1)))
return true;
- sprintf(dst->str, "%.*s%.*s%.*s",
+ sprintf(tmp, "%.*s%.*s%.*s",
(int) m_db.length, (m_db.length ? m_db.str : ""),
dot, ".",
(int) m_name.length, m_name.str);
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 5cb4cd87296..d8ac571b578 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -382,7 +382,7 @@ void reset_mqh(LEX_USER *lu, bool get_them= 0)
static const char mysql_system_user[]= "#mysql_system#";
// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
-static const char * get_valid_user_string(char* user)
+static const char * get_valid_user_string(const char* user)
{
return user ? user : mysql_system_user;
}
@@ -1108,7 +1108,7 @@ bool login_connection(THD *thd)
/* Updates global user connection stats. */
if (increment_connection_count(thd, TRUE))
{
- my_error(ER_OUTOFMEMORY, MYF(0), 2*sizeof(USER_STATS));
+ my_error(ER_OUTOFMEMORY, MYF(0), (int) (2*sizeof(USER_STATS)));
error= 1;
goto exit;
}
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index d76ee13a010..7c2a8cf9e65 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -677,8 +677,7 @@ bool With_clause::prepare_unreferenced_elements(THD *thd)
bool With_element::set_unparsed_spec(THD *thd, char *spec_start, char *spec_end)
{
unparsed_spec.length= spec_end - spec_start;
- unparsed_spec.str= (char*) thd->memdup(spec_start, unparsed_spec.length+1);
- unparsed_spec.str[unparsed_spec.length]= '\0';
+ unparsed_spec.str= thd->strmake(spec_start, unparsed_spec.length);
if (!unparsed_spec.str)
{
@@ -748,7 +747,7 @@ st_select_lex_unit *With_element::clone_parsed_spec(THD *thd,
TABLE_LIST *spec_tables_tail;
st_select_lex *with_select;
- if (parser_state.init(thd, unparsed_spec.str, unparsed_spec.length))
+ if (parser_state.init(thd, (char*) unparsed_spec.str, unparsed_spec.length))
goto err;
lex_start(thd);
with_select= &lex->select_lex;
@@ -830,9 +829,9 @@ With_element::rename_columns_of_derived_unit(THD *thd,
if (column_list.elements) // The column list is optional
{
List_iterator_fast<Item> it(select->item_list);
- List_iterator_fast<LEX_STRING> nm(column_list);
+ List_iterator_fast<LEX_CSTRING> nm(column_list);
Item *item;
- LEX_STRING *name;
+ LEX_CSTRING *name;
if (column_list.elements != select->item_list.elements)
{
diff --git a/sql/sql_cte.h b/sql/sql_cte.h
index 227461a16b3..a87c1b8acbd 100644
--- a/sql/sql_cte.h
+++ b/sql/sql_cte.h
@@ -63,7 +63,7 @@ private:
Unparsed specification of the query that specifies this element.
It used to build clones of the specification if they are needed.
*/
- LEX_STRING unparsed_spec;
+ LEX_CSTRING unparsed_spec;
/* Return the map where 1 is set only in the position for this element */
table_map get_elem_map() { return (table_map) 1 << number; }
@@ -73,14 +73,14 @@ public:
The name of the table introduced by this with elememt. The name
can be used in FROM lists of the queries in the scope of the element.
*/
- LEX_STRING *query_name;
+ LEX_CSTRING *query_name;
/*
Optional list of column names to name the columns of the table introduced
by this with element. It is used in the case when the names are not
inherited from the query that specified the table. Otherwise the list is
always empty.
*/
- List <LEX_STRING> column_list;
+ List <LEX_CSTRING> column_list;
/* The query that specifies the table introduced by this with element */
st_select_lex_unit *spec;
/*
@@ -119,8 +119,8 @@ public:
*/
select_union_recursive *rec_result;
- With_element(LEX_STRING *name,
- List <LEX_STRING> list,
+ With_element(LEX_CSTRING *name,
+ List <LEX_CSTRING> list,
st_select_lex_unit *unit)
: next(NULL), base_dep_map(0), derived_dep_map(0),
sq_dep_map(0), work_dep_map(0), mutually_recursive(0),
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 6054c45b1c3..f91b92b1d4f 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -53,16 +53,16 @@ const char *del_exts[]= {".BAK", ".opt", NullS};
static TYPELIB deletable_extentions=
{array_elements(del_exts)-1,"del_exts", del_exts, NULL};
-static bool find_db_tables_and_rm_known_files(THD *, MY_DIR *, char *,
+static bool find_db_tables_and_rm_known_files(THD *, MY_DIR *, const char *,
const char *, TABLE_LIST **);
long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path);
static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error);
static void mysql_change_db_impl(THD *thd,
- LEX_STRING *new_db_name,
+ LEX_CSTRING *new_db_name,
ulong new_db_access,
CHARSET_INFO *new_db_charset);
-static bool mysql_rm_db_internal(THD *thd, char *db,
+static bool mysql_rm_db_internal(THD *thd, const char *db,
bool if_exists, bool silent);
@@ -122,8 +122,8 @@ uchar* dboptions_get_key(my_dbopt_t *opt, size_t *length,
Helper function to write a query to binlog used by mysql_rm_db()
*/
-static inline int write_to_binlog(THD *thd, char *query, uint q_len,
- char *db, uint db_len)
+static inline int write_to_binlog(THD *thd, const char *query, uint q_len,
+ const char *db, uint db_len)
{
Query_log_event qinfo(thd, query, q_len, FALSE, TRUE, FALSE, 0);
qinfo.db= db;
@@ -566,7 +566,7 @@ CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name)
*/
static int
-mysql_create_db_internal(THD *thd, char *db,
+mysql_create_db_internal(THD *thd, const char *db,
const DDL_options_st &options,
Schema_specification_st *create_info,
bool silent)
@@ -584,7 +584,7 @@ mysql_create_db_internal(THD *thd, char *db,
}
char db_tmp[SAFE_NAME_LEN];
- char *dbnorm= normalize_db_name(db, db_tmp, sizeof(db_tmp));
+ const char *dbnorm= normalize_db_name(db, db_tmp, sizeof(db_tmp));
if (lock_schema_name(thd, dbnorm))
DBUG_RETURN(-1);
@@ -764,7 +764,7 @@ exit:
}
-int mysql_create_db(THD *thd, char *db,
+int mysql_create_db(THD *thd, const char *db,
const DDL_options_st &options,
const Schema_specification_st *create_info)
{
@@ -805,7 +805,7 @@ bool mysql_alter_db(THD *thd, const char *db,
*/
static bool
-mysql_rm_db_internal(THD *thd,char *db, bool if_exists, bool silent)
+mysql_rm_db_internal(THD *thd, const char *db, bool if_exists, bool silent)
{
ulong deleted_tables= 0;
bool error= true, rm_mysql_schema;
@@ -818,7 +818,7 @@ mysql_rm_db_internal(THD *thd,char *db, bool if_exists, bool silent)
DBUG_ENTER("mysql_rm_db");
char db_tmp[SAFE_NAME_LEN];
- char *dbnorm= normalize_db_name(db, db_tmp, sizeof(db_tmp));
+ const char *dbnorm= normalize_db_name(db, db_tmp, sizeof(db_tmp));
if (lock_schema_name(thd, dbnorm))
DBUG_RETURN(true);
@@ -884,8 +884,8 @@ mysql_rm_db_internal(THD *thd,char *db, bool if_exists, bool silent)
{
for (table= tables; table; table= table->next_local)
{
- LEX_STRING db_name= { table->db, table->db_length };
- LEX_STRING table_name= { table->table_name, table->table_name_length };
+ LEX_CSTRING db_name= { table->db, table->db_length };
+ LEX_CSTRING table_name= { table->table_name, table->table_name_length };
if (table->open_type == OT_BASE_ONLY ||
!thd->find_temporary_table(table))
(void) delete_statistics_for_table(thd, &db_name, &table_name);
@@ -997,7 +997,8 @@ update_binlog:
if (ha_table_exists(thd, tbl->db, tbl->table_name))
continue;
- my_snprintf(quoted_name, sizeof(quoted_name), "%`s", tbl->table_name);
+ my_snprintf(quoted_name, sizeof(quoted_name), quoted_string,
+ tbl->table_name);
tbl_name_len= strlen(quoted_name) + 1; /* +1 for the comma */
if (query_pos + tbl_name_len + 1 >= query_end)
{
@@ -1048,25 +1049,25 @@ exit:
}
-bool mysql_rm_db(THD *thd,char *db, bool if_exists)
+bool mysql_rm_db(THD *thd, const char *db, bool if_exists)
{
return mysql_rm_db_internal(thd, db, if_exists, false);
}
static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
- char *dbname,
+ const char *dbname,
const char *path,
TABLE_LIST **tables)
{
char filePath[FN_REFLEN];
- LEX_STRING db= { dbname, strlen(dbname) };
+ LEX_CSTRING db= { dbname, strlen(dbname) };
TABLE_LIST *tot_list=0, **tot_list_next_local, **tot_list_next_global;
DBUG_ENTER("find_db_tables_and_rm_known_files");
DBUG_PRINT("enter",("path: %s", path));
/* first, get the list of tables */
- Dynamic_array<LEX_STRING*> files(dirp->number_of_files);
+ Dynamic_array<LEX_CSTRING*> files(dirp->number_of_files);
Discovered_table_list tl(thd, &files);
if (ha_discover_table_names(thd, &db, dirp, &tl, true))
DBUG_RETURN(1);
@@ -1076,7 +1077,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
for (size_t idx=0; idx < files.elements(); idx++)
{
- LEX_STRING *table= files.at(idx);
+ LEX_CSTRING *table= files.at(idx);
/* Drop the table nicely */
TABLE_LIST *table_list=(TABLE_LIST*)thd->calloc(sizeof(*table_list));
@@ -1092,7 +1093,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
/* To be able to correctly look up the table in the table cache. */
if (lower_case_table_names)
table_list->table_name_length= my_casedn_str(files_charset_info,
- table_list->table_name);
+ (char*) table_list->table_name);
table_list->alias= table_list->table_name; // If lower_case_table_names=2
table_list->mdl_request.init(MDL_key::TABLE, table_list->db,
@@ -1298,7 +1299,7 @@ err:
*/
static void mysql_change_db_impl(THD *thd,
- LEX_STRING *new_db_name,
+ LEX_CSTRING *new_db_name,
ulong new_db_access,
CHARSET_INFO *new_db_charset)
{
@@ -1330,7 +1331,7 @@ static void mysql_change_db_impl(THD *thd,
the previous database name, we should do it explicitly.
*/
thd->set_db(NULL, 0);
- thd->reset_db(new_db_name->str, new_db_name->length);
+ thd->reset_db(const_cast<char*>(new_db_name->str), new_db_name->length);
}
/* 2. Update security context. */
@@ -1442,9 +1443,10 @@ static void backup_current_db_name(THD *thd,
@retval TRUE Error
*/
-bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
+bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name,
+ bool force_switch)
{
- LEX_STRING new_db_file_name;
+ LEX_CSTRING new_db_file_name;
Security_context *sctx= thd->security_ctx;
ulong db_access= sctx->db_access;
@@ -1507,12 +1509,13 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
It's next to impossible however to get this error when we are called
from sp_head::execute(). But let's switch the current database to NULL
in this case to be sure.
+ The cast below ok here as new_db_file_name was just allocated
*/
- if (check_db_name(&new_db_file_name))
+ if (check_db_name((LEX_STRING*) &new_db_file_name))
{
my_error(ER_WRONG_DB_NAME, MYF(0), new_db_file_name.str);
- my_free(new_db_file_name.str);
+ my_free(const_cast<char*>(new_db_file_name.str));
if (force_switch)
mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
@@ -1546,7 +1549,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
new_db_file_name.str);
general_log_print(thd, COM_INIT_DB, ER_THD(thd, ER_DBACCESS_DENIED_ERROR),
sctx->priv_user, sctx->priv_host, new_db_file_name.str);
- my_free(new_db_file_name.str);
+ my_free(const_cast<char*>(new_db_file_name.str));
DBUG_RETURN(TRUE);
}
#endif
@@ -1563,7 +1566,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
ER_BAD_DB_ERROR, ER_THD(thd, ER_BAD_DB_ERROR),
new_db_file_name.str);
- my_free(new_db_file_name.str);
+ my_free(const_cast<char*>(new_db_file_name.str));
/* Change db to NULL. */
@@ -1577,7 +1580,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
/* Report an error and free new_db_file_name. */
my_error(ER_BAD_DB_ERROR, MYF(0), new_db_file_name.str);
- my_free(new_db_file_name.str);
+ my_free(const_cast<char*>(new_db_file_name.str));
/* The operation failed. */
@@ -1622,7 +1625,7 @@ done:
*/
bool mysql_opt_change_db(THD *thd,
- const LEX_STRING *new_db_name,
+ const LEX_CSTRING *new_db_name,
LEX_STRING *saved_db_name,
bool force_switch,
bool *cur_db_changed)
@@ -1652,7 +1655,8 @@ bool mysql_opt_change_db(THD *thd,
@param old_db 5.0 database name, in #mysql50#name format
@return 0 on success, 1 on error
*/
-bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
+
+bool mysql_upgrade_db(THD *thd, LEX_CSTRING *old_db)
{
int error= 0, change_to_newdb= 0;
char path[FN_REFLEN+16];
@@ -1661,7 +1665,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
MY_DIR *dirp;
TABLE_LIST *table_list;
SELECT_LEX *sl= thd->lex->current_select;
- LEX_STRING new_db;
+ LEX_CSTRING new_db;
DBUG_ENTER("mysql_upgrade_db");
if ((old_db->length <= MYSQL50_TABLE_NAME_PREFIX_LENGTH) ||
@@ -1717,7 +1721,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
{
FILEINFO *file= dirp->dir_entry + idx;
char *extension, tname[FN_REFLEN + 1];
- LEX_STRING table_str;
+ LEX_CSTRING table_str;
DBUG_PRINT("info",("Examining: %s", file->name));
/* skiping non-FRM files */
@@ -1731,8 +1735,8 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
table_str.length= filename_to_tablename(file->name,
tname, sizeof(tname)-1);
table_str.str= (char*) thd->memdup(tname, table_str.length + 1);
- Table_ident *old_ident= new Table_ident(thd, *old_db, table_str, 0);
- Table_ident *new_ident= new Table_ident(thd, new_db, table_str, 0);
+ Table_ident *old_ident= new Table_ident(thd, old_db, &table_str, 0);
+ Table_ident *new_ident= new Table_ident(thd, &new_db, &table_str, 0);
if (!old_ident || !new_ident ||
!sl->add_table_to_list(thd, old_ident, NULL,
TL_OPTION_UPDATING, TL_IGNORE,
@@ -1881,7 +1885,7 @@ bool check_db_dir_existence(const char *db_name)
}
-char *normalize_db_name(char *db, char *buffer, size_t buffer_size)
+const char *normalize_db_name(const char *db, char *buffer, size_t buffer_size)
{
DBUG_ASSERT(buffer_size > 1);
if (!lower_case_table_names)
diff --git a/sql/sql_db.h b/sql/sql_db.h
index 7b3417dde1b..a4ada7de6a2 100644
--- a/sql/sql_db.h
+++ b/sql/sql_db.h
@@ -20,18 +20,18 @@
class THD;
-int mysql_create_db(THD *thd, char *db,
+int mysql_create_db(THD *thd, const char *db,
const DDL_options_st &options,
const Schema_specification_st *create);
bool mysql_alter_db(THD *thd, const char *db,
const Schema_specification_st *create);
-bool mysql_rm_db(THD *thd, char *db, bool if_exists);
-bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db);
-bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name,
+bool mysql_rm_db(THD *thd, const char *db, bool if_exists);
+bool mysql_upgrade_db(THD *thd, LEX_CSTRING *old_db);
+bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name,
bool force_switch);
bool mysql_opt_change_db(THD *thd,
- const LEX_STRING *new_db_name,
+ const LEX_CSTRING *new_db_name,
LEX_STRING *saved_db_name,
bool force_switch,
bool *cur_db_changed);
@@ -45,7 +45,8 @@ CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name);
bool my_dbopt_init(void);
void my_dbopt_cleanup(void);
-char *normalize_db_name(char *db, char *buffer, size_t buffer_size);
+const char *normalize_db_name(const char *db, char *buffer,
+ size_t buffer_size);
#define MY_DB_OPT_FILE "db.opt"
diff --git a/sql/sql_digest.cc b/sql/sql_digest.cc
index 7f6f3bbfe9b..18106a70475 100644
--- a/sql/sql_digest.cc
+++ b/sql/sql_digest.cc
@@ -570,7 +570,7 @@ sql_digest_state* digest_add_token(sql_digest_state *state,
case IDENT_QUOTED:
{
YYSTYPE *lex_token= yylval;
- char *yytext= lex_token->lex_str.str;
+ const char *yytext= lex_token->lex_str.str;
size_t yylen= lex_token->lex_str.length;
/*
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 745471a1365..144cf9d4a30 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -994,7 +994,7 @@ uint32 convert_error_message(char *to, uint32 to_length, CHARSET_INFO *to_cs,
@retval false if it's bad.
*/
-bool is_sqlstate_valid(const LEX_STRING *sqlstate)
+bool is_sqlstate_valid(const LEX_CSTRING *sqlstate)
{
if (sqlstate->length != 5)
return false;
diff --git a/sql/sql_error.h b/sql/sql_error.h
index bbe97333210..f020b9cc789 100644
--- a/sql/sql_error.h
+++ b/sql/sql_error.h
@@ -1244,7 +1244,7 @@ uint32 convert_error_message(char *to, uint32 to_length,
extern const LEX_STRING warning_level_names[];
-bool is_sqlstate_valid(const LEX_STRING *sqlstate);
+bool is_sqlstate_valid(const LEX_CSTRING *sqlstate);
/**
Checks if the specified SQL-state-string defines COMPLETION condition.
This function assumes that the given string contains a valid SQL-state.
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 357f1159367..5a86bffc51a 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -424,7 +424,7 @@ uint Explain_union::make_union_table_name(char *buf)
{
uint childno= 0;
uint len, lastop= 0;
- LEX_STRING type;
+ LEX_CSTRING type;
switch (operation)
{
case OP_MIX:
@@ -1147,7 +1147,8 @@ void Explain_index_use::set(MEM_ROOT *mem_root, KEY *key, uint key_len_arg)
uint len= 0;
for (uint i= 0; i < key->usable_key_parts; i++)
{
- key_parts_list.append_str(mem_root, key->key_part[i].field->field_name);
+ key_parts_list.append_str(mem_root,
+ key->key_part[i].field->field_name.str);
len += key->key_part[i].store_length;
if (len >= key_len_arg)
break;
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index d4673605e13..babb09a1267 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -549,7 +549,7 @@ SQL_HANDLER *mysql_ha_find_handler(THD *thd, const char *name)
static bool
mysql_ha_fix_cond_and_key(SQL_HANDLER *handler,
- enum enum_ha_read_modes mode, char *keyname,
+ enum enum_ha_read_modes mode, const char *keyname,
List<Item> *key_expr,
Item *cond, bool in_prepare)
{
@@ -671,7 +671,7 @@ mysql_ha_fix_cond_and_key(SQL_HANDLER *handler,
*/
bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
- enum enum_ha_read_modes mode, char *keyname,
+ enum enum_ha_read_modes mode, const char *keyname,
List<Item> *key_expr,
enum ha_rkey_function ha_rkey_mode, Item *cond,
ha_rows select_limit_cnt, ha_rows offset_limit_cnt)
@@ -926,7 +926,8 @@ err0:
*/
SQL_HANDLER *mysql_ha_read_prepare(THD *thd, TABLE_LIST *tables,
- enum enum_ha_read_modes mode, char *keyname,
+ enum enum_ha_read_modes mode,
+ const char *keyname,
List<Item> *key_expr, Item *cond)
{
SQL_HANDLER *handler;
diff --git a/sql/sql_handler.h b/sql/sql_handler.h
index 7fe5ae5bba8..cb1aff1d727 100644
--- a/sql/sql_handler.h
+++ b/sql/sql_handler.h
@@ -68,7 +68,7 @@ struct TABLE_LIST;
bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen);
bool mysql_ha_close(THD *thd, TABLE_LIST *tables);
-bool mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *,
+bool mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes, const char *,
List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
void mysql_ha_flush(THD *thd);
void mysql_ha_flush_tables(THD *thd, TABLE_LIST *all_tables);
@@ -78,6 +78,7 @@ void mysql_ha_set_explicit_lock_duration(THD *thd);
void mysql_ha_rm_temporary_tables(THD *thd);
SQL_HANDLER *mysql_ha_read_prepare(THD *thd, TABLE_LIST *tables,
- enum enum_ha_read_modes mode, char *keyname,
+ enum enum_ha_read_modes mode,
+ const char *keyname,
List<Item> *key_expr, Item *cond);
#endif
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index fc218cb18f2..bd11397e2aa 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -92,10 +92,14 @@ static bool init_fields(THD *thd, TABLE_LIST *tables,
context->resolve_in_table_list_only(tables);
for (; count-- ; find_fields++)
{
+ LEX_CSTRING field_name= {find_fields->field_name,
+ strlen(find_fields->field_name) };
/* We have to use 'new' here as field will be re_linked on free */
- Item_field *field= new (thd->mem_root) Item_field(thd, context,
- "mysql", find_fields->table_name,
- find_fields->field_name);
+ Item_field *field= (new (thd->mem_root)
+ Item_field(thd, context,
+ "mysql",
+ find_fields->table_name,
+ &field_name));
if (!(find_fields->field= find_field_in_tables(thd, field, tables, NULL,
0, REPORT_ALL_ERRORS, 1,
TRUE)))
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index f97732860ad..8085e3ded1b 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -289,7 +289,8 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
if (check_unique && thd->dup_field)
{
- my_error(ER_FIELD_SPECIFIED_TWICE, MYF(0), thd->dup_field->field_name);
+ my_error(ER_FIELD_SPECIFIED_TWICE, MYF(0),
+ thd->dup_field->field_name.str);
DBUG_RETURN(-1);
}
}
@@ -328,7 +329,8 @@ static bool has_no_default_value(THD *thd, Field *field, TABLE_LIST *table_list)
else
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_NO_DEFAULT_FOR_FIELD,
- ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD), field->field_name);
+ ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD),
+ field->field_name.str);
}
return thd->really_abort_on_warning();
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index aad5e2c0e51..dad438d1013 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -51,8 +51,12 @@ sys_var *trg_new_row_fake_var= (sys_var*) 0x01;
/**
LEX_STRING constant for null-string to be used in parser and other places.
*/
-const LEX_STRING null_lex_str= {NULL, 0};
-const LEX_STRING empty_lex_str= {(char *) "", 0};
+const LEX_STRING empty_lex_str= {(char *) "", 0};
+const LEX_CSTRING null_clex_str= {NULL, 0};
+const LEX_CSTRING empty_clex_str= {"", 0};
+const LEX_CSTRING star_clex_str= {"*", 1};
+const LEX_CSTRING param_clex_str= {"?", 1};
+
/**
@note The order of the elements of this array must correspond to
the order of elements in enum_binlog_stmt_unsafe.
@@ -192,8 +196,8 @@ init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex)
lex_start(thd);
context->init();
if ((!(table_ident= new Table_ident(thd,
- table->s->table_name,
- table->s->db, TRUE))) ||
+ &table->s->table_name,
+ &table->s->db, TRUE))) ||
(!(table_list= select_lex->add_table_to_list(thd,
table_ident,
NULL,
@@ -422,27 +426,28 @@ void Lex_input_stream::body_utf8_append(const char *ptr)
*/
void Lex_input_stream::body_utf8_append_ident(THD *thd,
- const LEX_STRING *txt,
+ const LEX_CSTRING *txt,
const char *end_ptr)
{
if (!m_cpp_utf8_processed_ptr)
return;
- LEX_STRING utf_txt;
+ LEX_CSTRING utf_txt;
CHARSET_INFO *txt_cs= thd->charset();
if (!my_charset_same(txt_cs, &my_charset_utf8_general_ci))
{
- thd->convert_string(&utf_txt,
+ LEX_STRING to;
+ thd->convert_string(&to,
&my_charset_utf8_general_ci,
txt->str, (uint) txt->length,
txt_cs);
+ utf_txt.str= to.str;
+ utf_txt.length= to.length;
+
}
else
- {
- utf_txt.str= txt->str;
- utf_txt.length= txt->length;
- }
+ utf_txt= *txt;
/* NOTE: utf_txt.length is in bytes, not in symbols. */
@@ -603,7 +608,7 @@ Lex_input_stream::get_escape_func(THD *thd, my_wc_t sep) const
@param sep - the string delimiter (single or double quote)
*/
void Lex_input_stream::body_utf8_append_escape(THD *thd,
- const LEX_STRING *txt,
+ const LEX_CSTRING *txt,
CHARSET_INFO *cs,
const char *end_ptr,
my_wc_t sep)
@@ -741,7 +746,7 @@ void LEX::start(THD *thd_arg)
create_info.lex_start();
verbose= 0;
- name= null_lex_str;
+ name= null_clex_str;
event_parse_data= NULL;
profile_options= PROFILE_NONE;
nest_level=0 ;
@@ -887,16 +892,16 @@ bool is_keyword(const char *name, uint len)
@retval 1 name isn't a function
*/
-bool is_lex_native_function(const LEX_STRING *name)
+bool is_lex_native_function(const LEX_CSTRING *name)
{
DBUG_ASSERT(name != NULL);
return (get_hash_symbol(name->str, (uint) name->length, 1) != 0);
}
-bool is_native_function(THD *thd, const LEX_STRING *name)
+bool is_native_function(THD *thd, const LEX_CSTRING *name)
{
- if (find_native_function_builder(thd, *name))
+ if (find_native_function_builder(thd, name))
return true;
if (is_lex_native_function(name))
@@ -906,7 +911,7 @@ bool is_native_function(THD *thd, const LEX_STRING *name)
}
-bool is_native_function_with_warn(THD *thd, const LEX_STRING *name)
+bool is_native_function_with_warn(THD *thd, const LEX_CSTRING *name)
{
if (!is_native_function(thd, name))
return false;
@@ -948,9 +953,9 @@ bool is_native_function_with_warn(THD *thd, const LEX_STRING *name)
/* make a copy of token before ptr and set yytoklen */
-static LEX_STRING get_token(Lex_input_stream *lip, uint skip, uint length)
+static LEX_CSTRING get_token(Lex_input_stream *lip, uint skip, uint length)
{
- LEX_STRING tmp;
+ LEX_CSTRING tmp;
lip->yyUnget(); // ptr points now after last token char
tmp.length= length;
tmp.str= lip->m_thd->strmake(lip->get_tok_start() + skip, tmp.length);
@@ -968,18 +973,17 @@ static LEX_STRING get_token(Lex_input_stream *lip, uint skip, uint length)
future to operate multichar strings (like ucs2)
*/
-static LEX_STRING get_quoted_token(Lex_input_stream *lip,
- uint skip,
- uint length, char quote)
+static LEX_CSTRING get_quoted_token(Lex_input_stream *lip,
+ uint skip,
+ uint length, char quote)
{
- LEX_STRING tmp;
+ LEX_CSTRING tmp;
const char *from, *end;
char *to;
lip->yyUnget(); // ptr points now after last token char
tmp.length= length;
- tmp.str=(char*) lip->m_thd->alloc(tmp.length+1);
+ tmp.str= to= (char*) lip->m_thd->alloc(tmp.length+1);
from= lip->get_tok_start() + skip;
- to= tmp.str;
end= to+length;
lip->m_cpp_text_start= lip->get_cpp_tok_start() + skip;
@@ -1114,6 +1118,7 @@ bool Lex_input_stream::get_text(Lex_string_with_metadata_st *dst, uint sep,
/* Found end. Unescape and return string */
const char *str, *end;
+ char *to;
str= get_tok_start();
end= get_ptr();
@@ -1122,24 +1127,25 @@ bool Lex_input_stream::get_text(Lex_string_with_metadata_st *dst, uint sep,
end -= post_skip;
DBUG_ASSERT(end >= str);
- if (!(dst->str= (char*) m_thd->alloc((uint) (end - str) + 1)))
+ if (!(to= (char*) m_thd->alloc((uint) (end - str) + 1)))
{
- dst->str= (char*) ""; // Sql_alloc has set error flag
+ dst->str= ""; // Sql_alloc has set error flag
dst->length= 0;
return true;
}
+ dst->str= to;
m_cpp_text_start= get_cpp_tok_start() + pre_skip;
m_cpp_text_end= get_cpp_ptr() - post_skip;
if (!found_escape)
{
- memcpy(dst->str, str, dst->length= (end - str));
- dst->str[dst->length]= 0;
+ memcpy(to, str, dst->length= (end - str));
+ to[dst->length]= 0;
}
else
{
- dst->length= unescape(cs, dst->str, str, end, sep);
+ dst->length= unescape(cs, to, str, end, sep);
}
return false;
}
@@ -2096,7 +2102,7 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
}
-void trim_whitespace(CHARSET_INFO *cs, LEX_STRING *str, uint *prefix_length)
+void trim_whitespace(CHARSET_INFO *cs, LEX_CSTRING *str, uint *prefix_length)
{
/*
TODO:
@@ -2550,7 +2556,7 @@ uint st_select_lex_node::get_in_sum_expr() { return 0; }
TABLE_LIST* st_select_lex_node::get_table_list() { return 0; }
List<Item>* st_select_lex_node::get_item_list() { return 0; }
TABLE_LIST *st_select_lex_node::add_table_to_list(THD *thd, Table_ident *table,
- LEX_STRING *alias,
+ LEX_CSTRING *alias,
ulong table_join_options,
thr_lock_type flags,
enum_mdl_type mdl_type,
@@ -3235,7 +3241,7 @@ uint8 LEX::get_effective_with_check(TABLE_LIST *view)
*/
bool
-LEX::copy_db_to(char **p_db, size_t *p_db_length) const
+LEX::copy_db_to(const char **p_db, size_t *p_db_length) const
{
if (sphead && sphead->m_name.str)
{
@@ -3818,7 +3824,7 @@ void st_select_lex::alloc_index_hints (THD *thd)
RETURN VALUE
0 on success, non-zero otherwise
*/
-bool st_select_lex::add_index_hint (THD *thd, char *str, uint length)
+bool st_select_lex::add_index_hint (THD *thd, const char *str, uint length)
{
return index_hints->push_front(new (thd->mem_root)
Index_hint(current_index_hint_type,
@@ -5020,7 +5026,7 @@ bool LEX::add_unit_in_brackets(SELECT_LEX *nselect)
/* add SELECT list*/
Item *item= new (thd->mem_root)
- Item_field(thd, context, NULL, NULL, "*");
+ Item_field(thd, context, NULL, NULL, &star_clex_str);
if (item == NULL)
DBUG_RETURN(TRUE);
if (add_item_to_list(thd, item))
@@ -5039,7 +5045,7 @@ bool LEX::add_unit_in_brackets(SELECT_LEX *nselect)
if (ti == NULL)
DBUG_RETURN(TRUE);
char buff[10];
- LEX_STRING alias;
+ LEX_CSTRING alias;
alias.length= my_snprintf(buff, sizeof(buff),
"__%u", dummy_select->select_number);
alias.str= thd->strmake(buff, alias.length);
@@ -5083,15 +5089,15 @@ void LEX::check_automatic_up(enum sub_select_type type)
}
-sp_variable *LEX::sp_param_init(LEX_STRING name)
+sp_variable *LEX::sp_param_init(LEX_CSTRING *name)
{
if (spcont->find_variable(name, true))
{
- my_error(ER_SP_DUP_PARAM, MYF(0), name.str);
+ my_error(ER_SP_DUP_PARAM, MYF(0), name->str);
return NULL;
}
sp_variable *spvar= spcont->add_variable(thd, name);
- init_last_field(&spvar->field_def, name.str,
+ init_last_field(&spvar->field_def, name,
thd->variables.collation_database);
return spvar;
}
@@ -5099,7 +5105,7 @@ sp_variable *LEX::sp_param_init(LEX_STRING name)
bool LEX::sp_param_fill_definition(sp_variable *spvar)
{
- return sphead->fill_spvar_definition(thd, last_field, spvar->name.str);
+ return sphead->fill_spvar_definition(thd, last_field, &spvar->name);
}
@@ -5113,14 +5119,14 @@ void LEX::set_stmt_init()
bool LEX::init_internal_variable(struct sys_var_with_base *variable,
- LEX_STRING name)
+ const LEX_CSTRING *name)
{
sp_variable *spv;
/* Best effort lookup for system variable. */
if (!spcont || !(spv = spcont->find_variable(name, false)))
{
- struct sys_var_with_base tmp= {NULL, name};
+ struct sys_var_with_base tmp= {NULL, *name};
/* Not an SP local variable */
if (find_sys_var_null_base(thd, &tmp))
@@ -5135,32 +5141,33 @@ bool LEX::init_internal_variable(struct sys_var_with_base *variable,
Will depend on the context of the SET statement.
*/
variable->var= NULL;
- variable->base_name= name;
+ variable->base_name= *name;
return false;
}
-bool LEX::is_trigger_new_or_old_reference(const LEX_STRING name)
+bool LEX::is_trigger_new_or_old_reference(const LEX_CSTRING *name)
{
return sphead && sphead->m_type == TYPE_ENUM_TRIGGER &&
- name.length == 3 &&
- (!my_strcasecmp(system_charset_info, name.str, "NEW") ||
- !my_strcasecmp(system_charset_info, name.str, "OLD"));
+ name->length == 3 &&
+ (!my_strcasecmp(system_charset_info, name->str, "NEW") ||
+ !my_strcasecmp(system_charset_info, name->str, "OLD"));
}
bool LEX::init_internal_variable(struct sys_var_with_base *variable,
- LEX_STRING dbname, LEX_STRING name)
+ const LEX_CSTRING *dbname,
+ const LEX_CSTRING *name)
{
- if (check_reserved_words(&dbname))
+ if (check_reserved_words(dbname))
{
my_error(ER_UNKNOWN_STRUCTURED_VARIABLE, MYF(0),
- (int) dbname.length, dbname.str);
+ (int) dbname->length, dbname->str);
return true;
}
if (is_trigger_new_or_old_reference(dbname))
{
- if (dbname.str[0]=='O' || dbname.str[0]=='o')
+ if (dbname->str[0]=='O' || dbname->str[0]=='o')
{
my_error(ER_TRG_CANT_CHANGE_ROW, MYF(0), "OLD", "");
return true;
@@ -5177,27 +5184,27 @@ bool LEX::init_internal_variable(struct sys_var_with_base *variable,
}
/* This special combination will denote field of NEW row */
variable->var= trg_new_row_fake_var;
- variable->base_name= name;
+ variable->base_name= *name;
return false;
}
- sys_var *tmp= find_sys_var_ex(thd, name.str, name.length, true, false);
+ sys_var *tmp= find_sys_var_ex(thd, name->str, name->length, true, false);
if (!tmp)
{
my_error(ER_UNKNOWN_STRUCTURED_VARIABLE, MYF(0),
- (int) dbname.length, dbname.str);
+ (int) dbname->length, dbname->str);
return true;
}
if (!tmp->is_struct())
- my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), name.str);
+ my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), name->str);
variable->var= tmp;
- variable->base_name= dbname;
+ variable->base_name= *dbname;
return false;
}
bool LEX::init_default_internal_variable(struct sys_var_with_base *variable,
- LEX_STRING name)
+ LEX_CSTRING name)
{
sys_var *tmp= find_sys_var(thd, name.str, name.length);
if (!tmp)
@@ -5216,7 +5223,7 @@ void LEX::sp_variable_declarations_init(THD *thd, int nvars)
sphead->reset_lex(thd);
spcont->declare_var_boundary(nvars);
- thd->lex->init_last_field(&spvar->field_def, spvar->name.str,
+ thd->lex->init_last_field(&spvar->field_def, &spvar->name,
thd->variables.collation_database);
}
@@ -5259,7 +5266,7 @@ bool LEX::sp_variable_declarations_finalize(THD *thd, int nvars,
if (!last)
spvar->field_def.set_column_definition(cdef);
}
- if (sphead->fill_spvar_definition(thd, &spvar->field_def, spvar->name.str))
+ if (sphead->fill_spvar_definition(thd, &spvar->field_def, &spvar->name))
return true;
spvar->field_def.set_row_field_definitions(row);
@@ -5293,7 +5300,8 @@ LEX::sp_variable_declarations_rowtype_finalize(THD *thd, int nvars,
{
uint coffp;
const sp_pcursor *pcursor= ref->table.str && ref->db.str ? NULL :
- spcont->find_cursor(ref->m_column, &coffp, false);
+ spcont->find_cursor(&ref->m_column, &coffp,
+ false);
if (!def && !(def= new (thd->mem_root) Item_null(thd)))
return true;
@@ -5329,13 +5337,13 @@ LEX::sp_variable_declarations_rowtype_finalize(THD *thd, int nvars,
*/
Table_ident *table_ref;
if (!(table_ref= new (thd->mem_root) Table_ident(thd,
- ref->table,
- ref->m_column,
+ &ref->table,
+ &ref->m_column,
false)))
return true;
spvar->field_def.set_table_rowtype_ref(table_ref);
}
- sphead->fill_spvar_definition(thd, &spvar->field_def, spvar->name.str);
+ sphead->fill_spvar_definition(thd, &spvar->field_def, &spvar->name);
spvar->default_value= def;
/* The last instruction is responsible for freeing LEX. */
sp_instr_set *is= new (this->thd->mem_root)
@@ -5361,7 +5369,7 @@ LEX::sp_variable_declarations_with_ref_finalize(THD *thd, int nvars,
{
sp_variable *spvar= spcont->get_last_context_variable((uint) nvars - 1 - i);
spvar->field_def.set_column_type_ref(ref);
- spvar->field_def.field_name= spvar->name.str;
+ spvar->field_def.field_name= spvar->name;
}
sphead->m_flags|= sp_head::HAS_COLUMN_TYPE_REFS;
return sp_variable_declarations_finalize(thd, nvars, NULL, NULL, def);
@@ -5392,12 +5400,12 @@ LEX::sp_variable_declarations_with_ref_finalize(THD *thd, int nvars,
*/
-sp_variable *LEX::sp_add_for_loop_variable(THD *thd, const LEX_STRING name,
+sp_variable *LEX::sp_add_for_loop_variable(THD *thd, const LEX_CSTRING *name,
Item *value)
{
sp_variable *spvar= spcont->add_variable(thd, name);
spcont->declare_var_boundary(1);
- spvar->field_def.field_name= spvar->name.str;
+ spvar->field_def.field_name= spvar->name;
spvar->field_def.sql_type= MYSQL_TYPE_LONGLONG;
/*
The below is a simplified version of what
@@ -5423,7 +5431,7 @@ sp_variable *LEX::sp_add_for_loop_variable(THD *thd, const LEX_STRING name,
sp_variable *
LEX::sp_add_for_loop_cursor_variable(THD *thd,
- const LEX_STRING name,
+ const LEX_CSTRING *name,
const sp_pcursor *pcursor,
uint coffset,
sp_assignment_lex *param_lex,
@@ -5433,7 +5441,7 @@ LEX::sp_add_for_loop_cursor_variable(THD *thd,
if (!spvar)
return NULL;
spcont->declare_var_boundary(1);
- sphead->fill_spvar_definition(thd, &spvar->field_def, spvar->name.str);
+ sphead->fill_spvar_definition(thd, &spvar->field_def, &spvar->name);
if (!(spvar->default_value= new (thd->mem_root) Item_null(thd)))
return NULL;
@@ -5461,7 +5469,7 @@ bool LEX::sp_for_loop_condition(THD *thd, const Lex_for_loop_st &loop)
{
sp_variable *src= i == 0 ? loop.m_index : loop.m_upper_bound;
args[i]= new (thd->mem_root)
- Item_splocal(thd, src->name, src->offset, src->sql_type());
+ Item_splocal(thd, &src->name, src->offset, src->sql_type());
if (args[i] == NULL)
return true;
#ifndef DBUG_OFF
@@ -5493,13 +5501,13 @@ bool LEX::sp_for_loop_intrange_condition_test(THD *thd,
bool LEX::sp_for_loop_cursor_condition_test(THD *thd,
const Lex_for_loop_st &loop)
{
- const LEX_STRING *cursor_name;
+ const LEX_CSTRING *cursor_name;
Item *expr;
spcont->set_for_loop(loop);
sphead->reset_lex(thd);
cursor_name= spcont->find_cursor(loop.m_cursor_offset);
DBUG_ASSERT(cursor_name);
- if (!(expr= new (thd->mem_root) Item_func_cursor_found(thd, *cursor_name,
+ if (!(expr= new (thd->mem_root) Item_func_cursor_found(thd, cursor_name,
loop.m_cursor_offset)))
return true;
if (thd->lex->sp_while_loop_expression(thd, expr))
@@ -5509,7 +5517,7 @@ bool LEX::sp_for_loop_cursor_condition_test(THD *thd,
bool LEX::sp_for_loop_intrange_declarations(THD *thd, Lex_for_loop_st *loop,
- const LEX_STRING &index,
+ const LEX_CSTRING *index,
const Lex_for_loop_bounds_st &bounds)
{
if (!(loop->m_index=
@@ -5528,14 +5536,14 @@ bool LEX::sp_for_loop_intrange_declarations(THD *thd, Lex_for_loop_st *loop,
bool LEX::sp_for_loop_cursor_declarations(THD *thd,
Lex_for_loop_st *loop,
- const LEX_STRING &index,
+ const LEX_CSTRING *index,
const Lex_for_loop_bounds_st &bounds)
{
Item *item= bounds.m_index->get_item();
Item_splocal *item_splocal;
Item_field *item_field;
Item_func_sp *item_func_sp= NULL;
- LEX_STRING name;
+ LEX_CSTRING name;
uint coffs, param_count= 0;
const sp_pcursor *pcursor;
@@ -5544,10 +5552,7 @@ bool LEX::sp_for_loop_cursor_declarations(THD *thd,
else if ((item_field= item->type() == Item::FIELD_ITEM ?
static_cast<Item_field *>(item) : NULL) &&
item_field->table_name == NULL)
- {
- name.str= (char *) item_field->field_name;
- name.length= strlen(item_field->field_name);
- }
+ name= item_field->field_name;
else if (item->type() == Item::FUNC_ITEM &&
static_cast<Item_func*>(item)->functype() == Item_func::FUNC_SP &&
!static_cast<Item_func_sp*>(item)->get_sp_name()->m_explicit_name)
@@ -5574,7 +5579,7 @@ bool LEX::sp_for_loop_cursor_declarations(THD *thd,
thd->parse_error();
return true;
}
- if (!(pcursor= spcont->find_cursor_with_error(name, &coffs, false)) ||
+ if (!(pcursor= spcont->find_cursor_with_error(&name, &coffs, false)) ||
pcursor->check_param_count_with_error(param_count))
return true;
@@ -5597,7 +5602,7 @@ bool LEX::sp_for_loop_cursor_declarations(THD *thd,
bool LEX::sp_for_loop_increment(THD *thd, const Lex_for_loop_st &loop)
{
Item_splocal *splocal= new (thd->mem_root)
- Item_splocal(thd, loop.m_index->name, loop.m_index->offset,
+ Item_splocal(thd, &loop.m_index->name, loop.m_index->offset,
loop.m_index->sql_type());
if (splocal == NULL)
return true;
@@ -5645,7 +5650,7 @@ bool LEX::sp_for_loop_cursor_finalize(THD *thd, const Lex_for_loop_st &loop)
/***************************************************************************/
-bool LEX::sp_declare_cursor(THD *thd, const LEX_STRING name,
+bool LEX::sp_declare_cursor(THD *thd, const LEX_CSTRING *name,
sp_lex_cursor *cursor_stmt,
sp_pcontext *param_ctx, bool add_cpush_instr)
{
@@ -5654,7 +5659,7 @@ bool LEX::sp_declare_cursor(THD *thd, const LEX_STRING name,
if (spcont->find_cursor(name, &offp, true))
{
- my_error(ER_SP_DUP_CURS, MYF(0), name.str);
+ my_error(ER_SP_DUP_CURS, MYF(0), name->str);
return true;
}
cursor_stmt->set_cursor_name(name);
@@ -5680,7 +5685,7 @@ bool LEX::sp_declare_cursor(THD *thd, const LEX_STRING name,
@param parameters - Cursor parameters, e.g. OPEN c(1,2,3)
@returns - false on success, true on error
*/
-bool LEX::sp_open_cursor(THD *thd, const LEX_STRING name,
+bool LEX::sp_open_cursor(THD *thd, const LEX_CSTRING *name,
List<sp_assignment_lex> *parameters)
{
uint offset;
@@ -5710,7 +5715,7 @@ bool LEX::sp_handler_declaration_init(THD *thd, int type)
sphead->push_backpatch(thd, i, spcont->last_label()))
return true;
- if (sphead->push_backpatch(thd, i, spcont->push_label(thd, empty_lex_str, 0)))
+ if (sphead->push_backpatch(thd, i, spcont->push_label(thd, &empty_clex_str, 0)))
return true;
return false;
@@ -5743,7 +5748,7 @@ bool LEX::sp_handler_declaration_finalize(THD *thd, int type)
}
-void LEX::sp_block_init(THD *thd, const LEX_STRING label)
+void LEX::sp_block_init(THD *thd, const LEX_CSTRING *label)
{
spcont->push_label(thd, label, sphead->instructions(), sp_label::BEGIN);
spcont= spcont->push_context(thd, sp_pcontext::REGULAR_SCOPE);
@@ -5781,43 +5786,43 @@ bool LEX::sp_block_finalize(THD *thd, const Lex_spblock_st spblock,
bool LEX::sp_block_finalize(THD *thd, const Lex_spblock_st spblock,
- const LEX_STRING end_label)
+ const LEX_CSTRING *end_label)
{
sp_label *splabel;
if (sp_block_finalize(thd, spblock, &splabel))
return true;
- if (end_label.str &&
+ if (end_label->str &&
my_strcasecmp(system_charset_info,
- end_label.str, splabel->name.str) != 0)
+ end_label->str, splabel->name.str) != 0)
{
- my_error(ER_SP_LABEL_MISMATCH, MYF(0), end_label.str);
+ my_error(ER_SP_LABEL_MISMATCH, MYF(0), end_label->str);
return true;
}
return false;
}
-sp_name *LEX::make_sp_name(THD *thd, LEX_STRING &name)
+sp_name *LEX::make_sp_name(THD *thd, LEX_CSTRING *name)
{
sp_name *res;
- LEX_STRING db;
- if (check_routine_name(&name) ||
+ LEX_CSTRING db;
+ if (check_routine_name(name) ||
copy_db_to(&db.str, &db.length) ||
- (!(res= new (thd->mem_root) sp_name(db, name, false))))
+ (!(res= new (thd->mem_root) sp_name(&db, name, false))))
return NULL;
return res;
}
-sp_name *LEX::make_sp_name(THD *thd, LEX_STRING &name1, LEX_STRING &name2)
+sp_name *LEX::make_sp_name(THD *thd, LEX_CSTRING *name1, LEX_CSTRING *name2)
{
sp_name *res;
- if (!name1.str || check_db_name(&name1))
+ if (!name1->str || check_db_name((LEX_STRING*) name1))
{
- my_error(ER_WRONG_DB_NAME, MYF(0), name1.str);
+ my_error(ER_WRONG_DB_NAME, MYF(0), name1->str);
return NULL;
}
- if (check_routine_name(&name2) ||
+ if (check_routine_name(name2) ||
(!(res= new (thd->mem_root) sp_name(name1, name2, true))))
return NULL;
return res;
@@ -5929,18 +5934,18 @@ bool LEX::sp_change_context(THD *thd, const sp_pcontext *ctx, bool exclusive)
}
-bool LEX::sp_leave_statement(THD *thd, const LEX_STRING label_name)
+bool LEX::sp_leave_statement(THD *thd, const LEX_CSTRING *label_name)
{
sp_label *lab= spcont->find_label(label_name);
if (!lab)
{
- my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "LEAVE", label_name.str);
+ my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "LEAVE", label_name->str);
return true;
}
return sp_exit_block(thd, lab, NULL);
}
-bool LEX::sp_goto_statement(THD *thd, const LEX_STRING label_name)
+bool LEX::sp_goto_statement(THD *thd, const LEX_CSTRING *label_name)
{
sp_label *lab= spcont->find_goto_label(label_name);
if (!lab || lab->ip == 0)
@@ -5967,19 +5972,19 @@ bool LEX::sp_goto_statement(THD *thd, const LEX_STRING label_name)
return false;
}
-bool LEX::sp_push_goto_label(THD *thd, const LEX_STRING label_name)
+bool LEX::sp_push_goto_label(THD *thd, const LEX_CSTRING *label_name)
{
sp_label *lab= spcont->find_goto_label(label_name, false);
if (lab)
{
if (lab->ip != 0)
{
- my_error(ER_SP_LABEL_REDEFINE, MYF(0), label_name.str);
+ my_error(ER_SP_LABEL_REDEFINE, MYF(0), label_name->str);
return true;
}
lab->ip= sphead->instructions();
- sp_label *beginblocklabel= spcont->find_label(empty_lex_str);
+ sp_label *beginblocklabel= spcont->find_label(&empty_clex_str);
sphead->backpatch_goto(thd, lab, beginblocklabel);
}
else
@@ -6038,24 +6043,24 @@ bool LEX::sp_exit_statement(THD *thd, Item *item)
}
-bool LEX::sp_exit_statement(THD *thd, const LEX_STRING label_name, Item *item)
+bool LEX::sp_exit_statement(THD *thd, const LEX_CSTRING *label_name, Item *item)
{
sp_label *lab= spcont->find_label(label_name);
if (!lab || lab->type != sp_label::ITERATION)
{
- my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "EXIT", label_name);
+ my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "EXIT", label_name->str);
return true;
}
return sp_exit_block(thd, lab, item);
}
-bool LEX::sp_iterate_statement(THD *thd, const LEX_STRING label_name)
+bool LEX::sp_iterate_statement(THD *thd, const LEX_CSTRING *label_name)
{
sp_label *lab= spcont->find_label(label_name);
if (!lab || lab->type != sp_label::ITERATION)
{
- my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "ITERATE", label_name.str);
+ my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "ITERATE", label_name->str);
return true;
}
return sp_continue_loop(thd, lab);
@@ -6111,12 +6116,13 @@ bool LEX::sp_continue_statement(THD *thd, Item *when)
}
-bool LEX::sp_continue_statement(THD *thd, const LEX_STRING label_name, Item *when)
+bool LEX::sp_continue_statement(THD *thd, const LEX_CSTRING *label_name,
+ Item *when)
{
sp_label *lab= spcont->find_label(label_name);
if (!lab || lab->type != sp_label::ITERATION)
{
- my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "CONTINUE", label_name);
+ my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "CONTINUE", label_name->str);
return true;
}
return sp_continue_loop(thd, lab, when);
@@ -6136,12 +6142,12 @@ bool LEX::maybe_start_compound_statement(THD *thd)
}
-bool LEX::sp_push_loop_label(THD *thd, const LEX_STRING label_name)
+bool LEX::sp_push_loop_label(THD *thd, const LEX_CSTRING *label_name)
{
sp_label *lab= spcont->find_label(label_name);
if (lab)
{
- my_error(ER_SP_LABEL_REDEFINE, MYF(0), label_name.str);
+ my_error(ER_SP_LABEL_REDEFINE, MYF(0), label_name->str);
return true;
}
spcont->push_label(thd, label_name, sphead->instructions(),
@@ -6155,21 +6161,21 @@ bool LEX::sp_push_loop_empty_label(THD *thd)
if (maybe_start_compound_statement(thd))
return true;
/* Unlabeled controls get an empty label. */
- spcont->push_label(thd, empty_lex_str, sphead->instructions(),
+ spcont->push_label(thd, &empty_clex_str, sphead->instructions(),
sp_label::ITERATION);
return false;
}
-bool LEX::sp_pop_loop_label(THD *thd, const LEX_STRING label_name)
+bool LEX::sp_pop_loop_label(THD *thd, const LEX_CSTRING *label_name)
{
sp_label *lab= spcont->pop_label();
sphead->backpatch(lab);
- if (label_name.str &&
- my_strcasecmp(system_charset_info, label_name.str,
+ if (label_name->str &&
+ my_strcasecmp(system_charset_info, label_name->str,
lab->name.str) != 0)
{
- my_error(ER_SP_LABEL_MISMATCH, MYF(0), label_name.str);
+ my_error(ER_SP_LABEL_MISMATCH, MYF(0), label_name->str);
return true;
}
return false;
@@ -6209,8 +6215,9 @@ bool LEX::sp_while_loop_finalize(THD *thd)
}
-Item *LEX::create_and_link_Item_trigger_field(THD *thd, const char *name,
- bool new_row)
+Item *LEX::create_and_link_Item_trigger_field(THD *thd,
+ const LEX_CSTRING *name,
+ bool new_row)
{
Item_trigger_field *trg_fld;
@@ -6249,7 +6256,7 @@ Item *LEX::create_and_link_Item_trigger_field(THD *thd, const char *name,
}
-Item_param *LEX::add_placeholder(THD *thd, char *name,
+Item_param *LEX::add_placeholder(THD *thd, const LEX_CSTRING *name,
uint pos_in_query, uint len_in_query)
{
if (!parsing_options.allows_variable)
@@ -6293,8 +6300,8 @@ bool LEX::add_resignal_statement(THD *thd, const sp_condition_value *v)
Item *LEX::create_item_ident_nospvar(THD *thd,
- const LEX_STRING &a,
- const LEX_STRING &b)
+ const LEX_CSTRING *a,
+ const LEX_CSTRING *b)
{
DBUG_ASSERT(this == thd->lex);
/*
@@ -6304,28 +6311,28 @@ Item *LEX::create_item_ident_nospvar(THD *thd,
*/
if (is_trigger_new_or_old_reference(a))
{
- bool new_row= (a.str[0]=='N' || a.str[0]=='n');
+ bool new_row= (a->str[0]=='N' || a->str[0]=='n');
- return create_and_link_Item_trigger_field(thd, b.str, new_row);
+ return create_and_link_Item_trigger_field(thd, b, new_row);
}
if (current_select->no_table_names_allowed)
{
- my_error(ER_TABLENAME_NOT_ALLOWED_HERE, MYF(0), a.str, thd->where);
+ my_error(ER_TABLENAME_NOT_ALLOWED_HERE, MYF(0), a->str, thd->where);
return NULL;
}
if ((current_select->parsing_place != IN_HAVING) ||
(current_select->get_in_sum_expr() > 0))
return new (thd->mem_root) Item_field(thd, current_context(),
- NullS, a.str, b.str);
+ NullS, a->str, b);
return new (thd->mem_root) Item_ref(thd, current_context(),
- NullS, a.str, b.str);
+ NullS, a->str, b);
}
Item_splocal *LEX::create_item_spvar_row_field(THD *thd,
- const LEX_STRING &a,
- const LEX_STRING &b,
+ const LEX_CSTRING *a,
+ const LEX_CSTRING *b,
sp_variable *spv,
uint pos_in_q,
uint length_in_q)
@@ -6368,13 +6375,13 @@ Item_splocal *LEX::create_item_spvar_row_field(THD *thd,
my_var *LEX::create_outvar(THD *thd,
- const LEX_STRING &a,
- const LEX_STRING &b)
+ const LEX_CSTRING *a,
+ const LEX_CSTRING *b)
{
sp_variable *t;
if (!spcont || !(t= spcont->find_variable(a, false)))
{
- my_error(ER_SP_UNDECLARED_VAR, MYF(0), a.str);
+ my_error(ER_SP_UNDECLARED_VAR, MYF(0), a->str);
return NULL;
}
uint row_field_offset;
@@ -6413,8 +6420,8 @@ Item *LEX::create_item_func_lastval(THD *thd, Table_ident *table_ident)
Item *LEX::create_item_func_nextval(THD *thd,
- const LEX_STRING &db,
- const LEX_STRING &name)
+ const LEX_CSTRING *db,
+ const LEX_CSTRING *name)
{
Table_ident *table_ident;
if (!(table_ident= new (thd->mem_root) Table_ident(thd, db, name, false)))
@@ -6424,8 +6431,8 @@ Item *LEX::create_item_func_nextval(THD *thd,
Item *LEX::create_item_func_lastval(THD *thd,
- const LEX_STRING &db,
- const LEX_STRING &name)
+ const LEX_CSTRING *db,
+ const LEX_CSTRING *name)
{
Table_ident *table_ident;
if (!(table_ident= new (thd->mem_root) Table_ident(thd, db, name, false)))
@@ -6435,24 +6442,24 @@ Item *LEX::create_item_func_lastval(THD *thd,
Item *LEX::create_item_ident(THD *thd,
- const LEX_STRING &a,
- const LEX_STRING &b,
+ const LEX_CSTRING *a,
+ const LEX_CSTRING *b,
uint pos_in_q, uint length_in_q)
{
sp_variable *spv;
if (spcont && (spv= spcont->find_variable(a, false)))
return create_item_spvar_row_field(thd, a, b, spv, pos_in_q, length_in_q);
- if ((thd->variables.sql_mode & MODE_ORACLE) && b.length == 7)
+ if ((thd->variables.sql_mode & MODE_ORACLE) && b->length == 7)
{
if (!my_strnncoll(system_charset_info,
- (const uchar *) b.str, 7,
+ (const uchar *) b->str, 7,
(const uchar *) "NEXTVAL", 7))
- return create_item_func_nextval(thd, null_lex_str, a);
+ return create_item_func_nextval(thd, &null_clex_str, a);
else if (!my_strnncoll(system_charset_info,
- (const uchar *) b.str, 7,
+ (const uchar *) b->str, 7,
(const uchar *) "CURRVAL", 7))
- return create_item_func_lastval(thd, null_lex_str, a);
+ return create_item_func_lastval(thd, &null_clex_str, a);
}
return create_item_ident_nospvar(thd, a, b);
@@ -6460,47 +6467,47 @@ Item *LEX::create_item_ident(THD *thd,
Item *LEX::create_item_ident(THD *thd,
- const LEX_STRING &a,
- const LEX_STRING &b,
- const LEX_STRING &c)
+ const LEX_CSTRING *a,
+ const LEX_CSTRING *b,
+ const LEX_CSTRING *c)
{
const char *schema= (thd->client_capabilities & CLIENT_NO_SCHEMA ?
- NullS : a.str);
+ NullS : a->str);
- if ((thd->variables.sql_mode & MODE_ORACLE) && c.length == 7)
+ if ((thd->variables.sql_mode & MODE_ORACLE) && c->length == 7)
{
if (!my_strnncoll(system_charset_info,
- (const uchar *) c.str, 7,
+ (const uchar *) c->str, 7,
(const uchar *) "NEXTVAL", 7))
return create_item_func_nextval(thd, a, b);
else if (!my_strnncoll(system_charset_info,
- (const uchar *) c.str, 7,
+ (const uchar *) c->str, 7,
(const uchar *) "CURRVAL", 7))
return create_item_func_lastval(thd, a, b);
}
if (current_select->no_table_names_allowed)
{
- my_error(ER_TABLENAME_NOT_ALLOWED_HERE, MYF(0), b.str, thd->where);
+ my_error(ER_TABLENAME_NOT_ALLOWED_HERE, MYF(0), b->str, thd->where);
return NULL;
}
if (current_select->parsing_place != IN_HAVING ||
current_select->get_in_sum_expr() > 0)
return new (thd->mem_root) Item_field(thd, current_context(),
- schema, b.str, c.str);
+ schema, b->str, c);
return new (thd->mem_root) Item_ref(thd, current_context(),
- schema, b.str, c.str);
+ schema, b->str, c);
}
Item *LEX::create_item_limit(THD *thd,
- const LEX_STRING &a,
+ const LEX_CSTRING *a,
uint pos_in_q, uint length_in_q)
{
sp_variable *spv;
if (!spcont || !(spv= spcont->find_variable(a, false)))
{
- my_error(ER_SP_UNDECLARED_VAR, MYF(0), a.str);
+ my_error(ER_SP_UNDECLARED_VAR, MYF(0), a->str);
return NULL;
}
@@ -6525,14 +6532,14 @@ Item *LEX::create_item_limit(THD *thd,
Item *LEX::create_item_limit(THD *thd,
- const LEX_STRING &a,
- const LEX_STRING &b,
+ const LEX_CSTRING *a,
+ const LEX_CSTRING *b,
uint pos_in_q, uint length_in_q)
{
sp_variable *spv;
if (!spcont || !(spv= spcont->find_variable(a, false)))
{
- my_error(ER_SP_UNDECLARED_VAR, MYF(0), a.str);
+ my_error(ER_SP_UNDECLARED_VAR, MYF(0), a->str);
return NULL;
}
// Qualified %TYPE variables are not possible
@@ -6573,26 +6580,26 @@ bool LEX::set_variable(struct sys_var_with_base *variable, Item *item)
was previously checked by init_internal_variable().
*/
DBUG_ASSERT(spcont);
- sp_variable *spv= spcont->find_variable(variable->base_name, false);
+ sp_variable *spv= spcont->find_variable(&variable->base_name, false);
DBUG_ASSERT(spv);
/* It is a local variable. */
return sphead->set_local_variable(thd, spcont, spv, item, this, true);
}
-Item *LEX::create_item_ident_nosp(THD *thd, LEX_STRING name)
+Item *LEX::create_item_ident_nosp(THD *thd, LEX_CSTRING *name)
{
if (current_select->parsing_place != IN_HAVING ||
current_select->get_in_sum_expr() > 0)
return new (thd->mem_root) Item_field(thd, current_context(),
- NullS, NullS, name.str);
+ NullS, NullS, name);
return new (thd->mem_root) Item_ref(thd, current_context(),
- NullS, NullS, name.str);
+ NullS, NullS, name);
}
-Item *LEX::create_item_ident_sp(THD *thd, LEX_STRING name,
+Item *LEX::create_item_ident_sp(THD *thd, LEX_CSTRING *name,
uint start_in_q,
uint length_in_q)
{
@@ -6629,16 +6636,16 @@ Item *LEX::create_item_ident_sp(THD *thd, LEX_STRING name,
if (thd->variables.sql_mode & MODE_ORACLE)
{
- if (!my_strcasecmp(system_charset_info, name.str, "SQLCODE"))
+ if (!my_strcasecmp(system_charset_info, name->str, "SQLCODE"))
return new (thd->mem_root) Item_func_sqlcode(thd);
- if (!my_strcasecmp(system_charset_info, name.str, "SQLERRM"))
+ if (!my_strcasecmp(system_charset_info, name->str, "SQLERRM"))
return new (thd->mem_root) Item_func_sqlerrm(thd);
}
return create_item_ident_nosp(thd, name);
}
-Item *LEX::create_item_ident_sp(THD *thd, LEX_STRING name,
+Item *LEX::create_item_ident_sp(THD *thd, LEX_CSTRING *name,
const char *start_in_q,
const char *end_in_q)
{
@@ -6652,8 +6659,8 @@ Item *LEX::create_item_ident_sp(THD *thd, LEX_STRING name,
Generate instructions for:
SET x.y= expr;
*/
-bool LEX::set_variable(const LEX_STRING &name1,
- const LEX_STRING &name2,
+bool LEX::set_variable(const LEX_CSTRING *name1,
+ const LEX_CSTRING *name2,
Item *item)
{
sp_variable *spv;
@@ -7017,14 +7024,14 @@ Item *st_select_lex::build_cond_for_grouping_fields(THD *thd, Item *cond,
}
-bool LEX::sp_add_cfetch(THD *thd, const LEX_STRING &name)
+bool LEX::sp_add_cfetch(THD *thd, const LEX_CSTRING *name)
{
uint offset;
sp_instr_cfetch *i;
if (!spcont->find_cursor(name, &offset, false))
{
- my_error(ER_SP_CURSOR_MISMATCH, MYF(0), name.str);
+ my_error(ER_SP_CURSOR_MISMATCH, MYF(0), name->str);
return true;
}
i= new (thd->mem_root)
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index c1c751ecbbc..91f9eb77db2 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -48,7 +48,7 @@
This will allow to avoid unnecessary copying, as well as
create more optimal Item types in sql_yacc.yy
*/
-struct Lex_string_with_metadata_st: public LEX_STRING
+struct Lex_string_with_metadata_st: public LEX_CSTRING
{
bool m_is_8bit; // True if the string has 8bit characters
public:
@@ -154,7 +154,7 @@ void binlog_unsafe_map_init();
struct sys_var_with_base
{
sys_var *var;
- LEX_STRING base_name;
+ LEX_CSTRING base_name;
};
struct LEX_TYPE
@@ -198,8 +198,10 @@ struct LEX_TYPE
#ifdef MYSQL_SERVER
-extern const LEX_STRING null_lex_str;
-extern const LEX_STRING empty_lex_str;
+extern const LEX_STRING empty_lex_str;
+extern const LEX_CSTRING empty_clex_str;
+extern const LEX_CSTRING star_clex_str;
+extern const LEX_CSTRING param_clex_str;
enum enum_sp_suid_behaviour
{
@@ -258,11 +260,11 @@ typedef Mem_root_array<ORDER*, true> Group_list_ptrs;
typedef struct st_lex_server_options
{
long port;
- LEX_STRING server_name, host, db, username, password, scheme, socket, owner;
- void reset(LEX_STRING name)
+ LEX_CSTRING server_name, host, db, username, password, scheme, socket, owner;
+ void reset(LEX_CSTRING name)
{
server_name= name;
- host= db= username= password= scheme= socket= owner= null_lex_str;
+ host= db= username= password= scheme= socket= owner= null_clex_str;
port= -1;
}
} LEX_SERVER_OPTIONS;
@@ -280,13 +282,13 @@ struct LEX_MASTER_INFO
DYNAMIC_ARRAY repl_ignore_server_ids;
DYNAMIC_ARRAY repl_do_domain_ids;
DYNAMIC_ARRAY repl_ignore_domain_ids;
- char *host, *user, *password, *log_file_name;
- char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
- char *ssl_crl, *ssl_crlpath;
- char *relay_log_name;
- LEX_STRING connection_name;
+ const char *host, *user, *password, *log_file_name;
+ const char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
+ const char *ssl_crl, *ssl_crlpath;
+ const char *relay_log_name;
+ LEX_CSTRING connection_name;
/* Value in START SLAVE UNTIL master_gtid_pos=xxx */
- LEX_STRING gtid_pos_str;
+ LEX_CSTRING gtid_pos_str;
ulonglong pos;
ulong relay_log_pos;
ulong server_id;
@@ -332,7 +334,7 @@ struct LEX_MASTER_INFO
ssl= ssl_verify_server_cert= heartbeat_opt=
repl_ignore_server_ids_opt= repl_do_domain_ids_opt=
repl_ignore_domain_ids_opt= LEX_MI_UNCHANGED;
- gtid_pos_str= null_lex_str;
+ gtid_pos_str= null_clex_str;
use_gtid_opt= LEX_GTID_UNCHANGED;
sql_delay= -1;
}
@@ -380,10 +382,10 @@ public:
The index name. Empty (str=NULL) name represents an empty list
USE INDEX () clause
*/
- LEX_STRING key_name;
+ LEX_CSTRING key_name;
Index_hint (enum index_hint_type type_arg, index_clause_map clause_arg,
- char *str, uint length) :
+ const char *str, uint length) :
type(type_arg), clause(clause_arg)
{
key_name.str= str;
@@ -580,7 +582,7 @@ public:
virtual List<Item>* get_item_list();
virtual ulong get_table_join_options();
virtual TABLE_LIST *add_table_to_list(THD *thd, Table_ident *table,
- LEX_STRING *alias,
+ LEX_CSTRING *alias,
ulong table_options,
thr_lock_type flags= TL_UNLOCK,
enum_mdl_type mdl_type= MDL_SHARED_READ,
@@ -804,7 +806,7 @@ class st_select_lex: public st_select_lex_node
{
public:
Name_resolution_context context;
- char *db;
+ const char *db;
Item *where, *having; /* WHERE & HAVING clauses */
Item *prep_where; /* saved WHERE clause for prepared statement processing */
Item *prep_having;/* saved HAVING clause for prepared statement processing */
@@ -1028,7 +1030,7 @@ public:
bool add_order_to_list(THD *thd, Item *item, bool asc);
bool add_gorder_to_list(THD *thd, Item *item, bool asc);
TABLE_LIST* add_table_to_list(THD *thd, Table_ident *table,
- LEX_STRING *alias,
+ LEX_CSTRING *alias,
ulong table_options,
thr_lock_type flags= TL_UNLOCK,
enum_mdl_type mdl_type= MDL_SHARED_READ,
@@ -1108,7 +1110,7 @@ public:
Add a index hint to the tagged list of hints. The type and clause of the
hint will be the current ones (set by set_index_hint())
*/
- bool add_index_hint (THD *thd, char *str, uint length);
+ bool add_index_hint (THD *thd, const char *str, uint length);
/* make a list to hold index hints */
void alloc_index_hints (THD *thd);
@@ -1186,11 +1188,11 @@ public:
List<Window_spec> window_specs;
void prepare_add_window_spec(THD *thd);
- bool add_window_def(THD *thd, LEX_STRING *win_name, LEX_STRING *win_ref,
+ bool add_window_def(THD *thd, LEX_CSTRING *win_name, LEX_CSTRING *win_ref,
SQL_I_List<ORDER> win_partition_list,
SQL_I_List<ORDER> win_order_list,
Window_frame *win_frame);
- bool add_window_spec(THD *thd, LEX_STRING *win_ref,
+ bool add_window_spec(THD *thd, LEX_CSTRING *win_ref,
SQL_I_List<ORDER> win_partition_list,
SQL_I_List<ORDER> win_order_list,
Window_frame *win_frame);
@@ -1237,7 +1239,7 @@ inline bool st_select_lex_unit::is_unit_op ()
struct st_sp_chistics
{
- LEX_STRING comment;
+ LEX_CSTRING comment;
enum enum_sp_suid_behaviour suid;
bool detistic;
enum enum_sp_data_access daccess;
@@ -2270,10 +2272,10 @@ public:
void body_utf8_append(const char *ptr);
void body_utf8_append(const char *ptr, const char *end_ptr);
void body_utf8_append_ident(THD *thd,
- const LEX_STRING *txt,
+ const LEX_CSTRING *txt,
const char *end_ptr);
void body_utf8_append_escape(THD *thd,
- const LEX_STRING *txt,
+ const LEX_CSTRING *txt,
CHARSET_INFO *txt_cs,
const char *end_ptr,
my_wc_t sep);
@@ -2597,15 +2599,15 @@ struct LEX: public Query_tables_list
// type information
CHARSET_INFO *charset;
- LEX_STRING name;
- char *help_arg;
- char *backup_dir; /* For RESTORE/BACKUP */
- char* to_log; /* For PURGE MASTER LOGS TO */
- char* x509_subject,*x509_issuer,*ssl_cipher;
+ LEX_CSTRING name;
+ const char *help_arg;
+ const char *backup_dir; /* For RESTORE/BACKUP */
+ const char* to_log; /* For PURGE MASTER LOGS TO */
+ const char* x509_subject,*x509_issuer,*ssl_cipher;
String *wild; /* Wildcard in SHOW {something} LIKE 'wild'*/
sql_exchange *exchange;
select_result *result;
- LEX_STRING comment, ident;
+ LEX_CSTRING comment, ident;
LEX_USER *grant_user;
XID *xid;
THD *thd;
@@ -2615,7 +2617,7 @@ struct LEX: public Query_tables_list
plugin_ref plugins_static_buffer[INITIAL_LEX_PLUGIN_LIST_SIZE];
/** SELECT of CREATE VIEW statement */
- LEX_STRING create_view_select;
+ LEX_CSTRING create_view_select;
uint number_of_selects; // valid only for view
@@ -2667,7 +2669,7 @@ public:
List<Item_func_set_user_var> set_var_list; // in-query assignment list
List<Item_param> param_list;
List<LEX_STRING> view_list; // view list (list of field names in view)
- List<LEX_STRING> with_column_list; // list of column names in with_list_element
+ List<LEX_CSTRING> with_column_list; // list of column names in with_list_element
List<LEX_STRING> *column_list; // list of column names (in ANALYZE)
List<LEX_STRING> *index_list; // list of index names (in ANALYZE)
/*
@@ -2695,7 +2697,7 @@ public:
Key *last_key;
LEX_MASTER_INFO mi; // used by CHANGE MASTER
LEX_SERVER_OPTIONS server_options;
- LEX_STRING relay_log_connection_name;
+ LEX_CSTRING relay_log_connection_name;
USER_RESOURCES mqh;
LEX_RESET_SLAVE reset_slave_info;
ulonglong type;
@@ -2789,7 +2791,7 @@ public:
*/
TABLE_LIST *create_last_non_select_table;
/* Prepared statements SQL syntax:*/
- LEX_STRING prepared_stmt_name; /* Statement name (in all queries) */
+ LEX_CSTRING prepared_stmt_name; /* Statement name (in all queries) */
/* PREPARE or EXECUTE IMMEDIATE source expression */
Item *prepared_stmt_code;
/* Names of user variables holding parameters (in EXECUTE) */
@@ -2910,7 +2912,7 @@ public:
SQL_I_List<ORDER> save_group_list;
SQL_I_List<ORDER> save_order_list;
- LEX_STRING *win_ref;
+ LEX_CSTRING *win_ref;
Window_frame *win_frame;
Window_frame_bound *frame_top_bound;
Window_frame_bound *frame_bottom_bound;
@@ -2943,7 +2945,7 @@ public:
return NULL;
}
- virtual const LEX_STRING *cursor_name() const { return &null_lex_str; }
+ virtual const LEX_CSTRING *cursor_name() const { return &null_clex_str; }
void start(THD *thd);
@@ -3034,7 +3036,7 @@ public:
context_stack.pop();
}
- bool copy_db_to(char **p_db, size_t *p_db_length) const;
+ bool copy_db_to(const char **p_db, size_t *p_db_length) const;
Name_resolution_context *current_context()
{
@@ -3079,7 +3081,8 @@ public:
bool is_analyze, bool *printed_anything);
void restore_set_statement_var();
- void init_last_field(Column_definition *field, const char *name, CHARSET_INFO *cs);
+ void init_last_field(Column_definition *field, const LEX_CSTRING *name,
+ const CHARSET_INFO *cs);
bool set_bincmp(CHARSET_INFO *cs, bool bin);
bool get_dynamic_sql_string(LEX_CSTRING *dst, String *buffer);
@@ -3094,7 +3097,7 @@ public:
}
return false;
}
- sp_variable *sp_param_init(LEX_STRING name);
+ sp_variable *sp_param_init(LEX_CSTRING *name);
bool sp_param_fill_definition(sp_variable *spvar);
int case_stmt_action_expr(Item* expr);
@@ -3104,12 +3107,12 @@ public:
enum sub_select_type type,
bool is_top_level);
bool setup_select_in_parentheses();
- bool set_trigger_new_row(LEX_STRING *name, Item *val);
+ bool set_trigger_new_row(LEX_CSTRING *name, Item *val);
bool set_system_variable(struct sys_var_with_base *tmp,
enum enum_var_type var_type, Item *val);
void set_stmt_init();
- sp_name *make_sp_name(THD *thd, LEX_STRING &name);
- sp_name *make_sp_name(THD *thd, LEX_STRING &name1, LEX_STRING &name2);
+ sp_name *make_sp_name(THD *thd, LEX_CSTRING *name);
+ sp_name *make_sp_name(THD *thd, LEX_CSTRING *name1, LEX_CSTRING *name2);
sp_head *make_sp_head(THD *thd, sp_name *name,
enum stored_procedure_type type);
sp_head *make_sp_head_no_recursive(THD *thd, sp_name *name,
@@ -3130,13 +3133,14 @@ public:
return make_sp_head_no_recursive(thd, name, type);
}
bool init_internal_variable(struct sys_var_with_base *variable,
- LEX_STRING name);
+ const LEX_CSTRING *name);
bool init_internal_variable(struct sys_var_with_base *variable,
- LEX_STRING dbname, LEX_STRING name);
+ const LEX_CSTRING *dbname,
+ const LEX_CSTRING *name);
bool init_default_internal_variable(struct sys_var_with_base *variable,
- LEX_STRING name);
+ LEX_CSTRING name);
bool set_variable(struct sys_var_with_base *variable, Item *item);
- bool set_variable(const LEX_STRING &name1, const LEX_STRING &name2,
+ bool set_variable(const LEX_CSTRING *name1, const LEX_CSTRING *name2,
Item *item);
void sp_variable_declarations_init(THD *thd, int nvars);
bool sp_variable_declarations_finalize(THD *thd, int nvars,
@@ -3164,24 +3168,24 @@ public:
bool sp_handler_declaration_init(THD *thd, int type);
bool sp_handler_declaration_finalize(THD *thd, int type);
- bool sp_declare_cursor(THD *thd, const LEX_STRING name,
+ bool sp_declare_cursor(THD *thd, const LEX_CSTRING *name,
class sp_lex_cursor *cursor_stmt,
sp_pcontext *param_ctx, bool add_cpush_instr);
- bool sp_open_cursor(THD *thd, const LEX_STRING name,
+ bool sp_open_cursor(THD *thd, const LEX_CSTRING *name,
List<sp_assignment_lex> *parameters);
- Item_splocal *create_item_for_sp_var(LEX_STRING name, sp_variable *spvar,
+ Item_splocal *create_item_for_sp_var(LEX_CSTRING *name, sp_variable *spvar,
const char *start_in_q,
const char *end_in_q);
- Item *create_item_ident_nosp(THD *thd, LEX_STRING name);
- Item *create_item_ident_sp(THD *thd, LEX_STRING name,
+ Item *create_item_ident_nosp(THD *thd, LEX_CSTRING *name);
+ Item *create_item_ident_sp(THD *thd, LEX_CSTRING *name,
uint start_in_q,
uint length_in_q);
- Item *create_item_ident_sp(THD *thd, LEX_STRING name,
+ Item *create_item_ident_sp(THD *thd, LEX_CSTRING *name,
const char *start_in_q,
const char *end_in_q);
- Item *create_item_ident(THD *thd, LEX_STRING name,
+ Item *create_item_ident(THD *thd, LEX_CSTRING *name,
const char *start_in_q,
const char *end_in_q)
{
@@ -3204,8 +3208,8 @@ public:
- Item_ref
*/
Item *create_item_ident_nospvar(THD *thd,
- const LEX_STRING &a,
- const LEX_STRING &b);
+ const LEX_CSTRING *a,
+ const LEX_CSTRING *b);
/*
Create an Item corresponding to a ROW field valiable: var.field
@param THD - THD, for mem_root
@@ -3217,8 +3221,8 @@ public:
@length_in_q - length in the query (for binary log)
*/
Item_splocal *create_item_spvar_row_field(THD *thd,
- const LEX_STRING &var,
- const LEX_STRING &field,
+ const LEX_CSTRING *var,
+ const LEX_CSTRING *field,
sp_variable *spvar,
uint pos_in_q,
uint length_in_q);
@@ -3236,8 +3240,8 @@ public:
@retval - NULL on error, or a pointer to a new Item.
*/
Item *create_item_ident(THD *thd,
- const LEX_STRING &a,
- const LEX_STRING &b,
+ const LEX_CSTRING *a,
+ const LEX_CSTRING *b,
uint pos_in_q, uint length_in_q);
/*
@@ -3251,22 +3255,22 @@ public:
@retval - NULL on error, or a pointer to a new Item.
*/
Item *create_item_ident(THD *thd,
- const LEX_STRING &a,
- const LEX_STRING &b,
- const LEX_STRING &c);
+ const LEX_CSTRING *a,
+ const LEX_CSTRING *b,
+ const LEX_CSTRING *c);
/*
Create an item for "NEXT VALUE FOR sequence_name"
*/
Item *create_item_func_nextval(THD *thd, Table_ident *ident);
- Item *create_item_func_nextval(THD *thd, const LEX_STRING &db,
- const LEX_STRING &name);
+ Item *create_item_func_nextval(THD *thd, const LEX_CSTRING *db,
+ const LEX_CSTRING *name);
/*
Create an item for "PREVIOUS VALUE FOR sequence_name"
*/
Item *create_item_func_lastval(THD *thd, Table_ident *ident);
- Item *create_item_func_lastval(THD *thd, const LEX_STRING &db,
- const LEX_STRING &name);
+ Item *create_item_func_lastval(THD *thd, const LEX_CSTRING *db,
+ const LEX_CSTRING *name);
/*
Create an item for a name in LIMIT clause: LIMIT var
@@ -3279,7 +3283,7 @@ public:
(non in SP, unknown variable, wrong data type).
*/
Item *create_item_limit(THD *thd,
- const LEX_STRING &var_name,
+ const LEX_CSTRING *var_name,
uint pos_in_q, uint length_in_q);
/*
@@ -3295,8 +3299,8 @@ public:
wrong data type).
*/
Item *create_item_limit(THD *thd,
- const LEX_STRING &var_name,
- const LEX_STRING &field_name,
+ const LEX_CSTRING *var_name,
+ const LEX_CSTRING *field_name,
uint pos_in_q, uint length_in_q);
/*
@@ -3307,19 +3311,19 @@ public:
@param field_name - the variable field name
*/
my_var *create_outvar(THD *thd,
- const LEX_STRING &var_name,
- const LEX_STRING &field_name);
+ const LEX_CSTRING *var_name,
+ const LEX_CSTRING *field_name);
- bool is_trigger_new_or_old_reference(const LEX_STRING name);
+ bool is_trigger_new_or_old_reference(const LEX_CSTRING *name);
- Item *create_and_link_Item_trigger_field(THD *thd, const char *name,
- bool new_row);
+ Item *create_and_link_Item_trigger_field(THD *thd, const LEX_CSTRING *name,
+ bool new_row);
- void sp_block_init(THD *thd, const LEX_STRING label);
+ void sp_block_init(THD *thd, const LEX_CSTRING *label);
void sp_block_init(THD *thd)
{
// Unlabeled blocks get an empty label
- sp_block_init(thd, empty_lex_str);
+ sp_block_init(thd, &empty_clex_str);
}
bool sp_block_finalize(THD *thd, const Lex_spblock_st spblock)
{
@@ -3331,8 +3335,8 @@ public:
return sp_block_finalize(thd, Lex_spblock());
}
bool sp_block_finalize(THD *thd, const Lex_spblock_st spblock,
- const LEX_STRING end_label);
- bool sp_block_finalize(THD *thd, const LEX_STRING end_label)
+ const LEX_CSTRING *end_label);
+ bool sp_block_finalize(THD *thd, const LEX_CSTRING *end_label)
{
return sp_block_finalize(thd, Lex_spblock(), end_label);
}
@@ -3360,51 +3364,51 @@ public:
uint executable_section_ip,
uint exception_count);
bool sp_exit_statement(THD *thd, Item *when);
- bool sp_exit_statement(THD *thd, const LEX_STRING label_name, Item *item);
- bool sp_leave_statement(THD *thd, const LEX_STRING label_name);
- bool sp_goto_statement(THD *thd, const LEX_STRING label_name);
+ bool sp_exit_statement(THD *thd, const LEX_CSTRING *label_name, Item *item);
+ bool sp_leave_statement(THD *thd, const LEX_CSTRING *label_name);
+ bool sp_goto_statement(THD *thd, const LEX_CSTRING *label_name);
bool sp_continue_statement(THD *thd, Item *when);
- bool sp_continue_statement(THD *thd, const LEX_STRING label_name, Item *when);
- bool sp_iterate_statement(THD *thd, const LEX_STRING label_name);
+ bool sp_continue_statement(THD *thd, const LEX_CSTRING *label_name, Item *when);
+ bool sp_iterate_statement(THD *thd, const LEX_CSTRING *label_name);
bool maybe_start_compound_statement(THD *thd);
- bool sp_push_loop_label(THD *thd, LEX_STRING label_name);
+ bool sp_push_loop_label(THD *thd, const LEX_CSTRING *label_name);
bool sp_push_loop_empty_label(THD *thd);
- bool sp_pop_loop_label(THD *thd, const LEX_STRING label_name);
+ bool sp_pop_loop_label(THD *thd, const LEX_CSTRING *label_name);
void sp_pop_loop_empty_label(THD *thd);
bool sp_while_loop_expression(THD *thd, Item *expr);
bool sp_while_loop_finalize(THD *thd);
- bool sp_push_goto_label(THD *thd, LEX_STRING label_name);
+ bool sp_push_goto_label(THD *thd, const LEX_CSTRING *label_name);
- Item_param *add_placeholder(THD *thd, char *name,
+ Item_param *add_placeholder(THD *thd, const LEX_CSTRING *name,
uint pos_in_query, uint len_in_query);
- Item_param *add_placeholder(THD *thd, char *name,
+ Item_param *add_placeholder(THD *thd, const LEX_CSTRING *name,
const char *pos, const char *end)
{
return add_placeholder(thd, name, pos - substatement_query(thd), end - pos);
}
/* Integer range FOR LOOP methods */
- sp_variable *sp_add_for_loop_variable(THD *thd, const LEX_STRING name,
+ sp_variable *sp_add_for_loop_variable(THD *thd, const LEX_CSTRING *name,
Item *value);
sp_variable *sp_add_for_loop_upper_bound(THD *thd, Item *value)
{
- LEX_STRING name= { C_STRING_WITH_LEN("[upper_bound]") };
- return sp_add_for_loop_variable(thd, name, value);
+ LEX_CSTRING name= { C_STRING_WITH_LEN("[upper_bound]") };
+ return sp_add_for_loop_variable(thd, &name, value);
}
bool sp_for_loop_intrange_declarations(THD *thd, Lex_for_loop_st *loop,
- const LEX_STRING &index,
+ const LEX_CSTRING *index,
const Lex_for_loop_bounds_st &bounds);
bool sp_for_loop_intrange_condition_test(THD *thd, const Lex_for_loop_st &loop);
bool sp_for_loop_intrange_finalize(THD *thd, const Lex_for_loop_st &loop);
/* Cursor FOR LOOP methods */
bool sp_for_loop_cursor_declarations(THD *thd, Lex_for_loop_st *loop,
- const LEX_STRING &index,
+ const LEX_CSTRING *index,
const Lex_for_loop_bounds_st &bounds);
sp_variable *sp_add_for_loop_cursor_variable(THD *thd,
- const LEX_STRING name,
+ const LEX_CSTRING *name,
const class sp_pcursor *cur,
uint coffset,
sp_assignment_lex *param_lex,
@@ -3436,7 +3440,7 @@ public:
Additional loop characteristics are copied from "bounds" to "loop".
*/
bool sp_for_loop_declarations(THD *thd, Lex_for_loop_st *loop,
- const LEX_STRING &index,
+ const LEX_CSTRING *index,
const Lex_for_loop_bounds_st &bounds)
{
return bounds.is_for_loop_cursor() ?
@@ -3488,7 +3492,7 @@ public:
return false;
}
// Add a key as a part of CREATE TABLE or ALTER TABLE
- bool add_key(Key::Keytype key_type, const LEX_STRING &key_name,
+ bool add_key(Key::Keytype key_type, const LEX_CSTRING *key_name,
ha_key_alg algorithm, DDL_options_st ddl)
{
if (check_add_key(ddl) ||
@@ -3498,7 +3502,7 @@ public:
return false;
}
// Add a key for a CREATE INDEX statement
- bool add_create_index(Key::Keytype key_type, const LEX_STRING &key_name,
+ bool add_create_index(Key::Keytype key_type, const LEX_CSTRING *key_name,
ha_key_alg algorithm, DDL_options_st ddl)
{
if (check_create_options(ddl) ||
@@ -3524,10 +3528,10 @@ public:
Add an UNIQUE or PRIMARY key which is a part of a column definition:
CREATE TABLE t1 (a INT PRIMARY KEY);
*/
- void add_key_to_list(LEX_STRING *field_name,
+ void add_key_to_list(LEX_CSTRING *field_name,
enum Key::Keytype type, bool check_exists);
// Add a constraint as a part of CREATE TABLE or ALTER TABLE
- bool add_constraint(LEX_STRING *name, Virtual_column_info *constr,
+ bool add_constraint(LEX_CSTRING *name, Virtual_column_info *constr,
bool if_not_exists)
{
constr->name= *name;
@@ -3563,7 +3567,7 @@ public:
create_info.add(options);
return check_create_options(create_info);
}
- bool sp_add_cfetch(THD *thd, const LEX_STRING &name);
+ bool sp_add_cfetch(THD *thd, const LEX_CSTRING *name);
bool set_command_with_check(enum_sql_command command,
uint scope,
@@ -3867,18 +3871,18 @@ int init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex);
extern int MYSQLlex(union YYSTYPE *yylval, THD *thd);
extern int ORAlex(union YYSTYPE *yylval, THD *thd);
-extern void trim_whitespace(CHARSET_INFO *cs, LEX_STRING *str,
+extern void trim_whitespace(CHARSET_INFO *cs, LEX_CSTRING *str,
uint *prefix_removed);
-extern bool is_lex_native_function(const LEX_STRING *name);
-extern bool is_native_function(THD *thd, const LEX_STRING *name);
-extern bool is_native_function_with_warn(THD *thd, const LEX_STRING *name);
+extern bool is_lex_native_function(const LEX_CSTRING *name);
+extern bool is_native_function(THD *thd, const LEX_CSTRING *name);
+extern bool is_native_function_with_warn(THD *thd, const LEX_CSTRING *name);
/**
@} (End of group Semantic_Analysis)
*/
-void my_missing_function_error(const LEX_STRING &token, const char *name);
+void my_missing_function_error(const LEX_CSTRING &token, const char *name);
bool is_keyword(const char *name, uint len);
Virtual_column_info *add_virtual_expression(THD *thd, Item *expr);
diff --git a/sql/sql_list.h b/sql/sql_list.h
index 217cdad5abb..e1307f1daa0 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -522,10 +522,10 @@ public:
base_list(tmp, mem_root) {}
inline bool push_back(T *a) { return base_list::push_back(a); }
inline bool push_back(T *a, MEM_ROOT *mem_root)
- { return base_list::push_back(a, mem_root); }
+ { return base_list::push_back((void*) a, mem_root); }
inline bool push_front(T *a) { return base_list::push_front(a); }
inline bool push_front(T *a, MEM_ROOT *mem_root)
- { return base_list::push_front(a, mem_root); }
+ { return base_list::push_front((void*) a, mem_root); }
inline T* head() {return (T*) base_list::head(); }
inline T** head_ref() {return (T**) base_list::head_ref(); }
inline T* pop() {return (T*) base_list::pop(); }
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 6f0e97a61c9..b430aea4c0b 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -283,13 +283,13 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
killed_state killed_status;
bool is_concurrent;
#endif
- char *db = table_list->db; // This is never null
+ const char *db = table_list->db; // This is never null
/*
If path for file is not defined, we will use the current database.
If this is not set, we will use the directory where the table to be
loaded is located
*/
- char *tdb= thd->db ? thd->db : db; // Result is never null
+ const char *tdb= thd->db ? thd->db : db; // Result is never null
ulong skip_lines= ex->skip_lines;
bool transactional_table __attribute__((unused));
DBUG_ENTER("mysql_load");
@@ -812,7 +812,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
if (n++)
query_str.append(", ");
if (item->real_type() == Item::FIELD_ITEM)
- append_identifier(thd, &query_str, item->name, strlen(item->name));
+ append_identifier(thd, &query_str, item->name.str, item->name.length);
else
{
/* Actually Item_user_var_as_out_param despite claiming STRING_ITEM. */
@@ -836,8 +836,8 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
val= lv++;
if (n++)
query_str.append(STRING_WITH_LEN(", "));
- append_identifier(thd, &query_str, item->name, strlen(item->name));
- query_str.append(val->name);
+ append_identifier(thd, &query_str, item->name.str, item->name.length);
+ query_str.append(val->name.str, val->name.length);
}
}
@@ -1085,7 +1085,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
Field *field= ((Item_field *)real_item)->field;
if (field->reset())
{
- my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field->field_name,
+ my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field->field_name.str,
thd->get_stmt_da()->current_row_for_warning());
DBUG_RETURN(1);
}
@@ -1164,7 +1164,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
Field *field= ((Item_field *)real_item)->field;
if (field->reset())
{
- my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0),field->field_name,
+ my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0),field->field_name.str,
thd->get_stmt_da()->current_row_for_warning());
DBUG_RETURN(1);
}
@@ -1296,7 +1296,7 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
xmlit.rewind();
tag= xmlit++;
- while(tag && strcmp(tag->field.c_ptr(), item->name) != 0)
+ while(tag && strcmp(tag->field.c_ptr(), item->name.str) != 0)
tag= xmlit++;
if (!tag) // found null
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 012d4689dde..b6955ee885f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1576,7 +1576,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (thd->wsrep_conflict_state == ABORTED &&
command != COM_STMT_CLOSE && command != COM_QUIT)
{
- my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction");
+ my_message(ER_LOCK_DEADLOCK, "wsrep aborted transaction", MYF(0));
WSREP_DEBUG("Deadlock error for: %s", thd->query());
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
thd->killed = NOT_KILLED;
@@ -1656,9 +1656,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
switch (command) {
case COM_INIT_DB:
{
- LEX_STRING tmp;
+ LEX_CSTRING tmp;
status_var_increment(thd->status_var.com_stat[SQLCOM_CHANGE_DB]);
- if (thd->copy_with_error(system_charset_info, &tmp,
+ if (thd->copy_with_error(system_charset_info, (LEX_STRING*) &tmp,
thd->charset(), packet, packet_length))
break;
if (!mysql_change_db(thd, &tmp, FALSE))
@@ -1728,7 +1728,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (auth_rc)
{
/* Free user if allocated by acl_authenticate */
- my_free(thd->security_ctx->user);
+ my_free(const_cast<char*>(thd->security_ctx->user));
*thd->security_ctx= save_security_ctx;
if (thd->user_connect)
decrease_user_connections(thd->user_connect);
@@ -1747,7 +1747,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
decrease_user_connections(save_user_connect);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
my_free(save_db);
- my_free(save_security_ctx.user);
+ my_free(const_cast<char*>(save_security_ctx.user));
}
break;
}
@@ -1919,7 +1919,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
/* Locked closure of all tables */
TABLE_LIST table_list;
LEX_STRING table_name;
- LEX_STRING db;
+ LEX_CSTRING db;
/*
SHOW statements should not add the used tables to the list of tables
used in a transaction.
@@ -1966,7 +1966,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (lower_case_table_names)
{
table_name.length= my_casedn_str(files_charset_info, table_name.str);
- db.length= my_casedn_str(files_charset_info, db.str);
+ db.length= my_casedn_str(files_charset_info, (char*) db.str);
}
table_list.init_one_table(db.str, db.length, table_name.str,
table_name.length, table_name.str, TL_READ);
@@ -2107,7 +2107,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
else
#endif
{
- thd->lex->relay_log_connection_name= empty_lex_str;
+ thd->lex->relay_log_connection_name= empty_clex_str;
if (reload_acl_and_cache(thd, options, (TABLE_LIST*) 0, &not_used))
break;
}
@@ -2288,7 +2288,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (server_command_flags[subcommand] & CF_NO_COM_MULTI)
{
- my_error(ER_BAD_COMMAND_IN_MULTI, MYF(0), command_name[subcommand]);
+ my_error(ER_BAD_COMMAND_IN_MULTI, MYF(0),
+ command_name[subcommand].str);
goto com_multi_end;
}
@@ -2530,10 +2531,16 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
DBUG_RETURN(1);
}
schema_select_lex= new (thd->mem_root) SELECT_LEX();
- db.str= schema_select_lex->db= lex->select_lex.db;
schema_select_lex->table_list.first= NULL;
+ if (lower_case_table_names == 1)
+ lex->select_lex.db= thd->strdup(lex->select_lex.db);
+ schema_select_lex->db= lex->select_lex.db;
+ /*
+ check_db_name() may change db.str if lower_case_table_names == 1,
+ but that's ok as the db is allocted above in this case.
+ */
+ db.str= (char*) lex->select_lex.db;
db.length= strlen(db.str);
-
if (check_db_name(&db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db.str);
@@ -2897,16 +2904,13 @@ static bool do_execute_sp(THD *thd, sp_head *sp)
static int mysql_create_routine(THD *thd, LEX *lex)
{
- uint namelen;
- char *name;
-
DBUG_ASSERT(lex->sphead != 0);
DBUG_ASSERT(lex->sphead->m_db.str); /* Must be initialized in the parser */
/*
Verify that the database name is allowed, optionally
lowercase it.
*/
- if (check_db_name(&lex->sphead->m_db))
+ if (check_db_name((LEX_STRING*) &lex->sphead->m_db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str);
return true;
@@ -2925,15 +2929,15 @@ static int mysql_create_routine(THD *thd, LEX *lex)
return true;
}
- name= lex->sphead->name(&namelen);
+ const LEX_CSTRING *name= lex->sphead->name();
#ifdef HAVE_DLOPEN
if (lex->sphead->m_type == TYPE_ENUM_FUNCTION)
{
- udf_func *udf = find_udf(name, namelen);
+ udf_func *udf = find_udf(name->str, name->length);
if (udf)
{
- my_error(ER_UDF_EXISTS, MYF(0), name);
+ my_error(ER_UDF_EXISTS, MYF(0), name->str);
return true;
}
}
@@ -2989,10 +2993,10 @@ static int mysql_create_routine(THD *thd, LEX *lex)
if (sp_automatic_privileges && !opt_noacl &&
check_routine_access(thd, DEFAULT_CREATE_PROC_ACLS,
- lex->sphead->m_db.str, name,
+ lex->sphead->m_db.str, name->str,
lex->sql_command == SQLCOM_CREATE_PROCEDURE, 1))
{
- if (sp_grant_privileges(thd, lex->sphead->m_db.str, name,
+ if (sp_grant_privileges(thd, lex->sphead->m_db.str, name->str,
lex->sql_command == SQLCOM_CREATE_PROCEDURE))
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
ER_PROC_AUTO_GRANT_FAIL, ER_THD(thd, ER_PROC_AUTO_GRANT_FAIL));
@@ -4898,7 +4902,7 @@ end_with_restore_list:
#endif
case SQLCOM_CHANGE_DB:
{
- LEX_STRING db_str= { (char *) select_lex->db, strlen(select_lex->db) };
+ LEX_CSTRING db_str= { (char *) select_lex->db, strlen(select_lex->db) };
if (!mysql_change_db(thd, &db_str, FALSE))
my_ok(thd);
@@ -5021,7 +5025,7 @@ end_with_restore_list:
break;
case SQLCOM_CREATE_DB:
{
- if (check_db_name(&lex->name))
+ if (check_db_name((LEX_STRING*) &lex->name))
{
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
break;
@@ -5056,7 +5060,7 @@ end_with_restore_list:
}
case SQLCOM_DROP_DB:
{
- if (check_db_name(&lex->name))
+ if (check_db_name((LEX_STRING*) &lex->name))
{
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
break;
@@ -5088,7 +5092,7 @@ end_with_restore_list:
}
case SQLCOM_ALTER_DB_UPGRADE:
{
- LEX_STRING *db= & lex->name;
+ LEX_CSTRING *db= &lex->name;
#ifdef HAVE_REPLICATION
if (thd->slave_thread)
{
@@ -5102,7 +5106,7 @@ end_with_restore_list:
}
}
#endif
- if (check_db_name(db))
+ if (check_db_name((LEX_STRING*) db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db->str);
break;
@@ -5122,8 +5126,8 @@ end_with_restore_list:
}
case SQLCOM_ALTER_DB:
{
- LEX_STRING *db= &lex->name;
- if (check_db_name(db))
+ LEX_CSTRING *db= &lex->name;
+ if (check_db_name((LEX_STRING*) db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db->str);
break;
@@ -5156,19 +5160,19 @@ end_with_restore_list:
case SQLCOM_SHOW_CREATE_DB:
{
char db_name_buff[NAME_LEN+1];
- LEX_STRING db_name;
+ LEX_CSTRING db_name;
DBUG_EXECUTE_IF("4x_server_emul",
my_error(ER_UNKNOWN_ERROR, MYF(0)); goto error;);
db_name.str= db_name_buff;
db_name.length= lex->name.length;
- strmov(db_name.str, lex->name.str);
+ strmov(db_name_buff, lex->name.str);
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
- if (check_db_name(&db_name))
+ if (check_db_name((LEX_STRING*) &db_name))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str);
break;
@@ -5224,13 +5228,13 @@ end_with_restore_list:
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
- res= Events::show_create_event(thd, lex->spname->m_db,
- lex->spname->m_name);
+ res= Events::show_create_event(thd, &lex->spname->m_db,
+ &lex->spname->m_name);
break;
case SQLCOM_DROP_EVENT:
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
if (!(res= Events::drop_event(thd,
- lex->spname->m_db, lex->spname->m_name,
+ &lex->spname->m_db, &lex->spname->m_name,
lex->if_exists())))
my_ok(thd);
break;
@@ -5901,8 +5905,8 @@ end_with_restore_list:
enum stored_procedure_type type;
type= (lex->sql_command == SQLCOM_DROP_PROCEDURE ?
TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION);
- char *db= lex->spname->m_db.str;
- char *name= lex->spname->m_name.str;
+ const char *db= lex->spname->m_db.str;
+ const char *name= lex->spname->m_name.str;
if (check_routine_access(thd, ALTER_PROC_ACL, db, name,
lex->sql_command == SQLCOM_DROP_PROCEDURE, 0))
@@ -7047,7 +7051,8 @@ deny:
bool
-check_routine_access(THD *thd, ulong want_access,char *db, char *name,
+check_routine_access(THD *thd, ulong want_access, const char *db,
+ const char *name,
bool is_proc, bool no_errors)
{
TABLE_LIST tables[1];
@@ -7220,8 +7225,8 @@ bool check_fk_parent_table_access(THD *thd,
TABLE_LIST parent_table;
bool is_qualified_table_name;
Foreign_key *fk_key= (Foreign_key *)key;
- LEX_STRING db_name;
- LEX_STRING table_name= { fk_key->ref_table.str,
+ LEX_CSTRING db_name;
+ LEX_CSTRING table_name= { fk_key->ref_table.str,
fk_key->ref_table.length };
const ulong privileges= (SELECT_ACL | INSERT_ACL | UPDATE_ACL |
DELETE_ACL | REFERENCES_ACL);
@@ -7237,12 +7242,13 @@ bool check_fk_parent_table_access(THD *thd,
if (fk_key->ref_db.str)
{
is_qualified_table_name= true;
- db_name.str= (char *) thd->memdup(fk_key->ref_db.str,
- fk_key->ref_db.length+1);
+ if (!(db_name.str= (char *) thd->memdup(fk_key->ref_db.str,
+ fk_key->ref_db.length+1)))
+ return true;
db_name.length= fk_key->ref_db.length;
// Check if database name is valid or not.
- if (fk_key->ref_db.str && check_db_name(&db_name))
+ if (check_db_name((LEX_STRING*) &db_name))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str);
return true;
@@ -7252,11 +7258,14 @@ bool check_fk_parent_table_access(THD *thd,
{
if (!thd->db)
{
- db_name.str= (char *) thd->memdup(create_db, strlen(create_db)+1);
+ DBUG_ASSERT(create_db);
db_name.length= strlen(create_db);
+ if (!(db_name.str= (char *) thd->memdup(create_db,
+ db_name.length+1)))
+ return true;
is_qualified_table_name= true;
- if(create_db && check_db_name(&db_name))
+ if (check_db_name((LEX_STRING*) &db_name))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str);
return true;
@@ -7274,10 +7283,11 @@ bool check_fk_parent_table_access(THD *thd,
// if lower_case_table_names is set then convert tablename to lower case.
if (lower_case_table_names)
{
- table_name.str= (char *) thd->memdup(fk_key->ref_table.str,
- fk_key->ref_table.length+1);
- table_name.length= my_casedn_str(files_charset_info, table_name.str);
- db_name.length = my_casedn_str(files_charset_info, db_name.str);
+ char *name;
+ table_name.str= name= (char *) thd->memdup(fk_key->ref_table.str,
+ fk_key->ref_table.length+1);
+ table_name.length= my_casedn_str(files_charset_info, name);
+ db_name.length= my_casedn_str(files_charset_info, (char*) db_name.str);
}
parent_table.init_one_table(db_name.str, db_name.length,
@@ -7649,7 +7659,7 @@ void create_select_for_variable(const char *var_name)
{
THD *thd;
LEX *lex;
- LEX_STRING tmp;
+ LEX_CSTRING tmp;
Item *var;
char buff[MAX_SYS_VAR_LENGTH*2+4+8], *end;
DBUG_ENTER("create_select_for_variable");
@@ -7658,13 +7668,13 @@ void create_select_for_variable(const char *var_name)
lex= thd->lex;
mysql_init_select(lex);
lex->sql_command= SQLCOM_SELECT;
- tmp.str= (char*) var_name;
+ tmp.str= var_name;
tmp.length=strlen(var_name);
/*
We set the name of Item to @@session.var_name because that then is used
as the column name in the output.
*/
- if ((var= get_system_var(thd, OPT_SESSION, tmp, null_lex_str)))
+ if ((var= get_system_var(thd, OPT_SESSION, tmp, null_clex_str)))
{
end= strxmov(buff, "@@session.", var_name, NullS);
var->set_name(thd, buff, end-buff, system_charset_info);
@@ -7757,7 +7767,7 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
(longlong) thd->thread_id, is_autocommit,
thd->wsrep_retry_counter,
thd->variables.wsrep_retry_autocommit, thd->query());
- my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction");
+ my_message(ER_LOCK_DEADLOCK, "wsrep aborted transaction", MYF(0));
thd->killed= NOT_KILLED;
thd->wsrep_conflict_state= NO_CONFLICT;
if (thd->wsrep_conflict_state != REPLAYING)
@@ -8031,7 +8041,7 @@ bool add_to_list(THD *thd, SQL_I_List<ORDER> &list, Item *item,bool asc)
TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
Table_ident *table,
- LEX_STRING *alias,
+ LEX_CSTRING *alias,
ulong table_options,
thr_lock_type lock_type,
enum_mdl_type mdl_type,
@@ -8041,7 +8051,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
{
register TABLE_LIST *ptr;
TABLE_LIST *UNINIT_VAR(previous_table_ref); /* The table preceding the current one. */
- char *alias_str;
+ const char *alias_str;
LEX *lex= thd->lex;
DBUG_ENTER("add_table_to_list");
@@ -8056,7 +8066,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
}
if (table->is_derived_table() == FALSE && table->db.str &&
- check_db_name(&table->db))
+ check_db_name((LEX_STRING*) &table->db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), table->db.str);
DBUG_RETURN(0);
@@ -8091,9 +8101,10 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
if (lower_case_table_names)
{
if (table->table.length)
- table->table.length= my_casedn_str(files_charset_info, table->table.str);
+ table->table.length= my_casedn_str(files_charset_info,
+ (char*) table->table.str);
if (ptr->db_length && ptr->db != any_db)
- ptr->db_length= my_casedn_str(files_charset_info, ptr->db);
+ ptr->db_length= my_casedn_str(files_charset_info, (char*) ptr->db);
}
ptr->table_name=table->table.str;
@@ -8436,8 +8447,8 @@ void st_select_lex::prepare_add_window_spec(THD *thd)
}
bool st_select_lex::add_window_def(THD *thd,
- LEX_STRING *win_name,
- LEX_STRING *win_ref,
+ LEX_CSTRING *win_name,
+ LEX_CSTRING *win_ref,
SQL_I_List<ORDER> win_partition_list,
SQL_I_List<ORDER> win_order_list,
Window_frame *win_frame)
@@ -8459,7 +8470,7 @@ bool st_select_lex::add_window_def(THD *thd,
}
bool st_select_lex::add_window_spec(THD *thd,
- LEX_STRING *win_ref,
+ LEX_CSTRING *win_ref,
SQL_I_List<ORDER> win_partition_list,
SQL_I_List<ORDER> win_order_list,
Window_frame *win_frame)
@@ -9588,7 +9599,7 @@ void get_default_definer(THD *thd, LEX_USER *definer, bool role)
if (role)
{
definer->user.str= const_cast<char*>(sctx->priv_role);
- definer->host= empty_lex_str;
+ definer->host= empty_clex_str;
}
else
{
@@ -9645,7 +9656,8 @@ LEX_USER *create_default_definer(THD *thd, bool role)
- On error, return 0.
*/
-LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name)
+LEX_USER *create_definer(THD *thd, LEX_CSTRING *user_name,
+ LEX_CSTRING *host_name)
{
LEX_USER *definer;
@@ -9679,7 +9691,7 @@ LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name)
The function is not used in existing code but can be useful later?
*/
-bool check_string_byte_length(LEX_STRING *str, uint err_msg,
+bool check_string_byte_length(LEX_CSTRING *str, uint err_msg,
uint max_byte_length)
{
if (str->length <= max_byte_length)
@@ -9709,7 +9721,7 @@ bool check_string_byte_length(LEX_STRING *str, uint err_msg,
*/
-bool check_string_char_length(LEX_STRING *str, uint err_msg,
+bool check_string_char_length(LEX_CSTRING *str, uint err_msg,
uint max_char_length, CHARSET_INFO *cs,
bool no_error)
{
@@ -9728,7 +9740,7 @@ bool check_string_char_length(LEX_STRING *str, uint err_msg,
}
-bool check_ident_length(LEX_STRING *ident)
+bool check_ident_length(LEX_CSTRING *ident)
{
if (check_string_char_length(ident, 0, NAME_CHAR_LEN, system_charset_info, 1))
{
@@ -9838,7 +9850,7 @@ int error_if_data_home_dir(const char *path, const char *what)
has invalid symbols
*/
-bool check_host_name(LEX_STRING *str)
+bool check_host_name(LEX_CSTRING *str)
{
const char *name= str->str;
const char *end= str->str + str->length;
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index be3979b1f66..bf241d04e7b 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -70,19 +70,19 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
enum enum_schema_tables schema_table_idx);
void get_default_definer(THD *thd, LEX_USER *definer, bool role);
LEX_USER *create_default_definer(THD *thd, bool role);
-LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name);
+LEX_USER *create_definer(THD *thd, LEX_CSTRING *user_name, LEX_CSTRING *host_name);
LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock=true);
bool sp_process_definer(THD *thd);
-bool check_string_byte_length(LEX_STRING *str, uint err_msg,
+bool check_string_byte_length(LEX_CSTRING *str, uint err_msg,
uint max_byte_length);
-bool check_string_char_length(LEX_STRING *str, uint err_msg,
+bool check_string_char_length(LEX_CSTRING *str, uint err_msg,
uint max_char_length, CHARSET_INFO *cs,
bool no_error);
-bool check_ident_length(LEX_STRING *ident);
+bool check_ident_length(LEX_CSTRING *ident);
CHARSET_INFO* merge_charset_and_collation(CHARSET_INFO *cs, CHARSET_INFO *cl);
CHARSET_INFO *find_bin_collation(CHARSET_INFO *cs);
-bool check_host_name(LEX_STRING *str);
-bool check_identifier_name(LEX_STRING *str, uint max_char_length,
+bool check_host_name(LEX_CSTRING *str);
+bool check_identifier_name(LEX_CSTRING *str, uint max_char_length,
uint err_code, const char *param_for_err_msg);
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
bool sqlcom_can_generate_row_events(const THD *thd);
@@ -136,12 +136,12 @@ extern const LEX_STRING command_name[];
extern uint server_command_flags[];
/* Inline functions */
-inline bool check_identifier_name(LEX_STRING *str, uint err_code)
+inline bool check_identifier_name(LEX_CSTRING *str, uint err_code)
{
return check_identifier_name(str, NAME_CHAR_LEN, err_code, "");
}
-inline bool check_identifier_name(LEX_STRING *str)
+inline bool check_identifier_name(LEX_CSTRING *str)
{
return check_identifier_name(str, NAME_CHAR_LEN, 0, "");
}
@@ -150,7 +150,8 @@ inline bool check_identifier_name(LEX_STRING *str)
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
bool check_single_table_access(THD *thd, ulong privilege,
TABLE_LIST *tables, bool no_errors);
-bool check_routine_access(THD *thd,ulong want_access,char *db,char *name,
+bool check_routine_access(THD *thd,ulong want_access,const char *db,
+ const char *name,
bool is_proc, bool no_errors);
bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table);
bool check_some_routine_access(THD *thd, const char *db, const char *name, bool is_proc);
@@ -164,8 +165,8 @@ inline bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables
inline bool check_single_table_access(THD *thd, ulong privilege,
TABLE_LIST *tables, bool no_errors)
{ return false; }
-inline bool check_routine_access(THD *thd,ulong want_access,char *db,
- char *name, bool is_proc, bool no_errors)
+inline bool check_routine_access(THD *thd,ulong want_access, const char *db,
+ const char *name, bool is_proc, bool no_errors)
{ return false; }
inline bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table)
{
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index d226f7e05ba..053b864ed68 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -198,15 +198,15 @@ Item* convert_charset_partition_constant(Item *item, CHARSET_INFO *cs)
@retval false String not found
*/
-static bool is_name_in_list(char *name, List<char> list_names)
+static bool is_name_in_list(const char *name, List<const char> list_names)
{
- List_iterator<char> names_it(list_names);
+ List_iterator<const char> names_it(list_names);
uint num_names= list_names.elements;
uint i= 0;
do
{
- char *list_name= names_it++;
+ const char *list_name= names_it++;
if (!(my_strcasecmp(system_charset_info, name, list_name)))
return TRUE;
} while (++i < num_names);
@@ -484,8 +484,8 @@ static bool set_up_field_array(THD *thd, TABLE *table,
{
if (!is_sub_part && part_info->column_list)
{
- List_iterator<char> it(part_info->part_field_list);
- char *field_name;
+ List_iterator<const char> it(part_info->part_field_list);
+ const char *field_name;
DBUG_ASSERT(num_fields == part_info->part_field_list.elements);
inx= 0;
@@ -494,7 +494,7 @@ static bool set_up_field_array(THD *thd, TABLE *table,
field_name= it++;
if (!my_strcasecmp(system_charset_info,
field_name,
- field->field_name))
+ field->field_name.str))
break;
} while (++inx < num_fields);
if (inx == num_fields)
@@ -779,14 +779,14 @@ static void clear_field_flag(TABLE *table)
*/
-static bool handle_list_of_fields(THD *thd, List_iterator<char> it,
+static bool handle_list_of_fields(THD *thd, List_iterator<const char> it,
TABLE *table,
partition_info *part_info,
bool is_sub_part)
{
Field *field;
bool result;
- char *field_name;
+ const char *field_name;
bool is_list_empty= TRUE;
DBUG_ENTER("handle_list_of_fields");
@@ -1613,7 +1613,7 @@ bool fix_partition_func(THD *thd, TABLE *table,
set_linear_hash_mask(part_info, part_info->num_subparts);
if (part_info->list_of_subpart_fields)
{
- List_iterator<char> it(part_info->subpart_field_list);
+ List_iterator<const char> it(part_info->subpart_field_list);
if (unlikely(handle_list_of_fields(thd, it, table, part_info, TRUE)))
goto end;
}
@@ -1640,7 +1640,7 @@ bool fix_partition_func(THD *thd, TABLE *table,
set_linear_hash_mask(part_info, part_info->num_parts);
if (part_info->list_of_part_fields)
{
- List_iterator<char> it(part_info->part_field_list);
+ List_iterator<const char> it(part_info->part_field_list);
if (unlikely(handle_list_of_fields(thd, it, table, part_info, FALSE)))
goto end;
}
@@ -1662,7 +1662,7 @@ bool fix_partition_func(THD *thd, TABLE *table,
const char *error_str;
if (part_info->column_list)
{
- List_iterator<char> it(part_info->part_field_list);
+ List_iterator<const char> it(part_info->part_field_list);
if (unlikely(handle_list_of_fields(thd, it, table, part_info, FALSE)))
goto end;
}
@@ -1844,12 +1844,12 @@ static int add_subpartition_by(File fptr)
return err + add_partition_by(fptr);
}
-static int add_part_field_list(File fptr, List<char> field_list)
+static int add_part_field_list(File fptr, List<const char> field_list)
{
uint i, num_fields;
int err= 0;
- List_iterator<char> part_it(field_list);
+ List_iterator<const char> part_it(field_list);
num_fields= field_list.elements;
i= 0;
err+= add_begin_parenthesis(fptr);
@@ -2142,7 +2142,7 @@ error:
NULL No field found
*/
-static Create_field* get_sql_field(char *field_name,
+static Create_field* get_sql_field(const char *field_name,
Alter_info *alter_info)
{
List_iterator<Create_field> it(alter_info->create_list);
@@ -2152,7 +2152,7 @@ static Create_field* get_sql_field(char *field_name,
while ((sql_field= it++))
{
if (!(my_strcasecmp(system_charset_info,
- sql_field->field_name,
+ sql_field->field_name.str,
field_name)))
{
DBUG_RETURN(sql_field);
@@ -2169,7 +2169,7 @@ static int add_column_list_values(File fptr, partition_info *part_info,
{
int err= 0;
uint i;
- List_iterator<char> it(part_info->part_field_list);
+ List_iterator<const char> it(part_info->part_field_list);
uint num_elements= part_info->part_field_list.elements;
bool use_parenthesis= (part_info->part_type == LIST_PARTITION &&
part_info->num_columns > 1U);
@@ -2179,7 +2179,7 @@ static int add_column_list_values(File fptr, partition_info *part_info,
for (i= 0; i < num_elements; i++)
{
part_column_list_val *col_val= &list_value->col_val_array[i];
- char *field_name= it++;
+ const char *field_name= it++;
if (col_val->max_value)
err+= add_string(fptr, partition_keywords[PKW_MAXVALUE].str);
else if (col_val->null_value)
@@ -2215,7 +2215,7 @@ static int add_column_list_values(File fptr, partition_info *part_info,
return 1;
}
if (check_part_field(sql_field->sql_type,
- sql_field->field_name,
+ sql_field->field_name.str,
&result_type,
&need_cs_check))
return 1;
@@ -2229,7 +2229,7 @@ static int add_column_list_values(File fptr, partition_info *part_info,
Field *field= part_info->part_field_array[i];
result_type= field->result_type();
if (check_part_field(field->real_type(),
- field->field_name,
+ field->field_name.str,
&result_type,
&need_cs_check))
return 1;
@@ -6836,7 +6836,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
Alter_info *alter_info,
HA_CREATE_INFO *create_info,
TABLE_LIST *table_list,
- char *db,
+ const char *db,
const char *table_name)
{
/* Set-up struct used to write frm files */
diff --git a/sql/sql_partition.h b/sql/sql_partition.h
index 93e3bbba641..c273f622d0a 100644
--- a/sql/sql_partition.h
+++ b/sql/sql_partition.h
@@ -257,7 +257,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
Alter_info *alter_info,
HA_CREATE_INFO *create_info,
TABLE_LIST *table_list,
- char *db,
+ const char *db,
const char *table_name);
bool set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
enum partition_state part_state);
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index 18f25ab7cf7..c727d749300 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -371,16 +371,14 @@ static bool exchange_name_with_ddl_log(THD *thd,
/* call rename table from table to tmp-name */
DBUG_EXECUTE_IF("exchange_partition_fail_3",
my_error(ER_ERROR_ON_RENAME, MYF(0),
- name, tmp_name, 0, "n/a");
+ name, tmp_name, 0);
error_set= TRUE;
goto err_rename;);
DBUG_EXECUTE_IF("exchange_partition_abort_3", DBUG_SUICIDE(););
if (file->ha_rename_table(name, tmp_name))
{
- char errbuf[MYSYS_STRERROR_SIZE];
- my_strerror(errbuf, sizeof(errbuf), my_errno);
my_error(ER_ERROR_ON_RENAME, MYF(0), name, tmp_name,
- my_errno, errbuf);
+ my_errno);
error_set= TRUE;
goto err_rename;
}
@@ -392,16 +390,13 @@ static bool exchange_name_with_ddl_log(THD *thd,
/* call rename table from partition to table */
DBUG_EXECUTE_IF("exchange_partition_fail_5",
my_error(ER_ERROR_ON_RENAME, MYF(0),
- from_name, name, 0, "n/a");
+ from_name, name, 0);
error_set= TRUE;
goto err_rename;);
DBUG_EXECUTE_IF("exchange_partition_abort_5", DBUG_SUICIDE(););
if (file->ha_rename_table(from_name, name))
{
- char errbuf[MYSYS_STRERROR_SIZE];
- my_strerror(errbuf, sizeof(errbuf), my_errno);
- my_error(ER_ERROR_ON_RENAME, MYF(0), from_name, name,
- my_errno, errbuf);
+ my_error(ER_ERROR_ON_RENAME, MYF(0), from_name, name, my_errno);
error_set= TRUE;
goto err_rename;
}
@@ -413,16 +408,13 @@ static bool exchange_name_with_ddl_log(THD *thd,
/* call rename table from tmp-nam to partition */
DBUG_EXECUTE_IF("exchange_partition_fail_7",
my_error(ER_ERROR_ON_RENAME, MYF(0),
- tmp_name, from_name, 0, "n/a");
+ tmp_name, from_name, 0);
error_set= TRUE;
goto err_rename;);
DBUG_EXECUTE_IF("exchange_partition_abort_7", DBUG_SUICIDE(););
if (file->ha_rename_table(tmp_name, from_name))
{
- char errbuf[MYSYS_STRERROR_SIZE];
- my_strerror(errbuf, sizeof(errbuf), my_errno);
- my_error(ER_ERROR_ON_RENAME, MYF(0), tmp_name, from_name,
- my_errno, errbuf);
+ my_error(ER_ERROR_ON_RENAME, MYF(0), tmp_name, from_name, my_errno);
error_set= TRUE;
goto err_rename;
}
@@ -491,7 +483,7 @@ bool Sql_cmd_alter_table_exchange_partition::
TABLE_LIST *swap_table_list;
handlerton *table_hton;
partition_element *part_elem;
- char *partition_name;
+ const char *partition_name;
char temp_name[FN_REFLEN+1];
char part_file_name[FN_REFLEN+1];
char swap_file_name[FN_REFLEN+1];
@@ -579,7 +571,7 @@ bool Sql_cmd_alter_table_exchange_partition::
swap_table_list->table_name,
"", 0);
/* create a unique temp name #sqlx-nnnn_nnnn, x for eXchange */
- my_snprintf(temp_name, sizeof(temp_name), "%sx-%lx_%lx",
+ my_snprintf(temp_name, sizeof(temp_name), "%sx-%lx_%llx",
tmp_file_prefix, current_pid, thd->thread_id);
if (lower_case_table_names)
my_casedn_str(files_charset_info, temp_name);
@@ -808,11 +800,11 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd)
Prune all, but named partitions,
to avoid excessive calls to external_lock().
*/
- List_iterator<char> partition_names_it(alter_info->partition_names);
+ List_iterator<const char> partition_names_it(alter_info->partition_names);
uint num_names= alter_info->partition_names.elements;
for (i= 0; i < num_names; i++)
{
- char *partition_name= partition_names_it++;
+ const char *partition_name= partition_names_it++;
String *str_partition_name= new (thd->mem_root)
String(partition_name, system_charset_info);
if (!str_partition_name)
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index fe779cf01b4..61b33c54eb4 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -296,10 +296,10 @@ public:
sys_var_pluginvar *cast_pluginvar() { return this; }
uchar* real_value_ptr(THD *thd, enum_var_type type);
TYPELIB* plugin_var_typelib(void);
- uchar* do_value_ptr(THD *thd, enum_var_type type, const LEX_STRING *base);
- uchar* session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar* do_value_ptr(THD *thd, enum_var_type type, const LEX_CSTRING *base);
+ uchar* session_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return do_value_ptr(thd, OPT_SESSION, base); }
- uchar* global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar* global_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return do_value_ptr(thd, OPT_GLOBAL, base); }
uchar *default_value_ptr(THD *thd)
{ return do_value_ptr(thd, OPT_DEFAULT, 0); }
@@ -364,7 +364,7 @@ bool check_valid_path(const char *path, size_t len)
return prefix < len;
}
-static void fix_dl_name(MEM_ROOT *root, LEX_STRING *dl)
+static void fix_dl_name(MEM_ROOT *root, LEX_CSTRING *dl)
{
const size_t so_ext_len= sizeof(SO_EXT) - 1;
if (my_strcasecmp(&my_charset_latin1, dl->str + dl->length - so_ext_len,
@@ -444,7 +444,7 @@ static int item_val_real(struct st_mysql_value *value, double *buf)
#ifdef HAVE_DLOPEN
-static struct st_plugin_dl *plugin_dl_find(const LEX_STRING *dl)
+static struct st_plugin_dl *plugin_dl_find(const LEX_CSTRING *dl)
{
uint i;
struct st_plugin_dl *tmp;
@@ -500,7 +500,7 @@ static void free_plugin_mem(struct st_plugin_dl *p)
if (p->handle)
dlclose(p->handle);
#endif
- my_free(p->dl.str);
+ my_free(const_cast<char*>(p->dl.str));
if (p->allocated)
my_free(p->plugins);
}
@@ -720,7 +720,7 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl,
}
#endif /* HAVE_DLOPEN */
-static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
+static st_plugin_dl *plugin_dl_add(const LEX_CSTRING *dl, int report)
{
#ifdef HAVE_DLOPEN
char dlpath[FN_REFLEN];
@@ -739,7 +739,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
plugin directory are used (to make this even remotely secure).
*/
if (check_valid_path(dl->str, dl->length) ||
- check_string_char_length((LEX_STRING *) dl, 0, NAME_CHAR_LEN,
+ check_string_char_length((LEX_CSTRING *) dl, 0, NAME_CHAR_LEN,
system_charset_info, 1) ||
plugin_dir_len + dl->length + 1 >= FN_REFLEN)
{
@@ -832,10 +832,12 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
static_cast<int>(plugin_dl.dl.length));
goto ret;
}
- plugin_dl.dl.length= copy_and_convert(plugin_dl.dl.str, plugin_dl.dl.length,
- files_charset_info, dl->str, dl->length, system_charset_info,
- &dummy_errors);
- plugin_dl.dl.str[plugin_dl.dl.length]= 0;
+ plugin_dl.dl.length= copy_and_convert((char*) plugin_dl.dl.str,
+ plugin_dl.dl.length,
+ files_charset_info, dl->str,
+ dl->length, system_charset_info,
+ &dummy_errors);
+ ((char*) plugin_dl.dl.str)[plugin_dl.dl.length]= 0;
/* Add this dll to array */
if (! (tmp= plugin_dl_insert_or_reuse(&plugin_dl)))
{
@@ -878,7 +880,8 @@ static void plugin_dl_del(struct st_plugin_dl *plugin_dl)
}
-static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int type)
+static struct st_plugin_int *plugin_find_internal(const LEX_CSTRING *name,
+ int type)
{
uint i;
DBUG_ENTER("plugin_find_internal");
@@ -905,7 +908,7 @@ static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int ty
}
-static SHOW_COMP_OPTION plugin_status(const LEX_STRING *name, int type)
+static SHOW_COMP_OPTION plugin_status(const LEX_CSTRING *name, int type)
{
SHOW_COMP_OPTION rc= SHOW_OPTION_NO;
struct st_plugin_int *plugin;
@@ -922,7 +925,7 @@ static SHOW_COMP_OPTION plugin_status(const LEX_STRING *name, int type)
}
-bool plugin_is_ready(const LEX_STRING *name, int type)
+bool plugin_is_ready(const LEX_CSTRING *name, int type)
{
bool rc= FALSE;
if (plugin_status(name, type) == SHOW_OPTION_YES)
@@ -933,7 +936,7 @@ bool plugin_is_ready(const LEX_STRING *name, int type)
SHOW_COMP_OPTION plugin_status(const char *name, size_t len, int type)
{
- LEX_STRING plugin_name= { (char *) name, len };
+ LEX_CSTRING plugin_name= { name, len };
return plugin_status(&plugin_name, type);
}
@@ -1017,7 +1020,7 @@ plugin_ref plugin_lock(THD *thd, plugin_ref ptr)
}
-plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name, int type)
+plugin_ref plugin_lock_by_name(THD *thd, const LEX_CSTRING *name, int type)
{
LEX *lex= thd ? thd->lex : 0;
plugin_ref rc= NULL;
@@ -1060,7 +1063,7 @@ static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)
Requires that a write-lock is held on LOCK_system_variables_hash
*/
static bool plugin_add(MEM_ROOT *tmp_root,
- const LEX_STRING *name, LEX_STRING *dl, int report)
+ const LEX_CSTRING *name, LEX_CSTRING *dl, int report)
{
struct st_plugin_int tmp, *maybe_dupe;
struct st_maria_plugin *plugin;
@@ -1527,7 +1530,7 @@ int plugin_init(int *argc, char **argv, int flags)
MEM_ROOT tmp_root;
bool reaped_mandatory_plugin= false;
bool mandatory= true;
- LEX_STRING MyISAM= { C_STRING_WITH_LEN("MyISAM") };
+ LEX_CSTRING MyISAM= { STRING_WITH_LEN("MyISAM") };
DBUG_ENTER("plugin_init");
if (initialized)
@@ -1650,7 +1653,7 @@ int plugin_init(int *argc, char **argv, int flags)
char path[FN_REFLEN + 1];
build_table_filename(path, sizeof(path) - 1, "mysql", "plugin", reg_ext, 0);
char engine_name_buf[NAME_CHAR_LEN + 1];
- LEX_STRING maybe_myisam= { engine_name_buf, 0 };
+ LEX_CSTRING maybe_myisam= { engine_name_buf, 0 };
bool is_sequence;
Table_type frm_type= dd_frm_type(NULL, path, &maybe_myisam, &is_sequence);
/* if mysql.plugin table is MyISAM - load it right away */
@@ -1809,8 +1812,8 @@ static void plugin_load(MEM_ROOT *tmp_root)
get_field(tmp_root, table->field[0], &str_name);
get_field(tmp_root, table->field[1], &str_dl);
- LEX_STRING name= {(char *)str_name.ptr(), str_name.length()};
- LEX_STRING dl= {(char *)str_dl.ptr(), str_dl.length()};
+ LEX_CSTRING name= {str_name.ptr(), str_name.length()};
+ LEX_CSTRING dl= {str_dl.ptr(), str_dl.length()};
/*
there're no other threads running yet, so we don't need a mutex.
@@ -1873,14 +1876,16 @@ static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list)
mysql_mutex_lock(&LOCK_plugin);
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
name.str= 0; // load everything
- if (plugin_add(tmp_root, &name, &dl, REPORT_TO_LOG))
+ if (plugin_add(tmp_root, (LEX_CSTRING*) &name, (LEX_CSTRING*) &dl,
+ REPORT_TO_LOG))
goto error;
}
else
{
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
mysql_mutex_lock(&LOCK_plugin);
- if (plugin_add(tmp_root, &name, &dl, REPORT_TO_LOG))
+ if (plugin_add(tmp_root, (LEX_CSTRING*) &name, (LEX_CSTRING*) &dl,
+ REPORT_TO_LOG))
goto error;
}
mysql_mutex_unlock(&LOCK_plugin);
@@ -2048,7 +2053,7 @@ void plugin_shutdown(void)
That is, initialize it, and update mysql.plugin table
*/
-static bool finalize_install(THD *thd, TABLE *table, const LEX_STRING *name,
+static bool finalize_install(THD *thd, TABLE *table, const LEX_CSTRING *name,
int *argc, char **argv)
{
struct st_plugin_int *tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN);
@@ -2102,12 +2107,12 @@ static bool finalize_install(THD *thd, TABLE *table, const LEX_STRING *name,
return 0;
}
-bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
- const LEX_STRING *dl_arg)
+bool mysql_install_plugin(THD *thd, const LEX_CSTRING *name,
+ const LEX_CSTRING *dl_arg)
{
TABLE_LIST tables;
TABLE *table;
- LEX_STRING dl= *dl_arg;
+ LEX_CSTRING dl= *dl_arg;
bool error;
int argc=orig_argc;
char **argv=orig_argv;
@@ -2167,7 +2172,7 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
struct st_maria_plugin *plugin;
for (plugin= plugin_dl->plugins; plugin->info; plugin++)
{
- LEX_STRING str= { const_cast<char*>(plugin->name), strlen(plugin->name) };
+ LEX_CSTRING str= { plugin->name, strlen(plugin->name) };
error|= finalize_install(thd, table, &str, &argc, argv);
}
}
@@ -2185,7 +2190,7 @@ err:
}
-static bool do_uninstall(THD *thd, TABLE *table, const LEX_STRING *name)
+static bool do_uninstall(THD *thd, TABLE *table, const LEX_CSTRING *name)
{
struct st_plugin_int *plugin;
mysql_mutex_assert_owner(&LOCK_plugin);
@@ -2241,12 +2246,12 @@ static bool do_uninstall(THD *thd, TABLE *table, const LEX_STRING *name)
}
-bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
- const LEX_STRING *dl_arg)
+bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name,
+ const LEX_CSTRING *dl_arg)
{
TABLE *table;
TABLE_LIST tables;
- LEX_STRING dl= *dl_arg;
+ LEX_CSTRING dl= *dl_arg;
bool error= false;
DBUG_ENTER("mysql_uninstall_plugin");
@@ -2298,7 +2303,7 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
for (struct st_maria_plugin *plugin= plugin_dl->plugins;
plugin->info; plugin++)
{
- LEX_STRING str= { const_cast<char*>(plugin->name), strlen(plugin->name) };
+ LEX_CSTRING str= { plugin->name, strlen(plugin->name) };
error|= do_uninstall(thd, table, &str);
}
}
@@ -2414,7 +2419,7 @@ static bool plugin_dl_foreach_internal(THD *thd, st_plugin_dl *plugin_dl,
return 0;
}
-bool plugin_dl_foreach(THD *thd, const LEX_STRING *dl,
+bool plugin_dl_foreach(THD *thd, const LEX_CSTRING *dl,
plugin_foreach_func *func, void *arg)
{
bool err= 0;
@@ -3383,7 +3388,7 @@ TYPELIB* sys_var_pluginvar::plugin_var_typelib(void)
uchar* sys_var_pluginvar::do_value_ptr(THD *thd, enum_var_type type,
- const LEX_STRING *base)
+ const LEX_CSTRING *base)
{
uchar* result;
diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h
index 7b89246a9f9..469ae5c88a3 100644
--- a/sql/sql_plugin.h
+++ b/sql/sql_plugin.h
@@ -90,7 +90,7 @@ struct st_ptr_backup {
struct st_plugin_dl
{
- LEX_STRING dl;
+ LEX_CSTRING dl;
void *handle;
struct st_maria_plugin *plugins;
st_ptr_backup *ptr_backup;
@@ -105,7 +105,7 @@ struct st_plugin_dl
struct st_plugin_int
{
- LEX_STRING name;
+ LEX_CSTRING name;
struct st_maria_plugin *plugin;
struct st_plugin_dl *plugin_dl;
st_ptr_backup *ptr_backup;
@@ -163,18 +163,18 @@ extern const char *plugin_maturity_names[];
extern int plugin_init(int *argc, char **argv, int init_flags);
extern void plugin_shutdown(void);
void add_plugin_options(DYNAMIC_ARRAY *options, MEM_ROOT *mem_root);
-extern bool plugin_is_ready(const LEX_STRING *name, int type);
+extern bool plugin_is_ready(const LEX_CSTRING *name, int type);
#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C)
#define my_plugin_lock(A,B) plugin_lock(A,B)
extern plugin_ref plugin_lock(THD *thd, plugin_ref ptr);
-extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name,
+extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_CSTRING *name,
int type);
extern void plugin_unlock(THD *thd, plugin_ref plugin);
extern void plugin_unlock_list(THD *thd, plugin_ref *list, uint count);
-extern bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
- const LEX_STRING *dl);
-extern bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
- const LEX_STRING *dl);
+extern bool mysql_install_plugin(THD *thd, const LEX_CSTRING *name,
+ const LEX_CSTRING *dl);
+extern bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name,
+ const LEX_CSTRING *dl);
extern bool plugin_register_builtin(struct st_mysql_plugin *plugin);
extern void plugin_thdvar_init(THD *thd);
extern void plugin_thdvar_cleanup(THD *thd);
@@ -192,7 +192,7 @@ extern bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
int type, uint state_mask, void *arg);
extern void sync_dynamic_session_variables(THD* thd, bool global_lock);
-extern bool plugin_dl_foreach(THD *thd, const LEX_STRING *dl,
+extern bool plugin_dl_foreach(THD *thd, const LEX_CSTRING *dl,
plugin_foreach_func *func, void *arg);
sys_var *find_sys_var_ex(THD *thd, const char *str, size_t length,
diff --git a/sql/sql_plugin_compat.h b/sql/sql_plugin_compat.h
index 5c7bb620575..e0b184c9b2f 100644
--- a/sql/sql_plugin_compat.h
+++ b/sql/sql_plugin_compat.h
@@ -25,7 +25,7 @@
#define MIN_AUTHENTICATION_INTERFACE_VERSION 0x0100
struct MYSQL_SERVER_AUTH_INFO_0x0100 {
- char *user_name;
+ const char *user_name;
unsigned int user_name_length;
const char *auth_string;
unsigned long auth_string_length;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 5f17cdec049..2a523fd61b7 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -202,7 +202,7 @@ public:
void setup_set_params();
virtual Query_arena::Type type() const;
virtual void cleanup_stmt();
- bool set_name(LEX_STRING *name);
+ bool set_name(LEX_CSTRING *name);
inline void close_cursor() { delete cursor; cursor= 0; }
inline bool is_in_use() { return flags & (uint) IS_IN_USE; }
inline bool is_sql_prepare() const { return flags & (uint) IS_SQL_PREPARE; }
@@ -1940,8 +1940,7 @@ static int mysql_test_show_grants(Prepared_statement *stmt)
THD *thd= stmt->thd;
List<Item> fields;
- mysql_show_grants_get_fields(thd, &fields, "Grants for");
-
+ mysql_show_grants_get_fields(thd, &fields, STRING_WITH_LEN("Grants for"));
DBUG_RETURN(send_stmt_metadata(thd, stmt, &fields));
}
#endif /*NO_EMBEDDED_ACCESS_CHECKS*/
@@ -2264,7 +2263,7 @@ static int mysql_test_handler_read(Prepared_statement *stmt,
{
if (!lex->result && !(lex->result= new (stmt->mem_root) select_send(thd)))
{
- my_error(ER_OUTOFMEMORY, MYF(0), sizeof(select_send));
+ my_error(ER_OUTOFMEMORY, MYF(0), (int) sizeof(select_send));
DBUG_RETURN(1);
}
if (send_prep_stmt(stmt, ha_table->fields.elements) ||
@@ -2762,7 +2761,7 @@ bool LEX::get_dynamic_sql_string(LEX_CSTRING *dst, String *buffer)
void mysql_sql_stmt_prepare(THD *thd)
{
LEX *lex= thd->lex;
- LEX_STRING *name= &lex->prepared_stmt_name;
+ LEX_CSTRING *name= &lex->prepared_stmt_name;
Prepared_statement *stmt;
LEX_CSTRING query;
DBUG_ENTER("mysql_sql_stmt_prepare");
@@ -3117,7 +3116,7 @@ void mysql_sql_stmt_execute(THD *thd)
{
LEX *lex= thd->lex;
Prepared_statement *stmt;
- LEX_STRING *name= &lex->prepared_stmt_name;
+ LEX_CSTRING *name= &lex->prepared_stmt_name;
/* Query text for binary, general or slow log, if any of them is open */
String expanded_query;
DBUG_ENTER("mysql_sql_stmt_execute");
@@ -3338,7 +3337,7 @@ void mysqld_stmt_close(THD *thd, char *packet)
void mysql_sql_stmt_close(THD *thd)
{
Prepared_statement* stmt;
- LEX_STRING *name= &thd->lex->prepared_stmt_name;
+ LEX_CSTRING *name= &thd->lex->prepared_stmt_name;
DBUG_PRINT("info", ("DEALLOCATE PREPARE: %.*s\n", (int) name->length,
name->str));
@@ -3700,7 +3699,7 @@ void Prepared_statement::cleanup_stmt()
}
-bool Prepared_statement::set_name(LEX_STRING *name_arg)
+bool Prepared_statement::set_name(LEX_CSTRING *name_arg)
{
name.length= name_arg->length;
name.str= (char*) memdup_root(mem_root, name_arg->str, name_arg->length);
@@ -4353,7 +4352,7 @@ Prepared_statement::reprepare()
char saved_cur_db_name_buf[SAFE_NAME_LEN+1];
LEX_STRING saved_cur_db_name=
{ saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) };
- LEX_STRING stmt_db_name= { db, db_length };
+ LEX_CSTRING stmt_db_name= { db, db_length };
bool cur_db_changed;
bool error;
@@ -4376,7 +4375,7 @@ Prepared_statement::reprepare()
thd->variables.sql_mode= save_sql_mode;
if (cur_db_changed)
- mysql_change_db(thd, &saved_cur_db_name, TRUE);
+ mysql_change_db(thd, (LEX_CSTRING*) &saved_cur_db_name, TRUE);
if (! error)
{
@@ -4474,7 +4473,7 @@ Prepared_statement::swap_prepared_statement(Prepared_statement *copy)
/* Don't swap flags: the copy has IS_SQL_PREPARE always set. */
/* swap_variables(uint, flags, copy->flags); */
/* Swap names, the old name is allocated in the wrong memory root */
- swap_variables(LEX_STRING, name, copy->name);
+ swap_variables(LEX_CSTRING, name, copy->name);
/* Ditto */
swap_variables(char *, db, copy->db);
swap_variables(size_t, db_length, copy->db_length);
@@ -4519,7 +4518,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
{ saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) };
bool cur_db_changed;
- LEX_STRING stmt_db_name= { db, db_length };
+ LEX_CSTRING stmt_db_name= { db, db_length };
status_var_increment(thd->status_var.com_stmt_execute);
@@ -4647,7 +4646,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
*/
if (cur_db_changed)
- mysql_change_db(thd, &saved_cur_db_name, TRUE);
+ mysql_change_db(thd, (LEX_CSTRING*) &saved_cur_db_name, TRUE);
/* Assert that if an error, no cursor is open */
DBUG_ASSERT(! (error && cursor));
@@ -4722,8 +4721,8 @@ bool Prepared_statement::execute_immediate(const char *query, uint query_len)
{
DBUG_ENTER("Prepared_statement::execute_immediate");
String expanded_query;
- static LEX_STRING execute_immediate_stmt_name=
- {(char*) STRING_WITH_LEN("(immediate)") };
+ static LEX_CSTRING execute_immediate_stmt_name=
+ {STRING_WITH_LEN("(immediate)") };
set_sql_prepare();
name= execute_immediate_stmt_name; // for DBUG_PRINT etc
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index f3b62991c5c..7206162792a 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -120,8 +120,10 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table)
continue;
field_info= &schema_table->fields_info[i];
+ LEX_CSTRING field_name= {field_info->field_name,
+ strlen(field_info->field_name) };
Item_field *field= new (thd->mem_root) Item_field(thd, context,
- NullS, NullS, field_info->field_name);
+ NullS, NullS, &field_name);
if (field)
{
field->set_name(thd, field_info->old_name,
diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc
index 463989b3805..400c230ea43 100644
--- a/sql/sql_reload.cc
+++ b/sql/sql_reload.cc
@@ -166,7 +166,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options,
if (options & REFRESH_RELAY_LOG)
{
#ifdef HAVE_REPLICATION
- LEX_STRING connection_name;
+ LEX_CSTRING connection_name;
Master_info *mi;
if (thd)
connection_name= thd->lex->relay_log_connection_name;
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 1588644f0e1..2cba634e17c 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -33,8 +33,8 @@
static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list,
bool skip_error);
-static bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db,
- char *new_table_name, char *new_table_alias,
+static bool do_rename(THD *thd, TABLE_LIST *ren_table, const char *new_db,
+ const char *new_table_name, const char *new_table_alias,
bool skip_error);
static TABLE_LIST *reverse_table_list(TABLE_LIST *table_list);
@@ -50,7 +50,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
bool binlog_error= 0;
TABLE_LIST *ren_table= 0;
int to_table;
- char *rename_log_table[2]= {NULL, NULL};
+ const char *rename_log_table[2]= {NULL, NULL};
DBUG_ENTER("mysql_rename_tables");
/*
@@ -254,8 +254,9 @@ do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table,
*/
static bool
-do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
- char *new_table_alias, bool skip_error)
+do_rename(THD *thd, TABLE_LIST *ren_table, const char *new_db,
+ const char *new_table_name, const char *new_table_alias,
+ bool skip_error)
{
int rc= 1;
handlerton *hton;
@@ -291,11 +292,11 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
if (!(rc= mysql_rename_table(hton, ren_table->db, old_alias,
new_db, new_alias, 0)))
{
- LEX_STRING db_name= { ren_table->db, ren_table->db_length };
- LEX_STRING table_name= { ren_table->table_name,
+ LEX_CSTRING db_name= { ren_table->db, ren_table->db_length };
+ LEX_CSTRING table_name= { ren_table->table_name,
ren_table->table_name_length };
- LEX_STRING new_table= { (char *) new_alias, strlen(new_alias) };
- LEX_STRING new_db_name= { (char*)new_db, strlen(new_db)};
+ LEX_CSTRING new_table= { new_alias, strlen(new_alias) };
+ LEX_CSTRING new_db_name= { new_db, strlen(new_db)};
(void) rename_table_in_stat_tables(thd, &db_name, &table_name,
&new_db_name, &new_table);
if ((rc= Table_triggers_list::change_table_name(thd, ren_table->db,
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 7c30aa38f1a..98009827cb4 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -865,7 +865,6 @@ get_binlog_list(MEM_ROOT *memroot)
!(e->name= strmake_root(memroot, fname, length)))
{
mysql_bin_log.unlock_index();
- my_error(ER_OUTOFMEMORY, MYF(0), length + 1 + sizeof(*e));
DBUG_RETURN(NULL);
}
e->next= current_list;
@@ -3045,7 +3044,7 @@ int start_slave(THD* thd , Master_info* mi, bool net_report)
{
/* connection was deleted while we waited for lock_slave_threads */
mi->unlock_slave_threads();
- my_error(WARN_NO_MASTER_INFO, mi->connection_name.length,
+ my_error(WARN_NO_MASTER_INFO, MYF(0), (int) mi->connection_name.length,
mi->connection_name.str);
DBUG_RETURN(-1);
}
@@ -3303,7 +3302,7 @@ int reset_slave(THD *thd, Master_info* mi)
{
/* connection was deleted while we waited for lock_slave_threads */
mi->unlock_slave_threads();
- my_error(WARN_NO_MASTER_INFO, mi->connection_name.length,
+ my_error(WARN_NO_MASTER_INFO, MYF(0), (int) mi->connection_name.length,
mi->connection_name.str);
DBUG_RETURN(-1);
}
@@ -3445,7 +3444,7 @@ static bool get_string_parameter(char *to, const char *from, size_t length,
uint from_numchars= cs->cset->numchars(cs, from, from + from_length);
if (from_numchars > length / cs->mbmaxlen)
{
- my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name, length / cs->mbmaxlen);
+ my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name, (int) (length / cs->mbmaxlen));
return 1;
}
memcpy(to, from, from_length+1);
@@ -3514,7 +3513,7 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added)
{
/* connection was deleted while we waited for lock_slave_threads */
mi->unlock_slave_threads();
- my_error(WARN_NO_MASTER_INFO, mi->connection_name.length,
+ my_error(WARN_NO_MASTER_INFO, MYF(0), (int) mi->connection_name.length,
mi->connection_name.str);
DBUG_RETURN(TRUE);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 47c03023faa..f82c7580469 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -321,8 +321,8 @@ void dbug_serve_apcs(THD *thd, int n_calls)
bool dbug_user_var_equals_int(THD *thd, const char *name, int value)
{
user_var_entry *var;
- LEX_STRING varname= {(char*)name, strlen(name)};
- if ((var= get_variable(&thd->user_vars, varname, FALSE)))
+ LEX_CSTRING varname= { name, strlen(name)};
+ if ((var= get_variable(&thd->user_vars, &varname, FALSE)))
{
bool null_value;
longlong var_value= var->val_int(&null_value);
@@ -514,9 +514,9 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
new_ref= direct_ref ?
new (thd->mem_root) Item_direct_ref(thd, ref->context, item_ref, ref->table_name,
- ref->field_name, ref->alias_name_used) :
+ &ref->field_name, ref->alias_name_used) :
new (thd->mem_root) Item_ref(thd, ref->context, item_ref, ref->table_name,
- ref->field_name, ref->alias_name_used);
+ &ref->field_name, ref->alias_name_used);
if (!new_ref)
return TRUE;
ref->outer_ref= new_ref;
@@ -15819,7 +15819,7 @@ const_expression_in_where(COND *cond, Item *comp_item, Field *comp_field,
*/
Field *create_tmp_field_from_field(THD *thd, Field *org_field,
- const char *name, TABLE *table,
+ LEX_CSTRING *name, TABLE *table,
Item_field *item)
{
Field *new_field;
@@ -15833,7 +15833,7 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field,
if (item)
item->result_field= new_field;
else
- new_field->field_name= name;
+ new_field->field_name= *name;
new_field->flags|= (org_field->flags & NO_DEFAULT_VALUE_FLAG);
if (org_field->maybe_null() || (item && item->maybe_null))
new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join
@@ -15859,21 +15859,25 @@ Field *Item::create_tmp_field(bool group, TABLE *table, uint convert_int_length)
switch (cmp_type()) {
case REAL_RESULT:
+ {
new_field= new (mem_root)
- Field_double(max_length, maybe_null, name, decimals, TRUE);
+ Field_double(max_length, maybe_null, &name, decimals, TRUE);
break;
+ }
case INT_RESULT:
+ {
/*
Select an integer type with the minimal fit precision.
convert_int_length is sign inclusive, don't consider the sign.
*/
if (max_char_length() > convert_int_length)
new_field= new (mem_root)
- Field_longlong(max_char_length(), maybe_null, name, unsigned_flag);
+ Field_longlong(max_char_length(), maybe_null, &name, unsigned_flag);
else
new_field= new (mem_root)
- Field_long(max_char_length(), maybe_null, name, unsigned_flag);
+ Field_long(max_char_length(), maybe_null, &name, unsigned_flag);
break;
+ }
case TIME_RESULT:
new_field= tmp_table_field_from_field_type(table, true, false);
break;
@@ -15967,9 +15971,10 @@ Field *Item::create_field_for_schema(THD *thd, TABLE *table)
{
Field *field;
if (max_length > MAX_FIELD_VARCHARLENGTH)
- field= new Field_blob(max_length, maybe_null, name, collation.collation);
+ field= new Field_blob(max_length, maybe_null, &name,
+ collation.collation);
else
- field= new Field_varstring(max_length, maybe_null, name,
+ field= new Field_varstring(max_length, maybe_null, &name,
table->s, collation.collation);
if (field)
field->init(table);
@@ -16081,12 +16086,13 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
field->result_field= result;
}
else
+ {
+ LEX_CSTRING *tmp= orig_item ? &orig_item->name : &item->name;
result= create_tmp_field_from_field(thd, (*from_field= field->field),
- orig_item ? orig_item->name :
- item->name,
- table,
+ tmp, table,
modify_item ? field :
NULL);
+ }
if (orig_type == Item::REF_ITEM && orig_modify)
((Item_ref*)orig_item)->set_result_field(result);
/*
@@ -16114,11 +16120,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
{
*((*copy_func)++)= item;
}
-
Field *result_field=
create_tmp_field_from_field(thd,
sp_result_field,
- item_func_sp->name,
+ &item_func_sp->name,
table,
NULL);
@@ -16470,6 +16475,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
distinct, false);
if (!new_field)
goto err; // Should be OOM
+ DBUG_ASSERT(!new_field->field_name.str || strlen(new_field->field_name.str) == new_field->field_name.length);
tmp_from_field++;
reclength+=new_field->pack_length();
if (new_field->flags & BLOB_FLAG)
@@ -16545,6 +16551,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
goto err; // Got OOM
continue; // Some kind of const item
}
+ DBUG_ASSERT(!new_field->field_name.str || strlen(new_field->field_name.str) == new_field->field_name.length);
if (type == Item::SUM_FUNC_ITEM)
{
Item_sum *agg_item= (Item_sum *) item;
@@ -16988,7 +16995,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
(uchar*) 0,
(uint) 0,
Field::NONE,
- NullS, &my_charset_bin);
+ &null_clex_str, &my_charset_bin);
if (!key_part_info->field)
goto err;
key_part_info->field->init(table);
@@ -17121,7 +17128,7 @@ bool Virtual_tmp_table::add(List<Spvar_definition> &field_list)
if (!(tmp= cdef->make_field(s, in_use->mem_root, 0,
(uchar*) (f_maybe_null(cdef->pack_flag) ? "" : 0),
f_maybe_null(cdef->pack_flag) ? 1 : 0,
- cdef->field_name)))
+ &cdef->field_name)))
return true;
add(tmp);
}
@@ -22102,7 +22109,7 @@ find_order_in_list(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_NON_UNIQ_ERROR,
ER_THD(thd, ER_NON_UNIQ_ERROR),
- ((Item_ident*) order_item)->field_name,
+ ((Item_ident*) order_item)->field_name.str,
thd->where);
}
}
@@ -23139,14 +23146,15 @@ change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array,
ifield->db_name= iref->db_name;
}
#ifndef DBUG_OFF
- if (!item_field->name)
+ if (!item_field->name.str)
{
char buff[256];
String str(buff,sizeof(buff),&my_charset_bin);
str.length(0);
str.extra_allocation(1024);
item->print(&str, QT_ORDINARY);
- item_field->name= thd->strmake(str.ptr(),str.length());
+ item_field->name.str= thd->strmake(str.ptr(), str.length());
+ item_field->name.length= str.length();
}
#endif
}
@@ -23499,8 +23507,9 @@ static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list,
if (item->eq(*group_tmp->item,0))
{
Item *new_item;
- if (!(new_item= new (thd->mem_root) Item_ref(thd, context, group_tmp->item, 0,
- item->name)))
+ if (!(new_item= new (thd->mem_root) Item_ref(thd, context,
+ group_tmp->item, 0,
+ &item->name)))
return 1; // fatal_error is set
thd->change_item_tree(arg, new_item);
arg_changed= TRUE;
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 77cf73d785f..86b8a56fb43 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1714,7 +1714,7 @@ void copy_fields(TMP_TABLE_PARAM *param);
bool copy_funcs(Item **func_ptr, const THD *thd);
uint find_shortest_key(TABLE *table, const key_map *usable_keys);
Field* create_tmp_field_from_field(THD *thd, Field* org_field,
- const char *name, TABLE *table,
+ LEX_CSTRING *name, TABLE *table,
Item_field *item);
bool is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args);
diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc
index 9d3045df732..19ba20d78cd 100644
--- a/sql/sql_sequence.cc
+++ b/sql/sql_sequence.cc
@@ -28,7 +28,7 @@ struct Field_definition
const char *field_name;
uint length;
enum enum_field_types sql_type;
- LEX_STRING comment;
+ LEX_CSTRING comment;
ulong flags;
};
@@ -45,19 +45,19 @@ struct Field_definition
static Field_definition sequence_structure[]=
{
- {"next_value", 21, MYSQL_TYPE_LONGLONG, {C_STRING_WITH_LEN("next not cached value")},
+ {"next_value", 21, MYSQL_TYPE_LONGLONG, {STRING_WITH_LEN("next not cached value")},
FL},
- {"min_value", 21, MYSQL_TYPE_LONGLONG, {C_STRING_WITH_LEN("min value")}, FL},
- {"max_value", 21, MYSQL_TYPE_LONGLONG, {C_STRING_WITH_LEN("max value")}, FL},
- {"start", 21, MYSQL_TYPE_LONGLONG, {C_STRING_WITH_LEN("start value")}, FL},
+ {"min_value", 21, MYSQL_TYPE_LONGLONG, {STRING_WITH_LEN("min value")}, FL},
+ {"max_value", 21, MYSQL_TYPE_LONGLONG, {STRING_WITH_LEN("max value")}, FL},
+ {"start", 21, MYSQL_TYPE_LONGLONG, {STRING_WITH_LEN("start value")}, FL},
{"increment", 21, MYSQL_TYPE_LONGLONG,
{C_STRING_WITH_LEN("increment value")}, FL},
- {"cache", 21, MYSQL_TYPE_LONGLONG, {C_STRING_WITH_LEN("cache size")}, FL},
- {"cycle", 1, MYSQL_TYPE_TINY, {C_STRING_WITH_LEN("cycle state")},
+ {"cache", 21, MYSQL_TYPE_LONGLONG, {STRING_WITH_LEN("cache size")}, FL},
+ {"cycle", 1, MYSQL_TYPE_TINY, {STRING_WITH_LEN("cycle state")},
FL | UNSIGNED_FLAG },
{"round", 21, MYSQL_TYPE_LONGLONG,
- {C_STRING_WITH_LEN("How many cycles has been done")}, FL},
- {NULL, 0, MYSQL_TYPE_LONGLONG, {C_STRING_WITH_LEN("")}, 0}
+ {STRING_WITH_LEN("How many cycles has been done")}, FL},
+ {NULL, 0, MYSQL_TYPE_LONGLONG, {STRING_WITH_LEN("")}, 0}
};
#undef FL
@@ -194,11 +194,11 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields)
{
Field_definition *field_def= &sequence_structure[field_no];
if (my_strcasecmp(system_charset_info, field_def->field_name,
- field->field_name) ||
+ field->field_name.str) ||
field->flags != field_def->flags ||
field->sql_type != field_def->sql_type)
{
- reason= field->field_name;
+ reason= field->field_name.str;
goto err;
}
}
@@ -228,10 +228,13 @@ bool prepare_sequence_fields(THD *thd, List<Create_field> *fields)
for (field_info= sequence_structure; field_info->field_name ; field_info++)
{
Create_field *new_field;
+ LEX_CSTRING field_name= {field_info->field_name,
+ strlen(field_info->field_name)};
+
if (unlikely(!(new_field= new Create_field())))
DBUG_RETURN(TRUE); /* purify inspected */
- new_field->field_name= field_info->field_name;
+ new_field->field_name= field_name;
new_field->sql_type= field_info->sql_type;
new_field->length= field_info->length;
new_field->char_length= field_info->length;
diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc
index 836b0563e23..bbed5ac8991 100644
--- a/sql/sql_servers.cc
+++ b/sql/sql_servers.cc
@@ -64,7 +64,7 @@ static int insert_server_record_into_cache(FOREIGN_SERVER *server);
static FOREIGN_SERVER *
prepare_server_struct_for_insert(LEX_SERVER_OPTIONS *server_options);
/* drop functions */
-static int delete_server_record(TABLE *table, LEX_STRING *name);
+static int delete_server_record(TABLE *table, LEX_CSTRING *name);
static int delete_server_record_in_cache(LEX_SERVER_OPTIONS *server_options);
/* update functions */
@@ -939,7 +939,7 @@ end:
*/
static int
-delete_server_record(TABLE *table, LEX_STRING *name)
+delete_server_record(TABLE *table, LEX_CSTRING *name)
{
int error;
DBUG_ENTER("delete_server_record");
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 01f474a73fb..2f4993f0437 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -94,17 +94,17 @@ enum enum_i_s_events_fields
#define USERNAME_WITH_HOST_CHAR_LENGTH (USERNAME_CHAR_LENGTH + HOSTNAME_LENGTH + 2)
-static const LEX_STRING trg_action_time_type_names[]=
+static const LEX_CSTRING trg_action_time_type_names[]=
{
- { C_STRING_WITH_LEN("BEFORE") },
- { C_STRING_WITH_LEN("AFTER") }
+ { STRING_WITH_LEN("BEFORE") },
+ { STRING_WITH_LEN("AFTER") }
};
-static const LEX_STRING trg_event_type_names[]=
+static const LEX_CSTRING trg_event_type_names[]=
{
- { C_STRING_WITH_LEN("INSERT") },
- { C_STRING_WITH_LEN("UPDATE") },
- { C_STRING_WITH_LEN("DELETE") }
+ { STRING_WITH_LEN("INSERT") },
+ { STRING_WITH_LEN("UPDATE") },
+ { STRING_WITH_LEN("DELETE") }
};
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -134,7 +134,7 @@ static int show_create_view(THD *thd, TABLE_LIST *table, String *buff);
static int show_create_sequence(THD *thd, TABLE_LIST *table_list,
String *packet);
-static const LEX_STRING *view_algorithm(TABLE_LIST *table);
+static const LEX_CSTRING *view_algorithm(TABLE_LIST *table);
bool get_lookup_field_values(THD *, COND *, TABLE_LIST *, LOOKUP_FIELD_VALUES *);
@@ -148,13 +148,13 @@ static int make_version_string(char *buf, int buf_length, uint version)
}
-static const LEX_STRING maturity_name[]={
- { C_STRING_WITH_LEN("Unknown") },
- { C_STRING_WITH_LEN("Experimental") },
- { C_STRING_WITH_LEN("Alpha") },
- { C_STRING_WITH_LEN("Beta") },
- { C_STRING_WITH_LEN("Gamma") },
- { C_STRING_WITH_LEN("Stable") }};
+static const LEX_CSTRING maturity_name[]={
+ { STRING_WITH_LEN("Unknown") },
+ { STRING_WITH_LEN("Experimental") },
+ { STRING_WITH_LEN("Alpha") },
+ { STRING_WITH_LEN("Beta") },
+ { STRING_WITH_LEN("Gamma") },
+ { STRING_WITH_LEN("Stable") }};
static my_bool show_plugins(THD *thd, plugin_ref plugin,
@@ -314,7 +314,7 @@ int fill_all_plugins(THD *thd, TABLE_LIST *tables, COND *cond)
for (uint i=0; i < (uint) dirp->number_of_files; i++)
{
FILEINFO *file= dirp->dir_entry+i;
- LEX_STRING dl= { file->name, strlen(file->name) };
+ LEX_CSTRING dl= { file->name, strlen(file->name) };
const char *dlend= dl.str + dl.length;
const size_t so_ext_len= sizeof(SO_EXT) - 1;
@@ -387,8 +387,8 @@ exit:
static int get_geometry_column_record(THD *thd, TABLE_LIST *tables,
TABLE *table, bool res,
- LEX_STRING *db_name,
- LEX_STRING *table_name)
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
CHARSET_INFO *cs= system_charset_info;
TABLE *show_table;
@@ -442,7 +442,8 @@ static int get_geometry_column_record(THD *thd, TABLE_LIST *tables,
/*G_TABLE_NAME*/
table->field[6]->store(table_name->str, table_name->length, cs);
/*G_GEOMETRY_COLUMN*/
- table->field[7]->store(field->field_name, strlen(field->field_name), cs);
+ table->field[7]->store(field->field_name.str, field->field_name.length,
+ cs);
/*STORAGE_TYPE*/
table->field[8]->store(1LL, TRUE); /*Always 1 (binary implementation)*/
/*GEOMETRY_TYPE*/
@@ -667,7 +668,7 @@ static bool skip_ignored_dir_check= TRUE;
bool
ignore_db_dirs_init()
{
- return my_init_dynamic_array(&ignore_db_dirs_array, sizeof(LEX_STRING *),
+ return my_init_dynamic_array(&ignore_db_dirs_array, sizeof(LEX_CSTRING *),
0, 0, MYF(0));
}
@@ -687,7 +688,7 @@ static uchar *
db_dirs_hash_get_key(const uchar *data, size_t *len_ret,
my_bool __attribute__((unused)))
{
- LEX_STRING *e= (LEX_STRING *) data;
+ LEX_CSTRING *e= (LEX_CSTRING *) data;
*len_ret= e->length;
return (uchar *) e->str;
@@ -708,7 +709,7 @@ db_dirs_hash_get_key(const uchar *data, size_t *len_ret,
bool
push_ignored_db_dir(char *path)
{
- LEX_STRING *new_elt;
+ LEX_CSTRING *new_elt;
char *new_elt_buffer;
size_t path_len= strlen(path);
@@ -717,7 +718,7 @@ push_ignored_db_dir(char *path)
// No need to normalize, it's only a directory name, not a path.
if (!my_multi_malloc(0,
- &new_elt, sizeof(LEX_STRING),
+ &new_elt, sizeof(LEX_CSTRING),
&new_elt_buffer, path_len + 1,
NullS))
return true;
@@ -739,8 +740,8 @@ push_ignored_db_dir(char *path)
void
ignore_db_dirs_reset()
{
- LEX_STRING **elt;
- while (NULL!= (elt= (LEX_STRING **) pop_dynamic(&ignore_db_dirs_array)))
+ LEX_CSTRING **elt;
+ while (NULL!= (elt= (LEX_CSTRING **) pop_dynamic(&ignore_db_dirs_array)))
if (elt && *elt)
my_free(*elt);
}
@@ -790,8 +791,7 @@ ignore_db_dirs_process_additions()
ulong i;
size_t len;
char *ptr;
- LEX_STRING *dir;
-
+ LEX_CSTRING *dir;
skip_ignored_dir_check= TRUE;
@@ -943,8 +943,8 @@ enum find_files_result {
static find_files_result
-find_files(THD *thd, Dynamic_array<LEX_STRING*> *files, LEX_STRING *db,
- const char *path, const LEX_STRING *wild)
+find_files(THD *thd, Dynamic_array<LEX_CSTRING*> *files, LEX_CSTRING *db,
+ const char *path, const LEX_CSTRING *wild)
{
MY_DIR *dirp;
Discovered_table_list tl(thd, files, wild);
@@ -1328,8 +1328,8 @@ void mysqld_show_create_db_get_fields(THD *thd, List<Item> *field_list)
}
-bool mysqld_show_create_db(THD *thd, LEX_STRING *dbname,
- LEX_STRING *orig_dbname,
+bool mysqld_show_create_db(THD *thd, LEX_CSTRING *dbname,
+ LEX_CSTRING *orig_dbname,
const DDL_options_st &options)
{
char buff[2048];
@@ -1437,7 +1437,7 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
for (ptr=table->field ; (field= *ptr); ptr++)
{
if (!wild || !wild[0] ||
- !wild_case_compare(system_charset_info, field->field_name,wild))
+ !wild_case_compare(system_charset_info, field->field_name.str,wild))
{
if (table_list->view)
field_list.push_back(new (mem_root)
@@ -1814,7 +1814,7 @@ static void add_table_options(THD *thd, TABLE *table,
if (!create_info_arg ||
(create_info_arg->used_fields & HA_CREATE_USED_ENGINE))
{
- LEX_STRING *engine_name= table->file->engine_name();
+ LEX_CSTRING *engine_name= table->file->engine_name();
if (sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
packet->append(STRING_WITH_LEN(" TYPE="));
@@ -2041,7 +2041,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
*/
if (with_db_name == WITH_DB_NAME)
{
- const LEX_STRING *const db=
+ const LEX_CSTRING *const db=
table_list->schema_table ? &INFORMATION_SCHEMA_NAME : &table->s->db;
if (!thd->db || strcmp(db->str, thd->db))
{
@@ -2067,7 +2067,8 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(STRING_WITH_LEN(",\n"));
packet->append(STRING_WITH_LEN(" "));
- append_identifier(thd,packet,field->field_name, strlen(field->field_name));
+ append_identifier(thd,packet,field->field_name.str,
+ field->field_name.length);
packet->append(' ');
type.set(tmp, sizeof(tmp), system_charset_info);
@@ -2191,8 +2192,8 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(',');
if (key_part->field)
- append_identifier(thd,packet,key_part->field->field_name,
- strlen(key_part->field->field_name));
+ append_identifier(thd,packet, key_part->field->field_name.str,
+ key_part->field->field_name.length);
if (key_part->field &&
(key_part->length !=
table->field[key_part->fieldnr-1]->key_length() &&
@@ -2206,7 +2207,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
store_key_options(thd, packet, table, key_info);
if (key_info->parser)
{
- LEX_STRING *parser_name= plugin_name(key_info->parser);
+ LEX_CSTRING *parser_name= plugin_name(key_info->parser);
packet->append(STRING_WITH_LEN(" /*!50100 WITH PARSER "));
append_identifier(thd, packet, parser_name->str, parser_name->length);
packet->append(STRING_WITH_LEN(" */ "));
@@ -2354,11 +2355,11 @@ void view_store_options(THD *thd, TABLE_LIST *table, String *buff)
Returns ALGORITHM clause of a view
*/
-static const LEX_STRING *view_algorithm(TABLE_LIST *table)
+static const LEX_CSTRING *view_algorithm(TABLE_LIST *table)
{
- static const LEX_STRING undefined= { C_STRING_WITH_LEN("UNDEFINED") };
- static const LEX_STRING merge= { C_STRING_WITH_LEN("MERGE") };
- static const LEX_STRING temptable= { C_STRING_WITH_LEN("TEMPTABLE") };
+ static const LEX_CSTRING undefined= { STRING_WITH_LEN("UNDEFINED") };
+ static const LEX_CSTRING merge= { STRING_WITH_LEN("MERGE") };
+ static const LEX_CSTRING temptable= { STRING_WITH_LEN("TEMPTABLE") };
switch (table->algorithm) {
case VIEW_ALGORITHM_TMPTABLE:
return &temptable;
@@ -2382,8 +2383,8 @@ static const LEX_STRING *view_algorithm(TABLE_LIST *table)
definer_host [in] host name part of definer
*/
-void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user,
- const LEX_STRING *definer_host)
+void append_definer(THD *thd, String *buffer, const LEX_CSTRING *definer_user,
+ const LEX_CSTRING *definer_host)
{
buffer->append(STRING_WITH_LEN("DEFINER="));
append_identifier(thd, buffer, definer_user->str, definer_user->length);
@@ -2468,7 +2469,7 @@ static int show_create_sequence(THD *thd, TABLE_LIST *table_list,
{
TABLE *table= table_list->table;
SEQUENCE *seq= table->s->sequence;
- LEX_STRING alias;
+ LEX_CSTRING alias;
sql_mode_t sql_mode= thd->variables.sql_mode;
bool foreign_db_mode= sql_mode & (MODE_POSTGRESQL | MODE_ORACLE |
MODE_MSSQL | MODE_DB2 |
@@ -2816,8 +2817,9 @@ int select_result_text_buffer::append_row(List<Item> &items, bool send_names)
if (send_names)
{
- data_ptr= item->name;
- data_len= strlen(item->name);
+ DBUG_ASSERT(strlen(item->name.str) == item->name.length);
+ data_ptr= item->name.str;
+ data_len= item->name.length;
}
else
{
@@ -2973,7 +2975,7 @@ int fill_show_explain(THD *thd, TABLE_LIST *table, COND *cond)
}
else
{
- my_error(ER_NO_SUCH_THREAD, MYF(0), thread_id);
+ my_error(ER_NO_SUCH_THREAD, MYF(0), (ulong) thread_id);
DBUG_RETURN(1);
}
}
@@ -3339,7 +3341,7 @@ const char* get_one_variable(THD *thd,
{
sys_var *var= (sys_var *) value;
show_type= var->show_type();
- value= var->value_ptr(thd, value_type, &null_lex_str);
+ value= var->value_ptr(thd, value_type, &null_clex_str);
*charset= var->charset(thd);
}
@@ -3643,10 +3645,10 @@ bool schema_table_store_record(THD *thd, TABLE *table)
static int make_table_list(THD *thd, SELECT_LEX *sel,
- LEX_STRING *db_name, LEX_STRING *table_name)
+ LEX_CSTRING *db_name, LEX_CSTRING *table_name)
{
Table_ident *table_ident;
- table_ident= new Table_ident(thd, *db_name, *table_name, 1);
+ table_ident= new Table_ident(thd, db_name, table_name, 1);
if (!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ, MDL_SHARED_READ))
return 1;
return 0;
@@ -3717,8 +3719,8 @@ bool get_lookup_value(THD *thd, Item_func *item_func,
/* Lookup value is database name */
if (!cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
- (uchar *) item_field->field_name,
- strlen(item_field->field_name)))
+ (uchar *) item_field->field_name.str,
+ item_field->field_name.length))
{
thd->make_lex_string(&lookup_field_vals->db_value,
tmp_str->ptr(), tmp_str->length());
@@ -3726,8 +3728,8 @@ bool get_lookup_value(THD *thd, Item_func *item_func,
/* Lookup value is table name */
else if (!cs->coll->strnncollsp(cs, (uchar *) field_name2,
strlen(field_name2),
- (uchar *) item_field->field_name,
- strlen(item_field->field_name)))
+ (uchar *) item_field->field_name.str,
+ item_field->field_name.length))
{
thd->make_lex_string(&lookup_field_vals->table_value,
tmp_str->ptr(), tmp_str->length());
@@ -3812,11 +3814,11 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
field_info[schema_table->idx_field2].field_name : "";
if (table->table != item_field->field->table ||
(cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
- (uchar *) item_field->field_name,
- strlen(item_field->field_name)) &&
+ (uchar *) item_field->field_name.str,
+ item_field->field_name.length) &&
cs->coll->strnncollsp(cs, (uchar *) field_name2, strlen(field_name2),
- (uchar *) item_field->field_name,
- strlen(item_field->field_name))))
+ (uchar *) item_field->field_name.str,
+ item_field->field_name.length)))
return 0;
}
else if (item->type() == Item::REF_ITEM)
@@ -3958,10 +3960,12 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables,
are allocating a new memory buffer for these strings.
*/
if (lookup_field_values->db_value.str && lookup_field_values->db_value.str[0])
- my_casedn_str(system_charset_info, lookup_field_values->db_value.str);
+ my_casedn_str(system_charset_info,
+ (char*) lookup_field_values->db_value.str);
if (lookup_field_values->table_value.str &&
lookup_field_values->table_value.str[0])
- my_casedn_str(system_charset_info, lookup_field_values->table_value.str);
+ my_casedn_str(system_charset_info,
+ (char*) lookup_field_values->table_value.str);
}
return rc;
@@ -3990,8 +3994,8 @@ enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table)
non-zero error
*/
-int make_db_list(THD *thd, Dynamic_array<LEX_STRING*> *files,
- LOOKUP_FIELD_VALUES *lookup_field_vals)
+static int make_db_list(THD *thd, Dynamic_array<LEX_CSTRING*> *files,
+ LOOKUP_FIELD_VALUES *lookup_field_vals)
{
if (lookup_field_vals->wild_db_value)
{
@@ -4048,13 +4052,13 @@ int make_db_list(THD *thd, Dynamic_array<LEX_STRING*> *files,
*/
if (files->append_val(&INFORMATION_SCHEMA_NAME))
return 1;
- return find_files(thd, files, 0, mysql_data_home, &null_lex_str);
+ return find_files(thd, files, 0, mysql_data_home, &null_clex_str);
}
struct st_add_schema_table
{
- Dynamic_array<LEX_STRING*> *files;
+ Dynamic_array<LEX_CSTRING*> *files;
const char *wild;
};
@@ -4062,9 +4066,9 @@ struct st_add_schema_table
static my_bool add_schema_table(THD *thd, plugin_ref plugin,
void* p_data)
{
- LEX_STRING *file_name= 0;
+ LEX_CSTRING *file_name= 0;
st_add_schema_table *data= (st_add_schema_table *)p_data;
- Dynamic_array<LEX_STRING*> *file_list= data->files;
+ Dynamic_array<LEX_CSTRING*> *file_list= data->files;
const char *wild= data->wild;
ST_SCHEMA_TABLE *schema_table= plugin_data(plugin, ST_SCHEMA_TABLE *);
DBUG_ENTER("add_schema_table");
@@ -4084,18 +4088,18 @@ static my_bool add_schema_table(THD *thd, plugin_ref plugin,
DBUG_RETURN(0);
}
- if ((file_name= thd->make_lex_string(schema_table->table_name,
- strlen(schema_table->table_name))) &&
+ if ((file_name= thd->make_clex_string(schema_table->table_name,
+ strlen(schema_table->table_name))) &&
!file_list->append(file_name))
DBUG_RETURN(0);
DBUG_RETURN(1);
}
-int schema_tables_add(THD *thd, Dynamic_array<LEX_STRING*> *files,
+int schema_tables_add(THD *thd, Dynamic_array<LEX_CSTRING*> *files,
const char *wild)
{
- LEX_STRING *file_name= 0;
+ LEX_CSTRING *file_name;
ST_SCHEMA_TABLE *tmp_schema_table= schema_tables;
st_add_schema_table add_data;
DBUG_ENTER("schema_tables_add");
@@ -4117,8 +4121,8 @@ int schema_tables_add(THD *thd, Dynamic_array<LEX_STRING*> *files,
continue;
}
if ((file_name=
- thd->make_lex_string(tmp_schema_table->table_name,
- strlen(tmp_schema_table->table_name))) &&
+ thd->make_clex_string(tmp_schema_table->table_name,
+ strlen(tmp_schema_table->table_name))) &&
!files->append(file_name))
continue;
DBUG_RETURN(1);
@@ -4153,9 +4157,9 @@ int schema_tables_add(THD *thd, Dynamic_array<LEX_STRING*> *files,
*/
static int
-make_table_name_list(THD *thd, Dynamic_array<LEX_STRING*> *table_names,
+make_table_name_list(THD *thd, Dynamic_array<LEX_CSTRING*> *table_names,
LEX *lex, LOOKUP_FIELD_VALUES *lookup_field_vals,
- LEX_STRING *db_name)
+ LEX_CSTRING *db_name)
{
char path[FN_REFLEN + 1];
build_table_filename(path, sizeof(path) - 1, db_name->str, "", "", 0);
@@ -4172,13 +4176,13 @@ make_table_name_list(THD *thd, Dynamic_array<LEX_STRING*> *table_names,
}
if (db_name == &INFORMATION_SCHEMA_NAME)
{
- LEX_STRING *name;
+ LEX_CSTRING *name;
ST_SCHEMA_TABLE *schema_table=
find_schema_table(thd, lookup_field_vals->table_value.str);
if (schema_table && !schema_table->hidden)
{
- if (!(name= thd->make_lex_string(schema_table->table_name,
- strlen(schema_table->table_name))) ||
+ if (!(name= thd->make_clex_string(schema_table->table_name,
+ strlen(schema_table->table_name))) ||
table_names->append(name))
return 1;
}
@@ -4223,9 +4227,9 @@ make_table_name_list(THD *thd, Dynamic_array<LEX_STRING*> *table_names,
static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl,
- LEX_STRING *db, LEX_STRING *table)
+ LEX_CSTRING *db, LEX_CSTRING *table)
{
- LEX_STRING engine_name= { buf, 0 };
+ LEX_CSTRING engine_name= { buf, 0 };
if (thd->get_stmt_da()->sql_errno() == ER_UNKNOWN_STORAGE_ENGINE)
{
@@ -4263,8 +4267,8 @@ static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl,
static bool
fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
TABLE *table, ST_SCHEMA_TABLE *schema_table,
- LEX_STRING *orig_db_name,
- LEX_STRING *orig_table_name,
+ LEX_CSTRING *orig_db_name,
+ LEX_CSTRING *orig_table_name,
Open_tables_backup *open_tables_state_backup,
bool can_deadlock)
{
@@ -4272,7 +4276,7 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
Query_arena::STMT_CONVENTIONAL_EXECUTION),
backup_arena, *old_arena;
LEX *old_lex= thd->lex, temp_lex, *lex;
- LEX_STRING db_name, table_name;
+ LEX_CSTRING db_name, table_name;
TABLE_LIST *table_list;
bool result= true;
DBUG_ENTER("fill_schema_table_by_open");
@@ -4438,7 +4442,8 @@ end:
*/
static int fill_schema_table_names(THD *thd, TABLE_LIST *tables,
- LEX_STRING *db_name, LEX_STRING *table_name)
+ LEX_CSTRING *db_name,
+ LEX_CSTRING *table_name)
{
TABLE *table= tables->table;
if (db_name == &INFORMATION_SCHEMA_NAME)
@@ -4607,8 +4612,8 @@ try_acquire_high_prio_shared_mdl_lock(THD *thd, TABLE_LIST *table,
static int fill_schema_table_from_frm(THD *thd, TABLE *table,
ST_SCHEMA_TABLE *schema_table,
- LEX_STRING *db_name,
- LEX_STRING *table_name,
+ LEX_CSTRING *db_name,
+ LEX_CSTRING *table_name,
Open_tables_backup *open_tables_state_backup,
bool can_deadlock)
{
@@ -4833,7 +4838,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
ST_SCHEMA_TABLE *schema_table= tables->schema_table;
IS_table_read_plan *plan= tables->is_table_read_plan;
enum enum_schema_tables schema_table_idx;
- Dynamic_array<LEX_STRING*> db_names;
+ Dynamic_array<LEX_CSTRING*> db_names;
Item *partial_cond= plan->partial_cond;
int error= 1;
Open_tables_backup open_tables_state_backup;
@@ -4871,7 +4876,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
*/
if (lsel && lsel->table_list.first)
{
- LEX_STRING db_name, table_name;
+ LEX_CSTRING db_name, table_name;
db_name.str= lsel->table_list.first->db;
db_name.length= lsel->table_list.first->db_length;
@@ -4906,7 +4911,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
goto err;
for (size_t i=0; i < db_names.elements(); i++)
{
- LEX_STRING *db_name= db_names.at(i);
+ LEX_CSTRING *db_name= db_names.at(i);
DBUG_ASSERT(db_name->length <= NAME_LEN);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!(check_access(thd, SELECT_ACL, db_name->str,
@@ -4916,7 +4921,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
acl_get(sctx->host, sctx->ip, sctx->priv_user, db_name->str, 0))
#endif
{
- Dynamic_array<LEX_STRING*> table_names;
+ Dynamic_array<LEX_CSTRING*> table_names;
int res= make_table_name_list(thd, &table_names, lex,
&plan->lookup_field_vals, db_name);
if (res == 2) /* Not fatal error, continue */
@@ -4926,7 +4931,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
for (size_t i=0; i < table_names.elements(); i++)
{
- LEX_STRING *table_name= table_names.at(i);
+ LEX_CSTRING *table_name= table_names.at(i);
DBUG_ASSERT(table_name->length <= NAME_LEN);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -5009,7 +5014,7 @@ err:
}
-bool store_schema_shemata(THD* thd, TABLE *table, LEX_STRING *db_name,
+bool store_schema_shemata(THD* thd, TABLE *table, LEX_CSTRING *db_name,
CHARSET_INFO *cs)
{
restore_record(table, s->default_values);
@@ -5029,7 +5034,7 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
*/
LOOKUP_FIELD_VALUES lookup_field_vals;
- Dynamic_array<LEX_STRING*> db_names;
+ Dynamic_array<LEX_CSTRING*> db_names;
Schema_specification_st create;
TABLE *table= tables->table;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -5065,7 +5070,7 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
for (size_t i=0; i < db_names.elements(); i++)
{
- LEX_STRING *db_name= db_names.at(i);
+ LEX_CSTRING *db_name= db_names.at(i);
DBUG_ASSERT(db_name->length <= NAME_LEN);
if (db_name == &INFORMATION_SCHEMA_NAME)
{
@@ -5092,8 +5097,8 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
TABLE *table, bool res,
- LEX_STRING *db_name,
- LEX_STRING *table_name)
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
const char *tmp_buff;
MYSQL_TIME time;
@@ -5521,8 +5526,8 @@ static void store_column_type(TABLE *table, Field *field, CHARSET_INFO *cs,
static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
TABLE *table, bool res,
- LEX_STRING *db_name,
- LEX_STRING *table_name)
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
LEX *lex= thd->lex;
const char *wild= lex->wild ? lex->wild->ptr() : NullS;
@@ -5564,7 +5569,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
DEBUG_SYNC(thd, "get_schema_column");
if (wild && wild[0] &&
- wild_case_compare(system_charset_info, field->field_name,wild))
+ wild_case_compare(system_charset_info, field->field_name.str, wild))
continue;
count++;
@@ -5577,7 +5582,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
&tables->grant.privilege, 0, 0, MY_TEST(tables->schema_table));
col_access= get_column_grant(thd, &tables->grant,
db_name->str, table_name->str,
- field->field_name) & COL_ACLS;
+ field->field_name.str) & COL_ACLS;
if (!tables->schema_table && !col_access)
continue;
char *end= tmp;
@@ -5595,7 +5600,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
table->field[0]->store(STRING_WITH_LEN("def"), cs);
table->field[1]->store(db_name->str, db_name->length, cs);
table->field[2]->store(table_name->str, table_name->length, cs);
- table->field[3]->store(field->field_name, strlen(field->field_name),
+ table->field[3]->store(field->field_name.str, field->field_name.length,
cs);
table->field[4]->store((longlong) count, TRUE);
@@ -5708,13 +5713,13 @@ static my_bool iter_schema_engines(THD *thd, plugin_ref plugin,
if (!(hton->flags & HTON_HIDDEN))
{
- LEX_STRING *name= plugin_name(plugin);
+ LEX_CSTRING *name= plugin_name(plugin);
if (!(wild && wild[0] &&
wild_case_compare(scs, name->str,wild)))
{
- LEX_STRING yesno[2]= {{ C_STRING_WITH_LEN("NO") },
- { C_STRING_WITH_LEN("YES") }};
- LEX_STRING *tmp;
+ LEX_CSTRING yesno[2]= {{ STRING_WITH_LEN("NO") },
+ { STRING_WITH_LEN("YES") }};
+ LEX_CSTRING *tmp;
const char *option_name= show_comp_option_name[(int) hton->state];
restore_record(table, s->default_values);
@@ -5925,7 +5930,8 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table,
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_MYSQL_TYPE],
&tmp_string);
table->field[15]->store(tmp_string.ptr(), tmp_string.length(), cs);
- field= sp->m_return_field_def.make_field(&share, thd->mem_root, "");
+ field= sp->m_return_field_def.make_field(&share, thd->mem_root,
+ &empty_clex_str);
field->table= &tbl;
tbl.in_use= thd;
store_column_type(table, field, cs, 6);
@@ -5973,7 +5979,7 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table,
table->field[15]->store(tmp_string.ptr(), tmp_string.length(), cs);
field= spvar->field_def.make_field(&share, thd->mem_root,
- spvar->name.str);
+ &spvar->name);
field->table= &tbl;
tbl.in_use= thd;
store_column_type(table, field, cs, 6);
@@ -6064,7 +6070,8 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
bzero((char*) &tbl, sizeof(TABLE));
(void) build_table_filename(path, sizeof(path), "", "", "", 0);
init_tmp_table_share(thd, &share, "", 0, "", path);
- field= sp->m_return_field_def.make_field(&share, thd->mem_root, "");
+ field= sp->m_return_field_def.make_field(&share, thd->mem_root,
+ &empty_clex_str);
field->table= &tbl;
tbl.in_use= thd;
store_column_type(table, field, cs, 5);
@@ -6190,8 +6197,8 @@ err:
static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
TABLE *table, bool res,
- LEX_STRING *db_name,
- LEX_STRING *table_name)
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_stat_record");
@@ -6226,7 +6233,8 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
for (uint i=0 ; i < show_table->s->keys ; i++,key_info++)
{
KEY_PART_INFO *key_part= key_info->key_part;
- const char *str;
+ LEX_CSTRING *str;
+ LEX_CSTRING unknown= {STRING_WITH_LEN("?unknown field?") };
for (uint j=0 ; j < key_info->user_defined_key_parts ; j++,key_part++)
{
restore_record(table, s->default_values);
@@ -6238,9 +6246,9 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
table->field[4]->store(db_name->str, db_name->length, cs);
table->field[5]->store(key_info->name, strlen(key_info->name), cs);
table->field[6]->store((longlong) (j+1), TRUE);
- str=(key_part->field ? key_part->field->field_name :
- "?unknown field?");
- table->field[7]->store(str, strlen(str), cs);
+ str= (key_part->field ? &key_part->field->field_name :
+ &unknown);
+ table->field[7]->store(str->str, str->length, cs);
if (show_table->file)
{
if (show_table->file->index_flags(i, j, 0) & HA_READ_ORDER)
@@ -6258,8 +6266,8 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
table->field[9]->store((longlong) records, TRUE);
table->field[9]->set_notnull();
}
- str= show_table->file->index_type(i);
- table->field[13]->store(str, strlen(str), cs);
+ const char *tmp= show_table->file->index_type(i);
+ table->field[13]->store(tmp, strlen(tmp), cs);
}
if (!(key_info->flags & HA_FULLTEXT) &&
(key_part->field &&
@@ -6294,8 +6302,8 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
static int get_schema_views_record(THD *thd, TABLE_LIST *tables,
TABLE *table, bool res,
- LEX_STRING *db_name,
- LEX_STRING *table_name)
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
CHARSET_INFO *cs= system_charset_info;
char definer[USER_HOST_BUFF_SIZE];
@@ -6438,9 +6446,10 @@ static int get_schema_views_record(THD *thd, TABLE_LIST *tables,
}
-bool store_constraints(THD *thd, TABLE *table, LEX_STRING *db_name,
- LEX_STRING *table_name, const char *key_name,
- uint key_len, const char *con_type, uint con_len)
+static bool
+store_constraints(THD *thd, TABLE *table, const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name, const char *key_name,
+ uint key_len, const char *con_type, uint con_len)
{
CHARSET_INFO *cs= system_charset_info;
restore_record(table, s->default_values);
@@ -6456,8 +6465,8 @@ bool store_constraints(THD *thd, TABLE *table, LEX_STRING *db_name,
static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
TABLE *table, bool res,
- LEX_STRING *db_name,
- LEX_STRING *table_name)
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
DBUG_ENTER("get_schema_constraints_record");
if (res)
@@ -6529,14 +6538,15 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
static bool store_trigger(THD *thd, Trigger *trigger,
- TABLE *table, LEX_STRING *db_name,
- LEX_STRING *table_name)
+ TABLE *table, const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
CHARSET_INFO *cs= system_charset_info;
- LEX_STRING sql_mode_rep;
+ LEX_CSTRING sql_mode_rep;
MYSQL_TIME timestamp;
char definer_holder[USER_HOST_BUFF_SIZE];
- LEX_STRING definer_buffer, trigger_stmt, trigger_body;
+ LEX_STRING definer_buffer;
+ LEX_CSTRING trigger_stmt, trigger_body;
definer_buffer.str= definer_holder;
trigger->get_trigger_info(&trigger_stmt, &trigger_body, &definer_buffer);
@@ -6585,8 +6595,8 @@ static bool store_trigger(THD *thd, Trigger *trigger,
static int get_schema_triggers_record(THD *thd, TABLE_LIST *tables,
TABLE *table, bool res,
- LEX_STRING *db_name,
- LEX_STRING *table_name)
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
DBUG_ENTER("get_schema_triggers_record");
/*
@@ -6632,10 +6642,11 @@ ret:
}
-void store_key_column_usage(TABLE *table, LEX_STRING *db_name,
- LEX_STRING *table_name, const char *key_name,
- uint key_len, const char *con_type, uint con_len,
- longlong idx)
+static void
+store_key_column_usage(TABLE *table, const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name, const char *key_name,
+ uint key_len, const char *con_type, uint con_len,
+ longlong idx)
{
CHARSET_INFO *cs= system_charset_info;
table->field[0]->store(STRING_WITH_LEN("def"), cs);
@@ -6652,8 +6663,8 @@ void store_key_column_usage(TABLE *table, LEX_STRING *db_name,
static int get_schema_key_column_usage_record(THD *thd,
TABLE_LIST *tables,
TABLE *table, bool res,
- LEX_STRING *db_name,
- LEX_STRING *table_name)
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
DBUG_ENTER("get_schema_key_column_usage_record");
if (res)
@@ -6689,8 +6700,8 @@ static int get_schema_key_column_usage_record(THD *thd,
store_key_column_usage(table, db_name, table_name,
key_info->name,
strlen(key_info->name),
- key_part->field->field_name,
- strlen(key_part->field->field_name),
+ key_part->field->field_name.str,
+ key_part->field->field_name.length,
(longlong) f_idx);
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
@@ -6703,9 +6714,9 @@ static int get_schema_key_column_usage_record(THD *thd,
List_iterator_fast<FOREIGN_KEY_INFO> fkey_it(f_key_list);
while ((f_key_info= fkey_it++))
{
- LEX_STRING *f_info;
- LEX_STRING *r_info;
- List_iterator_fast<LEX_STRING> it(f_key_info->foreign_fields),
+ LEX_CSTRING *f_info;
+ LEX_CSTRING *r_info;
+ List_iterator_fast<LEX_CSTRING> it(f_key_info->foreign_fields),
it1(f_key_info->referenced_fields);
uint f_idx= 0;
while ((f_info= it++))
@@ -6741,10 +6752,10 @@ static int get_schema_key_column_usage_record(THD *thd,
#ifdef WITH_PARTITION_STORAGE_ENGINE
-static void collect_partition_expr(THD *thd, List<char> &field_list,
+static void collect_partition_expr(THD *thd, List<const char> &field_list,
String *str)
{
- List_iterator<char> part_it(field_list);
+ List_iterator<const char> part_it(field_list);
ulong no_fields= field_list.elements;
const char *field_str;
str->length(0);
@@ -6933,8 +6944,8 @@ get_partition_column_description(THD *thd,
static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
TABLE *table, bool res,
- LEX_STRING *db_name,
- LEX_STRING *table_name)
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
CHARSET_INFO *cs= system_charset_info;
char buff[61];
@@ -7236,7 +7247,7 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
/* SQL_MODE */
{
- LEX_STRING sql_mode;
+ LEX_CSTRING sql_mode;
sql_mode_string_representation(thd, et.sql_mode, &sql_mode);
sch_table->field[ISE_SQL_MODE]->
store(sql_mode.str, sql_mode.length, scs);
@@ -7258,7 +7269,7 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
sch_table->field[ISE_INTERVAL_VALUE]->
store(show_str.ptr(), show_str.length(), scs);
- LEX_STRING *ival= &interval_type_to_name[et.interval];
+ LEX_CSTRING *ival= &interval_type_to_name[et.interval];
sch_table->field[ISE_INTERVAL_FIELD]->set_notnull();
sch_table->field[ISE_INTERVAL_FIELD]->store(ival->str, ival->length, scs);
@@ -7492,7 +7503,8 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond)
static int
get_referential_constraints_record(THD *thd, TABLE_LIST *tables,
TABLE *table, bool res,
- LEX_STRING *db_name, LEX_STRING *table_name)
+ const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name)
{
CHARSET_INFO *cs= system_charset_info;
LEX_CSTRING *s;
@@ -7670,6 +7682,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
for (; fields_info->field_name; fields_info++)
{
+ uint field_name_length= strlen(fields_info->field_name);
switch (fields_info->field_type) {
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_LONG:
@@ -7689,14 +7702,14 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
case MYSQL_TYPE_DATE:
if (!(item=new (mem_root)
Item_return_date_time(thd, fields_info->field_name,
- strlen(fields_info->field_name),
+ field_name_length,
fields_info->field_type)))
DBUG_RETURN(0);
break;
case MYSQL_TYPE_TIME:
if (!(item=new (mem_root)
Item_return_date_time(thd, fields_info->field_name,
- strlen(fields_info->field_name),
+ field_name_length,
fields_info->field_type)))
DBUG_RETURN(0);
break;
@@ -7704,7 +7717,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
case MYSQL_TYPE_DATETIME:
if (!(item=new (mem_root)
Item_return_date_time(thd, fields_info->field_name,
- strlen(fields_info->field_name),
+ field_name_length,
fields_info->field_type)))
DBUG_RETURN(0);
item->decimals= fields_info->field_length;
@@ -7737,8 +7750,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
item->max_length+= 1;
if (item->decimals > 0)
item->max_length+= 1;
- item->set_name(thd, fields_info->field_name,
- strlen(fields_info->field_name), cs);
+ item->set_name(thd, fields_info->field_name, field_name_length, cs);
break;
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
@@ -7761,7 +7773,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
DBUG_RETURN(0);
}
item->set_name(thd, fields_info->field_name,
- strlen(fields_info->field_name), cs);
+ field_name_length, cs);
break;
}
field_list.push_back(item, thd->mem_root);
@@ -7816,8 +7828,10 @@ static int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
if (field_info->old_name)
{
+ LEX_CSTRING field_name= {field_info->field_name,
+ strlen(field_info->field_name)};
Item_field *field= new (thd->mem_root)
- Item_field(thd, context, NullS, NullS, field_info->field_name);
+ Item_field(thd, context, NullS, NullS, &field_name);
if (field)
{
field->set_name(thd, field_info->old_name,
@@ -7843,8 +7857,11 @@ int make_schemata_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
ST_FIELD_INFO *field_info= &schema_table->fields_info[1];
String buffer(tmp,sizeof(tmp), system_charset_info);
+ LEX_CSTRING field_name= {field_info->field_name,
+ strlen(field_info->field_name) };
+
Item_field *field= new (thd->mem_root) Item_field(thd, context,
- NullS, NullS, field_info->field_name);
+ NullS, NullS, &field_name);
if (!field || add_item_to_list(thd, field))
return 1;
buffer.length(0);
@@ -7867,8 +7884,10 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
String buffer(tmp,sizeof(tmp), thd->charset());
LEX *lex= thd->lex;
Name_resolution_context *context= &lex->select_lex.context;
-
ST_FIELD_INFO *field_info= &schema_table->fields_info[2];
+ LEX_CSTRING field_name= {field_info->field_name,
+ strlen(field_info->field_name) };
+
buffer.length(0);
buffer.append(field_info->old_name);
buffer.append(lex->select_lex.db);
@@ -7879,15 +7898,17 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
buffer.append(')');
}
Item_field *field= new (thd->mem_root) Item_field(thd, context,
- NullS, NullS, field_info->field_name);
+ NullS, NullS, &field_name);
if (add_item_to_list(thd, field))
return 1;
field->set_name(thd, buffer.ptr(), buffer.length(), system_charset_info);
if (thd->lex->verbose)
{
- field->set_name(thd, buffer.ptr(), buffer.length(), system_charset_info);
field_info= &schema_table->fields_info[3];
- field= new (thd->mem_root) Item_field(thd, context, NullS, NullS, field_info->field_name);
+ LEX_CSTRING field_name2= {field_info->field_name,
+ strlen(field_info->field_name) };
+ field= new (thd->mem_root) Item_field(thd, context, NullS, NullS,
+ &field_name2);
if (add_item_to_list(thd, field))
return 1;
field->set_name(thd, field_info->old_name, strlen(field_info->old_name),
@@ -7907,12 +7928,14 @@ int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
for (; *field_num >= 0; field_num++)
{
field_info= &schema_table->fields_info[*field_num];
+ LEX_CSTRING field_name= {field_info->field_name,
+ strlen(field_info->field_name)};
if (!thd->lex->verbose && (*field_num == 14 ||
*field_num == 18 ||
*field_num == 19))
continue;
Item_field *field= new (thd->mem_root) Item_field(thd, context,
- NullS, NullS, field_info->field_name);
+ NullS, NullS, &field_name);
if (field)
{
field->set_name(thd, field_info->old_name,
@@ -7936,8 +7959,10 @@ int make_character_sets_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
for (; *field_num >= 0; field_num++)
{
field_info= &schema_table->fields_info[*field_num];
+ LEX_CSTRING field_name= {field_info->field_name,
+ strlen(field_info->field_name)};
Item_field *field= new (thd->mem_root) Item_field(thd, context,
- NullS, NullS, field_info->field_name);
+ NullS, NullS, &field_name);
if (field)
{
field->set_name(thd, field_info->old_name,
@@ -7961,8 +7986,10 @@ int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
for (; *field_num >= 0; field_num++)
{
field_info= &schema_table->fields_info[*field_num];
+ LEX_CSTRING field_name= {field_info->field_name,
+ strlen(field_info->field_name)};
Item_field *field= new (thd->mem_root) Item_field(thd, context,
- NullS, NullS, field_info->field_name);
+ NullS, NullS, &field_name);
if (field)
{
field->set_name(thd, field_info->old_name,
@@ -8076,7 +8103,7 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
int make_schema_select(THD *thd, SELECT_LEX *sel,
ST_SCHEMA_TABLE *schema_table)
{
- LEX_STRING db, table;
+ LEX_CSTRING db, table;
DBUG_ENTER("make_schema_select");
DBUG_PRINT("enter", ("mysql_schema_select: %s", schema_table->table_name));
/*
@@ -8094,7 +8121,7 @@ int make_schema_select(THD *thd, SELECT_LEX *sel,
if (schema_table->old_format(thd, schema_table))
DBUG_RETURN(1);
- if (!sel->add_table_to_list(thd, new Table_ident(thd, db, table, 0),
+ if (!sel->add_table_to_list(thd, new Table_ident(thd, &db, &table, 0),
0, 0, TL_READ, MDL_SHARED_READ))
DBUG_RETURN(1);
@@ -9472,8 +9499,8 @@ static bool show_create_trigger_impl(THD *thd, Trigger *trigger)
int ret_code;
Protocol *p= thd->protocol;
List<Item> fields;
- LEX_STRING trg_sql_mode_str, trg_body;
- LEX_STRING trg_sql_original_stmt;
+ LEX_CSTRING trg_sql_mode_str, trg_body;
+ LEX_CSTRING trg_sql_original_stmt;
LEX_STRING trg_definer;
CHARSET_INFO *trg_client_cs;
MEM_ROOT *mem_root= thd->mem_root;
@@ -9627,8 +9654,8 @@ TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name)
{
char trn_path_buff[FN_REFLEN];
LEX_STRING trn_path= { trn_path_buff, 0 };
- LEX_STRING db;
- LEX_STRING tbl_name;
+ LEX_CSTRING db;
+ LEX_CSTRING tbl_name;
TABLE_LIST *table;
build_trn_path(thd, trg_name, &trn_path);
@@ -9639,7 +9666,8 @@ TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name)
return NULL;
}
- if (load_table_name_for_trigger(thd, trg_name, &trn_path, &tbl_name))
+ if (load_table_name_for_trigger(thd, trg_name, (LEX_CSTRING*) &trn_path,
+ &tbl_name))
return NULL;
/* We need to reset statement table list to be PS/SP friendly. */
@@ -9650,7 +9678,7 @@ TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name)
db.str= thd->strmake(db.str, db.length);
if (lower_case_table_names)
- db.length= my_casedn_str(files_charset_info, db.str);
+ db.length= my_casedn_str(files_charset_info, (char*) db.str);
tbl_name.str= thd->strmake(tbl_name.str, tbl_name.length);
diff --git a/sql/sql_show.h b/sql/sql_show.h
index e93b855450c..dc2fe9738fe 100644
--- a/sql/sql_show.h
+++ b/sql/sql_show.h
@@ -90,8 +90,8 @@ bool mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
List<Item> *field_list, String *buffer);
bool mysqld_show_create(THD *thd, TABLE_LIST *table_list);
void mysqld_show_create_db_get_fields(THD *thd, List<Item> *field_list);
-bool mysqld_show_create_db(THD *thd, LEX_STRING *db_name,
- LEX_STRING *orig_db_name,
+bool mysqld_show_create_db(THD *thd, LEX_CSTRING *db_name,
+ LEX_CSTRING *orig_db_name,
const DDL_options_st &options);
void mysqld_list_processes(THD *thd,const char *user,bool verbose);
@@ -103,8 +103,8 @@ bool mysqld_show_contributors(THD *thd);
bool mysqld_show_privileges(THD *thd);
char *make_backup_log_name(char *buff, const char *name, const char* log_ext);
uint calc_sum_of_all_status(STATUS_VAR *to);
-void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user,
- const LEX_STRING *definer_host);
+void append_definer(THD *thd, String *buffer, const LEX_CSTRING *definer_user,
+ const LEX_CSTRING *definer_host);
int add_status_vars(SHOW_VAR *list);
void remove_status_vars(SHOW_VAR *list);
void init_status_vars();
@@ -180,13 +180,13 @@ typedef struct st_lookup_field_values
Note that this value length may exceed @c NAME_LEN.
@sa wild_db_value
*/
- LEX_STRING db_value;
+ LEX_CSTRING db_value;
/**
Value of a TABLE_NAME clause.
Note that this value length may exceed @c NAME_LEN.
@sa wild_table_value
*/
- LEX_STRING table_value;
+ LEX_CSTRING table_value;
/**
True when @c db_value is a LIKE clause,
false when @c db_value is an '=' clause.
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index ad71f634265..3ec8fea29c6 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -471,9 +471,9 @@ protected:
/* Table for which statistical data is read / updated */
TABLE *table;
- TABLE_SHARE *table_share; /* Table share for 'table */
- LEX_STRING *db_name; /* Name of the database containing 'table' */
- LEX_STRING *table_name; /* Name of the table 'table' */
+ TABLE_SHARE *table_share; /* Table share for 'table */
+ LEX_CSTRING *db_name; /* Name of the database containing 'table' */
+ LEX_CSTRING *table_name; /* Name of the table 'table' */
void store_record_for_update()
{
@@ -528,7 +528,7 @@ public:
by the database name 'db' and the table name 'tab'.
*/
- Stat_table(TABLE *stat, LEX_STRING *db, LEX_STRING *tab)
+ Stat_table(TABLE *stat, LEX_CSTRING *db, LEX_CSTRING *tab)
:stat_table(stat), table_share(NULL)
{
common_init_stat_table();
@@ -553,7 +553,7 @@ public:
The method is called by the update_table_name_key_parts function.
*/
- virtual void change_full_table_name(LEX_STRING *db, LEX_STRING *tab)= 0;
+ virtual void change_full_table_name(LEX_CSTRING *db, LEX_CSTRING *tab)= 0;
/**
@@ -703,7 +703,7 @@ public:
to store the new names in the record buffer used for updates.
*/
- bool update_table_name_key_parts(LEX_STRING *db, LEX_STRING *tab)
+ bool update_table_name_key_parts(LEX_CSTRING *db, LEX_CSTRING *tab)
{
store_record_for_update();
change_full_table_name(db, tab);
@@ -765,7 +765,7 @@ private:
table_name_field= stat_table->field[TABLE_STAT_TABLE_NAME];
}
- void change_full_table_name(LEX_STRING *db, LEX_STRING *tab)
+ void change_full_table_name(LEX_CSTRING *db, LEX_CSTRING *tab)
{
db_name_field->store(db->str, db->length, system_charset_info);
table_name_field->store(tab->str, tab->length, system_charset_info);
@@ -795,7 +795,7 @@ public:
from the database 'db'.
*/
- Table_stat(TABLE *stat, LEX_STRING *db, LEX_STRING *tab)
+ Table_stat(TABLE *stat, LEX_CSTRING *db, LEX_CSTRING *tab)
:Stat_table(stat, db, tab)
{
common_init_table_stat();
@@ -909,7 +909,7 @@ private:
column_name_field= stat_table->field[COLUMN_STAT_COLUMN_NAME];
}
- void change_full_table_name(LEX_STRING *db, LEX_STRING *tab)
+ void change_full_table_name(LEX_CSTRING *db, LEX_CSTRING *tab)
{
db_name_field->store(db->str, db->length, system_charset_info);
table_name_field->store(tab->str, tab->length, system_charset_info);
@@ -939,7 +939,7 @@ public:
from the database 'db'.
*/
- Column_stat(TABLE *stat, LEX_STRING *db, LEX_STRING *tab)
+ Column_stat(TABLE *stat, LEX_CSTRING *db, LEX_CSTRING *tab)
:Stat_table(stat, db, tab)
{
common_init_column_stat_table();
@@ -983,8 +983,7 @@ public:
void set_key_fields(Field *col)
{
set_full_table_name();
- const char *column_name= col->field_name;
- column_name_field->store(column_name, strlen(column_name),
+ column_name_field->store(col->field_name.str, col->field_name.length,
system_charset_info);
table_field= col;
}
@@ -1245,7 +1244,7 @@ private:
prefix_arity_field= stat_table->field[INDEX_STAT_PREFIX_ARITY];
}
- void change_full_table_name(LEX_STRING *db, LEX_STRING *tab)
+ void change_full_table_name(LEX_CSTRING *db, LEX_CSTRING *tab)
{
db_name_field->store(db->str, db->length, system_charset_info);
table_name_field->store(tab->str, tab->length, system_charset_info);
@@ -1277,7 +1276,7 @@ public:
from the database 'db'.
*/
- Index_stat(TABLE *stat, LEX_STRING *db, LEX_STRING *tab)
+ Index_stat(TABLE *stat, LEX_CSTRING *db, LEX_CSTRING *tab)
:Stat_table(stat, db, tab)
{
common_init_index_stat_table();
@@ -1320,7 +1319,7 @@ public:
void set_index_prefix_key_fields(KEY *index_info)
{
set_full_table_name();
- char *index_name= index_info->name;
+ const char *index_name= index_info->name;
index_name_field->store(index_name, strlen(index_name),
system_charset_info);
table_key_info= index_info;
@@ -1961,7 +1960,7 @@ void create_min_max_statistical_fields_for_table(TABLE *table)
for (uint i=0; i < 2; i++, record+= rec_buff_length)
{
- for (Field **field_ptr= table->field; *field_ptr; field_ptr++)
+ for (Field **field_ptr= table->field; *field_ptr; field_ptr++)
{
Field *fld;
Field *table_field= *field_ptr;
@@ -2030,7 +2029,7 @@ void create_min_max_statistical_fields_for_table_share(THD *thd,
for (uint i=0; i < 2; i++, record+= rec_buff_length)
{
- for (Field **field_ptr= table_share->field; *field_ptr; field_ptr++)
+ for (Field **field_ptr= table_share->field; *field_ptr; field_ptr++)
{
Field *fld;
Field *table_field= *field_ptr;
@@ -2493,7 +2492,7 @@ bool Column_statistics_collected::add(ha_rows rowno)
set_not_null(COLUMN_STAT_MIN_VALUE);
if (max_value && column->update_max(max_value, rowno == nulls))
set_not_null(COLUMN_STAT_MAX_VALUE);
- if (count_distinct)
+ if (count_distinct)
err= count_distinct->add();
}
return err;
@@ -3283,7 +3282,7 @@ int read_statistics_for_tables_if_needed(THD *thd, TABLE_LIST *tables)
The function is called when executing the statement DROP TABLE 'tab'.
*/
-int delete_statistics_for_table(THD *thd, LEX_STRING *db, LEX_STRING *tab)
+int delete_statistics_for_table(THD *thd, LEX_CSTRING *db, LEX_CSTRING *tab)
{
int err;
enum_binlog_format save_binlog_format;
@@ -3521,8 +3520,8 @@ int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info,
The function is called when executing any statement that renames a table
*/
-int rename_table_in_stat_tables(THD *thd, LEX_STRING *db, LEX_STRING *tab,
- LEX_STRING *new_db, LEX_STRING *new_tab)
+int rename_table_in_stat_tables(THD *thd, LEX_CSTRING *db, LEX_CSTRING *tab,
+ LEX_CSTRING *new_db, LEX_CSTRING *new_tab)
{
int err;
enum_binlog_format save_binlog_format;
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index f46583839d1..eb59b149753 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -94,12 +94,12 @@ int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *share,
bool is_safe);
int alloc_statistics_for_table(THD *thd, TABLE *table);
int update_statistics_for_table(THD *thd, TABLE *table);
-int delete_statistics_for_table(THD *thd, LEX_STRING *db, LEX_STRING *tab);
+int delete_statistics_for_table(THD *thd, LEX_CSTRING *db, LEX_CSTRING *tab);
int delete_statistics_for_column(THD *thd, TABLE *tab, Field *col);
int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info,
bool ext_prefixes_only);
-int rename_table_in_stat_tables(THD *thd, LEX_STRING *db, LEX_STRING *tab,
- LEX_STRING *new_db, LEX_STRING *new_tab);
+int rename_table_in_stat_tables(THD *thd, LEX_CSTRING *db, LEX_CSTRING *tab,
+ LEX_CSTRING *new_db, LEX_CSTRING *new_tab);
int rename_column_in_stat_tables(THD *thd, TABLE *tab, Field *col,
const char *new_name);
void set_statistics_for_table(THD *thd, TABLE *table);
@@ -259,10 +259,10 @@ static inline
int rename_table_in_stat_tables(THD *thd, const char *db, const char *tab,
const char *new_db, const char *new_tab)
{
- LEX_STRING od= { const_cast<char*>(db), strlen(db) };
- LEX_STRING ot= { const_cast<char*>(tab), strlen(tab) };
- LEX_STRING nd= { const_cast<char*>(new_db), strlen(new_db) };
- LEX_STRING nt= { const_cast<char*>(new_tab), strlen(new_tab) };
+ LEX_CSTRING od= { db, strlen(db) };
+ LEX_CSTRING ot= { tab, strlen(tab) };
+ LEX_CSTRING nd= { new_db, strlen(new_db) };
+ LEX_CSTRING nt= { new_tab, strlen(new_tab) };
return rename_table_in_stat_tables(thd, &od, &ot, &nd, &nt);
}
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 3d7703b9f61..fad2b4994af 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -560,6 +560,10 @@ public:
memcpy(Ptr + str_length, data, data_len);
str_length += data_len;
}
+ void q_append(const LEX_CSTRING *ls)
+ {
+ q_append(ls->str, ls->length);
+ }
void write_at_position(int position, uint32 value)
{
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index ddf3f4d1b07..8c05d0fa02b 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -65,7 +65,7 @@ const char *primary_key_name="PRIMARY";
static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end);
static char *make_unique_key_name(THD *thd, const char *field_name, KEY *start,
KEY *end);
-static void make_unique_constraint_name(THD *thd, LEX_STRING *name,
+static void make_unique_constraint_name(THD *thd, LEX_CSTRING *name,
List<Virtual_column_info> *vcol,
uint *nr);
static int copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
@@ -1084,7 +1084,7 @@ static bool deactivate_ddl_log_entry_no_lock(uint entry_no)
static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
{
bool frm_action= FALSE;
- LEX_STRING handler_name;
+ LEX_CSTRING handler_name;
handler *file= NULL;
MEM_ROOT mem_root;
int error= TRUE;
@@ -2031,8 +2031,8 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, bool if_exists,
{
for (table= tables; table; table= table->next_local)
{
- LEX_STRING db_name= { table->db, table->db_length };
- LEX_STRING table_name= { table->table_name, table->table_name_length };
+ LEX_CSTRING db_name= { table->db, table->db_length };
+ LEX_CSTRING table_name= { table->table_name, table->table_name_length };
if (table->open_type == OT_BASE_ONLY ||
!thd->find_temporary_table(table))
(void) delete_statistics_for_table(thd, &db_name, &table_name);
@@ -2182,7 +2182,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
bool dont_free_locks)
{
TABLE_LIST *table;
- char path[FN_REFLEN + 1], wrong_tables_buff[160], *alias= NULL;
+ char path[FN_REFLEN + 1], wrong_tables_buff[160];
+ const char *alias= NULL;
String wrong_tables(wrong_tables_buff, sizeof(wrong_tables_buff)-1,
system_charset_info);
uint path_length= 0, errors= 0;
@@ -2271,7 +2272,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
{
bool is_trans= 0;
bool table_creation_was_logged= 1;
- char *db=table->db;
+ const char *db= table->db;
size_t db_length= table->db_length;
handlerton *table_type= 0;
@@ -2908,7 +2909,7 @@ bool Column_definition::prepare_create_field(uint *blob_columns,
pack_length= calc_pack_length(sql_type, (uint) length);
if ((length / charset->mbmaxlen) > MAX_FIELD_CHARLENGTH)
{
- my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), field_name,
+ my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), field_name.str,
static_cast<ulong>(MAX_FIELD_CHARLENGTH));
DBUG_RETURN(true);
}
@@ -2924,7 +2925,7 @@ bool Column_definition::prepare_create_field(uint *blob_columns,
pack_flag= pack_length_to_packflag(pack_length) | FIELDFLAG_INTERVAL;
if (charset->state & MY_CS_BINSORT)
pack_flag|= FIELDFLAG_BINARY;
- if (check_duplicates_in_interval("ENUM", field_name, interval,
+ if (check_duplicates_in_interval("ENUM", field_name.str, interval,
charset, &dup_val_count))
DBUG_RETURN(true);
break;
@@ -2932,13 +2933,13 @@ bool Column_definition::prepare_create_field(uint *blob_columns,
pack_flag= pack_length_to_packflag(pack_length) | FIELDFLAG_BITFIELD;
if (charset->state & MY_CS_BINSORT)
pack_flag|= FIELDFLAG_BINARY;
- if (check_duplicates_in_interval("SET", field_name, interval,
+ if (check_duplicates_in_interval("SET", field_name.str, interval,
charset, &dup_val_count))
DBUG_RETURN(true);
/* Check that count of unique members is not more then 64 */
if (interval->count - dup_val_count > sizeof(longlong)*8)
{
- my_error(ER_TOO_BIG_SET, MYF(0), field_name);
+ my_error(ER_TOO_BIG_SET, MYF(0), field_name.str);
DBUG_RETURN(true);
}
break;
@@ -3054,7 +3055,7 @@ void promote_first_timestamp_column(List<Create_field> *column_definitions)
DBUG_PRINT("info", ("First TIMESTAMP column '%s' was promoted to "
"DEFAULT CURRENT_TIMESTAMP ON UPDATE "
"CURRENT_TIMESTAMP",
- column_definition->field_name
+ column_definition->field_name.str
));
column_definition->unireg_check= Field::TIMESTAMP_DNUN_FIELD;
}
@@ -3278,7 +3279,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
safe_charset_converter(thd, save_cs)))
{
/* Could not convert */
- my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name.str);
DBUG_RETURN(TRUE);
}
/* Fix for prepare statement */
@@ -3318,7 +3319,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (not_found)
{
- my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name.str);
DBUG_RETURN(TRUE);
}
}
@@ -3326,9 +3327,9 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (!(sql_field->flags & NOT_NULL_FLAG))
null_fields++;
- if (check_column_name(sql_field->field_name))
+ if (check_column_name(sql_field->field_name.str))
{
- my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name);
+ my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name.str);
DBUG_RETURN(TRUE);
}
@@ -3336,8 +3337,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
{
if (my_strcasecmp(system_charset_info,
- sql_field->field_name,
- dup_field->field_name) == 0)
+ sql_field->field_name.str,
+ dup_field->field_name.str) == 0)
{
/*
If this was a CREATE ... SELECT statement, accept a field
@@ -3345,7 +3346,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
*/
if (field_no < select_field_pos || dup_no >= select_field_pos)
{
- my_error(ER_DUP_FIELDNAME, MYF(0), sql_field->field_name);
+ my_error(ER_DUP_FIELDNAME, MYF(0), sql_field->field_name.str);
DBUG_RETURN(TRUE);
}
else
@@ -3701,7 +3702,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
while ((sql_field=it++) &&
my_strcasecmp(system_charset_info,
column->field_name.str,
- sql_field->field_name))
+ sql_field->field_name.str))
field++;
if (!sql_field)
{
@@ -3799,7 +3800,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (sql_field->vcol_info->flags & VCOL_NOT_STRICTLY_DETERMINISTIC)
{
/* use check_expression() to report an error */
- check_expression(sql_field->vcol_info, sql_field->field_name,
+ check_expression(sql_field->vcol_info, &sql_field->field_name,
VCOL_GENERATED_STORED);
DBUG_ASSERT(thd->is_error());
DBUG_RETURN(TRUE);
@@ -3953,7 +3954,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
primary_key=1;
}
else if (!(key_name= key->name.str))
- key_name=make_unique_key_name(thd, sql_field->field_name,
+ key_name=make_unique_key_name(thd, sql_field->field_name.str,
*key_info_buffer, key_info);
if (check_if_keyname_exists(key_name, *key_info_buffer, key_info))
{
@@ -3978,7 +3979,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
if (validate_comment_length(thd, &key->key_create_info.comment,
- INDEX_COMMENT_MAXLEN, ER_TOO_LONG_INDEX_COMMENT,
+ INDEX_COMMENT_MAXLEN,
+ ER_TOO_LONG_INDEX_COMMENT,
key_info->name))
DBUG_RETURN(TRUE);
@@ -4052,7 +4054,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
'column_name TIMESTAMP DEFAULT 0'.
*/
- my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name.str);
DBUG_RETURN(TRUE);
}
}
@@ -4092,7 +4094,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
my_error(ER_TOO_LONG_IDENT, MYF(0), check->name.str);
DBUG_RETURN(TRUE);
}
- if (check_expression(check, check->name.str, VCOL_CHECK_TABLE))
+ if (check_expression(check, &check->name, VCOL_CHECK_TABLE))
DBUG_RETURN(TRUE);
}
}
@@ -4135,7 +4137,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
@retval true Error found
@retval false On Success
*/
-bool validate_comment_length(THD *thd, LEX_STRING *comment, size_t max_len,
+bool validate_comment_length(THD *thd, LEX_CSTRING *comment, size_t max_len,
uint err_code, const char *name)
{
DBUG_ENTER("validate_comment_length");
@@ -4171,7 +4173,8 @@ bool validate_comment_length(THD *thd, LEX_STRING *comment, size_t max_len,
*/
static void set_table_default_charset(THD *thd,
- HA_CREATE_INFO *create_info, char *db)
+ HA_CREATE_INFO *create_info,
+ const char *db)
{
/*
If the table character set was not given explicitly,
@@ -4212,14 +4215,14 @@ bool Column_definition::prepare_blob_field(THD *thd)
if (thd->is_strict_mode())
{
- my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), field_name,
+ my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), field_name.str,
static_cast<ulong>(MAX_FIELD_VARCHARLENGTH / charset->mbmaxlen));
DBUG_RETURN(1);
}
sql_type= MYSQL_TYPE_BLOB;
flags|= BLOB_FLAG;
my_snprintf(warn_buff, sizeof(warn_buff), ER_THD(thd, ER_AUTO_CONVERT),
- field_name,
+ field_name.str,
(charset == &my_charset_bin) ? "VARBINARY" : "VARCHAR",
(charset == &my_charset_bin) ? "BLOB" : "TEXT");
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_AUTO_CONVERT,
@@ -4358,15 +4361,16 @@ handler *mysql_create_frm_image(THD *thd,
{
if (part_elem->part_comment)
{
- LEX_STRING comment= {
- part_elem->part_comment, strlen(part_elem->part_comment)
+ LEX_CSTRING comment= { part_elem->part_comment,
+ strlen(part_elem->part_comment)
};
if (validate_comment_length(thd, &comment,
TABLE_PARTITION_COMMENT_MAXLEN,
ER_TOO_LONG_TABLE_PARTITION_COMMENT,
part_elem->partition_name))
DBUG_RETURN(NULL);
- part_elem->part_comment[comment.length]= '\0';
+ /* cut comment length. Safe to do in all cases */
+ ((char*)part_elem->part_comment)[comment.length]= '\0';
}
if (part_elem->subpartitions.elements)
{
@@ -4376,7 +4380,7 @@ handler *mysql_create_frm_image(THD *thd,
{
if (subpart_elem->part_comment)
{
- LEX_STRING comment= {
+ LEX_CSTRING comment= {
subpart_elem->part_comment, strlen(subpart_elem->part_comment)
};
if (validate_comment_length(thd, &comment,
@@ -4384,7 +4388,8 @@ handler *mysql_create_frm_image(THD *thd,
ER_TOO_LONG_TABLE_PARTITION_COMMENT,
subpart_elem->partition_name))
DBUG_RETURN(NULL);
- subpart_elem->part_comment[comment.length]= '\0';
+ /* cut comment length. Safe to do in all cases */
+ ((char*)subpart_elem->part_comment)[comment.length]= '\0';
}
}
}
@@ -4874,7 +4879,7 @@ int mysql_create_table_no_lock(THD *thd,
// Check if we hit FN_REFLEN bytes along with file extension.
if (length+reg_ext_length > FN_REFLEN)
{
- my_error(ER_IDENT_CAUSES_TOO_LONG_PATH, MYF(0), sizeof(path)-1, path);
+ my_error(ER_IDENT_CAUSES_TOO_LONG_PATH, MYF(0), (int) sizeof(path)-1, path);
return true;
}
}
@@ -5061,7 +5066,7 @@ make_unique_key_name(THD *thd, const char *field_name,KEY *start,KEY *end)
Make an unique name for constraints without a name
*/
-static void make_unique_constraint_name(THD *thd, LEX_STRING *name,
+static void make_unique_constraint_name(THD *thd, LEX_CSTRING *name,
List<Virtual_column_info> *vcol,
uint *nr)
{
@@ -5147,7 +5152,7 @@ mysql_rename_table(handlerton *base, const char *old_db,
// Check if we hit FN_REFLEN bytes along with file extension.
if (length+reg_ext_length > FN_REFLEN)
{
- my_error(ER_IDENT_CAUSES_TOO_LONG_PATH, MYF(0), sizeof(to)-1, to);
+ my_error(ER_IDENT_CAUSES_TOO_LONG_PATH, MYF(0), (int) sizeof(to)-1, to);
DBUG_RETURN(TRUE);
}
@@ -5679,7 +5684,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
while ((sql_field=it++))
{
- if (!sql_field->create_if_not_exists || sql_field->change)
+ if (!sql_field->create_if_not_exists || sql_field->change.str)
continue;
/*
If there is a field with the same name in the table already,
@@ -5688,7 +5693,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
for (f_ptr=table->field; *f_ptr; f_ptr++)
{
if (my_strcasecmp(system_charset_info,
- sql_field->field_name, (*f_ptr)->field_name) == 0)
+ sql_field->field_name.str, (*f_ptr)->field_name.str) == 0)
goto drop_create_field;
}
{
@@ -5701,7 +5706,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
while ((chk_field= chk_it++) && chk_field != sql_field)
{
if (my_strcasecmp(system_charset_info,
- sql_field->field_name, chk_field->field_name) == 0)
+ sql_field->field_name.str, chk_field->field_name.str) == 0)
goto drop_create_field;
}
}
@@ -5709,7 +5714,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
drop_create_field:
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_DUP_FIELDNAME, ER_THD(thd, ER_DUP_FIELDNAME),
- sql_field->field_name);
+ sql_field->field_name.str);
it.remove();
if (alter_info->create_list.is_empty())
{
@@ -5728,7 +5733,7 @@ drop_create_field:
while ((sql_field=it++))
{
- if (!sql_field->create_if_not_exists || !sql_field->change)
+ if (!sql_field->create_if_not_exists || !sql_field->change.str)
continue;
/*
If there is NO field with the same name in the table already,
@@ -5737,7 +5742,7 @@ drop_create_field:
for (f_ptr=table->field; *f_ptr; f_ptr++)
{
if (my_strcasecmp(system_charset_info,
- sql_field->change, (*f_ptr)->field_name) == 0)
+ sql_field->change.str, (*f_ptr)->field_name.str) == 0)
{
break;
}
@@ -5747,7 +5752,7 @@ drop_create_field:
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_BAD_FIELD_ERROR,
ER_THD(thd, ER_BAD_FIELD_ERROR),
- sql_field->change, table->s->table_name.str);
+ sql_field->change.str, table->s->table_name.str);
it.remove();
if (alter_info->create_list.is_empty())
{
@@ -5779,7 +5784,7 @@ drop_create_field:
for (f_ptr=table->field; *f_ptr; f_ptr++)
{
if (my_strcasecmp(system_charset_info,
- drop->name, (*f_ptr)->field_name) == 0)
+ drop->name, (*f_ptr)->field_name.str) == 0)
{
remove_drop= FALSE;
break;
@@ -6010,8 +6015,8 @@ remove_key:
if ((alter_info->flags & Alter_info::ALTER_DROP_PARTITION) &&
thd->lex->if_exists())
{
- List_iterator<char> names_it(alter_info->partition_names);
- char *name;
+ List_iterator<const char> names_it(alter_info->partition_names);
+ const char *name;
while ((name= names_it++))
{
@@ -6363,13 +6368,13 @@ static bool fill_alter_inplace_info(THD *thd,
}
/* Check if field was renamed */
- if (my_strcasecmp(system_charset_info, field->field_name,
- new_field->field_name))
+ if (my_strcasecmp(system_charset_info, field->field_name.str,
+ new_field->field_name.str))
{
field->flags|= FIELD_IS_RENAMED;
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_NAME;
rename_column_in_stat_tables(thd, table, field,
- new_field->field_name);
+ new_field->field_name.str);
}
/* Check that NULL behavior is same for old and new fields */
@@ -6820,8 +6825,8 @@ bool mysql_compare_tables(TABLE *table,
/* Check if field was renamed */
if (my_strcasecmp(system_charset_info,
- field->field_name,
- tmp_new_field->field_name))
+ field->field_name.str,
+ tmp_new_field->field_name.str))
DBUG_RETURN(false);
/* Evaluate changes bitmap and send to check_if_incompatible_data() */
@@ -7509,7 +7514,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
while ((drop=drop_it++))
{
if (drop->type == Alter_drop::COLUMN &&
- !my_strcasecmp(system_charset_info,field->field_name, drop->name))
+ !my_strcasecmp(system_charset_info,field->field_name.str,
+ drop->name))
{
/* Reset auto_increment value if it was dropped */
if (MTYP_TYPENR(field->unireg_check) == Field::NEXT_NUMBER &&
@@ -7532,8 +7538,9 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
def_it.rewind();
while ((def=def_it++))
{
- if (def->change &&
- !my_strcasecmp(system_charset_info,field->field_name, def->change))
+ if (def->change.str &&
+ !my_strcasecmp(system_charset_info,field->field_name.str,
+ def->change.str))
break;
}
if (def)
@@ -7550,7 +7557,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
my_error(ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN, MYF(0));
goto err;
}
- if (!def->after)
+ if (!def->after.str)
{
/*
If this ALTER TABLE doesn't have an AFTER clause for the modified
@@ -7574,7 +7581,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
Alter_column *alter;
while ((alter=alter_it++))
{
- if (!my_strcasecmp(system_charset_info,field->field_name, alter->name))
+ if (!my_strcasecmp(system_charset_info,field->field_name.str,
+ alter->name))
break;
}
if (alter)
@@ -7590,9 +7598,9 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
def_it.rewind();
while ((def=def_it++)) // Add new columns
{
- if (def->change && ! def->field)
+ if (def->change.str && ! def->field)
{
- my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change,
+ my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change.str,
table->s->table_name.str);
goto err;
}
@@ -7614,12 +7622,12 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
alter_ctx->datetime_field= def;
alter_ctx->error_if_not_empty= TRUE;
}
- if (!def->after)
+ if (!def->after.str)
new_create_list.push_back(def, thd->mem_root);
else
{
Create_field *find;
- if (def->change)
+ if (def->change.str)
{
find_it.rewind();
/*
@@ -7642,19 +7650,21 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}
}
}
- if (def->after == first_keyword)
+ if (def->after.str == first_keyword)
new_create_list.push_front(def, thd->mem_root);
else
{
find_it.rewind();
while ((find=find_it++))
{
- if (!my_strcasecmp(system_charset_info, def->after, find->field_name))
+ if (!my_strcasecmp(system_charset_info, def->after.str,
+ find->field_name.str))
break;
}
if (!find)
{
- my_error(ER_BAD_FIELD_ERROR, MYF(0), def->after, table->s->table_name.str);
+ my_error(ER_BAD_FIELD_ERROR, MYF(0), def->after.str,
+ table->s->table_name.str);
goto err;
}
find_it.after(def); // Put column after this
@@ -7682,7 +7692,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
for (uint i=0 ; i < table->s->keys ; i++,key_info++)
{
- char *key_name= key_info->name;
+ const char *key_name= key_info->name;
Alter_drop *drop;
drop_it.rewind();
while ((drop=drop_it++))
@@ -7719,21 +7729,21 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
{
if (!key_part->field)
continue; // Wrong field (from UNIREG)
- const char *key_part_name=key_part->field->field_name;
+ const char *key_part_name=key_part->field->field_name.str;
Create_field *cfield;
uint key_part_length;
field_it.rewind();
while ((cfield=field_it++))
{
- if (cfield->change)
+ if (cfield->change.str)
{
if (!my_strcasecmp(system_charset_info, key_part_name,
- cfield->change))
+ cfield->change.str))
break;
}
else if (!my_strcasecmp(system_charset_info,
- key_part_name, cfield->field_name))
+ key_part_name, cfield->field_name.str))
break;
}
if (!cfield)
@@ -7780,8 +7790,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
key_part_length= 0; // Use whole field
}
key_part_length /= key_part->field->charset()->mbmaxlen;
- key_parts.push_back(new Key_part_spec(cfield->field_name,
- strlen(cfield->field_name),
+ key_parts.push_back(new Key_part_spec(&cfield->field_name,
key_part_length),
thd->mem_root);
}
@@ -7799,8 +7808,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
KEY_CREATE_INFO key_create_info;
Key *key;
enum Key::Keytype key_type;
+ LEX_CSTRING tmp_name;
bzero((char*) &key_create_info, sizeof(key_create_info));
-
key_create_info.algorithm= key_info->algorithm;
if (key_info->flags & HA_USES_BLOCK_SIZE)
key_create_info.block_size= key_info->block_size;
@@ -7829,10 +7838,11 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
else
key_type= Key::MULTIPLE;
- key= new Key(key_type, key_name, strlen(key_name),
- &key_create_info,
+ tmp_name.str= key_name;
+ tmp_name.length= strlen(key_name);
+ key= new Key(key_type, &tmp_name, &key_create_info,
MY_TEST(key_info->flags & HA_GENERATED_KEY),
- key_parts, key_info->option_list, DDL_options());
+ &key_parts, key_info->option_list, DDL_options());
new_key_list.push_back(key, thd->mem_root);
}
}
@@ -7957,7 +7967,7 @@ static Create_field *get_field_by_old_name(Alter_info *alter_info,
{
if (new_field->field &&
(my_strcasecmp(system_charset_info,
- new_field->field->field_name,
+ new_field->field->field_name.str,
old_name) == 0))
break;
}
@@ -7997,11 +8007,11 @@ enum fk_column_change_type
static enum fk_column_change_type
fk_check_column_changes(THD *thd, Alter_info *alter_info,
- List<LEX_STRING> &fk_columns,
+ List<LEX_CSTRING> &fk_columns,
const char **bad_column_name)
{
- List_iterator_fast<LEX_STRING> column_it(fk_columns);
- LEX_STRING *column;
+ List_iterator_fast<LEX_CSTRING> column_it(fk_columns);
+ LEX_CSTRING *column;
*bad_column_name= NULL;
@@ -8013,8 +8023,8 @@ fk_check_column_changes(THD *thd, Alter_info *alter_info,
{
Field *old_field= new_field->field;
- if (my_strcasecmp(system_charset_info, old_field->field_name,
- new_field->field_name))
+ if (my_strcasecmp(system_charset_info, old_field->field_name.str,
+ new_field->field_name.str))
{
/*
Copy algorithm doesn't support proper renaming of columns in
@@ -8178,7 +8188,7 @@ static bool fk_prepare_copy_alter_table(THD *thd, TABLE *table,
case FK_COLUMN_DROPPED:
{
StringBuffer<NAME_LEN*2+2> buff(system_charset_info);
- LEX_STRING *db= f_key->foreign_db, *tbl= f_key->foreign_table;
+ LEX_CSTRING *db= f_key->foreign_db, *tbl= f_key->foreign_table;
append_identifier(thd, &buff, db->str, db->length);
buff.append('.');
@@ -8380,11 +8390,11 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list,
DBUG_RETURN(true);
close_all_tables_for_name(thd, table->s, HA_EXTRA_PREPARE_FOR_RENAME, NULL);
- LEX_STRING old_db_name= { alter_ctx->db, strlen(alter_ctx->db) };
- LEX_STRING old_table_name=
+ LEX_CSTRING old_db_name= { alter_ctx->db, strlen(alter_ctx->db) };
+ LEX_CSTRING old_table_name=
{ alter_ctx->table_name, strlen(alter_ctx->table_name) };
- LEX_STRING new_db_name= { alter_ctx->new_db, strlen(alter_ctx->new_db) };
- LEX_STRING new_table_name=
+ LEX_CSTRING new_db_name= { alter_ctx->new_db, strlen(alter_ctx->new_db) };
+ LEX_CSTRING new_table_name=
{ alter_ctx->new_alias, strlen(alter_ctx->new_alias) };
(void) rename_table_in_stat_tables(thd, &old_db_name, &old_table_name,
&new_db_name, &new_table_name);
@@ -8472,7 +8482,7 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list,
based on information about the table changes from fill_alter_inplace_info().
*/
-bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
+bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
HA_CREATE_INFO *create_info,
TABLE_LIST *table_list,
Alter_info *alter_info,
@@ -9364,7 +9374,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
*/
char backup_name[32];
my_snprintf(backup_name, sizeof(backup_name), "%s2-%lx-%lx", tmp_file_prefix,
- current_pid, thd->thread_id);
+ current_pid, (long) thd->thread_id);
if (lower_case_table_names)
my_casedn_str(files_charset_info, backup_name);
if (mysql_rename_table(old_db_type, alter_ctx.db, alter_ctx.table_name,
@@ -9504,7 +9514,7 @@ err_new_table_cleanup:
thd->abort_on_warning= true;
make_truncated_value_warning(thd, Sql_condition::WARN_LEVEL_WARN,
f_val, strlength(f_val), t_type,
- alter_ctx.datetime_field->field_name);
+ alter_ctx.datetime_field->field_name.str);
thd->abort_on_warning= save_abort_on_warning;
}
@@ -10159,7 +10169,7 @@ bool check_engine(THD *thd, const char *db_name,
if (no_substitution)
{
const char *engine_name= ha_resolve_storage_engine_name(req_engine);
- my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), engine_name, engine_name);
+ my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), engine_name);
DBUG_RETURN(TRUE);
}
*new_engine= enf_engine;
diff --git a/sql/sql_table.h b/sql/sql_table.h
index 0ab6dcaa3ef..4fb6135e9cc 100644
--- a/sql/sql_table.h
+++ b/sql/sql_table.h
@@ -217,7 +217,7 @@ bool mysql_prepare_alter_table(THD *thd, TABLE *table,
Alter_table_ctx *alter_ctx);
bool mysql_trans_prepare_alter_copy_data(THD *thd);
bool mysql_trans_commit_alter_copy_data(THD *thd);
-bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
+bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
HA_CREATE_INFO *create_info,
TABLE_LIST *table_list,
Alter_info *alter_info,
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 804a6b5c493..33a82883f8f 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -135,7 +135,8 @@ void TEST_filesort(SORT_FIELD *sortorder,uint s_length)
out.append(*sortorder->field->table_name);
out.append('.');
}
- out.append(sortorder->field->field_name ? sortorder->field->field_name:
+ out.append(sortorder->field->field_name.str ?
+ sortorder->field->field_name.str :
"tmp_table_column");
}
else
@@ -236,11 +237,11 @@ static void print_keyuse(KEYUSE *keyuse)
keyuse->val->print(&str, QT_ORDINARY);
str.append('\0');
if (keyuse->is_for_hash_join())
- fieldname= keyuse->table->field[keyuse->keypart]->field_name;
+ fieldname= keyuse->table->field[keyuse->keypart]->field_name.str;
else if (keyuse->keypart == FT_KEYPART)
fieldname= "FT_KEYPART";
else
- fieldname= key_info->key_part[keyuse->keypart].field->field_name;
+ fieldname= key_info->key_part[keyuse->keypart].field->field_name.str;
ll2str(keyuse->used_tables, buf2, 16, 0);
fprintf(DBUG_FILE, "KEYUSE: %s.%s=%s optimize: %u used_tables: %s "
"ref_table_rows: %lu keypart_map: %0lx\n",
diff --git a/sql/sql_time.cc b/sql/sql_time.cc
index cad4bae03e8..c8ec1fc7f6a 100644
--- a/sql/sql_time.cc
+++ b/sql/sql_time.cc
@@ -40,27 +40,27 @@
See also interval_type, interval_names
*/
-LEX_STRING interval_type_to_name[INTERVAL_LAST] = {
- { C_STRING_WITH_LEN("YEAR")},
- { C_STRING_WITH_LEN("QUARTER")},
- { C_STRING_WITH_LEN("MONTH")},
- { C_STRING_WITH_LEN("WEEK")},
- { C_STRING_WITH_LEN("DAY")},
- { C_STRING_WITH_LEN("HOUR")},
- { C_STRING_WITH_LEN("MINUTE")},
- { C_STRING_WITH_LEN("SECOND")},
- { C_STRING_WITH_LEN("MICROSECOND")},
- { C_STRING_WITH_LEN("YEAR_MONTH")},
- { C_STRING_WITH_LEN("DAY_HOUR")},
- { C_STRING_WITH_LEN("DAY_MINUTE")},
- { C_STRING_WITH_LEN("DAY_SECOND")},
- { C_STRING_WITH_LEN("HOUR_MINUTE")},
- { C_STRING_WITH_LEN("HOUR_SECOND")},
- { C_STRING_WITH_LEN("MINUTE_SECOND")},
- { C_STRING_WITH_LEN("DAY_MICROSECOND")},
- { C_STRING_WITH_LEN("HOUR_MICROSECOND")},
- { C_STRING_WITH_LEN("MINUTE_MICROSECOND")},
- { C_STRING_WITH_LEN("SECOND_MICROSECOND")}
+LEX_CSTRING interval_type_to_name[INTERVAL_LAST] = {
+ { STRING_WITH_LEN("YEAR")},
+ { STRING_WITH_LEN("QUARTER")},
+ { STRING_WITH_LEN("MONTH")},
+ { STRING_WITH_LEN("WEEK")},
+ { STRING_WITH_LEN("DAY")},
+ { STRING_WITH_LEN("HOUR")},
+ { STRING_WITH_LEN("MINUTE")},
+ { STRING_WITH_LEN("SECOND")},
+ { STRING_WITH_LEN("MICROSECOND")},
+ { STRING_WITH_LEN("YEAR_MONTH")},
+ { STRING_WITH_LEN("DAY_HOUR")},
+ { STRING_WITH_LEN("DAY_MINUTE")},
+ { STRING_WITH_LEN("DAY_SECOND")},
+ { STRING_WITH_LEN("HOUR_MINUTE")},
+ { STRING_WITH_LEN("HOUR_SECOND")},
+ { STRING_WITH_LEN("MINUTE_SECOND")},
+ { STRING_WITH_LEN("DAY_MICROSECOND")},
+ { STRING_WITH_LEN("HOUR_MICROSECOND")},
+ { STRING_WITH_LEN("MINUTE_MICROSECOND")},
+ { STRING_WITH_LEN("SECOND_MICROSECOND")}
};
/* Calc weekday from daynr */
diff --git a/sql/sql_time.h b/sql/sql_time.h
index e0cab5cfa66..03e38c158f6 100644
--- a/sql/sql_time.h
+++ b/sql/sql_time.h
@@ -203,7 +203,7 @@ extern DATE_TIME_FORMAT global_date_format;
extern DATE_TIME_FORMAT global_datetime_format;
extern DATE_TIME_FORMAT global_time_format;
extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-extern LEX_STRING interval_type_to_name[];
+extern LEX_CSTRING interval_type_to_name[];
static inline bool
non_zero_hhmmssuu(const MYSQL_TIME *ltime)
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index d804e568b79..1d0d3341b37 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -34,8 +34,9 @@
#include "sp_cache.h" // sp_invalidate_cache
#include <mysys_err.h>
-LEX_STRING *make_lex_string(LEX_STRING *lex_str, const char* str, uint length,
- MEM_ROOT *mem_root)
+LEX_CSTRING *make_lex_string(LEX_CSTRING *lex_str,
+ const char* str, uint length,
+ MEM_ROOT *mem_root)
{
if (!(lex_str->str= strmake_root(mem_root, str, length)))
return 0;
@@ -56,9 +57,9 @@ public:
static Trigger_creation_ctx *create(THD *thd,
const char *db_name,
const char *table_name,
- const LEX_STRING *client_cs_name,
- const LEX_STRING *connection_cl_name,
- const LEX_STRING *db_cl_name);
+ const LEX_CSTRING *client_cs_name,
+ const LEX_CSTRING *connection_cl_name,
+ const LEX_CSTRING *db_cl_name);
Trigger_creation_ctx(CHARSET_INFO *client_cs,
CHARSET_INFO *connection_cl,
@@ -92,9 +93,9 @@ Trigger_creation_ctx *
Trigger_creation_ctx::create(THD *thd,
const char *db_name,
const char *table_name,
- const LEX_STRING *client_cs_name,
- const LEX_STRING *connection_cl_name,
- const LEX_STRING *db_cl_name)
+ const LEX_CSTRING *client_cs_name,
+ const LEX_CSTRING *connection_cl_name,
+ const LEX_CSTRING *db_cl_name)
{
CHARSET_INFO *client_cs;
CHARSET_INFO *connection_cl;
@@ -162,7 +163,7 @@ Trigger_creation_ctx::create(THD *thd,
/*************************************************************************/
-static const LEX_STRING triggers_file_type=
+static const LEX_CSTRING triggers_file_type=
{ C_STRING_WITH_LEN("TRIGGERS") };
const char * const TRG_EXT= ".TRG";
@@ -176,37 +177,37 @@ const char * const TRG_EXT= ".TRG";
static File_option triggers_file_parameters[]=
{
{
- { C_STRING_WITH_LEN("triggers") },
+ { STRING_WITH_LEN("triggers") },
my_offsetof(class Table_triggers_list, definitions_list),
FILE_OPTIONS_STRLIST
},
{
- { C_STRING_WITH_LEN("sql_modes") },
+ { STRING_WITH_LEN("sql_modes") },
my_offsetof(class Table_triggers_list, definition_modes_list),
FILE_OPTIONS_ULLLIST
},
{
- { C_STRING_WITH_LEN("definers") },
+ { STRING_WITH_LEN("definers") },
my_offsetof(class Table_triggers_list, definers_list),
FILE_OPTIONS_STRLIST
},
{
- { C_STRING_WITH_LEN("client_cs_names") },
+ { STRING_WITH_LEN("client_cs_names") },
my_offsetof(class Table_triggers_list, client_cs_names),
FILE_OPTIONS_STRLIST
},
{
- { C_STRING_WITH_LEN("connection_cl_names") },
+ { STRING_WITH_LEN("connection_cl_names") },
my_offsetof(class Table_triggers_list, connection_cl_names),
FILE_OPTIONS_STRLIST
},
{
- { C_STRING_WITH_LEN("db_cl_names") },
+ { STRING_WITH_LEN("db_cl_names") },
my_offsetof(class Table_triggers_list, db_cl_names),
FILE_OPTIONS_STRLIST
},
{
- { C_STRING_WITH_LEN("created") },
+ { STRING_WITH_LEN("created") },
my_offsetof(class Table_triggers_list, create_times),
FILE_OPTIONS_ULLLIST
},
@@ -215,7 +216,7 @@ static File_option triggers_file_parameters[]=
File_option sql_modes_parameters=
{
- { C_STRING_WITH_LEN("sql_modes") },
+ { STRING_WITH_LEN("sql_modes") },
my_offsetof(class Table_triggers_list, definition_modes_list),
FILE_OPTIONS_ULLLIST
};
@@ -238,18 +239,18 @@ static const int TRG_NUM_REQUIRED_PARAMETERS= 7;
struct st_trigname
{
- LEX_STRING trigger_table;
+ LEX_CSTRING trigger_table;
};
-static const LEX_STRING trigname_file_type=
- { C_STRING_WITH_LEN("TRIGGERNAME") };
+static const LEX_CSTRING trigname_file_type=
+ { STRING_WITH_LEN("TRIGGERNAME") };
const char * const TRN_EXT= ".TRN";
static File_option trigname_file_parameters[]=
{
{
- { C_STRING_WITH_LEN("trigger_table")},
+ { STRING_WITH_LEN("trigger_table")},
offsetof(struct st_trigname, trigger_table),
FILE_OPTIONS_ESTRING
},
@@ -260,9 +261,9 @@ static File_option trigname_file_parameters[]=
class Handle_old_incorrect_sql_modes_hook: public Unknown_key_hook
{
private:
- char *path;
+ const char *path;
public:
- Handle_old_incorrect_sql_modes_hook(char *file_path)
+ Handle_old_incorrect_sql_modes_hook(const char *file_path)
:path(file_path)
{};
virtual bool process_unknown_string(const char *&unknown_key, uchar* base,
@@ -273,15 +274,15 @@ public:
class Handle_old_incorrect_trigger_table_hook: public Unknown_key_hook
{
public:
- Handle_old_incorrect_trigger_table_hook(char *file_path,
- LEX_STRING *trigger_table_arg)
+ Handle_old_incorrect_trigger_table_hook(const char *file_path,
+ LEX_CSTRING *trigger_table_arg)
:path(file_path), trigger_table_value(trigger_table_arg)
{};
virtual bool process_unknown_string(const char *&unknown_key, uchar* base,
MEM_ROOT *mem_root, const char *end);
private:
- char *path;
- LEX_STRING *trigger_table_value;
+ const char *path;
+ LEX_CSTRING *trigger_table_value;
};
@@ -299,7 +300,7 @@ class Deprecated_trigger_syntax_handler : public Internal_error_handler
private:
char m_message[MYSQL_ERRMSG_SIZE];
- LEX_STRING *m_trigger_name;
+ LEX_CSTRING *m_trigger_name;
public:
@@ -329,7 +330,7 @@ public:
return false;
}
- LEX_STRING *get_trigger_name() { return m_trigger_name; }
+ LEX_CSTRING *get_trigger_name() { return m_trigger_name; }
char *get_error_message() { return m_message; }
};
@@ -643,10 +644,10 @@ end:
static void build_trig_stmt_query(THD *thd, TABLE_LIST *tables,
String *stmt_query, String *trigger_def,
- LEX_STRING *trg_definer,
+ LEX_CSTRING *trg_definer,
char trg_definer_holder[])
{
- LEX_STRING stmt_definition;
+ LEX_CSTRING stmt_definition;
LEX *lex= thd->lex;
uint prefix_trimmed, suffix_trimmed;
size_t original_length;
@@ -671,7 +672,7 @@ static void build_trig_stmt_query(THD *thd, TABLE_LIST *tables,
}
else
{
- *trg_definer= empty_lex_str;
+ *trg_definer= empty_clex_str;
}
@@ -736,7 +737,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
LEX *lex= thd->lex;
TABLE *table= tables->table;
char file_buff[FN_REFLEN], trigname_buff[FN_REFLEN];
- LEX_STRING file, trigname_file;
+ LEX_CSTRING file, trigname_file;
char trg_definer_holder[USER_HOST_BUFF_SIZE];
Item_trigger_field *trg_field;
struct st_trigname trigname;
@@ -839,7 +840,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
ER_TRG_ALREADY_EXISTS,
ER_THD(thd, ER_TRG_ALREADY_EXISTS),
trigname_buff);
- LEX_STRING trg_definer_tmp;
+ LEX_CSTRING trg_definer_tmp;
String trigger_def;
/*
@@ -1050,7 +1051,7 @@ bool Table_triggers_list::save_trigger_file(THD *thd, const char *db,
const char *table_name)
{
char file_buff[FN_REFLEN];
- LEX_STRING file;
+ LEX_CSTRING file;
if (create_lists_needed_for_files(thd->mem_root))
return true;
@@ -1070,7 +1071,7 @@ bool Table_triggers_list::save_trigger_file(THD *thd, const char *db,
@param remove_from_list If set, remove trigger if found
*/
-Trigger *Table_triggers_list::find_trigger(const LEX_STRING *name,
+Trigger *Table_triggers_list::find_trigger(const LEX_CSTRING *name,
bool remove_from_list)
{
for (uint i= 0; i < (uint)TRG_EVENT_MAX; i++)
@@ -1125,7 +1126,7 @@ Trigger *Table_triggers_list::find_trigger(const LEX_STRING *name,
bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables,
String *stmt_query)
{
- const LEX_STRING *sp_name= &thd->lex->spname->m_name; // alias
+ const LEX_CSTRING *sp_name= &thd->lex->spname->m_name; // alias
char path[FN_REFLEN];
Trigger *trigger;
@@ -1298,7 +1299,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
bool names_only)
{
char path_buff[FN_REFLEN];
- LEX_STRING path;
+ LEX_CSTRING path;
File_parser *parser;
LEX_STRING save_db;
DBUG_ENTER("Table_triggers_list::check_n_load");
@@ -1318,7 +1319,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
if (is_equal(&triggers_file_type, parser->type()))
{
Handle_old_incorrect_sql_modes_hook sql_modes_hook(path.str);
- LEX_STRING *trg_create_str;
+ LEX_CSTRING *trg_create_str;
ulonglong *trg_sql_mode, *trg_create_time;
Trigger *trigger;
Table_triggers_list *trigger_list=
@@ -1332,7 +1333,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
&sql_modes_hook))
goto error;
- List_iterator_fast<LEX_STRING> it(trigger_list->definitions_list);
+ List_iterator_fast<LEX_CSTRING> it(trigger_list->definitions_list);
if (!trigger_list->definitions_list.is_empty() &&
(trigger_list->client_cs_names.is_empty() ||
@@ -1351,10 +1352,10 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
status_var_increment(thd->status_var.feature_trigger);
List_iterator_fast<ulonglong> itm(trigger_list->definition_modes_list);
- List_iterator_fast<LEX_STRING> it_definer(trigger_list->definers_list);
- List_iterator_fast<LEX_STRING> it_client_cs_name(trigger_list->client_cs_names);
- List_iterator_fast<LEX_STRING> it_connection_cl_name(trigger_list->connection_cl_names);
- List_iterator_fast<LEX_STRING> it_db_cl_name(trigger_list->db_cl_names);
+ List_iterator_fast<LEX_CSTRING> it_definer(trigger_list->definers_list);
+ List_iterator_fast<LEX_CSTRING> it_client_cs_name(trigger_list->client_cs_names);
+ List_iterator_fast<LEX_CSTRING> it_connection_cl_name(trigger_list->connection_cl_names);
+ List_iterator_fast<LEX_CSTRING> it_db_cl_name(trigger_list->db_cl_names);
List_iterator_fast<ulonglong> it_create_times(trigger_list->create_times);
LEX *old_lex= thd->lex, lex;
sp_rcontext *save_spcont= thd->spcont;
@@ -1369,7 +1370,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
{
sp_head *sp;
sql_mode_t sql_mode;
- LEX_STRING *trg_definer;
+ LEX_CSTRING *trg_definer;
Trigger_creation_ctx *creation_ctx;
/*
@@ -1386,7 +1387,8 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
thd->variables.sql_mode= sql_mode;
Parser_state parser_state;
- if (parser_state.init(thd, trg_create_str->str, trg_create_str->length))
+ if (parser_state.init(thd, (char*) trg_create_str->str,
+ trg_create_str->length))
goto err_with_lex_cleanup;
if (!trigger_list->client_cs_names.is_empty())
@@ -1441,7 +1443,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
trigger->sql_mode= sql_mode;
trigger->definition= *trg_create_str;
trigger->create_time= trg_create_time ? *trg_create_time : 0;
- trigger->name= sp ? sp->m_name : empty_lex_str;
+ trigger->name= sp ? sp->m_name : empty_clex_str;
trigger->on_table_name.str= (char*) lex.raw_trg_on_table_name_begin;
trigger->on_table_name.length= (lex.raw_trg_on_table_name_end -
lex.raw_trg_on_table_name_begin);
@@ -1464,7 +1466,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
if (parse_error)
{
- LEX_STRING *name;
+ LEX_CSTRING *name;
/*
In case of errors, disable all triggers for the table, but keep
@@ -1483,7 +1485,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
goto err_with_lex_cleanup;
}
trigger->definer= ((!trg_definer || !trg_definer->length) ?
- empty_lex_str : *trg_definer);
+ empty_clex_str : *trg_definer);
continue;
}
@@ -1509,8 +1511,8 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
schema.
*/
- sp->set_definer((char*) "", 0);
- trigger->definer= empty_lex_str;
+ sp->set_definer("", 0);
+ trigger->definer= empty_clex_str;
/*
trigger_list without definer information are executed under the
@@ -1622,7 +1624,7 @@ error:
void Table_triggers_list::add_trigger(trg_event_type event,
trg_action_time_type action_time,
trigger_order_type ordering_clause,
- LEX_STRING *anchor_trigger_name,
+ LEX_CSTRING *anchor_trigger_name,
Trigger *trigger)
{
Trigger **parent= &triggers[event][action_time];
@@ -1673,8 +1675,9 @@ void Table_triggers_list::add_trigger(trg_event_type event,
True error
*/
-void Trigger::get_trigger_info(LEX_STRING *trigger_stmt,
- LEX_STRING *trigger_body, LEX_STRING *definer)
+void Trigger::get_trigger_info(LEX_CSTRING *trigger_stmt,
+ LEX_CSTRING *trigger_body,
+ LEX_STRING *definer)
{
DBUG_ENTER("get_trigger_info");
@@ -1726,7 +1729,7 @@ bool add_table_for_trigger(THD *thd,
LEX *lex= thd->lex;
char trn_path_buff[FN_REFLEN];
LEX_STRING trn_path= { trn_path_buff, 0 };
- LEX_STRING tbl_name= null_lex_str;
+ LEX_CSTRING tbl_name= null_clex_str;
DBUG_ENTER("add_table_for_trigger");
@@ -1750,7 +1753,8 @@ bool add_table_for_trigger(THD *thd,
DBUG_RETURN(TRUE);
}
- if (load_table_name_for_trigger(thd, trg_name, &trn_path, &tbl_name))
+ if (load_table_name_for_trigger(thd, trg_name, (LEX_CSTRING*) &trn_path,
+ &tbl_name))
DBUG_RETURN(TRUE);
*table= sp_add_to_query_tables(thd, lex, trg_name->m_db.str,
@@ -1774,7 +1778,8 @@ bool add_table_for_trigger(THD *thd,
True error
*/
-bool Table_triggers_list::drop_all_triggers(THD *thd, char *db, char *name)
+bool Table_triggers_list::drop_all_triggers(THD *thd, const char *db,
+ const char *name)
{
TABLE table;
char path[FN_REFLEN];
@@ -1848,7 +1853,7 @@ struct change_table_name_param
THD *thd;
const char *old_db_name;
const char *new_db_name;
- LEX_STRING *new_table_name;
+ LEX_CSTRING *new_table_name;
Trigger *stopper;
};
@@ -1857,8 +1862,8 @@ bool
Table_triggers_list::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)
{
struct change_table_name_param param;
sql_mode_t save_sql_mode= thd->variables.sql_mode;
@@ -1890,9 +1895,8 @@ bool Trigger::change_table_name(void* param_arg)
{
change_table_name_param *param= (change_table_name_param*) param_arg;
THD *thd= param->thd;
- LEX_STRING *new_table_name= param->new_table_name;
-
- LEX_STRING *def= &definition, new_def;
+ LEX_CSTRING *new_table_name= param->new_table_name;
+ LEX_CSTRING *def= &definition, new_def;
size_t on_q_table_name_len, before_on_len;
String buff;
@@ -1947,7 +1951,7 @@ bool Trigger::change_table_name(void* param_arg)
Trigger *
Table_triggers_list::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)
{
struct change_table_name_param param;
@@ -1966,7 +1970,7 @@ bool Trigger::change_on_table_name(void* param_arg)
char trigname_buff[FN_REFLEN];
struct st_trigname trigname;
- LEX_STRING trigname_file;
+ LEX_CSTRING trigname_file;
if (param->stopper == this)
return 0; // Stop processing
@@ -2056,8 +2060,8 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db,
result= 1;
goto end;
}
- LEX_STRING old_table_name= { (char *) old_alias, strlen(old_alias) };
- LEX_STRING new_table_name= { (char *) new_table, strlen(new_table) };
+ LEX_CSTRING old_table_name= { (char *) old_alias, strlen(old_alias) };
+ LEX_CSTRING new_table_name= { (char *) new_table, strlen(new_table) };
/*
Since triggers should be in the same schema as their subject tables
moving table with them between two schemas raises too many questions.
@@ -2468,16 +2472,14 @@ 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)
{
File_parser *parser;
struct st_trigname trn_data;
-
Handle_old_incorrect_trigger_table_hook trigger_table_hook(
trn_path->str,
&trn_data.trigger_table);
-
DBUG_ENTER("load_table_name_for_trigger");
/* Parse the TRN-file. */
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;
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc
index daa295d768e..d4859efc7af 100644
--- a/sql/sql_truncate.cc
+++ b/sql/sql_truncate.cc
@@ -38,11 +38,11 @@
*/
static bool fk_info_append_fields(THD *thd, String *str,
- List<LEX_STRING> *fields)
+ List<LEX_CSTRING> *fields)
{
bool res= FALSE;
- LEX_STRING *field;
- List_iterator_fast<LEX_STRING> it(*fields);
+ LEX_CSTRING *field;
+ List_iterator_fast<LEX_CSTRING> it(*fields);
while ((field= it++))
{
diff --git a/sql/sql_type.cc b/sql/sql_type.cc
index 6a150703831..43c27372546 100644
--- a/sql/sql_type.cc
+++ b/sql/sql_type.cc
@@ -739,7 +739,7 @@ Type_handler::make_num_distinct_aggregator_field(MEM_ROOT *mem_root,
Field_double(NULL, item->max_length,
(uchar *) (item->maybe_null ? "" : 0),
item->maybe_null ? 1 : 0, Field::NONE,
- item->name, item->decimals, 0, item->unsigned_flag);
+ &item->name, item->decimals, 0, item->unsigned_flag);
}
@@ -752,7 +752,7 @@ Type_handler_float::make_num_distinct_aggregator_field(MEM_ROOT *mem_root,
Field_float(NULL, item->max_length,
(uchar *) (item->maybe_null ? "" : 0),
item->maybe_null ? 1 : 0, Field::NONE,
- item->name, item->decimals, 0, item->unsigned_flag);
+ &item->name, item->decimals, 0, item->unsigned_flag);
}
@@ -767,7 +767,7 @@ Type_handler_decimal_result::make_num_distinct_aggregator_field(
Field_new_decimal(NULL, item->max_length,
(uchar *) (item->maybe_null ? "" : 0),
item->maybe_null ? 1 : 0, Field::NONE,
- item->name, item->decimals, 0, item->unsigned_flag);
+ &item->name, item->decimals, 0, item->unsigned_flag);
}
@@ -784,14 +784,12 @@ Type_handler_int_result::make_num_distinct_aggregator_field(MEM_ROOT *mem_root,
Field_longlong(NULL, item->max_length,
(uchar *) (item->maybe_null ? "" : 0),
item->maybe_null ? 1 : 0, Field::NONE,
- item->name, 0, item->unsigned_flag);
+ &item->name, 0, item->unsigned_flag);
}
/***********************************************************************/
-#define TMPNAME ""
-
Field *Type_handler_tiny::make_conversion_table_field(TABLE *table,
uint metadata,
const Field *target)
@@ -805,7 +803,7 @@ Field *Type_handler_tiny::make_conversion_table_field(TABLE *table,
bool unsigned_flag= ((Field_num*) target)->unsigned_flag;
return new (table->in_use->mem_root)
Field_tiny(NULL, 4 /*max_length*/, (uchar *) "", 1, Field::NONE,
- TMPNAME, 0/*zerofill*/, unsigned_flag);
+ &empty_clex_str, 0/*zerofill*/, unsigned_flag);
}
@@ -817,7 +815,7 @@ Field *Type_handler_short::make_conversion_table_field(TABLE *table,
bool unsigned_flag= ((Field_num*) target)->unsigned_flag;
return new (table->in_use->mem_root)
Field_short(NULL, 6 /*max_length*/, (uchar *) "", 1, Field::NONE,
- TMPNAME, 0/*zerofill*/, unsigned_flag);
+ &empty_clex_str, 0/*zerofill*/, unsigned_flag);
}
@@ -829,7 +827,7 @@ Field *Type_handler_int24::make_conversion_table_field(TABLE *table,
bool unsigned_flag= ((Field_num*) target)->unsigned_flag;
return new (table->in_use->mem_root)
Field_medium(NULL, 9 /*max_length*/, (uchar *) "", 1, Field::NONE,
- TMPNAME, 0/*zerofill*/, unsigned_flag);
+ &empty_clex_str, 0/*zerofill*/, unsigned_flag);
}
@@ -841,7 +839,7 @@ Field *Type_handler_long::make_conversion_table_field(TABLE *table,
bool unsigned_flag= ((Field_num*) target)->unsigned_flag;
return new (table->in_use->mem_root)
Field_long(NULL, 11 /*max_length*/, (uchar *) "", 1, Field::NONE,
- TMPNAME, 0/*zerofill*/, unsigned_flag);
+ &empty_clex_str, 0/*zerofill*/, unsigned_flag);
}
@@ -853,7 +851,7 @@ Field *Type_handler_longlong::make_conversion_table_field(TABLE *table,
bool unsigned_flag= ((Field_num*) target)->unsigned_flag;
return new (table->in_use->mem_root)
Field_longlong(NULL, 20 /*max_length*/,(uchar *) "", 1, Field::NONE,
- TMPNAME, 0/*zerofill*/, unsigned_flag);
+ &empty_clex_str, 0/*zerofill*/, unsigned_flag);
}
@@ -865,7 +863,7 @@ Field *Type_handler_float::make_conversion_table_field(TABLE *table,
{
return new (table->in_use->mem_root)
Field_float(NULL, 12 /*max_length*/, (uchar *) "", 1, Field::NONE,
- TMPNAME, 0/*dec*/, 0/*zerofill*/, 0/*unsigned_flag*/);
+ &empty_clex_str, 0/*dec*/, 0/*zerofill*/, 0/*unsigned_flag*/);
}
@@ -876,7 +874,7 @@ Field *Type_handler_double::make_conversion_table_field(TABLE *table,
{
return new (table->in_use->mem_root)
Field_double(NULL, 22 /*max_length*/, (uchar *) "", 1, Field::NONE,
- TMPNAME, 0/*dec*/, 0/*zerofill*/, 0/*unsigned_flag*/);
+ &empty_clex_str, 0/*dec*/, 0/*zerofill*/, 0/*unsigned_flag*/);
}
@@ -891,7 +889,7 @@ Field *Type_handler_newdecimal::make_conversion_table_field(TABLE *table,
DBUG_ASSERT(decimals <= DECIMAL_MAX_SCALE);
return new (table->in_use->mem_root)
Field_new_decimal(NULL, max_length, (uchar *) "", 1, Field::NONE,
- TMPNAME, decimals, 0/*zerofill*/, 0/*unsigned*/);
+ &empty_clex_str, decimals, 0/*zerofill*/, 0/*unsigned*/);
}
@@ -907,7 +905,7 @@ Field *Type_handler_olddecimal::make_conversion_table_field(TABLE *table,
" column Name: %s.%s.%s.",
target->table->s->db.str,
target->table->s->table_name.str,
- target->field_name);
+ target->field_name.str);
return NULL;
}
@@ -918,7 +916,7 @@ Field *Type_handler_year::make_conversion_table_field(TABLE *table,
const
{
return new(table->in_use->mem_root)
- Field_year(NULL, 4, (uchar *) "", 1, Field::NONE, TMPNAME);
+ Field_year(NULL, 4, (uchar *) "", 1, Field::NONE, &empty_clex_str);
}
@@ -928,7 +926,7 @@ Field *Type_handler_null::make_conversion_table_field(TABLE *table,
const
{
return new(table->in_use->mem_root)
- Field_null(NULL, 0, Field::NONE, TMPNAME, target->charset());
+ Field_null(NULL, 0, Field::NONE, &empty_clex_str, target->charset());
}
@@ -938,7 +936,7 @@ Field *Type_handler_timestamp::make_conversion_table_field(TABLE *table,
const
{
return new_Field_timestamp(table->in_use->mem_root, NULL, (uchar *) "", 1,
- Field::NONE, TMPNAME, table->s, target->decimals());
+ Field::NONE, &empty_clex_str, table->s, target->decimals());
}
@@ -949,7 +947,7 @@ Field *Type_handler_timestamp2::make_conversion_table_field(TABLE *table,
{
return new(table->in_use->mem_root)
Field_timestampf(NULL, (uchar *) "", 1, Field::NONE,
- TMPNAME, table->s, metadata);
+ &empty_clex_str, table->s, metadata);
}
@@ -959,7 +957,7 @@ Field *Type_handler_newdate::make_conversion_table_field(TABLE *table,
const
{
return new(table->in_use->mem_root)
- Field_newdate(NULL, (uchar *) "", 1, Field::NONE, TMPNAME);
+ Field_newdate(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str);
}
@@ -969,7 +967,7 @@ Field *Type_handler_date::make_conversion_table_field(TABLE *table,
const
{
return new(table->in_use->mem_root)
- Field_date(NULL, (uchar *) "", 1, Field::NONE, TMPNAME);
+ Field_date(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str);
}
@@ -979,7 +977,7 @@ Field *Type_handler_time::make_conversion_table_field(TABLE *table,
const
{
return new_Field_time(table->in_use->mem_root, NULL, (uchar *) "", 1,
- Field::NONE, TMPNAME, target->decimals());
+ Field::NONE, &empty_clex_str, target->decimals());
}
@@ -989,7 +987,7 @@ Field *Type_handler_time2::make_conversion_table_field(TABLE *table,
const
{
return new(table->in_use->mem_root)
- Field_timef(NULL, (uchar *) "", 1, Field::NONE, TMPNAME, metadata);
+ Field_timef(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, metadata);
}
@@ -999,7 +997,7 @@ Field *Type_handler_datetime::make_conversion_table_field(TABLE *table,
const
{
return new_Field_datetime(table->in_use->mem_root, NULL, (uchar *) "", 1,
- Field::NONE, TMPNAME, target->decimals());
+ Field::NONE, &empty_clex_str, target->decimals());
}
@@ -1010,7 +1008,7 @@ Field *Type_handler_datetime2::make_conversion_table_field(TABLE *table,
{
return new(table->in_use->mem_root)
Field_datetimef(NULL, (uchar *) "", 1,
- Field::NONE, TMPNAME, metadata);
+ Field::NONE, &empty_clex_str, metadata);
}
@@ -1023,7 +1021,7 @@ Field *Type_handler_bit::make_conversion_table_field(TABLE *table,
uint32 max_length= 8 * (metadata >> 8U) + (metadata & 0x00ff);
return new(table->in_use->mem_root)
Field_bit_as_char(NULL, max_length, (uchar *) "", 1,
- Field::NONE, TMPNAME);
+ Field::NONE, &empty_clex_str);
}
@@ -1036,7 +1034,7 @@ Field *Type_handler_string::make_conversion_table_field(TABLE *table,
uint32 max_length= (((metadata >> 4) & 0x300) ^ 0x300) + (metadata & 0x00ff);
return new(table->in_use->mem_root)
Field_string(NULL, max_length, (uchar *) "", 1,
- Field::NONE, TMPNAME, target->charset());
+ Field::NONE, &empty_clex_str, target->charset());
}
@@ -1047,7 +1045,7 @@ Field *Type_handler_varchar::make_conversion_table_field(TABLE *table,
{
return new(table->in_use->mem_root)
Field_varstring(NULL, metadata, HA_VARCHAR_PACKLENGTH(metadata),
- (uchar *) "", 1, Field::NONE, TMPNAME,
+ (uchar *) "", 1, Field::NONE, &empty_clex_str,
table->s, target->charset());
}
@@ -1058,7 +1056,7 @@ Field *Type_handler_tiny_blob::make_conversion_table_field(TABLE *table,
const
{
return new(table->in_use->mem_root)
- Field_blob(NULL, (uchar *) "", 1, Field::NONE, TMPNAME,
+ Field_blob(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str,
table->s, 1, target->charset());
}
@@ -1069,7 +1067,7 @@ Field *Type_handler_blob::make_conversion_table_field(TABLE *table,
const
{
return new(table->in_use->mem_root)
- Field_blob(NULL, (uchar *) "", 1, Field::NONE, TMPNAME,
+ Field_blob(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str,
table->s, 2, target->charset());
}
@@ -1080,7 +1078,7 @@ Field *Type_handler_medium_blob::make_conversion_table_field(TABLE *table,
const
{
return new(table->in_use->mem_root)
- Field_blob(NULL, (uchar *) "", 1, Field::NONE, TMPNAME,
+ Field_blob(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str,
table->s, 3, target->charset());
}
@@ -1091,7 +1089,7 @@ Field *Type_handler_long_blob::make_conversion_table_field(TABLE *table,
const
{
return new(table->in_use->mem_root)
- Field_blob(NULL, (uchar *) "", 1, Field::NONE, TMPNAME,
+ Field_blob(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str,
table->s, 4, target->charset());
}
@@ -1119,7 +1117,7 @@ Field *Type_handler_geometry::make_conversion_table_field(TABLE *table,
The statistics was already incremented when "target" was created.
*/
return new(table->in_use->mem_root)
- Field_geom(NULL, (uchar *) "", 1, Field::NONE, TMPNAME, table->s, 4,
+ Field_geom(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, table->s, 4,
((const Field_geom*) target)->geom_type,
((const Field_geom*) target)->srid);
}
@@ -1134,7 +1132,7 @@ Field *Type_handler_enum::make_conversion_table_field(TABLE *table,
DBUG_ASSERT(target->real_type() == MYSQL_TYPE_ENUM);
return new(table->in_use->mem_root)
Field_enum(NULL, target->field_length,
- (uchar *) "", 1, Field::NONE, TMPNAME,
+ (uchar *) "", 1, Field::NONE, &empty_clex_str,
metadata & 0x00ff/*pack_length()*/,
((const Field_enum*) target)->typelib, target->charset());
}
@@ -1149,7 +1147,7 @@ Field *Type_handler_set::make_conversion_table_field(TABLE *table,
DBUG_ASSERT(target->real_type() == MYSQL_TYPE_SET);
return new(table->in_use->mem_root)
Field_set(NULL, target->field_length,
- (uchar *) "", 1, Field::NONE, TMPNAME,
+ (uchar *) "", 1, Field::NONE, &empty_clex_str,
metadata & 0x00ff/*pack_length()*/,
((const Field_enum*) target)->typelib, target->charset());
}
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 05698ce82cc..612cc97f6a2 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -54,12 +54,12 @@ static HASH udf_hash;
static mysql_rwlock_t THR_LOCK_udf;
-static udf_func *add_udf(LEX_STRING *name, Item_result ret,
- char *dl, Item_udftype typ);
+static udf_func *add_udf(LEX_CSTRING *name, Item_result ret,
+ const char *dl, Item_udftype typ);
static void del_udf(udf_func *udf);
static void *find_udf_dl(const char *dl);
-static char *init_syms(udf_func *tmp, char *nm)
+static const char *init_syms(udf_func *tmp, char *nm)
{
char *end;
@@ -192,7 +192,7 @@ void udf_init()
while (!(error= read_record_info.read_record(&read_record_info)))
{
DBUG_PRINT("info",("init udf record"));
- LEX_STRING name;
+ LEX_CSTRING name;
name.str=get_field(&mem, table->field[0]);
name.length = (uint) strlen(name.str);
char *dl_name= get_field(&mem, table->field[2]);
@@ -242,7 +242,8 @@ void udf_init()
}
tmp->dlhandle = dl;
{
- char buf[SAFE_NAME_LEN+16], *missing;
+ char buf[SAFE_NAME_LEN+16];
+ const char *missing;
if ((missing= init_syms(tmp, buf)))
{
sql_print_error(ER_THD(new_thd, ER_CANT_FIND_DL_ENTRY), missing);
@@ -311,9 +312,9 @@ static void del_udf(udf_func *udf)
The functions will be automaticly removed when the least threads
doesn't use it anymore
*/
- char *name= udf->name.str;
+ const char *name= udf->name.str;
uint name_length=udf->name.length;
- udf->name.str=(char*) "*";
+ udf->name.str= "*";
udf->name.length=1;
my_hash_update(&udf_hash,(uchar*) udf,(uchar*) name,name_length);
}
@@ -351,6 +352,7 @@ udf_func *find_udf(const char *name,uint length,bool mark_used)
{
udf_func *udf=0;
DBUG_ENTER("find_udf");
+ DBUG_ASSERT(strlen(name) == length);
if (!initialized)
DBUG_RETURN(NULL);
@@ -362,8 +364,7 @@ udf_func *find_udf(const char *name,uint length,bool mark_used)
else
mysql_rwlock_rdlock(&THR_LOCK_udf); /* Called during parsing */
- if ((udf=(udf_func*) my_hash_search(&udf_hash,(uchar*) name,
- length ? length : (uint) strlen(name))))
+ if ((udf=(udf_func*) my_hash_search(&udf_hash,(uchar*) name, length)))
{
if (!udf->dlhandle)
udf=0; // Could not be opened
@@ -395,7 +396,7 @@ static void *find_udf_dl(const char *dl)
/* Assume that name && dl is already allocated */
-static udf_func *add_udf(LEX_STRING *name, Item_result ret, char *dl,
+static udf_func *add_udf(LEX_CSTRING *name, Item_result ret, const char *dl,
Item_udftype type)
{
if (!name || !dl || !(uint) type || (uint) type > (uint) UDFTYPE_AGGREGATE)
@@ -431,7 +432,7 @@ static int mysql_drop_function_internal(THD *thd, udf_func *udf, TABLE *table)
{
DBUG_ENTER("mysql_drop_function_internal");
- char *exact_name_str= udf->name.str;
+ const char *exact_name_str= udf->name.str;
uint exact_name_len= udf->name.length;
del_udf(udf);
@@ -548,7 +549,8 @@ int mysql_create_function(THD *thd,udf_func *udf)
}
udf->dlhandle=dl;
{
- char buf[SAFE_NAME_LEN+16], *missing;
+ char buf[SAFE_NAME_LEN+16];
+ const char *missing;
if ((missing= init_syms(udf, buf)))
{
my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), missing);
@@ -604,7 +606,7 @@ err:
}
-int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
+int mysql_drop_function(THD *thd, const LEX_CSTRING *udf_name)
{
TABLE *table;
TABLE_LIST tables;
diff --git a/sql/sql_udf.h b/sql/sql_udf.h
index d3ec1cc1f95..1c805227f97 100644
--- a/sql/sql_udf.h
+++ b/sql/sql_udf.h
@@ -37,10 +37,10 @@ typedef longlong (*Udf_func_longlong)(UDF_INIT *, UDF_ARGS *, uchar *,
typedef struct st_udf_func
{
- LEX_STRING name;
+ LEX_CSTRING name;
Item_result returns;
Item_udftype type;
- char *dl;
+ const char *dl;
void *dlhandle;
Udf_func_any func;
Udf_func_init func_init;
@@ -137,10 +137,10 @@ class udf_handler :public Sql_alloc
#ifdef HAVE_DLOPEN
void udf_init(void),udf_free(void);
-udf_func *find_udf(const char *name, uint len=0,bool mark_used=0);
+udf_func *find_udf(const char *name, uint len, bool mark_used=0);
void free_udf(udf_func *udf);
int mysql_create_function(THD *thd,udf_func *udf);
-int mysql_drop_function(THD *thd,const LEX_STRING *name);
+int mysql_drop_function(THD *thd, const LEX_CSTRING *name);
#else
static inline void udf_init(void) { }
static inline void udf_free(void) { }
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 8390699511c..d90b0c7aa68 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -976,7 +976,8 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
else
intersect_mark->value= 0; //reset
types.push_front(union_result->intersect_mark= intersect_mark);
- union_result->intersect_mark->name= (char *)"___";
+ union_result->intersect_mark->name.str= "___";
+ union_result->intersect_mark->name.length= 3;
}
bool error=
union_result->create_result_table(thd, &types,
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 35e1fe24b97..568dd40df46 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -140,7 +140,7 @@ static bool check_fields(THD *thd, List<Item> &items)
if (!(field= item->field_for_view_update()))
{
/* item has name, because it comes from VIEW SELECT list */
- my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name.str);
return TRUE;
}
/*
@@ -1992,6 +1992,9 @@ loop_end:
TABLE *tbl= table;
do
{
+ LEX_CSTRING field_name;
+ field_name.str= tbl->alias.c_ptr();
+ field_name.length= strlen(field_name.str);
/*
Signal each table (including tables referenced by WITH CHECK OPTION
clause) for which we will store row position in the temporary table
@@ -2000,7 +2003,7 @@ loop_end:
tbl->prepare_for_position();
Field_string *field= new Field_string(tbl->file->ref_length, 0,
- tbl->alias.c_ptr(),
+ &field_name,
&my_charset_bin);
if (!field)
DBUG_RETURN(1);
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 1d6fe38b66b..447d80b8b00 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -39,7 +39,7 @@
#define MD5_BUFF_LENGTH 33
-const LEX_STRING view_type= { C_STRING_WITH_LEN("VIEW") };
+const LEX_CSTRING view_type= { STRING_WITH_LEN("VIEW") };
static int mysql_register_view(THD *, TABLE_LIST *, enum_view_create_mode);
@@ -63,9 +63,9 @@ static void make_unique_view_field_name(THD *thd, Item *target,
List<Item> &item_list,
Item *last_element)
{
- char *name= (target->orig_name ?
- target->orig_name :
- target->name);
+ const char *name= (target->orig_name ?
+ target->orig_name :
+ target->name.str);
size_t name_len;
uint attempt;
char buff[NAME_LEN+1];
@@ -85,7 +85,7 @@ static void make_unique_view_field_name(THD *thd, Item *target,
{
check= itc++;
if (check != target &&
- my_strcasecmp(system_charset_info, buff, check->name) == 0)
+ my_strcasecmp(system_charset_info, buff, check->name.str) == 0)
{
ok= FALSE;
break;
@@ -96,7 +96,7 @@ static void make_unique_view_field_name(THD *thd, Item *target,
itc.rewind();
}
- target->orig_name= target->name;
+ target->orig_name= target->name.str;
target->set_name(thd, buff, name_len, system_charset_info);
}
@@ -140,7 +140,7 @@ bool check_duplicate_names(THD *thd, List<Item> &item_list, bool gen_unique_view
itc.rewind();
while ((check= itc++) && check != item)
{
- if (my_strcasecmp(system_charset_info, item->name, check->name) == 0)
+ if (my_strcasecmp(system_charset_info, item->name.str, check->name.str) == 0)
{
if (!gen_unique_view_name)
goto err;
@@ -178,10 +178,10 @@ void make_valid_column_names(THD *thd, List<Item> &item_list)
for (uint column_no= 1; (item= it++); column_no++)
{
- if (!item->is_autogenerated_name || !check_column_name(item->name))
+ if (!item->is_autogenerated_name || !check_column_name(item->name.str))
continue;
name_len= my_snprintf(buff, NAME_LEN, "Name_exp_%u", column_no);
- item->orig_name= item->name;
+ item->orig_name= item->name.str;
item->set_name(thd, buff, name_len, system_charset_info);
}
@@ -602,7 +602,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
{
Item_field *fld= item->field_for_view_update();
uint priv= (get_column_grant(thd, &view->grant, view->db,
- view->table_name, item->name) &
+ view->table_name, item->name.str) &
VIEW_ANY_ACL);
if (fld && !fld->field->table->s->tmp_table)
@@ -620,7 +620,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
{
my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
"create view", thd->security_ctx->priv_user,
- thd->security_ctx->priv_host, report_item->name,
+ thd->security_ctx->priv_host, report_item->name.str,
view->table_name);
res= TRUE;
goto err;
@@ -711,11 +711,11 @@ err:
}
-static void make_view_filename(LEX_STRING *dir, char *dir_buff,
+static void make_view_filename(LEX_CSTRING *dir, char *dir_buff,
size_t dir_buff_len,
- LEX_STRING *path, char *path_buff,
+ LEX_CSTRING *path, char *path_buff,
size_t path_buff_len,
- LEX_STRING *file,
+ LEX_CSTRING *file,
TABLE_LIST *view)
{
/* print file name */
@@ -741,37 +741,37 @@ static const int required_view_parameters= 15;
parse()
*/
static File_option view_parameters[]=
-{{{ C_STRING_WITH_LEN("query")},
+{{{ STRING_WITH_LEN("query")},
my_offsetof(TABLE_LIST, select_stmt),
FILE_OPTIONS_ESTRING},
- {{ C_STRING_WITH_LEN("md5")},
+ {{ STRING_WITH_LEN("md5")},
my_offsetof(TABLE_LIST, md5),
FILE_OPTIONS_STRING},
- {{ C_STRING_WITH_LEN("updatable")},
+ {{ STRING_WITH_LEN("updatable")},
my_offsetof(TABLE_LIST, updatable_view),
FILE_OPTIONS_ULONGLONG},
- {{ C_STRING_WITH_LEN("algorithm")},
+ {{ STRING_WITH_LEN("algorithm")},
my_offsetof(TABLE_LIST, algorithm),
FILE_OPTIONS_VIEW_ALGO},
- {{ C_STRING_WITH_LEN("definer_user")},
+ {{ STRING_WITH_LEN("definer_user")},
my_offsetof(TABLE_LIST, definer.user),
FILE_OPTIONS_STRING},
- {{ C_STRING_WITH_LEN("definer_host")},
+ {{ STRING_WITH_LEN("definer_host")},
my_offsetof(TABLE_LIST, definer.host),
FILE_OPTIONS_STRING},
- {{ C_STRING_WITH_LEN("suid")},
+ {{ STRING_WITH_LEN("suid")},
my_offsetof(TABLE_LIST, view_suid),
FILE_OPTIONS_ULONGLONG},
- {{ C_STRING_WITH_LEN("with_check_option")},
+ {{ STRING_WITH_LEN("with_check_option")},
my_offsetof(TABLE_LIST, with_check),
FILE_OPTIONS_ULONGLONG},
- {{ C_STRING_WITH_LEN("timestamp")},
+ {{ STRING_WITH_LEN("timestamp")},
my_offsetof(TABLE_LIST, timestamp),
FILE_OPTIONS_TIMESTAMP},
- {{ C_STRING_WITH_LEN("create-version")},
+ {{ STRING_WITH_LEN("create-version")},
my_offsetof(TABLE_LIST, file_version),
FILE_OPTIONS_ULONGLONG},
- {{ C_STRING_WITH_LEN("source")},
+ {{ STRING_WITH_LEN("source")},
my_offsetof(TABLE_LIST, source),
FILE_OPTIONS_ESTRING},
{{(char*) STRING_WITH_LEN("client_cs_name")},
@@ -783,21 +783,21 @@ static File_option view_parameters[]=
{{(char*) STRING_WITH_LEN("view_body_utf8")},
my_offsetof(TABLE_LIST, view_body_utf8),
FILE_OPTIONS_ESTRING},
- {{ C_STRING_WITH_LEN("mariadb-version")},
+ {{ STRING_WITH_LEN("mariadb-version")},
my_offsetof(TABLE_LIST, mariadb_version),
FILE_OPTIONS_ULONGLONG},
{{NullS, 0}, 0,
FILE_OPTIONS_STRING}
};
-static LEX_STRING view_file_type[]= {{(char*) STRING_WITH_LEN("VIEW") }};
+static LEX_CSTRING view_file_type[]= {{STRING_WITH_LEN("VIEW") }};
int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum,
bool swap_alg)
{
char dir_buff[FN_REFLEN + 1], path_buff[FN_REFLEN + 1];
- LEX_STRING dir, file, path;
+ LEX_CSTRING dir, file, path;
DBUG_ENTER("mariadb_fix_view");
if (!wrong_checksum && view->mariadb_version)
@@ -912,7 +912,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
char md5[MD5_BUFF_LENGTH];
bool can_be_merged;
char dir_buff[FN_REFLEN + 1], path_buff[FN_REFLEN + 1];
- LEX_STRING dir, file, path;
+ LEX_CSTRING dir, file, path;
int error= 0;
DBUG_ENTER("mysql_register_view");
@@ -1014,7 +1014,7 @@ loop_out:
/* check old .frm */
{
char path_buff[FN_REFLEN];
- LEX_STRING path;
+ LEX_CSTRING path;
File_parser *parser;
path.str= path_buff;
@@ -1333,7 +1333,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
{
char old_db_buf[SAFE_NAME_LEN+1];
- LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) };
+ LEX_CSTRING old_db= { old_db_buf, sizeof(old_db_buf) };
bool dbchanged;
Parser_state parser_state;
if (parser_state.init(thd, table->select_stmt.str,
@@ -1344,7 +1344,8 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
Use view db name as thread default database, in order to ensure
that the view is parsed and prepared correctly.
*/
- if ((result= mysql_opt_change_db(thd, &table->view_db, &old_db, 1,
+ if ((result= mysql_opt_change_db(thd, &table->view_db,
+ (LEX_STRING*) &old_db, 1,
&dbchanged)))
goto end;
@@ -1772,7 +1773,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
char path[FN_REFLEN + 1];
TABLE_LIST *view;
String non_existant_views;
- char *wrong_object_db= NULL, *wrong_object_name= NULL;
+ const char *wrong_object_db= NULL, *wrong_object_name= NULL;
bool error= FALSE;
bool some_views_deleted= FALSE;
bool something_wrong= FALSE;
@@ -2137,7 +2138,7 @@ mysql_rename_view(THD *thd,
const char *new_name,
TABLE_LIST *view)
{
- LEX_STRING pathstr;
+ LEX_CSTRING pathstr;
File_parser *parser;
char path_buff[FN_REFLEN + 1];
bool error= TRUE;
@@ -2153,7 +2154,7 @@ mysql_rename_view(THD *thd,
{
TABLE_LIST view_def;
char dir_buff[FN_REFLEN + 1];
- LEX_STRING dir, file;
+ LEX_CSTRING dir, file;
/*
To be PS-friendly we should either to restore state of
diff --git a/sql/sql_view.h b/sql/sql_view.h
index b9eb92198f8..ff94d2de935 100644
--- a/sql/sql_view.h
+++ b/sql/sql_view.h
@@ -60,7 +60,7 @@ void make_valid_column_names(THD *thd, List<Item> &item_list);
#define VIEW_ANY_ACL (SELECT_ACL | UPDATE_ACL | INSERT_ACL | DELETE_ACL)
-extern const LEX_STRING view_type;
+extern const LEX_CSTRING view_type;
void make_valid_column_names(List<Item> &item_list);
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 557c7503306..ac70d3d0f32 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -12,13 +12,13 @@ Window_spec::check_window_names(List_iterator_fast<Window_spec> &it)
{
if (window_names_are_checked)
return false;
- char *name= this->name();
- char *ref_name= window_reference();
+ const char *name= this->name();
+ const char *ref_name= window_reference();
it.rewind();
Window_spec *win_spec;
while((win_spec= it++) && win_spec != this)
{
- char *win_spec_name= win_spec->name();
+ const char *win_spec_name= win_spec->name();
if (!win_spec_name)
break;
if (name && my_strcasecmp(system_charset_info, name, win_spec_name) == 0)
@@ -384,8 +384,8 @@ int compare_window_frame_bounds(Window_frame_bound *win_frame_bound1,
return CMP_EQ;
else
{
- res= strcmp(win_frame_bound1->offset->name,
- win_frame_bound2->offset->name);
+ res= strcmp(win_frame_bound1->offset->name.str,
+ win_frame_bound2->offset->name.str);
res= res > 0 ? CMP_GT : CMP_LT;
if (is_bottom_bound)
res= -res;
diff --git a/sql/sql_window.h b/sql/sql_window.h
index 6a56fc84392..ed1d9e36492 100644
--- a/sql/sql_window.h
+++ b/sql/sql_window.h
@@ -96,7 +96,7 @@ class Window_spec : public Sql_alloc
public:
virtual ~Window_spec() {}
- LEX_STRING *window_ref;
+ LEX_CSTRING *window_ref;
SQL_I_List<ORDER> *partition_list;
@@ -106,7 +106,7 @@ class Window_spec : public Sql_alloc
Window_spec *referenced_win_spec;
- Window_spec(LEX_STRING *win_ref,
+ Window_spec(LEX_CSTRING *win_ref,
SQL_I_List<ORDER> *part_list,
SQL_I_List<ORDER> *ord_list,
Window_frame *win_frame)
@@ -114,11 +114,14 @@ class Window_spec : public Sql_alloc
partition_list(part_list), order_list(ord_list),
window_frame(win_frame), referenced_win_spec(NULL) {}
- virtual char *name() { return NULL; }
+ virtual const char *name() { return NULL; }
bool check_window_names(List_iterator_fast<Window_spec> &it);
- char *window_reference() { return window_ref ? window_ref->str : NULL; }
+ const char *window_reference()
+ {
+ return window_ref ? window_ref->str : NULL;
+ }
void join_partition_and_order_lists()
{
@@ -138,17 +141,17 @@ class Window_def : public Window_spec
{
public:
- LEX_STRING *window_name;
+ LEX_CSTRING *window_name;
- Window_def(LEX_STRING *win_name,
- LEX_STRING *win_ref,
+ Window_def(LEX_CSTRING *win_name,
+ LEX_CSTRING *win_ref,
SQL_I_List<ORDER> *part_list,
SQL_I_List<ORDER> *ord_list,
Window_frame *win_frame)
: Window_spec(win_ref, part_list, ord_list, win_frame),
window_name(win_name) {}
- char *name() { return window_name->str; }
+ const char *name() { return window_name->str; }
};
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 1cc9f17cd20..59c045029f4 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -238,7 +238,7 @@ int LEX::case_stmt_action_when(Item *when, bool simple)
return
!MY_TEST(i) ||
- sphead->push_backpatch(thd, i, spcont->push_label(thd, empty_lex_str, 0)) ||
+ sphead->push_backpatch(thd, i, spcont->push_label(thd, &empty_clex_str, 0)) ||
sphead->add_cont_backpatch(i) ||
sphead->add_instr(i);
}
@@ -320,7 +320,7 @@ LEX::set_system_variable(struct sys_var_with_base *tmp,
@return TRUE if error, FALSE otherwise.
*/
-bool LEX::set_trigger_new_row(LEX_STRING *name, Item *val)
+bool LEX::set_trigger_new_row(LEX_CSTRING *name, Item *val)
{
Item_trigger_field *trg_fld;
sp_instr_set_trigger_field *sp_fld;
@@ -336,7 +336,7 @@ bool LEX::set_trigger_new_row(LEX_STRING *name, Item *val)
trg_fld= new (thd->mem_root)
Item_trigger_field(thd, current_context(),
Item_trigger_field::NEW_ROW,
- name->str, UPDATE_ACL, FALSE);
+ name, UPDATE_ACL, FALSE);
if (trg_fld == NULL)
return TRUE;
@@ -373,7 +373,7 @@ bool LEX::set_trigger_new_row(LEX_STRING *name, Item *val)
@return An Item_splocal object representing the SP variable, or NULL on error.
*/
Item_splocal*
-LEX::create_item_for_sp_var(LEX_STRING name, sp_variable *spvar,
+LEX::create_item_for_sp_var(LEX_CSTRING *name, sp_variable *spvar,
const char *start_in_q, const char *end_in_q)
{
Item_splocal *item;
@@ -385,7 +385,7 @@ LEX::create_item_for_sp_var(LEX_STRING name, sp_variable *spvar,
if (!spvar)
{
- my_error(ER_SP_UNDECLARED_VAR, MYF(0), name.str);
+ my_error(ER_SP_UNDECLARED_VAR, MYF(0), name->str);
return NULL;
}
@@ -682,27 +682,28 @@ bool sp_create_assignment_instr(THD *thd, bool no_lookahead)
return false;
}
-void LEX::add_key_to_list(LEX_STRING *field_name,
+void LEX::add_key_to_list(LEX_CSTRING *field_name,
enum Key::Keytype type, bool check_exists)
{
Key *key;
MEM_ROOT *mem_root= thd->mem_root;
key= new (mem_root)
- Key(type, null_lex_str, HA_KEY_ALG_UNDEF, false,
+ Key(type, &null_clex_str, HA_KEY_ALG_UNDEF, false,
DDL_options(check_exists ?
DDL_options::OPT_IF_NOT_EXISTS :
DDL_options::OPT_NONE));
- key->columns.push_back(new (mem_root) Key_part_spec(*field_name, 0),
+ key->columns.push_back(new (mem_root) Key_part_spec(field_name, 0),
mem_root);
alter_info.key_list.push_back(key, mem_root);
}
-void LEX::init_last_field(Column_definition *field, const char *field_name,
- CHARSET_INFO *cs)
+void LEX::init_last_field(Column_definition *field,
+ const LEX_CSTRING *field_name,
+ const CHARSET_INFO *cs)
{
last_field= field;
- field->field_name= field_name;
+ field->field_name= *field_name;
/* reset LEX fields that are used in Create_field::set_and_check() */
charset= cs;
@@ -758,7 +759,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
uint sp_instr_addr;
/* structs */
- LEX_STRING lex_str;
+ LEX_CSTRING lex_str;
LEX_SYMBOL symbol;
Lex_string_with_metadata_st lex_string_with_metadata;
struct sys_var_with_base variable;
@@ -787,7 +788,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
LEX *lex;
sp_assignment_lex *assignment_lex;
class sp_lex_cursor *sp_cursor_stmt;
- LEX_STRING *lex_str_ptr;
+ LEX_CSTRING *lex_str_ptr;
LEX_USER *lex_user;
List<Condition_information_item> *cond_info_list;
List<DYNCALL_CREATE_DEF> *dyncol_def_list;
@@ -795,7 +796,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
List<sp_assignment_lex> *sp_assignment_lex_list;
List<Statement_information_item> *stmt_info_list;
List<String> *string_list;
- List<LEX_STRING> *lex_str_list;
+ List<LEX_CSTRING> *lex_str_list;
Statement_information_item *stmt_info_item;
String *string;
TABLE_LIST *table_list;
@@ -1607,7 +1608,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
sp_opt_label BIN_NUM label_ident TEXT_STRING_filesystem ident_or_empty
opt_constraint constraint opt_ident
sp_decl_ident
- sp_block_label
+ sp_block_label opt_place opt_db
%type <lex_string_with_metadata>
TEXT_STRING
@@ -1628,12 +1629,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
optionally_qualified_column_ident
%type <simple_string>
- remember_name remember_end opt_db remember_tok_start
+ remember_name remember_end remember_tok_start
wild_and_where
- field_length opt_field_length opt_field_length_default_1
%type <const_simple_string>
- opt_place
+ field_length opt_field_length opt_field_length_default_1
%type <string>
text_string hex_or_bin_String opt_gconcat_separator
@@ -2410,7 +2410,7 @@ optional_connection_name:
/* empty */
{
LEX *lex= thd->lex;
- lex->mi.connection_name= null_lex_str;
+ lex->mi.connection_name= null_clex_str;
}
| connection_name
;
@@ -2446,7 +2446,7 @@ create:
*/
lex->query_tables->open_strategy= TABLE_LIST::OPEN_STUB;
lex->create_info.default_table_charset= NULL;
- lex->name= null_lex_str;
+ lex->name= null_clex_str;
lex->create_last_non_select_table= lex->last_table();
}
create_body
@@ -2484,7 +2484,7 @@ create:
*/
lex->alter_info.reset();
lex->query_tables->open_strategy= TABLE_LIST::OPEN_STUB;
- lex->name= null_lex_str;
+ lex->name= null_clex_str;
lex->create_last_non_select_table= lex->last_table();
if (!(lex->create_info.seq_create_info= new (thd->mem_root)
sequence_definition()))
@@ -2529,7 +2529,7 @@ create:
{
if (Lex->add_create_index_prepare($8))
MYSQL_YYABORT;
- if (Lex->add_create_index($2, $5, $6, $1 | $4))
+ if (Lex->add_create_index($2, &$5, $6, $1 | $4))
MYSQL_YYABORT;
}
'(' key_list ')' normal_key_options
@@ -2539,7 +2539,7 @@ create:
{
if (Lex->add_create_index_prepare($7))
MYSQL_YYABORT;
- if (Lex->add_create_index($2, $5, HA_KEY_ALG_UNDEF, $1 | $4))
+ if (Lex->add_create_index($2, &$5, HA_KEY_ALG_UNDEF, $1 | $4))
MYSQL_YYABORT;
}
'(' key_list ')' fulltext_key_options
@@ -2549,7 +2549,7 @@ create:
{
if (Lex->add_create_index_prepare($7))
MYSQL_YYABORT;
- if (Lex->add_create_index($2, $5, HA_KEY_ALG_UNDEF, $1 | $4))
+ if (Lex->add_create_index($2, &$5, HA_KEY_ALG_UNDEF, $1 | $4))
MYSQL_YYABORT;
}
'(' key_list ')' spatial_key_options
@@ -2696,7 +2696,8 @@ server_option:
{
MYSQL_YYABORT_UNLESS(Lex->server_options.host.str == 0);
Lex->server_options.host= $2;
- my_casedn_str(system_charset_info, Lex->server_options.host.str);
+ my_casedn_str(system_charset_info,
+ (char*) Lex->server_options.host.str);
}
| DATABASE TEXT_STRING_sys
{
@@ -2899,12 +2900,12 @@ clear_privileges:
sp_name:
ident '.' ident
{
- if (!($$= Lex->make_sp_name(thd, $1, $3)))
+ if (!($$= Lex->make_sp_name(thd, &$1, &$3)))
MYSQL_YYABORT;
}
| ident
{
- if (!($$= Lex->make_sp_name(thd, $1)))
+ if (!($$= Lex->make_sp_name(thd, &$1)))
MYSQL_YYABORT;
}
;
@@ -3003,7 +3004,7 @@ sp_fdparams:
sp_param_name:
ident
{
- if (!($$= Lex->sp_param_init($1)))
+ if (!($$= Lex->sp_param_init(&$1)))
MYSQL_YYABORT;
}
;
@@ -3021,7 +3022,7 @@ sp_param_name_and_type:
| sp_param_name ROW_SYM row_type_body
{
$$= $1;
- $$->field_def.field_name= $$->name.str;
+ $$->field_def.field_name= $$->name;
Lex->sphead->fill_spvar_definition(thd, &$$->field_def);
Lex->sphead->row_fill_field_definitions(thd, $3);
$$->field_def.set_row_field_definitions($3);
@@ -3108,13 +3109,13 @@ sp_decl:
qualified_column_ident:
sp_decl_ident '.' ident
{
- if (!($$= new (thd->mem_root) Qualified_column_ident($1, $3)))
+ if (!($$= new (thd->mem_root) Qualified_column_ident(&$1, &$3)))
MYSQL_YYABORT;
}
| sp_decl_ident '.' ident '.' ident
{
if (!($$= new (thd->mem_root) Qualified_column_ident(thd,
- $1, $3, $5)))
+ &$1, &$3, &$5)))
MYSQL_YYABORT;
}
;
@@ -3122,18 +3123,18 @@ qualified_column_ident:
optionally_qualified_column_ident:
sp_decl_ident
{
- if (!($$= new (thd->mem_root) Qualified_column_ident($1)))
+ if (!($$= new (thd->mem_root) Qualified_column_ident(&$1)))
MYSQL_YYABORT;
}
| sp_decl_ident '.' ident
{
- if (!($$= new (thd->mem_root) Qualified_column_ident($1, $3)))
+ if (!($$= new (thd->mem_root) Qualified_column_ident(&$1, &$3)))
MYSQL_YYABORT;
}
| sp_decl_ident '.' ident '.' ident
{
if (!($$= new (thd->mem_root) Qualified_column_ident(thd,
- $1, $3, $5)))
+ &$1, &$3, &$5)))
MYSQL_YYABORT;
}
;
@@ -3146,7 +3147,7 @@ row_field_name:
my_yyabort_error((ER_TOO_LONG_IDENT, MYF(0), $1.str));
if (!($$= new (thd->mem_root) Spvar_definition()))
MYSQL_YYABORT;
- Lex->init_last_field($$, $1.str, thd->variables.collation_database);
+ Lex->init_last_field($$, &$1, thd->variables.collation_database);
}
;
@@ -3164,8 +3165,8 @@ row_field_definition_list:
| row_field_definition_list ',' row_field_definition
{
uint unused;
- if ($1->find_row_field_by_name($3->field_name, &unused))
- my_yyabort_error((ER_DUP_FIELDNAME, MYF(0), $3->field_name));
+ if ($1->find_row_field_by_name(&$3->field_name, &unused))
+ my_yyabort_error((ER_DUP_FIELDNAME, MYF(0), $3->field_name.str));
$$= $1;
$$->push_back($3, thd->mem_root);
}
@@ -3222,7 +3223,7 @@ sp_decl_body:
sp_decl_variable_list
| sp_decl_ident CONDITION_SYM FOR_SYM sp_cond
{
- if (Lex->spcont->declare_condition(thd, $1, $4))
+ if (Lex->spcont->declare_condition(thd, &$1, $4))
MYSQL_YYABORT;
$$.vars= $$.hndlrs= $$.curs= 0;
$$.conds= 1;
@@ -3249,7 +3250,7 @@ sp_decl_body:
sp_pcontext *param_ctx= Lex->spcont;
if (Lex->sp_block_finalize(thd))
MYSQL_YYABORT;
- if (Lex->sp_declare_cursor(thd, $1, $6, param_ctx, true))
+ if (Lex->sp_declare_cursor(thd, &$1, $6, param_ctx, true))
MYSQL_YYABORT;
$$.vars= $$.conds= $$.hndlrs= 0;
$$.curs= 1;
@@ -3357,7 +3358,7 @@ sp_hcond:
}
| ident /* CONDITION name */
{
- $$= Lex->spcont->find_condition($1, false);
+ $$= Lex->spcont->find_condition(&$1, false);
if ($$ == NULL)
my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str));
}
@@ -3398,7 +3399,7 @@ signal_value:
/* SIGNAL foo cannot be used outside of stored programs */
if (lex->spcont == NULL)
my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str));
- cond= lex->spcont->find_condition($1, false);
+ cond= lex->spcont->find_condition(&$1, false);
if (cond == NULL)
my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str));
if (cond->type != sp_condition_value::SQLSTATE)
@@ -3574,7 +3575,7 @@ simple_target_specification:
ident
{
Lex_input_stream *lip= &thd->m_parser_state->m_lip;
- $$= thd->lex->create_item_for_sp_var($1, NULL,
+ $$= thd->lex->create_item_for_sp_var(&$1, NULL,
lip->get_tok_start(),
lip->get_ptr());
if ($$ == NULL)
@@ -3582,7 +3583,7 @@ simple_target_specification:
}
| '@' ident_or_text
{
- $$= new (thd->mem_root) Item_func_get_user_var(thd, $2);
+ $$= new (thd->mem_root) Item_func_get_user_var(thd, &$2);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -3668,9 +3669,9 @@ sp_decl_idents:
LEX *lex= Lex;
sp_pcontext *spc= lex->spcont;
- if (spc->find_variable($1, TRUE))
+ if (spc->find_variable(&$1, TRUE))
my_yyabort_error((ER_SP_DUP_VAR, MYF(0), $1.str));
- spc->add_variable(thd, $1);
+ spc->add_variable(thd, &$1);
$$= 1;
}
| sp_decl_idents ',' ident
@@ -3680,9 +3681,9 @@ sp_decl_idents:
LEX *lex= Lex;
sp_pcontext *spc= lex->spcont;
- if (spc->find_variable($3, TRUE))
+ if (spc->find_variable(&$3, TRUE))
my_yyabort_error((ER_SP_DUP_VAR, MYF(0), $3.str));
- spc->add_variable(thd, $3);
+ spc->add_variable(thd, &$3);
$$= $1 + 1;
}
;
@@ -3817,7 +3818,7 @@ sp_proc_stmt_return:
sp_proc_stmt_leave:
LEAVE_SYM label_ident
{
- if (Lex->sp_leave_statement(thd, $2))
+ if (Lex->sp_leave_statement(thd, &$2))
MYSQL_YYABORT;
}
;
@@ -3825,7 +3826,7 @@ sp_proc_stmt_leave:
sp_proc_stmt_iterate:
ITERATE_SYM label_ident
{
- if (Lex->sp_iterate_statement(thd, $2))
+ if (Lex->sp_iterate_statement(thd, &$2))
MYSQL_YYABORT;
}
;
@@ -3878,7 +3879,7 @@ opt_parenthesized_cursor_actual_parameters:
sp_proc_stmt_open:
OPEN_SYM ident opt_parenthesized_cursor_actual_parameters
{
- if (Lex->sp_open_cursor(thd, $2, $3))
+ if (Lex->sp_open_cursor(thd, &$2, $3))
MYSQL_YYABORT;
}
;
@@ -3886,17 +3887,17 @@ sp_proc_stmt_open:
sp_proc_stmt_fetch_head:
FETCH_SYM ident INTO
{
- if (Lex->sp_add_cfetch(thd, $2))
+ if (Lex->sp_add_cfetch(thd, &$2))
MYSQL_YYABORT;
}
| FETCH_SYM FROM ident INTO
{
- if (Lex->sp_add_cfetch(thd, $3))
+ if (Lex->sp_add_cfetch(thd, &$3))
MYSQL_YYABORT;
}
| FETCH_SYM NEXT_SYM FROM ident INTO
{
- if (Lex->sp_add_cfetch(thd, $4))
+ if (Lex->sp_add_cfetch(thd, &$4))
MYSQL_YYABORT;
}
;
@@ -3913,7 +3914,7 @@ sp_proc_stmt_close:
uint offset;
sp_instr_cclose *i;
- if (! lex->spcont->find_cursor($2, &offset, false))
+ if (! lex->spcont->find_cursor(&$2, &offset, false))
my_yyabort_error((ER_SP_CURSOR_MISMATCH, MYF(0), $2.str));
i= new (thd->mem_root)
sp_instr_cclose(sp->instructions(), lex->spcont, offset);
@@ -3931,7 +3932,7 @@ sp_fetch_list:
sp_pcontext *spc= lex->spcont;
sp_variable *spv;
- if (!spc || !(spv = spc->find_variable($1, false)))
+ if (!spc || !(spv = spc->find_variable(&$1, false)))
my_yyabort_error((ER_SP_UNDECLARED_VAR, MYF(0), $1.str));
/* An SP local variable */
@@ -3945,7 +3946,7 @@ sp_fetch_list:
sp_pcontext *spc= lex->spcont;
sp_variable *spv;
- if (!spc || !(spv = spc->find_variable($3, false)))
+ if (!spc || !(spv = spc->find_variable(&$3, false)))
my_yyabort_error((ER_SP_UNDECLARED_VAR, MYF(0), $3.str));
/* An SP local variable */
@@ -3965,7 +3966,7 @@ sp_if:
sp_instr_jump_if_not *i= new (thd->mem_root)
sp_instr_jump_if_not(ip, ctx, $2, lex);
if (i == NULL ||
- sp->push_backpatch(thd, i, ctx->push_label(thd, empty_lex_str, 0)) ||
+ sp->push_backpatch(thd, i, ctx->push_label(thd, &empty_clex_str, 0)) ||
sp->add_cont_backpatch(i) ||
sp->add_instr(i))
MYSQL_YYABORT;
@@ -3982,7 +3983,7 @@ sp_if:
sp->add_instr(i))
MYSQL_YYABORT;
sp->backpatch(ctx->pop_label());
- sp->push_backpatch(thd, i, ctx->push_label(thd, empty_lex_str, 0));
+ sp->push_backpatch(thd, i, ctx->push_label(thd, &empty_clex_str, 0));
}
sp_elseifs
{
@@ -4047,7 +4048,7 @@ case_stmt_specification:
BACKPATCH: Creating target label for the jump to after END CASE
(instruction 12 in the example)
*/
- Lex->spcont->push_label(thd, empty_lex_str, Lex->sphead->instructions());
+ Lex->spcont->push_label(thd, &empty_clex_str, Lex->sphead->instructions());
}
case_stmt_body
else_clause_opt
@@ -4156,14 +4157,14 @@ else_clause_opt:
;
sp_opt_label:
- /* Empty */ { $$= null_lex_str; }
+ /* Empty */ { $$= null_clex_str; }
| label_ident { $$= $1; }
;
sp_block_label:
label_ident ':'
{
- if (Lex->spcont->block_label_declare($1))
+ if (Lex->spcont->block_label_declare(&$1))
MYSQL_YYABORT;
$$= $1;
}
@@ -4173,14 +4174,14 @@ sp_labeled_block:
sp_block_label
BEGIN_SYM
{
- Lex->sp_block_init(thd, $1);
+ Lex->sp_block_init(thd, &$1);
}
sp_decls
sp_proc_stmts
END
sp_opt_label
{
- if (Lex->sp_block_finalize(thd, $4, $7))
+ if (Lex->sp_block_finalize(thd, $4, &$7))
MYSQL_YYABORT;
}
;
@@ -4268,7 +4269,7 @@ repeat_body:
pop_sp_loop_label:
sp_opt_label
{
- if (Lex->sp_pop_loop_label(thd, $1))
+ if (Lex->sp_pop_loop_label(thd, &$1))
MYSQL_YYABORT;
}
;
@@ -4276,14 +4277,14 @@ pop_sp_loop_label:
sp_labeled_control:
label_ident ':' LOOP_SYM
{
- if (Lex->sp_push_loop_label(thd, $1))
+ if (Lex->sp_push_loop_label(thd, &$1))
MYSQL_YYABORT;
}
loop_body pop_sp_loop_label
{ }
| label_ident ':' WHILE_SYM
{
- if (Lex->sp_push_loop_label(thd, $1))
+ if (Lex->sp_push_loop_label(thd, &$1))
MYSQL_YYABORT;
Lex->sphead->reset_lex(thd);
}
@@ -4291,7 +4292,7 @@ sp_labeled_control:
{ }
| label_ident ':' REPEAT_SYM
{
- if (Lex->sp_push_loop_label(thd, $1))
+ if (Lex->sp_push_loop_label(thd, &$1))
MYSQL_YYABORT;
}
repeat_body pop_sp_loop_label
@@ -4683,11 +4684,11 @@ size_number:
ulonglong number;
uint text_shift_number= 0;
longlong prefix_number;
- char *start_ptr= $1.str;
+ const char *start_ptr= $1.str;
uint str_len= $1.length;
- char *end_ptr= start_ptr + str_len;
+ const char *end_ptr= start_ptr + str_len;
int error;
- prefix_number= my_strtoll10(start_ptr, &end_ptr, &error);
+ prefix_number= my_strtoll10(start_ptr, (char**) &end_ptr, &error);
if ((start_ptr + str_len - 1) == end_ptr)
{
switch (end_ptr[0])
@@ -4841,7 +4842,7 @@ have_partitioning:
/* empty */
{
#ifdef WITH_PARTITION_STORAGE_ENGINE
- LEX_STRING partition_name={C_STRING_WITH_LEN("partition")};
+ LEX_CSTRING partition_name={STRING_WITH_LEN("partition")};
if (!plugin_is_ready(&partition_name, MYSQL_STORAGE_ENGINE_PLUGIN))
my_yyabort_error((ER_OPTION_PREVENTS_STATEMENT, MYF(0),
"--skip-partition"));
@@ -5949,28 +5950,28 @@ key_def:
key_or_index opt_if_not_exists opt_ident opt_USING_key_algorithm
{
Lex->option_list= NULL;
- if (Lex->add_key(Key::MULTIPLE, $3, $4, $2))
+ if (Lex->add_key(Key::MULTIPLE, &$3, $4, $2))
MYSQL_YYABORT;
}
'(' key_list ')' normal_key_options { }
| key_or_index opt_if_not_exists ident TYPE_SYM btree_or_rtree
{
Lex->option_list= NULL;
- if (Lex->add_key(Key::MULTIPLE, $3, $5, $2))
+ if (Lex->add_key(Key::MULTIPLE, &$3, $5, $2))
MYSQL_YYABORT;
}
'(' key_list ')' normal_key_options { }
| fulltext opt_key_or_index opt_if_not_exists opt_ident
{
Lex->option_list= NULL;
- if (Lex->add_key($1, $4, HA_KEY_ALG_UNDEF, $3))
+ if (Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3))
MYSQL_YYABORT;
}
'(' key_list ')' fulltext_key_options { }
| spatial opt_key_or_index opt_if_not_exists opt_ident
{
Lex->option_list= NULL;
- if (Lex->add_key($1, $4, HA_KEY_ALG_UNDEF, $3))
+ if (Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3))
MYSQL_YYABORT;
}
'(' key_list ')' spatial_key_options { }
@@ -5979,7 +5980,7 @@ key_def:
opt_USING_key_algorithm
{
Lex->option_list= NULL;
- if (Lex->add_key($2, $4.str ? $4 : $1, $5, $3))
+ if (Lex->add_key($2, $4.str ? &$4 : &$1, $5, $3))
MYSQL_YYABORT;
}
'(' key_list ')' normal_key_options { }
@@ -5987,7 +5988,7 @@ key_def:
TYPE_SYM btree_or_rtree
{
Lex->option_list= NULL;
- if (Lex->add_key($2, $4.str ? $4 : $1, $6, $3))
+ if (Lex->add_key($2, $4.str ? &$4 : &$1, $6, $3))
MYSQL_YYABORT;
}
'(' key_list ')' normal_key_options { }
@@ -5995,7 +5996,7 @@ key_def:
{
if (Lex->check_add_key($4) ||
!(Lex->last_key= (new (thd->mem_root)
- Key(Key::MULTIPLE, $1.str ? $1 : $5,
+ Key(Key::MULTIPLE, $1.str ? &$1 : &$5,
HA_KEY_ALG_UNDEF, true, $4))))
MYSQL_YYABORT;
Lex->option_list= NULL;
@@ -6004,11 +6005,11 @@ key_def:
{
LEX *lex=Lex;
Key *key= (new (thd->mem_root)
- Foreign_key($5.str ? $5 : $1,
- lex->last_key->columns,
- $10->db,
- $10->table,
- lex->ref_list,
+ Foreign_key($5.str ? &$5 : &$1,
+ &lex->last_key->columns,
+ &$10->db,
+ &$10->table,
+ &lex->ref_list,
lex->fk_delete_opt,
lex->fk_update_opt,
lex->fk_match_option,
@@ -6054,7 +6055,7 @@ check_constraint:
;
opt_constraint:
- /* empty */ { $$= null_lex_str; }
+ /* empty */ { $$= null_clex_str; }
| constraint { $$= $1; }
;
@@ -6075,7 +6076,7 @@ field_spec:
if (!f)
MYSQL_YYABORT;
- lex->init_last_field(f, $1.str, NULL);
+ lex->init_last_field(f, &$1, NULL);
$<create_field>$= f;
}
field_type_or_serial opt_check_constraint
@@ -6253,7 +6254,7 @@ field_type:
ulonglong tmp_length= my_strtoll10($2.length(), NULL, &err);
if (err || tmp_length > PRECISION_FOR_DOUBLE)
my_yyabort_error((ER_WRONG_FIELD_SPEC, MYF(0),
- Lex->last_field->field_name));
+ Lex->last_field->field_name.str));
if (tmp_length > PRECISION_FOR_FLOAT)
$$.set(MYSQL_TYPE_DOUBLE);
else
@@ -6791,14 +6792,14 @@ opt_ref_list:
ref_list:
ref_list ',' ident
{
- Key_part_spec *key= new (thd->mem_root) Key_part_spec($3, 0);
+ Key_part_spec *key= new (thd->mem_root) Key_part_spec(&$3, 0);
if (key == NULL)
MYSQL_YYABORT;
Lex->ref_list.push_back(key, thd->mem_root);
}
| ident
{
- Key_part_spec *key= new (thd->mem_root) Key_part_spec($1, 0);
+ Key_part_spec *key= new (thd->mem_root) Key_part_spec(&$1, 0);
if (key == NULL)
MYSQL_YYABORT;
LEX *lex= Lex;
@@ -7024,7 +7025,7 @@ key_list:
key_part:
ident
{
- $$= new (thd->mem_root) Key_part_spec($1, 0);
+ $$= new (thd->mem_root) Key_part_spec(&$1, 0);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -7033,19 +7034,19 @@ key_part:
int key_part_len= atoi($3.str);
if (!key_part_len)
my_yyabort_error((ER_KEY_PART_0, MYF(0), $1.str));
- $$= new (thd->mem_root) Key_part_spec($1, (uint) key_part_len);
+ $$= new (thd->mem_root) Key_part_spec(&$1, (uint) key_part_len);
if ($$ == NULL)
MYSQL_YYABORT;
}
;
opt_ident:
- /* empty */ { $$= null_lex_str; }
+ /* empty */ { $$= null_clex_str; }
| field_ident { $$= $1; }
;
opt_component:
- /* empty */ { $$= null_lex_str; }
+ /* empty */ { $$= null_clex_str; }
| '.' ident { $$= $2; }
;
@@ -7062,7 +7063,7 @@ string_list:
alter:
ALTER
{
- Lex->name= null_lex_str;
+ Lex->name= null_clex_str;
Lex->table_type= TABLE_TYPE_UNKNOWN;
Lex->sql_command= SQLCOM_ALTER_TABLE;
Lex->duplicates= DUP_ERROR;
@@ -7268,7 +7269,7 @@ opt_ev_sql_stmt:
;
ident_or_empty:
- /* empty */ { $$= null_lex_str; }
+ /* empty */ { $$= null_clex_str; }
| ident { $$= $1; }
;
@@ -7553,7 +7554,7 @@ alter_list_item:
{
Lex->alter_info.flags|= Alter_info::ALTER_CHANGE_COLUMN;
Lex->create_last_non_select_table= Lex->last_table();
- $5->change= $4.str;
+ $5->change= $4;
$5->after= $6;
}
| MODIFY_SYM opt_column opt_if_exists_table_element
@@ -7658,7 +7659,7 @@ alter_list_item:
MYSQL_YYABORT;
}
if (check_table_name($3->table.str,$3->table.length, FALSE) ||
- ($3->db.str && check_db_name(&$3->db)))
+ ($3->db.str && check_db_name((LEX_STRING*) &$3->db)))
my_yyabort_error((ER_WRONG_TABLE_NAME, MYF(0), $3->table.str));
lex->name= $3->table;
lex->alter_info.flags|= Alter_info::ALTER_RENAME;
@@ -7773,15 +7774,16 @@ opt_restrict:
;
opt_place:
- /* empty */ { $$= NULL; }
+ /* empty */ { $$= null_clex_str; }
| AFTER_SYM ident
{
- $$= $2.str;
+ $$= $2;
Lex->alter_info.flags |= Alter_info::ALTER_COLUMN_ORDER;
}
| FIRST_SYM
{
- $$= first_keyword;
+ $$.str= first_keyword;
+ $$.length= 5; /* Length of "first" */
Lex->alter_info.flags |= Alter_info::ALTER_COLUMN_ORDER;
}
;
@@ -8655,7 +8657,7 @@ select_item_list:
{
Item *item= new (thd->mem_root)
Item_field(thd, &thd->lex->current_select->context,
- NULL, NULL, "*");
+ NULL, NULL, &star_clex_str);
if (item == NULL)
MYSQL_YYABORT;
if (add_item_to_list(thd, item))
@@ -8684,7 +8686,7 @@ select_item:
$2->is_autogenerated_name= FALSE;
$2->set_name(thd, $4.str, $4.length, system_charset_info);
}
- else if (!$2->name)
+ else if (!$2->name.str || $2->name.str == item_empty_name)
{
$2->set_name(thd, $1, (uint) ($3 - $1), thd->charset());
}
@@ -8710,7 +8712,7 @@ remember_end:
;
select_alias:
- /* empty */ { $$=null_lex_str;}
+ /* empty */ { $$=null_clex_str;}
| AS ident { $$=$2; }
| AS TEXT_STRING_sys { $$=$2; }
| ident { $$=$1; }
@@ -10147,10 +10149,10 @@ function_call_generic:
This will be revised with WL#2128 (SQL PATH)
*/
- builder= find_native_function_builder(thd, $1);
+ builder= find_native_function_builder(thd, &$1);
if (builder)
{
- item= builder->create_func(thd, $1, $4);
+ item= builder->create_func(thd, &$1, $4);
}
else
{
@@ -10172,7 +10174,7 @@ function_call_generic:
{
builder= find_qualified_function_builder(thd);
DBUG_ASSERT(builder);
- item= builder->create_func(thd, $1, $4);
+ item= builder->create_func(thd, &$1, $4);
}
}
@@ -10200,7 +10202,7 @@ function_call_generic:
version() (a vendor can specify any schema).
*/
- if (!$1.str || check_db_name(&$1))
+ if (!$1.str || check_db_name((LEX_STRING*) &$1))
my_yyabort_error((ER_WRONG_DB_NAME, MYF(0), $1.str));
if (check_routine_name(&$3))
{
@@ -10209,7 +10211,7 @@ function_call_generic:
builder= find_qualified_function_builder(thd);
DBUG_ASSERT(builder);
- item= builder->create_with_db(thd, $1, $3, true, $5);
+ item= builder->create_with_db(thd, &$1, &$3, true, $5);
if (! ($$= item))
{
@@ -10561,7 +10563,7 @@ simple_window_func:
window_name:
ident
{
- $$= (LEX_STRING *) thd->memdup(&$1, sizeof(LEX_STRING));
+ $$= (LEX_CSTRING *) thd->memdup(&$1, sizeof(LEX_CSTRING));
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -10583,7 +10585,7 @@ variable_aux:
ident_or_text SET_VAR expr
{
Item_func_set_user_var *item;
- $$= item= new (thd->mem_root) Item_func_set_user_var(thd, $1, $3);
+ $$= item= new (thd->mem_root) Item_func_set_user_var(thd, &$1, $3);
if ($$ == NULL)
MYSQL_YYABORT;
LEX *lex= Lex;
@@ -10592,7 +10594,7 @@ variable_aux:
}
| ident_or_text
{
- $$= new (thd->mem_root) Item_func_get_user_var(thd, $1);
+ $$= new (thd->mem_root) Item_func_get_user_var(thd, &$1);
if ($$ == NULL)
MYSQL_YYABORT;
LEX *lex= Lex;
@@ -11296,7 +11298,7 @@ key_usage_element:
ident
{ Select->add_index_hint(thd, $1.str, $1.length); }
| PRIMARY_SYM
- { Select->add_index_hint(thd, (char *)"PRIMARY", 7); }
+ { Select->add_index_hint(thd, "PRIMARY", 7); }
;
key_usage_list:
@@ -11372,7 +11374,7 @@ opt_table_alias:
/* empty */ { $$=0; }
| table_alias ident
{
- $$= (LEX_STRING*) thd->memdup(&$2,sizeof(LEX_STRING));
+ $$= (LEX_CSTRING*) thd->memdup(&$2,sizeof(LEX_STRING));
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -11508,7 +11510,7 @@ window_def:
if (Select->add_window_def(thd, $1, lex->win_ref,
Select->group_list,
Select->order_list,
- lex->win_frame ))
+ lex->win_frame))
MYSQL_YYABORT;
}
;
@@ -11525,7 +11527,7 @@ opt_window_ref:
/* empty */ {}
| ident
{
- thd->lex->win_ref= (LEX_STRING *) thd->memdup(&$1, sizeof(LEX_STRING));
+ thd->lex->win_ref= (LEX_CSTRING *) thd->memdup(&$1, sizeof(LEX_CSTRING));
if (thd->lex->win_ref == NULL)
MYSQL_YYABORT;
}
@@ -11793,7 +11795,7 @@ limit_option:
{
LEX *lex= thd->lex;
Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- if (!($$= lex->create_item_limit(thd, $1,
+ if (!($$= lex->create_item_limit(thd, &$1,
$1.m_pos -
lex->substatement_query(thd),
lip->get_tok_end() - $1.m_pos)))
@@ -11803,7 +11805,7 @@ limit_option:
{
LEX *lex= thd->lex;
Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- if (!($$= lex->create_item_limit(thd, $1, $3,
+ if (!($$= lex->create_item_limit(thd, &$1, &$3,
$1.m_pos -
lex->substatement_query(thd),
lip->get_ptr() - $1.m_pos)))
@@ -11928,7 +11930,7 @@ procedure_clause:
lex->proc_list.next= &lex->proc_list.first;
Item_field *item= new (thd->mem_root)
Item_field(thd, &lex->current_select->context,
- NULL, NULL, $2.str);
+ NULL, NULL, &$2);
if (item == NULL)
MYSQL_YYABORT;
if (add_proc_to_list(thd, item))
@@ -11965,7 +11967,7 @@ procedure_item:
{
if (add_proc_to_list(thd, $2))
MYSQL_YYABORT;
- if (!$2->name)
+ if (!$2->name.str || $2->name.str == item_empty_name)
$2->set_name(thd, $1, (uint) ($3 - $1), thd->charset());
}
;
@@ -12008,22 +12010,22 @@ select_var_ident: select_outvar
select_outvar:
'@' ident_or_text
{
- $$ = Lex->result ? new (thd->mem_root) my_var_user($2) : NULL;
+ $$ = Lex->result ? new (thd->mem_root) my_var_user(&$2) : NULL;
}
| ident_or_text
{
sp_variable *t;
- if (!Lex->spcont || !(t= Lex->spcont->find_variable($1, false)))
+ if (!Lex->spcont || !(t= Lex->spcont->find_variable(&$1, false)))
my_yyabort_error((ER_SP_UNDECLARED_VAR, MYF(0), $1.str));
$$ = Lex->result ? (new (thd->mem_root)
- my_var_sp($1, t->offset, t->type_handler(),
+ my_var_sp(&$1, t->offset, t->type_handler(),
Lex->sphead)) :
NULL;
}
| ident '.' ident
{
- if (!($$= Lex->create_outvar(thd, $1, $3)))
+ if (!($$= Lex->create_outvar(thd, &$1, &$3)))
MYSQL_YYABORT;
}
;
@@ -12123,12 +12125,12 @@ drop:
{
LEX *lex= thd->lex;
sp_name *spname;
- if ($4.str && check_db_name(&$4))
+ if ($4.str && check_db_name((LEX_STRING*) &$4))
my_yyabort_error((ER_WRONG_DB_NAME, MYF(0), $4.str));
if (lex->sphead)
my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"));
lex->set_command(SQLCOM_DROP_FUNCTION, $3);
- spname= new (thd->mem_root) sp_name($4, $6, true);
+ spname= new (thd->mem_root) sp_name(&$4, &$6, true);
if (spname == NULL)
MYSQL_YYABORT;
lex->spname= spname;
@@ -12136,14 +12138,14 @@ drop:
| DROP FUNCTION_SYM opt_if_exists ident
{
LEX *lex= thd->lex;
- LEX_STRING db= {0, 0};
+ LEX_CSTRING db= {0, 0};
sp_name *spname;
if (lex->sphead)
my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"));
if (thd->db && lex->copy_db_to(&db.str, &db.length))
MYSQL_YYABORT;
lex->set_command(SQLCOM_DROP_FUNCTION, $3);
- spname= new (thd->mem_root) sp_name(db, $4, false);
+ spname= new (thd->mem_root) sp_name(&db, &$4, false);
if (spname == NULL)
MYSQL_YYABORT;
lex->spname= spname;
@@ -12627,7 +12629,7 @@ table_wild_list:
table_wild_one:
ident opt_wild
{
- Table_ident *ti= new (thd->mem_root) Table_ident($1);
+ Table_ident *ti= new (thd->mem_root) Table_ident(&$1);
if (ti == NULL)
MYSQL_YYABORT;
if (!Select->add_table_to_list(thd,
@@ -12640,7 +12642,7 @@ table_wild_one:
}
| ident '.' ident opt_wild
{
- Table_ident *ti= new (thd->mem_root) Table_ident(thd, $1, $3, 0);
+ Table_ident *ti= new (thd->mem_root) Table_ident(thd, &$1, &$3, 0);
if (ti == NULL)
MYSQL_YYABORT;
if (!Select->add_table_to_list(thd,
@@ -12761,7 +12763,7 @@ show:
{
LEX *lex=Lex;
lex->wild=0;
- lex->ident=null_lex_str;
+ lex->ident= null_clex_str;
mysql_init_select(lex);
lex->current_select->parsing_place= SELECT_LIST;
lex->create_info.init();
@@ -12784,7 +12786,7 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_TABLES;
- lex->select_lex.db= $3;
+ lex->select_lex.db= $3.str;
if (prepare_schema_table(thd, lex, 0, SCH_TABLE_NAMES))
MYSQL_YYABORT;
}
@@ -12792,7 +12794,7 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_TRIGGERS;
- lex->select_lex.db= $3;
+ lex->select_lex.db= $3.str;
if (prepare_schema_table(thd, lex, 0, SCH_TRIGGERS))
MYSQL_YYABORT;
}
@@ -12800,7 +12802,7 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_EVENTS;
- lex->select_lex.db= $2;
+ lex->select_lex.db= $2.str;
if (prepare_schema_table(thd, lex, 0, SCH_EVENTS))
MYSQL_YYABORT;
}
@@ -12808,7 +12810,7 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
- lex->select_lex.db= $3;
+ lex->select_lex.db= $3.str;
if (prepare_schema_table(thd, lex, 0, SCH_TABLES))
MYSQL_YYABORT;
}
@@ -12816,7 +12818,7 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
- lex->select_lex.db= $3;
+ lex->select_lex.db= $3.str;
if (prepare_schema_table(thd, lex, 0, SCH_OPEN_TABLES))
MYSQL_YYABORT;
}
@@ -12848,8 +12850,8 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_FIELDS;
- if ($5)
- $4->change_db($5);
+ if ($5.str)
+ $4->change_db(&$5);
if (prepare_schema_table(thd, lex, $4, SCH_COLUMNS))
MYSQL_YYABORT;
}
@@ -12876,8 +12878,8 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_KEYS;
- if ($4)
- $3->change_db($4);
+ if ($4.str)
+ $3->change_db(&$4);
if (prepare_schema_table(thd, lex, $3, SCH_STATISTICS))
MYSQL_YYABORT;
}
@@ -13006,7 +13008,7 @@ show_param:
| SLAVE STATUS_SYM
{
LEX *lex= thd->lex;
- lex->mi.connection_name= null_lex_str;
+ lex->mi.connection_name= null_clex_str;
lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
lex->verbose= 0;
}
@@ -13124,8 +13126,8 @@ opt_storage:
;
opt_db:
- /* empty */ { $$= 0; }
- | from_or_in ident { $$= $2.str; }
+ /* empty */ { $$= null_clex_str; }
+ | from_or_in ident { $$= $2; }
;
opt_full:
@@ -13340,7 +13342,7 @@ flush_option:
| LOGS_SYM
{
Lex->type|= REFRESH_LOG;
- Lex->relay_log_connection_name= empty_lex_str;
+ Lex->relay_log_connection_name= empty_clex_str;
}
| STATUS_SYM
{ Lex->type|= REFRESH_STATUS; }
@@ -13678,7 +13680,7 @@ field_or_var:
simple_ident_nospvar {$$= $1;}
| '@' ident_or_text
{
- $$= new (thd->mem_root) Item_user_var_as_out_param(thd, $2);
+ $$= new (thd->mem_root) Item_user_var_as_out_param(thd, &$2);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -13710,7 +13712,7 @@ load_data_set_elem:
text_literal:
TEXT_STRING
{
- LEX_STRING tmp;
+ LEX_CSTRING tmp;
CHARSET_INFO *cs_con= thd->variables.collation_connection;
CHARSET_INFO *cs_cli= thd->variables.character_set_client;
uint repertoire= $1.repertoire(cs_cli);
@@ -13720,8 +13722,11 @@ text_literal:
tmp= $1;
else
{
- if (thd->convert_string(&tmp, cs_con, $1.str, $1.length, cs_cli))
+ LEX_STRING to;
+ if (thd->convert_string(&to, cs_con, $1.str, $1.length, cs_cli))
MYSQL_YYABORT;
+ tmp.str= to.str;
+ tmp.length= to.length;
}
$$= new (thd->mem_root) Item_string(thd, tmp.str, tmp.length,
cs_con,
@@ -13819,7 +13824,7 @@ hex_or_bin_String:
param_marker:
PARAM_MARKER
{
- if (!($$= Lex->add_placeholder(thd, (char *) "?",
+ if (!($$= Lex->add_placeholder(thd, &param_clex_str,
YYLIP->get_tok_start(),
YYLIP->get_tok_start() + 1)))
MYSQL_YYABORT;
@@ -14013,7 +14018,7 @@ with_list_element:
query_name
opt_with_column_list
{
- $2= new List<LEX_STRING> (Lex->with_column_list);
+ $2= new List<LEX_CSTRING> (Lex->with_column_list);
if ($2 == NULL)
MYSQL_YYABORT;
Lex->with_column_list.empty();
@@ -14040,13 +14045,13 @@ opt_with_column_list:
with_column_list:
ident
{
- Lex->with_column_list.push_back((LEX_STRING*)
- thd->memdup(&$1, sizeof(LEX_STRING)));
+ Lex->with_column_list.push_back((LEX_CSTRING*)
+ thd->memdup(&$1, sizeof(LEX_CSTRING)));
}
| with_column_list ',' ident
{
- Lex->with_column_list.push_back((LEX_STRING*)
- thd->memdup(&$3, sizeof(LEX_STRING)));
+ Lex->with_column_list.push_back((LEX_CSTRING*)
+ thd->memdup(&$3, sizeof(LEX_CSTRING)));
}
;
@@ -14054,7 +14059,7 @@ with_column_list:
query_name:
ident
{
- $$= (LEX_STRING *) thd->memdup(&$1, sizeof(LEX_STRING));
+ $$= (LEX_CSTRING *) thd->memdup(&$1, sizeof(LEX_CSTRING));
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -14076,7 +14081,7 @@ table_wild:
{
SELECT_LEX *sel= Select;
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
- NullS, $1.str, "*");
+ NullS, $1.str, &star_clex_str);
if ($$ == NULL)
MYSQL_YYABORT;
sel->with_wild++;
@@ -14088,7 +14093,7 @@ table_wild:
NullS : $1.str;
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
schema,
- $3.str,"*");
+ $3.str, &star_clex_str);
if ($$ == NULL)
MYSQL_YYABORT;
sel->with_wild++;
@@ -14103,7 +14108,7 @@ simple_ident:
ident
{
Lex_input_stream *lip= YYLIP;
- if (!($$= Lex->create_item_ident(thd, $1,
+ if (!($$= Lex->create_item_ident(thd, &$1,
lip->get_tok_start_prev(),
lip->get_tok_end())))
MYSQL_YYABORT;
@@ -14112,7 +14117,7 @@ simple_ident:
| ident '.' ident
{
LEX *lex= thd->lex;
- if (!($$= lex->create_item_ident(thd, $1, $3,
+ if (!($$= lex->create_item_ident(thd, &$1, &$3,
$1.m_pos -
lex->substatement_query(thd),
YYLIP->get_tok_end() - $1.m_pos)))
@@ -14123,7 +14128,7 @@ simple_ident:
simple_ident_nospvar:
ident
{
- if (!($$= Lex->create_item_ident_nosp(thd, $1)))
+ if (!($$= Lex->create_item_ident_nosp(thd, &$1)))
MYSQL_YYABORT;
}
| simple_ident_q { $$= $1; }
@@ -14132,7 +14137,7 @@ simple_ident_nospvar:
simple_ident_q:
ident '.' ident
{
- if (!($$= Lex->create_item_ident_nospvar(thd, $1, $3)))
+ if (!($$= Lex->create_item_ident_nospvar(thd, &$1, &$3)))
MYSQL_YYABORT;
}
| simple_ident_q2
@@ -14141,12 +14146,12 @@ simple_ident_q:
simple_ident_q2:
'.' ident '.' ident
{
- if (!($$= Lex->create_item_ident(thd, null_lex_str, $2, $4)))
+ if (!($$= Lex->create_item_ident(thd, &null_clex_str, &$2, &$4)))
MYSQL_YYABORT;
}
| ident '.' ident '.' ident
{
- if (!($$= Lex->create_item_ident(thd, $1, $3, $5)))
+ if (!($$= Lex->create_item_ident(thd, &$1, &$3, &$5)))
MYSQL_YYABORT;
}
;
@@ -14176,20 +14181,20 @@ field_ident:
table_ident:
ident
{
- $$= new (thd->mem_root) Table_ident($1);
+ $$= new (thd->mem_root) Table_ident(&$1);
if ($$ == NULL)
MYSQL_YYABORT;
}
| ident '.' ident
{
- $$= new (thd->mem_root) Table_ident(thd, $1, $3, 0);
+ $$= new (thd->mem_root) Table_ident(thd, &$1, &$3, 0);
if ($$ == NULL)
MYSQL_YYABORT;
}
| '.' ident
{
/* For Delphi */
- $$= new (thd->mem_root) Table_ident($2);
+ $$= new (thd->mem_root) Table_ident(&$2);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -14198,13 +14203,13 @@ table_ident:
table_ident_opt_wild:
ident opt_wild
{
- $$= new (thd->mem_root) Table_ident($1);
+ $$= new (thd->mem_root) Table_ident(&$1);
if ($$ == NULL)
MYSQL_YYABORT;
}
| ident '.' ident opt_wild
{
- $$= new (thd->mem_root) Table_ident(thd, $1, $3, 0);
+ $$= new (thd->mem_root) Table_ident(thd, &$1, &$3, 0);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -14213,8 +14218,8 @@ table_ident_opt_wild:
table_ident_nodb:
ident
{
- LEX_STRING db={(char*) any_db,3};
- $$= new (thd->mem_root) Table_ident(thd, db, $1, 0);
+ LEX_CSTRING db={(char*) any_db,3};
+ $$= new (thd->mem_root) Table_ident(thd, &db, &$1, 0);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -14239,9 +14244,12 @@ IDENT_sys:
}
else
{
- if (thd->convert_with_error(system_charset_info, &$$,
+ LEX_STRING to;
+ if (thd->convert_with_error(system_charset_info, &to,
thd->charset(), $1.str, $1.length))
MYSQL_YYABORT;
+ $$.str= to.str;
+ $$.length= to.length;
}
}
;
@@ -14253,9 +14261,12 @@ TEXT_STRING_sys:
$$= $1;
else
{
- if (thd->convert_string(&$$, system_charset_info,
+ LEX_STRING to;
+ if (thd->convert_string(&to, system_charset_info,
$1.str, $1.length, thd->charset()))
MYSQL_YYABORT;
+ $$.str= to.str;
+ $$.length= to.length;
}
}
;
@@ -14267,10 +14278,13 @@ TEXT_STRING_literal:
$$= $1;
else
{
- if (thd->convert_string(&$$, thd->variables.collation_connection,
+ LEX_STRING to;
+ if (thd->convert_string(&to, thd->variables.collation_connection,
$1.str, $1.length, thd->charset()))
MYSQL_YYABORT;
- }
+ $$.str= to.str;
+ $$.length= to.length;
+ }
}
;
@@ -14281,10 +14295,13 @@ TEXT_STRING_filesystem:
$$= $1;
else
{
- if (thd->convert_string(&$$,
+ LEX_STRING to;
+ if (thd->convert_string(&to,
thd->variables.character_set_filesystem,
$1.str, $1.length, thd->charset()))
MYSQL_YYABORT;
+ $$.str= to.str;
+ $$.length= to.length;
}
}
;
@@ -14292,7 +14309,7 @@ TEXT_STRING_filesystem:
ident:
IDENT_sys
{
- (LEX_STRING &)$$= $1;
+ (LEX_CSTRING &)$$= $1;
$$.m_pos= (char *) YYLIP->get_tok_start_prev();
}
| keyword
@@ -14308,7 +14325,7 @@ ident:
ident_with_tok_start:
IDENT_sys
{
- (LEX_STRING &)$$= $1;
+ (LEX_CSTRING &)$$= $1;
$$.m_pos= (char *) YYLIP->get_tok_start();
}
| keyword
@@ -14343,7 +14360,7 @@ user_maybe_role:
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
MYSQL_YYABORT;
$$->user = $1;
- $$->host= null_lex_str; // User or Role, see get_current_user()
+ $$->host= null_clex_str; // User or Role, see get_current_user()
$$->reset_auth();
if (check_string_char_length(&$$->user, ER_USERNAME,
@@ -14370,7 +14387,7 @@ user_maybe_role:
It's OK to use in-place lowercase as long as
the character set is utf8.
*/
- my_casedn_str(system_charset_info, $$->host.str);
+ my_casedn_str(system_charset_info, (char*) $$->host.str);
}
else
{
@@ -14386,8 +14403,8 @@ user_maybe_role:
if (!($$=(LEX_USER*)thd->calloc(sizeof(LEX_USER))))
MYSQL_YYABORT;
$$->user= current_user;
- $$->plugin= empty_lex_str;
- $$->auth= empty_lex_str;
+ $$->plugin= empty_clex_str;
+ $$->auth= empty_clex_str;
}
;
@@ -14992,14 +15009,14 @@ option_value_no_option_type:
ident equal set_expr_or_default
{
struct sys_var_with_base var;
- if (Lex->init_internal_variable(&var, $1) ||
+ if (Lex->init_internal_variable(&var, &$1) ||
Lex->set_variable(&var, $3))
MYSQL_YYABORT;
}
| ident '.' ident equal set_expr_or_default
{
DBUG_ASSERT(Lex->var_list.is_empty());
- if (Lex->set_variable($1, $3, $5))
+ if (Lex->set_variable(&$1, &$3, $5))
MYSQL_YYABORT;
}
| DEFAULT '.' ident equal set_expr_or_default
@@ -15012,7 +15029,7 @@ option_value_no_option_type:
| '@' ident_or_text equal expr
{
Item_func_set_user_var *item;
- item= new (thd->mem_root) Item_func_set_user_var(thd, $2, $4);
+ item= new (thd->mem_root) Item_func_set_user_var(thd, &$2, $4);
if (item == NULL)
MYSQL_YYABORT;
set_var_user *var= new (thd->mem_root) set_var_user(item);
@@ -15050,15 +15067,11 @@ option_value_no_option_type:
{
LEX *lex= Lex;
sp_pcontext *spc= lex->spcont;
- LEX_STRING names;
-
- names.str= (char *)"names";
- names.length= 5;
- if (spc && spc->find_variable(names, false))
+ LEX_CSTRING names= { STRING_WITH_LEN("names") };
+ if (spc && spc->find_variable(&names, false))
my_error(ER_SP_BAD_VAR_SHADOW, MYF(0), names.str);
else
thd->parse_error();
-
MYSQL_YYABORT;
}
| NAMES_SYM charset_name_or_default opt_collate
@@ -15135,12 +15148,12 @@ option_value_no_option_type:
internal_variable_name:
ident
{
- if (Lex->init_internal_variable(&$$, $1))
+ if (Lex->init_internal_variable(&$$, &$1))
MYSQL_YYABORT;
}
| ident '.' ident
{
- if (Lex->init_internal_variable(&$$, $1, $3))
+ if (Lex->init_internal_variable(&$$, &$1, &$3))
MYSQL_YYABORT;
}
| DEFAULT '.' ident
@@ -15167,7 +15180,7 @@ transaction_access_mode:
set_var *var= (new (thd->mem_root)
set_var(thd, lex->option_type,
find_sys_var(thd, "tx_read_only"),
- &null_lex_str,
+ &null_clex_str,
item));
if (var == NULL)
MYSQL_YYABORT;
@@ -15185,7 +15198,7 @@ isolation_level:
set_var *var= (new (thd->mem_root)
set_var(thd, lex->option_type,
find_sys_var(thd, "tx_isolation"),
- &null_lex_str,
+ &null_clex_str,
item));
if (var == NULL)
MYSQL_YYABORT;
@@ -15210,15 +15223,15 @@ opt_for_user:
{
LEX *lex= thd->lex;
sp_pcontext *spc= lex->spcont;
- LEX_STRING pw= { C_STRING_WITH_LEN("password") };
+ LEX_CSTRING pw= { STRING_WITH_LEN("password") };
- if (spc && spc->find_variable(pw, false))
+ if (spc && spc->find_variable(&pw, false))
my_yyabort_error((ER_SP_BAD_VAR_SHADOW, MYF(0), pw.str));
if (!(lex->definer= (LEX_USER*) thd->calloc(sizeof(LEX_USER))))
MYSQL_YYABORT;
lex->definer->user= current_user;
- lex->definer->plugin= empty_lex_str;
- lex->definer->auth= empty_lex_str;
+ lex->definer->plugin= empty_clex_str;
+ lex->definer->auth= empty_clex_str;
}
| FOR_SYM user equal { Lex->definer= $2; }
;
@@ -15377,7 +15390,7 @@ handler:
;
handler_read_or_scan:
- handler_scan_function { Lex->ident= null_lex_str; }
+ handler_scan_function { Lex->ident= null_clex_str; }
| ident handler_rkey_function { Lex->ident= $1; }
;
@@ -15565,13 +15578,13 @@ grant_role:
CHARSET_INFO *cs= system_charset_info;
/* trim end spaces (as they'll be lost in mysql.user anyway) */
$1.length= cs->cset->lengthsp(cs, $1.str, $1.length);
- $1.str[$1.length] = '\0';
+ ((char*) $1.str)[$1.length] = '\0';
if ($1.length == 0)
my_yyabort_error((ER_INVALID_ROLE, MYF(0), ""));
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
MYSQL_YYABORT;
- $$->user = $1;
- $$->host= empty_lex_str;
+ $$->user= $1;
+ $$->host= empty_clex_str;
$$->reset_auth();
if (check_string_char_length(&$$->user, ER_USERNAME,
@@ -15781,7 +15794,7 @@ grant_user:
{
$$= $1;
$1->plugin= $4;
- $1->auth= empty_lex_str;
+ $1->auth= empty_clex_str;
}
| user IDENTIFIED_SYM via_or_with ident_or_text using_or_as TEXT_STRING_sys
{
@@ -16376,7 +16389,8 @@ view_select:
void *create_view_select= thd->memdup(lex->create_view_select.str, len);
lex->create_view_select.length= len;
lex->create_view_select.str= (char *) create_view_select;
- trim_whitespace(thd->charset(), &lex->create_view_select,
+ trim_whitespace(thd->charset(),
+ &lex->create_view_select,
&not_used);
lex->parsing_options.allows_variable= TRUE;
lex->current_select->set_with_clause($2);
@@ -16498,7 +16512,7 @@ trigger_tail:
lex->query_tables can be wiped out.
*/
if (!lex->select_lex.add_table_to_list(thd, $11,
- (LEX_STRING*) 0,
+ (LEX_CSTRING*) 0,
TL_OPTION_UPDATING,
TL_READ_NO_INSERT,
MDL_SHARED_NO_WRITE))
@@ -16547,7 +16561,8 @@ sf_tail:
RETURNS_SYM /* $6 */
{ /* $7 */
LEX *lex= Lex;
- lex->init_last_field(&lex->sphead->m_return_field_def, NULL,
+ lex->init_last_field(&lex->sphead->m_return_field_def,
+ &empty_clex_str,
thd->variables.collation_database);
}
type_with_opt_collate /* $8 */
@@ -16698,7 +16713,7 @@ install:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_INSTALL_PLUGIN;
- lex->comment= null_lex_str;
+ lex->comment= null_clex_str;
lex->ident= $3;
}
;
@@ -16714,7 +16729,7 @@ uninstall:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;
- lex->comment= null_lex_str;
+ lex->comment= null_clex_str;
lex->ident= $3;
}
;
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index aa76dabff1f..77ced40ed5f 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -168,7 +168,7 @@ void ORAerror(THD *thd, const char *s)
uint sp_instr_addr;
/* structs */
- LEX_STRING lex_str;
+ LEX_CSTRING lex_str;
LEX_SYMBOL symbol;
Lex_string_with_metadata_st lex_string_with_metadata;
struct sys_var_with_base variable;
@@ -183,7 +183,7 @@ void ORAerror(THD *thd, const char *s)
Lex_for_loop_bounds_st for_loop_bounds;
struct
{
- LEX_STRING name;
+ LEX_CSTRING name;
uint offset;
} sp_cursor_name_and_offset;
@@ -202,7 +202,7 @@ void ORAerror(THD *thd, const char *s)
LEX *lex;
sp_assignment_lex *assignment_lex;
class sp_lex_cursor *sp_cursor_stmt;
- LEX_STRING *lex_str_ptr;
+ LEX_CSTRING *lex_str_ptr;
LEX_USER *lex_user;
List<Condition_information_item> *cond_info_list;
List<DYNCALL_CREATE_DEF> *dyncol_def_list;
@@ -210,7 +210,7 @@ void ORAerror(THD *thd, const char *s)
List<sp_assignment_lex> *sp_assignment_lex_list;
List<Statement_information_item> *stmt_info_list;
List<String> *string_list;
- List<LEX_STRING> *lex_str_list;
+ List<LEX_CSTRING> *lex_str_list;
Statement_information_item *stmt_info_item;
String *string;
TABLE_LIST *table_list;
@@ -1024,7 +1024,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
label_declaration_oracle labels_declaration_oracle
ident_directly_assignable
sp_decl_ident
- sp_block_label
+ sp_block_label opt_place opt_db
%type <lex_string_with_metadata>
TEXT_STRING
@@ -1045,15 +1045,14 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
optionally_qualified_column_ident
%type <simple_string>
- remember_name remember_end opt_db remember_tok_start
+ remember_name remember_end remember_tok_start
wild_and_where
- field_length opt_field_length opt_field_length_default_1
colon_with_pos
- opt_field_length_default_sp_param_char
- opt_field_length_default_sp_param_varchar
%type <const_simple_string>
- opt_place
+ field_length opt_field_length opt_field_length_default_1
+ opt_field_length_default_sp_param_varchar
+ opt_field_length_default_sp_param_char
%type <string>
text_string hex_or_bin_String opt_gconcat_separator
@@ -1864,7 +1863,7 @@ optional_connection_name:
/* empty */
{
LEX *lex= thd->lex;
- lex->mi.connection_name= null_lex_str;
+ lex->mi.connection_name= null_clex_str;
}
| connection_name
;
@@ -1900,7 +1899,7 @@ create:
*/
lex->query_tables->open_strategy= TABLE_LIST::OPEN_STUB;
lex->create_info.default_table_charset= NULL;
- lex->name= null_lex_str;
+ lex->name= null_clex_str;
lex->create_last_non_select_table= lex->last_table();
}
create_body
@@ -1938,7 +1937,7 @@ create:
*/
lex->alter_info.reset();
lex->query_tables->open_strategy= TABLE_LIST::OPEN_STUB;
- lex->name= null_lex_str;
+ lex->name= null_clex_str;
lex->create_last_non_select_table= lex->last_table();
if (!(lex->create_info.seq_create_info= new (thd->mem_root)
sequence_definition()))
@@ -1983,7 +1982,7 @@ create:
{
if (Lex->add_create_index_prepare($8))
MYSQL_YYABORT;
- if (Lex->add_create_index($2, $5, $6, $1 | $4))
+ if (Lex->add_create_index($2, &$5, $6, $1 | $4))
MYSQL_YYABORT;
}
'(' key_list ')' normal_key_options
@@ -1993,7 +1992,7 @@ create:
{
if (Lex->add_create_index_prepare($7))
MYSQL_YYABORT;
- if (Lex->add_create_index($2, $5, HA_KEY_ALG_UNDEF, $1 | $4))
+ if (Lex->add_create_index($2, &$5, HA_KEY_ALG_UNDEF, $1 | $4))
MYSQL_YYABORT;
}
'(' key_list ')' fulltext_key_options
@@ -2003,7 +2002,7 @@ create:
{
if (Lex->add_create_index_prepare($7))
MYSQL_YYABORT;
- if (Lex->add_create_index($2, $5, HA_KEY_ALG_UNDEF, $1 | $4))
+ if (Lex->add_create_index($2, &$5, HA_KEY_ALG_UNDEF, $1 | $4))
MYSQL_YYABORT;
}
'(' key_list ')' spatial_key_options
@@ -2150,7 +2149,8 @@ server_option:
{
MYSQL_YYABORT_UNLESS(Lex->server_options.host.str == 0);
Lex->server_options.host= $2;
- my_casedn_str(system_charset_info, Lex->server_options.host.str);
+ my_casedn_str(system_charset_info,
+ (char*) Lex->server_options.host.str);
}
| DATABASE TEXT_STRING_sys
{
@@ -2353,12 +2353,12 @@ clear_privileges:
sp_name:
ident '.' ident
{
- if (!($$= Lex->make_sp_name(thd, $1, $3)))
+ if (!($$= Lex->make_sp_name(thd, &$1, &$3)))
MYSQL_YYABORT;
}
| ident
{
- if (!($$= Lex->make_sp_name(thd, $1)))
+ if (!($$= Lex->make_sp_name(thd, &$1)))
MYSQL_YYABORT;
}
;
@@ -2462,7 +2462,7 @@ sp_fdparams:
sp_param_name:
ident
{
- if (!($$= Lex->sp_param_init($1)))
+ if (!($$= Lex->sp_param_init(&$1)))
MYSQL_YYABORT;
}
;
@@ -2480,7 +2480,7 @@ sp_param_name_and_type:
| sp_param_name field_type_row
{
$$= $1;
- $$->field_def.field_name= $$->name.str;
+ $$->field_def.field_name= $$->name;
Lex->sphead->fill_spvar_definition(thd, &$$->field_def);
Lex->sphead->row_fill_field_definitions(thd, $2);
$$->field_def.set_row_field_definitions($2);
@@ -2512,7 +2512,7 @@ sp_pdparam:
| sp_param_name sp_opt_inout field_type_row
{
$1->mode= $2;
- $1->field_def.field_name= $1->name.str;
+ $1->field_def.field_name= $1->name;
Lex->sphead->fill_spvar_definition(thd, &$1->field_def);
Lex->sphead->row_fill_field_definitions(thd, $3);
$1->field_def.set_row_field_definitions($3);
@@ -2635,13 +2635,13 @@ opt_sp_decl_handler_list:
qualified_column_ident:
sp_decl_ident '.' ident
{
- if (!($$= new (thd->mem_root) Qualified_column_ident($1, $3)))
+ if (!($$= new (thd->mem_root) Qualified_column_ident(&$1, &$3)))
MYSQL_YYABORT;
}
| sp_decl_ident '.' ident '.' ident
{
if (!($$= new (thd->mem_root) Qualified_column_ident(thd,
- $1, $3, $5)))
+ &$1, &$3, &$5)))
MYSQL_YYABORT;
}
;
@@ -2649,18 +2649,18 @@ qualified_column_ident:
optionally_qualified_column_ident:
sp_decl_ident
{
- if (!($$= new (thd->mem_root) Qualified_column_ident($1)))
+ if (!($$= new (thd->mem_root) Qualified_column_ident(&$1)))
MYSQL_YYABORT;
}
| sp_decl_ident '.' ident
{
- if (!($$= new (thd->mem_root) Qualified_column_ident($1, $3)))
+ if (!($$= new (thd->mem_root) Qualified_column_ident(&$1, &$3)))
MYSQL_YYABORT;
}
| sp_decl_ident '.' ident '.' ident
{
if (!($$= new (thd->mem_root) Qualified_column_ident(thd,
- $1, $3, $5)))
+ &$1, &$3, &$5)))
MYSQL_YYABORT;
}
;
@@ -2673,7 +2673,7 @@ row_field_name:
my_yyabort_error((ER_TOO_LONG_IDENT, MYF(0), $1.str));
if (!($$= new (thd->mem_root) Spvar_definition()))
MYSQL_YYABORT;
- Lex->init_last_field($$, $1.str, thd->variables.collation_database);
+ Lex->init_last_field($$, &$1, thd->variables.collation_database);
}
;
@@ -2691,8 +2691,8 @@ row_field_definition_list:
| row_field_definition_list ',' row_field_definition
{
uint unused;
- if ($1->find_row_field_by_name($3->field_name, &unused))
- my_yyabort_error((ER_DUP_FIELDNAME, MYF(0), $3->field_name));
+ if ($1->find_row_field_by_name(&$3->field_name, &unused))
+ my_yyabort_error((ER_DUP_FIELDNAME, MYF(0), $3->field_name.str));
$$= $1;
$$->push_back($3, thd->mem_root);
}
@@ -2746,7 +2746,7 @@ sp_decl_non_handler:
}
| ident_directly_assignable CONDITION_SYM FOR_SYM sp_cond
{
- if (Lex->spcont->declare_condition(thd, $1, $4))
+ if (Lex->spcont->declare_condition(thd, &$1, $4))
MYSQL_YYABORT;
$$.vars= $$.hndlrs= $$.curs= 0;
$$.conds= 1;
@@ -2756,7 +2756,7 @@ sp_decl_non_handler:
sp_condition_value *spcond= new (thd->mem_root)
sp_condition_value_user_defined();
if (!spcond ||
- Lex->spcont->declare_condition(thd, $1, spcond))
+ Lex->spcont->declare_condition(thd, &$1, spcond))
MYSQL_YYABORT;
$$.vars= $$.hndlrs= $$.curs= 0;
$$.conds= 1;
@@ -2771,7 +2771,7 @@ sp_decl_non_handler:
sp_pcontext *param_ctx= Lex->spcont;
if (Lex->sp_block_finalize(thd))
MYSQL_YYABORT;
- if (Lex->sp_declare_cursor(thd, $2, $6, param_ctx, false))
+ if (Lex->sp_declare_cursor(thd, &$2, $6, param_ctx, false))
MYSQL_YYABORT;
$$.vars= $$.conds= $$.hndlrs= 0;
$$.curs= 1;
@@ -2894,7 +2894,7 @@ sp_hcond:
}
| ident /* CONDITION name */
{
- $$= Lex->spcont->find_declared_or_predefined_condition($1);
+ $$= Lex->spcont->find_declared_or_predefined_condition(&$1);
if ($$ == NULL)
my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str));
}
@@ -2949,7 +2949,7 @@ signal_value:
/* SIGNAL foo cannot be used outside of stored programs */
if (lex->spcont == NULL)
my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str));
- cond= lex->spcont->find_declared_or_predefined_condition($1);
+ cond= lex->spcont->find_declared_or_predefined_condition(&$1);
if (cond == NULL)
my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str));
if (!cond->has_sql_state())
@@ -3125,7 +3125,7 @@ simple_target_specification:
ident
{
Lex_input_stream *lip= &thd->m_parser_state->m_lip;
- $$= thd->lex->create_item_for_sp_var($1, NULL,
+ $$= thd->lex->create_item_for_sp_var(&$1, NULL,
lip->get_tok_start(),
lip->get_ptr());
if ($$ == NULL)
@@ -3133,7 +3133,7 @@ simple_target_specification:
}
| '@' ident_or_text
{
- $$= new (thd->mem_root) Item_func_get_user_var(thd, $2);
+ $$= new (thd->mem_root) Item_func_get_user_var(thd, &$2);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -3232,9 +3232,9 @@ sp_decl_idents:
LEX *lex= Lex;
sp_pcontext *spc= lex->spcont;
- if (spc->find_variable($1, TRUE))
+ if (spc->find_variable(&$1, TRUE))
my_yyabort_error((ER_SP_DUP_VAR, MYF(0), $1.str));
- spc->add_variable(thd, $1);
+ spc->add_variable(thd, &$1);
$$= 1;
}
| sp_decl_idents ',' ident
@@ -3244,9 +3244,9 @@ sp_decl_idents:
LEX *lex= Lex;
sp_pcontext *spc= lex->spcont;
- if (spc->find_variable($3, TRUE))
+ if (spc->find_variable(&$3, TRUE))
my_yyabort_error((ER_SP_DUP_VAR, MYF(0), $3.str));
- spc->add_variable(thd, $3);
+ spc->add_variable(thd, &$3);
$$= $1 + 1;
}
;
@@ -3306,7 +3306,7 @@ sp_statement:
{
// Direct procedure call (without the CALL keyword)
LEX *lex = Lex;
- if (!(lex->spname= lex->make_sp_name(thd, $1)))
+ if (!(lex->spname= lex->make_sp_name(thd, &$1)))
MYSQL_YYABORT;
lex->sql_command= SQLCOM_CALL;
lex->value_list.empty();
@@ -3316,7 +3316,7 @@ sp_statement:
| ident_directly_assignable '.' ident
{
LEX *lex = Lex;
- if (!(lex->spname= lex->make_sp_name(thd, $1, $3)))
+ if (!(lex->spname= lex->make_sp_name(thd, &$1, &$3)))
MYSQL_YYABORT;
lex->sql_command= SQLCOM_CALL;
lex->value_list.empty();
@@ -3430,7 +3430,7 @@ sp_proc_stmt_exit:
}
| EXIT_SYM label_ident
{
- if (Lex->sp_exit_statement(thd, $2, NULL))
+ if (Lex->sp_exit_statement(thd, &$2, NULL))
MYSQL_YYABORT;
}
| EXIT_SYM WHEN_SYM reset_lex_expr
@@ -3441,7 +3441,7 @@ sp_proc_stmt_exit:
}
| EXIT_SYM label_ident WHEN_SYM reset_lex_expr
{
- if (Lex->sp_exit_statement(thd, $2, $4) ||
+ if (Lex->sp_exit_statement(thd, &$2, $4) ||
Lex->sphead->restore_lex(thd))
MYSQL_YYABORT;
}
@@ -3455,7 +3455,7 @@ sp_proc_stmt_continue:
}
| CONTINUE_SYM label_ident
{
- if (Lex->sp_continue_statement(thd, $2, NULL))
+ if (Lex->sp_continue_statement(thd, &$2, NULL))
MYSQL_YYABORT;
}
| CONTINUE_SYM WHEN_SYM reset_lex_expr
@@ -3466,7 +3466,7 @@ sp_proc_stmt_continue:
}
| CONTINUE_SYM label_ident WHEN_SYM reset_lex_expr
{
- if (Lex->sp_continue_statement(thd, $2, $4) ||
+ if (Lex->sp_continue_statement(thd, &$2, $4) ||
Lex->sphead->restore_lex(thd))
MYSQL_YYABORT;
}
@@ -3476,7 +3476,7 @@ sp_proc_stmt_continue:
sp_proc_stmt_leave:
LEAVE_SYM label_ident
{
- if (Lex->sp_leave_statement(thd, $2))
+ if (Lex->sp_leave_statement(thd, &$2))
MYSQL_YYABORT;
}
;
@@ -3484,7 +3484,7 @@ sp_proc_stmt_leave:
sp_proc_stmt_iterate:
ITERATE_SYM label_ident
{
- if (Lex->sp_iterate_statement(thd, $2))
+ if (Lex->sp_iterate_statement(thd, &$2))
MYSQL_YYABORT;
}
;
@@ -3492,7 +3492,7 @@ sp_proc_stmt_iterate:
sp_proc_stmt_goto:
GOTO_SYM label_ident
{
- if (Lex->sp_goto_statement(thd, $2))
+ if (Lex->sp_goto_statement(thd, &$2))
MYSQL_YYABORT;
}
;
@@ -3562,7 +3562,7 @@ opt_parenthesized_cursor_actual_parameters:
sp_proc_stmt_open:
OPEN_SYM ident opt_parenthesized_cursor_actual_parameters
{
- if (Lex->sp_open_cursor(thd, $2, $3))
+ if (Lex->sp_open_cursor(thd, &$2, $3))
MYSQL_YYABORT;
}
;
@@ -3570,17 +3570,17 @@ sp_proc_stmt_open:
sp_proc_stmt_fetch_head:
FETCH_SYM ident INTO
{
- if (Lex->sp_add_cfetch(thd, $2))
+ if (Lex->sp_add_cfetch(thd, &$2))
MYSQL_YYABORT;
}
| FETCH_SYM FROM ident INTO
{
- if (Lex->sp_add_cfetch(thd, $3))
+ if (Lex->sp_add_cfetch(thd, &$3))
MYSQL_YYABORT;
}
| FETCH_SYM NEXT_SYM FROM ident INTO
{
- if (Lex->sp_add_cfetch(thd, $4))
+ if (Lex->sp_add_cfetch(thd, &$4))
MYSQL_YYABORT;
}
;
@@ -3597,7 +3597,7 @@ sp_proc_stmt_close:
uint offset;
sp_instr_cclose *i;
- if (! lex->spcont->find_cursor($2, &offset, false))
+ if (! lex->spcont->find_cursor(&$2, &offset, false))
my_yyabort_error((ER_SP_CURSOR_MISMATCH, MYF(0), $2.str));
i= new (thd->mem_root)
sp_instr_cclose(sp->instructions(), lex->spcont, offset);
@@ -3615,7 +3615,7 @@ sp_fetch_list:
sp_pcontext *spc= lex->spcont;
sp_variable *spv;
- if (!spc || !(spv = spc->find_variable($1, false)))
+ if (!spc || !(spv = spc->find_variable(&$1, false)))
my_yyabort_error((ER_SP_UNDECLARED_VAR, MYF(0), $1.str));
/* An SP local variable */
@@ -3629,7 +3629,7 @@ sp_fetch_list:
sp_pcontext *spc= lex->spcont;
sp_variable *spv;
- if (!spc || !(spv = spc->find_variable($3, false)))
+ if (!spc || !(spv = spc->find_variable(&$3, false)))
my_yyabort_error((ER_SP_UNDECLARED_VAR, MYF(0), $3.str));
/* An SP local variable */
@@ -3649,7 +3649,7 @@ sp_if:
sp_instr_jump_if_not *i= new (thd->mem_root)
sp_instr_jump_if_not(ip, ctx, $2, lex);
if (i == NULL ||
- sp->push_backpatch(thd, i, ctx->push_label(thd, empty_lex_str, 0)) ||
+ sp->push_backpatch(thd, i, ctx->push_label(thd, &empty_clex_str, 0)) ||
sp->add_cont_backpatch(i) ||
sp->add_instr(i))
MYSQL_YYABORT;
@@ -3666,7 +3666,7 @@ sp_if:
sp->add_instr(i))
MYSQL_YYABORT;
sp->backpatch(ctx->pop_label());
- sp->push_backpatch(thd, i, ctx->push_label(thd, empty_lex_str, 0));
+ sp->push_backpatch(thd, i, ctx->push_label(thd, &empty_clex_str, 0));
}
sp_elseifs
{
@@ -3731,7 +3731,7 @@ case_stmt_specification:
BACKPATCH: Creating target label for the jump to after END CASE
(instruction 12 in the example)
*/
- Lex->spcont->push_label(thd, empty_lex_str, Lex->sphead->instructions());
+ Lex->spcont->push_label(thd, &empty_clex_str, Lex->sphead->instructions());
}
case_stmt_body
else_clause_opt
@@ -3840,14 +3840,14 @@ else_clause_opt:
;
sp_opt_label:
- /* Empty */ { $$= null_lex_str; }
+ /* Empty */ { $$= null_clex_str; }
| label_ident { $$= $1; }
;
sp_block_label:
labels_declaration_oracle
{
- if (Lex->spcont->block_label_declare($1))
+ if (Lex->spcont->block_label_declare(&$1))
MYSQL_YYABORT;
$$= $1;
}
@@ -3857,7 +3857,7 @@ sp_labeled_block:
sp_block_label
BEGIN_SYM
{
- Lex->sp_block_init(thd, $1);
+ Lex->sp_block_init(thd, &$1);
if (Lex->sp_block_with_exceptions_finalize_declarations(thd))
MYSQL_YYABORT;
}
@@ -3865,13 +3865,13 @@ sp_labeled_block:
END
sp_opt_label
{
- if (Lex->sp_block_finalize(thd, Lex_spblock($4), $6))
+ if (Lex->sp_block_finalize(thd, Lex_spblock($4), &$6))
MYSQL_YYABORT;
}
| sp_block_label
DECLARE_SYM
{
- Lex->sp_block_init(thd, $1);
+ Lex->sp_block_init(thd, &$1);
}
sp_decl_body_list
{
@@ -3884,7 +3884,7 @@ sp_labeled_block:
sp_opt_label
{
$4.hndlrs+= $7.hndlrs;
- if (Lex->sp_block_finalize(thd, $4, $9))
+ if (Lex->sp_block_finalize(thd, $4, &$9))
MYSQL_YYABORT;
}
;
@@ -4003,7 +4003,7 @@ opt_sp_for_loop_direction:
sp_for_loop_index_and_bounds:
ident_directly_assignable sp_for_loop_bounds
{
- if (Lex->sp_for_loop_declarations(thd, &$$, $1, $2))
+ if (Lex->sp_for_loop_declarations(thd, &$$, &$1, $2))
MYSQL_YYABORT;
}
;
@@ -4028,8 +4028,8 @@ sp_for_loop_bounds:
{
Item *item;
DBUG_ASSERT(Lex->sphead);
- LEX_STRING name= {C_STRING_WITH_LEN("[implicit_cursor]") };
- if (Lex->sp_declare_cursor(thd, name, $4, NULL, true))
+ LEX_CSTRING name= {STRING_WITH_LEN("[implicit_cursor]") };
+ if (Lex->sp_declare_cursor(thd, &name, $4, NULL, true))
MYSQL_YYABORT;
if (!($$.m_index= new (thd->mem_root) sp_assignment_lex(thd, thd->lex)))
MYSQL_YYABORT;
@@ -4037,7 +4037,7 @@ sp_for_loop_bounds:
Lex->sphead->reset_lex(thd, $$.m_index);
if (!(item= new (thd->mem_root) Item_field(thd,
Lex->current_context(),
- NullS, NullS, name.str)))
+ NullS, NullS, &name)))
MYSQL_YYABORT;
$$.m_index->set_item_and_free_list(item, NULL);
if (Lex->sphead->restore_lex(thd))
@@ -4101,7 +4101,7 @@ repeat_body:
pop_sp_loop_label:
sp_opt_label
{
- if (Lex->sp_pop_loop_label(thd, $1))
+ if (Lex->sp_pop_loop_label(thd, &$1))
MYSQL_YYABORT;
}
;
@@ -4109,14 +4109,14 @@ pop_sp_loop_label:
sp_labeled_control:
labels_declaration_oracle LOOP_SYM
{
- if (Lex->sp_push_loop_label(thd, $1))
+ if (Lex->sp_push_loop_label(thd, &$1))
MYSQL_YYABORT;
}
loop_body pop_sp_loop_label
{ }
| labels_declaration_oracle WHILE_SYM
{
- if (Lex->sp_push_loop_label(thd, $1))
+ if (Lex->sp_push_loop_label(thd, &$1))
MYSQL_YYABORT;
Lex->sphead->reset_lex(thd);
}
@@ -4129,7 +4129,7 @@ sp_labeled_control:
}
sp_for_loop_index_and_bounds
{
- if (Lex->sp_push_loop_label(thd, $1)) // The inner WHILE block
+ if (Lex->sp_push_loop_label(thd, &$1)) // The inner WHILE block
MYSQL_YYABORT;
if (Lex->sp_for_loop_condition_test(thd, $4))
MYSQL_YYABORT;
@@ -4150,7 +4150,7 @@ sp_labeled_control:
}
| labels_declaration_oracle REPEAT_SYM
{
- if (Lex->sp_push_loop_label(thd, $1))
+ if (Lex->sp_push_loop_label(thd, &$1))
MYSQL_YYABORT;
}
repeat_body pop_sp_loop_label
@@ -4568,11 +4568,11 @@ size_number:
ulonglong number;
uint text_shift_number= 0;
longlong prefix_number;
- char *start_ptr= $1.str;
+ const char *start_ptr= $1.str;
uint str_len= $1.length;
- char *end_ptr= start_ptr + str_len;
+ const char *end_ptr= start_ptr + str_len;
int error;
- prefix_number= my_strtoll10(start_ptr, &end_ptr, &error);
+ prefix_number= my_strtoll10(start_ptr, (char**) &end_ptr, &error);
if ((start_ptr + str_len - 1) == end_ptr)
{
switch (end_ptr[0])
@@ -4726,7 +4726,7 @@ have_partitioning:
/* empty */
{
#ifdef WITH_PARTITION_STORAGE_ENGINE
- LEX_STRING partition_name={C_STRING_WITH_LEN("partition")};
+ LEX_CSTRING partition_name={STRING_WITH_LEN("partition")};
if (!plugin_is_ready(&partition_name, MYSQL_STORAGE_ENGINE_PLUGIN))
my_yyabort_error((ER_OPTION_PREVENTS_STATEMENT, MYF(0),
"--skip-partition"));
@@ -5834,28 +5834,28 @@ key_def:
key_or_index opt_if_not_exists opt_ident opt_USING_key_algorithm
{
Lex->option_list= NULL;
- if (Lex->add_key(Key::MULTIPLE, $3, $4, $2))
+ if (Lex->add_key(Key::MULTIPLE, &$3, $4, $2))
MYSQL_YYABORT;
}
'(' key_list ')' normal_key_options { }
| key_or_index opt_if_not_exists ident TYPE_SYM btree_or_rtree
{
Lex->option_list= NULL;
- if (Lex->add_key(Key::MULTIPLE, $3, $5, $2))
+ if (Lex->add_key(Key::MULTIPLE, &$3, $5, $2))
MYSQL_YYABORT;
}
'(' key_list ')' normal_key_options { }
| fulltext opt_key_or_index opt_if_not_exists opt_ident
{
Lex->option_list= NULL;
- if (Lex->add_key($1, $4, HA_KEY_ALG_UNDEF, $3))
+ if (Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3))
MYSQL_YYABORT;
}
'(' key_list ')' fulltext_key_options { }
| spatial opt_key_or_index opt_if_not_exists opt_ident
{
Lex->option_list= NULL;
- if (Lex->add_key($1, $4, HA_KEY_ALG_UNDEF, $3))
+ if (Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3))
MYSQL_YYABORT;
}
'(' key_list ')' spatial_key_options { }
@@ -5864,7 +5864,7 @@ key_def:
opt_USING_key_algorithm
{
Lex->option_list= NULL;
- if (Lex->add_key($2, $4.str ? $4 : $1, $5, $3))
+ if (Lex->add_key($2, $4.str ? &$4 : &$1, $5, $3))
MYSQL_YYABORT;
}
'(' key_list ')' normal_key_options { }
@@ -5872,7 +5872,7 @@ key_def:
TYPE_SYM btree_or_rtree
{
Lex->option_list= NULL;
- if (Lex->add_key($2, $4.str ? $4 : $1, $6, $3))
+ if (Lex->add_key($2, $4.str ? &$4 : &$1, $6, $3))
MYSQL_YYABORT;
}
'(' key_list ')' normal_key_options { }
@@ -5880,7 +5880,7 @@ key_def:
{
if (Lex->check_add_key($4) ||
!(Lex->last_key= (new (thd->mem_root)
- Key(Key::MULTIPLE, $1.str ? $1 : $5,
+ Key(Key::MULTIPLE, $1.str ? &$1 : &$5,
HA_KEY_ALG_UNDEF, true, $4))))
MYSQL_YYABORT;
Lex->option_list= NULL;
@@ -5889,11 +5889,11 @@ key_def:
{
LEX *lex=Lex;
Key *key= (new (thd->mem_root)
- Foreign_key($5.str ? $5 : $1,
- lex->last_key->columns,
- $10->db,
- $10->table,
- lex->ref_list,
+ Foreign_key($5.str ? &$5 : &$1,
+ &lex->last_key->columns,
+ &$10->db,
+ &$10->table,
+ &lex->ref_list,
lex->fk_delete_opt,
lex->fk_update_opt,
lex->fk_match_option,
@@ -5939,7 +5939,7 @@ check_constraint:
;
opt_constraint:
- /* empty */ { $$= null_lex_str; }
+ /* empty */ { $$= null_clex_str; }
| constraint { $$= $1; }
;
@@ -5960,7 +5960,7 @@ field_spec:
if (!f)
MYSQL_YYABORT;
- lex->init_last_field(f, $1.str, NULL);
+ lex->init_last_field(f, &$1, NULL);
$<create_field>$= f;
}
field_type_or_serial opt_check_constraint
@@ -6156,7 +6156,7 @@ field_type_numeric:
ulonglong tmp_length= my_strtoll10($2.length(), NULL, &err);
if (err || tmp_length > PRECISION_FOR_DOUBLE)
my_yyabort_error((ER_WRONG_FIELD_SPEC, MYF(0),
- Lex->last_field->field_name));
+ Lex->last_field->field_name.str));
if (tmp_length > PRECISION_FOR_FLOAT)
$$.set(MYSQL_TYPE_DOUBLE);
else
@@ -6810,14 +6810,14 @@ opt_ref_list:
ref_list:
ref_list ',' ident
{
- Key_part_spec *key= new (thd->mem_root) Key_part_spec($3, 0);
+ Key_part_spec *key= new (thd->mem_root) Key_part_spec(&$3, 0);
if (key == NULL)
MYSQL_YYABORT;
Lex->ref_list.push_back(key, thd->mem_root);
}
| ident
{
- Key_part_spec *key= new (thd->mem_root) Key_part_spec($1, 0);
+ Key_part_spec *key= new (thd->mem_root) Key_part_spec(&$1, 0);
if (key == NULL)
MYSQL_YYABORT;
LEX *lex= Lex;
@@ -7043,7 +7043,7 @@ key_list:
key_part:
ident
{
- $$= new (thd->mem_root) Key_part_spec($1, 0);
+ $$= new (thd->mem_root) Key_part_spec(&$1, 0);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -7052,19 +7052,19 @@ key_part:
int key_part_len= atoi($3.str);
if (!key_part_len)
my_yyabort_error((ER_KEY_PART_0, MYF(0), $1.str));
- $$= new (thd->mem_root) Key_part_spec($1, (uint) key_part_len);
+ $$= new (thd->mem_root) Key_part_spec(&$1, (uint) key_part_len);
if ($$ == NULL)
MYSQL_YYABORT;
}
;
opt_ident:
- /* empty */ { $$= null_lex_str; }
+ /* empty */ { $$= null_clex_str; }
| field_ident { $$= $1; }
;
opt_component:
- /* empty */ { $$= null_lex_str; }
+ /* empty */ { $$= null_clex_str; }
| '.' ident { $$= $2; }
;
@@ -7081,7 +7081,7 @@ string_list:
alter:
ALTER
{
- Lex->name= null_lex_str;
+ Lex->name= null_clex_str;
Lex->table_type= TABLE_TYPE_UNKNOWN;
Lex->sql_command= SQLCOM_ALTER_TABLE;
Lex->duplicates= DUP_ERROR;
@@ -7287,7 +7287,7 @@ opt_ev_sql_stmt:
;
ident_or_empty:
- /* empty */ { $$= null_lex_str; }
+ /* empty */ { $$= null_clex_str; }
| ident { $$= $1; }
;
@@ -7572,7 +7572,7 @@ alter_list_item:
{
Lex->alter_info.flags|= Alter_info::ALTER_CHANGE_COLUMN;
Lex->create_last_non_select_table= Lex->last_table();
- $5->change= $4.str;
+ $5->change= $4;
$5->after= $6;
}
| MODIFY_SYM opt_column opt_if_exists_table_element
@@ -7677,7 +7677,7 @@ alter_list_item:
MYSQL_YYABORT;
}
if (check_table_name($3->table.str,$3->table.length, FALSE) ||
- ($3->db.str && check_db_name(&$3->db)))
+ ($3->db.str && check_db_name((LEX_STRING*) &$3->db)))
my_yyabort_error((ER_WRONG_TABLE_NAME, MYF(0), $3->table.str));
lex->name= $3->table;
lex->alter_info.flags|= Alter_info::ALTER_RENAME;
@@ -7792,15 +7792,16 @@ opt_restrict:
;
opt_place:
- /* empty */ { $$= NULL; }
+ /* empty */ { $$= null_clex_str; }
| AFTER_SYM ident
{
- $$= $2.str;
+ $$= $2;
Lex->alter_info.flags |= Alter_info::ALTER_COLUMN_ORDER;
}
| FIRST_SYM
{
- $$= first_keyword;
+ $$.str= first_keyword;
+ $$.length= 5; /* Length of "first" */
Lex->alter_info.flags |= Alter_info::ALTER_COLUMN_ORDER;
}
;
@@ -8674,7 +8675,7 @@ select_item_list:
{
Item *item= new (thd->mem_root)
Item_field(thd, &thd->lex->current_select->context,
- NULL, NULL, "*");
+ NULL, NULL, &star_clex_str);
if (item == NULL)
MYSQL_YYABORT;
if (add_item_to_list(thd, item))
@@ -8703,7 +8704,7 @@ select_item:
$2->is_autogenerated_name= FALSE;
$2->set_name(thd, $4.str, $4.length, system_charset_info);
}
- else if (!$2->name)
+ else if (!$2->name.str || $2->name.str == item_empty_name)
{
$2->set_name(thd, $1, (uint) ($3 - $1), thd->charset());
}
@@ -8736,7 +8737,7 @@ remember_end:
;
select_alias:
- /* empty */ { $$=null_lex_str;}
+ /* empty */ { $$=null_clex_str;}
| AS ident { $$=$2; }
| AS TEXT_STRING_sys { $$=$2; }
| ident { $$=$1; }
@@ -9247,7 +9248,7 @@ sp_cursor_name_and_offset:
LEX *lex= Lex;
$$.name= $1;
if (!lex->spcont ||
- !lex->spcont->find_cursor($1, &$$.offset, false))
+ !lex->spcont->find_cursor(&$1, &$$.offset, false))
my_yyabort_error((ER_SP_CURSOR_MISMATCH, MYF(0), $1.str));
}
;
@@ -9256,25 +9257,25 @@ explicit_cursor_attr:
sp_cursor_name_and_offset '%' ISOPEN_SYM
{
if (!($$= new (thd->mem_root)
- Item_func_cursor_isopen(thd, $1.name, $1.offset)))
+ Item_func_cursor_isopen(thd, &$1.name, $1.offset)))
MYSQL_YYABORT;
}
| sp_cursor_name_and_offset '%' FOUND_SYM
{
if (!($$= new (thd->mem_root)
- Item_func_cursor_found(thd, $1.name, $1.offset)))
+ Item_func_cursor_found(thd, &$1.name, $1.offset)))
MYSQL_YYABORT;
}
| sp_cursor_name_and_offset '%' NOTFOUND_SYM
{
if (!($$= new (thd->mem_root)
- Item_func_cursor_notfound(thd, $1.name, $1.offset)))
+ Item_func_cursor_notfound(thd, &$1.name, $1.offset)))
MYSQL_YYABORT;
}
| sp_cursor_name_and_offset '%' ROWCOUNT_SYM
{
if (!($$= new (thd->mem_root)
- Item_func_cursor_rowcount(thd, $1.name, $1.offset)))
+ Item_func_cursor_rowcount(thd, &$1.name, $1.offset)))
MYSQL_YYABORT;
}
;
@@ -10239,10 +10240,10 @@ function_call_generic:
This will be revised with WL#2128 (SQL PATH)
*/
- builder= find_native_function_builder(thd, $1);
+ builder= find_native_function_builder(thd, &$1);
if (builder)
{
- item= builder->create_func(thd, $1, $4);
+ item= builder->create_func(thd, &$1, $4);
}
else
{
@@ -10264,7 +10265,7 @@ function_call_generic:
{
builder= find_qualified_function_builder(thd);
DBUG_ASSERT(builder);
- item= builder->create_func(thd, $1, $4);
+ item= builder->create_func(thd, &$1, $4);
}
}
@@ -10292,7 +10293,7 @@ function_call_generic:
version() (a vendor can specify any schema).
*/
- if (!$1.str || check_db_name(&$1))
+ if (!$1.str || check_db_name((LEX_STRING*) &$1))
my_yyabort_error((ER_WRONG_DB_NAME, MYF(0), $1.str));
if (check_routine_name(&$3))
{
@@ -10301,7 +10302,7 @@ function_call_generic:
builder= find_qualified_function_builder(thd);
DBUG_ASSERT(builder);
- item= builder->create_with_db(thd, $1, $3, true, $5);
+ item= builder->create_with_db(thd, &$1, &$3, true, $5);
if (! ($$= item))
{
@@ -10653,7 +10654,7 @@ simple_window_func:
window_name:
ident
{
- $$= (LEX_STRING *) thd->memdup(&$1, sizeof(LEX_STRING));
+ $$= (LEX_CSTRING *) thd->memdup(&$1, sizeof(LEX_CSTRING));
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -10675,7 +10676,7 @@ variable_aux:
ident_or_text SET_VAR expr
{
Item_func_set_user_var *item;
- $$= item= new (thd->mem_root) Item_func_set_user_var(thd, $1, $3);
+ $$= item= new (thd->mem_root) Item_func_set_user_var(thd, &$1, $3);
if ($$ == NULL)
MYSQL_YYABORT;
LEX *lex= Lex;
@@ -10684,7 +10685,7 @@ variable_aux:
}
| ident_or_text
{
- $$= new (thd->mem_root) Item_func_get_user_var(thd, $1);
+ $$= new (thd->mem_root) Item_func_get_user_var(thd, &$1);
if ($$ == NULL)
MYSQL_YYABORT;
LEX *lex= Lex;
@@ -11414,7 +11415,7 @@ key_usage_element:
ident
{ Select->add_index_hint(thd, $1.str, $1.length); }
| PRIMARY_SYM
- { Select->add_index_hint(thd, (char *)"PRIMARY", 7); }
+ { Select->add_index_hint(thd, "PRIMARY", 7); }
;
key_usage_list:
@@ -11490,7 +11491,7 @@ opt_table_alias:
/* empty */ { $$=0; }
| table_alias ident
{
- $$= (LEX_STRING*) thd->memdup(&$2,sizeof(LEX_STRING));
+ $$= (LEX_CSTRING*) thd->memdup(&$2,sizeof(LEX_STRING));
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -11626,7 +11627,7 @@ window_def:
if (Select->add_window_def(thd, $1, lex->win_ref,
Select->group_list,
Select->order_list,
- lex->win_frame ))
+ lex->win_frame))
MYSQL_YYABORT;
}
;
@@ -11643,7 +11644,7 @@ opt_window_ref:
/* empty */ {}
| ident
{
- thd->lex->win_ref= (LEX_STRING *) thd->memdup(&$1, sizeof(LEX_STRING));
+ thd->lex->win_ref= (LEX_CSTRING *) thd->memdup(&$1, sizeof(LEX_CSTRING));
if (thd->lex->win_ref == NULL)
MYSQL_YYABORT;
}
@@ -11911,7 +11912,7 @@ limit_option:
{
LEX *lex= thd->lex;
Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- if (!($$= lex->create_item_limit(thd, $1,
+ if (!($$= lex->create_item_limit(thd, &$1,
$1.m_pos -
lex->substatement_query(thd),
lip->get_tok_end() - $1.m_pos)))
@@ -11921,7 +11922,7 @@ limit_option:
{
LEX *lex= thd->lex;
Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- if (!($$= lex->create_item_limit(thd, $1, $3,
+ if (!($$= lex->create_item_limit(thd, &$1, &$3,
$1.m_pos -
lex->substatement_query(thd),
lip->get_ptr() - $1.m_pos)))
@@ -12046,7 +12047,7 @@ procedure_clause:
lex->proc_list.next= &lex->proc_list.first;
Item_field *item= new (thd->mem_root)
Item_field(thd, &lex->current_select->context,
- NULL, NULL, $2.str);
+ NULL, NULL, &$2);
if (item == NULL)
MYSQL_YYABORT;
if (add_proc_to_list(thd, item))
@@ -12083,7 +12084,7 @@ procedure_item:
{
if (add_proc_to_list(thd, $2))
MYSQL_YYABORT;
- if (!$2->name)
+ if (!$2->name.str || $2->name.str == item_empty_name)
$2->set_name(thd, $1, (uint) ($3 - $1), thd->charset());
}
;
@@ -12126,22 +12127,22 @@ select_var_ident: select_outvar
select_outvar:
'@' ident_or_text
{
- $$ = Lex->result ? new (thd->mem_root) my_var_user($2) : NULL;
+ $$ = Lex->result ? new (thd->mem_root) my_var_user(&$2) : NULL;
}
| ident_or_text
{
sp_variable *t;
- if (!Lex->spcont || !(t= Lex->spcont->find_variable($1, false)))
+ if (!Lex->spcont || !(t= Lex->spcont->find_variable(&$1, false)))
my_yyabort_error((ER_SP_UNDECLARED_VAR, MYF(0), $1.str));
$$ = Lex->result ? (new (thd->mem_root)
- my_var_sp($1, t->offset, t->type_handler(),
+ my_var_sp(&$1, t->offset, t->type_handler(),
Lex->sphead)) :
NULL;
}
| ident '.' ident
{
- if (!($$= Lex->create_outvar(thd, $1, $3)))
+ if (!($$= Lex->create_outvar(thd, &$1, &$3)))
MYSQL_YYABORT;
}
;
@@ -12241,12 +12242,12 @@ drop:
{
LEX *lex= thd->lex;
sp_name *spname;
- if ($4.str && check_db_name(&$4))
+ if ($4.str && check_db_name((LEX_STRING*) &$4))
my_yyabort_error((ER_WRONG_DB_NAME, MYF(0), $4.str));
if (lex->sphead)
my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"));
lex->set_command(SQLCOM_DROP_FUNCTION, $3);
- spname= new (thd->mem_root) sp_name($4, $6, true);
+ spname= new (thd->mem_root) sp_name(&$4, &$6, true);
if (spname == NULL)
MYSQL_YYABORT;
lex->spname= spname;
@@ -12254,14 +12255,14 @@ drop:
| DROP FUNCTION_SYM opt_if_exists ident
{
LEX *lex= thd->lex;
- LEX_STRING db= {0, 0};
+ LEX_CSTRING db= {0, 0};
sp_name *spname;
if (lex->sphead)
my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"));
if (thd->db && lex->copy_db_to(&db.str, &db.length))
MYSQL_YYABORT;
lex->set_command(SQLCOM_DROP_FUNCTION, $3);
- spname= new (thd->mem_root) sp_name(db, $4, false);
+ spname= new (thd->mem_root) sp_name(&db, &$4, false);
if (spname == NULL)
MYSQL_YYABORT;
lex->spname= spname;
@@ -12745,7 +12746,7 @@ table_wild_list:
table_wild_one:
ident opt_wild
{
- Table_ident *ti= new (thd->mem_root) Table_ident($1);
+ Table_ident *ti= new (thd->mem_root) Table_ident(&$1);
if (ti == NULL)
MYSQL_YYABORT;
if (!Select->add_table_to_list(thd,
@@ -12758,7 +12759,7 @@ table_wild_one:
}
| ident '.' ident opt_wild
{
- Table_ident *ti= new (thd->mem_root) Table_ident(thd, $1, $3, 0);
+ Table_ident *ti= new (thd->mem_root) Table_ident(thd, &$1, &$3, 0);
if (ti == NULL)
MYSQL_YYABORT;
if (!Select->add_table_to_list(thd,
@@ -12886,7 +12887,7 @@ show:
{
LEX *lex=Lex;
lex->wild=0;
- lex->ident=null_lex_str;
+ lex->ident= null_clex_str;
mysql_init_select(lex);
lex->current_select->parsing_place= SELECT_LIST;
lex->create_info.init();
@@ -12909,7 +12910,7 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_TABLES;
- lex->select_lex.db= $3;
+ lex->select_lex.db= $3.str;
if (prepare_schema_table(thd, lex, 0, SCH_TABLE_NAMES))
MYSQL_YYABORT;
}
@@ -12917,7 +12918,7 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_TRIGGERS;
- lex->select_lex.db= $3;
+ lex->select_lex.db= $3.str;
if (prepare_schema_table(thd, lex, 0, SCH_TRIGGERS))
MYSQL_YYABORT;
}
@@ -12925,7 +12926,7 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_EVENTS;
- lex->select_lex.db= $2;
+ lex->select_lex.db= $2.str;
if (prepare_schema_table(thd, lex, 0, SCH_EVENTS))
MYSQL_YYABORT;
}
@@ -12933,7 +12934,7 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
- lex->select_lex.db= $3;
+ lex->select_lex.db= $3.str;
if (prepare_schema_table(thd, lex, 0, SCH_TABLES))
MYSQL_YYABORT;
}
@@ -12941,7 +12942,7 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
- lex->select_lex.db= $3;
+ lex->select_lex.db= $3.str;
if (prepare_schema_table(thd, lex, 0, SCH_OPEN_TABLES))
MYSQL_YYABORT;
}
@@ -12973,8 +12974,8 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_FIELDS;
- if ($5)
- $4->change_db($5);
+ if ($5.str)
+ $4->change_db(&$5);
if (prepare_schema_table(thd, lex, $4, SCH_COLUMNS))
MYSQL_YYABORT;
}
@@ -13001,8 +13002,8 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_KEYS;
- if ($4)
- $3->change_db($4);
+ if ($4.str)
+ $3->change_db(&$4);
if (prepare_schema_table(thd, lex, $3, SCH_STATISTICS))
MYSQL_YYABORT;
}
@@ -13131,7 +13132,7 @@ show_param:
| SLAVE STATUS_SYM
{
LEX *lex= thd->lex;
- lex->mi.connection_name= null_lex_str;
+ lex->mi.connection_name= null_clex_str;
lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
lex->verbose= 0;
}
@@ -13249,8 +13250,8 @@ opt_storage:
;
opt_db:
- /* empty */ { $$= 0; }
- | from_or_in ident { $$= $2.str; }
+ /* empty */ { $$= null_clex_str; }
+ | from_or_in ident { $$= $2; }
;
opt_full:
@@ -13465,7 +13466,7 @@ flush_option:
| LOGS_SYM
{
Lex->type|= REFRESH_LOG;
- Lex->relay_log_connection_name= empty_lex_str;
+ Lex->relay_log_connection_name= empty_clex_str;
}
| STATUS_SYM
{ Lex->type|= REFRESH_STATUS; }
@@ -13803,7 +13804,7 @@ field_or_var:
simple_ident_nospvar {$$= $1;}
| '@' ident_or_text
{
- $$= new (thd->mem_root) Item_user_var_as_out_param(thd, $2);
+ $$= new (thd->mem_root) Item_user_var_as_out_param(thd, &$2);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -13835,7 +13836,7 @@ load_data_set_elem:
text_literal:
TEXT_STRING
{
- LEX_STRING tmp;
+ LEX_CSTRING tmp;
CHARSET_INFO *cs_con= thd->variables.collation_connection;
CHARSET_INFO *cs_cli= thd->variables.character_set_client;
uint repertoire= $1.repertoire(cs_cli);
@@ -13845,8 +13846,11 @@ text_literal:
tmp= $1;
else
{
- if (thd->convert_string(&tmp, cs_con, $1.str, $1.length, cs_cli))
+ LEX_STRING to;
+ if (thd->convert_string(&to, cs_con, $1.str, $1.length, cs_cli))
MYSQL_YYABORT;
+ tmp.str= to.str;
+ tmp.length= to.length;
}
$$= new (thd->mem_root) Item_string(thd, tmp.str, tmp.length,
cs_con,
@@ -13944,20 +13948,20 @@ hex_or_bin_String:
param_marker:
PARAM_MARKER
{
- if (!($$= Lex->add_placeholder(thd, (char *) "?",
+ if (!($$= Lex->add_placeholder(thd, &param_clex_str,
YYLIP->get_tok_start(),
YYLIP->get_tok_start() + 1)))
MYSQL_YYABORT;
}
| colon_with_pos ident
{
- if (!($$= Lex->add_placeholder(thd, NULL,
+ if (!($$= Lex->add_placeholder(thd, &null_clex_str,
$1, YYLIP->get_tok_end())))
MYSQL_YYABORT;
}
| colon_with_pos NUM
{
- if (!($$= Lex->add_placeholder(thd, NULL,
+ if (!($$= Lex->add_placeholder(thd, &null_clex_str,
$1, YYLIP->get_ptr())))
MYSQL_YYABORT;
}
@@ -14150,7 +14154,7 @@ with_list_element:
query_name
opt_with_column_list
{
- $2= new List<LEX_STRING> (Lex->with_column_list);
+ $2= new List<LEX_CSTRING> (Lex->with_column_list);
if ($2 == NULL)
MYSQL_YYABORT;
Lex->with_column_list.empty();
@@ -14177,13 +14181,13 @@ opt_with_column_list:
with_column_list:
ident
{
- Lex->with_column_list.push_back((LEX_STRING*)
- thd->memdup(&$1, sizeof(LEX_STRING)));
+ Lex->with_column_list.push_back((LEX_CSTRING*)
+ thd->memdup(&$1, sizeof(LEX_CSTRING)));
}
| with_column_list ',' ident
{
- Lex->with_column_list.push_back((LEX_STRING*)
- thd->memdup(&$3, sizeof(LEX_STRING)));
+ Lex->with_column_list.push_back((LEX_CSTRING*)
+ thd->memdup(&$3, sizeof(LEX_CSTRING)));
}
;
@@ -14191,7 +14195,7 @@ with_column_list:
query_name:
ident
{
- $$= (LEX_STRING *) thd->memdup(&$1, sizeof(LEX_STRING));
+ $$= (LEX_CSTRING *) thd->memdup(&$1, sizeof(LEX_CSTRING));
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -14213,7 +14217,7 @@ table_wild:
{
SELECT_LEX *sel= Select;
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
- NullS, $1.str, "*");
+ NullS, $1.str, &star_clex_str);
if ($$ == NULL)
MYSQL_YYABORT;
sel->with_wild++;
@@ -14225,7 +14229,7 @@ table_wild:
NullS : $1.str;
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
schema,
- $3.str,"*");
+ $3.str, &star_clex_str);
if ($$ == NULL)
MYSQL_YYABORT;
sel->with_wild++;
@@ -14240,7 +14244,7 @@ simple_ident:
ident
{
Lex_input_stream *lip= YYLIP;
- if (!($$= Lex->create_item_ident(thd, $1,
+ if (!($$= Lex->create_item_ident(thd, &$1,
lip->get_tok_start_prev(),
lip->get_tok_end())))
MYSQL_YYABORT;
@@ -14249,7 +14253,7 @@ simple_ident:
| ident '.' ident
{
LEX *lex= thd->lex;
- if (!($$= lex->create_item_ident(thd, $1, $3,
+ if (!($$= lex->create_item_ident(thd, &$1, &$3,
$1.m_pos -
lex->substatement_query(thd),
YYLIP->get_tok_end() - $1.m_pos)))
@@ -14260,7 +14264,7 @@ simple_ident:
simple_ident_nospvar:
ident
{
- if (!($$= Lex->create_item_ident_nosp(thd, $1)))
+ if (!($$= Lex->create_item_ident_nosp(thd, &$1)))
MYSQL_YYABORT;
}
| simple_ident_q { $$= $1; }
@@ -14269,7 +14273,7 @@ simple_ident_nospvar:
simple_ident_q:
ident '.' ident
{
- if (!($$= Lex->create_item_ident_nospvar(thd, $1, $3)))
+ if (!($$= Lex->create_item_ident_nospvar(thd, &$1, &$3)))
MYSQL_YYABORT;
}
| simple_ident_q2
@@ -14279,11 +14283,11 @@ simple_ident_q2:
colon_with_pos ident '.' ident
{
LEX *lex= Lex;
- if (lex->is_trigger_new_or_old_reference($2))
+ if (lex->is_trigger_new_or_old_reference(&$2))
{
bool new_row= ($2.str[0]=='N' || $2.str[0]=='n');
if (!($$= Lex->create_and_link_Item_trigger_field(thd,
- $4.str,
+ &$4,
new_row)))
MYSQL_YYABORT;
}
@@ -14295,12 +14299,12 @@ simple_ident_q2:
}
| '.' ident '.' ident
{
- if (!($$= Lex->create_item_ident(thd, null_lex_str, $2, $4)))
+ if (!($$= Lex->create_item_ident(thd, &null_clex_str, &$2, &$4)))
MYSQL_YYABORT;
}
| ident '.' ident '.' ident
{
- if (!($$= Lex->create_item_ident(thd, $1, $3, $5)))
+ if (!($$= Lex->create_item_ident(thd, &$1, &$3, &$5)))
MYSQL_YYABORT;
}
;
@@ -14330,20 +14334,20 @@ field_ident:
table_ident:
ident
{
- $$= new (thd->mem_root) Table_ident($1);
+ $$= new (thd->mem_root) Table_ident(&$1);
if ($$ == NULL)
MYSQL_YYABORT;
}
| ident '.' ident
{
- $$= new (thd->mem_root) Table_ident(thd, $1, $3, 0);
+ $$= new (thd->mem_root) Table_ident(thd, &$1, &$3, 0);
if ($$ == NULL)
MYSQL_YYABORT;
}
| '.' ident
{
/* For Delphi */
- $$= new (thd->mem_root) Table_ident($2);
+ $$= new (thd->mem_root) Table_ident(&$2);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -14352,13 +14356,13 @@ table_ident:
table_ident_opt_wild:
ident opt_wild
{
- $$= new (thd->mem_root) Table_ident($1);
+ $$= new (thd->mem_root) Table_ident(&$1);
if ($$ == NULL)
MYSQL_YYABORT;
}
| ident '.' ident opt_wild
{
- $$= new (thd->mem_root) Table_ident(thd, $1, $3, 0);
+ $$= new (thd->mem_root) Table_ident(thd, &$1, &$3, 0);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -14367,8 +14371,8 @@ table_ident_opt_wild:
table_ident_nodb:
ident
{
- LEX_STRING db={(char*) any_db,3};
- $$= new (thd->mem_root) Table_ident(thd, db, $1, 0);
+ LEX_CSTRING db={(char*) any_db,3};
+ $$= new (thd->mem_root) Table_ident(thd, &db, &$1, 0);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -14393,9 +14397,12 @@ IDENT_sys:
}
else
{
- if (thd->convert_with_error(system_charset_info, &$$,
+ LEX_STRING to;
+ if (thd->convert_with_error(system_charset_info, &to,
thd->charset(), $1.str, $1.length))
MYSQL_YYABORT;
+ $$.str= to.str;
+ $$.length= to.length;
}
}
;
@@ -14407,9 +14414,12 @@ TEXT_STRING_sys:
$$= $1;
else
{
- if (thd->convert_string(&$$, system_charset_info,
+ LEX_STRING to;
+ if (thd->convert_string(&to, system_charset_info,
$1.str, $1.length, thd->charset()))
MYSQL_YYABORT;
+ $$.str= to.str;
+ $$.length= to.length;
}
}
;
@@ -14421,10 +14431,13 @@ TEXT_STRING_literal:
$$= $1;
else
{
- if (thd->convert_string(&$$, thd->variables.collation_connection,
+ LEX_STRING to;
+ if (thd->convert_string(&to, thd->variables.collation_connection,
$1.str, $1.length, thd->charset()))
MYSQL_YYABORT;
- }
+ $$.str= to.str;
+ $$.length= to.length;
+ }
}
;
@@ -14435,10 +14448,13 @@ TEXT_STRING_filesystem:
$$= $1;
else
{
- if (thd->convert_string(&$$,
+ LEX_STRING to;
+ if (thd->convert_string(&to,
thd->variables.character_set_filesystem,
$1.str, $1.length, thd->charset()))
MYSQL_YYABORT;
+ $$.str= to.str;
+ $$.length= to.length;
}
}
;
@@ -14446,7 +14462,7 @@ TEXT_STRING_filesystem:
ident:
IDENT_sys
{
- (LEX_STRING &)$$= $1;
+ (LEX_CSTRING &)$$= $1;
$$.m_pos= (char *) YYLIP->get_tok_start_prev();
}
| keyword
@@ -14462,7 +14478,7 @@ ident:
ident_with_tok_start:
IDENT_sys
{
- (LEX_STRING &)$$= $1;
+ (LEX_CSTRING &)$$= $1;
$$.m_pos= (char *) YYLIP->get_tok_start();
}
| keyword
@@ -14512,7 +14528,7 @@ labels_declaration_oracle:
label_declaration_oracle:
SHIFT_LEFT label_ident SHIFT_RIGHT
{
- if (Lex->sp_push_goto_label(thd, $2))
+ if (Lex->sp_push_goto_label(thd, &$2))
MYSQL_YYABORT;
$$= $2;
}
@@ -14530,7 +14546,7 @@ user_maybe_role:
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
MYSQL_YYABORT;
$$->user = $1;
- $$->host= null_lex_str; // User or Role, see get_current_user()
+ $$->host= null_clex_str; // User or Role, see get_current_user()
$$->reset_auth();
if (check_string_char_length(&$$->user, ER_USERNAME,
@@ -14557,7 +14573,7 @@ user_maybe_role:
It's OK to use in-place lowercase as long as
the character set is utf8.
*/
- my_casedn_str(system_charset_info, $$->host.str);
+ my_casedn_str(system_charset_info, (char*) $$->host.str);
}
else
{
@@ -14573,8 +14589,8 @@ user_maybe_role:
if (!($$=(LEX_USER*)thd->calloc(sizeof(LEX_USER))))
MYSQL_YYABORT;
$$->user= current_user;
- $$->plugin= empty_lex_str;
- $$->auth= empty_lex_str;
+ $$->plugin= empty_clex_str;
+ $$->auth= empty_clex_str;
}
;
@@ -15125,7 +15141,7 @@ set_assign:
{
LEX *lex= Lex;
DBUG_ASSERT(lex->var_list.is_empty());
- if (lex->set_variable($1, $3, $6) ||
+ if (lex->set_variable(&$1, &$3, $6) ||
lex->sphead->restore_lex(thd))
MYSQL_YYABORT;
}
@@ -15266,14 +15282,14 @@ option_value_no_option_type:
ident equal set_expr_or_default
{
struct sys_var_with_base var;
- if (Lex->init_internal_variable(&var, $1) ||
+ if (Lex->init_internal_variable(&var, &$1) ||
Lex->set_variable(&var, $3))
MYSQL_YYABORT;
}
| ident '.' ident equal set_expr_or_default
{
DBUG_ASSERT(Lex->var_list.is_empty());
- if (Lex->set_variable($1, $3, $5))
+ if (Lex->set_variable(&$1, &$3, $5))
MYSQL_YYABORT;
}
| DEFAULT '.' ident equal set_expr_or_default
@@ -15286,7 +15302,7 @@ option_value_no_option_type:
| '@' ident_or_text equal expr
{
Item_func_set_user_var *item;
- item= new (thd->mem_root) Item_func_set_user_var(thd, $2, $4);
+ item= new (thd->mem_root) Item_func_set_user_var(thd, &$2, $4);
if (item == NULL)
MYSQL_YYABORT;
set_var_user *var= new (thd->mem_root) set_var_user(item);
@@ -15324,15 +15340,11 @@ option_value_no_option_type:
{
LEX *lex= Lex;
sp_pcontext *spc= lex->spcont;
- LEX_STRING names;
-
- names.str= (char *)"names";
- names.length= 5;
- if (spc && spc->find_variable(names, false))
+ LEX_CSTRING names= { STRING_WITH_LEN("names") };
+ if (spc && spc->find_variable(&names, false))
my_error(ER_SP_BAD_VAR_SHADOW, MYF(0), names.str);
else
thd->parse_error();
-
MYSQL_YYABORT;
}
| NAMES_SYM charset_name_or_default opt_collate
@@ -15409,12 +15421,12 @@ option_value_no_option_type:
internal_variable_name:
ident
{
- if (Lex->init_internal_variable(&$$, $1))
+ if (Lex->init_internal_variable(&$$, &$1))
MYSQL_YYABORT;
}
| ident '.' ident
{
- if (Lex->init_internal_variable(&$$, $1, $3))
+ if (Lex->init_internal_variable(&$$, &$1, &$3))
MYSQL_YYABORT;
}
| DEFAULT '.' ident
@@ -15428,7 +15440,7 @@ internal_variable_name:
internal_variable_name_directly_assignable:
ident_directly_assignable
{
- if (Lex->init_internal_variable(&$$, $1))
+ if (Lex->init_internal_variable(&$$, &$1))
MYSQL_YYABORT;
}
| DEFAULT '.' ident
@@ -15438,12 +15450,12 @@ internal_variable_name_directly_assignable:
}
| colon_with_pos ident_directly_assignable '.' ident
{
- if (!Lex->is_trigger_new_or_old_reference($2))
+ if (!Lex->is_trigger_new_or_old_reference(&$2))
{
thd->parse_error();
MYSQL_YYABORT;
}
- if (Lex->init_internal_variable(&$$, $2, $4))
+ if (Lex->init_internal_variable(&$$, &$2, &$4))
MYSQL_YYABORT;
}
;
@@ -15465,7 +15477,7 @@ transaction_access_mode:
set_var *var= (new (thd->mem_root)
set_var(thd, lex->option_type,
find_sys_var(thd, "tx_read_only"),
- &null_lex_str,
+ &null_clex_str,
item));
if (var == NULL)
MYSQL_YYABORT;
@@ -15483,7 +15495,7 @@ isolation_level:
set_var *var= (new (thd->mem_root)
set_var(thd, lex->option_type,
find_sys_var(thd, "tx_isolation"),
- &null_lex_str,
+ &null_clex_str,
item));
if (var == NULL)
MYSQL_YYABORT;
@@ -15508,15 +15520,15 @@ opt_for_user:
{
LEX *lex= thd->lex;
sp_pcontext *spc= lex->spcont;
- LEX_STRING pw= { C_STRING_WITH_LEN("password") };
+ LEX_CSTRING pw= { STRING_WITH_LEN("password") };
- if (spc && spc->find_variable(pw, false))
+ if (spc && spc->find_variable(&pw, false))
my_yyabort_error((ER_SP_BAD_VAR_SHADOW, MYF(0), pw.str));
if (!(lex->definer= (LEX_USER*) thd->calloc(sizeof(LEX_USER))))
MYSQL_YYABORT;
lex->definer->user= current_user;
- lex->definer->plugin= empty_lex_str;
- lex->definer->auth= empty_lex_str;
+ lex->definer->plugin= empty_clex_str;
+ lex->definer->auth= empty_clex_str;
}
| FOR_SYM user equal { Lex->definer= $2; }
;
@@ -15675,7 +15687,7 @@ handler:
;
handler_read_or_scan:
- handler_scan_function { Lex->ident= null_lex_str; }
+ handler_scan_function { Lex->ident= null_clex_str; }
| ident handler_rkey_function { Lex->ident= $1; }
;
@@ -15863,13 +15875,13 @@ grant_role:
CHARSET_INFO *cs= system_charset_info;
/* trim end spaces (as they'll be lost in mysql.user anyway) */
$1.length= cs->cset->lengthsp(cs, $1.str, $1.length);
- $1.str[$1.length] = '\0';
+ ((char*) $1.str)[$1.length] = '\0';
if ($1.length == 0)
my_yyabort_error((ER_INVALID_ROLE, MYF(0), ""));
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
MYSQL_YYABORT;
- $$->user = $1;
- $$->host= empty_lex_str;
+ $$->user= $1;
+ $$->host= empty_clex_str;
$$->reset_auth();
if (check_string_char_length(&$$->user, ER_USERNAME,
@@ -16079,7 +16091,7 @@ grant_user:
{
$$= $1;
$1->plugin= $4;
- $1->auth= empty_lex_str;
+ $1->auth= empty_clex_str;
}
| user IDENTIFIED_SYM via_or_with ident_or_text using_or_as TEXT_STRING_sys
{
@@ -16665,7 +16677,8 @@ view_select:
void *create_view_select= thd->memdup(lex->create_view_select.str, len);
lex->create_view_select.length= len;
lex->create_view_select.str= (char *) create_view_select;
- trim_whitespace(thd->charset(), &lex->create_view_select,
+ trim_whitespace(thd->charset(),
+ &lex->create_view_select,
&not_used);
lex->parsing_options.allows_variable= TRUE;
lex->current_select->set_with_clause($2);
@@ -16789,7 +16802,7 @@ trigger_tail:
lex->query_tables can be wiped out.
*/
if (!lex->select_lex.add_table_to_list(thd, $11,
- (LEX_STRING*) 0,
+ (LEX_CSTRING*) 0,
TL_OPTION_UPDATING,
TL_READ_NO_INSERT,
MDL_SHARED_NO_WRITE))
@@ -16838,7 +16851,8 @@ sf_tail:
RETURN_SYM /* $6 */
{ /* $7 */
LEX *lex= Lex;
- lex->init_last_field(&lex->sphead->m_return_field_def, NULL,
+ lex->init_last_field(&lex->sphead->m_return_field_def,
+ &empty_clex_str,
thd->variables.collation_database);
}
sp_param_type_with_opt_collate /* $8 */
@@ -17019,7 +17033,7 @@ install:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_INSTALL_PLUGIN;
- lex->comment= null_lex_str;
+ lex->comment= null_clex_str;
lex->ident= $3;
}
;
@@ -17035,7 +17049,7 @@ uninstall:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;
- lex->comment= null_lex_str;
+ lex->comment= null_clex_str;
lex->ident= $3;
}
;
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index bf5fe9d6f00..01c9fe4e70b 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -331,10 +331,10 @@ outp:
>=0 Ordinal position
*/
-int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
+int find_string_in_array(LEX_CSTRING * const haystack, LEX_CSTRING * const needle,
CHARSET_INFO * const cs)
{
- const LEX_STRING *pos;
+ const LEX_CSTRING *pos;
for (pos= haystack; pos->str; pos++)
if (!cs->coll->strnncollsp(cs, (uchar *) pos->str, pos->length,
(uchar *) needle->str, needle->length))
@@ -345,12 +345,12 @@ int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
}
-char *set_to_string(THD *thd, LEX_STRING *result, ulonglong set,
- const char *lib[])
+const char *set_to_string(THD *thd, LEX_CSTRING *result, ulonglong set,
+ const char *lib[])
{
char buff[STRING_BUFFER_USUAL_SIZE*8];
String tmp(buff, sizeof(buff), &my_charset_latin1);
- LEX_STRING unused;
+ LEX_CSTRING unused;
if (!result)
result= &unused;
@@ -376,12 +376,12 @@ char *set_to_string(THD *thd, LEX_STRING *result, ulonglong set,
return result->str;
}
-char *flagset_to_string(THD *thd, LEX_STRING *result, ulonglong set,
- const char *lib[])
+const char *flagset_to_string(THD *thd, LEX_CSTRING *result, ulonglong set,
+ const char *lib[])
{
char buff[STRING_BUFFER_USUAL_SIZE*8];
String tmp(buff, sizeof(buff), &my_charset_latin1);
- LEX_STRING unused;
+ LEX_CSTRING unused;
if (!result) result= &unused;
diff --git a/sql/strfunc.h b/sql/strfunc.h
index 7b031710c76..7f3021e1a6d 100644
--- a/sql/strfunc.h
+++ b/sql/strfunc.h
@@ -33,12 +33,13 @@ uint find_type2(const TYPELIB *lib, const char *find, uint length,
void unhex_type2(TYPELIB *lib);
uint check_word(TYPELIB *lib, const char *val, const char *end,
const char **end_of_word);
-int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
+int find_string_in_array(LEX_CSTRING * const haystack,
+ LEX_CSTRING * const needle,
CHARSET_INFO * const cs);
-char *flagset_to_string(THD *thd, LEX_STRING *result, ulonglong set,
+const char *flagset_to_string(THD *thd, LEX_CSTRING *result, ulonglong set,
const char *lib[]);
-char *set_to_string(THD *thd, LEX_STRING *result, ulonglong set,
- const char *lib[]);
+const char *set_to_string(THD *thd, LEX_CSTRING *result, ulonglong set,
+ const char *lib[]);
/*
These functions were protected by INNODB_COMPATIBILITY_HOOKS
diff --git a/sql/structs.h b/sql/structs.h
index 1b3c0b7a7f2..1a143602eea 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -124,10 +124,10 @@ typedef struct st_key {
union
{
plugin_ref parser; /* Fulltext [pre]parser */
- LEX_STRING *parser_name; /* Fulltext [pre]parser name */
+ LEX_CSTRING *parser_name; /* Fulltext [pre]parser name */
};
KEY_PART_INFO *key_part;
- char *name; /* Name of key */
+ const char *name; /* Name of key */
/* Unique name for cache; db + \0 + table_name + \0 + key_name + \0 */
uchar *cache_name;
/*
@@ -152,7 +152,7 @@ typedef struct st_key {
int bdb_return_if_eq;
} handler;
TABLE *table;
- LEX_STRING comment;
+ LEX_CSTRING comment;
/** reference to the list of options or NULL */
engine_option_value *option_list;
ha_index_option_struct *option_struct; /* structure with parsed options */
@@ -204,21 +204,24 @@ extern const char *show_comp_option_name[];
typedef int *(*update_var)(THD *, struct st_mysql_show_var *);
typedef struct st_lex_user {
- LEX_STRING user, host, plugin, auth;
- LEX_STRING pwtext, pwhash;
+ LEX_CSTRING user, host, plugin, auth;
+ LEX_CSTRING pwtext, pwhash;
bool is_role() const { return user.str[0] && !host.str[0]; }
- void set_lex_string(LEX_STRING *l, char *buf)
+ void set_lex_string(LEX_CSTRING *l, char *buf)
{
if (is_role())
*l= user;
else
- l->length= strxmov(l->str= buf, user.str, "@", host.str, NullS) - buf;
+ {
+ l->str= buf;
+ l->length= strxmov(buf, user.str, "@", host.str, NullS) - buf;
+ }
}
void reset_auth()
{
pwtext.length= pwhash.length= plugin.length= auth.length= 0;
pwtext.str= pwhash.str= 0;
- plugin.str= auth.str= const_cast<char*>("");
+ plugin.str= auth.str= "";
}
} LEX_USER;
@@ -708,7 +711,7 @@ public:
};
-struct Lex_string_with_pos_st: public LEX_STRING
+struct Lex_string_with_pos_st: public LEX_CSTRING
{
const char *m_pos;
};
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index a3bc3f6d9cf..b4583b1c187 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -1015,7 +1015,7 @@ static Sys_var_lexstring Sys_init_connect(
#ifdef HAVE_REPLICATION
static bool check_master_connection(sys_var *self, THD *thd, set_var *var)
{
- LEX_STRING tmp;
+ LEX_CSTRING tmp;
tmp.str= var->save_result.string_value.str;
tmp.length= var->save_result.string_value.length;
if (!tmp.str || check_master_connection_name(&tmp))
@@ -1547,7 +1547,7 @@ static Sys_var_gtid_binlog_pos Sys_gtid_binlog_pos(
uchar *
-Sys_var_gtid_binlog_pos::global_value_ptr(THD *thd, const LEX_STRING *base)
+Sys_var_gtid_binlog_pos::global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
char buf[128];
String str(buf, sizeof(buf), system_charset_info);
@@ -1575,7 +1575,7 @@ static Sys_var_gtid_current_pos Sys_gtid_current_pos(
uchar *
-Sys_var_gtid_current_pos::global_value_ptr(THD *thd, const LEX_STRING *base)
+Sys_var_gtid_current_pos::global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
String str;
char *p;
@@ -1656,7 +1656,7 @@ Sys_var_gtid_slave_pos::global_update(THD *thd, set_var *var)
uchar *
-Sys_var_gtid_slave_pos::global_value_ptr(THD *thd, const LEX_STRING *base)
+Sys_var_gtid_slave_pos::global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
String str;
char *p;
@@ -1774,7 +1774,7 @@ Sys_var_gtid_binlog_state::global_update(THD *thd, set_var *var)
uchar *
-Sys_var_gtid_binlog_state::global_value_ptr(THD *thd, const LEX_STRING *base)
+Sys_var_gtid_binlog_state::global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
char buf[512];
String str(buf, sizeof(buf), system_charset_info);
@@ -1807,7 +1807,7 @@ static Sys_var_last_gtid Sys_last_gtid(
uchar *
-Sys_var_last_gtid::session_value_ptr(THD *thd, const LEX_STRING *base)
+Sys_var_last_gtid::session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
char buf[10+1+10+1+20+1];
String str(buf, sizeof(buf), system_charset_info);
@@ -1916,7 +1916,7 @@ Sys_var_slave_parallel_mode::global_update(THD *thd, set_var *var)
{
enum_slave_parallel_mode new_value=
(enum_slave_parallel_mode)var->save_result.ulonglong_value;
- LEX_STRING *base_name= &var->base;
+ LEX_CSTRING *base_name= &var->base;
Master_info *mi;
bool res= false;
@@ -1936,7 +1936,7 @@ Sys_var_slave_parallel_mode::global_update(THD *thd, set_var *var)
if (mi->rli.slave_running)
{
my_error(ER_SLAVE_MUST_STOP, MYF(0),
- mi->connection_name.length, mi->connection_name.str);
+ (int) mi->connection_name.length, mi->connection_name.str);
res= true;
}
else
@@ -1959,7 +1959,7 @@ Sys_var_slave_parallel_mode::global_update(THD *thd, set_var *var)
uchar *
Sys_var_slave_parallel_mode::global_value_ptr(THD *thd,
- const LEX_STRING *base_name)
+ const LEX_CSTRING *base_name)
{
Master_info *mi;
enum_slave_parallel_mode val=
@@ -3061,7 +3061,7 @@ static const char *sql_mode_names[]=
};
export bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode,
- LEX_STRING *ls)
+ LEX_CSTRING *ls)
{
set_to_string(thd, ls, sql_mode, sql_mode_names);
return ls->str == 0;
@@ -4336,7 +4336,7 @@ static Sys_var_mybool Sys_relay_log_recovery(
bool Sys_var_rpl_filter::global_update(THD *thd, set_var *var)
{
bool result= true; // Assume error
- LEX_STRING *base_name= &var->base;
+ LEX_CSTRING *base_name= &var->base;
if (!base_name->length)
base_name= &thd->variables.default_master_connection;
@@ -4350,7 +4350,7 @@ bool Sys_var_rpl_filter::global_update(THD *thd, set_var *var)
if (mi->rli.slave_running)
{
my_error(ER_SLAVE_MUST_STOP, MYF(0),
- mi->connection_name.length,
+ (int) mi->connection_name.length,
mi->connection_name.str);
result= true;
}
@@ -4397,7 +4397,7 @@ bool Sys_var_rpl_filter::set_filter_value(const char *value, Master_info *mi)
}
uchar *Sys_var_rpl_filter::global_value_ptr(THD *thd,
- const LEX_STRING *base_name)
+ const LEX_CSTRING *base_name)
{
char buf[256];
String tmp(buf, sizeof(buf), &my_charset_bin);
@@ -4553,7 +4553,7 @@ static bool update_slave_skip_counter(sys_var *self, THD *thd, Master_info *mi)
{
if (mi->rli.slave_running)
{
- my_error(ER_SLAVE_MUST_STOP, MYF(0), mi->connection_name.length,
+ my_error(ER_SLAVE_MUST_STOP, MYF(0), (int) mi->connection_name.length,
mi->connection_name.str);
return true;
}
diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic
index 780450b484b..a157538d528 100644
--- a/sql/sys_vars.ic
+++ b/sql/sys_vars.ic
@@ -364,9 +364,9 @@ public:
{ var->save_result.ulonglong_value= option.def_value; }
uchar *valptr(THD *thd, ulong val)
{ return (uchar*)typelib.type_names[val]; }
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, session_var(thd, ulong)); }
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, global_var(ulong)); }
uchar *default_value_ptr(THD *thd)
{ return valptr(thd, option.def_value); }
@@ -619,7 +619,7 @@ public:
DBUG_ASSERT(res == 0);
}
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(thd != NULL);
size_t len= sysvartrack_value_len(thd);
@@ -669,7 +669,7 @@ public:
void global_save_default(THD *thd, set_var *var)
{ DBUG_ASSERT(FALSE); }
protected:
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
return thd->security_ctx->proxy_user[0] ?
(uchar *) &(thd->security_ctx->proxy_user[0]) : NULL;
@@ -685,7 +685,7 @@ public:
{}
protected:
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
return (uchar*)thd->security_ctx->external_user;
}
@@ -725,7 +725,7 @@ public:
bool global_update(THD *thd, set_var *var);
protected:
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base);
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base);
bool set_filter_value(const char *value, Master_info *mi);
};
@@ -736,7 +736,7 @@ protected:
Class specific constructor arguments:
enum charset_enum is_os_charset_arg
- Backing store: LEX_STRING
+ Backing store: LEX_CSTRING
@note
Behaves exactly as Sys_var_charptr, only the backing store is different.
@@ -757,22 +757,22 @@ public:
getopt, is_os_charset_arg, def_val, lock, binlog_status_arg,
on_check_func, on_update_func, substitute)
{
- global_var(LEX_STRING).length= strlen(def_val);
- SYSVAR_ASSERT(size == sizeof(LEX_STRING));
+ global_var(LEX_CSTRING).length= strlen(def_val);
+ SYSVAR_ASSERT(size == sizeof(LEX_CSTRING));
*const_cast<SHOW_TYPE*>(&show_val_type)= SHOW_LEX_STRING;
}
bool global_update(THD *thd, set_var *var)
{
if (Sys_var_charptr::global_update(thd, var))
return true;
- global_var(LEX_STRING).length= var->save_result.string_value.length;
+ global_var(LEX_CSTRING).length= var->save_result.string_value.length;
return false;
}
};
/*
- A LEX_STRING stored only in thd->variables
+ A LEX_CSTRING stored only in thd->variables
Only to be used for small buffers
*/
@@ -822,10 +822,10 @@ public:
}
bool session_update(THD *thd, set_var *var)
{
- LEX_STRING *tmp= &session_var(thd, LEX_STRING);
+ LEX_CSTRING *tmp= &session_var(thd, LEX_CSTRING);
tmp->length= var->save_result.string_value.length;
/* Store as \0 terminated string (just to be safe) */
- strmake(tmp->str, var->save_result.string_value.str, tmp->length);
+ strmake((char*) tmp->str, var->save_result.string_value.str, tmp->length);
return false;
}
bool global_update(THD *thd, set_var *var)
@@ -843,7 +843,7 @@ public:
{
DBUG_ASSERT(FALSE);
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(FALSE);
return NULL;
@@ -913,13 +913,13 @@ public:
char *ptr= (char*)(intptr)option.def_value;
var->save_result.string_value.str= ptr;
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
char buf[256];
DBUG_EXPLAIN(buf, sizeof(buf));
return (uchar*) thd->strdup(buf);
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
char buf[256];
DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
@@ -974,7 +974,7 @@ public:
bool global_update(THD *thd, set_var *var)
{
ulonglong new_value= var->save_result.ulonglong_value;
- LEX_STRING *base_name= &var->base;
+ LEX_CSTRING *base_name= &var->base;
KEY_CACHE *key_cache;
/* If no basename, assume it's for the key cache named 'default' */
@@ -1001,7 +1001,7 @@ public:
return keycache_update(thd, key_cache, offset, new_value);
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
KEY_CACHE *key_cache= get_key_cache(base);
if (!key_cache)
@@ -1186,7 +1186,7 @@ public:
lock, binlog_status_arg, on_check_func, on_update_func,
substitute)
{ }
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
if (thd->user_connect && thd->user_connect->user_resources.user_conn)
return (uchar*) &(thd->user_connect->user_resources.user_conn);
@@ -1300,9 +1300,9 @@ public:
{ var->save_result.ulonglong_value= option.def_value; }
uchar *valptr(THD *thd, ulonglong val)
{ return (uchar*)flagset_to_string(thd, 0, val, typelib.type_names); }
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, session_var(thd, ulonglong)); }
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, global_var(ulonglong)); }
uchar *default_value_ptr(THD *thd)
{ return valptr(thd, option.def_value); }
@@ -1399,9 +1399,9 @@ public:
{ var->save_result.ulonglong_value= option.def_value; }
uchar *valptr(THD *thd, ulonglong val)
{ return (uchar*)set_to_string(thd, 0, val, typelib.type_names); }
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, session_var(thd, ulonglong)); }
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, global_var(ulonglong)); }
uchar *default_value_ptr(THD *thd)
{ return valptr(thd, option.def_value); }
@@ -1450,7 +1450,7 @@ public:
var->save_result.plugin= NULL;
else
{
- const LEX_STRING pname= { const_cast<char*>(res->ptr()), res->length() };
+ const LEX_CSTRING pname= { const_cast<char*>(res->ptr()), res->length() };
plugin_ref plugin;
// special code for storage engines (e.g. to handle historical aliases)
@@ -1504,7 +1504,7 @@ public:
if (!default_value)
return 0;
- LEX_STRING pname= { default_value, strlen(pname.str) };
+ LEX_CSTRING pname= { default_value, strlen(default_value) };
plugin_ref plugin;
if (plugin_type == MYSQL_STORAGE_ENGINE_PLUGIN)
@@ -1525,9 +1525,9 @@ public:
return (uchar*)(plugin ? thd->strmake(plugin_name(plugin)->str,
plugin_name(plugin)->length) : 0);
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, session_var(thd, plugin_ref)); }
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, global_var(plugin_ref)); }
uchar *default_value_ptr(THD *thd)
{ return valptr(thd, get_default(thd)); }
@@ -1593,11 +1593,11 @@ public:
{
DBUG_ASSERT(FALSE);
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
return debug_sync_value_ptr(thd);
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(FALSE);
return 0;
@@ -1680,9 +1680,9 @@ public:
thd->sys_var_tmp.my_bool_value= reverse_semantics ^ ((val & bitmask) != 0);
return (uchar*) &thd->sys_var_tmp.my_bool_value;
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, session_var(thd, ulonglong)); }
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, global_var(ulonglong)); }
uchar *default_value_ptr(THD *thd)
{
@@ -1743,12 +1743,12 @@ public:
{ var->value= 0; }
void global_save_default(THD *thd, set_var *var)
{ DBUG_ASSERT(FALSE); }
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
thd->sys_var_tmp.ulonglong_value= read_func(thd);
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(FALSE);
return 0;
@@ -1808,13 +1808,13 @@ public:
{ var->value= 0; }
void global_save_default(THD *thd, set_var *var)
{ DBUG_ASSERT(FALSE); }
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
thd->sys_var_tmp.double_value= thd->start_time +
thd->start_time_sec_part/(double)TIME_SECOND_PART_FACTOR;
return (uchar*) &thd->sys_var_tmp.double_value;
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(FALSE);
return 0;
@@ -1878,12 +1878,12 @@ public:
}
void session_save_default(THD *thd, set_var *var) { }
void global_save_default(THD *thd, set_var *var) { }
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(FALSE);
return 0;
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
return (uchar*)show_comp_option_name[global_var(enum SHOW_COMP_OPTION)];
}
@@ -1955,9 +1955,9 @@ public:
}
uchar *valptr(THD *thd, uchar *val)
{ return val ? *(uchar**)(val+name_offset) : 0; }
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, session_var(thd, uchar*)); }
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, global_var(uchar*)); }
uchar *default_value_ptr(THD *thd)
{ return valptr(thd, *(uchar**)option.def_value); }
@@ -2031,7 +2031,7 @@ public:
}
uchar *valptr(THD *thd, Time_zone *val)
{ return (uchar *)(val->get_name()->ptr()); }
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
/*
This is an ugly fix for replication: we don't replicate properly queries
@@ -2044,7 +2044,7 @@ public:
thd->time_zone_used= 1;
return valptr(thd, session_var(thd, Time_zone *));
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, global_var(Time_zone*)); }
uchar *default_value_ptr(THD *thd)
{ return valptr(thd, *(Time_zone**)option.def_value); }
@@ -2215,7 +2215,7 @@ public:
/* Use value given in variable declaration */
global_save_default(thd, var);
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
ulonglong *tmp, res;
tmp= (ulonglong*) (((uchar*)&(thd->variables)) + offset);
@@ -2223,7 +2223,7 @@ public:
*tmp= res;
return (uchar*) tmp;
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
return session_value_ptr(thd, base);
}
@@ -2275,12 +2275,12 @@ public:
{
DBUG_ASSERT(false);
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(false);
return NULL;
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base);
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base);
};
@@ -2324,12 +2324,12 @@ public:
{
DBUG_ASSERT(false);
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(false);
return NULL;
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base);
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base);
};
@@ -2364,12 +2364,12 @@ public:
/* Record the attempt to use default so we can error. */
var->value= 0;
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(false);
return NULL;
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base);
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base);
uchar *default_value_ptr(THD *thd)
{ return 0; }
};
@@ -2406,12 +2406,12 @@ public:
/* Record the attempt to use default so we can error. */
var->value= 0;
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(false);
return NULL;
}
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base);
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base);
uchar *default_value_ptr(THD *thd)
{ return 0; }
};
@@ -2456,8 +2456,8 @@ public:
{
DBUG_ASSERT(false);
}
- uchar *session_value_ptr(THD *thd, const LEX_STRING *base);
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base)
+ uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base);
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{
DBUG_ASSERT(false);
return NULL;
@@ -2483,5 +2483,5 @@ public:
SYSVAR_ASSERT(scope() == GLOBAL);
}
bool global_update(THD *thd, set_var *var);
- uchar *global_value_ptr(THD *thd, const LEX_STRING *base);
+ uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base);
};
diff --git a/sql/table.cc b/sql/table.cc
index fae17fd8f20..b57d45b0f1f 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -53,25 +53,25 @@ static Virtual_column_info * unpack_vcol_info_from_frm(THD *, MEM_ROOT *,
static bool check_vcol_forward_refs(Field *, Virtual_column_info *);
/* INFORMATION_SCHEMA name */
-LEX_STRING INFORMATION_SCHEMA_NAME= {C_STRING_WITH_LEN("information_schema")};
+LEX_CSTRING INFORMATION_SCHEMA_NAME= {STRING_WITH_LEN("information_schema")};
/* PERFORMANCE_SCHEMA name */
-LEX_STRING PERFORMANCE_SCHEMA_DB_NAME= {C_STRING_WITH_LEN("performance_schema")};
+LEX_CSTRING PERFORMANCE_SCHEMA_DB_NAME= {STRING_WITH_LEN("performance_schema")};
/* MYSQL_SCHEMA name */
-LEX_STRING MYSQL_SCHEMA_NAME= {C_STRING_WITH_LEN("mysql")};
+LEX_CSTRING MYSQL_SCHEMA_NAME= {STRING_WITH_LEN("mysql")};
/* GENERAL_LOG name */
-LEX_STRING GENERAL_LOG_NAME= {C_STRING_WITH_LEN("general_log")};
+LEX_CSTRING GENERAL_LOG_NAME= {STRING_WITH_LEN("general_log")};
/* SLOW_LOG name */
-LEX_STRING SLOW_LOG_NAME= {C_STRING_WITH_LEN("slow_log")};
+LEX_CSTRING SLOW_LOG_NAME= {STRING_WITH_LEN("slow_log")};
/*
Keyword added as a prefix when parsing the defining expression for a
virtual column read from the column definition saved in the frm file
*/
-static LEX_STRING parse_vcol_keyword= { C_STRING_WITH_LEN("PARSE_VCOL_EXPR ") };
+static LEX_CSTRING parse_vcol_keyword= { STRING_WITH_LEN("PARSE_VCOL_EXPR ") };
static int64 last_table_id;
@@ -208,8 +208,8 @@ View_creation_ctx * View_creation_ctx::create(THD *thd,
static uchar *get_field_name(Field **buff, size_t *length,
my_bool not_used __attribute__((unused)))
{
- *length= (uint) strlen((*buff)->field_name);
- return (uchar*) (*buff)->field_name;
+ *length= (uint) (*buff)->field_name.length;
+ return (uchar*) (*buff)->field_name.str;
}
@@ -242,7 +242,8 @@ char *fn_rext(char *name)
return name + strlen(name);
}
-TABLE_CATEGORY get_table_category(const LEX_STRING *db, const LEX_STRING *name)
+TABLE_CATEGORY get_table_category(const LEX_CSTRING *db,
+ const LEX_CSTRING *name)
{
DBUG_ASSERT(db != NULL);
DBUG_ASSERT(name != NULL);
@@ -322,7 +323,7 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name,
share->path.str= path_buff;
share->path.length= path_length;
- strmov(share->path.str, path);
+ strmov(path_buff, path);
share->normalized_path.str= share->path.str;
share->normalized_path.length= path_length;
share->table_category= get_table_category(& share->db, & share->table_name);
@@ -621,7 +622,7 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
share->is_view= 1;
if (flags & GTS_VIEW)
{
- LEX_STRING pathstr= { path, length };
+ LEX_CSTRING pathstr= { path, length };
/*
Create view file parser and hold it in TABLE_SHARE member
view_def.
@@ -1273,7 +1274,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
case EXTRA2_DEFAULT_PART_ENGINE:
#ifdef WITH_PARTITION_STORAGE_ENGINE
{
- LEX_STRING name= { (char*)extra2, length };
+ LEX_CSTRING name= { (char*)extra2, length };
share->default_part_plugin= ha_resolve_by_name(NULL, &name, false);
if (!share->default_part_plugin)
goto err;
@@ -1436,7 +1437,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
if (next_chunk + 2 < buff_end)
{
uint str_db_type_length= uint2korr(next_chunk);
- LEX_STRING name;
+ LEX_CSTRING name;
name.str= (char*) next_chunk + 2;
name.length= str_db_type_length;
@@ -1483,7 +1484,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
else if (!tmp_plugin)
{
/* purecov: begin inspected */
- name.str[name.length]=0;
+ ((char*) name.str)[name.length]=0;
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), name.str);
goto err;
/* purecov: end */
@@ -1534,7 +1535,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
{
if (keyinfo->flags & HA_USES_PARSER)
{
- LEX_STRING parser_name;
+ LEX_CSTRING parser_name;
if (next_chunk >= buff_end)
{
DBUG_PRINT("error",
@@ -1747,7 +1748,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
enum_field_types field_type;
CHARSET_INFO *charset=NULL;
Field::geometry_type geom_type= Field::GEOM_GEOMETRY;
- LEX_STRING comment;
+ LEX_CSTRING comment;
+ LEX_CSTRING name;
Virtual_column_info *vcol_info= 0;
uint gis_length, gis_decimals, srid= 0;
Field::utype unireg_check;
@@ -1960,12 +1962,14 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
/* Convert pre-10.2.2 timestamps to use Field::default_value */
unireg_check= (Field::utype) MTYP_TYPENR(unireg_type);
+ name.str= fieldnames.type_names[i];
+ name.length= strlen(name.str);
*field_ptr= reg_field=
make_field(share, &share->mem_root, record+recpos, (uint32) field_length,
null_pos, null_bit_pos, pack_flag, field_type, charset,
geom_type, srid, unireg_check,
(interval_nr ? share->intervals+interval_nr-1 : NULL),
- share->fieldnames.type_names[i]);
+ &name);
if (!reg_field) // Not supported field type
goto err;
@@ -1997,8 +2001,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
if (vcol_info)
{
- vcol_info->name.str= const_cast<char*>(reg_field->field_name);
- vcol_info->name.length = strlen(reg_field->field_name);
+ vcol_info->name= reg_field->field_name;
if (mysql57_null_bits && !vcol_info->stored_in_db)
{
/* MySQL 5.7 has null bits last */
@@ -2381,15 +2384,14 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
}
vcol_screen_pos+= FRM_VCOL_NEW_HEADER_SIZE;
- vcol_info->name.length= name_length;
if (name_length)
+ {
vcol_info->name.str= strmake_root(&share->mem_root,
(char*)vcol_screen_pos, name_length);
- else
- {
- vcol_info->name.str= const_cast<char*>(reg_field->field_name);
- vcol_info->name.length = strlen(reg_field->field_name);
+ vcol_info->name.length= name_length;
}
+ else
+ vcol_info->name= reg_field->field_name;
vcol_screen_pos+= name_length + expr_length;
switch (type) {
@@ -2621,7 +2623,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
else
thd->set_n_backup_active_arena(arena, &backup);
- thd->reset_db(db.str, db.length);
+ thd->reset_db((char*) db.str, db.length);
lex_start(thd);
if ((error= parse_sql(thd, & parser_state, NULL) ||
@@ -3913,7 +3915,6 @@ bool check_table_name(const char *name, size_t length, bool check_for_path_chars
size_t name_length= 0;
const char *end= name+length;
-
if (!check_for_path_chars &&
(check_for_path_chars= check_mysql50_prefix(name)))
{
@@ -4064,7 +4065,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
{
Field *field= table->field[i];
- if (strncmp(field->field_name, field_def->name.str,
+ if (strncmp(field->field_name.str, field_def->name.str,
field_def->name.length))
{
/*
@@ -4076,7 +4077,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
"expected column '%s' at position %d, found '%s'.",
table->s->db.str, table->alias.c_ptr(),
field_def->name.str, i,
- field->field_name);
+ field->field_name.str);
}
field->sql_type(sql_type);
/*
@@ -4525,7 +4526,7 @@ void TABLE::reset_item_list(List<Item> *item_list, uint skip) const
buffer buffer for md5 writing
*/
-void TABLE_LIST::calc_md5(char *buffer)
+void TABLE_LIST::calc_md5(const char *buffer)
{
uchar digest[16];
compute_md5_hash(digest, select_stmt.str,
@@ -4613,8 +4614,9 @@ bool TABLE_LIST::create_field_translation(THD *thd)
while ((item= it++))
{
- DBUG_ASSERT(item->name && item->name[0]);
- transl[field_count].name= thd->strdup(item->name);
+ DBUG_ASSERT(item->name.str && item->name.str[0]);
+ transl[field_count].name.str= thd->strmake(item->name.str, item->name.length);
+ transl[field_count].name.length= item->name.length;
transl[field_count++].item= item;
}
field_translation= transl;
@@ -5439,7 +5441,7 @@ bool TABLE_LIST::prepare_security(THD *thd)
while ((tbl= tb++))
{
DBUG_ASSERT(tbl->referencing_view);
- char *local_db, *local_table_name;
+ const char *local_db, *local_table_name;
if (tbl->view)
{
local_db= tbl->view_db.str;
@@ -5564,15 +5566,15 @@ Natural_join_column::Natural_join_column(Item_field *field_param,
}
-const char *Natural_join_column::name()
+LEX_CSTRING *Natural_join_column::name()
{
if (view_field)
{
DBUG_ASSERT(table_field == NULL);
- return view_field->name;
+ return &view_field->name;
}
- return table_field->field_name;
+ return &table_field->field_name;
}
@@ -5582,7 +5584,7 @@ Item *Natural_join_column::create_item(THD *thd)
{
DBUG_ASSERT(table_field == NULL);
return create_view_field(thd, table_ref, &view_field->item,
- view_field->name);
+ &view_field->name);
}
return table_field;
}
@@ -5651,9 +5653,9 @@ void Field_iterator_view::set(TABLE_LIST *table)
}
-const char *Field_iterator_table::name()
+LEX_CSTRING *Field_iterator_table::name()
{
- return (*ptr)->field_name;
+ return &(*ptr)->field_name;
}
@@ -5662,6 +5664,7 @@ Item *Field_iterator_table::create_item(THD *thd)
SELECT_LEX *select= thd->lex->current_select;
Item_field *item= new (thd->mem_root) Item_field(thd, &select->context, *ptr);
+ DBUG_ASSERT(strlen(item->name.str) == item->name.length);
if (item && thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
!thd->lex->in_sum_func && select->cur_pos_in_select_list != UNDEF_POS)
{
@@ -5673,19 +5676,19 @@ Item *Field_iterator_table::create_item(THD *thd)
}
-const char *Field_iterator_view::name()
+LEX_CSTRING *Field_iterator_view::name()
{
- return ptr->name;
+ return &ptr->name;
}
Item *Field_iterator_view::create_item(THD *thd)
{
- return create_view_field(thd, view, &ptr->item, ptr->name);
+ return create_view_field(thd, view, &ptr->item, &ptr->name);
}
Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
- const char *name)
+ LEX_CSTRING *name)
{
bool save_wrapper= thd->lex->select_lex.no_wrap_view_item;
Item *field= *field_ref;
@@ -7387,7 +7390,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
if (vcol_info->expr->save_in_field(vf, 0))
field_error= error= 1;
DBUG_PRINT("info", ("field '%s' - updated error: %d",
- vf->field_name, field_error));
+ vf->field_name.str, field_error));
if (swap_values && (vf->flags & BLOB_FLAG))
{
/*
@@ -7401,7 +7404,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
}
else
{
- DBUG_PRINT("info", ("field '%s' - skipped", vf->field_name));
+ DBUG_PRINT("info", ("field '%s' - skipped", vf->field_name.str));
}
}
if (handler_pushed)
@@ -7475,7 +7478,7 @@ int TABLE::update_default_fields(bool update_command, bool ignore_errors)
res|= field->evaluate_update_default_function();
if (!ignore_errors && res)
{
- my_error(ER_CALCULATING_DEFAULT_VALUE, MYF(0), field->field_name);
+ my_error(ER_CALCULATING_DEFAULT_VALUE, MYF(0), field->field_name.str);
break;
}
res= 0;
@@ -8229,11 +8232,13 @@ LEX_CSTRING *fk_option_name(enum_fk_option opt)
}
-Field *TABLE::find_field_by_name(const char *str) const
+Field *TABLE::find_field_by_name(LEX_CSTRING *str) const
{
+ uint length= str->length;
for (Field **tmp= field; *tmp; tmp++)
{
- if (!my_strcasecmp(system_charset_info, (*tmp)->field_name, str))
+ if ((*tmp)->field_name.length == length &&
+ !my_strcasecmp(system_charset_info, (*tmp)->field_name.str, str->str))
return *tmp;
}
return NULL;
@@ -8245,9 +8250,9 @@ bool TABLE::export_structure(THD *thd, Row_definition_list *defs)
for (Field **src= field; *src; src++)
{
uint offs;
- if (defs->find_row_field_by_name(src[0]->field_name, &offs))
+ if (defs->find_row_field_by_name(&src[0]->field_name, &offs))
{
- my_error(ER_DUP_FIELDNAME, MYF(0), src[0]->field_name);
+ my_error(ER_DUP_FIELDNAME, MYF(0), src[0]->field_name.str);
return true;
}
Spvar_definition *def= new (thd->mem_root) Spvar_definition(thd, *src);
diff --git a/sql/table.h b/sql/table.h
index 94a0d483413..ebe5ced5bc1 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -449,15 +449,15 @@ enum enum_table_category
};
typedef enum enum_table_category TABLE_CATEGORY;
-TABLE_CATEGORY get_table_category(const LEX_STRING *db,
- const LEX_STRING *name);
+TABLE_CATEGORY get_table_category(const LEX_CSTRING *db,
+ const LEX_CSTRING *name);
typedef struct st_table_field_type
{
- LEX_STRING name;
- LEX_STRING type;
- LEX_STRING cset;
+ LEX_CSTRING name;
+ LEX_CSTRING type;
+ LEX_CSTRING cset;
} TABLE_FIELD_TYPE;
@@ -601,7 +601,7 @@ struct TABLE_SHARE
TABLE_STATISTICS_CB stats_cb;
uchar *default_values; /* row with default values */
- LEX_STRING comment; /* Comment about table */
+ LEX_CSTRING comment; /* Comment about table */
CHARSET_INFO *table_charset; /* Default charset of string fields */
MY_BITMAP *check_set; /* Fields used by check constrant */
@@ -616,12 +616,12 @@ struct TABLE_SHARE
should correspond to each other.
To ensure this one can use set_table_cache() methods.
*/
- LEX_STRING table_cache_key;
- LEX_STRING db; /* Pointer to db */
- LEX_STRING table_name; /* Table name (for open) */
- LEX_STRING path; /* Path to .frm file (from datadir) */
- LEX_STRING normalized_path; /* unpack_filename(path) */
- LEX_STRING connect_string;
+ LEX_CSTRING table_cache_key;
+ LEX_CSTRING db; /* Pointer to db */
+ LEX_CSTRING table_name; /* Table name (for open) */
+ LEX_CSTRING path; /* Path to .frm file (from datadir) */
+ LEX_CSTRING normalized_path; /* unpack_filename(path) */
+ LEX_CSTRING connect_string;
/*
Set of keys in use, implemented as a Bitmap.
@@ -1445,7 +1445,7 @@ public:
TABLE *tmp_table,
TMP_TABLE_PARAM *tmp_table_param,
bool with_cleanup);
- Field *find_field_by_name(const char *str) const;
+ Field *find_field_by_name(LEX_CSTRING *str) const;
bool export_structure(THD *thd, class Row_definition_list *defs);
};
@@ -1493,16 +1493,16 @@ enum enum_fk_option { FK_OPTION_UNDEF, FK_OPTION_RESTRICT, FK_OPTION_CASCADE,
typedef struct st_foreign_key_info
{
- LEX_STRING *foreign_id;
- LEX_STRING *foreign_db;
- LEX_STRING *foreign_table;
- LEX_STRING *referenced_db;
- LEX_STRING *referenced_table;
+ LEX_CSTRING *foreign_id;
+ LEX_CSTRING *foreign_db;
+ LEX_CSTRING *foreign_table;
+ LEX_CSTRING *referenced_db;
+ LEX_CSTRING *referenced_table;
enum_fk_option update_method;
enum_fk_option delete_method;
- LEX_STRING *referenced_key_name;
- List<LEX_STRING> foreign_fields;
- List<LEX_STRING> referenced_fields;
+ LEX_CSTRING *referenced_key_name;
+ List<LEX_CSTRING> foreign_fields;
+ List<LEX_CSTRING> referenced_fields;
} FOREIGN_KEY_INFO;
LEX_CSTRING *fk_option_name(enum_fk_option opt);
@@ -1565,7 +1565,8 @@ typedef struct st_schema_table
/* Handle fileds for old SHOW */
int (*old_format) (THD *thd, struct st_schema_table *schema_table);
int (*process_table) (THD *thd, TABLE_LIST *tables, TABLE *table,
- bool res, LEX_STRING *db_name, LEX_STRING *table_name);
+ bool res, const LEX_CSTRING *db_name,
+ const LEX_CSTRING *table_name);
int idx_field1, idx_field2;
bool hidden;
uint i_s_requested_object; /* the object we need to open(TABLE | VIEW) */
@@ -1646,12 +1647,12 @@ class select_unit;
class TMP_TABLE_PARAM;
Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
- const char *name);
+ LEX_CSTRING *name);
struct Field_translator
{
Item *item;
- const char *name;
+ LEX_CSTRING name;
};
@@ -1678,7 +1679,7 @@ public:
public:
Natural_join_column(Field_translator *field_param, TABLE_LIST *tab);
Natural_join_column(Item_field *field_param, TABLE_LIST *tab);
- const char *name();
+ LEX_CSTRING *name();
Item *create_item(THD *thd);
Field *field();
const char *table_name();
@@ -1799,8 +1800,8 @@ struct TABLE_LIST
TABLE_LIST *next_local;
/* link in a global list of all queries tables */
TABLE_LIST *next_global, **prev_global;
- char *db, *alias, *table_name, *schema_table_name;
- char *option; /* Used by cache index */
+ const char *db, *alias, *table_name, *schema_table_name;
+ const char *option; /* Used by cache index */
Item *on_expr; /* Used with outer join */
Item *sj_on_expr;
@@ -1991,10 +1992,10 @@ struct TABLE_LIST
Item *where; /* VIEW WHERE clause condition */
Item *check_option; /* WITH CHECK OPTION condition */
LEX_STRING select_stmt; /* text of (CREATE/SELECT) statement */
- LEX_STRING md5; /* md5 of query text */
- LEX_STRING source; /* source of CREATE VIEW */
- LEX_STRING view_db; /* saved view database */
- LEX_STRING view_name; /* saved view name */
+ LEX_CSTRING md5; /* md5 of query text */
+ LEX_CSTRING source; /* source of CREATE VIEW */
+ LEX_CSTRING view_db; /* saved view database */
+ LEX_CSTRING view_name; /* saved view name */
LEX_STRING timestamp; /* GMT time stamp of last operation */
st_lex_user definer; /* definer of view */
ulonglong file_version; /* version of file's field set */
@@ -2128,8 +2129,8 @@ struct TABLE_LIST
These attributes MUST NOT be used for any purposes but the parsing.
*/
- LEX_STRING view_client_cs_name;
- LEX_STRING view_connection_cl_name;
+ LEX_CSTRING view_client_cs_name;
+ LEX_CSTRING view_connection_cl_name;
/*
View definition (SELECT-statement) in the UTF-form.
@@ -2177,7 +2178,7 @@ struct TABLE_LIST
List<String> *partition_names;
#endif /* WITH_PARTITION_STORAGE_ENGINE */
- void calc_md5(char *buffer);
+ void calc_md5(const char *buffer);
int view_check_option(THD *thd, bool ignore_failure);
bool create_field_translation(THD *thd);
bool setup_underlying(THD *thd);
@@ -2360,7 +2361,7 @@ struct TABLE_LIST
@brief Returns the name of the database that the referenced table belongs
to.
*/
- char *get_db_name() const { return view != NULL ? view_db.str : db; }
+ const char *get_db_name() const { return view != NULL ? view_db.str : db; }
/**
@brief Returns the name of the table that this TABLE_LIST represents.
@@ -2368,7 +2369,7 @@ struct TABLE_LIST
@details The unqualified table name or view name for a table or view,
respectively.
*/
- char *get_table_name() const { return view != NULL ? view_name.str : table_name; }
+ const char *get_table_name() const { return view != NULL ? view_name.str : table_name; }
bool is_active_sjm();
bool is_jtbm() { return MY_TEST(jtbm_subselect != NULL); }
st_select_lex_unit *get_unit();
@@ -2422,7 +2423,7 @@ public:
virtual void set(TABLE_LIST *)= 0;
virtual void next()= 0;
virtual bool end_of_fields()= 0; /* Return 1 at end of list */
- virtual const char *name()= 0;
+ virtual LEX_CSTRING *name()= 0;
virtual Item *create_item(THD *)= 0;
virtual Field *field()= 0;
};
@@ -2442,7 +2443,7 @@ public:
void set_table(TABLE *table) { ptr= table->field; }
void next() { ptr++; }
bool end_of_fields() { return *ptr == 0; }
- const char *name();
+ LEX_CSTRING *name();
Item *create_item(THD *thd);
Field *field() { return *ptr; }
};
@@ -2459,7 +2460,7 @@ public:
void set(TABLE_LIST *table);
void next() { ptr++; }
bool end_of_fields() { return ptr == array_end; }
- const char *name();
+ LEX_CSTRING *name();
Item *create_item(THD *thd);
Item **item_ptr() {return &ptr->item; }
Field *field() { return 0; }
@@ -2483,7 +2484,7 @@ public:
void set(TABLE_LIST *table);
void next();
bool end_of_fields() { return !cur_column_ref; }
- const char *name() { return cur_column_ref->name(); }
+ LEX_CSTRING *name() { return cur_column_ref->name(); }
Item *create_item(THD *thd) { return cur_column_ref->create_item(thd); }
Field *field() { return cur_column_ref->field(); }
Natural_join_column *column_ref() { return cur_column_ref; }
@@ -2520,7 +2521,7 @@ public:
void next();
bool end_of_fields()
{ return (table_ref == last_leaf && field_it->end_of_fields()); }
- const char *name() { return field_it->name(); }
+ LEX_CSTRING *name() { return field_it->name(); }
const char *get_table_name();
const char *get_db_name();
GRANT_INFO *grant();
@@ -2701,7 +2702,7 @@ int rename_file_ext(const char * from,const char * to,const char * ext);
char *get_field(MEM_ROOT *mem, Field *field);
bool get_field(MEM_ROOT *mem, Field *field, class String *res);
-bool validate_comment_length(THD *thd, LEX_STRING *comment, size_t max_len,
+bool validate_comment_length(THD *thd, LEX_CSTRING *comment, size_t max_len,
uint err_code, const char *name);
int closefrm(TABLE *table);
@@ -2724,14 +2725,14 @@ static inline int set_zone(int nr,int min_zone,int max_zone)
}
/* performance schema */
-extern LEX_STRING PERFORMANCE_SCHEMA_DB_NAME;
+extern LEX_CSTRING PERFORMANCE_SCHEMA_DB_NAME;
-extern LEX_STRING GENERAL_LOG_NAME;
-extern LEX_STRING SLOW_LOG_NAME;
+extern LEX_CSTRING GENERAL_LOG_NAME;
+extern LEX_CSTRING SLOW_LOG_NAME;
/* information schema */
-extern LEX_STRING INFORMATION_SCHEMA_NAME;
-extern LEX_STRING MYSQL_SCHEMA_NAME;
+extern LEX_CSTRING INFORMATION_SCHEMA_NAME;
+extern LEX_CSTRING MYSQL_SCHEMA_NAME;
inline bool is_infoschema_db(const char *name, size_t len)
{
diff --git a/sql/transaction.cc b/sql/transaction.cc
index 9bacfb81bba..8e3a812abff 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -577,7 +577,7 @@ bool trans_rollback_stmt(THD *thd)
/* Find a named savepoint in the current transaction. */
static SAVEPOINT **
-find_savepoint(THD *thd, LEX_STRING name)
+find_savepoint(THD *thd, LEX_CSTRING name)
{
SAVEPOINT **sv= &thd->transaction.savepoints;
@@ -603,7 +603,7 @@ find_savepoint(THD *thd, LEX_STRING name)
@retval TRUE Failure
*/
-bool trans_savepoint(THD *thd, LEX_STRING name)
+bool trans_savepoint(THD *thd, LEX_CSTRING name)
{
SAVEPOINT **sv, *newsv;
DBUG_ENTER("trans_savepoint");
@@ -680,7 +680,7 @@ bool trans_savepoint(THD *thd, LEX_STRING name)
@retval TRUE Failure
*/
-bool trans_rollback_to_savepoint(THD *thd, LEX_STRING name)
+bool trans_rollback_to_savepoint(THD *thd, LEX_CSTRING name)
{
int res= FALSE;
SAVEPOINT *sv= *find_savepoint(thd, name);
@@ -757,7 +757,7 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_STRING name)
@retval TRUE Failure
*/
-bool trans_release_savepoint(THD *thd, LEX_STRING name)
+bool trans_release_savepoint(THD *thd, LEX_CSTRING name)
{
int res= FALSE;
SAVEPOINT *sv= *find_savepoint(thd, name);
diff --git a/sql/transaction.h b/sql/transaction.h
index 90de11aabe3..b6b22053150 100644
--- a/sql/transaction.h
+++ b/sql/transaction.h
@@ -34,9 +34,9 @@ bool trans_rollback_implicit(THD *thd);
bool trans_commit_stmt(THD *thd);
bool trans_rollback_stmt(THD *thd);
-bool trans_savepoint(THD *thd, LEX_STRING name);
-bool trans_rollback_to_savepoint(THD *thd, LEX_STRING name);
-bool trans_release_savepoint(THD *thd, LEX_STRING name);
+bool trans_savepoint(THD *thd, LEX_CSTRING name);
+bool trans_rollback_to_savepoint(THD *thd, LEX_CSTRING name);
+bool trans_release_savepoint(THD *thd, LEX_CSTRING name);
bool trans_xa_start(THD *thd);
bool trans_xa_end(THD *thd);
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 0bb8a4e77c6..268ee24f509 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -73,7 +73,7 @@ static uchar *extra2_write_len(uchar *pos, size_t len)
}
static uchar *extra2_write(uchar *pos, enum extra2_frm_value_type type,
- LEX_STRING *str)
+ const LEX_CSTRING *str)
{
*pos++ = type;
pos= extra2_write_len(pos, str->length);
@@ -84,7 +84,7 @@ static uchar *extra2_write(uchar *pos, enum extra2_frm_value_type type,
static uchar *extra2_write(uchar *pos, enum extra2_frm_value_type type,
LEX_CUSTRING *str)
{
- return extra2_write(pos, type, reinterpret_cast<LEX_STRING *>(str));
+ return extra2_write(pos, type, reinterpret_cast<LEX_CSTRING *>(str));
}
/**
@@ -107,7 +107,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const char *table,
List<Create_field> &create_fields,
uint keys, KEY *key_info, handler *db_file)
{
- LEX_STRING str_db_type;
+ LEX_CSTRING str_db_type;
uint reclength, key_info_length, i;
ulong key_buff_length;
ulong filepos, data_offset;
@@ -616,7 +616,8 @@ static bool pack_header(THD *thd, uchar *forminfo,
while ((field=it++))
{
if (validate_comment_length(thd, &field->comment, COLUMN_COMMENT_MAXLEN,
- ER_TOO_LONG_FIELD_COMMENT, field->field_name))
+ ER_TOO_LONG_FIELD_COMMENT,
+ field->field_name.str))
DBUG_RETURN(1);
totlength+= field->length;
@@ -632,7 +633,7 @@ static bool pack_header(THD *thd, uchar *forminfo,
length=field->pack_length;
if ((uint) field->offset+ (uint) data_offset+ length > reclength)
reclength=(uint) (field->offset+ data_offset + length);
- n_length+= (ulong) strlen(field->field_name)+1;
+ n_length+= field->field_name.length + 1;
field->interval_id=0;
field->save_interval= 0;
if (field->interval)
@@ -776,7 +777,7 @@ static size_t packed_fields_length(List<Create_field> &create_fields)
}
length+= FCOMP;
- length+= strlen(field->field_name)+1;
+ length+= field->field_name.length + 1;
length+= field->comment.length;
}
length+= 2;
@@ -837,7 +838,7 @@ static bool pack_fields(uchar **buff_arg, List<Create_field> &create_fields,
it.rewind();
while ((field=it++))
{
- buff= (uchar*)strmov((char*) buff, field->field_name);
+ buff= (uchar*)strmov((char*) buff, field->field_name.str);
*buff++=NAMES_SEP_CHAR;
}
*buff++= 0;
@@ -959,7 +960,7 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options,
field->unireg_check,
field->save_interval ? field->save_interval
: field->interval,
- field->field_name);
+ &field->field_name);
if (!regfield)
{
error= 1;
@@ -989,7 +990,7 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options,
/* If not ok or warning of level 'note' */
if (res != 0 && res != 3)
{
- my_error(ER_INVALID_DEFAULT, MYF(0), regfield->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), regfield->field_name.str);
error= 1;
delete regfield; //To avoid memory leak
goto err;
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index bbeb56d9b21..1cdcb30d8ed 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -1409,7 +1409,7 @@ static int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
1: TOI replication was skipped
-1: TOI replication failed
*/
-static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
+static int wsrep_TOI_begin(THD *thd, const char *db_, const char *table_,
const TABLE_LIST* table_list)
{
wsrep_status_t ret(WSREP_WARNING);
@@ -1473,8 +1473,8 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
ret,
(thd->db ? thd->db : "(null)"),
(thd->query()) ? thd->query() : "void");
- my_error(ER_LOCK_DEADLOCK, MYF(0), "WSREP replication failed. Check "
- "your wsrep connection state and retry the query.");
+ my_message(ER_LOCK_DEADLOCK, "WSREP replication failed. Check "
+ "your wsrep connection state and retry the query.", MYF(0));
wsrep_keys_free(&key_arr);
rc= -1;
}
@@ -1512,7 +1512,7 @@ static void wsrep_TOI_end(THD *thd) {
}
}
-static int wsrep_RSU_begin(THD *thd, char *db_, char *table_)
+static int wsrep_RSU_begin(THD *thd, const char *db_, const char *table_)
{
wsrep_status_t ret(WSREP_WARNING);
WSREP_DEBUG("RSU BEGIN: %lld, %d : %s", (long long)wsrep_thd_trx_seqno(thd),
@@ -1595,7 +1595,7 @@ static void wsrep_RSU_end(THD *thd)
thd->variables.wsrep_on = 1;
}
-int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,
+int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
const TABLE_LIST* table_list)
{
int ret= 0;
@@ -2549,8 +2549,8 @@ static int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len)
LEX *lex= thd->lex;
String stmt_query;
- LEX_STRING definer_user;
- LEX_STRING definer_host;
+ LEX_CSTRING definer_user;
+ LEX_CSTRING definer_host;
if (!lex->definer)
{
@@ -2587,7 +2587,7 @@ static int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len)
append_definer(thd, &stmt_query, &definer_user, &definer_host);
- LEX_STRING stmt_definition;
+ LEX_CSTRING stmt_definition;
uint not_used;
stmt_definition.str= (char*) thd->lex->stmt_definition_begin;
stmt_definition.length= thd->lex->stmt_definition_end
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index 8c81367d12f..c553b4ba27e 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -280,7 +280,7 @@ extern PSI_mutex_key key_LOCK_wsrep_desync;
extern PSI_file_key key_file_wsrep_gra_log;
#endif /* HAVE_PSI_INTERFACE */
struct TABLE_LIST;
-int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,
+int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
const TABLE_LIST* table_list);
void wsrep_to_isolation_end(THD *thd);
void wsrep_cleanup_transaction(THD *thd);
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 03e53dd3e97..a2d3b4923ab 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -103,7 +103,7 @@ static rpl_group_info* wsrep_relay_group_init(const char* log_fname)
new Format_description_log_event(4);
}
- static LEX_STRING connection_name= { C_STRING_WITH_LEN("wsrep") };
+ static LEX_CSTRING connection_name= { STRING_WITH_LEN("wsrep") };
/*
Master_info's constructor initializes rpl_filter by either an already
@@ -285,7 +285,6 @@ void wsrep_replay_transaction(THD *thd)
else
{
WSREP_DEBUG("replay failed, rolling back");
- //my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction");
}
thd->wsrep_conflict_state= ABORTED;
wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle);
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index b34fdf8b7ed..d7f55dbca60 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -313,7 +313,7 @@ bool wsrep_provider_update (sys_var *self, THD* thd, enum_var_type type)
//when fails
if (wsrep_init())
{
- my_error(ER_CANT_OPEN_LIBRARY, MYF(0), tmp);
+ my_error(ER_CANT_OPEN_LIBRARY, MYF(0), tmp, my_error, "wsrep_init failed");
rcode = true;
}
free(tmp);
@@ -614,7 +614,7 @@ bool wsrep_max_ws_size_update (sys_var *self, THD *thd, enum_var_type)
char max_ws_size_opt[128];
my_snprintf(max_ws_size_opt, sizeof(max_ws_size_opt),
- "repl.max_ws_size=%d", wsrep_max_ws_size);
+ "repl.max_ws_size=%lu", wsrep_max_ws_size);
wsrep_status_t ret= wsrep->options_set(wsrep, max_ws_size_opt);
if (ret != WSREP_OK)
{