summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysql.cc121
-rw-r--r--extra/my_print_defaults.c2
-rw-r--r--include/my_sys.h6
-rw-r--r--libmysqld/libmysql.c11
-rw-r--r--mysys/charset.c33
-rw-r--r--plugin/feedback/sender_thread.cc6
-rw-r--r--plugin/func_test/plugin.cc6
-rw-r--r--plugin/type_inet/item_inetfunc.h55
-rw-r--r--plugin/type_inet/sql_type_inet.cc8
-rw-r--r--plugin/type_inet/sql_type_inet.h4
-rw-r--r--plugin/type_mysql_json/mysql_json.cc28
-rw-r--r--sql/create_options.cc2
-rw-r--r--sql/event_data_objects.cc2
-rw-r--r--sql/event_scheduler.cc4
-rw-r--r--sql/field.cc2
-rw-r--r--sql/field_conv.cc2
-rw-r--r--sql/filesort.cc17
-rw-r--r--sql/ha_partition.cc84
-rw-r--r--sql/handler.cc17
-rw-r--r--sql/handler.h2
-rw-r--r--sql/item.cc106
-rw-r--r--sql/item.h58
-rw-r--r--sql/item_cmpfunc.cc72
-rw-r--r--sql/item_cmpfunc.h275
-rw-r--r--sql/item_func.cc47
-rw-r--r--sql/item_func.h548
-rw-r--r--sql/item_geofunc.cc54
-rw-r--r--sql/item_geofunc.h297
-rw-r--r--sql/item_jsonfunc.cc110
-rw-r--r--sql/item_jsonfunc.h157
-rw-r--r--sql/item_strfunc.cc21
-rw-r--r--sql/item_strfunc.h534
-rw-r--r--sql/item_subselect.cc48
-rw-r--r--sql/item_sum.cc11
-rw-r--r--sql/item_sum.h78
-rw-r--r--sql/item_timefunc.cc32
-rw-r--r--sql/item_timefunc.h319
-rw-r--r--sql/item_vers.cc2
-rw-r--r--sql/item_vers.h43
-rw-r--r--sql/item_windowfunc.cc15
-rw-r--r--sql/item_windowfunc.h74
-rw-r--r--sql/item_xmlfunc.cc91
-rw-r--r--sql/item_xmlfunc.h12
-rw-r--r--sql/json_table.cc47
-rw-r--r--sql/key.cc4
-rw-r--r--sql/log_event_server.cc30
-rw-r--r--sql/my_json_writer.cc14
-rw-r--r--sql/mysqld.h2
-rw-r--r--sql/opt_range.cc29
-rw-r--r--sql/protocol.cc11
-rw-r--r--sql/protocol.h11
-rw-r--r--sql/repl_failsafe.cc6
-rw-r--r--sql/rpl_filter.cc2
-rw-r--r--sql/rpl_gtid.cc6
-rw-r--r--sql/rpl_mi.cc7
-rw-r--r--sql/set_var.cc8
-rw-r--r--sql/slave.cc116
-rw-r--r--sql/sp.cc10
-rw-r--r--sql/sp_head.cc13
-rw-r--r--sql/spatial.cc10
-rw-r--r--sql/sql_acl.cc17
-rw-r--r--sql/sql_admin.cc130
-rw-r--r--sql/sql_analyse.h4
-rw-r--r--sql/sql_analyze_stmt.cc12
-rw-r--r--sql/sql_base.cc4
-rw-r--r--sql/sql_class.cc12
-rw-r--r--sql/sql_class.h3
-rw-r--r--sql/sql_cte.cc2
-rw-r--r--sql/sql_digest.cc8
-rw-r--r--sql/sql_explain.cc137
-rw-r--r--sql/sql_help.cc4
-rw-r--r--sql/sql_insert.cc10
-rw-r--r--sql/sql_lex.cc3
-rw-r--r--sql/sql_load.cc6
-rw-r--r--sql/sql_partition.cc18
-rw-r--r--sql/sql_partition_admin.cc2
-rw-r--r--sql/sql_repl.cc4
-rw-r--r--sql/sql_select.cc38
-rw-r--r--sql/sql_show.cc147
-rw-r--r--sql/sql_string.h62
-rw-r--r--sql/sql_table.cc76
-rw-r--r--sql/sql_table.h2
-rw-r--r--sql/sql_test.cc22
-rw-r--r--sql/sql_truncate.cc14
-rw-r--r--sql/sql_type.cc62
-rw-r--r--sql/sql_type.h49
-rw-r--r--sql/sql_type_geom.cc22
-rw-r--r--sql/sql_type_geom.h7
-rw-r--r--sql/sql_view.cc10
-rw-r--r--sql/sql_yacc.yy2
-rw-r--r--sql/strfunc.cc9
-rw-r--r--sql/table.cc11
-rw-r--r--sql/tztime.cc3
-rw-r--r--sql/wsrep_mysqld.cc15
-rw-r--r--storage/connect/ha_connect.cc74
-rw-r--r--storage/federated/ha_federated.cc29
-rw-r--r--storage/federatedx/ha_federatedx.cc60
-rw-r--r--storage/federatedx/ha_federatedx.h2
-rw-r--r--storage/maria/ha_maria.cc30
-rw-r--r--storage/myisam/ha_myisam.cc28
-rw-r--r--storage/myisammrg/ha_myisammrg.cc4
-rw-r--r--storage/oqgraph/ha_oqgraph.cc14
-rw-r--r--storage/rocksdb/ha_rocksdb.cc18
-rw-r--r--storage/rocksdb/rdb_datadic.cc8
-rw-r--r--storage/sphinx/ha_sphinx.cc41
-rw-r--r--storage/spider/hs_client/config.hpp2
-rw-r--r--storage/spider/hs_client/hstcpcli.cpp6
-rw-r--r--storage/spider/hs_client/socket.cpp3
-rw-r--r--storage/spider/spd_db_conn.cc16
-rw-r--r--storage/spider/spd_db_handlersocket.cc94
-rw-r--r--storage/spider/spd_db_mysql.cc102
-rw-r--r--storage/spider/spd_db_oracle.cc102
-rw-r--r--storage/spider/spd_malloc.cc13
113 files changed, 3547 insertions, 1768 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 494d4c2fbd1..131b3036df8 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -2062,13 +2062,14 @@ static int read_and_execute(bool interactive)
{
status.exit_status= 1;
String msg;
- msg.append("ASCII '\\0' appeared in the statement, but this is not "
- "allowed unless option --binary-mode is enabled and mysql is "
- "run in non-interactive mode. Set --binary-mode to 1 if ASCII "
- "'\\0' is expected. Query: '");
+ msg.append(STRING_WITH_LEN(
+ "ASCII '\\0' appeared in the statement, but this is not "
+ "allowed unless option --binary-mode is enabled and mysql is "
+ "run in non-interactive mode. Set --binary-mode to 1 if ASCII "
+ "'\\0' is expected. Query: '"));
msg.append(glob_buffer);
- msg.append(line);
- msg.append("'.");
+ msg.append(line, strlen(line));
+ msg.append(STRING_WITH_LEN("'."));
put_info(msg.c_ptr(), INFO_ERROR);
break;
}
@@ -2462,8 +2463,9 @@ static bool add_line(String &buffer, char *line, size_t line_length,
my_isspace(charset_info, pos[2]))))
{
// Add trailing single line comments to this statement
- buffer.append(pos);
- pos+= strlen(pos);
+ size_t length= strlen(pos);
+ buffer.append(pos, length);
+ pos+= length;
}
pos--;
@@ -2509,7 +2511,7 @@ static bool add_line(String &buffer, char *line, size_t line_length,
{
bool started_with_nothing= !buffer.length();
- buffer.append(pos);
+ buffer.append(pos, strlen(pos));
/*
A single-line comment by itself gets sent immediately so that
@@ -2667,7 +2669,7 @@ static void fix_history(String *final_command)
not in string, change to space
if in string, leave it alone
*/
- fixed_buffer.append(str_char == '\0' ? " " : "\n");
+ fixed_buffer.append(str_char == '\0' ? ' ' : '\n');
total_lines++;
break;
case '\\':
@@ -3313,7 +3315,8 @@ com_go(String *buffer,char *line __attribute__((unused)))
#ifdef HAVE_READLINE
if (status.add_to_history)
{
- buffer->append(vertical ? "\\G" : delimiter);
+ const char *delim= vertical ? "\\G" : delimiter;
+ buffer->append(delim, strlen(delim));
/* Append final command onto history */
fix_history(buffer);
}
@@ -5227,20 +5230,27 @@ static const char *construct_prompt()
add_int_to_prompt(++prompt_counter);
break;
case 'v':
- if (connected)
- processed_prompt.append(mysql_get_server_info(&mysql));
- else
- processed_prompt.append("not_connected");
+ {
+ const char *info= (connected ?
+ mysql_get_server_info(&mysql) :
+ "not_connected");
+ processed_prompt.append(info, strlen(info));
break;
+ }
case 'd':
- processed_prompt.append(current_db ? current_db : "(none)");
- break;
+ {
+ const char *db= current_db ? current_db : "(none)";
+ processed_prompt.append(db, strlen(db));
+ break;
+ }
case 'N':
- if (connected)
- processed_prompt.append(mysql_get_server_name(&mysql));
- else
- processed_prompt.append("unknown");
+ {
+ const char *name= (connected ?
+ mysql_get_server_name(&mysql) :
+ "unknown");
+ processed_prompt.append(name, strlen(name));
break;
+ }
case 'h':
case 'H':
{
@@ -5249,16 +5259,20 @@ static const char *construct_prompt()
if (strstr(prompt, "Localhost") || strstr(prompt, "localhost "))
{
if (*c == 'h')
- processed_prompt.append("localhost");
+ processed_prompt.append(STRING_WITH_LEN("localhost"));
else
{
static char hostname[FN_REFLEN];
- if (hostname[0])
- processed_prompt.append(hostname);
+ static size_t hostname_length;
+ if (hostname_length)
+ processed_prompt.append(hostname, hostname_length);
else if (gethostname(hostname, sizeof(hostname)) == 0)
- processed_prompt.append(hostname);
+ {
+ hostname_length= strlen(hostname);
+ processed_prompt.append(hostname, hostname_length);
+ }
else
- processed_prompt.append("gethostname(2) failed");
+ processed_prompt.append(STRING_WITH_LEN("gethostname(2) failed"));
}
}
else
@@ -5273,38 +5287,47 @@ static const char *construct_prompt()
#ifndef EMBEDDED_LIBRARY
if (!connected)
{
- processed_prompt.append("not_connected");
+ processed_prompt.append(STRING_WITH_LEN("not_connected"));
break;
}
const char *host_info = mysql_get_host_info(&mysql);
if (strstr(host_info, "memory"))
{
- processed_prompt.append( mysql.host );
+ processed_prompt.append( mysql.host, strlen(mysql.host));
}
else if (strstr(host_info,"TCP/IP") ||
!mysql.unix_socket)
add_int_to_prompt(mysql.port);
else
{
- char *pos=strrchr(mysql.unix_socket,'/');
- processed_prompt.append(pos ? pos+1 : mysql.unix_socket);
+ char *pos= strrchr(mysql.unix_socket,'/');
+ const char *tmp= pos ? pos+1 : mysql.unix_socket;
+ processed_prompt.append(tmp, strlen(tmp));
}
#endif
}
break;
case 'U':
+ {
+ const char *name;
if (!full_username)
init_username();
- processed_prompt.append(full_username ? full_username :
- (current_user ? current_user : "(unknown)"));
+ name= (full_username ? full_username :
+ (current_user ? current_user : "(unknown)"));
+ processed_prompt.append(name, strlen(name));
break;
+ }
case 'u':
+ {
+ const char *name;
if (!full_username)
init_username();
- processed_prompt.append(part_username ? part_username :
- (current_user ? current_user : "(unknown)"));
+ name= (part_username ? part_username :
+ (current_user ? current_user : "(unknown)"));
+ processed_prompt.append(name, strlen(name));
break;
+ }
case PROMPT_CHAR:
processed_prompt.append(PROMPT_CHAR);
break;
@@ -5345,29 +5368,39 @@ static const char *construct_prompt()
add_int_to_prompt(t->tm_year+1900);
break;
case 'D':
+ {
char* dateTime;
+ const char *tmp;
dateTime = ctime(&lclock);
- processed_prompt.append(strtok(dateTime,"\n"));
+ tmp= strtok(dateTime,"\n");
+ processed_prompt.append(tmp, strlen(tmp));
break;
+ }
case 's':
if (t->tm_sec < 10)
processed_prompt.append('0');
add_int_to_prompt(t->tm_sec);
break;
case 'w':
- processed_prompt.append(day_names[t->tm_wday]);
- break;
+ {
+ const char *name= day_names[t->tm_wday];
+ processed_prompt.append(name, strlen(name));
+ break;
+ }
case 'P':
- processed_prompt.append(t->tm_hour < 12 ? "am" : "pm");
+ processed_prompt.append(t->tm_hour < 12 ? "am" : "pm", 2);
break;
case 'o':
add_int_to_prompt(t->tm_mon+1);
break;
case 'O':
- processed_prompt.append(month_names[t->tm_mon]);
+ {
+ const char *name= month_names[t->tm_mon];
+ processed_prompt.append(name, strlen(name));
break;
+ }
case '\'':
- processed_prompt.append("'");
+ processed_prompt.append('\'');
break;
case '"':
processed_prompt.append('"');
@@ -5379,10 +5412,10 @@ static const char *construct_prompt()
processed_prompt.append('\t');
break;
case 'l':
- processed_prompt.append(delimiter_str);
+ processed_prompt.append(delimiter_str, strlen(delimiter_str));
break;
default:
- processed_prompt.append(c);
+ processed_prompt.append(*c);
}
}
}
@@ -5394,8 +5427,8 @@ static const char *construct_prompt()
static void add_int_to_prompt(int toadd)
{
char buffer[16];
- int10_to_str(toadd,buffer,10);
- processed_prompt.append(buffer);
+ size_t length= (size_t) (int10_to_str(toadd,buffer,10) - buffer);
+ processed_prompt.append(buffer, length);
}
static void init_username()
diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c
index 1dec667949f..f73ac7825b6 100644
--- a/extra/my_print_defaults.c
+++ b/extra/my_print_defaults.c
@@ -106,7 +106,7 @@ static void usage()
static my_bool
get_one_option(const struct my_option *opt __attribute__((unused)),
const char *argument __attribute__((unused)),
- const char *filename)
+ const char *filename __attribute__((unused)))
{
switch (opt->id) {
case 'c':
diff --git a/include/my_sys.h b/include/my_sys.h
index d887efda638..e381edfb9b5 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -1059,7 +1059,8 @@ extern void add_compiled_collation(struct charset_info_st *cs);
extern void add_compiled_extra_collation(struct charset_info_st *cs);
extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
char *to, size_t to_length,
- const char *from, size_t length);
+ const char *from, size_t length,
+ my_bool *overflow);
extern char *get_tty_password(const char *opt_message);
#ifdef _WIN32
#define BACKSLASH_MBTAIL
@@ -1069,7 +1070,8 @@ extern CHARSET_INFO *fs_character_set(void);
extern const char *my_default_csname(void);
extern size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info,
char *to, size_t to_length,
- const char *from, size_t length);
+ const char *from, size_t length,
+ my_bool *overflow);
extern void thd_increment_bytes_sent(void *thd, size_t length);
extern void thd_increment_bytes_received(void *thd, size_t length);
diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c
index e131a92b01e..dd723f0af10 100644
--- a/libmysqld/libmysql.c
+++ b/libmysqld/libmysql.c
@@ -1210,16 +1210,21 @@ mysql_hex_string(char *to, const char *from, ulong length)
ulong STDCALL
mysql_escape_string(char *to,const char *from,ulong length)
{
- return (uint) escape_string_for_mysql(default_charset_info, to, 0, from, length);
+ my_bool overflow;
+ return (uint) escape_string_for_mysql(default_charset_info, to, 0, from,
+ length, &overflow);
}
ulong STDCALL
mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
ulong length)
{
+ my_bool overflow;
if (mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)
- return (uint) escape_quotes_for_mysql(mysql->charset, to, 0, from, length);
- return (uint) escape_string_for_mysql(mysql->charset, to, 0, from, length);
+ return (ulong) escape_quotes_for_mysql(mysql->charset, to, 0, from, length,
+ &overflow);
+ return (ulong) escape_string_for_mysql(mysql->charset, to, 0, from, length,
+ &overflow);
}
void STDCALL
diff --git a/mysys/charset.c b/mysys/charset.c
index c786488d09f..403faf5626f 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -1080,6 +1080,8 @@ my_bool resolve_collation(const char *cl_name,
to_length Length of destination buffer, or 0
from The string to escape
length The length of the string to escape
+ overflow Set to 1 if the escaped string did not fit in
+ the to buffer
DESCRIPTION
This escapes the contents of a string by adding backslashes before special
@@ -1091,17 +1093,17 @@ my_bool resolve_collation(const char *cl_name,
"big enough"
RETURN VALUES
- (size_t) -1 The escaped string did not fit in the to buffer
# The length of the escaped string
*/
size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
char *to, size_t to_length,
- const char *from, size_t length)
+ const char *from, size_t length,
+ my_bool *overflow)
{
const char *to_start= to;
const char *end, *to_end=to_start + (to_length ? to_length-1 : 2*length);
- my_bool overflow= FALSE;
+ *overflow= FALSE;
for (end= from + length; from < end; from++)
{
char escape= 0;
@@ -1111,7 +1113,7 @@ size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
{
if (to + tmp_length > to_end)
{
- overflow= TRUE;
+ *overflow= TRUE;
break;
}
while (tmp_length--)
@@ -1161,7 +1163,7 @@ size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
{
if (to + 2 > to_end)
{
- overflow= TRUE;
+ *overflow= TRUE;
break;
}
*to++= '\\';
@@ -1171,14 +1173,14 @@ size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
{
if (to + 1 > to_end)
{
- overflow= TRUE;
+ *overflow= TRUE;
break;
}
*to++= *from;
}
}
*to= 0;
- return overflow ? (size_t) -1 : (size_t) (to - to_start);
+ return (size_t) (to - to_start);
}
@@ -1220,6 +1222,7 @@ CHARSET_INFO *fs_character_set()
to_length Length of destination buffer, or 0
from The string to escape
length The length of the string to escape
+ overflow Set to 1 if the buffer overflows
DESCRIPTION
This escapes the contents of a string by doubling up any apostrophes that
@@ -1231,20 +1234,20 @@ CHARSET_INFO *fs_character_set()
mean "big enough"
RETURN VALUES
- ~0 The escaped string did not fit in the to buffer
- >=0 The length of the escaped string
+ The length of the escaped string
*/
size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info,
char *to, size_t to_length,
- const char *from, size_t length)
+ const char *from, size_t length,
+ my_bool *overflow)
{
const char *to_start= to;
const char *end, *to_end=to_start + (to_length ? to_length-1 : 2*length);
- my_bool overflow= FALSE;
#ifdef USE_MB
my_bool use_mb_flag= my_ci_use_mb(charset_info);
#endif
+ *overflow= FALSE;
for (end= from + length; from < end; from++)
{
#ifdef USE_MB
@@ -1253,7 +1256,7 @@ size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info,
{
if (to + tmp_length > to_end)
{
- overflow= TRUE;
+ *overflow= TRUE;
break;
}
while (tmp_length--)
@@ -1271,7 +1274,7 @@ size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info,
{
if (to + 2 > to_end)
{
- overflow= TRUE;
+ *overflow= TRUE;
break;
}
*to++= '\'';
@@ -1281,14 +1284,14 @@ size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info,
{
if (to + 1 > to_end)
{
- overflow= TRUE;
+ *overflow= TRUE;
break;
}
*to++= *from;
}
}
*to= 0;
- return overflow ? (ulong)~0 : (ulong) (to - to_start);
+ return (size_t) (to - to_start);
}
diff --git a/plugin/feedback/sender_thread.cc b/plugin/feedback/sender_thread.cc
index 73b1bc67e79..1aac71b132a 100644
--- a/plugin/feedback/sender_thread.cc
+++ b/plugin/feedback/sender_thread.cc
@@ -183,15 +183,15 @@ static void send_report(const char *when)
str.length(0);
str.append(STRING_WITH_LEN("FEEDBACK_SERVER_UID"));
str.append('\t');
- str.append(server_uid_buf);
+ str.append(server_uid_buf, sizeof(server_uid_buf)-1);
str.append('\n');
str.append(STRING_WITH_LEN("FEEDBACK_WHEN"));
str.append('\t');
- str.append(when);
+ str.append(when, strlen(when));
str.append('\n');
str.append(STRING_WITH_LEN("FEEDBACK_USER_INFO"));
str.append('\t');
- str.append(user_info);
+ str.append(user_info, strlen(user_info));
str.append('\n');
str.append('\n');
}
diff --git a/plugin/func_test/plugin.cc b/plugin/func_test/plugin.cc
index 5e1f1a66fa2..b49f87832d6 100644
--- a/plugin/func_test/plugin.cc
+++ b/plugin/func_test/plugin.cc
@@ -35,7 +35,11 @@ public:
set_maybe_null();
return false;
}
- const char *func_name() const { return "sysconst_test"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sysconst_test") };
+ return name;
+ }
const char *fully_qualified_func_name() const { return "sysconst_test()"; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_sysconst_test>(thd, this); }
diff --git a/plugin/type_inet/item_inetfunc.h b/plugin/type_inet/item_inetfunc.h
index f74eadb717c..5568bf55bdf 100644
--- a/plugin/type_inet/item_inetfunc.h
+++ b/plugin/type_inet/item_inetfunc.h
@@ -32,7 +32,11 @@ class Item_func_inet_aton : public Item_longlong_func
public:
Item_func_inet_aton(THD *thd, Item *a): Item_longlong_func(thd, a) {}
longlong val_int();
- const char *func_name() const { return "inet_aton"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("inet_aton") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals= 0;
@@ -56,7 +60,11 @@ public:
Item_func_inet_ntoa(THD *thd, Item *a): Item_str_func(thd, a)
{ }
String* val_str(String* str);
- const char *func_name() const { return "inet_ntoa"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("inet_ntoa") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals= 0;
@@ -98,9 +106,11 @@ public:
{ }
public:
- virtual const char *func_name() const
- { return "inet6_aton"; }
-
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("inet6_aton") };
+ return name;
+ }
virtual bool fix_length_and_dec()
{
decimals= 0;
@@ -127,8 +137,11 @@ public:
{ }
public:
- virtual const char *func_name() const
- { return "inet6_ntoa"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("inet6_ntoa") };
+ return name;
+ }
virtual bool fix_length_and_dec()
{
@@ -160,8 +173,11 @@ public:
{ }
public:
- virtual const char *func_name() const
- { return "is_ipv4"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("is_ipv4") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_is_ipv4>(thd, this); }
@@ -180,8 +196,11 @@ public:
Item_func_inet_bool_base(thd, ip_addr)
{ }
- virtual const char *func_name() const
- { return "is_ipv6"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("is_ipv6") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_is_ipv6>(thd, this); }
@@ -199,8 +218,11 @@ public:
inline Item_func_is_ipv4_compat(THD *thd, Item *ip_addr):
Item_func_inet_bool_base(thd, ip_addr)
{ }
- virtual const char *func_name() const
- { return "is_ipv4_compat"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("is_ipv4_compat") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_is_ipv4_compat>(thd, this); }
longlong val_int();
@@ -217,8 +239,11 @@ public:
inline Item_func_is_ipv4_mapped(THD *thd, Item *ip_addr):
Item_func_inet_bool_base(thd, ip_addr)
{ }
- virtual const char *func_name() const
- { return "is_ipv4_mapped"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("is_ipv4_mapped") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_is_ipv4_mapped>(thd, this); }
longlong val_int();
diff --git a/plugin/type_inet/sql_type_inet.cc b/plugin/type_inet/sql_type_inet.cc
index a3e7a4d6ca1..822502053e0 100644
--- a/plugin/type_inet/sql_type_inet.cc
+++ b/plugin/type_inet/sql_type_inet.cc
@@ -1044,7 +1044,11 @@ public:
Item_typecast_inet6 *cast= (Item_typecast_inet6*) item;
return args[0]->eq(cast->args[0], binary_cmp);
}
- const char *func_name() const override { return "cast_as_inet6"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_inet6") };
+ return name;
+ }
void print(String *str, enum_query_type query_type) override
{
str->append(STRING_WITH_LEN("cast("));
@@ -1212,7 +1216,7 @@ public:
{
StringBufferInet6 tmp;
m_value.to_string(&tmp);
- str->append("INET6'");
+ str->append(STRING_WITH_LEN("INET6'"));
str->append(tmp);
str->append('\'');
}
diff --git a/plugin/type_inet/sql_type_inet.h b/plugin/type_inet/sql_type_inet.h
index a00b2d35f18..23fb18ec41f 100644
--- a/plugin/type_inet/sql_type_inet.h
+++ b/plugin/type_inet/sql_type_inet.h
@@ -714,7 +714,7 @@ public:
return !na.is_null() && !nb.is_null() && !na.cmp(nb);
}
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *h,
Type_all_attributes *attr,
Item **items,
@@ -747,7 +747,7 @@ public:
Item **items,
uint nitems) const override
{
- return Item_hybrid_func_fix_attributes(thd, func->func_name(),
+ return Item_hybrid_func_fix_attributes(thd, func->func_name_cstring(),
func, func, items, nitems);
}
diff --git a/plugin/type_mysql_json/mysql_json.cc b/plugin/type_mysql_json/mysql_json.cc
index 4a75cae3909..c28a403a603 100644
--- a/plugin/type_mysql_json/mysql_json.cc
+++ b/plugin/type_mysql_json/mysql_json.cc
@@ -16,8 +16,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-#include "mysql_json.h"
#include "my_global.h"
+#include "mysql_json.h"
#include "compat56.h"
#include "my_decimal.h"
#include "sql_time.h"
@@ -169,25 +169,25 @@ static bool append_string_json(String *buffer, const uchar *data, size_t len)
const uchar c= *data;
switch (c) {
case '\\':
- buffer->append("\\\\");
+ buffer->append(STRING_WITH_LEN("\\\\"));
break;
case '\n':
- buffer->append("\\n");
+ buffer->append(STRING_WITH_LEN("\\n"));
break;
case '\r':
- buffer->append("\\r");
+ buffer->append(STRING_WITH_LEN("\\r"));
break;
case '"':
- buffer->append("\\\"");
+ buffer->append(STRING_WITH_LEN("\\\""));
break;
case '\b':
- buffer->append("\\b");
+ buffer->append(STRING_WITH_LEN("\\b"));
break;
case '\f':
- buffer->append("\\f");
+ buffer->append(STRING_WITH_LEN("\\f"));
break;
case '\t':
- buffer->append("\\t");
+ buffer->append(STRING_WITH_LEN("\\t"));
break;
default:
buffer->append(c);
@@ -242,11 +242,11 @@ static bool parse_mysql_scalar(String *buffer, size_t value_json_type,
return true;
switch (static_cast<JSONB_LITERAL_TYPES>(*data)) {
case JSONB_NULL_LITERAL:
- return buffer->append("null");
+ return buffer->append(STRING_WITH_LEN("null"));
case JSONB_TRUE_LITERAL:
- return buffer->append("true");
+ return buffer->append(STRING_WITH_LEN("true"));
case JSONB_FALSE_LITERAL:
- return buffer->append("false");
+ return buffer->append(STRING_WITH_LEN("false"));
default: /* Invalid literal constant, malformed JSON. */
return true;
}
@@ -326,7 +326,7 @@ static bool parse_mysql_scalar(String *buffer, size_t value_json_type,
default:
{
/* Any other MySQL type is presented as a base64 encoded string. */
- if (buffer->append("\"base64:type") ||
+ if (buffer->append(STRING_WITH_LEN("\"base64:type")) ||
buffer->append_longlong(field_type) ||
buffer->append(':'))
return true;
@@ -455,7 +455,7 @@ static bool parse_array_or_object(String *buffer, const uchar *data, size_t len,
/* First print the key. */
if (buffer->append('"') ||
append_string_json(buffer, data + key_start, key_len) ||
- buffer->append("\": "))
+ buffer->append(STRING_WITH_LEN("\": ")))
{
return true;
}
@@ -478,7 +478,7 @@ static bool parse_array_or_object(String *buffer, const uchar *data, size_t len,
return true;
}
- if (i != element_count - 1 && buffer->append(", "))
+ if (i != element_count - 1 && buffer->append(STRING_WITH_LEN(", ")))
return true;
}
diff --git a/sql/create_options.cc b/sql/create_options.cc
index 60e9b733efc..5437de0f0c3 100644
--- a/sql/create_options.cc
+++ b/sql/create_options.cc
@@ -402,7 +402,7 @@ static bool resolve_sysvars(handlerton *hton, ha_create_table_option *rules)
str.length(0);
for (const char **s= optp.typelib->type_names; *s; s++)
{
- if (str.append(*s) || str.append(','))
+ if (str.append(*s, strlen(*s)) || str.append(','))
return 1;
}
DBUG_ASSERT(str.length());
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 8acfea7417d..247df87235d 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -293,7 +293,7 @@ Event_basic::load_string_fields(Field **fields, ...)
bool
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, strlen(tz_name->str), &my_charset_latin1);
time_zone= my_tz_find(thd, &str);
return (time_zone == NULL);
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index 78802a5e109..d9647e3e34f 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -89,11 +89,11 @@ Event_worker_thread::print_warnings(THD *thd, Event_job_data *et)
prefix.append(STRING_WITH_LEN("Event Scheduler: ["));
prefix.append(et->definer.str, et->definer.length, system_charset_info);
- prefix.append("][", 2);
+ prefix.append(STRING_WITH_LEN("]["));
prefix.append(et->dbname.str, et->dbname.length, system_charset_info);
prefix.append('.');
prefix.append(et->name.str, et->name.length, system_charset_info);
- prefix.append("] ", 2);
+ prefix.append(STRING_WITH_LEN("] "));
Diagnostics_area::Sql_condition_iterator it=
thd->get_stmt_da()->sql_conditions();
diff --git a/sql/field.cc b/sql/field.cc
index 82e9966af51..5958fab57b8 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -11361,7 +11361,7 @@ Field::print_key_part_value(String *out, const uchar* key, uint32 length)
*/
if (*key)
{
- out->append(STRING_WITH_LEN("NULL"));
+ out->append(NULL_clex_str);
return;
}
null_byte++; // Skip null byte
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 47d63fe4645..f7e303be6d3 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -385,7 +385,7 @@ void Field_enum::do_field_enum(Copy_field *copy)
static void do_field_varbinary_pre50(Copy_field *copy)
{
char buff[MAX_FIELD_WIDTH];
- copy->tmp.set_quick(buff,sizeof(buff),copy->tmp.charset());
+ copy->tmp.set_buffer_if_not_allocated(buff,sizeof(buff),copy->tmp.charset());
copy->from_field->val_str(&copy->tmp);
/* Use the same function as in 4.1 to trim trailing spaces */
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 16ecb542ea1..3afd30cae30 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -668,24 +668,25 @@ const char* dbug_print_table_row(TABLE *table)
output.length(0);
output.append(table->alias);
- output.append("(");
+ output.append('(');
bool first= true;
for (pfield= table->field; *pfield ; pfield++)
{
+ const LEX_CSTRING *name;
if (table->read_set && !bitmap_is_set(table->read_set, (*pfield)->field_index))
continue;
if (first)
first= false;
else
- output.append(",");
+ output.append(',');
- output.append((*pfield)->field_name.str ?
- (*pfield)->field_name.str: "NULL");
+ name= (*pfield)->field_name.str ? &(*pfield)->field_name: &NULL_clex_str;
+ output.append(name);
}
- output.append(")=(");
+ output.append(STRING_WITH_LEN(")=("));
first= true;
for (pfield= table->field; *pfield ; pfield++)
@@ -698,10 +699,10 @@ const char* dbug_print_table_row(TABLE *table)
if (first)
first= false;
else
- output.append(",");
+ output.append(',');
if (field->is_null())
- output.append("NULL");
+ output.append(&NULL_clex_str);
else
{
if (field->type() == MYSQL_TYPE_BIT)
@@ -711,7 +712,7 @@ const char* dbug_print_table_row(TABLE *table)
output.append(tmp.ptr(), tmp.length());
}
}
- output.append(")");
+ output.append(')');
return output.c_ptr_safe();
}
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 91047d05fc8..b50813cdc94 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -1183,9 +1183,22 @@ int ha_partition::rename_partitions(const char *path)
#define ASSIGN_KEYCACHE_PARTS 5
#define PRELOAD_KEYS_PARTS 6
-static const char *opt_op_name[]= {NULL,
- "optimize", "analyze", "check", "repair",
- "assign_to_keycache", "preload_keys"};
+static const LEX_CSTRING opt_op_name[]=
+{
+ { NULL, 0},
+ { STRING_WITH_LEN("optimize") },
+ { STRING_WITH_LEN("analyze") },
+ { STRING_WITH_LEN("check") },
+ { STRING_WITH_LEN("repair") },
+ { STRING_WITH_LEN("assign_to_keycache") },
+ { STRING_WITH_LEN("preload_keys") }
+};
+
+
+static const LEX_CSTRING msg_note= { STRING_WITH_LEN("note") };
+static const LEX_CSTRING msg_warning= { STRING_WITH_LEN("warning") };
+#define msg_error error_clex_str
+
/*
Optimize table
@@ -1389,14 +1402,14 @@ int ha_partition::handle_opt_part(THD *thd, HA_CHECK_OPT *check_opt,
TODO: move this into the handler, or rewrite mysql_admin_table.
*/
bool print_admin_msg(THD* thd, uint len,
- const char* msg_type,
- const char* db_name, String &table_name,
- const char* op_name, const char *fmt, ...)
+ const LEX_CSTRING *msg_type,
+ const char* db_name, String &table_name,
+ const LEX_CSTRING *op_name, const char *fmt, ...)
ATTRIBUTE_FORMAT(printf, 7, 8);
bool print_admin_msg(THD* thd, uint len,
- const char* msg_type,
- const char* db_name, String &table_name,
- const char* op_name, const char *fmt, ...)
+ const LEX_CSTRING *msg_type,
+ const char* db_name, String &table_name,
+ const LEX_CSTRING *op_name, const char *fmt, ...)
{
va_list args;
Protocol *protocol= thd->protocol;
@@ -1504,9 +1517,9 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
error != HA_ADMIN_ALREADY_DONE &&
error != HA_ADMIN_TRY_ALTER)
{
- print_admin_msg(thd, MYSQL_ERRMSG_SIZE, "error",
+ print_admin_msg(thd, MYSQL_ERRMSG_SIZE, &msg_error,
table_share->db.str, table->alias,
- opt_op_name[flag],
+ &opt_op_name[flag],
"Subpartition %s returned error",
sub_elem->partition_name);
}
@@ -1531,9 +1544,9 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
error != HA_ADMIN_ALREADY_DONE &&
error != HA_ADMIN_TRY_ALTER)
{
- print_admin_msg(thd, MYSQL_ERRMSG_SIZE, "error",
+ print_admin_msg(thd, MYSQL_ERRMSG_SIZE, &msg_error,
table_share->db.str, table->alias,
- opt_op_name[flag], "Partition %s returned error",
+ &opt_op_name[flag], "Partition %s returned error",
part_elem->partition_name);
}
/* reset part_state for the remaining partitions */
@@ -9947,9 +9960,9 @@ void ha_partition::append_row_to_str(String &str)
for (; key_part != key_part_end; key_part++)
{
Field *field= key_part->field;
- str.append(" ");
+ str.append(' ');
str.append(&field->field_name);
- str.append(":");
+ str.append(':');
field_unpack(&str, field, rec, 0, false);
}
if (!is_rec0)
@@ -9967,9 +9980,9 @@ void ha_partition::append_row_to_str(String &str)
field_ptr++)
{
Field *field= *field_ptr;
- str.append(" ");
+ str.append(' ');
str.append(&field->field_name);
- str.append(":");
+ str.append(':');
field_unpack(&str, field, rec, 0, false);
}
if (!is_rec0)
@@ -10007,14 +10020,14 @@ void ha_partition::print_error(int error, myf errflag)
String str(buf,sizeof(buf),system_charset_info);
uint32 part_id;
str.length(0);
- str.append("(");
+ str.append('(');
str.append_ulonglong(m_last_part);
- str.append(" != ");
+ str.append(STRING_WITH_LEN(" != "));
if (get_part_for_buf(m_err_rec, m_rec0, m_part_info, &part_id))
- str.append("?");
+ str.append('?');
else
str.append_ulonglong(part_id);
- str.append(")");
+ str.append(')');
append_row_to_str(str);
/* Log this error, so the DBA can notice it and fix it! */
@@ -10967,9 +10980,9 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
read_part_id != m_part_info->vers_info->now_part->id &&
!m_part_info->vers_info->interval.is_set())
{
- print_admin_msg(ha_thd(), MYSQL_ERRMSG_SIZE, "note",
+ print_admin_msg(ha_thd(), MYSQL_ERRMSG_SIZE, &msg_note,
table_share->db.str, table->alias,
- opt_op_name[CHECK_PARTS],
+ &opt_op_name[CHECK_PARTS],
"Not supported for non-INTERVAL history partitions");
DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
}
@@ -10998,9 +11011,9 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
if (num_misplaced_rows > 0)
{
- print_admin_msg(ha_thd(), MYSQL_ERRMSG_SIZE, "warning",
+ print_admin_msg(ha_thd(), MYSQL_ERRMSG_SIZE, &msg_warning,
table_share->db.str, table->alias,
- opt_op_name[REPAIR_PARTS],
+ &opt_op_name[REPAIR_PARTS],
"Moved %lld misplaced rows",
num_misplaced_rows);
}
@@ -11020,9 +11033,9 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
if (!do_repair)
{
/* Check. */
- print_admin_msg(ha_thd(), MYSQL_ERRMSG_SIZE, "error",
+ print_admin_msg(ha_thd(), MYSQL_ERRMSG_SIZE, &msg_error,
table_share->db.str, table->alias,
- opt_op_name[CHECK_PARTS],
+ &opt_op_name[CHECK_PARTS],
"Found a misplaced row");
/* Break on first misplaced row! */
result= HA_ADMIN_NEEDS_UPGRADE;
@@ -11047,8 +11060,9 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
str.length(0);
if (result == HA_ERR_FOUND_DUPP_KEY)
{
- str.append("Duplicate key found, "
- "please update or delete the record:\n");
+ str.append(STRING_WITH_LEN("Duplicate key found, "
+ "please update or delete the "
+ "record:\n"));
result= HA_ADMIN_CORRUPT;
}
m_err_rec= NULL;
@@ -11068,9 +11082,9 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
(uint) correct_part_id,
str.c_ptr_safe());
}
- print_admin_msg(ha_thd(), MYSQL_ERRMSG_SIZE, "error",
+ print_admin_msg(ha_thd(), MYSQL_ERRMSG_SIZE, &msg_error,
table_share->db.str, table->alias,
- opt_op_name[REPAIR_PARTS],
+ &opt_op_name[REPAIR_PARTS],
"Failed to move/insert a row"
" from part %u into part %u:\n%s",
(uint) read_part_id,
@@ -11195,19 +11209,19 @@ int ha_partition::check_for_upgrade(HA_CHECK_OPT *check_opt)
!(part_buf= generate_partition_syntax_for_frm(thd, m_part_info,
&part_buf_len,
NULL, NULL)) ||
- print_admin_msg(thd, SQL_ADMIN_MSG_TEXT_SIZE + 1, "error",
+ print_admin_msg(thd, SQL_ADMIN_MSG_TEXT_SIZE + 1, &msg_error,
table_share->db.str,
table->alias,
- opt_op_name[CHECK_PARTS],
+ &opt_op_name[CHECK_PARTS],
KEY_PARTITIONING_CHANGED_STR,
db_name.c_ptr_safe(),
table_name.c_ptr_safe(),
part_buf))
{
/* Error creating admin message (too long string?). */
- print_admin_msg(thd, MYSQL_ERRMSG_SIZE, "error",
+ print_admin_msg(thd, MYSQL_ERRMSG_SIZE, &msg_error,
table_share->db.str, table->alias,
- opt_op_name[CHECK_PARTS],
+ &opt_op_name[CHECK_PARTS],
KEY_PARTITIONING_CHANGED_STR,
db_name.c_ptr_safe(), table_name.c_ptr_safe(),
"<old partition clause>, but add ALGORITHM = 1"
diff --git a/sql/handler.cc b/sql/handler.cc
index 6fd0175a09b..e36fbcccd76 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -136,11 +136,18 @@ static const LEX_CSTRING sys_table_aliases[]=
{NullS, 0}
};
-const char *ha_row_type[] = {
- "", "FIXED", "DYNAMIC", "COMPRESSED", "REDUNDANT", "COMPACT", "PAGE"
+const LEX_CSTRING ha_row_type[]=
+{
+ { STRING_WITH_LEN("") },
+ { STRING_WITH_LEN("FIXED") },
+ { STRING_WITH_LEN("DYNAMIC") },
+ { STRING_WITH_LEN("COMPRESSED") },
+ { STRING_WITH_LEN("REDUNDANT") },
+ { STRING_WITH_LEN("COMPACT") },
+ { STRING_WITH_LEN("PAGE") }
};
-const char *tx_isolation_names[] =
+const char *tx_isolation_names[]=
{ "READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ", "SERIALIZABLE",
NullS};
TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"",
@@ -4117,7 +4124,9 @@ void handler::print_error(int error, myf errflag)
break;
case HA_ERR_LOCK_DEADLOCK:
{
- String str, full_err_msg(ER_DEFAULT(ER_LOCK_DEADLOCK), system_charset_info);
+ String str, full_err_msg(ER_DEFAULT(ER_LOCK_DEADLOCK),
+ strlen(ER_DEFAULT(ER_LOCK_DEADLOCK)),
+ system_charset_info);
get_error_message(error, &str);
full_err_msg.append(str);
diff --git a/sql/handler.h b/sql/handler.h
index ef643c53df4..f43f91de18c 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -5114,7 +5114,7 @@ bool key_uses_partial_cols(TABLE_SHARE *table, uint keyno);
/* Some extern variables used with handlers */
-extern const char *ha_row_type[];
+extern const LEX_CSTRING ha_row_type[];
extern MYSQL_PLUGIN_IMPORT const char *tx_isolation_names[];
extern MYSQL_PLUGIN_IMPORT const char *binlog_format_names[];
extern TYPELIB tx_isolation_typelib;
diff --git a/sql/item.cc b/sql/item.cc
index fe5b45f31a9..5afad7eef14 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -501,7 +501,8 @@ void Item::print_parenthesised(String *str, enum_query_type query_type,
void Item::print(String *str, enum_query_type query_type)
{
- str->append(full_name());
+ const char *name= full_name();
+ str->append(name, strlen(name));
}
@@ -525,7 +526,7 @@ void Item::print_value(String *str)
String *ptr, tmp(buff,sizeof(buff),str->charset());
ptr= val_str(&tmp);
if (!ptr)
- str->append("NULL");
+ str->append(NULL_clex_str);
else
{
switch (cmp_type()) {
@@ -993,7 +994,7 @@ bool Item::check_cols(uint c)
}
-bool Item::check_type_or_binary(const char *opname,
+bool Item::check_type_or_binary(const LEX_CSTRING &opname,
const Type_handler *expect) const
{
const Type_handler *handler= type_handler();
@@ -1002,111 +1003,111 @@ bool Item::check_type_or_binary(const char *opname,
collation.collation == &my_charset_bin))
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Item::check_type_general_purpose_string(const char *opname) const
+bool Item::check_type_general_purpose_string(const LEX_CSTRING &opname) const
{
const Type_handler *handler= type_handler();
if (handler->is_general_purpose_string_type())
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Item::check_type_traditional_scalar(const char *opname) const
+bool Item::check_type_traditional_scalar(const LEX_CSTRING &opname) const
{
const Type_handler *handler= type_handler();
if (handler->is_traditional_scalar_type())
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Item::check_type_can_return_int(const char *opname) const
+bool Item::check_type_can_return_int(const LEX_CSTRING &opname) const
{
const Type_handler *handler= type_handler();
if (handler->can_return_int())
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Item::check_type_can_return_decimal(const char *opname) const
+bool Item::check_type_can_return_decimal(const LEX_CSTRING &opname) const
{
const Type_handler *handler= type_handler();
if (handler->can_return_decimal())
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Item::check_type_can_return_real(const char *opname) const
+bool Item::check_type_can_return_real(const LEX_CSTRING &opname) const
{
const Type_handler *handler= type_handler();
if (handler->can_return_real())
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Item::check_type_can_return_date(const char *opname) const
+bool Item::check_type_can_return_date(const LEX_CSTRING &opname) const
{
const Type_handler *handler= type_handler();
if (handler->can_return_date())
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Item::check_type_can_return_time(const char *opname) const
+bool Item::check_type_can_return_time(const LEX_CSTRING &opname) const
{
const Type_handler *handler= type_handler();
if (handler->can_return_time())
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Item::check_type_can_return_str(const char *opname) const
+bool Item::check_type_can_return_str(const LEX_CSTRING &opname) const
{
const Type_handler *handler= type_handler();
if (handler->can_return_str())
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Item::check_type_can_return_text(const char *opname) const
+bool Item::check_type_can_return_text(const LEX_CSTRING &opname) const
{
const Type_handler *handler= type_handler();
if (handler->can_return_text())
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Item::check_type_scalar(const char *opname) const
+bool Item::check_type_scalar(const LEX_CSTRING &opname) const
{
/*
fixed==true usually means than the Item has an initialized
@@ -2509,7 +2510,8 @@ void my_coll_agg_error(Item** args, uint count, const char *fname,
}
-bool Type_std_attributes::agg_item_collations(DTCollation &c, const char *fname,
+bool Type_std_attributes::agg_item_collations(DTCollation &c,
+ const LEX_CSTRING &fname,
Item **av, uint count,
uint flags, int item_sep)
{
@@ -2528,7 +2530,7 @@ bool Type_std_attributes::agg_item_collations(DTCollation &c, const char *fname,
unknown_cs= 1;
continue;
}
- my_coll_agg_error(av, count, fname, item_sep);
+ my_coll_agg_error(av, count, fname.str, item_sep);
return TRUE;
}
}
@@ -2536,14 +2538,14 @@ bool Type_std_attributes::agg_item_collations(DTCollation &c, const char *fname,
if (unknown_cs &&
c.derivation != DERIVATION_EXPLICIT)
{
- my_coll_agg_error(av, count, fname, item_sep);
+ my_coll_agg_error(av, count, fname.str, item_sep);
return TRUE;
}
if ((flags & MY_COLL_DISALLOW_NONE) &&
c.derivation == DERIVATION_NONE)
{
- my_coll_agg_error(av, count, fname, item_sep);
+ my_coll_agg_error(av, count, fname.str, item_sep);
return TRUE;
}
@@ -2557,7 +2559,7 @@ bool Type_std_attributes::agg_item_collations(DTCollation &c, const char *fname,
bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll,
- const char *fname,
+ const LEX_CSTRING &fname,
Item **args, uint nargs,
uint flags, int item_sep)
{
@@ -2598,7 +2600,7 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll,
args[0]= safe_args[0];
args[item_sep]= safe_args[1];
}
- my_coll_agg_error(args, nargs, fname, item_sep);
+ my_coll_agg_error(args, nargs, fname.str, item_sep);
res= TRUE;
break; // we cannot return here, we need to restore "arena".
}
@@ -2685,8 +2687,7 @@ Item_sp::Item_sp(THD *thd, Item_sp *item):
memset(&sp_mem_root, 0, sizeof(sp_mem_root));
}
-const char *
-Item_sp::func_name(THD *thd) const
+LEX_CSTRING Item_sp::func_name_cstring(THD *thd) const
{
/* Calculate length to avoid reallocation of string for sure */
size_t len= (((m_name->m_explicit_name ? m_name->m_db.length : 0) +
@@ -2706,7 +2707,7 @@ Item_sp::func_name(THD *thd) const
qname.append('.');
}
append_identifier(thd, &qname, &m_name->m_name);
- return qname.c_ptr_safe();
+ return { qname.c_ptr_safe(), qname.length() };
}
void
@@ -3794,7 +3795,8 @@ void Item_string::print(String *str, enum_query_type query_type)
if (print_introducer)
{
str->append('_');
- str->append(collation.collation->csname);
+ str->append(collation.collation->csname,
+ strlen(collation.collation->csname));
}
str->append('\'');
@@ -4753,11 +4755,11 @@ void Item_param::print(String *str, enum_query_type query_type)
}
else if (state == DEFAULT_VALUE)
{
- str->append("default");
+ str->append(STRING_WITH_LEN("default"));
}
else if (state == IGNORE_VALUE)
{
- str->append("ignore");
+ str->append(STRING_WITH_LEN("ignore"));
}
else
{
@@ -6642,11 +6644,11 @@ int Item::save_str_in_field(Field *field, bool no_conversions)
String *result;
CHARSET_INFO *cs= collation.collation;
char buff[MAX_FIELD_WIDTH]; // Alloc buffer for small columns
- str_value.set_quick(buff, sizeof(buff), cs);
+ str_value.set_buffer_if_not_allocated(buff, sizeof(buff), cs);
result=val_str(&str_value);
if (null_value)
{
- str_value.set_quick(0, 0, cs);
+ str_value.set_buffer_if_not_allocated(0, 0, cs);
return set_field_to_null_with_conversions(field, no_conversions);
}
@@ -6654,7 +6656,7 @@ int Item::save_str_in_field(Field *field, bool no_conversions)
field->set_notnull();
int error= field->store(result->ptr(),result->length(),cs);
- str_value.set_quick(0, 0, cs);
+ str_value.set_buffer_if_not_allocated(0, 0, cs);
return error;
}
@@ -6972,7 +6974,7 @@ void Item_float::print(String *str, enum_query_type query_type)
{
if (presentation)
{
- str->append(presentation);
+ str->append(presentation, strlen(presentation));
return;
}
char buffer[20];
@@ -7018,7 +7020,7 @@ void Item_hex_hybrid::print(String *str, enum_query_type query_type)
{
uint32 len= MY_MIN(str_value.length(), sizeof(longlong));
const char *ptr= str_value.ptr() + str_value.length() - len;
- str->append("0x");
+ str->append("0x",2);
str->append_hex(ptr, len);
}
@@ -7041,9 +7043,9 @@ decimal_digits_t Item_hex_hybrid::decimal_precision() const
void Item_hex_string::print(String *str, enum_query_type query_type)
{
- str->append("X'");
+ str->append("X'",2);
str->append_hex(str_value.ptr(), str_value.length());
- str->append("'");
+ str->append('\'');
}
@@ -7093,10 +7095,10 @@ Item_bin_string::Item_bin_string(THD *thd, const char *str, size_t str_length):
void Item_date_literal::print(String *str, enum_query_type query_type)
{
- str->append("DATE'");
+ str->append(STRING_WITH_LEN("DATE'"));
char buf[MAX_DATE_STRING_REP_LENGTH];
- my_date_to_str(cached_time.get_mysql_time(), buf);
- str->append(buf);
+ int length= my_date_to_str(cached_time.get_mysql_time(), buf);
+ str->append(buf, length);
str->append('\'');
}
@@ -7118,10 +7120,10 @@ bool Item_date_literal::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzyd
void Item_datetime_literal::print(String *str, enum_query_type query_type)
{
- str->append("TIMESTAMP'");
+ str->append(STRING_WITH_LEN("TIMESTAMP'"));
char buf[MAX_DATE_STRING_REP_LENGTH];
- my_datetime_to_str(cached_time.get_mysql_time(), buf, decimals);
- str->append(buf);
+ int length= my_datetime_to_str(cached_time.get_mysql_time(), buf, decimals);
+ str->append(buf, length);
str->append('\'');
}
@@ -7143,10 +7145,10 @@ bool Item_datetime_literal::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fu
void Item_time_literal::print(String *str, enum_query_type query_type)
{
- str->append("TIME'");
+ str->append(STRING_WITH_LEN("TIME'"));
char buf[MAX_DATE_STRING_REP_LENGTH];
- my_time_to_str(cached_time.get_mysql_time(), buf, decimals);
- str->append(buf);
+ int length= my_time_to_str(cached_time.get_mysql_time(), buf, decimals);
+ str->append(buf, length);
str->append('\'');
}
@@ -8590,7 +8592,7 @@ void Item_cache_wrapper::print(String *str, enum_query_type query_type)
return;
}
- str->append("<expr_cache>");
+ str->append(STRING_WITH_LEN("<expr_cache>"));
if (expr_cache)
{
init_on_demand();
diff --git a/sql/item.h b/sql/item.h
index 092fd6afcee..bf49546b60f 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1886,7 +1886,6 @@ public:
LOWEST_PRECEDENCE);
}
virtual void print(String *str, enum_query_type query_type);
-
class Print: public String
{
public:
@@ -2358,17 +2357,18 @@ public:
virtual Item* element_index(uint i) { return this; }
virtual Item** addr(uint i) { return 0; }
virtual bool check_cols(uint c);
- bool check_type_traditional_scalar(const char *opname) const;
- bool check_type_scalar(const char *opname) const;
- bool check_type_or_binary(const char *opname, const Type_handler *handler) const;
- bool check_type_general_purpose_string(const char *opname) const;
- bool check_type_can_return_int(const char *opname) const;
- bool check_type_can_return_decimal(const char *opname) const;
- bool check_type_can_return_real(const char *opname) const;
- bool check_type_can_return_str(const char *opname) const;
- bool check_type_can_return_text(const char *opname) const;
- bool check_type_can_return_date(const char *opname) const;
- bool check_type_can_return_time(const char *opname) const;
+ bool check_type_traditional_scalar(const LEX_CSTRING &opname) const;
+ bool check_type_scalar(const LEX_CSTRING &opname) const;
+ bool check_type_or_binary(const LEX_CSTRING &opname,
+ const Type_handler *handler) const;
+ bool check_type_general_purpose_string(const LEX_CSTRING &opname) const;
+ bool check_type_can_return_int(const LEX_CSTRING &opname) const;
+ bool check_type_can_return_decimal(const LEX_CSTRING &opname) const;
+ bool check_type_can_return_real(const LEX_CSTRING &opname) const;
+ bool check_type_can_return_str(const LEX_CSTRING &opname) const;
+ bool check_type_can_return_text(const LEX_CSTRING &opname) const;
+ bool check_type_can_return_date(const LEX_CSTRING &opname) const;
+ bool check_type_can_return_time(const LEX_CSTRING &opname) const;
// It is not row => null inside is impossible
virtual bool null_inside() { return 0; }
// used in row subselects to get value of elements
@@ -2650,7 +2650,8 @@ public:
DbugStringItemTypeValue(THD *thd, const Item *item)
{
append('(');
- append(item->type_handler()->name().ptr());
+ Name Item_name= item->type_handler()->name();
+ append(Item_name.ptr(), Item_name.length());
append(')');
const_cast<Item*>(item)->print(this, QT_EXPLAIN);
/* Append end \0 to allow usage of c_ptr() */
@@ -3808,7 +3809,7 @@ public:
void print(String *str, enum_query_type) override
{
- str->append(STRING_WITH_LEN("NULL"));
+ str->append(NULL_clex_str);
}
Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) override;
@@ -4515,7 +4516,7 @@ public:
void print(String *str, enum_query_type) override
{
- str->append(func_name);
+ str->append(func_name, strlen(func_name));
}
Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) override
@@ -5299,7 +5300,7 @@ protected:
bool agg_arg_charsets(DTCollation &c, Item **items, uint nitems,
uint flags, int item_sep)
{
- return Type_std_attributes::agg_arg_charsets(c, func_name(),
+ return Type_std_attributes::agg_arg_charsets(c, func_name_cstring(),
items, nitems,
flags, item_sep);
}
@@ -5308,7 +5309,7 @@ protected:
int item_sep= 1)
{
return Type_std_attributes::
- agg_arg_charsets_for_string_result(c, func_name(),
+ agg_arg_charsets_for_string_result(c, func_name_cstring(),
items, nitems, item_sep);
}
bool agg_arg_charsets_for_string_result_with_comparison(DTCollation &c,
@@ -5317,7 +5318,7 @@ protected:
int item_sep= 1)
{
return Type_std_attributes::
- agg_arg_charsets_for_string_result_with_comparison(c, func_name(),
+ agg_arg_charsets_for_string_result_with_comparison(c, func_name_cstring(),
items, nitems,
item_sep);
}
@@ -5332,7 +5333,7 @@ protected:
int item_sep= 1)
{
return Type_std_attributes::
- agg_arg_charsets_for_comparison(c, func_name(), items, nitems, item_sep);
+ agg_arg_charsets_for_comparison(c, func_name_cstring(), items, nitems, item_sep);
}
public:
@@ -5351,9 +5352,9 @@ public:
func_name());
return true;
}
- if (agg_item_set_converter(tmp, func_name(),
+ if (agg_item_set_converter(tmp, func_name_cstring(),
a, 1, MY_COLL_CMP_CONV, 1) ||
- agg_item_set_converter(tmp, func_name(),
+ agg_item_set_converter(tmp, func_name_cstring(),
b, 1, MY_COLL_CMP_CONV, 1))
return true;
*cs= tmp.collation;
@@ -5393,12 +5394,15 @@ public:
instead.
Added here, to the parent class of both Item_func and Item_sum.
- NOTE: for Items inherited from Item_sum, func_name() return part of
- function name till first argument (including '(') to make difference in
- names for functions with 'distinct' clause and without 'distinct' and
- also to make printing of items inherited from Item_sum uniform.
+ NOTE: for Items inherited from Item_sum, func_name() and
+ func_name_cstring() returns part of function name till first
+ argument (including '(') to make difference in names for functions
+ with 'distinct' clause and without 'distinct' and also to make
+ printing of items inherited from Item_sum uniform.
*/
- virtual const char *func_name() const= 0;
+ inline const char *func_name() const
+ { return (char*) func_name_cstring().str; }
+ virtual LEX_CSTRING func_name_cstring() const= 0;
virtual bool fix_length_and_dec()= 0;
bool const_item() const override { return const_item_cache; }
table_map used_tables() const override { return used_tables_cache; }
@@ -5433,7 +5437,7 @@ public:
Field *sp_result_field;
Item_sp(THD *thd, Name_resolution_context *context_arg, sp_name *name_arg);
Item_sp(THD *thd, Item_sp *item);
- const char *func_name(THD *thd) const;
+ LEX_CSTRING func_name_cstring(THD *thd) const;
void cleanup();
bool sp_check_access(THD *thd);
bool execute(THD *thd, bool *null_value, Item **args, uint arg_count);
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 044dbe9f8ae..e374d7fbd57 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -90,11 +90,11 @@ static int cmp_row_type(Item* item1, Item* item2)
@retval false otherwise
*/
-bool
-Type_handler_hybrid_field_type::aggregate_for_comparison(const char *funcname,
- Item **items,
- uint nitems,
- bool int_uint_as_dec)
+bool Type_handler_hybrid_field_type::
+aggregate_for_comparison(const LEX_CSTRING &funcname,
+ Item **items,
+ uint nitems,
+ bool int_uint_as_dec)
{
uint unsigned_count= items[0]->unsigned_flag;
/*
@@ -120,7 +120,7 @@ Type_handler_hybrid_field_type::aggregate_for_comparison(const char *funcname,
i == 1 ? items[0]->type_handler()->name().ptr() :
type_handler()->name().ptr(),
items[i]->type_handler()->name().ptr(),
- funcname);
+ funcname.str);
return true;
}
/*
@@ -476,7 +476,8 @@ int Arg_comparator::set_cmp_func(THD *thd, Item_func_or_sum *owner_arg,
b= a2;
Item *tmp_args[2]= {*a1, *a2};
Type_handler_hybrid_field_type tmp;
- if (tmp.aggregate_for_comparison(owner_arg->func_name(), tmp_args, 2, false))
+ if (tmp.aggregate_for_comparison(owner_arg->func_name_cstring(), tmp_args, 2,
+ false))
{
DBUG_ASSERT(thd->is_error());
return 1;
@@ -2114,7 +2115,8 @@ bool Item_func_between::fix_length_and_dec()
*/
if (!args[0] || !args[1] || !args[2])
return TRUE;
- if (m_comparator.aggregate_for_comparison(Item_func_between::func_name(),
+ if (m_comparator.aggregate_for_comparison(Item_func_between::
+ func_name_cstring(),
args, 3, false))
{
DBUG_ASSERT(current_thd->is_error());
@@ -2801,7 +2803,7 @@ void Item_func_nullif::print(String *str, enum_query_type query_type)
*/
DBUG_ASSERT(arg_count == 2 ||
args[0] == args[2] || current_thd->lex->context_analysis_only);
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
if (arg_count == 2)
args[0]->print(str, query_type);
@@ -3163,9 +3165,10 @@ bool Item_func_case_simple::prepare_predicant_and_values(THD *thd,
add_predicant(this, 0);
for (uint i= 0 ; i < ncases; i++)
{
+ static LEX_CSTRING case_when= { STRING_WITH_LEN("case..when") };
if (nulls_equal ?
- add_value("case..when", this, i + 1) :
- add_value_skip_null("case..when", this, i + 1, &have_null))
+ add_value(case_when, this, i + 1) :
+ add_value_skip_null(case_when, this, i + 1, &have_null))
return true;
}
all_values_added(&tmp, &type_cnt, &m_found_types);
@@ -3208,7 +3211,8 @@ bool Item_func_decode_oracle::fix_length_and_dec()
*/
bool Item_func_case::aggregate_then_and_else_arguments(THD *thd, uint start)
{
- if (aggregate_for_result(func_name(), args + start, arg_count - start, true))
+ if (aggregate_for_result(func_name_cstring(), args + start,
+ arg_count - start, true))
return true;
if (fix_attributes(args + start, arg_count - start))
@@ -3392,7 +3396,7 @@ void Item_func_case_simple::print(String *str, enum_query_type query_type)
void Item_func_decode_oracle::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
args[0]->print(str, query_type);
for (uint i= 1, count= when_count() ; i <= count; i++)
@@ -3926,7 +3930,7 @@ bool Predicant_to_list_comparator::alloc_comparators(THD *thd, uint nargs)
}
-bool Predicant_to_list_comparator::add_value(const char *funcname,
+bool Predicant_to_list_comparator::add_value(const LEX_CSTRING &funcname,
Item_args *args,
uint value_index)
{
@@ -3948,10 +3952,11 @@ bool Predicant_to_list_comparator::add_value(const char *funcname,
}
-bool Predicant_to_list_comparator::add_value_skip_null(const char *funcname,
- Item_args *args,
- uint value_index,
- bool *nulls_found)
+bool Predicant_to_list_comparator::
+add_value_skip_null(const LEX_CSTRING &funcname,
+ Item_args *args,
+ uint value_index,
+ bool *nulls_found)
{
/*
Skip explicit NULL constant items.
@@ -4377,7 +4382,8 @@ bool Item_func_in::prepare_predicant_and_values(THD *thd, uint *found_types)
add_predicant(this, 0);
for (uint i= 1 ; i < arg_count; i++)
{
- if (add_value_skip_null(Item_func_in::func_name(), this, i, &have_null))
+ if (add_value_skip_null(Item_func_in::func_name_cstring(), this, i,
+ &have_null))
return true;
}
all_values_added(&m_comparator, &type_cnt, found_types);
@@ -4504,7 +4510,7 @@ bool cmp_item_row::
aggregate_row_elements_for_comparison(THD *thd,
Type_handler_hybrid_field_type *cmp,
Item_args *tmp,
- const char *funcname,
+ const LEX_CSTRING &funcname,
uint col,
uint level)
{
@@ -4514,8 +4520,8 @@ bool cmp_item_row::
{
Item *arg= tmp->arguments()[i];
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
- ER_UNKNOWN_ERROR, "DBUG: %s[%d,%d] handler=%s",
- String_space(level).c_ptr(), col, i,
+ ER_UNKNOWN_ERROR, "DBUG: %*s[%d,%d] handler=%s",
+ level, "", col, i,
arg->type_handler()->name().ptr());
}
}
@@ -4526,8 +4532,8 @@ bool cmp_item_row::
{
if (!err)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
- ER_UNKNOWN_ERROR, "DBUG: %s=> handler=%s",
- String_space(level).c_ptr(),
+ ER_UNKNOWN_ERROR, "DBUG: %*s=> handler=%s",
+ level,"",
cmp->type_handler()->name().ptr());
}
);
@@ -4535,13 +4541,13 @@ bool cmp_item_row::
}
-bool cmp_item_row::prepare_comparators(THD *thd, const char *funcname,
+bool cmp_item_row::prepare_comparators(THD *thd, const LEX_CSTRING &funcname,
const Item_args *args, uint level)
{
DBUG_EXECUTE_IF("cmp_item",
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
- ER_UNKNOWN_ERROR, "DBUG: %sROW(%d args) level=%d",
- String_space(level).c_ptr(),
+ ER_UNKNOWN_ERROR, "DBUG: %*sROW(%d args) level=%d",
+ level,"",
args->argument_count(), level););
DBUG_ASSERT(args->argument_count() > 0);
if (alloc_comparators(thd, args->arguments()[0]->cols()))
@@ -4590,7 +4596,7 @@ bool Item_func_in::fix_for_row_comparison_using_bisection(THD *thd)
if (unlikely(!(array= new (thd->mem_root) in_row(thd, arg_count-1, 0))))
return true;
cmp_item_row *cmp= &((in_row*)array)->tmp;
- if (cmp->prepare_comparators(thd, func_name(), this, 0))
+ if (cmp->prepare_comparators(thd, func_name_cstring(), this, 0))
return true;
fix_in_vector();
return false;
@@ -4629,7 +4635,7 @@ bool Item_func_in::fix_for_row_comparison_using_cmp_items(THD *thd)
DBUG_ASSERT(get_comparator_type_handler(0) == &type_handler_row);
DBUG_ASSERT(get_comparator_cmp_item(0));
cmp_item_row *cmp_row= (cmp_item_row*) get_comparator_cmp_item(0);
- return cmp_row->prepare_comparators(thd, func_name(), this, 0);
+ return cmp_row->prepare_comparators(thd, func_name_cstring(), this, 0);
}
@@ -5281,7 +5287,7 @@ void Item_cond::print(String *str, enum_query_type query_type)
while ((item=li++))
{
str->append(' ');
- str->append(func_name());
+ str->append(func_name_cstring());
str->append(' ');
item->print_parenthesised(str, query_type, precedence());
}
@@ -5525,7 +5531,7 @@ void Item_func_isnull::print(String *str, enum_query_type query_type)
{
if (const_item() && !args[0]->maybe_null() &&
!(query_type & (QT_NO_DATA_EXPANSION | QT_VIEW_INTERNAL)))
- str->append("/*always not null*/ 1");
+ str->append(STRING_WITH_LEN("/*always not null*/ 1"));
else
args[0]->print_parenthesised(str, query_type, precedence());
str->append(STRING_WITH_LEN(" is null"));
@@ -5586,7 +5592,7 @@ void Item_func_like::print(String *str, enum_query_type query_type)
str->append(' ');
if (negated)
str->append(STRING_WITH_LEN(" not "));
- str->append(func_name());
+ str->append(func_name_cstring());
str->append(' ');
if (escape_used_in_parsing)
{
@@ -7244,7 +7250,7 @@ void Item_equal::print(String *str, enum_query_type query_type)
str->append('0');
return;
}
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
List_iterator_fast<Item> it(equal_items);
Item *item;
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index e0e4a17ef89..5005089577a 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -274,7 +274,11 @@ class Item_func_istrue : public Item_func_truth
public:
Item_func_istrue(THD *thd, Item *a): Item_func_truth(thd, a, true, true) {}
~Item_func_istrue() {}
- virtual const char* func_name() const { return "istrue"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("istrue") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_istrue>(thd, this); }
};
@@ -290,7 +294,11 @@ public:
Item_func_isnottrue(THD *thd, Item *a):
Item_func_truth(thd, a, true, false) {}
~Item_func_isnottrue() {}
- virtual const char* func_name() const { return "isnottrue"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("isnottrue") };
+ return name;
+ }
bool find_not_null_fields(table_map allowed) { return false; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_isnottrue>(thd, this); }
@@ -307,7 +315,11 @@ class Item_func_isfalse : public Item_func_truth
public:
Item_func_isfalse(THD *thd, Item *a): Item_func_truth(thd, a, false, true) {}
~Item_func_isfalse() {}
- virtual const char* func_name() const { return "isfalse"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("isfalse") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_isfalse>(thd, this); }
};
@@ -323,7 +335,11 @@ public:
Item_func_isnotfalse(THD *thd, Item *a):
Item_func_truth(thd, a, false, false) {}
~Item_func_isnotfalse() {}
- virtual const char* func_name() const { return "isnotfalse"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("isnotfalse") };
+ return name;
+ }
bool find_not_null_fields(table_map allowed) { return false; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_isnotfalse>(thd, this); }
@@ -377,7 +393,11 @@ public:
longlong val_int() override;
void cleanup() override;
enum Functype functype() const override { return IN_OPTIMIZER_FUNC; }
- const char *func_name() const override { return "<in_optimizer>"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<in_optimizer>") };
+ return name;
+ }
Item_cache **get_cache() { return &cache; }
void keep_top_level_cache();
Item *transform(THD *thd, Item_transformer transformer, uchar *arg) override;
@@ -583,7 +603,11 @@ class Item_func_xor :public Item_bool_func
public:
Item_func_xor(THD *thd, Item *i1, Item *i2): Item_bool_func(thd, i1, i2) {}
enum Functype functype() const { return XOR_FUNC; }
- const char *func_name() const { return "xor"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("xor") };
+ return name;
+ }
enum precedence precedence() const { return XOR_PRECEDENCE; }
void print(String *str, enum_query_type query_type)
{ Item_func::print_op(str, query_type); }
@@ -609,7 +633,11 @@ public:
bool is_top_level_item() const override { return abort_on_null; }
longlong val_int() override;
enum Functype functype() const override { return NOT_FUNC; }
- const char *func_name() const override { return "not"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("not") };
+ return name;
+ }
bool find_not_null_fields(table_map allowed) override { return false; }
enum precedence precedence() const override { return NEG_PRECEDENCE; }
Item *neg_transformer(THD *thd) override;
@@ -658,7 +686,11 @@ public:
{ trig_var= f; }
longlong val_int() { return *trig_var ? args[0]->val_int() : 1; }
enum Functype functype() const { return TRIG_COND_FUNC; };
- const char *func_name() const { return "trigcond"; };
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("trigcond") };
+ return name;
+ }
bool const_item() const { return FALSE; }
bool *get_trig_var() { return trig_var; }
void add_key_fields(JOIN *join, KEY_FIELD **key_fields,
@@ -683,7 +715,11 @@ public:
table_map not_null_tables() const { return 0; }
longlong val_int();
enum Functype functype() const { return NOT_ALL_FUNC; }
- const char *func_name() const { return "<not>"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<not>") };
+ return name;
+ }
bool fix_fields(THD *thd, Item **ref)
{return Item_func::fix_fields(thd, ref);}
virtual void print(String *str, enum_query_type query_type);
@@ -700,7 +736,11 @@ public:
Item_func_nop_all(THD *thd, Item *a): Item_func_not_all(thd, a) {}
longlong val_int();
- const char *func_name() const { return "<nop>"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<nop>") };
+ return name;
+ }
Item *neg_transformer(THD *thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_nop_all>(thd, this); }
@@ -719,7 +759,11 @@ public:
enum Functype functype() const { return EQ_FUNC; }
enum Functype rev_functype() const { return EQ_FUNC; }
cond_result eq_cmp_result() const { return COND_TRUE; }
- const char *func_name() const { return "="; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("=") };
+ return name;
+ }
void top_level_item() { abort_on_null= true; }
Item *negated_item(THD *thd);
COND *build_equal_items(THD *thd, COND_EQUAL *inherited,
@@ -759,7 +803,11 @@ public:
enum Functype functype() const { return EQUAL_FUNC; }
enum Functype rev_functype() const { return EQUAL_FUNC; }
cond_result eq_cmp_result() const { return COND_TRUE; }
- const char *func_name() const { return "<=>"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<=>") };
+ return name;
+ }
Item *neg_transformer(THD *thd) { return 0; }
void add_key_fields(JOIN *join, KEY_FIELD **key_fields,
uint *and_level, table_map usable_tables,
@@ -782,7 +830,11 @@ public:
enum Functype functype() const { return GE_FUNC; }
enum Functype rev_functype() const { return LE_FUNC; }
cond_result eq_cmp_result() const { return COND_TRUE; }
- const char *func_name() const { return ">="; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN(">=") };
+ return name;
+ }
Item *negated_item(THD *thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_ge>(thd, this); }
@@ -798,7 +850,11 @@ public:
enum Functype functype() const { return GT_FUNC; }
enum Functype rev_functype() const { return LT_FUNC; }
cond_result eq_cmp_result() const { return COND_FALSE; }
- const char *func_name() const { return ">"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN(">") };
+ return name;
+ }
Item *negated_item(THD *thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_gt>(thd, this); }
@@ -814,7 +870,11 @@ public:
enum Functype functype() const { return LE_FUNC; }
enum Functype rev_functype() const { return GE_FUNC; }
cond_result eq_cmp_result() const { return COND_TRUE; }
- const char *func_name() const { return "<="; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<=") };
+ return name;
+ }
Item *negated_item(THD *thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_le>(thd, this); }
@@ -830,7 +890,11 @@ public:
enum Functype functype() const { return LT_FUNC; }
enum Functype rev_functype() const { return GT_FUNC; }
cond_result eq_cmp_result() const { return COND_FALSE; }
- const char *func_name() const { return "<"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<") };
+ return name;
+ }
Item *negated_item(THD *thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_lt>(thd, this); }
@@ -849,7 +913,11 @@ public:
enum Functype functype() const { return NE_FUNC; }
enum Functype rev_functype() const { return NE_FUNC; }
cond_result eq_cmp_result() const { return COND_FALSE; }
- const char *func_name() const { return "<>"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<>") };
+ return name;
+ }
Item *negated_item(THD *thd);
void add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
table_map usable_tables, SARGABLE_PARAM **sargables);
@@ -921,7 +989,11 @@ public:
return m_comparator.type_handler()->Item_func_between_val_int(this);
}
enum Functype functype() const { return BETWEEN; }
- const char *func_name() const { return "between"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("between") };
+ return name;
+ }
enum precedence precedence() const { return BETWEEN_PRECEDENCE; }
bool fix_length_and_dec();
bool fix_length_and_dec_string(THD *)
@@ -972,7 +1044,11 @@ public:
Item_long_func(thd, a, b) {}
longlong val_int();
decimal_digits_t decimal_precision() const override { return 1; }
- const char *func_name() const { return "strcmp"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("strcmp") };
+ return name;
+ }
bool fix_length_and_dec()
{
if (agg_arg_charsets_for_comparison(cmp_collation, args, 2))
@@ -1008,11 +1084,15 @@ public:
bool fix_fields(THD *, Item **);
longlong val_int();
bool fix_length_and_dec();
- const char *func_name() const { return "interval"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("interval") };
+ return name;
+ }
decimal_digits_t decimal_precision() const override { return 2; }
void print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
print_args(str, 0, query_type);
}
Item *get_copy(THD *thd)
@@ -1036,12 +1116,16 @@ public:
bool native_op(THD *thd, Native *to);
bool fix_length_and_dec()
{
- if (aggregate_for_result(func_name(), args, arg_count, true))
+ if (aggregate_for_result(func_name_cstring(), args, arg_count, true))
return TRUE;
fix_attributes(args, arg_count);
return FALSE;
}
- const char *func_name() const { return "coalesce"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("coalesce") };
+ return name;
+ }
table_map not_null_tables() const { return 0; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_coalesce>(thd, this); }
@@ -1059,7 +1143,7 @@ class Item_func_case_abbreviation2 :public Item_func_case_expression
protected:
bool fix_length_and_dec2(Item **items)
{
- if (aggregate_for_result(func_name(), items, 2, true))
+ if (aggregate_for_result(func_name_cstring(), items, 2, true))
return TRUE;
fix_attributes(items, 2);
return FALSE;
@@ -1131,7 +1215,11 @@ public:
return TRUE;
return FALSE;
}
- const char *func_name() const { return "ifnull"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("ifnull") };
+ return name;
+ }
table_map not_null_tables() const { return 0; }
Item *get_copy(THD *thd)
@@ -1204,7 +1292,11 @@ public:
{
return fix_length_and_dec2_eliminate_null(args + 1);
}
- const char *func_name() const { return "if"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("if") };
+ return name;
+ }
bool eval_not_null_tables(void *opt_arg);
void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
Item *get_copy(THD *thd)
@@ -1223,7 +1315,11 @@ public:
Item_func_nvl2(THD *thd, Item *a, Item *b, Item *c):
Item_func_case_abbreviation2_switch(thd, a, b, c)
{}
- const char *func_name() const { return "nvl2"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("nvl2") };
+ return name;
+ }
bool fix_length_and_dec()
{
return fix_length_and_dec2_eliminate_null(args + 1);
@@ -1289,7 +1385,11 @@ public:
bool native_op(THD *thd, Native *to);
bool fix_length_and_dec();
bool walk(Item_processor processor, bool walk_subquery, void *arg);
- const char *func_name() const { return "nullif"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("nullif") };
+ return name;
+ }
void print(String *str, enum_query_type query_type);
void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &fields, uint flags);
@@ -1638,7 +1738,7 @@ public:
void set_charset(CHARSET_INFO *cs)
{
cmp_charset= cs;
- value.set_quick(value_buff, sizeof(value_buff), cs);
+ value.set_buffer_if_not_allocated(value_buff, sizeof(value_buff), cs);
}
};
@@ -2064,13 +2164,14 @@ public:
arguments (e.g. ROWs with size)
@retval false - a new element was successfully added.
*/
- bool add_value(const char *funcname, Item_args *args, uint value_index);
+ bool add_value(const LEX_CSTRING &funcname, Item_args *args,
+ uint value_index);
/**
Add a new element into m_comparators[], ignoring explicit NULL values.
If the value appeared to be an explicit NULL, nulls_found[0] is set to true.
*/
- bool add_value_skip_null(const char *funcname,
+ bool add_value_skip_null(const LEX_CSTRING &funcname,
Item_args *args, uint value_index,
bool *nulls_found);
@@ -2202,7 +2303,11 @@ public:
bool native_op(THD *thd, Native *to);
bool fix_fields(THD *thd, Item **ref);
table_map not_null_tables() const { return 0; }
- const char *func_name() const { return "case"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("case") };
+ return name;
+ }
CHARSET_INFO *compare_collation() const { return cmp_collation.collation; }
bool need_parentheses_in_default() { return true; }
};
@@ -2305,7 +2410,11 @@ public:
Item_func_decode_oracle(THD *thd, List<Item> &list)
:Item_func_case_simple(thd, list)
{ }
- const char *func_name() const { return "decode_oracle"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("decode_oracle") };
+ return name;
+ }
void print(String *str, enum_query_type query_type);
bool fix_length_and_dec();
Item *find_item();
@@ -2466,7 +2575,11 @@ public:
}
virtual void print(String *str, enum_query_type query_type);
enum Functype functype() const { return IN_FUNC; }
- const char *func_name() const { return "in"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("in") };
+ return name;
+ }
enum precedence precedence() const { return IN_PRECEDENCE; }
bool eval_not_null_tables(void *opt_arg);
bool find_not_null_fields(table_map allowed);
@@ -2500,14 +2613,14 @@ class cmp_item_row :public cmp_item
bool aggregate_row_elements_for_comparison(THD *thd,
Type_handler_hybrid_field_type *cmp,
Item_args *tmp,
- const char *funcname,
+ const LEX_CSTRING &funcname,
uint col,
uint level);
public:
cmp_item_row(): comparators(0), n(0) {}
~cmp_item_row();
void store_value(Item *item);
- bool prepare_comparators(THD *, const char *funcname,
+ bool prepare_comparators(THD *, const LEX_CSTRING &funcname,
const Item_args *args, uint level);
int cmp(Item *arg);
int cmp_not_null(const Value *val)
@@ -2580,7 +2693,11 @@ public:
Item_func_isnull(THD *thd, Item *a): Item_func_null_predicate(thd, a) {}
longlong val_int();
enum Functype functype() const { return ISNULL_FUNC; }
- const char *func_name() const { return "isnull"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("isnull") };
+ return name;
+ }
void print(String *str, enum_query_type query_type);
enum precedence precedence() const { return CMP_PRECEDENCE; }
@@ -2639,7 +2756,11 @@ public:
{}
enum Functype functype() const { return ISNOTNULLTEST_FUNC; }
longlong val_int();
- const char *func_name() const { return "<is_not_null_test>"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<is_not_null_test>") };
+ return name;
+ }
void update_used_tables();
/*
we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
@@ -2659,7 +2780,11 @@ public:
{ }
longlong val_int();
enum Functype functype() const { return ISNOTNULL_FUNC; }
- const char *func_name() const { return "isnotnull"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("isnotnull") };
+ return name;
+ }
enum precedence precedence() const { return CMP_PRECEDENCE; }
table_map not_null_tables() const
{ return abort_on_null ? not_null_tables_cache : 0; }
@@ -2794,7 +2919,11 @@ public:
cond);
return this;
}
- const char *func_name() const { return "like"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("like") };
+ return name;
+ }
enum precedence precedence() const { return IN_PRECEDENCE; }
bool fix_fields(THD *thd, Item **ref);
bool fix_length_and_dec()
@@ -2910,7 +3039,11 @@ public:
}
longlong val_int();
bool fix_length_and_dec();
- const char *func_name() const { return "regexp"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("regexp") };
+ return name;
+ }
enum precedence precedence() const { return IN_PRECEDENCE; }
Item *get_copy(THD *) { return 0; }
void print(String *str, enum_query_type query_type)
@@ -2932,8 +3065,8 @@ class Item_func_regexp_instr :public Item_long_func
{
bool check_arguments() const
{
- return args[0]->check_type_can_return_str(func_name()) ||
- args[1]->check_type_can_return_text(func_name());
+ return (args[0]->check_type_can_return_str(func_name_cstring()) ||
+ args[1]->check_type_can_return_text(func_name_cstring()));
}
Regexp_processor_pcre re;
DTCollation cmp_collation;
@@ -2950,7 +3083,11 @@ public:
}
longlong val_int();
bool fix_length_and_dec();
- const char *func_name() const { return "regexp_instr"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("regexp_instr") };
+ return name;
+ }
Item *get_copy(THD *thd) { return 0; }
};
@@ -3184,7 +3321,11 @@ public:
void update_const(THD *thd);
enum Functype functype() const { return MULT_EQUAL_FUNC; }
longlong val_int();
- const char *func_name() const { return "multiple equal"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("multiple equal") };
+ return name;
+ }
void sort(Item_field_cmpfunc compare, void *arg);
bool fix_length_and_dec();
bool fix_fields(THD *thd, Item **ref);
@@ -3362,7 +3503,11 @@ public:
Item_cond_and(THD *thd, List<Item> &list_arg): Item_cond(thd, list_arg) {}
enum Functype functype() const { return COND_AND_FUNC; }
longlong val_int();
- const char *func_name() const { return "and"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("and") };
+ return name;
+ }
enum precedence precedence() const { return AND_PRECEDENCE; }
table_map not_null_tables() const
{ return abort_on_null ? not_null_tables_cache: and_tables_cache; }
@@ -3396,7 +3541,11 @@ public:
Item_cond_or(THD *thd, List<Item> &list_arg): Item_cond(thd, list_arg) {}
enum Functype functype() const { return COND_OR_FUNC; }
longlong val_int();
- const char *func_name() const { return "or"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("or") };
+ return name;
+ }
enum precedence precedence() const { return OR_PRECEDENCE; }
table_map not_null_tables() const { return and_tables_cache; }
Item *copy_andor_structure(THD *thd);
@@ -3410,7 +3559,11 @@ class Item_func_dyncol_check :public Item_bool_func
public:
Item_func_dyncol_check(THD *thd, Item *str): Item_bool_func(thd, str) {}
longlong val_int();
- const char *func_name() const { return "column_check"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("column_check") };
+ return name;
+ }
bool need_parentheses_in_default() { return false; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_dyncol_check>(thd, this); }
@@ -3422,7 +3575,11 @@ public:
Item_func_dyncol_exists(THD *thd, Item *str, Item *num):
Item_bool_func(thd, str, num) {}
longlong val_int();
- const char *func_name() const { return "column_exists"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("column_exists") };
+ return name;
+ }
bool need_parentheses_in_default() { return false; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_dyncol_exists>(thd, this); }
@@ -3441,7 +3598,7 @@ public:
}
void print(String *str, enum_query_type query_type)
{
- Cursor_ref::print_func(str, func_name());
+ Cursor_ref::print_func(str, func_name_cstring());
}
};
@@ -3451,7 +3608,11 @@ class Item_func_cursor_isopen: public Item_func_cursor_bool_attr
public:
Item_func_cursor_isopen(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_bool_attr(thd, name, offset) { }
- const char *func_name() const { return "%ISOPEN"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("%ISOPEN") };
+ return name;
+ }
longlong val_int();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_cursor_isopen>(thd, this); }
@@ -3466,7 +3627,11 @@ public:
{
set_maybe_null();
}
- const char *func_name() const { return "%FOUND"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("%FOUND") };
+ return name;
+ }
longlong val_int();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_cursor_found>(thd, this); }
@@ -3481,7 +3646,11 @@ public:
{
set_maybe_null();
}
- const char *func_name() const { return "%NOTFOUND"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("%NOTFOUND") };
+ return name;
+ }
longlong val_int();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_cursor_notfound>(thd, this); }
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 21aaebdd52e..8bcf0ac4bb1 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -165,7 +165,7 @@ bool Item_func::check_argument_types_or_binary(const Type_handler *handler,
for (uint i= start; i < end ; i++)
{
DBUG_ASSERT(i < arg_count);
- if (args[i]->check_type_or_binary(func_name(), handler))
+ if (args[i]->check_type_or_binary(func_name_cstring(), handler))
return true;
}
return false;
@@ -178,7 +178,7 @@ bool Item_func::check_argument_types_traditional_scalar(uint start,
for (uint i= start; i < end ; i++)
{
DBUG_ASSERT(i < arg_count);
- if (args[i]->check_type_traditional_scalar(func_name()))
+ if (args[i]->check_type_traditional_scalar(func_name_cstring()))
return true;
}
return false;
@@ -191,7 +191,7 @@ bool Item_func::check_argument_types_can_return_int(uint start,
for (uint i= start; i < end ; i++)
{
DBUG_ASSERT(i < arg_count);
- if (args[i]->check_type_can_return_int(func_name()))
+ if (args[i]->check_type_can_return_int(func_name_cstring()))
return true;
}
return false;
@@ -204,7 +204,7 @@ bool Item_func::check_argument_types_can_return_real(uint start,
for (uint i= start; i < end ; i++)
{
DBUG_ASSERT(i < arg_count);
- if (args[i]->check_type_can_return_real(func_name()))
+ if (args[i]->check_type_can_return_real(func_name_cstring()))
return true;
}
return false;
@@ -217,7 +217,7 @@ bool Item_func::check_argument_types_can_return_text(uint start,
for (uint i= start; i < end ; i++)
{
DBUG_ASSERT(i < arg_count);
- if (args[i]->check_type_can_return_text(func_name()))
+ if (args[i]->check_type_can_return_text(func_name_cstring()))
return true;
}
return false;
@@ -230,7 +230,7 @@ bool Item_func::check_argument_types_can_return_str(uint start,
for (uint i= start; i < end ; i++)
{
DBUG_ASSERT(i < arg_count);
- if (args[i]->check_type_can_return_str(func_name()))
+ if (args[i]->check_type_can_return_str(func_name_cstring()))
return true;
}
return false;
@@ -243,7 +243,7 @@ bool Item_func::check_argument_types_can_return_date(uint start,
for (uint i= start; i < end ; i++)
{
DBUG_ASSERT(i < arg_count);
- if (args[i]->check_type_can_return_date(func_name()))
+ if (args[i]->check_type_can_return_date(func_name_cstring()))
return true;
}
return false;
@@ -256,7 +256,7 @@ bool Item_func::check_argument_types_can_return_time(uint start,
for (uint i= start; i < end ; i++)
{
DBUG_ASSERT(i < arg_count);
- if (args[i]->check_type_can_return_time(func_name()))
+ if (args[i]->check_type_can_return_time(func_name_cstring()))
return true;
}
return false;
@@ -268,7 +268,7 @@ bool Item_func::check_argument_types_scalar(uint start, uint end) const
for (uint i= start; i < end; i++)
{
DBUG_ASSERT(i < arg_count);
- if (args[i]->check_type_scalar(func_name()))
+ if (args[i]->check_type_scalar(func_name_cstring()))
return true;
}
return false;
@@ -605,7 +605,7 @@ table_map Item_func::not_null_tables() const
void Item_func::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
print_args(str, 0, query_type);
str->append(')');
@@ -629,7 +629,7 @@ void Item_func::print_op(String *str, enum_query_type query_type)
{
args[i]->print_parenthesised(str, query_type, precedence());
str->append(' ');
- str->append(func_name());
+ str->append(func_name_cstring());
str->append(' ');
}
args[arg_count-1]->print_parenthesised(str, query_type, higher_precedence());
@@ -672,7 +672,7 @@ bool Item_hybrid_func::fix_attributes(Item **items, uint nitems)
{
bool rc= Item_hybrid_func::type_handler()->
Item_hybrid_func_fix_attributes(current_thd,
- func_name(), this, this,
+ func_name_cstring(), this, this,
items, nitems);
DBUG_ASSERT(!rc || current_thd->is_error());
return rc;
@@ -1070,11 +1070,12 @@ void Item_real_typecast::print(String *str, enum_query_type query_type)
{
char len_buf[20*3 + 1];
char *end;
+ Name name= type_handler()->name();
str->append(STRING_WITH_LEN("cast("));
args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as "));
- str->append(type_handler()->name().ptr());
+ str->append(name.ptr(), name.length());
if (decimals != NOT_FIXED_DEC)
{
str->append('(');
@@ -3754,7 +3755,7 @@ void Item_udf_func::cleanup()
void Item_udf_func::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
for (uint i=0 ; i < arg_count ; i++)
{
@@ -5412,12 +5413,12 @@ int Item_func_set_user_var::save_in_field(Field *field, bool no_conversions,
String *result;
CHARSET_INFO *cs= collation.collation;
char buff[MAX_FIELD_WIDTH]; // Alloc buffer for small columns
- str_value.set_quick(buff, sizeof(buff), cs);
+ str_value.set_buffer_if_not_allocated(buff, sizeof(buff), cs);
result= m_var_entry->val_str(&null_value, &str_value, decimals);
if (null_value)
{
- str_value.set_quick(0, 0, cs);
+ str_value.set_buffer_if_not_allocated(0, 0, cs);
return set_field_to_null_with_conversions(field, no_conversions);
}
@@ -5425,7 +5426,7 @@ int Item_func_set_user_var::save_in_field(Field *field, bool no_conversions,
field->set_notnull();
error=field->store(result->ptr(),result->length(),cs);
- str_value.set_quick(0, 0, cs);
+ str_value.set_buffer_if_not_allocated(0, 0, cs);
}
else if (result_type() == REAL_RESULT)
{
@@ -6569,11 +6570,11 @@ Item_func_sp::cleanup()
Item_func::cleanup();
}
-const char *
-Item_func_sp::func_name() const
+LEX_CSTRING
+Item_func_sp::func_name_cstring() const
{
THD *thd= current_thd;
- return Item_sp::func_name(thd);
+ return Item_sp::func_name_cstring(thd);
}
@@ -6947,7 +6948,7 @@ bool Item_func_last_value::fix_length_and_dec()
}
-void Cursor_ref::print_func(String *str, const char *func_name)
+void Cursor_ref::print_func(String *str, const LEX_CSTRING &func_name)
{
append_identifier(current_thd, str, &m_cursor_name);
str->append(func_name);
@@ -7076,7 +7077,7 @@ void Item_func_nextval::print(String *str, enum_query_type query_type)
bool use_db_name= d_name.str && d_name.str[0];
THD *thd= current_thd; // Don't trust 'table'
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
/*
@@ -7200,7 +7201,7 @@ void Item_func_setval::print(String *str, enum_query_type query_type)
bool use_db_name= d_name.str && d_name.str[0];
THD *thd= current_thd; // Don't trust 'table'
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
/*
diff --git a/sql/item_func.h b/sql/item_func.h
index 4b8ed99a9d8..7a4a9c60f01 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -168,7 +168,7 @@ public:
}
void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &fields, uint flags);
- virtual void print(String *str, enum_query_type query_type);
+ void print(String *str, enum_query_type query_type) override;
void print_op(String *str, enum_query_type query_type);
void print_args(String *str, uint from, enum_query_type query_type);
bool is_null() {
@@ -1198,7 +1198,11 @@ public:
const Type_handler *type_handler() const { return &type_handler_slong; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_hash>(thd, this); }
- const char *func_name() const { return "<hash>"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<hash>") };
+ return name;
+ }
};
class Item_longlong_func: public Item_int_func
@@ -1230,7 +1234,7 @@ protected:
Cursor_ref(const LEX_CSTRING *name, uint offset)
:m_cursor_name(*name), m_cursor_offset(offset)
{ }
- void print_func(String *str, const char *func_name);
+ void print_func(String *str, const LEX_CSTRING &func_name);
};
@@ -1244,7 +1248,11 @@ public:
{
set_maybe_null();
}
- const char *func_name() const { return "%ROWCOUNT"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("%ROWCOUNT") };
+ return name;
+ }
longlong val_int();
bool check_vcol_func_processor(void *arg)
{
@@ -1252,7 +1260,7 @@ public:
}
void print(String *str, enum_query_type query_type)
{
- return Cursor_ref::print_func(str, func_name());
+ return Cursor_ref::print_func(str, func_name_cstring());
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_cursor_rowcount>(thd, this); }
@@ -1266,13 +1274,18 @@ class Item_func_connection_id :public Item_long_func
public:
Item_func_connection_id(THD *thd): Item_long_func(thd) { unsigned_flag=1; }
- const char *func_name() const { return "connection_id"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("connection_id") };
+ return name;
+ }
bool fix_length_and_dec();
bool fix_fields(THD *thd, Item **ref);
longlong val_int() { DBUG_ASSERT(fixed()); return value; }
bool check_vcol_func_processor(void *arg)
{
- return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
+ return mark_unsupported_function(func_name(), "()", arg,
+ VCOL_SESSION_FUNC);
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_connection_id>(thd, this); }
@@ -1286,7 +1299,11 @@ public:
{
unsigned_flag= 0;
}
- const char *func_name() const { return "cast_as_signed"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_signed") };
+ return name;
+ }
const Type_handler *type_handler() const
{
return Type_handler::type_handler_long_or_longlong(max_char_length(),
@@ -1347,7 +1364,11 @@ public:
{
unsigned_flag= 1;
}
- const char *func_name() const { return "cast_as_unsigned"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_unsigned") };
+ return name;
+ }
const Type_handler *type_handler() const
{
if (max_char_length() <= MY_INT32_NUM_DECIMAL_DIGITS - 1)
@@ -1399,7 +1420,11 @@ public:
return
args[0]->type_handler()->Item_decimal_typecast_fix_length_and_dec(this);
}
- const char *func_name() const { return "decimal_typecast"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("decimal_typecast") };
+ return name;
+ }
virtual void print(String *str, enum_query_type query_type);
bool need_parentheses_in_default() { return true; }
Item *get_copy(THD *thd)
@@ -1439,7 +1464,11 @@ public:
return
args[0]->type_handler()->Item_float_typecast_fix_length_and_dec(this);
}
- const char *func_name() const { return "float_typecast"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("float_typecast") };
+ return name;
+ }
double val_real()
{
return (double) (float) val_real_with_truncate(FLT_MAX);
@@ -1468,7 +1497,11 @@ public:
return
args[0]->type_handler()->Item_double_typecast_fix_length_and_dec(this);
}
- const char *func_name() const { return "double_typecast"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("double_typecast") };
+ return name;
+ }
double val_real() { return val_real_with_truncate(DBL_MAX); }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_double_typecast>(thd, this); }
@@ -1490,7 +1523,11 @@ class Item_func_plus :public Item_func_additive_op
public:
Item_func_plus(THD *thd, Item *a, Item *b):
Item_func_additive_op(thd, a, b) {}
- const char *func_name() const { return "+"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("+") };
+ return name;
+ }
enum precedence precedence() const { return ADD_PRECEDENCE; }
bool fix_length_and_dec();
longlong int_op();
@@ -1508,7 +1545,11 @@ public:
Item_func_additive_op(thd, a, b),
m_depends_on_sql_mode_no_unsigned_subtraction(false)
{ }
- const char *func_name() const { return "-"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("-") };
+ return name;
+ }
enum precedence precedence() const { return ADD_PRECEDENCE; }
Sql_mode_dependency value_depends_on_sql_mode() const;
longlong int_op();
@@ -1541,7 +1582,11 @@ class Item_func_mul :public Item_num_op
public:
Item_func_mul(THD *thd, Item *a, Item *b):
Item_num_op(thd, a, b) {}
- const char *func_name() const { return "*"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("*") };
+ return name;
+ }
enum precedence precedence() const { return MUL_PRECEDENCE; }
longlong int_op();
double real_op();
@@ -1563,7 +1608,11 @@ public:
longlong int_op() { DBUG_ASSERT(0); return 0; }
double real_op();
my_decimal *decimal_op(my_decimal *);
- const char *func_name() const { return "/"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("/") };
+ return name;
+ }
enum precedence precedence() const { return MUL_PRECEDENCE; }
bool fix_length_and_dec();
void fix_length_and_dec_double();
@@ -1580,7 +1629,11 @@ public:
Item_func_int_div(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b)
{}
longlong val_int();
- const char *func_name() const { return "DIV"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("DIV") };
+ return name;
+ }
enum precedence precedence() const { return MUL_PRECEDENCE; }
const Type_handler *type_handler() const
{ return type_handler_long_or_longlong(); }
@@ -1605,7 +1658,11 @@ public:
longlong int_op();
double real_op();
my_decimal *decimal_op(my_decimal *);
- const char *func_name() const { return "MOD"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("MOD") };
+ return name;
+ }
enum precedence precedence() const { return MUL_PRECEDENCE; }
void result_precision();
bool fix_length_and_dec();
@@ -1639,12 +1696,16 @@ public:
double real_op();
longlong int_op();
my_decimal *decimal_op(my_decimal *);
- const char *func_name() const { return "-"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("-") };
+ return name;
+ }
enum Functype functype() const { return NEG_FUNC; }
enum precedence precedence() const { return NEG_PRECEDENCE; }
void print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
args[0]->print_parenthesised(str, query_type, precedence());
}
void fix_length_and_dec_int();
@@ -1666,7 +1727,11 @@ public:
double real_op();
longlong int_op();
my_decimal *decimal_op(my_decimal *);
- const char *func_name() const { return "abs"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("abs") };
+ return name;
+ }
void fix_length_and_dec_int();
void fix_length_and_dec_double();
void fix_length_and_dec_decimal();
@@ -1698,7 +1763,11 @@ class Item_func_exp :public Item_dec_func
public:
Item_func_exp(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "exp"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("exp") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_exp>(thd, this); }
};
@@ -1709,7 +1778,11 @@ class Item_func_ln :public Item_dec_func
public:
Item_func_ln(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "ln"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("ln") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_ln>(thd, this); }
};
@@ -1721,7 +1794,11 @@ public:
Item_func_log(THD *thd, Item *a): Item_dec_func(thd, a) {}
Item_func_log(THD *thd, Item *a, Item *b): Item_dec_func(thd, a, b) {}
double val_real();
- const char *func_name() const { return "log"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("log") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_log>(thd, this); }
};
@@ -1732,7 +1809,11 @@ class Item_func_log2 :public Item_dec_func
public:
Item_func_log2(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "log2"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("log2") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_log2>(thd, this); }
};
@@ -1743,7 +1824,11 @@ class Item_func_log10 :public Item_dec_func
public:
Item_func_log10(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "log10"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("log10") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_log10>(thd, this); }
};
@@ -1754,7 +1839,11 @@ class Item_func_sqrt :public Item_dec_func
public:
Item_func_sqrt(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "sqrt"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sqrt") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_sqrt>(thd, this); }
};
@@ -1765,7 +1854,11 @@ class Item_func_pow :public Item_dec_func
public:
Item_func_pow(THD *thd, Item *a, Item *b): Item_dec_func(thd, a, b) {}
double val_real();
- const char *func_name() const { return "pow"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("pow") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_pow>(thd, this); }
};
@@ -1776,7 +1869,11 @@ class Item_func_acos :public Item_dec_func
public:
Item_func_acos(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "acos"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("acos") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_acos>(thd, this); }
};
@@ -1786,7 +1883,11 @@ class Item_func_asin :public Item_dec_func
public:
Item_func_asin(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "asin"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("asin") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_asin>(thd, this); }
};
@@ -1797,7 +1898,11 @@ public:
Item_func_atan(THD *thd, Item *a): Item_dec_func(thd, a) {}
Item_func_atan(THD *thd, Item *a, Item *b): Item_dec_func(thd, a, b) {}
double val_real();
- const char *func_name() const { return "atan"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("atan") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_atan>(thd, this); }
};
@@ -1807,7 +1912,11 @@ class Item_func_cos :public Item_dec_func
public:
Item_func_cos(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "cos"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("cos") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_cos>(thd, this); }
};
@@ -1817,7 +1926,11 @@ class Item_func_sin :public Item_dec_func
public:
Item_func_sin(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "sin"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sin") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_sin>(thd, this); }
};
@@ -1827,7 +1940,11 @@ class Item_func_tan :public Item_dec_func
public:
Item_func_tan(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "tan"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("tan") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_tan>(thd, this); }
};
@@ -1837,7 +1954,11 @@ class Item_func_cot :public Item_dec_func
public:
Item_func_cot(THD *thd, Item *a): Item_dec_func(thd, a) {}
double val_real();
- const char *func_name() const { return "cot"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("cot") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_cot>(thd, this); }
};
@@ -1878,7 +1999,11 @@ class Item_func_ceiling :public Item_func_int_val
{
public:
Item_func_ceiling(THD *thd, Item *a): Item_func_int_val(thd, a) {}
- const char *func_name() const { return "ceiling"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("ceiling") };
+ return name;
+ }
decimal_round_mode round_mode() const { return CEILING; }
longlong int_op();
double real_op();
@@ -1894,7 +2019,11 @@ class Item_func_floor :public Item_func_int_val
{
public:
Item_func_floor(THD *thd, Item *a): Item_func_int_val(thd, a) {}
- const char *func_name() const { return "floor"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("floor") };
+ return name;
+ }
decimal_round_mode round_mode() const { return FLOOR; }
longlong int_op();
double real_op();
@@ -1916,7 +2045,12 @@ class Item_func_round :public Item_func_hybrid_field_type
public:
Item_func_round(THD *thd, Item *a, Item *b, bool trunc_arg)
:Item_func_hybrid_field_type(thd, a, b), truncate(trunc_arg) {}
- const char *func_name() const { return truncate ? "truncate" : "round"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING truncate_name= {STRING_WITH_LEN("truncate") };
+ static LEX_CSTRING round_name= {STRING_WITH_LEN("round") };
+ return truncate ? truncate_name : round_name;
+ }
double real_op();
longlong int_op();
my_decimal *decimal_op(my_decimal *);
@@ -1966,7 +2100,11 @@ public:
Item_real_func(thd, a), rand(0), first_eval(TRUE) {}
Item_func_rand(THD *thd): Item_real_func(thd) {}
double val_real();
- const char *func_name() const { return "rand"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("rand") };
+ return name;
+ }
bool const_item() const { return 0; }
void update_used_tables();
bool fix_fields(THD *thd, Item **ref);
@@ -1984,10 +2122,14 @@ public:
class Item_func_sign :public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_can_return_real(func_name()); }
+ { return args[0]->check_type_can_return_real(func_name_cstring()); }
public:
Item_func_sign(THD *thd, Item *a): Item_long_func(thd, a) {}
- const char *func_name() const { return "sign"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sign") };
+ return name;
+ }
decimal_digits_t decimal_precision() const override { return 1; }
bool fix_length_and_dec() { fix_char_length(2); return FALSE; }
longlong val_int();
@@ -1998,16 +2140,20 @@ public:
class Item_func_units :public Item_real_func
{
- char *name;
+ LEX_CSTRING name;
double mul,add;
bool check_arguments() const
{ return check_argument_types_can_return_real(0, arg_count); }
public:
Item_func_units(THD *thd, char *name_arg, Item *a, double mul_arg,
double add_arg):
- Item_real_func(thd, a), name(name_arg), mul(mul_arg), add(add_arg) {}
+ Item_real_func(thd, a), mul(mul_arg), add(add_arg)
+ {
+ name.str= name_arg;
+ name.length= strlen(name_arg);
+ }
double val_real();
- const char *func_name() const { return name; }
+ LEX_CSTRING func_name_cstring() const override { return name; }
bool fix_length_and_dec()
{
decimals= NOT_FIXED_DEC;
@@ -2104,7 +2250,7 @@ public:
}
bool fix_length_and_dec()
{
- if (aggregate_for_min_max(func_name(), args, arg_count))
+ if (aggregate_for_min_max(func_name_cstring(), args, arg_count))
return true;
fix_attributes(args, arg_count);
return false;
@@ -2115,7 +2261,11 @@ class Item_func_min :public Item_func_min_max
{
public:
Item_func_min(THD *thd, List<Item> &list): Item_func_min_max(thd, list, 1) {}
- const char *func_name() const { return "least"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("least") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_min>(thd, this); }
};
@@ -2124,7 +2274,11 @@ class Item_func_max :public Item_func_min_max
{
public:
Item_func_max(THD *thd, List<Item> &list): Item_func_min_max(thd, list, -1) {}
- const char *func_name() const { return "greatest"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("greatest") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_max>(thd, this); }
};
@@ -2151,7 +2305,11 @@ public:
{ return val_decimal_from_item(args[0], dec); }
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{ return get_date_from_item(thd, args[0], ltime, fuzzydate); }
- const char *func_name() const { return "rollup_const"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("rollup_const") };
+ return name;
+ }
bool const_item() const { return 0; }
const Type_handler *type_handler() const { return args[0]->type_handler(); }
bool fix_length_and_dec()
@@ -2167,7 +2325,7 @@ public:
class Item_long_func_length: public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_can_return_str(func_name()); }
+ { return args[0]->check_type_can_return_str(func_name_cstring()); }
public:
Item_long_func_length(THD *thd, Item *a): Item_long_func(thd, a) {}
bool fix_length_and_dec() { max_length=10; return FALSE; }
@@ -2180,7 +2338,11 @@ class Item_func_octet_length :public Item_long_func_length
public:
Item_func_octet_length(THD *thd, Item *a): Item_long_func_length(thd, a) {}
longlong val_int();
- const char *func_name() const { return "octet_length"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("octet_length") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_octet_length>(thd, this); }
};
@@ -2196,7 +2358,11 @@ public:
return FALSE;
}
longlong val_int();
- const char *func_name() const { return "bit_length"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("bit_length") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_bit_length>(thd, this); }
};
@@ -2207,7 +2373,11 @@ class Item_func_char_length :public Item_long_func_length
public:
Item_func_char_length(THD *thd, Item *a): Item_long_func_length(thd, a) {}
longlong val_int();
- const char *func_name() const { return "char_length"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("char_length") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_char_length>(thd, this); }
};
@@ -2215,11 +2385,15 @@ public:
class Item_func_coercibility :public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_can_return_str(func_name()); }
+ { return args[0]->check_type_can_return_str(func_name_cstring()); }
public:
Item_func_coercibility(THD *thd, Item *a): Item_long_func(thd, a) {}
longlong val_int();
- const char *func_name() const { return "coercibility"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("coercibility") };
+ return name;
+ }
bool fix_length_and_dec()
{
max_length=10;
@@ -2254,7 +2428,7 @@ class Item_func_locate :public Item_long_func
bool check_arguments() const
{
return check_argument_types_can_return_str(0, 2) ||
- (arg_count > 2 && args[2]->check_type_can_return_int(func_name()));
+ (arg_count > 2 && args[2]->check_type_can_return_int(func_name_cstring()));
}
String value1,value2;
DTCollation cmp_collation;
@@ -2263,7 +2437,11 @@ public:
:Item_long_func(thd, a, b) {}
Item_func_locate(THD *thd, Item *a, Item *b, Item *c)
:Item_long_func(thd, a, b, c) {}
- const char *func_name() const { return "locate"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("locate") };
+ return name;
+ }
longlong val_int();
bool fix_length_and_dec()
{
@@ -2284,7 +2462,11 @@ class Item_func_field :public Item_long_func
public:
Item_func_field(THD *thd, List<Item> &list): Item_long_func(thd, list) {}
longlong val_int();
- const char *func_name() const { return "field"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("field") };
+ return name;
+ }
bool fix_length_and_dec();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_field>(thd, this); }
@@ -2299,7 +2481,11 @@ class Item_func_ascii :public Item_long_func
public:
Item_func_ascii(THD *thd, Item *a): Item_long_func(thd, a) {}
longlong val_int();
- const char *func_name() const { return "ascii"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("ascii") };
+ return name;
+ }
bool fix_length_and_dec() { max_length=3; return FALSE; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_ascii>(thd, this); }
@@ -2308,13 +2494,17 @@ public:
class Item_func_ord :public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_can_return_str(func_name()); }
+ { return args[0]->check_type_can_return_str(func_name_cstring()); }
String value;
public:
Item_func_ord(THD *thd, Item *a): Item_long_func(thd, a) {}
bool fix_length_and_dec() { fix_char_length(7); return FALSE; }
longlong val_int();
- const char *func_name() const { return "ord"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("ord") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_ord>(thd, this); }
};
@@ -2331,7 +2521,11 @@ public:
Item_func_find_in_set(THD *thd, Item *a, Item *b):
Item_long_func(thd, a, b), enum_value(0) {}
longlong val_int();
- const char *func_name() const { return "find_in_set"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("find_in_set") };
+ return name;
+ }
bool fix_length_and_dec();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_find_in_set>(thd, this); }
@@ -2373,7 +2567,11 @@ public:
Item_func_bit_or(THD *thd, Item *a, Item *b)
:Item_func_bit_operator(thd, a, b) {}
bool fix_length_and_dec();
- const char *func_name() const { return "|"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("|") };
+ return name;
+ }
enum precedence precedence() const { return BITOR_PRECEDENCE; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_bit_or>(thd, this); }
@@ -2385,7 +2583,11 @@ public:
Item_func_bit_and(THD *thd, Item *a, Item *b)
:Item_func_bit_operator(thd, a, b) {}
bool fix_length_and_dec();
- const char *func_name() const { return "&"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("&") };
+ return name;
+ }
enum precedence precedence() const { return BITAND_PRECEDENCE; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_bit_and>(thd, this); }
@@ -2394,10 +2596,14 @@ public:
class Item_func_bit_count :public Item_handled_func
{
bool check_arguments() const
- { return args[0]->check_type_can_return_int(func_name()); }
+ { return args[0]->check_type_can_return_int(func_name_cstring()); }
public:
Item_func_bit_count(THD *thd, Item *a): Item_handled_func(thd, a) {}
- const char *func_name() const { return "bit_count"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("bit_count") };
+ return name;
+ }
bool fix_length_and_dec();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_bit_count>(thd, this); }
@@ -2409,7 +2615,11 @@ public:
Item_func_shift_left(THD *thd, Item *a, Item *b)
:Item_func_bit_operator(thd, a, b) {}
bool fix_length_and_dec();
- const char *func_name() const { return "<<"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<<") };
+ return name;
+ }
enum precedence precedence() const { return SHIFT_PRECEDENCE; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_shift_left>(thd, this); }
@@ -2421,7 +2631,11 @@ public:
Item_func_shift_right(THD *thd, Item *a, Item *b)
:Item_func_bit_operator(thd, a, b) {}
bool fix_length_and_dec();
- const char *func_name() const { return ">>"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN(">>") };
+ return name;
+ }
enum precedence precedence() const { return SHIFT_PRECEDENCE; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_shift_right>(thd, this); }
@@ -2432,11 +2646,15 @@ class Item_func_bit_neg :public Item_func_bit_operator
public:
Item_func_bit_neg(THD *thd, Item *a): Item_func_bit_operator(thd, a) {}
bool fix_length_and_dec();
- const char *func_name() const { return "~"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("~") };
+ return name;
+ }
enum precedence precedence() const { return NEG_PRECEDENCE; }
void print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
args[0]->print_parenthesised(str, query_type, precedence());
}
Item *get_copy(THD *thd)
@@ -2452,7 +2670,11 @@ public:
Item_func_last_insert_id(THD *thd): Item_longlong_func(thd) {}
Item_func_last_insert_id(THD *thd, Item *a): Item_longlong_func(thd, a) {}
longlong val_int();
- const char *func_name() const { return "last_insert_id"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("last_insert_id") };
+ return name;
+ }
bool fix_length_and_dec()
{
unsigned_flag= true;
@@ -2474,15 +2696,19 @@ class Item_func_benchmark :public Item_long_func
{
bool check_arguments() const
{
- return args[0]->check_type_can_return_int(func_name()) ||
- args[1]->check_type_scalar(func_name());
+ return args[0]->check_type_can_return_int(func_name_cstring()) ||
+ args[1]->check_type_scalar(func_name_cstring());
}
public:
Item_func_benchmark(THD *thd, Item *count_expr, Item *expr):
Item_long_func(thd, count_expr, expr)
{}
longlong val_int();
- const char *func_name() const { return "benchmark"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("benchmark") };
+ return name;
+ }
bool fix_length_and_dec()
{
max_length=1;
@@ -2505,12 +2731,16 @@ void item_func_sleep_free(void);
class Item_func_sleep :public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_can_return_real(func_name()); }
+ { return args[0]->check_type_can_return_real(func_name_cstring()); }
public:
Item_func_sleep(THD *thd, Item *a): Item_long_func(thd, a) {}
bool fix_length_and_dec() { fix_char_length(1); return FALSE; }
bool const_item() const { return 0; }
- const char *func_name() const { return "sleep"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sleep") };
+ return name;
+ }
table_map used_tables() const
{
return used_tables_cache | RAND_TABLE_BIT;
@@ -2561,7 +2791,11 @@ public:
Item_func(thd), udf(udf_arg) {}
Item_udf_func(THD *thd, udf_func *udf_arg, List<Item> &list):
Item_func(thd, list), udf(udf_arg) {}
- const char *func_name() const { return udf.name(); }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ const char *tmp= udf.name();
+ return { tmp, strlen(tmp) };
+ }
enum Functype functype() const { return UDF_FUNC; }
bool fix_fields(THD *thd, Item **ref)
{
@@ -2635,7 +2869,8 @@ public:
virtual void print(String *str, enum_query_type query_type);
bool check_vcol_func_processor(void *arg)
{
- return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC);
+ return mark_unsupported_function(func_name(), "()", arg,
+ VCOL_NON_DETERMINISTIC);
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
@@ -2850,14 +3085,18 @@ class Item_func_get_lock final :public Item_func_lock
{
bool check_arguments() const
{
- return args[0]->check_type_general_purpose_string(func_name()) ||
- args[1]->check_type_can_return_real(func_name());
+ return args[0]->check_type_general_purpose_string(func_name_cstring()) ||
+ args[1]->check_type_can_return_real(func_name_cstring());
}
String value;
public:
Item_func_get_lock(THD *thd, Item *a, Item *b) :Item_func_lock(thd, a, b) {}
longlong val_int() final;
- const char *func_name() const final { return "get_lock"; }
+ LEX_CSTRING func_name_cstring() const override final
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("get_lock") };
+ return name;
+ }
bool fix_length_and_dec()
{
max_length= 1;
@@ -2875,7 +3114,11 @@ public:
Item_func_release_all_locks(THD *thd): Item_func_lock(thd)
{ unsigned_flag= 1; }
longlong val_int() final;
- const char *func_name() const final { return "release_all_locks"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("release_all_locks") };
+ return name;
+ }
Item *get_copy(THD *thd) final
{ return get_item_copy<Item_func_release_all_locks>(thd, this); }
};
@@ -2884,12 +3127,16 @@ public:
class Item_func_release_lock final :public Item_func_lock
{
bool check_arguments() const
- { return args[0]->check_type_general_purpose_string(func_name()); }
+ { return args[0]->check_type_general_purpose_string(func_name_cstring()); }
String value;
public:
Item_func_release_lock(THD *thd, Item *a): Item_func_lock(thd, a) {}
longlong val_int() final;
- const char *func_name() const { return "release_lock"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("release_lock") };
+ return name;
+ }
bool fix_length_and_dec()
{
max_length= 1;
@@ -2908,10 +3155,10 @@ class Item_master_pos_wait :public Item_longlong_func
bool check_arguments() const
{
return
- args[0]->check_type_general_purpose_string(func_name()) ||
- args[1]->check_type_can_return_int(func_name()) ||
- (arg_count > 2 && args[2]->check_type_can_return_int(func_name())) ||
- (arg_count > 3 && args[3]->check_type_general_purpose_string(func_name()));
+ args[0]->check_type_general_purpose_string(func_name_cstring()) ||
+ args[1]->check_type_can_return_int(func_name_cstring()) ||
+ (arg_count > 2 && args[2]->check_type_can_return_int(func_name_cstring())) ||
+ (arg_count > 3 && args[3]->check_type_general_purpose_string(func_name_cstring()));
}
String value;
public:
@@ -2922,7 +3169,11 @@ public:
Item_master_pos_wait(THD *thd, Item *a, Item *b, Item *c, Item *d):
Item_longlong_func(thd, a, b, c, d) {}
longlong val_int();
- const char *func_name() const { return "master_pos_wait"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("master_pos_wait") };
+ return name;
+ }
bool fix_length_and_dec()
{
max_length=21;
@@ -2942,8 +3193,8 @@ class Item_master_gtid_wait :public Item_long_func
{
bool check_arguments() const
{
- return args[0]->check_type_general_purpose_string(func_name()) ||
- (arg_count > 1 && args[1]->check_type_can_return_real(func_name()));
+ return args[0]->check_type_general_purpose_string(func_name_cstring()) ||
+ (arg_count > 1 && args[1]->check_type_can_return_real(func_name_cstring()));
}
String value;
public:
@@ -2952,7 +3203,11 @@ public:
Item_master_gtid_wait(THD *thd, Item *a, Item *b)
:Item_long_func(thd, a, b) {}
longlong val_int();
- const char *func_name() const { return "master_gtid_wait"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("master_gtid_wait") };
+ return name;
+ }
bool fix_length_and_dec() { max_length=2; return FALSE; }
bool check_vcol_func_processor(void *arg)
{
@@ -3060,7 +3315,11 @@ public:
void print(String *str, enum_query_type query_type);
enum precedence precedence() const { return ASSIGN_PRECEDENCE; }
void print_as_stmt(String *str, enum_query_type query_type);
- const char *func_name() const { return "set_user_var"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("set_user_var") };
+ return name;
+ }
int save_in_field(Field *field, bool no_conversions,
bool can_use_result_field);
int save_in_field(Field *field, bool no_conversions)
@@ -3098,7 +3357,11 @@ public:
We must always return variables as strings to guard against selects of type
select @t1:=1,@t1,@t:="hello",@t from foo where (@t1:= t2.b)
*/
- const char *func_name() const { return "get_user_var"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("get_user_var") };
+ return name;
+ }
bool const_item() const;
table_map used_tables() const
{ return const_item() ? 0 : RAND_TABLE_BIT; }
@@ -3230,7 +3493,11 @@ public:
return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate);
}
/* TODO: fix to support views */
- const char *func_name() const { return "get_system_var"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("get_system_var") };
+ return name;
+ }
/**
Indicates whether this system variable is written to the binlog or not.
@@ -3280,7 +3547,11 @@ public:
}
bool is_expensive_processor(void *arg) { return TRUE; }
enum Functype functype() const { return FT_FUNC; }
- const char *func_name() const { return "match"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("match") };
+ return name;
+ }
bool eval_not_null_tables(void *opt_arg)
{
not_null_tables_cache= 0;
@@ -3295,7 +3566,7 @@ public:
/* The following should be safe, even if we compare doubles */
longlong val_int() { DBUG_ASSERT(fixed()); return val_real() != 0.0; }
double val_real();
- virtual void print(String *str, enum_query_type query_type);
+ void print(String *str, enum_query_type query_type) override;
bool fix_index();
bool init_search(THD *thd, bool no_order);
@@ -3349,7 +3620,11 @@ public:
Item_func_bit_xor(THD *thd, Item *a, Item *b)
:Item_func_bit_operator(thd, a, b) {}
bool fix_length_and_dec();
- const char *func_name() const { return "^"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("^") };
+ return name;
+ }
enum precedence precedence() const { return BITXOR_PRECEDENCE; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_bit_xor>(thd, this); }
@@ -3358,12 +3633,16 @@ public:
class Item_func_is_free_lock :public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_general_purpose_string(func_name()); }
+ { return args[0]->check_type_general_purpose_string(func_name_cstring()); }
String value;
public:
Item_func_is_free_lock(THD *thd, Item *a): Item_long_func(thd, a) {}
longlong val_int();
- const char *func_name() const { return "is_free_lock"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("is_free_lock") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -3382,12 +3661,16 @@ public:
class Item_func_is_used_lock :public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_general_purpose_string(func_name()); }
+ { return args[0]->check_type_general_purpose_string(func_name_cstring()); }
String value;
public:
Item_func_is_used_lock(THD *thd, Item *a): Item_long_func(thd, a) {}
longlong val_int();
- const char *func_name() const { return "is_used_lock"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("is_used_lock") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0; max_length=10;
@@ -3444,7 +3727,11 @@ class Item_func_row_count :public Item_longlong_func
public:
Item_func_row_count(THD *thd): Item_longlong_func(thd) {}
longlong val_int();
- const char *func_name() const { return "row_count"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("row_count") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals= 0;
@@ -3498,7 +3785,7 @@ public:
void cleanup();
- const char *func_name() const;
+ LEX_CSTRING func_name_cstring() const override;
const Type_handler *type_handler() const;
@@ -3614,7 +3901,11 @@ class Item_func_found_rows :public Item_longlong_func
public:
Item_func_found_rows(THD *thd): Item_longlong_func(thd) {}
longlong val_int();
- const char *func_name() const { return "found_rows"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("found_rows") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals= 0;
@@ -3635,10 +3926,14 @@ class Item_func_oracle_sql_rowcount :public Item_longlong_func
public:
Item_func_oracle_sql_rowcount(THD *thd): Item_longlong_func(thd) {}
longlong val_int();
- const char *func_name() const { return "SQL%ROWCOUNT"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("SQL%ROWCOUNT") };
+ return name;
+ }
void print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
}
bool check_vcol_func_processor(void *arg)
{
@@ -3654,10 +3949,14 @@ class Item_func_sqlcode: public Item_long_func
public:
Item_func_sqlcode(THD *thd): Item_long_func(thd) { }
longlong val_int();
- const char *func_name() const { return "SQLCODE"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("SQLCODE") };
+ return name;
+ }
void print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
}
bool check_vcol_func_processor(void *arg)
{
@@ -3681,7 +3980,11 @@ class Item_func_uuid_short :public Item_longlong_func
{
public:
Item_func_uuid_short(THD *thd): Item_longlong_func(thd) {}
- const char *func_name() const { return "uuid_short"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("uuid_short") };
+ return name;
+ }
longlong val_int();
bool const_item() const { return false; }
bool fix_length_and_dec()
@@ -3689,7 +3992,8 @@ public:
table_map used_tables() const { return RAND_TABLE_BIT; }
bool check_vcol_func_processor(void *arg)
{
- return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC);
+ return mark_unsupported_function(func_name(), "()", arg,
+ VCOL_NON_DETERMINISTIC);
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_uuid_short>(thd, this); }
@@ -3709,7 +4013,11 @@ public:
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate);
bool val_native(THD *thd, Native *);
bool fix_length_and_dec();
- const char *func_name() const { return "last_value"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("last_value") };
+ return name;
+ }
const Type_handler *type_handler() const { return last_value->type_handler(); }
bool eval_not_null_tables(void *)
{
@@ -3743,7 +4051,11 @@ public:
Item_func_nextval(THD *thd, TABLE_LIST *table_list_arg):
Item_longlong_func(thd), table_list(table_list_arg) {}
longlong val_int();
- const char *func_name() const { return "nextval"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("nextval") };
+ return name;
+ }
bool fix_length_and_dec()
{
unsigned_flag= 0;
@@ -3788,7 +4100,11 @@ public:
Item_func_lastval(THD *thd, TABLE_LIST *table_list_arg):
Item_func_nextval(thd, table_list_arg) {}
longlong val_int();
- const char *func_name() const { return "lastval"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("lastval") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_lastval>(thd, this); }
};
@@ -3808,7 +4124,11 @@ public:
nextval(nextval_arg), round(round_arg), is_used(is_used_arg)
{}
longlong val_int();
- const char *func_name() const { return "setval"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("setval") };
+ return name;
+ }
void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_setval>(thd, this); }
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 8247fae6226..4bdb0b85cd0 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -293,7 +293,7 @@ String *Item_func_as_geojson::val_str_ascii(String *str)
goto error;
}
- if ((geom->as_json(str, max_dec, &dummy) || str->append("}", 1)))
+ if ((geom->as_json(str, max_dec, &dummy) || str->append('}')))
goto error;
return str;
@@ -1127,28 +1127,28 @@ Item_func_spatial_rel::get_mm_leaf(RANGE_OPT_PARAM *param,
}
-const char *Item_func_spatial_mbr_rel::func_name() const
+LEX_CSTRING Item_func_spatial_mbr_rel::func_name_cstring() const
{
switch (spatial_rel) {
case SP_CONTAINS_FUNC:
- return "mbrcontains";
+ return { STRING_WITH_LEN("mbrcontains") };
case SP_WITHIN_FUNC:
- return "mbrwithin";
+ return { STRING_WITH_LEN("mbrwithin") } ;
case SP_EQUALS_FUNC:
- return "mbrequals";
+ return { STRING_WITH_LEN("mbrequals") };
case SP_DISJOINT_FUNC:
- return "mbrdisjoint";
+ return { STRING_WITH_LEN("mbrdisjoint") };
case SP_INTERSECTS_FUNC:
- return "mbrintersects";
+ return { STRING_WITH_LEN("mbrintersects") };
case SP_TOUCHES_FUNC:
- return "mbrtouches";
+ return { STRING_WITH_LEN("mbrtouches") };
case SP_CROSSES_FUNC:
- return "mbrcrosses";
+ return { STRING_WITH_LEN("mbrcrosses") };
case SP_OVERLAPS_FUNC:
- return "mbroverlaps";
+ return { STRING_WITH_LEN("mbroverlaps") };
default:
DBUG_ASSERT(0); // Should never happened
- return "mbrsp_unknown";
+ return { STRING_WITH_LEN("mbrsp_unknown") };
}
}
@@ -1198,28 +1198,28 @@ longlong Item_func_spatial_mbr_rel::val_int()
}
-const char *Item_func_spatial_precise_rel::func_name() const
+LEX_CSTRING Item_func_spatial_precise_rel::func_name_cstring() const
{
switch (spatial_rel) {
case SP_CONTAINS_FUNC:
- return "st_contains";
+ return { STRING_WITH_LEN("st_contains") };
case SP_WITHIN_FUNC:
- return "st_within";
+ return { STRING_WITH_LEN("st_within") };
case SP_EQUALS_FUNC:
- return "st_equals";
+ return { STRING_WITH_LEN("st_equals") };
case SP_DISJOINT_FUNC:
- return "st_disjoint";
+ return { STRING_WITH_LEN("st_disjoint") };
case SP_INTERSECTS_FUNC:
- return "st_intersects";
+ return { STRING_WITH_LEN("st_intersects") };
case SP_TOUCHES_FUNC:
- return "st_touches";
+ return { STRING_WITH_LEN("st_touches") };
case SP_CROSSES_FUNC:
- return "st_crosses";
+ return { STRING_WITH_LEN("st_crosses") };
case SP_OVERLAPS_FUNC:
- return "st_overlaps";
+ return { STRING_WITH_LEN("st_overlaps") } ;
default:
DBUG_ASSERT(0); // Should never happened
- return "sp_unknown";
+ return { STRING_WITH_LEN("sp_unknown") };
}
}
@@ -1591,20 +1591,20 @@ exit:
}
-const char *Item_func_spatial_operation::func_name() const
+LEX_CSTRING Item_func_spatial_operation::func_name_cstring() const
{
switch (spatial_op) {
case Gcalc_function::op_intersection:
- return "st_intersection";
+ return { STRING_WITH_LEN("st_intersection") };
case Gcalc_function::op_difference:
- return "st_difference";
+ return { STRING_WITH_LEN("st_difference") };
case Gcalc_function::op_union:
- return "st_union";
+ return { STRING_WITH_LEN("st_union") };
case Gcalc_function::op_symdifference:
- return "st_symdifference";
+ return { STRING_WITH_LEN("st_symdifference") };
default:
DBUG_ASSERT(0); // Should never happen
- return "sp_unknown";
+ return { STRING_WITH_LEN("sp_unknown") };
}
}
diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h
index 476bee672ff..3166a22c136 100644
--- a/sql/item_geofunc.h
+++ b/sql/item_geofunc.h
@@ -57,7 +57,7 @@ protected:
bool check_arguments() const
{
DBUG_ASSERT(arg_count == 1);
- return Type_handler_geometry::check_type_geom_or_binary(func_name(),
+ return Type_handler_geometry::check_type_geom_or_binary(func_name_cstring(),
args[0]);
}
public:
@@ -74,7 +74,7 @@ class Item_long_func_args_geometry: public Item_long_func
bool check_arguments() const
{
DBUG_ASSERT(arg_count == 1);
- return Type_handler_geometry::check_type_geom_or_binary(func_name(),
+ return Type_handler_geometry::check_type_geom_or_binary(func_name_cstring(),
args[0]);
}
protected:
@@ -95,7 +95,7 @@ protected:
bool check_arguments() const
{
DBUG_ASSERT(arg_count == 1);
- return Type_handler_geometry::check_type_geom_or_binary(func_name(),
+ return Type_handler_geometry::check_type_geom_or_binary(func_name_cstring(),
args[0]);
}
public:
@@ -113,7 +113,7 @@ protected:
bool check_arguments() const
{
DBUG_ASSERT(arg_count >= 1);
- return Type_handler_geometry::check_type_geom_or_binary(func_name(),
+ return Type_handler_geometry::check_type_geom_or_binary(func_name_cstring(),
args[0]);
}
public:
@@ -135,7 +135,7 @@ protected:
bool check_arguments() const
{
DBUG_ASSERT(arg_count >= 1);
- return Type_handler_geometry::check_type_geom_or_binary(func_name(),
+ return Type_handler_geometry::check_type_geom_or_binary(func_name_cstring(),
args[0]);
}
public:
@@ -153,7 +153,7 @@ protected:
bool check_arguments() const
{
DBUG_ASSERT(arg_count >= 1);
- return Type_handler_geometry::check_type_geom_or_binary(func_name(),
+ return Type_handler_geometry::check_type_geom_or_binary(func_name_cstring(),
args[0]);
}
public:
@@ -173,7 +173,7 @@ protected:
bool check_arguments() const
{
DBUG_ASSERT(arg_count >= 2);
- return Type_handler_geometry::check_types_geom_or_binary(func_name(),
+ return Type_handler_geometry::check_types_geom_or_binary(func_name_cstring(),
args, 0, 2);
}
public:
@@ -192,7 +192,7 @@ protected:
bool check_arguments() const
{
DBUG_ASSERT(arg_count >= 2);
- return Type_handler_geometry::check_types_geom_or_binary(func_name(),
+ return Type_handler_geometry::check_types_geom_or_binary(func_name_cstring(),
args, 0, 2);
}
public:
@@ -205,14 +205,18 @@ class Item_func_geometry_from_text: public Item_geometry_func
{
bool check_arguments() const
{
- return args[0]->check_type_general_purpose_string(func_name()) ||
+ return args[0]->check_type_general_purpose_string(func_name_cstring()) ||
check_argument_types_can_return_int(1, MY_MIN(2, arg_count));
}
public:
Item_func_geometry_from_text(THD *thd, Item *a): Item_geometry_func(thd, a) {}
Item_func_geometry_from_text(THD *thd, Item *a, Item *srid):
Item_geometry_func(thd, a, srid) {}
- const char *func_name() const { return "st_geometryfromtext"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_geometryfromtext") };
+ return name;
+ }
String *val_str(String *);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_geometry_from_text>(thd, this); }
@@ -223,14 +227,18 @@ class Item_func_geometry_from_wkb: public Item_geometry_func
bool check_arguments() const
{
return
- Type_handler_geometry::check_type_geom_or_binary(func_name(), args[0]) ||
+ Type_handler_geometry::check_type_geom_or_binary(func_name_cstring(), args[0]) ||
check_argument_types_can_return_int(1, MY_MIN(2, arg_count));
}
public:
Item_func_geometry_from_wkb(THD *thd, Item *a): Item_geometry_func(thd, a) {}
Item_func_geometry_from_wkb(THD *thd, Item *a, Item *srid):
Item_geometry_func(thd, a, srid) {}
- const char *func_name() const { return "st_geometryfromwkb"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_geometryfromwkb") };
+ return name;
+ }
String *val_str(String *);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_geometry_from_wkb>(thd, this); }
@@ -243,7 +251,7 @@ class Item_func_geometry_from_json: public Item_geometry_func
bool check_arguments() const
{
// TODO: check with Alexey, for better args[1] and args[2] type control
- return args[0]->check_type_general_purpose_string(func_name()) ||
+ return args[0]->check_type_general_purpose_string(func_name_cstring()) ||
check_argument_types_traditional_scalar(1, MY_MIN(3, arg_count));
}
public:
@@ -252,7 +260,11 @@ public:
Item_geometry_func(thd, js, opt) {}
Item_func_geometry_from_json(THD *thd, Item *js, Item *opt, Item *srid):
Item_geometry_func(thd, js, opt, srid) {}
- const char *func_name() const { return "st_geomfromgeojson"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_geomfromgeojson") };
+ return name;
+ }
String *val_str(String *);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_geometry_from_json>(thd, this); }
@@ -264,7 +276,11 @@ class Item_func_as_wkt: public Item_str_ascii_func_args_geometry
public:
Item_func_as_wkt(THD *thd, Item *a)
:Item_str_ascii_func_args_geometry(thd, a) {}
- const char *func_name() const { return "st_astext"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_astext") };
+ return name;
+ }
String *val_str_ascii(String *);
bool fix_length_and_dec();
Item *get_copy(THD *thd)
@@ -276,7 +292,11 @@ class Item_func_as_wkb: public Item_binary_func_args_geometry
public:
Item_func_as_wkb(THD *thd, Item *a)
:Item_binary_func_args_geometry(thd, a) {}
- const char *func_name() const { return "st_aswkb"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_aswkb") };
+ return name;
+ }
String *val_str(String *);
const Type_handler *type_handler() const { return &type_handler_long_blob; }
bool fix_length_and_dec()
@@ -307,7 +327,11 @@ public:
:Item_str_ascii_func_args_geometry(thd, js, max_dec_digits) {}
Item_func_as_geojson(THD *thd, Item *js, Item *max_dec_digits, Item *opt)
:Item_str_ascii_func_args_geometry(thd, js, max_dec_digits, opt) {}
- const char *func_name() const { return "st_asgeojson"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_asgeojson") };
+ return name;
+ }
bool fix_length_and_dec();
String *val_str_ascii(String *);
Item *get_copy(THD *thd)
@@ -321,7 +345,11 @@ public:
Item_func_geometry_type(THD *thd, Item *a)
:Item_str_ascii_func_args_geometry(thd, a) {}
String *val_str_ascii(String *);
- const char *func_name() const { return "st_geometrytype"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_geometrytype") };
+ return name;
+ }
bool fix_length_and_dec()
{
// "GeometryCollection" is the longest
@@ -362,7 +390,11 @@ public:
:Item_geometry_func_args_geometry(thd, a),
res_heap(8192, sizeof(ch_node))
{}
- const char *func_name() const { return "st_convexhull"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_convexhull") };
+ return name;
+ }
String *val_str(String *);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_convexhull>(thd, this); }
@@ -374,7 +406,11 @@ class Item_func_centroid: public Item_geometry_func_args_geometry
public:
Item_func_centroid(THD *thd, Item *a)
:Item_geometry_func_args_geometry(thd, a) {}
- const char *func_name() const { return "st_centroid"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_centroid") };
+ return name;
+ }
String *val_str(String *);
const Type_handler *type_handler() const
{
@@ -389,7 +425,11 @@ class Item_func_envelope: public Item_geometry_func_args_geometry
public:
Item_func_envelope(THD *thd, Item *a)
:Item_geometry_func_args_geometry(thd, a) {}
- const char *func_name() const { return "st_envelope"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_envelope") };
+ return name;
+ }
String *val_str(String *);
const Type_handler *type_handler() const
{
@@ -427,7 +467,11 @@ class Item_func_boundary: public Item_geometry_func_args_geometry
public:
Item_func_boundary(THD *thd, Item *a)
:Item_geometry_func_args_geometry(thd, a) {}
- const char *func_name() const { return "st_boundary"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_boundary") };
+ return name;
+ }
String *val_str(String *);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_boundary>(thd, this); }
@@ -442,7 +486,11 @@ public:
Item_func_point(THD *thd, Item *a, Item *b): Item_geometry_func(thd, a, b) {}
Item_func_point(THD *thd, Item *a, Item *b, Item *srid):
Item_geometry_func(thd, a, b, srid) {}
- const char *func_name() const { return "point"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("point") };
+ return name;
+ }
String *val_str(String *);
const Type_handler *type_handler() const
{
@@ -458,19 +506,22 @@ class Item_func_spatial_decomp: public Item_geometry_func_args_geometry
public:
Item_func_spatial_decomp(THD *thd, Item *a, Item_func::Functype ft):
Item_geometry_func_args_geometry(thd, a) { decomp_func = ft; }
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- switch (decomp_func)
- {
+ static LEX_CSTRING startpoint= {STRING_WITH_LEN("st_startpoint") };
+ static LEX_CSTRING endpoint= {STRING_WITH_LEN("st_endpoint") };
+ static LEX_CSTRING exteriorring= {STRING_WITH_LEN("st_exteriorring") };
+ static LEX_CSTRING unknown= {STRING_WITH_LEN("spatial_decomp_unknown") };
+ switch (decomp_func) {
case SP_STARTPOINT:
- return "st_startpoint";
+ return startpoint;
case SP_ENDPOINT:
- return "st_endpoint";
+ return endpoint;
case SP_EXTERIORRING:
- return "st_exteriorring";
+ return exteriorring;
default:
DBUG_ASSERT(0); // Should never happened
- return "spatial_decomp_unknown";
+ return unknown;
}
}
String *val_str(String *);
@@ -484,26 +535,30 @@ class Item_func_spatial_decomp_n: public Item_geometry_func_args_geometry
bool check_arguments() const
{
return Item_geometry_func_args_geometry::check_arguments() ||
- args[1]->check_type_can_return_int(func_name());
+ args[1]->check_type_can_return_int(func_name_cstring());
}
public:
Item_func_spatial_decomp_n(THD *thd, Item *a, Item *b, Item_func::Functype ft)
:Item_geometry_func_args_geometry(thd, a, b),
decomp_func_n(ft)
{ }
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- switch (decomp_func_n)
- {
+ static LEX_CSTRING pointn= {STRING_WITH_LEN("st_pointn") };
+ static LEX_CSTRING geometryn= {STRING_WITH_LEN("st_geometryn") };
+ static LEX_CSTRING interiorringn= {STRING_WITH_LEN("st_interiorringn") };
+ static LEX_CSTRING unknown= {STRING_WITH_LEN("spatial_decomp_unknown") };
+
+ switch (decomp_func_n) {
case SP_POINTN:
- return "st_pointn";
+ return pointn;
case SP_GEOMETRYN:
- return "st_geometryn";
+ return geometryn;
case SP_INTERIORRINGN:
- return "st_interiorringn";
+ return interiorringn;
default:
DBUG_ASSERT(0); // Should never happened
- return "spatial_decomp_n_unknown";
+ return unknown;
}
}
String *val_str(String *);
@@ -515,7 +570,7 @@ class Item_func_spatial_collection: public Item_geometry_func
{
bool check_arguments() const
{
- return Type_handler_geometry::check_types_geom_or_binary(func_name(), args,
+ return Type_handler_geometry::check_types_geom_or_binary(func_name_cstring(), args,
0, arg_count);
}
enum Geometry::wkbType coll_type;
@@ -562,7 +617,11 @@ public:
{
return &type_handler_geometrycollection;
}
- const char *func_name() const { return "geometrycollection"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("geometrycollection") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_geometrycollection>(thd, this); }
};
@@ -577,7 +636,11 @@ public:
Geometry::wkb_point)
{ }
const Type_handler *type_handler() const { return &type_handler_linestring; }
- const char *func_name() const { return "linestring"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("linestring") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_linestring>(thd, this); }
};
@@ -592,7 +655,11 @@ public:
Geometry::wkb_linestring)
{ }
const Type_handler *type_handler() const { return &type_handler_polygon; }
- const char *func_name() const { return "polygon"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("polygon") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_polygon>(thd, this); }
};
@@ -610,7 +677,11 @@ public:
{
return &type_handler_multilinestring;
}
- const char *func_name() const { return "multilinestring"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("multilinestring") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_multilinestring>(thd, this); }
};
@@ -628,7 +699,11 @@ public:
{
return &type_handler_multipoint;
}
- const char *func_name() const { return "multipoint"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("multipoint") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_multipoint>(thd, this); }
};
@@ -646,7 +721,11 @@ public:
{
return &type_handler_multipolygon;
}
- const char *func_name() const { return "multipolygon"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("multipolygon") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_multipolygon>(thd, this); }
};
@@ -668,7 +747,7 @@ protected:
bool check_arguments() const
{
DBUG_ASSERT(arg_count >= 2);
- return Type_handler_geometry::check_types_geom_or_binary(func_name(),
+ return Type_handler_geometry::check_types_geom_or_binary(func_name_cstring(),
args, 0, 2);
}
public:
@@ -710,7 +789,7 @@ public:
Item_func_spatial_rel(thd, a, b, sp_rel)
{ }
longlong val_int();
- const char *func_name() const;
+ LEX_CSTRING func_name_cstring() const override;
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_spatial_mbr_rel>(thd, this); }
};
@@ -726,7 +805,7 @@ public:
Item_func_spatial_rel(thd, a, b, sp_rel), collector()
{ }
longlong val_int();
- const char *func_name() const;
+ LEX_CSTRING func_name_cstring() const override;
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_spatial_precise_rel>(thd, this); }
};
@@ -741,14 +820,18 @@ class Item_func_spatial_relate: public Item_bool_func_args_geometry_geometry
bool check_arguments() const
{
return Item_bool_func_args_geometry_geometry::check_arguments() ||
- args[2]->check_type_general_purpose_string(func_name());
+ args[2]->check_type_general_purpose_string(func_name_cstring());
}
public:
Item_func_spatial_relate(THD *thd, Item *a, Item *b, Item *matrix):
Item_bool_func_args_geometry_geometry(thd, a, b, matrix)
{ }
longlong val_int();
- const char *func_name() const { return "st_relate"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_relate") };
+ return name;
+ }
bool need_parentheses_in_default() { return false; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_spatial_relate>(thd, this); }
@@ -764,7 +847,7 @@ class Item_func_spatial_operation: public Item_geometry_func
bool check_arguments() const
{
DBUG_ASSERT(arg_count >= 2);
- return Type_handler_geometry::check_types_geom_or_binary(func_name(),
+ return Type_handler_geometry::check_types_geom_or_binary(func_name_cstring(),
args, 0, 2);
}
public:
@@ -782,7 +865,7 @@ public:
{}
virtual ~Item_func_spatial_operation();
String *val_str(String *);
- const char *func_name() const;
+ LEX_CSTRING func_name_cstring() const override;
virtual inline void print(String *str, enum_query_type query_type)
{
Item_func::print(str, query_type);
@@ -797,7 +880,7 @@ class Item_func_buffer: public Item_geometry_func_args_geometry
bool check_arguments() const
{
return Item_geometry_func_args_geometry::check_arguments() ||
- args[1]->check_type_can_return_real(func_name());
+ args[1]->check_type_can_return_real(func_name_cstring());
}
protected:
class Transporter : public Gcalc_operation_transporter
@@ -842,7 +925,11 @@ protected:
public:
Item_func_buffer(THD *thd, Item *obj, Item *distance)
:Item_geometry_func_args_geometry(thd, obj, distance) {}
- const char *func_name() const { return "st_buffer"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_buffer") };
+ return name;
+ }
String *val_str(String *);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_buffer>(thd, this); }
@@ -855,7 +942,11 @@ public:
Item_func_isempty(THD *thd, Item *a)
:Item_bool_func_args_geometry(thd, a) {}
longlong val_int() override;
- const char *func_name() const { return "st_isempty"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_isempty") };
+ return name;
+ }
bool fix_length_and_dec() override
{ set_maybe_null(); return FALSE; }
bool need_parentheses_in_default() override { return false; }
@@ -873,7 +964,11 @@ public:
Item_func_issimple(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
longlong val_int();
- const char *func_name() const { return "st_issimple"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_issimple") };
+ return name;
+ }
bool fix_length_and_dec() { decimals=0; max_length=2; return FALSE; }
decimal_digits_t decimal_precision() const override { return 1; }
Item *get_copy(THD *thd)
@@ -886,7 +981,11 @@ public:
Item_func_isclosed(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
longlong val_int();
- const char *func_name() const { return "st_isclosed"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_isclosed") };
+ return name;
+ }
bool fix_length_and_dec() { decimals=0; max_length=2; return FALSE; }
decimal_digits_t decimal_precision() const override { return 1; }
Item *get_copy(THD *thd)
@@ -898,7 +997,11 @@ class Item_func_isring: public Item_func_issimple
public:
Item_func_isring(THD *thd, Item *a): Item_func_issimple(thd, a) {}
longlong val_int();
- const char *func_name() const { return "st_isring"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_isring") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_isring>(thd, this); }
};
@@ -909,7 +1012,11 @@ public:
Item_func_dimension(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
longlong val_int() override;
- const char *func_name() const { return "st_dimension"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_dimension") };
+ return name;
+ }
bool fix_length_and_dec() override
{ max_length= 10; set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) override
@@ -922,7 +1029,11 @@ class Item_func_x: public Item_real_func_args_geometry
public:
Item_func_x(THD *thd, Item *a): Item_real_func_args_geometry(thd, a) {}
double val_real();
- const char *func_name() const { return "st_x"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_x") };
+ return name;
+ }
bool fix_length_and_dec()
{
if (Item_real_func::fix_length_and_dec())
@@ -940,7 +1051,11 @@ class Item_func_y: public Item_real_func_args_geometry
public:
Item_func_y(THD *thd, Item *a): Item_real_func_args_geometry(thd, a) {}
double val_real();
- const char *func_name() const { return "st_y"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_y") };
+ return name;
+ }
bool fix_length_and_dec()
{
if (Item_real_func::fix_length_and_dec())
@@ -959,7 +1074,11 @@ public:
Item_func_numgeometries(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
longlong val_int() override;
- const char *func_name() const { return "st_numgeometries"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_numgeometries") };
+ return name;
+ }
bool fix_length_and_dec() override
{ max_length= 10; set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) override
@@ -973,7 +1092,11 @@ public:
Item_func_numinteriorring(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
longlong val_int() override;
- const char *func_name() const { return "st_numinteriorrings"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_numinteriorrings") };
+ return name;
+ }
bool fix_length_and_dec() override
{ max_length= 10; set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) override
@@ -987,7 +1110,11 @@ public:
Item_func_numpoints(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
longlong val_int() override;
- const char *func_name() const { return "st_numpoints"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_numpoints") };
+ return name;
+ }
bool fix_length_and_dec() override
{ max_length= 10; set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) override
@@ -1000,7 +1127,11 @@ class Item_func_area: public Item_real_func_args_geometry
public:
Item_func_area(THD *thd, Item *a): Item_real_func_args_geometry(thd, a) {}
double val_real();
- const char *func_name() const { return "st_area"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_area") };
+ return name;
+ }
bool fix_length_and_dec()
{
if (Item_real_func::fix_length_and_dec())
@@ -1020,7 +1151,11 @@ public:
Item_func_glength(THD *thd, Item *a)
:Item_real_func_args_geometry(thd, a) {}
double val_real();
- const char *func_name() const { return "st_length"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_length") };
+ return name;
+ }
bool fix_length_and_dec()
{
if (Item_real_func::fix_length_and_dec())
@@ -1039,7 +1174,11 @@ public:
Item_func_srid(THD *thd, Item *a)
:Item_long_func_args_geometry(thd, a) {}
longlong val_int() override;
- const char *func_name() const { return "srid"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("srid") };
+ return name;
+ }
bool fix_length_and_dec() override
{ max_length= 10; set_maybe_null(); return FALSE; }
Item *get_copy(THD *thd) override
@@ -1058,7 +1197,11 @@ public:
Item_func_distance(THD *thd, Item *a, Item *b)
:Item_real_func_args_geometry_geometry(thd, a, b) {}
double val_real();
- const char *func_name() const { return "st_distance"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_distance") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_distance>(thd, this); }
};
@@ -1072,7 +1215,11 @@ public:
Item_func_sphere_distance(THD *thd, List<Item> &list):
Item_real_func(thd, list) {}
double val_real();
- const char *func_name() const { return "st_distance_sphere"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_distance_sphere") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_sphere_distance>(thd, this); }
};
@@ -1087,7 +1234,11 @@ class Item_func_pointonsurface: public Item_geometry_func_args_geometry
public:
Item_func_pointonsurface(THD *thd, Item *a)
:Item_geometry_func_args_geometry(thd, a) {}
- const char *func_name() const { return "st_pointonsurface"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_pointonsurface") };
+ return name;
+ }
String *val_str(String *);
const Type_handler *type_handler() const
{
@@ -1105,7 +1256,11 @@ class Item_func_gis_debug: public Item_long_func
Item_func_gis_debug(THD *thd, Item *a): Item_long_func(thd, a)
{ null_value= false; }
bool fix_length_and_dec() { fix_char_length(10); return FALSE; }
- const char *func_name() const { return "st_gis_debug"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("st_gis_debug") };
+ return name;
+ }
longlong val_int();
bool check_vcol_func_processor(void *arg)
{
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index 67a5a8fec00..5a3bb446356 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -118,7 +118,7 @@ static const char tab_arr[TAB_SIZE_LIMIT+1]= " ";
static int append_tab(String *js, int depth, int tab_size)
{
- if (js->append("\n", 1))
+ if (js->append('\n'))
return 1;
for (int i=0; i<depth; i++)
{
@@ -183,7 +183,7 @@ static int json_nice(json_engine_t *je, String *nice_js,
append_tab(nice_js, depth, tab_size))
goto error;
- nice_js->append("\"", 1);
+ nice_js->append('"');
append_simple(nice_js, key_start, key_end - key_start);
nice_js->append(colon, colon_len);
}
@@ -591,9 +591,9 @@ String *Item_func_json_quote::val_str(String *str)
str->length(0);
str->set_charset(&my_charset_utf8mb4_bin);
- if (str->append("\"", 1) ||
+ if (str->append('"') ||
st_append_escaped(str, s) ||
- str->append("\"", 1))
+ str->append('"'))
{
/* Report an error. */
null_value= 1;
@@ -805,7 +805,7 @@ String *Item_func_json_extract::read_json(String *str,
str->set_charset(js->charset());
str->length(0);
- if (possible_multiple_values && str->append("[", 1))
+ if (possible_multiple_values && str->append('['))
goto error;
}
@@ -867,7 +867,7 @@ String *Item_func_json_extract::read_json(String *str,
goto return_null;
}
- if (possible_multiple_values && str->append("]", 1))
+ if (possible_multiple_values && str->append(']'))
goto error; /* Out of memory. */
js= str;
@@ -1485,15 +1485,15 @@ static int append_json_value(String *str, Item *item, String *tmp_val)
if (item->result_type() == STRING_RESULT)
{
- return str->append("\"", 1) ||
+ return str->append('"') ||
st_append_escaped(str, sv) ||
- str->append("\"", 1);
+ str->append('"');
}
return st_append_escaped(str, sv);
}
append_null:
- return str->append("null", 4);
+ return str->append(STRING_WITH_LEN("null"));
}
@@ -1531,15 +1531,15 @@ static int append_json_value_from_field(String *str,
if (i->result_type() == STRING_RESULT)
{
- return str->append("\"", 1) ||
+ return str->append('"') ||
st_append_escaped(str, sv) ||
- str->append("\"", 1);
+ str->append('"');
}
return st_append_escaped(str, sv);
}
append_null:
- return str->append("null", 4);
+ return str->append(STRING_WITH_LEN("null"));
}
@@ -1549,7 +1549,7 @@ static int append_json_keyname(String *str, Item *item, String *tmp_val)
if (item->null_value)
goto append_null;
- return str->append("\"", 1) ||
+ return str->append('"') ||
st_append_escaped(str, sv) ||
str->append("\": ", 3);
@@ -1595,7 +1595,7 @@ String *Item_func_json_array::val_str(String *str)
str->length(0);
str->set_charset(collation.collation);
- if (str->append("[", 1) ||
+ if (str->append('[') ||
((arg_count > 0) && append_json_value(str, args[0], &tmp_val)))
goto err_return;
@@ -1606,7 +1606,7 @@ String *Item_func_json_array::val_str(String *str)
goto err_return;
}
- if (str->append("]", 1))
+ if (str->append(']'))
goto err_return;
if (result_limit == 0)
@@ -1735,11 +1735,11 @@ String *Item_func_json_array_append::val_str(String *str)
else
c_to= je.value_end;
- if (str->append("[", 1) ||
+ if (str->append('[') ||
str->append((const char *) c_from, c_to - c_from) ||
str->append(", ", 2) ||
append_json_value(str, args[n_arg+1], &tmp_val) ||
- str->append("]", 1) ||
+ str->append(']') ||
str->append((const char *) je.s.c_str,
js->end() - (const char *) je.s.c_str))
goto return_null; /* Out of memory. */
@@ -1925,7 +1925,7 @@ String *Item_func_json_object::val_str(String *str)
str->length(0);
str->set_charset(collation.collation);
- if (str->append("{", 1) ||
+ if (str->append('{') ||
(arg_count > 0 &&
(append_json_keyname(str, args[0], &tmp_val) ||
append_json_value(str, args[1], &tmp_val))))
@@ -1939,7 +1939,7 @@ String *Item_func_json_object::val_str(String *str)
goto err_return;
}
- if (str->append("}", 1))
+ if (str->append('}'))
goto err_return;
if (result_limit == 0)
@@ -1976,7 +1976,7 @@ static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
json_string_set_cs(&key_name, je1->s.cs);
- if (str->append("{", 1))
+ if (str->append('{'))
return 3;
while (json_scan_next(je1) == 0 &&
je1->state != JST_OBJ_END)
@@ -2002,7 +2002,7 @@ static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
*je2= sav_je2;
}
- if (str->append("\"", 1) ||
+ if (str->append('"') ||
append_simple(str, key_start, key_end - key_start) ||
str->append("\":", 2))
return 3;
@@ -2087,7 +2087,7 @@ merged_j1:
if (json_skip_key(je2))
return 1;
- if (str->append("\"", 1) ||
+ if (str->append('"') ||
append_simple(str, key_start, je2->s.c_str - key_start))
return 3;
@@ -2095,7 +2095,7 @@ continue_j2:
continue;
}
- if (str->append("}", 1))
+ if (str->append('}'))
return 3;
}
else
@@ -2115,7 +2115,7 @@ continue_j2:
}
else
{
- if (str->append("[", 1))
+ if (str->append('['))
return 3;
if (je1->value_type == JSON_VALUE_OBJECT)
{
@@ -2157,7 +2157,7 @@ continue_j2:
return 3;
if (je2->value_type != JSON_VALUE_ARRAY &&
- str->append("]", 1))
+ str->append(']'))
return 3;
}
@@ -2256,7 +2256,7 @@ static int copy_value_patch(String *str, json_engine_t *je)
}
/* JSON_VALUE_OBJECT */
- if (str->append("{", 1))
+ if (str->append('{'))
return 1;
while (json_scan_next(je) == 0 && je->state != JST_OBJ_END)
{
@@ -2279,12 +2279,12 @@ static int copy_value_patch(String *str, json_engine_t *je)
else
first_key= 0;
- if (str->append("\"", 1) ||
+ if (str->append('"') ||
append_simple(str, key_start, je->value_begin - key_start) ||
copy_value_patch(str, je))
return 1;
}
- if (str->append("}", 1))
+ if (str->append('}'))
return 1;
return 0;
@@ -2311,7 +2311,7 @@ static int do_merge_patch(String *str, json_engine_t *je1, json_engine_t *je2,
*empty_result= FALSE;
json_string_set_cs(&key_name, je1->s.cs);
- if (str->append("{", 1))
+ if (str->append('{'))
return 3;
while (json_scan_next(je1) == 0 &&
je1->state != JST_OBJ_END)
@@ -2337,7 +2337,7 @@ static int do_merge_patch(String *str, json_engine_t *je1, json_engine_t *je2,
*je2= sav_je2;
}
- if (str->append("\"", 1) ||
+ if (str->append('"') ||
append_simple(str, key_start, key_end - key_start) ||
str->append("\":", 2))
return 3;
@@ -2428,7 +2428,7 @@ merged_j1:
if (!first_key && str->append(", ", 2))
return 3;
- if (str->append("\"", 1) ||
+ if (str->append('"') ||
append_simple(str, key_start, key_end - key_start) ||
str->append("\":", 2))
return 3;
@@ -2449,7 +2449,7 @@ continue_j2:
continue;
}
- if (str->append("}", 1))
+ if (str->append('}'))
return 3;
}
else
@@ -2515,7 +2515,7 @@ String *Item_func_json_merge_patch::val_str(String *str)
goto error_return;
if (empty_result)
- str->append("null");
+ str->append(STRING_WITH_LEN("null"));
cont_point:
{
@@ -2876,7 +2876,7 @@ String *Item_func_json_insert::val_str(String *str)
str->length(0);
/* Wrap the value as an array. */
if (append_simple(str, js->ptr(), (const char *) v_from - js->ptr()) ||
- (do_array_autowrap && str->append("[", 1)))
+ (do_array_autowrap && str->append('[')))
goto js_error; /* Out of memory. */
if (je.value_type == JSON_VALUE_OBJECT)
@@ -2889,7 +2889,7 @@ String *Item_func_json_insert::val_str(String *str)
(append_simple(str, v_from, je.s.c_str - v_from) ||
str->append(", ", 2))) ||
append_json_value(str, args[n_arg+1], &tmp_val) ||
- (do_array_autowrap && str->append("]", 1)) ||
+ (do_array_autowrap && str->append(']')) ||
append_simple(str, je.s.c_str, js->end()-(const char *) je.s.c_str))
goto js_error; /* Out of memory. */
@@ -2960,7 +2960,7 @@ String *Item_func_json_insert::val_str(String *str)
str->length(0);
if (append_simple(str, js->ptr(), v_to - js->ptr()) ||
(n_key > 0 && str->append(", ", 2)) ||
- str->append("\"", 1) ||
+ str->append('"') ||
append_simple(str, lp->key, lp->key_end - lp->key) ||
str->append("\":", 2) ||
append_json_value(str, args[n_arg+1], &tmp_val) ||
@@ -3305,7 +3305,7 @@ skip_search:
goto null_return;
str->length(0);
- if (str->append("[", 1))
+ if (str->append('['))
goto err_return; /* Out of memory. */
/* Parse the OBJECT collecting the keys. */
while (json_scan_next(&je) == 0 && je.state != JST_OBJ_END)
@@ -3328,9 +3328,9 @@ skip_search:
if (!check_key_in_list(str, key_start, key_len))
{
if ((n_keys > 0 && str->append(", ", 2)) ||
- str->append("\"", 1) ||
+ str->append('"') ||
append_simple(str, key_start, key_len) ||
- str->append("\"", 1))
+ str->append('"'))
goto err_return;
n_keys++;
}
@@ -3345,7 +3345,7 @@ skip_search:
}
}
- if (unlikely(je.s.error || str->append("]", 1)))
+ if (unlikely(je.s.error || str->append(']')))
goto err_return;
null_value= 0;
@@ -3449,14 +3449,14 @@ static int append_json_path(String *str, const json_path_t *p)
else /*JSON_PATH_ARRAY*/
{
- if (str->append("[", 1) ||
+ if (str->append('[') ||
str->append_ulonglong(c->n_item) ||
- str->append("]", 1))
+ str->append(']'))
return TRUE;
}
}
- return str->append("\"", 1);
+ return str->append('"');
}
@@ -3517,7 +3517,7 @@ String *Item_func_json_search::val_str(String *str)
{
if (n_path_found == 2)
{
- if (str->append("[", 1) ||
+ if (str->append('[') ||
append_json_path(str, &sav_path))
goto js_error;
}
@@ -3543,7 +3543,7 @@ end:
}
else
{
- if (str->append("]", 1))
+ if (str->append(']'))
goto js_error;
}
@@ -3559,21 +3559,21 @@ null_return:
}
-const char *Item_func_json_format::func_name() const
+LEX_CSTRING Item_func_json_format::func_name_cstring() const
{
switch (fmt)
{
case COMPACT:
- return "json_compact";
+ return { STRING_WITH_LEN("json_compact") };
case LOOSE:
- return "json_loose";
+ return { STRING_WITH_LEN("json_loose") };
case DETAILED:
- return "json_detailed";
+ return { STRING_WITH_LEN("json_detailed") };
default:
DBUG_ASSERT(0);
};
- return "";
+ return NULL_clex_str;
}
@@ -3774,7 +3774,7 @@ Item_func_json_objectagg(THD *thd, Item_func_json_objectagg *item)
{
quick_group= FALSE;
result.set_charset(collation.collation);
- result.append("{");
+ result.append('{');
}
@@ -3855,11 +3855,11 @@ bool Item_func_json_objectagg::add()
null_value= 0;
if (result.length() > 1)
- result.append(", ");
+ result.append(STRING_WITH_LEN(", "));
- result.append("\"");
+ result.append('"');
result.append(*key);
- result.append("\":");
+ result.append(STRING_WITH_LEN("\":"));
buf.length(0);
append_json_value(&result, args[1], &buf);
@@ -3874,7 +3874,7 @@ String* Item_func_json_objectagg::val_str(String* str)
if (null_value)
return 0;
- result.append("}");
+ result.append('}');
return &result;
}
diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h
index 2ba515f448b..e09922dd5c1 100644
--- a/sql/item_jsonfunc.h
+++ b/sql/item_jsonfunc.h
@@ -83,7 +83,11 @@ protected:
public:
Item_func_json_valid(THD *thd, Item *json) : Item_bool_func(thd, json) {}
longlong val_int();
- const char *func_name() const { return "json_valid"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_valid") };
+ return name;
+ }
bool fix_length_and_dec()
{
if (Item_bool_func::fix_length_and_dec())
@@ -111,7 +115,11 @@ protected:
public:
Item_func_json_exists(THD *thd, Item *js, Item *i_path):
Item_bool_func(thd, js, i_path) {}
- const char *func_name() const { return "json_exists"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_exists") };
+ return name;
+ }
bool fix_length_and_dec();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_json_exists>(thd, this); }
@@ -147,7 +155,11 @@ class Item_func_json_value: public Item_str_func,
public:
Item_func_json_value(THD *thd, Item *js, Item *i_path):
Item_str_func(thd, js, i_path) {}
- const char *func_name() const override { return "json_value"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_value") };
+ return name;
+ }
bool fix_length_and_dec() override ;
String *val_str(String *to) override
{
@@ -171,7 +183,11 @@ class Item_func_json_query: public Item_json_func,
public:
Item_func_json_query(THD *thd, Item *js, Item *i_path):
Item_json_func(thd, js, i_path) {}
- const char *func_name() const override { return "json_query"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_query") };
+ return name;
+ }
bool fix_length_and_dec() override;
String *val_str(String *to) override
{
@@ -196,7 +212,11 @@ protected:
public:
Item_func_json_quote(THD *thd, Item *s): Item_str_func(thd, s) {}
- const char *func_name() const { return "json_quote"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_quote") };
+ return name;
+ }
bool fix_length_and_dec();
String *val_str(String *);
Item *get_copy(THD *thd)
@@ -211,7 +231,11 @@ protected:
String *read_json(json_engine_t *je);
public:
Item_func_json_unquote(THD *thd, Item *s): Item_str_func(thd, s) {}
- const char *func_name() const { return "json_unquote"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_unquote") };
+ return name;
+ }
bool fix_length_and_dec();
String *val_str(String *);
Item *get_copy(THD *thd)
@@ -242,7 +266,11 @@ public:
char **out_val, int *value_len);
Item_func_json_extract(THD *thd, List<Item> &list):
Item_json_str_multipath(thd, list) {}
- const char *func_name() const { return "json_extract"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_extract") };
+ return name;
+ }
enum Functype functype() const { return JSON_EXTRACT_FUNC; }
bool fix_length_and_dec();
String *val_str(String *);
@@ -266,7 +294,11 @@ protected:
public:
Item_func_json_contains(THD *thd, List<Item> &list):
Item_bool_func(thd, list) {}
- const char *func_name() const { return "json_contains"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_contains") };
+ return name;
+ }
bool fix_length_and_dec();
longlong val_int();
Item *get_copy(THD *thd)
@@ -287,7 +319,11 @@ protected:
public:
Item_func_json_contains_path(THD *thd, List<Item> &list):
Item_bool_func(thd, list), tmp_paths(0) {}
- const char *func_name() const { return "json_contains_path"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_contains_path") };
+ return name;
+ }
bool fix_fields(THD *thd, Item **ref);
bool fix_length_and_dec();
void cleanup();
@@ -309,7 +345,11 @@ public:
Item_json_func(thd, list) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "json_array"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_array") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_json_array>(thd, this); }
};
@@ -326,7 +366,11 @@ public:
bool fix_length_and_dec();
String *val_str(String *);
uint get_n_paths() const { return arg_count/2; }
- const char *func_name() const { return "json_array_append"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_array_append") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_json_array_append>(thd, this); }
};
@@ -338,7 +382,11 @@ public:
Item_func_json_array_insert(THD *thd, List<Item> &list):
Item_func_json_array_append(thd, list) {}
String *val_str(String *);
- const char *func_name() const { return "json_array_insert"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_array_insert") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_json_array_insert>(thd, this); }
};
@@ -352,7 +400,11 @@ public:
Item_func_json_object(THD *thd, List<Item> &list):
Item_func_json_array(thd, list) {}
String *val_str(String *);
- const char *func_name() const { return "json_object"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_object") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_json_object>(thd, this); }
};
@@ -366,7 +418,11 @@ public:
Item_func_json_merge(THD *thd, List<Item> &list):
Item_func_json_array(thd, list) {}
String *val_str(String *);
- const char *func_name() const { return "json_merge_preserve"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_merge_preserve") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_json_merge>(thd, this); }
};
@@ -376,7 +432,11 @@ class Item_func_json_merge_patch: public Item_func_json_merge
public:
Item_func_json_merge_patch(THD *thd, List<Item> &list):
Item_func_json_merge(thd, list) {}
- const char *func_name() const { return "json_merge_patch"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_merge_patch") };
+ return name;
+ }
String *val_str(String *);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_json_merge_patch>(thd, this); }
@@ -386,9 +446,9 @@ class Item_func_json_length: public Item_long_func
{
bool check_arguments() const
{
- return args[0]->check_type_can_return_text(func_name()) ||
+ return args[0]->check_type_can_return_text(func_name_cstring()) ||
(arg_count > 1 &&
- args[1]->check_type_general_purpose_string(func_name()));
+ args[1]->check_type_general_purpose_string(func_name_cstring()));
}
protected:
json_path_with_flags path;
@@ -397,7 +457,11 @@ protected:
public:
Item_func_json_length(THD *thd, List<Item> &list):
Item_long_func(thd, list) {}
- const char *func_name() const { return "json_length"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_length") };
+ return name;
+ }
bool fix_length_and_dec();
longlong val_int();
Item *get_copy(THD *thd)
@@ -408,12 +472,16 @@ public:
class Item_func_json_depth: public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_can_return_text(func_name()); }
+ { return args[0]->check_type_can_return_text(func_name_cstring()); }
protected:
String tmp_js;
public:
Item_func_json_depth(THD *thd, Item *js): Item_long_func(thd, js) {}
- const char *func_name() const { return "json_depth"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_depth") };
+ return name;
+ }
bool fix_length_and_dec() { max_length= 10; return FALSE; }
longlong val_int();
Item *get_copy(THD *thd)
@@ -427,7 +495,11 @@ protected:
String tmp_js;
public:
Item_func_json_type(THD *thd, Item *js): Item_str_func(thd, js) {}
- const char *func_name() const { return "json_type"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_type") };
+ return name;
+ }
bool fix_length_and_dec();
String *val_str(String *);
Item *get_copy(THD *thd)
@@ -448,10 +520,13 @@ public:
bool fix_length_and_dec();
String *val_str(String *);
uint get_n_paths() const { return arg_count/2; }
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return mode_insert ?
- (mode_replace ? "json_set" : "json_insert") : "json_update";
+ static LEX_CSTRING json_set= {STRING_WITH_LEN("json_set") };
+ static LEX_CSTRING json_insert= {STRING_WITH_LEN("json_insert") };
+ static LEX_CSTRING json_update= {STRING_WITH_LEN("json_update") };
+ return (mode_insert ?
+ (mode_replace ? json_set : json_insert) : json_update);
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_json_insert>(thd, this); }
@@ -468,7 +543,11 @@ public:
bool fix_length_and_dec();
String *val_str(String *);
uint get_n_paths() const { return arg_count - 1; }
- const char *func_name() const { return "json_remove"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_remove") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_json_remove>(thd, this); }
};
@@ -483,7 +562,11 @@ protected:
public:
Item_func_json_keys(THD *thd, List<Item> &list):
Item_str_func(thd, list) {}
- const char *func_name() const { return "json_keys"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_keys") };
+ return name;
+ }
bool fix_length_and_dec();
String *val_str(String *);
Item *get_copy(THD *thd)
@@ -506,7 +589,11 @@ protected:
public:
Item_func_json_search(THD *thd, List<Item> &list):
Item_json_str_multipath(thd, list) {}
- const char *func_name() const { return "json_search"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_search") };
+ return name;
+ }
bool fix_fields(THD *thd, Item **ref);
bool fix_length_and_dec();
String *val_str(String *);
@@ -535,7 +622,7 @@ public:
Item_func_json_format(THD *thd, List<Item> &list):
Item_json_func(thd, list), fmt(DETAILED) {}
- const char *func_name() const;
+ LEX_CSTRING func_name_cstring() const override;
bool fix_length_and_dec();
String *val_str(String *str);
String *val_json(String *str);
@@ -570,7 +657,11 @@ public:
Item_func_json_arrayagg(THD *thd, Item_func_json_arrayagg *item);
bool is_json_type() { return true; }
- const char *func_name() const { return "json_arrayagg("; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_arrayagg(") };
+ return name;
+ }
enum Sumfunctype sum_func() const {return JSON_ARRAYAGG_FUNC;}
String* val_str(String *str);
@@ -588,7 +679,7 @@ public:
Item_sum(thd, key, value)
{
quick_group= FALSE;
- result.append("{");
+ result.append('{');
}
Item_func_json_objectagg(THD *thd, Item_func_json_objectagg *item);
@@ -596,7 +687,11 @@ public:
void cleanup();
enum Sumfunctype sum_func () const {return JSON_OBJECTAGG_FUNC;}
- const char *func_name() const { return "json_objectagg"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("json_objectagg") };
+ return name;
+ }
const Type_handler *type_handler() const
{
if (too_big_for_varchar())
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 186693fb128..fc5b4deb9ac 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -554,7 +554,7 @@ String *Item_func_decode_histogram::val_str(String *str)
size_t size= my_snprintf(numbuf, sizeof(numbuf),
representation_by_type[type], val - prev);
str->append(numbuf, size);
- str->append(",");
+ str->append(',');
prev= val;
}
/* show delta with max */
@@ -2145,7 +2145,7 @@ void Item_func_trim::print(String *str, enum_query_type query_type)
Item_func::print(str, query_type);
return;
}
- str->append(Item_func_trim::func_name());
+ str->append(Item_func_trim::func_name_cstring());
str->append(func_name_ext());
str->append('(');
str->append(mode_name());
@@ -2934,13 +2934,14 @@ String *Item_func_make_set::val_str(String *str)
void Item_func_char::print(String *str, enum_query_type query_type)
{
- str->append(Item_func_char::func_name());
+ str->append(Item_func_char::func_name_cstring());
str->append('(');
print_args(str, 0, query_type);
if (collation.collation != &my_charset_bin)
{
str->append(STRING_WITH_LEN(" using "));
- str->append(collation.collation->csname);
+ str->append(collation.collation->csname,
+ strlen(collation.collation->csname));
}
str->append(')');
}
@@ -3223,7 +3224,7 @@ bool Item_func_pad::fix_length_and_dec()
return TRUE;
pad_str.set_charset(collation.collation);
pad_str.length(0);
- pad_str.append(" ", 1);
+ pad_str.append(' ');
}
DBUG_ASSERT(collation.collation->mbmaxlen > 0);
@@ -3533,7 +3534,8 @@ void Item_func_conv_charset::print(String *str, enum_query_type query_type)
str->append(STRING_WITH_LEN("convert("));
args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" using "));
- str->append(collation.collation->csname);
+ str->append(collation.collation->csname,
+ strlen(collation.collation->csname));
str->append(')');
}
@@ -3573,7 +3575,7 @@ void Item_func_set_collation::print(String *str, enum_query_type query_type)
{
args[0]->print_parenthesised(str, query_type, precedence());
str->append(STRING_WITH_LEN(" collate "));
- str->append(m_set_collation->name);
+ str->append(m_set_collation->name, strlen(m_set_collation->name));
}
String *Item_func_charset::val_str(String *str)
@@ -3704,7 +3706,7 @@ nl:
void Item_func_weight_string::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
args[0]->print(str, query_type);
str->append(',');
@@ -4631,7 +4633,8 @@ void Item_func_dyncol_create::print_arguments(String *str,
if (defs[i].cs)
{
str->append(STRING_WITH_LEN(" charset "));
- str->append(defs[i].cs->csname);
+ const char *cs= defs[i].cs->csname;
+ str->append(cs, strlen(cs));
str->append(' ');
}
break;
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 5981123888b..bc77edfd095 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -149,7 +149,11 @@ public:
fix_length_and_charset(32, default_charset());
return FALSE;
}
- const char *func_name() const { return "md5"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("md5") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_md5>(thd, this); }
};
@@ -161,7 +165,11 @@ public:
Item_func_sha(THD *thd, Item *a): Item_str_ascii_checksum_func(thd, a) {}
String *val_str_ascii(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "sha"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sha") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_sha>(thd, this); }
};
@@ -173,7 +181,11 @@ public:
:Item_str_ascii_checksum_func(thd, a, b) {}
String *val_str_ascii(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "sha2"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sha2") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_sha2>(thd, this); }
};
@@ -186,7 +198,11 @@ public:
:Item_str_ascii_checksum_func(thd, a) {}
String *val_str_ascii(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "to_base64"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("to_base64") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_to_base64>(thd, this); }
};
@@ -199,7 +215,11 @@ public:
:Item_str_binary_checksum_func(thd, a) { }
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "from_base64"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("from_base64") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_from_base64>(thd, this); }
};
@@ -226,7 +246,11 @@ public:
Item_func_aes_encrypt(THD *thd, Item *a, Item *b)
:Item_aes_crypt(thd, a, b) {}
bool fix_length_and_dec();
- const char *func_name() const { return "aes_encrypt"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("aes_encrypt") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_aes_encrypt>(thd, this); }
};
@@ -237,7 +261,11 @@ public:
Item_func_aes_decrypt(THD *thd, Item *a, Item *b):
Item_aes_crypt(thd, a, b) {}
bool fix_length_and_dec();
- const char *func_name() const { return "aes_decrypt"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("aes_decrypt") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_aes_decrypt>(thd, this); }
};
@@ -261,7 +289,11 @@ public:
Item_func_concat(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "concat"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("concat") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_concat>(thd, this); }
};
@@ -281,7 +313,11 @@ public:
:Item_func_concat(thd, a, b)
{ }
String *val_str(String *);
- const char *func_name() const { return "concat_operator_oracle"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("concat_operator_oracle") };
+ return name;
+ }
Item *get_copy(THD *thd)
{
return get_item_copy<Item_func_concat_operator_oracle>(thd, this);
@@ -302,7 +338,11 @@ public:
set_maybe_null();
return FALSE;
}
- const char *func_name() const { return "decode_histogram"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("decode_histogram") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_decode_histogram>(thd, this); }
};
@@ -314,7 +354,11 @@ public:
Item_func_concat_ws(THD *thd, List<Item> &list): Item_str_func(thd, list) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "concat_ws"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("concat_ws") };
+ return name;
+ }
table_map not_null_tables() const { return 0; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_concat_ws>(thd, this); }
@@ -327,7 +371,11 @@ public:
Item_func_reverse(THD *thd, Item *a): Item_str_func(thd, a) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "reverse"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("reverse") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_reverse>(thd, this); }
};
@@ -342,7 +390,11 @@ public:
String *val_str(String *to) { return val_str_internal(to, NULL); };
bool fix_length_and_dec();
String *val_str_internal(String *str, String *empty_string_for_null);
- const char *func_name() const { return "replace"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("replace") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_replace>(thd, this); }
};
@@ -355,7 +407,11 @@ public:
Item_func_replace_oracle(THD *thd, Item *org, Item *find, Item *replace):
Item_func_replace(thd, org, find, replace) {}
String *val_str(String *to) { return val_str_internal(to, &tmp_emtpystr); };
- const char *func_name() const { return "replace_oracle"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("replace_oracle") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_replace_oracle>(thd, this); }
};
@@ -380,7 +436,11 @@ public:
}
String *val_str(String *str);
bool fix_length_and_dec();
- const char *func_name() const { return "regexp_replace"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("regexp_replace") };
+ return name;
+ }
Item *get_copy(THD *thd) { return 0;}
};
@@ -401,7 +461,11 @@ public:
}
String *val_str(String *str);
bool fix_length_and_dec();
- const char *func_name() const { return "regexp_substr"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("regexp_substr") };
+ return name;
+ }
Item *get_copy(THD *thd) { return 0; }
};
@@ -415,7 +479,11 @@ public:
Item_str_func(thd, org, start, length, new_str) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "insert"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("insert") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_insert>(thd, this); }
};
@@ -437,7 +505,11 @@ class Item_func_lcase :public Item_str_conv
{
public:
Item_func_lcase(THD *thd, Item *item): Item_str_conv(thd, item) {}
- const char *func_name() const { return "lcase"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("lcase") };
+ return name;
+ }
bool fix_length_and_dec();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_lcase>(thd, this); }
@@ -447,7 +519,11 @@ class Item_func_ucase :public Item_str_conv
{
public:
Item_func_ucase(THD *thd, Item *item): Item_str_conv(thd, item) {}
- const char *func_name() const { return "ucase"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("ucase") };
+ return name;
+ }
bool fix_length_and_dec();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_ucase>(thd, this); }
@@ -461,7 +537,11 @@ public:
Item_func_left(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "left"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("left") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_left>(thd, this); }
};
@@ -474,7 +554,11 @@ public:
Item_func_right(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "right"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("right") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_right>(thd, this); }
};
@@ -491,7 +575,11 @@ public:
Item_str_func(thd, a, b, c) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "substr"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("substr") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_substr>(thd, this); }
};
@@ -514,7 +602,11 @@ public:
set_maybe_null();
return res;
}
- const char *func_name() const { return "substr_oracle"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("substr_oracle") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_substr_oracle>(thd, this); }
};
@@ -527,7 +619,11 @@ public:
Item_str_func(thd, a, b, c) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "substring_index"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("substring_index") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_substr_index>(thd, this); }
@@ -557,16 +653,24 @@ protected:
{
return trimmed_value(res, 0, res->length());
}
- virtual const char *func_name_ext() const { return ""; }
+ virtual LEX_CSTRING func_name_ext() const
+ {
+ static LEX_CSTRING name_ext= {STRING_WITH_LEN("") };
+ return name_ext;
+ }
public:
Item_func_trim(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {}
Item_func_trim(THD *thd, Item *a): Item_str_func(thd, a) {}
Sql_mode_dependency value_depends_on_sql_mode() const;
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "trim"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("trim") };
+ return name;
+ }
void print(String *str, enum_query_type query_type);
- virtual const char *mode_name() const { return "both"; }
+ virtual LEX_CSTRING mode_name() const { return { "both", 4}; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_trim>(thd, this); }
};
@@ -577,12 +681,20 @@ class Item_func_trim_oracle :public Item_func_trim
protected:
String *make_empty_result()
{ null_value= 1; return NULL; }
- const char *func_name_ext() const { return "_oracle"; }
+ LEX_CSTRING func_name_ext() const override
+ {
+ static LEX_CSTRING name_ext= {STRING_WITH_LEN("_oracle") };
+ return name_ext;
+ }
public:
Item_func_trim_oracle(THD *thd, Item *a, Item *b):
Item_func_trim(thd, a, b) {}
Item_func_trim_oracle(THD *thd, Item *a): Item_func_trim(thd, a) {}
- const char *func_name() const { return "trim_oracle"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("trim_oracle") };
+ return name;
+ }
bool fix_length_and_dec()
{
bool res= Item_func_trim::fix_length_and_dec();
@@ -604,8 +716,13 @@ public:
return Item_func::value_depends_on_sql_mode();
}
String *val_str(String *);
- const char *func_name() const { return "ltrim"; }
- const char *mode_name() const { return "leading"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("ltrim") };
+ return name;
+ }
+ LEX_CSTRING mode_name() const override
+ { return { STRING_WITH_LEN("leading") }; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_ltrim>(thd, this); }
};
@@ -616,12 +733,20 @@ class Item_func_ltrim_oracle :public Item_func_ltrim
protected:
String *make_empty_result()
{ null_value= 1; return NULL; }
- const char *func_name_ext() const { return "_oracle"; }
+ LEX_CSTRING func_name_ext() const override
+ {
+ static LEX_CSTRING name_ext= {STRING_WITH_LEN("_oracle") };
+ return name_ext;
+ }
public:
Item_func_ltrim_oracle(THD *thd, Item *a, Item *b):
Item_func_ltrim(thd, a, b) {}
Item_func_ltrim_oracle(THD *thd, Item *a): Item_func_ltrim(thd, a) {}
- const char *func_name() const { return "ltrim_oracle"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("ltrim_oracle") };
+ return name;
+ }
bool fix_length_and_dec()
{
bool res= Item_func_ltrim::fix_length_and_dec();
@@ -639,8 +764,13 @@ public:
Item_func_rtrim(THD *thd, Item *a, Item *b): Item_func_trim(thd, a, b) {}
Item_func_rtrim(THD *thd, Item *a): Item_func_trim(thd, a) {}
String *val_str(String *);
- const char *func_name() const { return "rtrim"; }
- const char *mode_name() const { return "trailing"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("rtrim") };
+ return name;
+ }
+ LEX_CSTRING mode_name() const override
+ { return { STRING_WITH_LEN("trailing") }; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_rtrim>(thd, this); }
};
@@ -651,12 +781,20 @@ class Item_func_rtrim_oracle :public Item_func_rtrim
protected:
String *make_empty_result()
{ null_value= 1; return NULL; }
- const char *func_name_ext() const { return "_oracle"; }
+ LEX_CSTRING func_name_ext() const override
+ {
+ static LEX_CSTRING name_ext= {STRING_WITH_LEN("_oracle") };
+ return name_ext;
+ }
public:
Item_func_rtrim_oracle(THD *thd, Item *a, Item *b):
Item_func_rtrim(thd, a, b) {}
Item_func_rtrim_oracle(THD *thd, Item *a): Item_func_rtrim(thd, a) {}
- const char *func_name() const { return "rtrim_oracle"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("rtrim_oracle") };
+ return name;
+ }
bool fix_length_and_dec()
{
bool res= Item_func_rtrim::fix_length_and_dec();
@@ -698,8 +836,12 @@ public:
default_charset());
return FALSE;
}
- const char *func_name() const { return ((deflt || alg == 1) ?
- "password" : "old_password"); }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING password_normal= {STRING_WITH_LEN("password") };
+ static LEX_CSTRING password_old= {STRING_WITH_LEN("old_password") };
+ return (deflt || alg == 1) ? password_normal : password_old;
+ }
static char *alloc(THD *thd, const char *password, size_t pass_len,
enum PW_Alg al);
Item *get_copy(THD *thd)
@@ -724,7 +866,11 @@ public:
max_length = args[0]->max_length + 9;
return FALSE;
}
- const char *func_name() const { return "des_encrypt"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("des_encrypt") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_des_encrypt>(thd, this); }
};
@@ -747,7 +893,11 @@ public:
max_length-= 9U;
return FALSE;
}
- const char *func_name() const { return "des_decrypt"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("des_decrypt") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_des_decrypt>(thd, this); }
};
@@ -784,7 +934,11 @@ public:
max_length = 13;
return FALSE;
}
- const char *func_name() const { return "encrypt"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("encrypt") };
+ return name;
+ }
bool check_vcol_func_processor(void *arg)
{
return FALSE;
@@ -808,7 +962,11 @@ public:
Item_str_binary_checksum_func(thd, a, seed_arg) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "encode"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("encode") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_encode>(thd, this); }
protected:
@@ -823,7 +981,11 @@ class Item_func_decode :public Item_func_encode
{
public:
Item_func_decode(THD *thd, Item *a, Item *seed_arg): Item_func_encode(thd, a, seed_arg) {}
- const char *func_name() const { return "decode"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("decode") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_decode>(thd, this); }
protected:
@@ -863,7 +1025,11 @@ public:
set_maybe_null();
return FALSE;
}
- const char *func_name() const { return "database"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("database") };
+ return name;
+ }
const char *fully_qualified_func_name() const { return "database()"; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_database>(thd, this); }
@@ -875,11 +1041,15 @@ class Item_func_sqlerrm :public Item_func_sysconst
public:
Item_func_sqlerrm(THD *thd): Item_func_sysconst(thd) {}
String *val_str(String *);
- const char *func_name() const { return "SQLERRM"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("SQLERRM") };
+ return name;
+ }
const char *fully_qualified_func_name() const { return "SQLERRM"; }
void print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
}
bool fix_length_and_dec()
{
@@ -915,7 +1085,11 @@ public:
HOSTNAME_LENGTH + 1) * SYSTEM_CHARSET_MBMAXLEN;
return FALSE;
}
- const char *func_name() const { return "user"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("user") };
+ return name;
+ }
const char *fully_qualified_func_name() const { return "user()"; }
int save_in_field(Field *field, bool no_conversions)
{
@@ -934,7 +1108,11 @@ public:
Item_func_current_user(THD *thd, Name_resolution_context *context_arg):
Item_func_user(thd), context(context_arg) {}
bool fix_fields(THD *thd, Item **ref);
- const char *func_name() const { return "current_user"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("current_user") };
+ return name;
+ }
const char *fully_qualified_func_name() const { return "current_user()"; }
bool check_vcol_func_processor(void *arg)
{
@@ -960,7 +1138,11 @@ public:
}
int save_in_field(Field *field, bool no_conversions)
{ return save_str_value_in_field(field, &str_value); }
- const char *func_name() const { return "current_role"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("current_role") };
+ return name;
+ }
const char *fully_qualified_func_name() const { return "current_role()"; }
String *val_str(String *)
{
@@ -969,7 +1151,6 @@ public:
}
bool check_vcol_func_processor(void *arg)
{
-
context= 0;
return mark_unsupported_function(fully_qualified_func_name(), arg,
VCOL_SESSION_FUNC);
@@ -986,7 +1167,11 @@ public:
Item_func_soundex(THD *thd, Item *a): Item_str_func(thd, a) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "soundex"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("soundex") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_soundex>(thd, this); }
};
@@ -1000,7 +1185,11 @@ public:
longlong val_int();
String *val_str(String *str);
bool fix_length_and_dec();
- const char *func_name() const { return "elt"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("elt") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_elt>(thd, this); }
};
@@ -1014,7 +1203,11 @@ public:
Item_func_make_set(THD *thd, List<Item> &list): Item_str_func(thd, list) {}
String *val_str(String *str);
bool fix_length_and_dec();
- const char *func_name() const { return "make_set"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("make_set") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_make_set>(thd, this); }
};
@@ -1031,7 +1224,11 @@ public:
String *val_str_ascii(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "format"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("format") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_format>(thd, this); }
};
@@ -1055,7 +1252,11 @@ public:
max_length= arg_count * 4;
return FALSE;
}
- const char *func_name() const { return "char"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("char") };
+ return name;
+ }
void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_char>(thd, this); }
@@ -1072,7 +1273,11 @@ public:
max_length= 4;
return FALSE;
}
- const char *func_name() const { return "chr"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("chr") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_chr>(thd, this); }
};
@@ -1085,7 +1290,11 @@ public:
Item_str_func(thd, arg1, arg2) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "repeat"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("repeat") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_repeat>(thd, this); }
};
@@ -1097,7 +1306,11 @@ public:
Item_func_space(THD *thd, Item *arg1): Item_str_func(thd, arg1) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "space"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("space") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_space>(thd, this); }
};
@@ -1110,7 +1323,11 @@ public:
Item_str_func(thd, arg1, arg2) {}
String *val_str(String *);
bool fix_length_and_dec();
- const char *func_name() const { return "binlog_gtid_pos"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("binlog_gtid_pos") };
+ return name;
+ }
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
@@ -1141,7 +1358,11 @@ public:
Item_func_rpad(THD *thd, Item *arg1, Item *arg2):
Item_func_pad(thd, arg1, arg2) {}
String *val_str(String *);
- const char *func_name() const { return "rpad"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("rpad") };
+ return name;
+ }
Sql_mode_dependency value_depends_on_sql_mode() const;
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_rpad>(thd, this); }
@@ -1163,7 +1384,11 @@ public:
set_maybe_null();
return res;
}
- const char *func_name() const { return "rpad_oracle"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("rpad_oracle") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_rpad_oracle>(thd, this); }
};
@@ -1177,7 +1402,11 @@ public:
Item_func_lpad(THD *thd, Item *arg1, Item *arg2):
Item_func_pad(thd, arg1, arg2) {}
String *val_str(String *);
- const char *func_name() const { return "lpad"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("lpad") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_lpad>(thd, this); }
};
@@ -1198,7 +1427,11 @@ public:
set_maybe_null();
return res;
}
- const char *func_name() const { return "lpad_oracle"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("lpad_oracle") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_lpad_oracle>(thd, this); }
};
@@ -1209,7 +1442,11 @@ class Item_func_conv :public Item_str_func
public:
Item_func_conv(THD *thd, Item *a, Item *b, Item *c):
Item_str_func(thd, a, b, c) {}
- const char *func_name() const { return "conv"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("conv") };
+ return name;
+ }
String *val_str(String *);
bool fix_length_and_dec()
{
@@ -1237,7 +1474,11 @@ protected:
public:
Item_func_hex(THD *thd, Item *a):
Item_str_ascii_checksum_func(thd, a), m_arg0_type_handler(NULL) {}
- const char *func_name() const { return "hex"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("hex") };
+ return name;
+ }
String *val_str_ascii_from_val_int(String *str);
String *val_str_ascii_from_val_real(String *str);
String *val_str_ascii_from_val_str(String *str);
@@ -1267,7 +1508,11 @@ public:
/* there can be bad hex strings */
set_maybe_null();
}
- const char *func_name() const { return "unhex"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("unhex") };
+ return name;
+ }
String *val_str(String *);
bool fix_length_and_dec()
{
@@ -1310,7 +1555,11 @@ class Item_func_like_range_min :public Item_func_like_range
public:
Item_func_like_range_min(THD *thd, Item *a, Item *b):
Item_func_like_range(thd, a, b, true) { }
- const char *func_name() const { return "like_range_min"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("like_range_min") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_like_range_min>(thd, this); }
};
@@ -1321,7 +1570,11 @@ class Item_func_like_range_max :public Item_func_like_range
public:
Item_func_like_range_max(THD *thd, Item *a, Item *b):
Item_func_like_range(thd, a, b, false) { }
- const char *func_name() const { return "like_range_max"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("like_range_max") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_like_range_max>(thd, this); }
};
@@ -1348,7 +1601,11 @@ public:
return FALSE;
}
void print(String *str, enum_query_type query_type);
- const char *func_name() const { return "cast_as_binary"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_binary") };
+ return name;
+ }
bool need_parentheses_in_default() { return true; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_binary>(thd, this); }
@@ -1361,7 +1618,11 @@ class Item_load_file :public Item_str_func
public:
Item_load_file(THD *thd, Item *a): Item_str_func(thd, a) {}
String *val_str(String *);
- const char *func_name() const { return "load_file"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("load_file") };
+ return name;
+ }
bool fix_length_and_dec()
{
collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
@@ -1389,7 +1650,11 @@ class Item_func_export_set: public Item_str_func
Item_str_func(thd, a, b, c, d, e) {}
String *val_str(String *str);
bool fix_length_and_dec();
- const char *func_name() const { return "export_set"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("export_set") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_export_set>(thd, this); }
};
@@ -1400,7 +1665,11 @@ class Item_func_quote :public Item_str_func
String tmp_value;
public:
Item_func_quote(THD *thd, Item *a): Item_str_func(thd, a) {}
- const char *func_name() const { return "quote"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("quote") };
+ return name;
+ }
String *val_str(String *);
bool fix_length_and_dec()
{
@@ -1501,7 +1770,11 @@ public:
return res;
}
bool fix_length_and_dec();
- const char *func_name() const { return "convert"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("convert") };
+ return name;
+ }
void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_conv_charset>(thd, this); }
@@ -1516,7 +1789,11 @@ public:
String *val_str(String *);
bool fix_length_and_dec();
bool eq(const Item *item, bool binary_cmp) const;
- const char *func_name() const { return "collate"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("collate") };
+ return name;
+ }
enum precedence precedence() const { return COLLATE_PRECEDENCE; }
enum Functype functype() const { return COLLATE_FUNC; }
void print(String *str, enum_query_type query_type);
@@ -1555,7 +1832,11 @@ public:
Item_func_charset(THD *thd, Item *a)
:Item_func_expr_str_metadata(thd, a) { }
String *val_str(String *);
- const char *func_name() const { return "charset"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("charset") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_charset>(thd, this); }
};
@@ -1567,7 +1848,11 @@ public:
Item_func_collation(THD *thd, Item *a)
:Item_func_expr_str_metadata(thd, a) {}
String *val_str(String *);
- const char *func_name() const { return "collation"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("collation") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_collation>(thd, this); }
};
@@ -1588,7 +1873,11 @@ public:
weigth_flags= flags_arg;
result_length= result_length_arg;
}
- const char *func_name() const { return "weight_string"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("weight_string") };
+ return name;
+ }
String *val_str(String *);
bool fix_length_and_dec();
bool eq(const Item *item, bool binary_cmp) const
@@ -1610,12 +1899,16 @@ public:
class Item_func_crc32 :public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_can_return_str(func_name()); }
+ { return args[0]->check_type_can_return_str(func_name_cstring()); }
String value;
public:
Item_func_crc32(THD *thd, Item *a): Item_long_func(thd, a)
{ unsigned_flag= 1; }
- const char *func_name() const { return "crc32"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("crc32") };
+ return name;
+ }
bool fix_length_and_dec() { max_length=10; return FALSE; }
longlong val_int();
Item *get_copy(THD *thd)
@@ -1628,7 +1921,11 @@ class Item_func_uncompressed_length : public Item_long_func_length
public:
Item_func_uncompressed_length(THD *thd, Item *a)
:Item_long_func_length(thd, a) {}
- const char *func_name() const{return "uncompressed_length";}
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("uncompressed_length") };
+ return name;
+ }
bool fix_length_and_dec()
{
max_length=10;
@@ -1656,7 +1953,11 @@ public:
max_length= (args[0]->max_length * 120) / 100 + 12;
return FALSE;
}
- const char *func_name() const{return "compress";}
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("compress") };
+ return name;
+ }
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_compress>(thd, this); }
@@ -1674,7 +1975,11 @@ public:
max_length= MAX_BLOB_WIDTH;
return FALSE;
}
- const char *func_name() const{return "uncompress";}
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("uncompress") };
+ return name;
+ }
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_uncompress>(thd, this); }
@@ -1693,11 +1998,16 @@ public:
}
bool const_item() const { return false; }
table_map used_tables() const { return RAND_TABLE_BIT; }
- const char *func_name() const{ return "uuid"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("uuid") };
+ return name;
+ }
String *val_str(String *);
bool check_vcol_func_processor(void *arg)
{
- return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC);
+ return mark_unsupported_function(func_name(), "()", arg,
+ VCOL_NON_DETERMINISTIC);
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_uuid>(thd, this); }
@@ -1718,7 +2028,11 @@ public:
Item_func_dyncol_create(THD *thd, List<Item> &args, DYNCALL_CREATE_DEF *dfs);
bool fix_fields(THD *thd, Item **ref);
bool fix_length_and_dec();
- const char *func_name() const{ return "column_create"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("column_create") };
+ return name;
+ }
String *val_str(String *);
void print(String *str, enum_query_type query_type);
enum Functype functype() const { return DYNCOL_FUNC; }
@@ -1733,7 +2047,11 @@ public:
Item_func_dyncol_add(THD *thd, List<Item> &args_arg, DYNCALL_CREATE_DEF *dfs):
Item_func_dyncol_create(thd, args_arg, dfs)
{}
- const char *func_name() const{ return "column_add"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("column_add") };
+ return name;
+ }
String *val_str(String *);
void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd)
@@ -1745,7 +2063,11 @@ class Item_func_dyncol_json: public Item_str_func
public:
Item_func_dyncol_json(THD *thd, Item *str): Item_str_func(thd, str)
{collation.set(DYNCOL_UTF);}
- const char *func_name() const{ return "column_json"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("column_json") };
+ return name;
+ }
String *val_str(String *);
bool fix_length_and_dec()
{
@@ -1776,7 +2098,11 @@ public:
/* Mark that collation can change between calls */
bool dynamic_result() { return 1; }
- const char *func_name() const { return "column_get"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("column_get") };
+ return name;
+ }
String *val_str(String *);
longlong val_int();
longlong val_int_signed_typecast()
@@ -1816,7 +2142,11 @@ public:
max_length= MAX_BLOB_WIDTH;
return FALSE;
}
- const char *func_name() const{ return "column_list"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("column_list") };
+ return name;
+ }
String *val_str(String *);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_dyncol_list>(thd, this); }
@@ -1837,7 +2167,11 @@ public:
{ return create_table_field_from_handler(root, table); }
String *val_str(String *str);
enum Functype functype() const { return TEMPTABLE_ROWID; }
- const char *func_name() const { return "<rowid>"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("<rowid>") };
+ return name;
+ }
bool fix_length_and_dec();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_temptable_rowid>(thd, this); }
@@ -1851,7 +2185,11 @@ class Item_func_wsrep_last_written_gtid: public Item_str_ascii_func
String gtid_str;
public:
Item_func_wsrep_last_written_gtid(THD *thd): Item_str_ascii_func(thd) {}
- const char *func_name() const { return "wsrep_last_written_gtid"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("wsrep_last_written_gtid") };
+ return name;
+ }
String *val_str_ascii(String *);
bool fix_length_and_dec()
{
@@ -1868,7 +2206,11 @@ class Item_func_wsrep_last_seen_gtid: public Item_str_ascii_func
String gtid_str;
public:
Item_func_wsrep_last_seen_gtid(THD *thd): Item_str_ascii_func(thd) {}
- const char *func_name() const { return "wsrep_last_seen_gtid"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("wsrep_last_seen_gtid") };
+ return name;
+ }
String *val_str_ascii(String *);
bool fix_length_and_dec()
{
@@ -1887,7 +2229,11 @@ public:
Item_func_wsrep_sync_wait_upto(THD *thd, Item *a): Item_int_func(thd, a) {}
Item_func_wsrep_sync_wait_upto(THD *thd, Item *a, Item* b): Item_int_func(thd, a, b) {}
const Type_handler *type_handler() const { return &type_handler_string; }
- const char *func_name() const { return "wsrep_sync_wait_upto_gtid"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("wsrep_sync_wait_upto_gtid") };
+ return name;
+ }
longlong val_int();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_wsrep_sync_wait_upto>(thd, this); }
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index d6e852215e4..580e67a11da 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1092,13 +1092,18 @@ void Item_subselect::print(String *str, enum_query_type query_type)
if (unit && unit->first_select())
{
char buf[64];
- ll2str(unit->first_select()->select_number, buf, 10, 0);
- str->append(buf);
+ size_t length= (size_t)
+ (longlong10_to_str(unit->first_select()->select_number, buf, 10) -
+ buf);
+ str->append(buf, length);
}
else
- str->append("NULL"); // TODO: what exactly does this mean?
+ {
+ // TODO: Explain what exactly does this mean?
+ str->append(NULL_clex_str);
+ }
- str->append(")");
+ str->append(')');
return;
}
if (engine)
@@ -1108,7 +1113,7 @@ void Item_subselect::print(String *str, enum_query_type query_type)
str->append(')');
}
else
- str->append("(...)");
+ str->append(STRING_WITH_LEN("(...)"));
}
@@ -3693,7 +3698,8 @@ void Item_allany_subselect::print(String *str, enum_query_type query_type)
{
left_expr->print(str, query_type);
str->append(' ');
- str->append(func->symbol(all));
+ const char *name= func->symbol(all);
+ str->append(name, strlen(name));
str->append(all ? " all " : " any ", 5);
}
Item_subselect::print(str, query_type);
@@ -6216,26 +6222,34 @@ bool Ordered_key::next_same()
void Ordered_key::print(String *str)
{
uint i;
- str->append("{idx=");
+
+ /* We have to pre-allocate string as we are using qs_append() */
+ if (str->alloc(str->length() +
+ 5+10+4+ (NAME_LEN+2)*key_column_count+
+ 20+11+21+10+FLOATING_POINT_BUFFER*3+50
+ ))
+ return;
+ str->append(STRING_WITH_LEN("{idx="));
str->qs_append(keyid);
- str->append(", (");
- for (i= 0; i < key_column_count - 1; i++)
+ str->append(STRING_WITH_LEN(", ("));
+ for (i= 0; i < key_column_count ; i++)
{
str->append(&key_columns[i]->field->field_name);
- str->append(", ");
+ str->append(STRING_WITH_LEN(", "));
}
- str->append(&key_columns[i]->field->field_name);
- str->append("), ");
+ if (key_column_count)
+ str->length(str->length() - 2);
+ str->append(STRING_WITH_LEN("), "));
- str->append("null_bitmap: (bits=");
+ str->append(STRING_WITH_LEN("null_bitmap: (bits="));
str->qs_append(null_key.n_bits);
- str->append(", nulls= ");
+ str->append(STRING_WITH_LEN(", nulls= "));
str->qs_append((double)null_count);
- str->append(", min_null= ");
+ str->append(STRING_WITH_LEN(", min_null= "));
str->qs_append((double)min_null_row);
- str->append(", max_null= ");
+ str->append(STRING_WITH_LEN(", max_null= "));
str->qs_append((double)max_null_row);
- str->append("), ");
+ str->append(STRING_WITH_LEN("), "));
str->append('}');
}
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 1bf1f986a2a..4a87a1632b2 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -497,7 +497,7 @@ void Item_sum::print(String *str, enum_query_type query_type)
{
/* orig_args is not filled with valid values until fix_fields() */
Item **pargs= fixed() ? orig_args : args;
- str->append(func_name());
+ str->append(func_name_cstring());
/*
TODO:
The fact that func_name() may return a name with an extra '('
@@ -1458,11 +1458,10 @@ Item_sum_sp::fix_length_and_dec()
DBUG_RETURN(res);
}
-const char *
-Item_sum_sp::func_name() const
+LEX_CSTRING Item_sum_sp::func_name_cstring() const
{
THD *thd= current_thd;
- return Item_sp::func_name(thd);
+ return Item_sp::func_name_cstring(thd);
}
Item* Item_sum_sp::copy_or_same(THD *thd)
@@ -3367,7 +3366,7 @@ void Item_udf_sum::cleanup()
void Item_udf_sum::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
for (uint i=0 ; i < arg_count ; i++)
{
@@ -4524,7 +4523,7 @@ uint Item_func_group_concat::get_null_bytes()
void Item_func_group_concat::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
if (distinct)
str->append(STRING_WITH_LEN("distinct "));
for (uint i= 0; i < arg_count_field; i++)
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 14672af6ef6..4f8cf996f55 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -838,9 +838,11 @@ public:
void reset_field();
void update_field();
void no_rows_in_result() {}
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return has_with_distinct() ? "sum(distinct " : "sum(";
+ static LEX_CSTRING name_distinct= { STRING_WITH_LEN("sum(distinct ")};
+ static LEX_CSTRING name_normal= { STRING_WITH_LEN("sum(") };
+ return has_with_distinct() ? name_distinct : name_normal;
}
Item *copy_or_same(THD* thd);
void remove();
@@ -911,9 +913,11 @@ public:
void reset_field();
void update_field();
void direct_add(longlong add_count);
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return has_with_distinct() ? "count(distinct " : "count(";
+ static LEX_CSTRING name_distinct= { STRING_WITH_LEN("count(distinct ")};
+ static LEX_CSTRING name_normal= { STRING_WITH_LEN("count(") };
+ return has_with_distinct() ? name_distinct : name_normal;
}
Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd)
@@ -961,9 +965,11 @@ public:
void update_field();
Item *result_item(THD *thd, Field *field);
void no_rows_in_result() {}
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return has_with_distinct() ? "avg(distinct " : "avg(";
+ static LEX_CSTRING name_distinct= { STRING_WITH_LEN("avg(distinct ")};
+ static LEX_CSTRING name_normal= { STRING_WITH_LEN("avg(") };
+ return has_with_distinct() ? name_distinct : name_normal;
}
Item *copy_or_same(THD* thd);
Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table);
@@ -1047,8 +1053,12 @@ public:
void update_field() override final;
Item *result_item(THD *thd, Field *field) override;
void no_rows_in_result() override final {}
- const char *func_name() const override
- { return sample ? "var_samp(" : "variance("; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name_sample= { STRING_WITH_LEN("var_samp(")};
+ static LEX_CSTRING name_normal= { STRING_WITH_LEN("variance(") };
+ return sample ? name_sample : name_normal;
+ }
Item *copy_or_same(THD* thd) override;
Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table) override
final;
@@ -1076,7 +1086,11 @@ class Item_sum_std final :public Item_sum_variance
enum Sumfunctype sum_func () const override final { return STD_FUNC; }
double val_real() override final;
Item *result_item(THD *thd, Field *field) override final;
- const char *func_name() const override final { return "std("; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING sum_name= {STRING_WITH_LEN("std(") };
+ return sum_name;
+ }
Item *copy_or_same(THD* thd) override final;
Item *get_copy(THD *thd) override final
{ return get_item_copy<Item_sum_std>(thd, this); }
@@ -1172,7 +1186,11 @@ public:
enum Sumfunctype sum_func () const {return MIN_FUNC;}
bool add();
- const char *func_name() const { return "min("; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING sum_name= {STRING_WITH_LEN("min(") };
+ return sum_name;
+ }
Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_min>(thd, this); }
@@ -1187,7 +1205,11 @@ public:
enum Sumfunctype sum_func () const {return MAX_FUNC;}
bool add();
- const char *func_name() const { return "max("; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING sum_name= {STRING_WITH_LEN("max(") };
+ return sum_name;
+ }
Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_max>(thd, this); }
@@ -1216,7 +1238,7 @@ public:
const Type_handler *type_handler() const { return &type_handler_ulonglong; }
bool fix_length_and_dec()
{
- if (args[0]->check_type_can_return_int(func_name()))
+ if (args[0]->check_type_can_return_int(func_name_cstring()))
return true;
decimals= 0; max_length=21; unsigned_flag= 1;
base_flags&= ~item_base_t::MAYBE_NULL;
@@ -1276,7 +1298,11 @@ public:
Item_sum_or(THD *thd, Item *item_par): Item_sum_bit(thd, item_par, 0) {}
Item_sum_or(THD *thd, Item_sum_or *item) :Item_sum_bit(thd, item) {}
bool add();
- const char *func_name() const { return "bit_or("; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING sum_name= {STRING_WITH_LEN("bit_or(") };
+ return sum_name;
+ }
Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_or>(thd, this); }
@@ -1293,7 +1319,11 @@ public:
Item_sum_bit(thd, item_par, ULONGLONG_MAX) {}
Item_sum_and(THD *thd, Item_sum_and *item) :Item_sum_bit(thd, item) {}
bool add();
- const char *func_name() const { return "bit_and("; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING sum_min_name= {STRING_WITH_LEN("bit_and(") };
+ return sum_min_name;
+ }
Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_and>(thd, this); }
@@ -1308,7 +1338,11 @@ public:
Item_sum_xor(THD *thd, Item *item_par): Item_sum_bit(thd, item_par, 0) {}
Item_sum_xor(THD *thd, Item_sum_xor *item) :Item_sum_bit(thd, item) {}
bool add();
- const char *func_name() const { return "bit_xor("; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING sum_min_name= {STRING_WITH_LEN("bit_xor(") };
+ return sum_min_name;
+ }
Item *copy_or_same(THD* thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_xor>(thd, this); }
@@ -1393,7 +1427,7 @@ public:
}
bool fix_length_and_dec();
bool fix_fields(THD *thd, Item **ref);
- const char *func_name() const;
+ LEX_CSTRING func_name_cstring() const override;
const Type_handler *type_handler() const;
bool add();
@@ -1606,7 +1640,11 @@ public:
Item_udf_sum(THD *thd, Item_udf_sum *item)
:Item_sum(thd, item), udf(item->udf)
{ udf.not_original= TRUE; }
- const char *func_name() const { return udf.name(); }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ const char *tmp= udf.name();
+ return {tmp, strlen(tmp) };
+ }
bool fix_fields(THD *thd, Item **ref)
{
DBUG_ASSERT(fixed() == 0);
@@ -1973,7 +2011,11 @@ public:
void cleanup();
enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;}
- const char *func_name() const { return "group_concat("; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING sum_name= {STRING_WITH_LEN("group_concat(") };
+ return sum_name;
+ }
const Type_handler *type_handler() const
{
if (too_big_for_varchar())
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 96d7daf9c63..cd46992701b 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -976,7 +976,7 @@ bool Item_func_monthname::fix_length_and_dec()
{
THD* thd= current_thd;
CHARSET_INFO *cs= thd->variables.collation_connection;
- locale= thd->variables.lc_time_names;
+ locale= thd->variables.lc_time_names;
collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire());
decimals=0;
max_length= locale->max_month_name_length * collation.collation->mbmaxlen;
@@ -1575,7 +1575,7 @@ bool Item_func_curtime::get_date(THD *thd, MYSQL_TIME *res,
void Item_func_curtime::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
if (decimals)
str->append_ulonglong(decimals);
@@ -1637,7 +1637,7 @@ bool Item_func_now::fix_fields(THD *thd, Item **items)
void Item_func_now::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
if (decimals)
str->append_ulonglong(decimals);
@@ -2109,16 +2109,19 @@ static const char *interval_names[]=
void Item_date_add_interval::print(String *str, enum_query_type query_type)
{
args[0]->print_parenthesised(str, query_type, INTERVAL_PRECEDENCE);
- str->append(date_sub_interval?" - interval ":" + interval ");
+ static LEX_CSTRING minus_interval= { STRING_WITH_LEN(" - interval ") };
+ static LEX_CSTRING plus_interval= { STRING_WITH_LEN(" + interval ") };
+ LEX_CSTRING *tmp= date_sub_interval ? &minus_interval : &plus_interval;
+ str->append(tmp);
args[1]->print(str, query_type);
str->append(' ');
- str->append(interval_names[int_type]);
+ str->append(interval_names[int_type], strlen(interval_names[int_type]));
}
void Item_extract::print(String *str, enum_query_type query_type)
{
str->append(STRING_WITH_LEN("extract("));
- str->append(interval_names[int_type]);
+ str->append(interval_names[int_type], strlen(interval_names[int_type]));
str->append(STRING_WITH_LEN(" from "));
args[0]->print(str, query_type);
str->append(')');
@@ -2260,7 +2263,8 @@ void Item_func::print_cast_temporal(String *str, enum_query_type query_type)
if (decimals && decimals != NOT_FIXED_DEC)
{
str->append('(');
- str->append(llstr(decimals, buf));
+ size_t length= (size_t) (longlong10_to_str(decimals, buf, -10) - buf);
+ str->append(buf, length);
str->append(')');
}
str->append(')');
@@ -2274,18 +2278,16 @@ void Item_char_typecast::print(String *str, enum_query_type query_type)
str->append(STRING_WITH_LEN(" as char"));
if (cast_length != ~0U)
{
+ char buf[20];
+ size_t length= (size_t) (longlong10_to_str(cast_length, buf, 10) - buf);
str->append('(');
- char buffer[20];
- // my_charset_bin is good enough for numbers
- String st(buffer, sizeof(buffer), &my_charset_bin);
- st.set(static_cast<ulonglong>(cast_length), &my_charset_bin);
- str->append(st);
+ str->append(buf, length);
str->append(')');
}
if (cast_cs)
{
str->append(STRING_WITH_LEN(" charset "));
- str->append(cast_cs->csname);
+ str->append(cast_cs->csname, strlen(cast_cs->csname));
}
str->append(')');
}
@@ -2882,7 +2884,7 @@ null_date:
void Item_func_timestamp_diff::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
switch (int_type) {
@@ -2961,7 +2963,7 @@ String *Item_func_get_format::val_str_ascii(String *str)
void Item_func_get_format::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
switch (type) {
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index c717a7bde98..892eb42c558 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -33,7 +33,7 @@ bool get_interval_value(THD *thd, Item *args,
class Item_long_func_date_field: public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_can_return_date(func_name()); }
+ { return args[0]->check_type_can_return_date(func_name_cstring()); }
public:
Item_long_func_date_field(THD *thd, Item *a)
:Item_long_func(thd, a) { }
@@ -43,7 +43,7 @@ public:
class Item_long_func_time_field: public Item_long_func
{
bool check_arguments() const
- { return args[0]->check_type_can_return_time(func_name()); }
+ { return args[0]->check_type_can_return_time(func_name_cstring()); }
public:
Item_long_func_time_field(THD *thd, Item *a)
:Item_long_func(thd, a) { }
@@ -57,7 +57,11 @@ class Item_func_period_add :public Item_long_func
public:
Item_func_period_add(THD *thd, Item *a, Item *b): Item_long_func(thd, a, b) {}
longlong val_int();
- const char *func_name() const { return "period_add"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("period_add") };
+ return name;
+ }
bool fix_length_and_dec()
{
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
@@ -75,7 +79,11 @@ class Item_func_period_diff :public Item_long_func
public:
Item_func_period_diff(THD *thd, Item *a, Item *b): Item_long_func(thd, a, b) {}
longlong val_int();
- const char *func_name() const { return "period_diff"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("period_diff") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -92,7 +100,11 @@ class Item_func_to_days :public Item_long_func_date_field
public:
Item_func_to_days(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
longlong val_int();
- const char *func_name() const { return "to_days"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("to_days") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -120,7 +132,11 @@ class Item_func_to_seconds :public Item_longlong_func
public:
Item_func_to_seconds(THD *thd, Item *a): Item_longlong_func(thd, a) {}
longlong val_int();
- const char *func_name() const { return "to_seconds"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("to_seconds") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -147,7 +163,11 @@ class Item_func_dayofmonth :public Item_long_func_date_field
public:
Item_func_dayofmonth(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
longlong val_int();
- const char *func_name() const { return "dayofmonth"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("dayofmonth") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -172,7 +192,11 @@ public:
Item_func_month(THD *thd, Item *a): Item_long_func(thd, a)
{ }
longlong val_int();
- const char *func_name() const { return "month"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("month") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals= 0;
@@ -196,7 +220,11 @@ class Item_func_monthname :public Item_str_func
MY_LOCALE *locale;
public:
Item_func_monthname(THD *thd, Item *a): Item_str_func(thd, a) {}
- const char *func_name() const { return "monthname"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("monthname") };
+ return name;
+ }
String *val_str(String *str);
bool fix_length_and_dec();
bool check_partition_func_processor(void *int_arg) {return TRUE;}
@@ -218,7 +246,11 @@ class Item_func_dayofyear :public Item_long_func_date_field
public:
Item_func_dayofyear(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
longlong val_int();
- const char *func_name() const { return "dayofyear"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("dayofyear") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals= 0;
@@ -242,7 +274,11 @@ class Item_func_hour :public Item_long_func_time_field
public:
Item_func_hour(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
longlong val_int();
- const char *func_name() const { return "hour"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("hour") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -266,7 +302,11 @@ class Item_func_minute :public Item_long_func_time_field
public:
Item_func_minute(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
longlong val_int();
- const char *func_name() const { return "minute"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("minute") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -290,7 +330,11 @@ class Item_func_quarter :public Item_long_func_date_field
public:
Item_func_quarter(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
longlong val_int();
- const char *func_name() const { return "quarter"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("quarter") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -314,7 +358,11 @@ class Item_func_second :public Item_long_func_time_field
public:
Item_func_second(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
longlong val_int();
- const char *func_name() const { return "second"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("second") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -337,14 +385,18 @@ class Item_func_week :public Item_long_func
{
bool check_arguments() const
{
- return args[0]->check_type_can_return_date(func_name()) ||
- (arg_count > 1 && args[1]->check_type_can_return_int(func_name()));
+ return args[0]->check_type_can_return_date(func_name_cstring()) ||
+ (arg_count > 1 && args[1]->check_type_can_return_int(func_name_cstring()));
}
public:
Item_func_week(THD *thd, Item *a): Item_long_func(thd, a) {}
Item_func_week(THD *thd, Item *a, Item *b): Item_long_func(thd, a, b) {}
longlong val_int();
- const char *func_name() const { return "week"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("week") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -370,14 +422,18 @@ class Item_func_yearweek :public Item_long_func
{
bool check_arguments() const
{
- return args[0]->check_type_can_return_date(func_name()) ||
- args[1]->check_type_can_return_int(func_name());
+ return args[0]->check_type_can_return_date(func_name_cstring()) ||
+ args[1]->check_type_can_return_int(func_name_cstring());
}
public:
Item_func_yearweek(THD *thd, Item *a, Item *b)
:Item_long_func(thd, a, b) {}
longlong val_int();
- const char *func_name() const { return "yearweek"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("yearweek") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -401,7 +457,11 @@ class Item_func_year :public Item_long_func_date_field
public:
Item_func_year(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
longlong val_int();
- const char *func_name() const { return "year"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("year") };
+ return name;
+ }
enum_monotonicity_info get_monotonicity_info() const;
longlong val_int_endpoint(bool left_endp, bool *incl_endp);
bool fix_length_and_dec()
@@ -429,9 +489,11 @@ public:
Item_func_weekday(THD *thd, Item *a, bool type_arg):
Item_long_func(thd, a), odbc_type(type_arg) { }
longlong val_int();
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return (odbc_type ? "dayofweek" : "weekday");
+ static LEX_CSTRING dayofweek= {STRING_WITH_LEN("dayofweek") };
+ static LEX_CSTRING weekday= {STRING_WITH_LEN("weekday") };
+ return (odbc_type ? dayofweek : weekday);
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
@@ -459,7 +521,11 @@ class Item_func_dayname :public Item_str_func
MY_LOCALE *locale;
public:
Item_func_dayname(THD *thd, Item *a): Item_str_func(thd, a) {}
- const char *func_name() const { return "dayname"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("dayname") };
+ return name;
+ }
String *val_str(String *str);
const Type_handler *type_handler() const { return &type_handler_varchar; }
bool fix_length_and_dec();
@@ -510,7 +576,11 @@ public:
Item_func_unix_timestamp(THD *thd): Item_func_seconds_hybrid(thd) {}
Item_func_unix_timestamp(THD *thd, Item *a):
Item_func_seconds_hybrid(thd, a) {}
- const char *func_name() const { return "unix_timestamp"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("unix_timestamp") };
+ return name;
+ }
enum_monotonicity_info get_monotonicity_info() const;
longlong val_int_endpoint(bool left_endp, bool *incl_endp);
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -547,7 +617,11 @@ class Item_func_time_to_sec :public Item_func_seconds_hybrid
public:
Item_func_time_to_sec(THD *thd, Item *item):
Item_func_seconds_hybrid(thd, item) {}
- const char *func_name() const { return "time_to_sec"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("time_to_sec") };
+ return name;
+ }
bool check_partition_func_processor(void *int_arg) {return FALSE;}
bool check_vcol_func_processor(void *arg) { return FALSE;}
bool check_valid_arguments_processor(void *int_arg)
@@ -651,7 +725,11 @@ class Item_func_curtime_local :public Item_func_curtime
{
public:
Item_func_curtime_local(THD *thd, uint dec): Item_func_curtime(thd, dec) {}
- const char *func_name() const { return "curtime"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("curtime") };
+ return name;
+ }
virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_curtime_local>(thd, this); }
@@ -662,7 +740,11 @@ class Item_func_curtime_utc :public Item_func_curtime
{
public:
Item_func_curtime_utc(THD *thd, uint dec): Item_func_curtime(thd, dec) {}
- const char *func_name() const { return "utc_time"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("utc_time") };
+ return name;
+ }
virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_curtime_utc>(thd, this); }
@@ -690,7 +772,11 @@ class Item_func_curdate_local :public Item_func_curdate
{
public:
Item_func_curdate_local(THD *thd): Item_func_curdate(thd) {}
- const char *func_name() const { return "curdate"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("curdate") };
+ return name;
+ }
void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_curdate_local>(thd, this); }
@@ -701,7 +787,11 @@ class Item_func_curdate_utc :public Item_func_curdate
{
public:
Item_func_curdate_utc(THD *thd): Item_func_curdate(thd) {}
- const char *func_name() const { return "utc_date"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("utc_date") };
+ return name;
+ }
void store_now_in_TIME(THD* thd, MYSQL_TIME *now_time);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_curdate_utc>(thd, this); }
@@ -738,7 +828,11 @@ class Item_func_now_local :public Item_func_now
{
public:
Item_func_now_local(THD *thd, uint dec): Item_func_now(thd, dec) {}
- const char *func_name() const { return "current_timestamp"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("current_timestamp") };
+ return name;
+ }
int save_in_field(Field *field, bool no_conversions);
virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time);
virtual enum Functype functype() const { return NOW_FUNC; }
@@ -751,7 +845,11 @@ class Item_func_now_utc :public Item_func_now
{
public:
Item_func_now_utc(THD *thd, uint dec): Item_func_now(thd, dec) {}
- const char *func_name() const { return "utc_timestamp"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("utc_timestamp") };
+ return name;
+ }
virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time);
virtual enum Functype functype() const { return NOW_UTC_FUNC; }
virtual bool check_vcol_func_processor(void *arg)
@@ -773,7 +871,11 @@ class Item_func_sysdate_local :public Item_func_now
public:
Item_func_sysdate_local(THD *thd, uint dec): Item_func_now(thd, dec) {}
bool const_item() const { return 0; }
- const char *func_name() const { return "sysdate"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sysdate") };
+ return name;
+ }
void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time);
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate);
table_map used_tables() const { return RAND_TABLE_BIT; }
@@ -791,10 +893,14 @@ public:
class Item_func_from_days :public Item_datefunc
{
bool check_arguments() const
- { return args[0]->check_type_can_return_int(func_name()); }
+ { return args[0]->check_type_can_return_int(func_name_cstring()); }
public:
Item_func_from_days(THD *thd, Item *a): Item_datefunc(thd, a) {}
- const char *func_name() const { return "from_days"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("from_days") };
+ return name;
+ }
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate);
bool check_partition_func_processor(void *int_arg) {return FALSE;}
bool check_vcol_func_processor(void *arg) { return FALSE;}
@@ -811,7 +917,7 @@ class Item_func_date_format :public Item_str_func
{
bool check_arguments() const
{
- return args[0]->check_type_can_return_date(func_name()) ||
+ return args[0]->check_type_can_return_date(func_name_cstring()) ||
check_argument_types_can_return_text(1, arg_count);
}
const MY_LOCALE *locale;
@@ -825,7 +931,11 @@ public:
Item_func_date_format(THD *thd, Item *a, Item *b, Item *c):
Item_str_func(thd, a, b, c), locale(0), is_time_format(false) {}
String *val_str(String *str);
- const char *func_name() const { return "date_format"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("date_format") };
+ return name;
+ }
bool fix_length_and_dec();
uint format_length(const String *format);
bool eq(const Item *item, bool binary_cmp) const;
@@ -844,7 +954,11 @@ class Item_func_time_format: public Item_func_date_format
public:
Item_func_time_format(THD *thd, Item *a, Item *b):
Item_func_date_format(thd, a, b) { is_time_format= true; }
- const char *func_name() const { return "time_format"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("time_format") };
+ return name;
+ }
bool check_vcol_func_processor(void *arg) { return false; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_time_format>(thd, this); }
@@ -854,11 +968,15 @@ public:
class Item_func_from_unixtime :public Item_datetimefunc
{
bool check_arguments() const
- { return args[0]->check_type_can_return_decimal(func_name()); }
+ { return args[0]->check_type_can_return_decimal(func_name_cstring()); }
Time_zone *tz;
public:
Item_func_from_unixtime(THD *thd, Item *a): Item_datetimefunc(thd, a) {}
- const char *func_name() const { return "from_unixtime"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("from_unixtime") };
+ return name;
+ }
bool fix_length_and_dec();
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate);
bool check_vcol_func_processor(void *arg)
@@ -888,7 +1006,7 @@ class Item_func_convert_tz :public Item_datetimefunc
{
bool check_arguments() const
{
- return args[0]->check_type_can_return_date(func_name()) ||
+ return args[0]->check_type_can_return_date(func_name_cstring()) ||
check_argument_types_can_return_text(1, arg_count);
}
/*
@@ -902,7 +1020,11 @@ class Item_func_convert_tz :public Item_datetimefunc
public:
Item_func_convert_tz(THD *thd, Item *a, Item *b, Item *c):
Item_datetimefunc(thd, a, b, c), from_tz_cached(0), to_tz_cached(0) {}
- const char *func_name() const { return "convert_tz"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("convert_tz") };
+ return name;
+ }
bool fix_length_and_dec()
{
fix_attributes_datetime(args[0]->datetime_precision(current_thd));
@@ -919,7 +1041,7 @@ class Item_func_convert_tz :public Item_datetimefunc
class Item_func_sec_to_time :public Item_timefunc
{
bool check_arguments() const
- { return args[0]->check_type_can_return_decimal(func_name()); }
+ { return args[0]->check_type_can_return_decimal(func_name_cstring()); }
public:
Item_func_sec_to_time(THD *thd, Item *item): Item_timefunc(thd, item) {}
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate);
@@ -929,7 +1051,11 @@ public:
set_maybe_null();
return FALSE;
}
- const char *func_name() const { return "sec_to_time"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sec_to_time") };
+ return name;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_sec_to_time>(thd, this); }
};
@@ -944,7 +1070,11 @@ public:
bool neg_arg):
Item_handled_func(thd, a, b), int_type(type_arg),
date_sub_interval(neg_arg) {}
- const char *func_name() const { return "date_add_interval"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("date_add_interval") };
+ return name;
+ }
bool fix_length_and_dec();
bool eq(const Item *item, bool binary_cmp) const;
void print(String *str, enum_query_type query_type);
@@ -1005,7 +1135,11 @@ class Item_extract :public Item_int_func,
}
longlong val_int();
enum Functype functype() const { return EXTRACT_FUNC; }
- const char *func_name() const { return "extract"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("extract") };
+ return name;
+ }
bool check_arguments() const;
bool fix_length_and_dec();
bool eq(const Item *item, bool binary_cmp) const;
@@ -1082,7 +1216,11 @@ public:
m_suppress_warning_to_error_escalation(false) {}
enum Functype functype() const { return CHAR_TYPECAST_FUNC; }
bool eq(const Item *item, bool binary_cmp) const;
- const char *func_name() const { return "cast_as_char"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_char") };
+ return name;
+ }
CHARSET_INFO *cast_charset() const { return cast_cs; }
String *val_str_generic(String *a);
String *val_str_binary_from_native(String *a);
@@ -1123,7 +1261,11 @@ class Item_date_typecast :public Item_datefunc
{
public:
Item_date_typecast(THD *thd, Item *a): Item_datefunc(thd, a) {}
- const char *func_name() const { return "cast_as_date"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_date") };
+ return name;
+ }
void print(String *str, enum_query_type query_type)
{
print_cast_temporal(str, query_type);
@@ -1143,7 +1285,11 @@ class Item_time_typecast :public Item_timefunc
public:
Item_time_typecast(THD *thd, Item *a, uint dec_arg):
Item_timefunc(thd, a) { decimals= dec_arg; }
- const char *func_name() const { return "cast_as_time"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_time") };
+ return name;
+ }
void print(String *str, enum_query_type query_type)
{
print_cast_temporal(str, query_type);
@@ -1165,7 +1311,11 @@ class Item_datetime_typecast :public Item_datetimefunc
public:
Item_datetime_typecast(THD *thd, Item *a, uint dec_arg):
Item_datetimefunc(thd, a) { decimals= dec_arg; }
- const char *func_name() const { return "cast_as_datetime"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_datetime") };
+ return name;
+ }
void print(String *str, enum_query_type query_type)
{
print_cast_temporal(str, query_type);
@@ -1189,7 +1339,11 @@ class Item_func_makedate :public Item_datefunc
public:
Item_func_makedate(THD *thd, Item *a, Item *b):
Item_datefunc(thd, a, b) {}
- const char *func_name() const { return "makedate"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("makedate") };
+ return name;
+ }
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_makedate>(thd, this); }
@@ -1200,14 +1354,18 @@ class Item_func_timestamp :public Item_datetimefunc
{
bool check_arguments() const
{
- return args[0]->check_type_can_return_date(func_name()) ||
- args[1]->check_type_can_return_time(func_name());
+ return args[0]->check_type_can_return_date(func_name_cstring()) ||
+ args[1]->check_type_can_return_time(func_name_cstring());
}
public:
Item_func_timestamp(THD *thd, Item *a, Item *b)
:Item_datetimefunc(thd, a, b)
{ }
- const char *func_name() const { return "timestamp"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("timestamp") };
+ return name;
+ }
bool fix_length_and_dec()
{
THD *thd= current_thd;
@@ -1255,7 +1413,12 @@ public:
:Item_handled_func(thd, a, b), sign(neg_arg ? -1 : 1)
{ }
bool fix_length_and_dec();
- const char *func_name() const { return sign > 0 ? "addtime" : "subtime"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING addtime= { STRING_WITH_LEN("addtime") };
+ static LEX_CSTRING subtime= { STRING_WITH_LEN("subtime") };
+ return sign > 0 ? addtime : subtime;
+ }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_add_time>(thd, this); }
};
@@ -1267,7 +1430,11 @@ class Item_func_timediff :public Item_timefunc
{ return check_argument_types_can_return_time(0, arg_count); }
public:
Item_func_timediff(THD *thd, Item *a, Item *b): Item_timefunc(thd, a, b) {}
- const char *func_name() const { return "timediff"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("timediff") };
+ return name;
+ }
bool fix_length_and_dec()
{
THD *thd= current_thd;
@@ -1287,7 +1454,7 @@ class Item_func_maketime :public Item_timefunc
bool check_arguments() const
{
return check_argument_types_can_return_int(0, 2) ||
- args[2]->check_type_can_return_decimal(func_name());
+ args[2]->check_type_can_return_decimal(func_name_cstring());
}
public:
Item_func_maketime(THD *thd, Item *a, Item *b, Item *c):
@@ -1299,7 +1466,11 @@ public:
set_maybe_null();
return FALSE;
}
- const char *func_name() const { return "maketime"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("maketime") };
+ return name;
+ }
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_maketime>(thd, this); }
@@ -1311,7 +1482,11 @@ class Item_func_microsecond :public Item_long_func_time_field
public:
Item_func_microsecond(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
longlong val_int();
- const char *func_name() const { return "microsecond"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("microsecond") };
+ return name;
+ }
bool fix_length_and_dec()
{
decimals=0;
@@ -1341,7 +1516,11 @@ public:
public:
Item_func_timestamp_diff(THD *thd, Item *a, Item *b, interval_type type_arg):
Item_longlong_func(thd, a, b), int_type(type_arg) {}
- const char *func_name() const { return "timestampdiff"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("timestampdiff") };
+ return name;
+ }
longlong val_int();
bool fix_length_and_dec()
{
@@ -1368,7 +1547,11 @@ public:
Item_str_ascii_func(thd, a), type(type_arg)
{}
String *val_str_ascii(String *str);
- const char *func_name() const { return "get_format"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("get_format") };
+ return name;
+ }
bool fix_length_and_dec()
{
set_maybe_null();
@@ -1395,7 +1578,11 @@ public:
{}
bool get_date_common(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate,
timestamp_type);
- const char *func_name() const { return "str_to_date"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("str_to_date") };
+ return name;
+ }
bool fix_length_and_dec();
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_str_to_date>(thd, this); }
@@ -1405,10 +1592,14 @@ public:
class Item_func_last_day :public Item_datefunc
{
bool check_arguments() const
- { return args[0]->check_type_can_return_date(func_name()); }
+ { return args[0]->check_type_can_return_date(func_name_cstring()); }
public:
Item_func_last_day(THD *thd, Item *a): Item_datefunc(thd, a) {}
- const char *func_name() const { return "last_day"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("last_day") };
+ return name;
+ }
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_last_day>(thd, this); }
diff --git a/sql/item_vers.cc b/sql/item_vers.cc
index c431cfb3c4e..c510329eed0 100644
--- a/sql/item_vers.cc
+++ b/sql/item_vers.cc
@@ -36,7 +36,7 @@ bool Item_func_history::val_bool()
void Item_func_history::print(String *str, enum_query_type query_type)
{
- str->append(func_name());
+ str->append(func_name_cstring());
str->append('(');
args[0]->print(str, query_type);
str->append(')');
diff --git a/sql/item_vers.h b/sql/item_vers.h
index e6cfe652029..177336775c5 100644
--- a/sql/item_vers.h
+++ b/sql/item_vers.h
@@ -46,7 +46,11 @@ public:
max_length= 1;
return FALSE;
}
- virtual const char* func_name() const { return "is_history"; }
+ virtual LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("is_history") };
+ return name;
+ }
virtual void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_history>(thd, this); }
@@ -57,13 +61,11 @@ class Item_func_trt_ts: public Item_datetimefunc
TR_table::field_id_t trt_field;
public:
Item_func_trt_ts(THD *thd, Item* a, TR_table::field_id_t _trt_field);
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- if (trt_field == TR_table::FLD_BEGIN_TS)
- {
- return "trt_begin_ts";
- }
- return "trt_commit_ts";
+ static LEX_CSTRING begin_name= {STRING_WITH_LEN("trt_begin_ts") };
+ static LEX_CSTRING commit_name= {STRING_WITH_LEN("trt_commit_ts") };
+ return (trt_field == TR_table::FLD_BEGIN_TS) ? begin_name : commit_name;
}
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate);
Item *get_copy(THD *thd)
@@ -84,20 +86,23 @@ public:
Item_func_trt_id(THD *thd, Item* a, TR_table::field_id_t _trt_field, bool _backwards= false);
Item_func_trt_id(THD *thd, Item* a, Item* b, TR_table::field_id_t _trt_field);
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- switch (trt_field)
- {
+ static LEX_CSTRING trx_name= {STRING_WITH_LEN("trt_trx_id") };
+ static LEX_CSTRING commit_name= {STRING_WITH_LEN("trt_commit_id") };
+ static LEX_CSTRING iso_name= {STRING_WITH_LEN("trt_iso_level") };
+
+ switch (trt_field) {
case TR_table::FLD_TRX_ID:
- return "trt_trx_id";
+ return trx_name;
case TR_table::FLD_COMMIT_ID:
- return "trt_commit_id";
+ return commit_name;
case TR_table::FLD_ISO_LEVEL:
- return "trt_iso_level";
+ return iso_name;
default:
DBUG_ASSERT(0);
}
- return NULL;
+ return NULL_clex_str;
}
bool fix_length_and_dec()
@@ -119,9 +124,10 @@ protected:
public:
Item_func_trt_trx_sees(THD *thd, Item* a, Item* b);
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "trt_trx_sees";
+ static LEX_CSTRING name= {STRING_WITH_LEN("trt_trx_sees") };
+ return name;
}
longlong val_int();
Item *get_copy(THD *thd)
@@ -137,9 +143,10 @@ public:
{
accept_eq= true;
}
- const char *func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "trt_trx_sees_eq";
+ static LEX_CSTRING name= {STRING_WITH_LEN("trt_trx_sees_eq") };
+ return name;
}
};
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index 262481d019b..a9e008b0b92 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -99,13 +99,15 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
if (window_spec->window_frame && is_frame_prohibited())
{
- my_error(ER_NOT_ALLOWED_WINDOW_FRAME, MYF(0), window_func()->func_name());
+ my_error(ER_NOT_ALLOWED_WINDOW_FRAME, MYF(0),
+ window_func()->func_name());
return true;
}
if (window_spec->order_list->elements == 0 && is_order_list_mandatory())
{
- my_error(ER_NO_ORDER_LIST_IN_WINDOW_SPEC, MYF(0), window_func()->func_name());
+ my_error(ER_NO_ORDER_LIST_IN_WINDOW_SPEC, MYF(0),
+ window_func()->func_name());
return true;
}
@@ -180,7 +182,8 @@ bool Item_window_func::check_result_type_of_order_item()
if (rtype != REAL_RESULT && rtype != INT_RESULT &&
rtype != DECIMAL_RESULT && rtype != TIME_RESULT)
{
- my_error(ER_WRONG_TYPE_FOR_PERCENTILE_FUNC, MYF(0), window_func()->func_name());
+ my_error(ER_WRONG_TYPE_FOR_PERCENTILE_FUNC, MYF(0),
+ window_func()->func_name());
return true;
}
return false;
@@ -553,7 +556,7 @@ void Item_window_func::print(String *str, enum_query_type query_type)
return;
}
window_func()->print(str, query_type);
- str->append(" over ");
+ str->append(STRING_WITH_LEN(" over "));
if (!window_spec)
str->append(window_name);
else
@@ -562,11 +565,11 @@ void Item_window_func::print(String *str, enum_query_type query_type)
void Item_window_func::print_for_percentile_functions(String *str, enum_query_type query_type)
{
window_func()->print(str, query_type);
- str->append(" within group ");
+ str->append(STRING_WITH_LEN(" within group "));
str->append('(');
window_spec->print_order(str,query_type);
str->append(')');
- str->append(" over ");
+ str->append(STRING_WITH_LEN(" over "));
str->append('(');
window_spec->print_partition(str,query_type);
str->append(')');
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h
index 99ef738ac69..196e69438b5 100644
--- a/sql/item_windowfunc.h
+++ b/sql/item_windowfunc.h
@@ -143,9 +143,10 @@ public:
{
return count;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "row_number";
+ static LEX_CSTRING name= {STRING_WITH_LEN("row_number") };
+ return name;
}
Item *get_copy(THD *thd)
@@ -205,9 +206,10 @@ public:
return RANK_FUNC;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "rank";
+ static LEX_CSTRING name= {STRING_WITH_LEN("rank") };
+ return name;
}
void setup_window_func(THD *thd, Window_spec *window_spec);
@@ -276,9 +278,10 @@ class Item_sum_dense_rank: public Item_sum_int
return DENSE_RANK_FUNC;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "dense_rank";
+ static LEX_CSTRING name= {STRING_WITH_LEN("dense_rank") };
+ return name;
}
void setup_window_func(THD *thd, Window_spec *window_spec);
@@ -350,9 +353,10 @@ class Item_sum_first_value : public Item_sum_hybrid_simple
return FIRST_VALUE_FUNC;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "first_value";
+ static LEX_CSTRING name= {STRING_WITH_LEN("first_value") };
+ return name;
}
Item *get_copy(THD *thd)
@@ -376,15 +380,17 @@ class Item_sum_last_value : public Item_sum_hybrid_simple
return LAST_VALUE_FUNC;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "last_value";
+ static LEX_CSTRING name= {STRING_WITH_LEN("last_value") };
+ return name;
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_last_value>(thd, this); }
};
+
class Item_sum_nth_value : public Item_sum_hybrid_simple
{
public:
@@ -396,15 +402,17 @@ class Item_sum_nth_value : public Item_sum_hybrid_simple
return NTH_VALUE_FUNC;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "nth_value";
+ static LEX_CSTRING name= {STRING_WITH_LEN("nth_value") };
+ return name;
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_nth_value>(thd, this); }
};
+
class Item_sum_lead : public Item_sum_hybrid_simple
{
public:
@@ -416,15 +424,17 @@ class Item_sum_lead : public Item_sum_hybrid_simple
return LEAD_FUNC;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "lead";
+ static LEX_CSTRING name= {STRING_WITH_LEN("lead") };
+ return name;
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_lead>(thd, this); }
};
+
class Item_sum_lag : public Item_sum_hybrid_simple
{
public:
@@ -436,9 +446,10 @@ class Item_sum_lag : public Item_sum_hybrid_simple
return LAG_FUNC;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "lag";
+ static LEX_CSTRING name= {STRING_WITH_LEN("lag") };
+ return name;
}
Item *get_copy(THD *thd)
@@ -523,9 +534,10 @@ class Item_sum_percent_rank: public Item_sum_double,
return PERCENT_RANK_FUNC;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "percent_rank";
+ static LEX_CSTRING name= {STRING_WITH_LEN("percent_rank") };
+ return name;
}
void update_field() {}
@@ -618,9 +630,10 @@ class Item_sum_cume_dist: public Item_sum_double,
partition_row_count_= 0;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "cume_dist";
+ static LEX_CSTRING name= {STRING_WITH_LEN("cume_dist") };
+ return name;
}
void update_field() {}
@@ -699,9 +712,10 @@ class Item_sum_ntile : public Item_sum_int,
n_old_val_= 0;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "ntile";
+ static LEX_CSTRING name= {STRING_WITH_LEN("ntile") };
+ return name;
}
void update_field() {}
@@ -855,9 +869,10 @@ public:
current_row_count_= 0;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "percentile_disc";
+ static LEX_CSTRING name= {STRING_WITH_LEN("percentile_disc") };
+ return name;
}
void update_field() {}
@@ -994,9 +1009,10 @@ public:
current_row_count_= 0;
}
- const char*func_name() const
+ LEX_CSTRING func_name_cstring() const override
{
- return "percentile_cont";
+ static LEX_CSTRING name= {STRING_WITH_LEN("percentile_cont") };
+ return name;
}
void update_field() {}
@@ -1357,7 +1373,11 @@ public:
return FALSE;
}
- const char* func_name() const { return "WF"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("WF") };
+ return name;
+ }
bool fix_fields(THD *thd, Item **ref);
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index f0c1f0f5075..b926564bdf9 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -198,7 +198,10 @@ public:
const_item_cache= false;
return FALSE;
}
- const char *func_name() const { return "nodeset"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("nodeset") };
+ }
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE);
@@ -213,7 +216,10 @@ class Item_nodeset_func_rootelement :public Item_nodeset_func
public:
Item_nodeset_func_rootelement(THD *thd, String *pxml):
Item_nodeset_func(thd, pxml) {}
- const char *func_name() const { return "xpath_rootelement"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_rootelement") };
+ }
bool val_native(THD *thd, Native *nodeset);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_nodeset_func_rootelement>(thd, this); }
@@ -226,7 +232,10 @@ class Item_nodeset_func_union :public Item_nodeset_func
public:
Item_nodeset_func_union(THD *thd, Item *a, Item *b, String *pxml):
Item_nodeset_func(thd, a, b, pxml) {}
- const char *func_name() const { return "xpath_union"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_union") };
+ }
bool val_native(THD *thd, Native *nodeset);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_nodeset_func_union>(thd, this); }
@@ -242,7 +251,10 @@ public:
Item_nodeset_func_axisbyname(THD *thd, Item *a, const char *n_arg, uint l_arg,
String *pxml):
Item_nodeset_func(thd, a, pxml), node_name(n_arg), node_namelen(l_arg) { }
- const char *func_name() const { return "xpath_axisbyname"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_axisbyname") };
+ }
bool validname(MY_XML_NODE *n)
{
if (node_name[0] == '*')
@@ -260,7 +272,10 @@ public:
Item_nodeset_func_selfbyname(THD *thd, Item *a, const char *n_arg, uint l_arg,
String *pxml):
Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml) {}
- const char *func_name() const { return "xpath_selfbyname"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_selfbyname") };
+ }
bool val_native(THD *thd, Native *nodeset);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_nodeset_func_selfbyname>(thd, this); }
@@ -274,7 +289,10 @@ public:
Item_nodeset_func_childbyname(THD *thd, Item *a, const char *n_arg, uint l_arg,
String *pxml):
Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml) {}
- const char *func_name() const { return "xpath_childbyname"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_childbyname") };
+ }
bool val_native(THD *thd, Native *nodeset);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_nodeset_func_childbyname>(thd, this); }
@@ -290,7 +308,10 @@ public:
String *pxml, bool need_self_arg):
Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml),
need_self(need_self_arg) {}
- const char *func_name() const { return "xpath_descendantbyname"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_descendantbyname") };
+ }
bool val_native(THD *thd, Native *nodeset);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_nodeset_func_descendantbyname>(thd, this); }
@@ -306,7 +327,10 @@ public:
String *pxml, bool need_self_arg):
Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml),
need_self(need_self_arg) {}
- const char *func_name() const { return "xpath_ancestorbyname"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_ancestorbyname") };
+ }
bool val_native(THD *thd, Native *nodeset);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_nodeset_func_ancestorbyname>(thd, this); }
@@ -320,7 +344,11 @@ public:
Item_nodeset_func_parentbyname(THD *thd, Item *a, const char *n_arg, uint l_arg,
String *pxml):
Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml) {}
- const char *func_name() const { return "xpath_parentbyname"; }
+
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_parentbyname") };
+ }
bool val_native(THD *thd, Native *nodeset);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_nodeset_func_parentbyname>(thd, this); }
@@ -334,7 +362,10 @@ public:
Item_nodeset_func_attributebyname(THD *thd, Item *a, const char *n_arg,
uint l_arg, String *pxml):
Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml) {}
- const char *func_name() const { return "xpath_attributebyname"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_attributebyname") };
+ }
bool val_native(THD *thd, Native *nodeset);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_nodeset_func_attributebyname>(thd, this); }
@@ -351,7 +382,10 @@ class Item_nodeset_func_predicate :public Item_nodeset_func
public:
Item_nodeset_func_predicate(THD *thd, Item *a, Item *b, String *pxml):
Item_nodeset_func(thd, a, b, pxml) {}
- const char *func_name() const { return "xpath_predicate"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_predicate") };
+ }
bool val_native(THD *thd, Native *nodeset);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_nodeset_func_predicate>(thd, this); }
@@ -364,7 +398,10 @@ class Item_nodeset_func_elementbyindex :public Item_nodeset_func
public:
Item_nodeset_func_elementbyindex(THD *thd, Item *a, Item *b, String *pxml):
Item_nodeset_func(thd, a, b, pxml) { }
- const char *func_name() const { return "xpath_elementbyindex"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_elementbyindex") };
+ }
bool val_native(THD *thd, Native *nodeset);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_nodeset_func_elementbyindex>(thd, this); }
@@ -384,7 +421,10 @@ class Item_xpath_cast_bool :public Item_bool_func
public:
Item_xpath_cast_bool(THD *thd, Item *a, String *pxml_arg):
Item_bool_func(thd, a), pxml(pxml_arg) {}
- const char *func_name() const { return "xpath_cast_bool"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_cast_bool") };
+ }
longlong val_int()
{
if (args[0]->fixed_type_handler() == &type_handler_xpath_nodeset)
@@ -406,7 +446,10 @@ class Item_xpath_cast_number :public Item_real_func
{
public:
Item_xpath_cast_number(THD *thd, Item *a): Item_real_func(thd, a) {}
- const char *func_name() const { return "xpath_cast_number"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_cast_number") };
+ }
virtual double val_real() { return args[0]->val_real(); }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_xpath_cast_number>(thd, this); }
@@ -439,7 +482,10 @@ class Item_func_xpath_position :public Item_long_func
public:
Item_func_xpath_position(THD *thd, Item *a, String *p):
Item_long_func(thd, a), pxml(p) {}
- const char *func_name() const { return "xpath_position"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_position") };
+ }
bool fix_length_and_dec() { max_length=10; return FALSE; }
longlong val_int()
{
@@ -460,7 +506,10 @@ class Item_func_xpath_count :public Item_long_func
public:
Item_func_xpath_count(THD *thd, Item *a, String *p):
Item_long_func(thd, a), pxml(p) {}
- const char *func_name() const { return "xpath_count"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_count") };
+ }
bool fix_length_and_dec() { max_length=10; return FALSE; }
longlong val_int()
{
@@ -484,7 +533,10 @@ public:
Item_func_xpath_sum(THD *thd, Item *a, String *p):
Item_real_func(thd, a), pxml(p) {}
- const char *func_name() const { return "xpath_sum"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_sum") };
+ }
double val_real()
{
double sum= 0;
@@ -556,7 +608,10 @@ public:
Item_nodeset_to_const_comparator(THD *thd, Item *nodeset, Item *cmpfunc,
String *p):
Item_bool_func(thd, nodeset, cmpfunc), pxml(p) {}
- const char *func_name() const { return "xpath_nodeset_to_const_comparator"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ return { STRING_WITH_LEN("xpath_nodeset_to_const_comparator") };
+ }
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE);
diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h
index 1d2b6e70995..366958710a4 100644
--- a/sql/item_xmlfunc.h
+++ b/sql/item_xmlfunc.h
@@ -131,7 +131,11 @@ class Item_func_xml_extractvalue: public Item_xml_str_func
public:
Item_func_xml_extractvalue(THD *thd, Item *a, Item *b):
Item_xml_str_func(thd, a, b) {}
- const char *func_name() const { return "extractvalue"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("extractvalue") };
+ return name;
+ }
String *val_str(String *);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_xml_extractvalue>(thd, this); }
@@ -148,7 +152,11 @@ class Item_func_xml_update: public Item_xml_str_func
public:
Item_func_xml_update(THD *thd, Item *a, Item *b, Item *c):
Item_xml_str_func(thd, a, b, c) {}
- const char *func_name() const { return "updatexml"; }
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("updatexml") };
+ return name;
+ }
String *val_str(String *);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_xml_update>(thd, this); }
diff --git a/sql/json_table.cc b/sql/json_table.cc
index 12e70f8f3a3..bbcc73028d9 100644
--- a/sql/json_table.cc
+++ b/sql/json_table.cc
@@ -900,20 +900,26 @@ int Json_table_column::print(THD *thd, Field **f, String *str)
switch (m_column_type)
{
case FOR_ORDINALITY:
- if (str->append("FOR ORDINALITY"))
+ if (str->append(STRING_WITH_LEN("FOR ORDINALITY")))
return 1;
break;
case EXISTS_PATH:
case PATH:
+ {
+ static const LEX_CSTRING path= { STRING_WITH_LEN(" PATH ") };
+ static const LEX_CSTRING exists_path= { STRING_WITH_LEN(" EXISTS PATH ") };
+
(*f)->sql_type(column_type);
if (str->append(column_type) ||
((*f)->has_charset() && m_explicit_cs &&
- (str->append(" CHARSET ") || str->append(m_explicit_cs->csname))) ||
- str->append(m_column_type == PATH ? " PATH " : " EXISTS PATH ") ||
+ (str->append(STRING_WITH_LEN(" CHARSET ")) ||
+ str->append(m_explicit_cs->csname, strlen(m_explicit_cs->csname)))) ||
+ str->append(m_column_type == PATH ? &path : &exists_path) ||
print_path(str, &m_path))
return 1;
break;
+ }
};
if (m_on_empty.print("EMPTY", str) ||
@@ -977,7 +983,7 @@ int Json_table_column::On_response::respond(Json_table_column *jc, Field *f,
int Json_table_column::On_response::print(const char *name, String *str) const
{
- const char *resp;
+ LEX_CSTRING resp;
const LEX_CSTRING *ds= NULL;
if (m_response == Json_table_column::RESPONSE_NOT_SPECIFIED)
return 0;
@@ -985,29 +991,28 @@ int Json_table_column::On_response::print(const char *name, String *str) const
switch (m_response)
{
case Json_table_column::RESPONSE_NULL:
- resp= "NULL";
+ lex_string_set3(&resp, STRING_WITH_LEN("NULL"));
break;
case Json_table_column::RESPONSE_ERROR:
- resp= "ERROR";
+ lex_string_set3(&resp, STRING_WITH_LEN("ERROR"));
break;
case Json_table_column::RESPONSE_DEFAULT:
{
- resp= "DEFAULT";
+ lex_string_set3(&resp, STRING_WITH_LEN("DEFAULT"));
ds= &m_default;
break;
}
default:
- resp= NULL;
+ lex_string_set3(&resp, "", 0);
DBUG_ASSERT(FALSE); /* should never happen. */
}
- return
- (str->append(' ') || str->append(resp) ||
- (ds && (str->append(" '") ||
- str->append_for_single_quote(ds->str, ds->length) ||
- str->append('\''))) ||
- str->append(" ON ") ||
- str->append(name));
+ return (str->append(' ') || str->append(resp) ||
+ (ds && (str->append(STRING_WITH_LEN(" '")) ||
+ str->append_for_single_quote(ds->str, ds->length) ||
+ str->append('\''))) ||
+ str->append(STRING_WITH_LEN(" ON ")) ||
+ str->append(name, strlen(name)));
}
@@ -1178,7 +1183,7 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str,
Json_table_column *jc= *last_column;
bool first_column= TRUE;
- if (str->append("COLUMNS ("))
+ if (str->append(STRING_WITH_LEN("COLUMNS (")))
return 1;
/* loop while jc belongs to the current or nested paths. */
@@ -1187,7 +1192,7 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str,
{
if (first_column)
first_column= FALSE;
- else if (str->append(", "))
+ else if (str->append(STRING_WITH_LEN(", ")))
return 1;
if (jc->m_nest == c_path)
@@ -1200,7 +1205,7 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str,
else
{
DBUG_ASSERT(column_in_this_or_nested(c_nested, jc));
- if (str->append("NESTED PATH ") ||
+ if (str->append(STRING_WITH_LEN("NESTED PATH ")) ||
print_path(str, &jc->m_nest->m_path) ||
str->append(' ') ||
c_nested->print(thd, f, str, it, &jc))
@@ -1209,7 +1214,7 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str,
}
}
- if (str->append(")"))
+ if (str->append(STRING_WITH_LEN(")")))
return 1;
*last_column= jc;
@@ -1235,12 +1240,12 @@ int Table_function_json_table::print(THD *thd, TABLE_LIST *sql_table,
DBUG_ENTER("Table_function_json_table::print");
- if (str->append("JSON_TABLE("))
+ if (str->append(STRING_WITH_LEN("JSON_TABLE(")))
DBUG_RETURN(TRUE);
m_json->print(str, query_type);
- if (str->append(", ") ||
+ if (str->append(STRING_WITH_LEN(", ")) ||
print_path(str, &m_nested_path.m_path) ||
str->append(' ') ||
m_nested_path.print(thd, &f_list, str, jc_i, &jc) ||
diff --git a/sql/key.cc b/sql/key.cc
index 32b4bd9c167..9a28d5a99b4 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -360,7 +360,7 @@ void field_unpack(String *to, Field *field, const uchar *rec, uint max_length,
{
if (field->is_null())
{
- to->append(STRING_WITH_LEN("NULL"));
+ to->append(NULL_clex_str);
DBUG_VOID_RETURN;
}
CHARSET_INFO *cs= field->charset();
@@ -434,7 +434,7 @@ void key_unpack(String *to, TABLE *table, KEY *key)
{
if (table->record[0][key_part->null_offset] & key_part->null_bit)
{
- to->append(STRING_WITH_LEN("NULL"));
+ to->append(NULL_clex_str);
continue;
}
}
diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc
index 77cab26cdbf..6ed79fa6b48 100644
--- a/sql/log_event_server.cc
+++ b/sql/log_event_server.cc
@@ -517,6 +517,7 @@ int append_query_string(CHARSET_INFO *csinfo, String *to,
const char *str, size_t len, bool no_backslash)
{
char *beg, *ptr;
+ my_bool overflow;
uint32 const orig_len= to->length();
if (to->reserve(orig_len + len * 2 + 4))
return 1;
@@ -530,7 +531,7 @@ int append_query_string(CHARSET_INFO *csinfo, String *to,
*ptr++= '\'';
if (!no_backslash)
{
- ptr+= escape_string_for_mysql(csinfo, ptr, 0, str, len);
+ ptr+= escape_string_for_mysql(csinfo, ptr, 0, str, len, &overflow);
}
else
{
@@ -660,7 +661,7 @@ Log_event::do_shall_skip(rpl_group_info *rgi)
void Log_event::pack_info(Protocol *protocol)
{
- protocol->store("", &my_charset_bin);
+ protocol->store("", 0, &my_charset_bin);
}
@@ -675,7 +676,7 @@ int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
log_name = p + 1;
protocol->prepare_for_resend();
- protocol->store(log_name, &my_charset_bin);
+ protocol->store(log_name, strlen(log_name), &my_charset_bin);
protocol->store((ulonglong) pos);
event_type = get_type_str();
protocol->store(event_type, strlen(event_type), &my_charset_bin);
@@ -4132,9 +4133,9 @@ static bool
user_var_append_name_part(THD *thd, String *buf,
const char *name, size_t name_len)
{
- return buf->append("@") ||
+ return buf->append('@') ||
append_identifier(thd, buf, name, name_len) ||
- buf->append("=");
+ buf->append('=');
}
void User_var_log_event::pack_info(Protocol* protocol)
@@ -4145,7 +4146,7 @@ void User_var_log_event::pack_info(Protocol* protocol)
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
buf.length(0);
if (user_var_append_name_part(protocol->thd, &buf, name, name_len) ||
- buf.append("NULL"))
+ buf.append(NULL_clex_str))
return;
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
}
@@ -4190,9 +4191,10 @@ void User_var_log_event::pack_info(Protocol* protocol)
buf.length(0);
my_decimal((const uchar *) (val + 2), val[0], val[1]).to_string(&str);
if (user_var_append_name_part(protocol->thd, &buf, name, name_len) ||
- buf.append(buf2))
+ buf.append(str))
return;
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
+
break;
}
case STRING_RESULT:
@@ -4204,7 +4206,7 @@ void User_var_log_event::pack_info(Protocol* protocol)
buf.length(0);
if (!(cs= get_charset(charset_number, MYF(0))))
{
- if (buf.append("???"))
+ if (buf.append(STRING_WITH_LEN("???")))
return;
}
else
@@ -4212,9 +4214,9 @@ void User_var_log_event::pack_info(Protocol* protocol)
size_t old_len;
char *beg, *end;
if (user_var_append_name_part(protocol->thd, &buf, name, name_len) ||
- buf.append("_") ||
- buf.append(cs->csname) ||
- buf.append(" "))
+ buf.append('_') ||
+ buf.append(cs->csname, strlen(cs->csname)) ||
+ buf.append(' '))
return;
old_len= buf.length();
if (buf.reserve(old_len + val_len * 2 + 3 + sizeof(" COLLATE ") +
@@ -4223,8 +4225,8 @@ void User_var_log_event::pack_info(Protocol* protocol)
beg= const_cast<char *>(buf.ptr()) + old_len;
end= str_to_hex(beg, val, val_len);
buf.length(old_len + (end - beg));
- if (buf.append(" COLLATE ") ||
- buf.append(cs->name))
+ if (buf.append(STRING_WITH_LEN(" COLLATE ")) ||
+ buf.append(cs->name, strlen(cs->name)))
return;
}
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
@@ -5028,7 +5030,7 @@ void Execute_load_query_log_event::pack_info(Protocol *protocol)
}
if (query && q_len && buf.append(query, q_len))
return;
- if (buf.append(" ;file_id=") ||
+ if (buf.append(STRING_WITH_LEN(" ;file_id=")) ||
buf.append_ulonglong(file_id))
return;
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc
index 3234b8f9995..a70ae164f18 100644
--- a/sql/my_json_writer.cc
+++ b/sql/my_json_writer.cc
@@ -33,7 +33,7 @@ void Json_writer::start_object()
if (!element_started)
start_element();
- output.append("{");
+ output.append('{');
indent_level+=INDENT_SIZE;
first_child=true;
element_started= false;
@@ -48,7 +48,7 @@ void Json_writer::start_array()
if (!element_started)
start_element();
- output.append("[");
+ output.append('[');
indent_level+=INDENT_SIZE;
first_child=true;
element_started= false;
@@ -62,7 +62,7 @@ void Json_writer::end_object()
if (!first_child)
append_indent();
first_child= false;
- output.append("}");
+ output.append('}');
}
@@ -73,7 +73,7 @@ void Json_writer::end_array()
indent_level-=INDENT_SIZE;
if (!first_child)
append_indent();
- output.append("]");
+ output.append(']');
}
@@ -104,7 +104,7 @@ Json_writer& Json_writer::add_member(const char *name, size_t len)
output.append('"');
output.append(name, len);
- output.append("\": ");
+ output.append(STRING_WITH_LEN("\": "));
return *this;
}
@@ -376,13 +376,13 @@ void Single_line_formatting_helper::flush_on_one_line()
{
owner->output.append('"');
owner->output.append(str);
- owner->output.append("\": ");
+ owner->output.append(STRING_WITH_LEN("\": "));
owner->output.append('[');
}
else
{
if (nr != 1)
- owner->output.append(", ");
+ owner->output.append(STRING_WITH_LEN(", "));
owner->output.append('"');
owner->output.append(str);
owner->output.append('"');
diff --git a/sql/mysqld.h b/sql/mysqld.h
index fb57c3303c2..6573b6b6a4b 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -268,6 +268,8 @@ 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 LEX_CSTRING in_left_expr_name, in_additional_cond, in_having_cond;
+extern const LEX_CSTRING NULL_clex_str;
+extern const LEX_CSTRING error_clex_str;
extern SHOW_VAR status_vars[];
extern struct system_variables max_system_variables;
extern struct system_status_var global_status_var;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index b5a671b3f37..742886c668f 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -16052,7 +16052,7 @@ print_sel_arg_key(Field *field, const uchar *key, String *out)
{
if (*key)
{
- out->append("NULL");
+ out->append(STRING_WITH_LEN("NULL"));
goto end;
}
key++; // Skip null byte
@@ -16085,15 +16085,16 @@ const char *dbug_print_sel_arg(SEL_ARG *sel_arg)
{
StringBuffer<64> buf;
String &out= dbug_print_sel_arg_buf;
+ LEX_CSTRING tmp;
out.length(0);
if (!sel_arg)
{
- out.append("NULL");
+ out.append(STRING_WITH_LEN("NULL"));
goto end;
}
- out.append("SEL_ARG(");
+ out.append(STRING_WITH_LEN("SEL_ARG("));
const char *stype;
switch(sel_arg->type) {
@@ -16113,34 +16114,42 @@ const char *dbug_print_sel_arg(SEL_ARG *sel_arg)
if (stype)
{
- out.append("type=");
- out.append(stype);
+ out.append(STRING_WITH_LEN("type="));
+ out.append(stype, strlen(stype));
goto end;
}
if (sel_arg->min_flag & NO_MIN_RANGE)
- out.append("-inf");
+ out.append(STRING_WITH_LEN("-inf"));
else
{
print_sel_arg_key(sel_arg->field, sel_arg->min_value, &buf);
out.append(buf);
}
- out.append((sel_arg->min_flag & NEAR_MIN)? "<" : "<=");
+ if (sel_arg->min_flag & NEAR_MIN)
+ lex_string_set3(&tmp, "<", 1);
+ else
+ lex_string_set3(&tmp, "<=", 2);
+ out.append(&tmp);
out.append(sel_arg->field->field_name);
- out.append((sel_arg->max_flag & NEAR_MAX)? "<" : "<=");
+ if (sel_arg->min_flag & NEAR_MAX)
+ lex_string_set3(&tmp, "<", 1);
+ else
+ lex_string_set3(&tmp, "<=", 2);
+ out.append(&tmp);
if (sel_arg->max_flag & NO_MAX_RANGE)
- out.append("+inf");
+ out.append(STRING_WITH_LEN("+inf"));
else
{
print_sel_arg_key(sel_arg->field, sel_arg->max_value, &buf);
out.append(buf);
}
- out.append(")");
+ out.append(')');
end:
return dbug_print_sel_arg_buf.c_ptr_safe();
diff --git a/sql/protocol.cc b/sql/protocol.cc
index d0566ed2506..15fca88080e 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -1344,9 +1344,9 @@ bool Protocol::send_result_set_row(List<Item> *row_items)
/**
- Send \\0 end terminated string.
+ Send \\0 end terminated string or NULL
- @param from NullS or \\0 terminated string
+ @param from NullS or \\0 terminated string
@note
In most cases one should use store(from, length) instead of this function
@@ -1357,12 +1357,11 @@ bool Protocol::send_result_set_row(List<Item> *row_items)
1 error
*/
-bool Protocol::store(const char *from, CHARSET_INFO *cs)
+bool Protocol::store_string_or_null(const char *from, CHARSET_INFO *cs)
{
if (!from)
return store_null();
- size_t length= strlen(from);
- return store(from, length, cs);
+ return store(from, strlen(from), cs);
}
@@ -1381,7 +1380,7 @@ bool Protocol::store(I_List<i_string>* str_list)
tmp.length(0);
while ((s=it++))
{
- tmp.append(s->ptr);
+ tmp.append(s->ptr, strlen(s->ptr));
tmp.append(',');
}
if ((len= tmp.length()))
diff --git a/sql/protocol.h b/sql/protocol.h
index a1868342ab4..bb9de2215f2 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -99,7 +99,12 @@ public:
bool send_result_set_row(List<Item> *row_items);
bool store(I_List<i_string> *str_list);
- bool store(const char *from, CHARSET_INFO *cs);
+ /* This will be deleted in future commit */
+ bool store(const char *from, CHARSET_INFO *cs)
+ {
+ return store_string_or_null(from, cs);
+ }
+ bool store_string_or_null(const char *from, CHARSET_INFO *cs);
bool store_warning(const char *from, size_t length);
String *storage_packet() { return packet; }
inline void free() { packet->free(); }
@@ -114,6 +119,10 @@ public:
{ return store_longlong((longlong) from, 1); }
inline bool store(String *str)
{ return store((char*) str->ptr(), str->length(), str->charset()); }
+ inline bool store(const LEX_CSTRING *from, CHARSET_INFO *cs)
+ {
+ return store(from->str, from->length, cs);
+ }
virtual bool prepare_for_send(uint num_columns)
{
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 26a2601e732..d0285b54928 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -183,11 +183,11 @@ static my_bool show_slave_hosts_callback(THD *thd, Protocol *protocol)
{
protocol->prepare_for_resend();
protocol->store(si->server_id);
- protocol->store(si->host, &my_charset_bin);
+ protocol->store(si->host, strlen(si->host), &my_charset_bin);
if (opt_show_slave_auth_info)
{
- protocol->store(si->user, &my_charset_bin);
- protocol->store(si->password, &my_charset_bin);
+ protocol->store(si->user, safe_strlen(si->user), &my_charset_bin);
+ protocol->store(si->password, safe_strlen(si->password), &my_charset_bin);
}
protocol->store((uint32) si->port);
protocol->store(si->master_id);
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index 5c4a4d9f58a..1e1f98c1e3e 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -805,7 +805,7 @@ Rpl_filter::db_rule_ent_list_to_str(String* str, I_List<i_string>* list)
while ((s= it++))
{
- str->append(s->ptr);
+ str->append(s->ptr, strlen(s->ptr));
str->append(',');
}
diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc
index bc06188af34..8b10703fdc2 100644
--- a/sql/rpl_gtid.cc
+++ b/sql/rpl_gtid.cc
@@ -1037,13 +1037,13 @@ rpl_slave_state_tostring_helper(String *dest, const rpl_gtid *gtid, bool *first)
if (*first)
*first= false;
else
- if (dest->append(",",1))
+ if (dest->append(','))
return true;
return
dest->append_ulonglong(gtid->domain_id) ||
- dest->append("-",1) ||
+ dest->append('-') ||
dest->append_ulonglong(gtid->server_id) ||
- dest->append("-",1) ||
+ dest->append('-') ||
dest->append_ulonglong(gtid->seq_no);
}
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 0649a8f05e8..bc37d8a947d 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -1971,15 +1971,16 @@ void prot_store_ids(THD *thd, DYNAMIC_ARRAY *ids)
break the loop whenever remained space could not fit
ellipses on the next cycle
*/
- sprintf(dbuff + cur_len, "...");
+ cur_len+= sprintf(dbuff + cur_len, "...");
break;
}
- cur_len += sprintf(buff + cur_len, "%s", dbuff);
+ cur_len+= sprintf(buff + cur_len, "%s", dbuff);
}
- thd->protocol->store(buff, &my_charset_bin);
+ thd->protocol->store(buff, cur_len, &my_charset_bin);
return;
}
+
bool Master_info_index::flush_all_relay_logs()
{
DBUG_ENTER("flush_all_relay_logs");
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 4406ce41bf1..f2b20686514 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1218,12 +1218,14 @@ int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond)
{
uint i;
strbuf.length(0);
- for (i=0; i + 1 < tl->count; i++)
+ for (i=0; i < tl->count; i++)
{
- strbuf.append(tl->type_names[i]);
+ const char *name= tl->type_names[i];
+ strbuf.append(name, strlen(name));
strbuf.append(',');
}
- strbuf.append(tl->type_names[i]);
+ if (!strbuf.is_empty())
+ strbuf.chop();
fields[11]->set_notnull();
fields[11]->store(strbuf.ptr(), strbuf.length(), scs);
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 1bd2802858c..9eba7148637 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -315,9 +315,11 @@ build_gtid_pos_create_query(THD *thd, String *query,
LEX_CSTRING *engine_name)
{
bool err= false;
- err|= query->append(gtid_pos_table_definition1);
+ err|= query->append(gtid_pos_table_definition1,
+ sizeof(gtid_pos_table_definition1)-1);
err|= append_identifier(thd, query, table_name);
- err|= query->append(gtid_pos_table_definition2);
+ err|= query->append(gtid_pos_table_definition2,
+ sizeof(gtid_pos_table_definition2)-1);
err|= append_identifier(thd, query, engine_name);
return err;
}
@@ -2540,15 +2542,20 @@ after_set_capability:
char quote_buf[2*sizeof(mi->master_log_name)+1];
char str_buf[28+2*sizeof(mi->master_log_name)+10];
String query(str_buf, sizeof(str_buf), system_charset_info);
+ size_t quote_length;
+ my_bool overflow;
query.length(0);
- query.append("SELECT binlog_gtid_pos('");
- escape_quotes_for_mysql(&my_charset_bin, quote_buf, sizeof(quote_buf),
- mi->master_log_name, strlen(mi->master_log_name));
- query.append(quote_buf);
- query.append("',");
+ query.append(STRING_WITH_LEN("SELECT binlog_gtid_pos('"));
+ quote_length= escape_quotes_for_mysql(&my_charset_bin, quote_buf,
+ sizeof(quote_buf),
+ mi->master_log_name,
+ strlen(mi->master_log_name),
+ &overflow);
+ query.append(quote_buf, quote_length);
+ query.append(STRING_WITH_LEN("',"));
query.append_ulonglong(mi->master_log_pos);
- query.append(")");
+ query.append(')');
if (!mysql_real_query(mysql, query.c_ptr_safe(), query.length()) &&
(master_res= mysql_store_result(mysql)) &&
@@ -3114,7 +3121,20 @@ void show_master_info_get_fields(THD *thd, List<Item> *field_list,
}
/* Text for Slave_IO_Running */
-static const char *slave_running[]= { "No", "Connecting", "Preparing", "Yes" };
+static const LEX_CSTRING slave_running[]=
+{
+ { STRING_WITH_LEN("No") },
+ { STRING_WITH_LEN("Connecting") },
+ { STRING_WITH_LEN("Preparing") },
+ { STRING_WITH_LEN("Yes") }
+};
+
+static const LEX_CSTRING msg_yes= { STRING_WITH_LEN("Yes") };
+static const LEX_CSTRING msg_no= { STRING_WITH_LEN("No") };
+#ifndef HAVE_OPENSSL
+static const LEX_CSTRING msg_ignored= { STRING_WITH_LEN("Ignored") };
+#endif
+
static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
String *gtid_pos)
@@ -3128,6 +3148,7 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
Protocol *protocol= thd->protocol;
Rpl_filter *rpl_filter= mi->rpl_filter;
StringBuffer<256> tmp;
+ const char *msg;
protocol->prepare_for_resend();
@@ -3145,11 +3166,13 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
Show what the sql driver replication thread is doing
This is only meaningful if there is only one slave thread.
*/
- protocol->store(mi->rli.sql_driver_thd ?
- mi->rli.sql_driver_thd->get_proc_info() : "",
- &my_charset_bin);
+ msg= (mi->rli.sql_driver_thd ?
+ mi->rli.sql_driver_thd->get_proc_info() : "");
+ protocol->store_string_or_null(msg, &my_charset_bin);
}
- protocol->store(mi->io_thd ? mi->io_thd->get_proc_info() : "", &my_charset_bin);
+ msg= mi->io_thd ? mi->io_thd->get_proc_info() : "";
+ protocol->store_string_or_null(msg, &my_charset_bin);
+
mysql_mutex_unlock(&mi->run_lock);
mysql_mutex_lock(&mi->data_lock);
@@ -3158,19 +3181,22 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
mysql_mutex_lock(&mi->err_lock);
/* err_lock is to protect mi->rli.last_error() */
mysql_mutex_lock(&mi->rli.err_lock);
- protocol->store(mi->host, &my_charset_bin);
- protocol->store(mi->user, &my_charset_bin);
+ protocol->store_string_or_null(mi->host, &my_charset_bin);
+ protocol->store_string_or_null(mi->user, &my_charset_bin);
protocol->store((uint32) mi->port);
protocol->store((uint32) mi->connect_retry);
- protocol->store(mi->master_log_name, &my_charset_bin);
- protocol->store((ulonglong) mi->master_log_pos);
- protocol->store(mi->rli.group_relay_log_name +
- dirname_length(mi->rli.group_relay_log_name),
+ protocol->store(mi->master_log_name, strlen(mi->master_log_name),
&my_charset_bin);
+ protocol->store((ulonglong) mi->master_log_pos);
+ msg= (mi->rli.group_relay_log_name +
+ dirname_length(mi->rli.group_relay_log_name));
+ protocol->store(msg, strlen(msg), &my_charset_bin);
protocol->store((ulonglong) mi->rli.group_relay_log_pos);
- protocol->store(mi->rli.group_master_log_name, &my_charset_bin);
- protocol->store(slave_running[mi->slave_running], &my_charset_bin);
- protocol->store(mi->rli.slave_running ? "Yes":"No", &my_charset_bin);
+ protocol->store(mi->rli.group_master_log_name,
+ strlen(mi->rli.group_master_log_name),
+ &my_charset_bin);
+ protocol->store(&slave_running[mi->slave_running], &my_charset_bin);
+ protocol->store(mi->rli.slave_running ? &msg_yes : &msg_no, &my_charset_bin);
protocol->store(rpl_filter->get_do_db());
protocol->store(rpl_filter->get_ignore_db());
@@ -3184,29 +3210,30 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
protocol->store(&tmp);
protocol->store(mi->rli.last_error().number);
- protocol->store(mi->rli.last_error().message, &my_charset_bin);
+ protocol->store_string_or_null(mi->rli.last_error().message,
+ &my_charset_bin);
protocol->store((uint32) mi->rli.slave_skip_counter);
protocol->store((ulonglong) mi->rli.group_master_log_pos);
protocol->store((ulonglong) mi->rli.log_space_total);
- protocol->store(
- mi->rli.until_condition==Relay_log_info::UNTIL_NONE ? "None":
- ( mi->rli.until_condition==Relay_log_info::UNTIL_MASTER_POS? "Master":
- ( mi->rli.until_condition==Relay_log_info::UNTIL_RELAY_POS? "Relay":
- "Gtid")), &my_charset_bin);
- protocol->store(mi->rli.until_log_name, &my_charset_bin);
+ msg= (mi->rli.until_condition==Relay_log_info::UNTIL_NONE ? "None" :
+ (mi->rli.until_condition==Relay_log_info::UNTIL_MASTER_POS? "Master":
+ (mi->rli.until_condition==Relay_log_info::UNTIL_RELAY_POS? "Relay":
+ "Gtid")));
+ protocol->store(msg, strlen(msg), &my_charset_bin);
+ protocol->store_string_or_null(mi->rli.until_log_name, &my_charset_bin);
protocol->store((ulonglong) mi->rli.until_log_pos);
#ifdef HAVE_OPENSSL
- protocol->store(mi->ssl? "Yes":"No", &my_charset_bin);
+ protocol->store(mi->ssl ? &msg_yes : &msg_no, &my_charset_bin);
#else
- protocol->store(mi->ssl? "Ignored":"No", &my_charset_bin);
+ protocol->store(mi->ssl ? &msg_ignored: &msg_no, &my_charset_bin);
#endif
- protocol->store(mi->ssl_ca, &my_charset_bin);
- protocol->store(mi->ssl_capath, &my_charset_bin);
- protocol->store(mi->ssl_cert, &my_charset_bin);
- protocol->store(mi->ssl_cipher, &my_charset_bin);
- protocol->store(mi->ssl_key, &my_charset_bin);
+ protocol->store_string_or_null(mi->ssl_ca, &my_charset_bin);
+ protocol->store_string_or_null(mi->ssl_capath, &my_charset_bin);
+ protocol->store_string_or_null(mi->ssl_cert, &my_charset_bin);
+ protocol->store_string_or_null(mi->ssl_cipher, &my_charset_bin);
+ protocol->store_string_or_null(mi->ssl_key, &my_charset_bin);
/*
Seconds_Behind_Master: if SQL thread is running and I/O thread is
@@ -3261,27 +3288,30 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
{
protocol->store_null();
}
- protocol->store(mi->ssl_verify_server_cert? "Yes":"No", &my_charset_bin);
+ protocol->store(mi->ssl_verify_server_cert? &msg_yes : &msg_no,
+ &my_charset_bin);
// Last_IO_Errno
protocol->store(mi->last_error().number);
// Last_IO_Error
- protocol->store(mi->last_error().message, &my_charset_bin);
+ protocol->store_string_or_null(mi->last_error().message, &my_charset_bin);
// Last_SQL_Errno
protocol->store(mi->rli.last_error().number);
// Last_SQL_Error
- protocol->store(mi->rli.last_error().message, &my_charset_bin);
+ protocol->store_string_or_null(mi->rli.last_error().message,
+ &my_charset_bin);
// Replicate_Ignore_Server_Ids
prot_store_ids(thd, &mi->ignore_server_ids);
// Master_Server_id
protocol->store((uint32) mi->master_id);
// SQL_Delay
// Master_Ssl_Crl
- protocol->store(mi->ssl_ca, &my_charset_bin);
+ protocol->store_string_or_null(mi->ssl_ca, &my_charset_bin);
// Master_Ssl_Crlpath
- protocol->store(mi->ssl_capath, &my_charset_bin);
+ protocol->store_string_or_null(mi->ssl_capath, &my_charset_bin);
// Using_Gtid
- protocol->store(mi->using_gtid_astext(mi->using_gtid), &my_charset_bin);
+ protocol->store_string_or_null(mi->using_gtid_astext(mi->using_gtid),
+ &my_charset_bin);
// Gtid_IO_Pos
{
mi->gtid_current_pos.to_string(&tmp);
@@ -3312,7 +3342,7 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
else
protocol->store_null();
// Slave_SQL_Running_State
- protocol->store(slave_sql_running_state, &my_charset_bin);
+ protocol->store_string_or_null(slave_sql_running_state, &my_charset_bin);
protocol->store(mi->total_ddl_groups);
protocol->store(mi->total_non_trans_groups);
diff --git a/sql/sp.cc b/sql/sp.cc
index 4cd5de43606..c821ebe6480 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -1075,12 +1075,14 @@ sp_returns_type(THD *thd, String &result, const sp_head *sp)
if (field->has_charset())
{
+ const char *name= field->charset()->csname;
result.append(STRING_WITH_LEN(" CHARSET "));
- result.append(field->charset()->csname);
+ result.append(name, strlen(name));
if (!(field->charset()->state & MY_CS_PRIMARY))
{
+ name= field->charset()->name;
result.append(STRING_WITH_LEN(" COLLATE "));
- result.append(field->charset()->name);
+ result.append(name, strlen(name));
}
}
@@ -1553,7 +1555,7 @@ Sp_handler_package::show_create_sp(THD *thd, String *buf,
buf->append(STRING_WITH_LEN("OR REPLACE "))) ||
append_definer(thd, buf, &definer.user, &definer.host) ||
buf->append(type_lex_cstring()) ||
- buf->append(" ", 1) ||
+ buf->append(' ') ||
(ddl_options.if_not_exists() &&
buf->append(STRING_WITH_LEN("IF NOT EXISTS "))) ||
(db.length > 0 &&
@@ -1561,7 +1563,7 @@ Sp_handler_package::show_create_sp(THD *thd, String *buf,
buf->append('.'))) ||
append_identifier(thd, buf, name.str, name.length) ||
append_package_chistics(buf, chistics) ||
- buf->append(" ", 1) ||
+ buf->append(' ') ||
buf->append(body.str, body.length);
return rc;
}
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index c4e08bb9606..d897a6b2f66 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -150,9 +150,9 @@ bool Item_splocal::append_value_for_log(THD *thd, String *str)
Item *item= this_item();
String *str_value= item->type_handler()->print_item_value(thd, item,
&str_value_holder);
- return str_value ?
- str->append(*str_value) :
- str->append(STRING_WITH_LEN("NULL"));
+ return (str_value ?
+ str->append(*str_value) :
+ str->append(NULL_clex_str));
}
@@ -166,7 +166,7 @@ bool Item_splocal_row_field::append_for_log(THD *thd, String *str)
if (str->append(STRING_WITH_LEN(" NAME_CONST('")) ||
str->append(&m_name) ||
- str->append(".") ||
+ str->append('.') ||
str->append(&m_field_name) ||
str->append(STRING_WITH_LEN("',")))
return true;
@@ -2117,7 +2117,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount,
if (str_value)
binlog_buf.append(*str_value);
else
- binlog_buf.append(STRING_WITH_LEN("NULL"));
+ binlog_buf.append(NULL_clex_str);
}
binlog_buf.append(')');
}
@@ -4203,7 +4203,8 @@ sp_instr_freturn::print(String *str)
if (str->reserve(1024+8+32)) // Add some for the expr. too
return;
str->qs_append(STRING_WITH_LEN("freturn "));
- str->qs_append(m_type_handler->name().ptr());
+ LEX_CSTRING name= m_type_handler->name().lex_cstring();
+ str->qs_append(&name);
str->qs_append(' ');
m_value->print(str, enum_query_type(QT_ORDINARY |
QT_ITEM_ORIGINAL_FUNC_NULLIF));
diff --git a/sql/spatial.cc b/sql/spatial.cc
index b879b603b67..df5a46ac8cc 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -380,7 +380,7 @@ int Geometry::as_json(String *wkt, uint max_dec_digits, const char **end)
if (wkt->reserve(4 + type_keyname_len + 2 + len + 2 + 2 +
coord_keyname_len + 4, 512))
return 1;
- wkt->qs_append("\"", 1);
+ wkt->qs_append('"');
wkt->qs_append((const char *) type_keyname, type_keyname_len);
wkt->qs_append("\": \"", 4);
wkt->qs_append(get_class_info()->m_geojson_name.str, len);
@@ -404,7 +404,7 @@ int Geometry::bbox_as_json(String *wkt)
const char *end;
if (wkt->reserve(5 + bbox_keyname_len + (FLOATING_POINT_DECIMALS+2)*4, 512))
return 1;
- wkt->qs_append("\"", 1);
+ wkt->qs_append('"');
wkt->qs_append((const char *) bbox_keyname, bbox_keyname_len);
wkt->qs_append("\": [", 4);
@@ -418,7 +418,7 @@ int Geometry::bbox_as_json(String *wkt)
wkt->qs_append(mbr.xmax);
wkt->qs_append(", ", 2);
wkt->qs_append(mbr.ymax);
- wkt->qs_append("]", 1);
+ wkt->qs_append(']');
return 0;
}
@@ -3504,13 +3504,13 @@ bool Gis_geometry_collection::get_data_as_json(String *txt, uint max_dec_digits,
if (!(geom= create_by_typeid(&buffer, wkb_type)))
return 1;
geom->set_data_ptr(data, (uint) (m_data_end - data));
- if (txt->append("{", 1) ||
+ if (txt->append('{') ||
geom->as_json(txt, max_dec_digits, &data) ||
txt->append(STRING_WITH_LEN("}, "), 512))
return 1;
}
txt->length(txt->length() - 2);
- if (txt->append("]", 1))
+ if (txt->append(']'))
return 1;
*end= data;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 82ee92c27ba..7a048ea45a0 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -453,15 +453,15 @@ public:
void print_grant(String *str)
{
str->append(STRING_WITH_LEN("GRANT PROXY ON '"));
- str->append(proxied_user);
+ str->append(proxied_user, strlen(proxied_user));
str->append(STRING_WITH_LEN("'@'"));
if (proxied_host.hostname)
str->append(proxied_host.hostname, strlen(proxied_host.hostname));
str->append(STRING_WITH_LEN("' TO '"));
- str->append(user);
+ str->append(user, strlen(user));
str->append(STRING_WITH_LEN("'@'"));
if (host.hostname)
- str->append(host.hostname);
+ str->append(host.hostname, strlen(host.hostname));
str->append(STRING_WITH_LEN("'"));
if (with_grant)
str->append(STRING_WITH_LEN(" WITH GRANT OPTION"));
@@ -1776,7 +1776,7 @@ class User_table_json: public User_table
if (value_len)
json.append(',');
json.append('"');
- json.append(key);
+ json.append(key, strlen(key));
json.append(STRING_WITH_LEN("\":"));
if (string)
json.append('"');
@@ -9136,7 +9136,7 @@ bool mysql_show_create_user(THD *thd, LEX_USER *lex_user)
goto end;
}
- result.append("CREATE USER ");
+ result.append(STRING_WITH_LEN("CREATE USER "));
append_identifier(thd, &result, username, strlen(username));
add_user_parameters(thd, &result, acl_user, false);
@@ -9160,9 +9160,10 @@ bool mysql_show_create_user(THD *thd, LEX_USER *lex_user)
of a user account, including both the manual expiration state of the
account and the automatic expiration policy attached to it, we should
print two statements here, a CREATE USER (printed above) and an ALTER USER */
- if (acl_user->password_expired && acl_user->password_lifetime > -1) {
+ if (acl_user->password_expired && acl_user->password_lifetime > -1)
+ {
result.length(0);
- result.append("ALTER USER ");
+ result.append(STRING_WITH_LEN("ALTER USER "));
append_identifier(thd, &result, username, strlen(username));
result.append('@');
append_identifier(thd, &result, acl_user->host.hostname,
@@ -9418,7 +9419,7 @@ static bool show_default_role(THD *thd, ACL_USER *acl_entry,
def_str.length(0);
def_str.append(STRING_WITH_LEN("SET DEFAULT ROLE "));
def_str.append(&def_rolename);
- def_str.append(" FOR '");
+ def_str.append(STRING_WITH_LEN(" FOR '"));
def_str.append(&acl_entry->user);
DBUG_ASSERT(!(acl_entry->flags & IS_ROLE));
def_str.append(STRING_WITH_LEN("'@'"));
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index ba5809c6835..3c2675d1d5d 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -32,6 +32,15 @@
#include "sql_admin.h"
#include "sql_statistics.h"
#include "wsrep_mysqld.h"
+
+const LEX_CSTRING msg_repair= { STRING_WITH_LEN("repair") };
+const LEX_CSTRING msg_assign_to_keycache=
+{ STRING_WITH_LEN("assign_to_keycache") };
+const LEX_CSTRING msg_analyze= { STRING_WITH_LEN("analyze") };
+const LEX_CSTRING msg_check= { STRING_WITH_LEN("check") };
+const LEX_CSTRING msg_preload_keys= { STRING_WITH_LEN("preload_keys") };
+const LEX_CSTRING msg_optimize= { STRING_WITH_LEN("optimize") };
+
/* Prepare, run and cleanup for mysql_recreate_table() */
static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list)
@@ -71,15 +80,16 @@ static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list)
static int send_check_errmsg(THD *thd, TABLE_LIST* table,
- const char* operator_name, const char* errmsg)
+ const LEX_CSTRING *operator_name,
+ const char* errmsg)
{
Protocol *protocol= thd->protocol;
protocol->prepare_for_resend();
protocol->store(table->alias.str, table->alias.length, system_charset_info);
- protocol->store((char*) operator_name, system_charset_info);
- protocol->store(STRING_WITH_LEN("error"), system_charset_info);
- protocol->store(errmsg, system_charset_info);
+ protocol->store(operator_name, system_charset_info);
+ protocol->store(&error_clex_str, system_charset_info);
+ protocol->store(errmsg, strlen(errmsg), system_charset_info);
thd->clear_error();
if (protocol->write())
return -1;
@@ -148,7 +158,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
*/
if (table->s->tmp_table)
{
- error= send_check_errmsg(thd, table_list, "repair",
+ error= send_check_errmsg(thd, table_list, &msg_repair,
"Cannot repair temporary table from .frm file");
goto end;
}
@@ -166,8 +176,12 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
if (table->s->frm_version < FRM_VER_TRUE_VARCHAR &&
table->s->varchar_fields)
{
- error= send_check_errmsg(thd, table_list, "repair",
- "Failed repairing a very old .frm file as the data file format has changed between versions. Please dump the table in your old system with mysqldump and read it into this system with mysql or mysqlimport");
+ error= send_check_errmsg(thd, table_list, &msg_repair,
+ "Failed repairing a very old .frm file as the "
+ "data file format has changed between versions. "
+ "Please dump the table in your old system with "
+ "mysqldump and read it into this system with "
+ "mysql or mysqlimport");
goto end;
}
@@ -225,12 +239,12 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
if (my_rename(from, tmp, MYF(MY_WME)))
{
- error= send_check_errmsg(thd, table_list, "repair",
+ error= send_check_errmsg(thd, table_list, &msg_repair,
"Failed renaming data file");
goto end;
}
if (dd_recreate_table(thd, table_list->db.str, table_list->table_name.str))
- create_error= send_check_errmsg(thd, table_list, "repair",
+ create_error= send_check_errmsg(thd, table_list, &msg_repair,
"Failed generating table from .frm file");
/*
'FALSE' for 'using_transactions' means don't postpone
@@ -240,7 +254,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
query_cache_invalidate3(thd, table_list, FALSE);
if (mysql_file_rename(key_file_misc, tmp, from, MYF(MY_WME)))
{
- error= send_check_errmsg(thd, table_list, "repair",
+ error= send_check_errmsg(thd, table_list, &msg_repair,
"Failed restoring .MYD file");
goto end;
}
@@ -262,7 +276,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
*/
if (open_table(thd, table_list, &ot_ctx))
{
- error= send_check_errmsg(thd, table_list, "repair",
+ error= send_check_errmsg(thd, table_list, &msg_repair,
"Failed to open partially repaired table");
goto end;
}
@@ -430,14 +444,17 @@ dbug_err:
}
#ifdef WITH_WSREP
- /*
- OPTIMIZE, REPAIR and ALTER may take MDL locks not only for the affected table, but
- also for the table referenced by foreign key constraint.
- This wsrep_toi_replication() function handles TOI replication for OPTIMIZE and REPAIR
- so that certification keys for potential FK parent tables are also appended in the
- write set.
- ALTER TABLE case is handled elsewhere.
- */
+/*
+ OPTIMIZE, REPAIR and ALTER may take MDL locks not only for the
+ affected table, but also for the table referenced by foreign key
+ constraint.
+
+ This wsrep_toi_replication() function handles TOI replication for
+ OPTIMIZE and REPAIR so that certification keys for potential FK
+ parent tables are also appended in the write set. ALTER TABLE
+ case is handled elsewhere.
+*/
+
static bool wsrep_toi_replication(THD *thd, TABLE_LIST *tables)
{
LEX *lex= thd->lex;
@@ -480,7 +497,7 @@ static bool wsrep_toi_replication(THD *thd, TABLE_LIST *tables)
*/
static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
HA_CHECK_OPT* check_opt,
- const char *operator_name,
+ const LEX_CSTRING *operator_name,
thr_lock_type lock_type,
bool org_open_for_modify,
bool repair_table_use_frm,
@@ -555,7 +572,8 @@ 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 table_name_buff[SAFE_NAME_LEN*2+2];
+ LEX_CSTRING table_name= { table_name_buff, 0};
const char *db= table->db.str;
bool fatal_error=0;
bool open_error;
@@ -567,7 +585,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
if (thd->is_killed())
break;
- strxmov(table_name, db, ".", table->table_name.str, NullS);
+ table_name.length= strxmov(table_name_buff, db, ".", table->table_name.str,
+ NullS) - table_name_buff;
thd->open_options|= extra_open_options;
table->lock_type= lock_type;
/*
@@ -645,12 +664,12 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
size_t length;
DBUG_PRINT("admin", ("sending non existent partition error"));
protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
+ protocol->store(&table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
- protocol->store(STRING_WITH_LEN("error"), system_charset_info);
+ protocol->store(&error_clex_str, system_charset_info);
length= my_snprintf(buff, sizeof(buff),
ER_THD(thd, ER_DROP_PARTITION_NON_EXISTENT),
- table_name);
+ table_name.str);
protocol->store(buff, length, system_charset_info);
if(protocol->write())
goto err;
@@ -734,11 +753,11 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
enum_sql_command save_sql_command= lex->sql_command;
DBUG_PRINT("admin", ("sending error message"));
protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
+ protocol->store(&table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
- protocol->store(STRING_WITH_LEN("error"), system_charset_info);
+ protocol->store(&error_clex_str, system_charset_info);
length= my_snprintf(buff, sizeof(buff), ER_THD(thd, ER_OPEN_AS_READONLY),
- table_name);
+ table_name.str);
protocol->store(buff, length, system_charset_info);
trans_commit_stmt(thd);
trans_commit(thd);
@@ -794,7 +813,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
/* purecov: begin inspected */
DBUG_PRINT("admin", ("sending crashed warning"));
protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
+ protocol->store(&table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
protocol->store(STRING_WITH_LEN("warning"), system_charset_info);
protocol->store(STRING_WITH_LEN("Table is marked as crashed"),
@@ -856,7 +875,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
if (result_code == HA_ADMIN_OK)
{
- DBUG_PRINT("admin", ("calling operator_func '%s'", operator_name));
+ DBUG_PRINT("admin", ("calling operator_func '%s'", operator_name->str));
THD_STAGE_INFO(thd, stage_executing);
result_code = (table->table->file->*operator_func)(thd, check_opt);
THD_STAGE_INFO(thd, stage_sending_data);
@@ -972,7 +991,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
else
{
protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
+ protocol->store(&table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
protocol->store(STRING_WITH_LEN("status"), system_charset_info);
protocol->store(STRING_WITH_LEN("Engine-independent statistics collected"),
@@ -1000,20 +1019,21 @@ send_result:
const Sql_condition *err;
while ((err= it++))
{
+ const char *err_msg= err->get_message_text();
protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
- protocol->store((char*) operator_name, system_charset_info);
+ protocol->store(&table_name, system_charset_info);
+ protocol->store(operator_name, system_charset_info);
protocol->store(warning_level_names[err->get_level()].str,
warning_level_names[err->get_level()].length,
system_charset_info);
- protocol->store(err->get_message_text(), system_charset_info);
+ protocol->store(err_msg, strlen(err_msg), system_charset_info);
if (protocol->write())
goto err;
}
thd->get_stmt_da()->clear_warning_info(thd->query_id);
}
protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
+ protocol->store(&table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
send_result_message:
@@ -1025,7 +1045,7 @@ send_result_message:
char buf[MYSQL_ERRMSG_SIZE];
size_t length=my_snprintf(buf, sizeof(buf),
ER_THD(thd, ER_CHECK_NOT_IMPLEMENTED),
- operator_name);
+ operator_name->str);
protocol->store(STRING_WITH_LEN("note"), system_charset_info);
protocol->store(buf, length, system_charset_info);
}
@@ -1036,7 +1056,7 @@ send_result_message:
char buf[MYSQL_ERRMSG_SIZE];
size_t length= my_snprintf(buf, sizeof(buf),
ER_THD(thd, ER_BAD_TABLE_ERROR),
- table_name);
+ table_name.str);
protocol->store(STRING_WITH_LEN("note"), system_charset_info);
protocol->store(buf, length, system_charset_info);
}
@@ -1067,13 +1087,13 @@ send_result_message:
break;
case HA_ADMIN_CORRUPT:
- protocol->store(STRING_WITH_LEN("error"), system_charset_info);
+ protocol->store(&error_clex_str, system_charset_info);
protocol->store(STRING_WITH_LEN("Corrupt"), system_charset_info);
fatal_error=1;
break;
case HA_ADMIN_INVALID:
- protocol->store(STRING_WITH_LEN("error"), system_charset_info);
+ protocol->store(&error_clex_str, system_charset_info);
protocol->store(STRING_WITH_LEN("Invalid argument"),
system_charset_info);
break;
@@ -1141,7 +1161,7 @@ send_result_message:
}
/* Start a new row for the final status row */
protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
+ protocol->store(&table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
if (result_code) // either mysql_recreate_table or analyze failed
{
@@ -1156,13 +1176,13 @@ send_result_message:
else
{
/* Hijack the row already in-progress. */
- protocol->store(STRING_WITH_LEN("error"), system_charset_info);
- protocol->store(err_msg, system_charset_info);
+ protocol->store(&error_clex_str, system_charset_info);
+ protocol->store(err_msg, strlen(err_msg), system_charset_info);
if (protocol->write())
goto err;
/* Start off another row for HA_ADMIN_FAILED */
protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
+ protocol->store(&table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
}
thd->clear_error();
@@ -1193,7 +1213,7 @@ send_result_message:
const char *what_to_upgrade= table->view ? "VIEW" :
table->table->file->ha_table_flags() & HA_CAN_REPAIR ? "TABLE" : 0;
- protocol->store(STRING_WITH_LEN("error"), system_charset_info);
+ protocol->store(&error_clex_str, system_charset_info);
if (what_to_upgrade)
length= my_snprintf(buf, sizeof(buf),
ER_THD(thd, ER_TABLE_NEEDS_UPGRADE),
@@ -1213,7 +1233,7 @@ send_result_message:
size_t length=my_snprintf(buf, sizeof(buf),
"Unknown - internal error %d during operation",
result_code);
- protocol->store(STRING_WITH_LEN("error"), system_charset_info);
+ protocol->store(&error_clex_str, system_charset_info);
protocol->store(buf, length, system_charset_info);
fatal_error=1;
break;
@@ -1363,8 +1383,9 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
}
check_opt.key_cache= key_cache;
DBUG_RETURN(mysql_admin_table(thd, tables, &check_opt,
- "assign_to_keycache", TL_READ_NO_INSERT, 0, 0,
- 0, 0, &handler::assign_to_keycache, 0, false));
+ &msg_assign_to_keycache, TL_READ_NO_INSERT, 0,
+ 0, 0, 0,
+ &handler::assign_to_keycache, 0, false));
}
@@ -1390,8 +1411,9 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables)
outdated information if parallel inserts into cache blocks happen.
*/
DBUG_RETURN(mysql_admin_table(thd, tables, 0,
- "preload_keys", TL_READ_NO_INSERT, 0, 0, 0, 0,
- &handler::preload_keys, 0, false));
+ &msg_preload_keys, TL_READ_NO_INSERT,
+ 0, 0, 0, 0,
+ &handler::preload_keys, 0, false));
}
@@ -1411,9 +1433,8 @@ bool Sql_cmd_analyze_table::execute(THD *thd)
WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table);
res= mysql_admin_table(thd, first_table, &m_lex->check_opt,
- "analyze", lock_type, 1, 0, 0, 0,
+ &msg_analyze, lock_type, 1, 0, 0, 0,
&handler::ha_analyze, 0, true);
-
m_lex->first_select_lex()->table_list.first= first_table;
m_lex->query_tables= first_table;
@@ -1437,7 +1458,7 @@ bool Sql_cmd_check_table::execute(THD *thd)
TRUE, UINT_MAX, FALSE))
goto error; /* purecov: inspected */
- res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "check",
+ res= mysql_admin_table(thd, first_table, &m_lex->check_opt, &msg_check,
lock_type, 0, 0, HA_OPEN_FOR_REPAIR, 0,
&handler::ha_check, &view_check, false);
@@ -1463,9 +1484,8 @@ bool Sql_cmd_optimize_table::execute(THD *thd)
res= (specialflag & SPECIAL_NO_NEW_FUNC) ?
mysql_recreate_table(thd, first_table, true) :
mysql_admin_table(thd, first_table, &m_lex->check_opt,
- "optimize", TL_WRITE, 1, 0, 0, 0,
+ &msg_optimize, TL_WRITE, 1, 0, 0, 0,
&handler::ha_optimize, 0, true);
-
m_lex->first_select_lex()->table_list.first= first_table;
m_lex->query_tables= first_table;
@@ -1484,7 +1504,7 @@ bool Sql_cmd_repair_table::execute(THD *thd)
if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table,
FALSE, UINT_MAX, FALSE))
goto error; /* purecov: inspected */
- res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "repair",
+ res= mysql_admin_table(thd, first_table, &m_lex->check_opt, &msg_repair,
TL_WRITE, 1,
MY_TEST(m_lex->check_opt.sql_flags & TT_USEFRM),
HA_OPEN_FOR_REPAIR, &prepare_for_repair,
diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h
index 9cdb93f4d6f..e76ff13c06e 100644
--- a/sql/sql_analyse.h
+++ b/sql/sql_analyse.h
@@ -116,8 +116,8 @@ class field_str :public field_info
public:
field_str(Item* a, analyse* b) :field_info(a,b),
- min_arg("",default_charset_info),
- max_arg("",default_charset_info), sum(0),
+ min_arg("",0,default_charset_info),
+ max_arg("",0,default_charset_info), sum(0),
must_be_blob(0), was_zero_fill(0),
was_maybe_zerofill(0), can_be_still_num(1)
{ init_tree(&tree, 0, 0, sizeof(String), (qsort_cmp2) sortcmp2,
diff --git a/sql/sql_analyze_stmt.cc b/sql/sql_analyze_stmt.cc
index 8df2f76aeaf..60a08c86bf7 100644
--- a/sql/sql_analyze_stmt.cc
+++ b/sql/sql_analyze_stmt.cc
@@ -87,20 +87,20 @@ void Filesort_tracker::print_json_members(Json_writer *writer)
void Filesort_tracker::get_data_format(String *str)
{
if (r_sort_keys_packed)
- str->append("packed_sort_key");
+ str->append(STRING_WITH_LEN("packed_sort_key"));
else
- str->append("sort_key");
- str->append(",");
+ str->append(STRING_WITH_LEN("sort_key"));
+ str->append(',');
if (r_using_addons)
{
if (r_packed_addon_fields)
- str->append("packed_addon_fields");
+ str->append(STRING_WITH_LEN("packed_addon_fields"));
else
- str->append("addon_fields");
+ str->append(STRING_WITH_LEN("addon_fields"));
}
else
- str->append("rowid");
+ str->append(STRING_WITH_LEN("rowid"));
}
void attach_gap_time_tracker(THD *thd, Gap_time_tracker *gap_tracker,
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 6c98b913be5..71af78d135d 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2951,9 +2951,9 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
String query(query_buf, sizeof(query_buf), system_charset_info);
query.length(0);
- query.append("DELETE FROM ");
+ query.append(STRING_WITH_LEN("DELETE FROM "));
append_identifier(thd, &query, &share->db);
- query.append(".");
+ query.append('.');
append_identifier(thd, &query, &share->table_name);
/*
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 59e40298b97..fd528c749e5 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -2918,11 +2918,11 @@ bool select_result::check_simple_select() const
}
-static String default_line_term("\n",default_charset_info);
-static String default_escaped("\\",default_charset_info);
-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);
+static String default_line_term("\n", 1, default_charset_info);
+static String default_escaped("\\", 1, default_charset_info);
+static String default_field_term("\t", 1, default_charset_info);
+static String default_enclosed_and_line_start("", 0, default_charset_info);
+static String default_xml_row_term("<row>", 5, default_charset_info);
sql_exchange::sql_exchange(const char *name, bool flag,
enum enum_filetype filetype_arg)
@@ -6530,7 +6530,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
table->lock_type >= TL_FIRST_WRITE)
{
table_names.append(&table->table_name);
- table_names.append(",");
+ table_names.append(',');
}
}
if (!table_names.is_empty())
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 1546e5e65b1..98ded8f142e 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -7604,11 +7604,12 @@ public:
bool aggregate_attributes(THD *thd)
{
+ static LEX_CSTRING union_name= { STRING_WITH_LEN("UNION") };
for (uint i= 0; i < arg_count; i++)
m_maybe_null|= args[i]->maybe_null();
return
type_handler()->Item_hybrid_func_fix_attributes(thd,
- "UNION", this, this,
+ union_name, this, this,
args, arg_count);
}
};
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index 90a8e736460..ad4a37d0fbe 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -1478,7 +1478,7 @@ void With_clause::print(THD *thd, String *str, enum_query_type query_type)
with_elem= with_elem->next)
{
if (with_elem != with_list.first)
- str->append(", ");
+ str->append(STRING_WITH_LEN(", "));
with_elem->print(thd, str, query_type);
}
}
diff --git a/sql/sql_digest.cc b/sql/sql_digest.cc
index 5ca855c9608..e00069366cd 100644
--- a/sql/sql_digest.cc
+++ b/sql/sql_digest.cc
@@ -182,7 +182,7 @@ void compute_digest_text(const sql_digest_storage* digest_storage,
if (byte_count > digest_storage->m_token_array_length)
{
- digest_output->append("\0", 1);
+ digest_output->append('\0');
return;
}
@@ -196,7 +196,7 @@ void compute_digest_text(const sql_digest_storage* digest_storage,
Can happen, as we do dirty reads on digest_storage,
which can be written to in another thread.
*/
- digest_output->append("\0", 1);
+ digest_output->append('\0');
return;
}
@@ -256,7 +256,7 @@ void compute_digest_text(const sql_digest_storage* digest_storage,
break;
}
/* Copy the converted identifier into the digest string. */
- digest_output->append("`", 1);
+ digest_output->append('`');
if (id_length > 0)
digest_output->append(id_string, id_length);
digest_output->append("` ", 2);
@@ -273,7 +273,7 @@ void compute_digest_text(const sql_digest_storage* digest_storage,
digest_output->append(tok_data->m_token_string, tok_length);
if (tok_data->m_append_space)
- digest_output->append(" ", 1);
+ digest_output->append(' ');
break;
}
}
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index eadbb0d4a5e..d13f175f706 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -296,7 +296,7 @@ static void push_string_list(THD *thd, List<Item> *item_list,
else
buf->append(',');
- buf->append(line);
+ buf->append(line, strlen(line));
}
push_string(thd, item_list, buf);
}
@@ -406,7 +406,7 @@ int print_explain_row(select_result_sink *result,
Item_float *fl= new (mem_root) Item_float(thd, *r_rows, 2);
String tmp;
String *res= fl->val_str(&tmp);
- r_rows_str.append(res->ptr());
+ r_rows_str.append(*res);
item_list.push_back(new (mem_root)
Item_string_sys(thd, r_rows_str.ptr(),
r_rows_str.length()), mem_root);
@@ -552,7 +552,7 @@ int Explain_union::print_explain(Explain_query *query,
Item_float *fl= new (mem_root) Item_float(thd, avg_rows, 2);
String tmp;
String *res= fl->val_str(&tmp);
- r_rows_str.append(res->ptr());
+ r_rows_str.append(*res);
item_list.push_back(new (mem_root)
Item_string_sys(thd, r_rows_str.ptr(),
r_rows_str.length()), mem_root);
@@ -1043,11 +1043,11 @@ void Explain_aggr_filesort::print_json_members(Json_writer *writer,
first= false;
else
{
- str.append(", ");
+ str.append(STRING_WITH_LEN(", "));
}
append_item_to_str(&str, item);
if (*direction == ORDER::ORDER_DESC)
- str.append(" desc");
+ str.append(STRING_WITH_LEN(" desc"));
}
writer->add_member("sort_key").add_str(str.c_ptr_safe());
@@ -1125,14 +1125,15 @@ void Explain_table_access::fill_key_str(String *key_str, bool is_json) const
CHARSET_INFO *cs= system_charset_info;
bool is_hj= (type == JT_HASH || type == JT_HASH_NEXT ||
type == JT_HASH_RANGE || type == JT_HASH_INDEX_MERGE);
- const char *hash_key_prefix= "#hash#";
+ LEX_CSTRING hash_key_prefix= { STRING_WITH_LEN("#hash#") };
+ const char *key_name;
- if (key.get_key_name())
+ if ((key_name= key.get_key_name()))
{
if (is_hj)
- key_str->append(hash_key_prefix, strlen(hash_key_prefix), cs);
+ key_str->append(hash_key_prefix.str, hash_key_prefix.length, cs);
- key_str->append(key.get_key_name());
+ key_str->append(key_name, strlen(key_name));
if (is_hj && type != JT_HASH)
key_str->append(':');
@@ -1148,7 +1149,10 @@ void Explain_table_access::fill_key_str(String *key_str, bool is_json) const
key_str->append(buf2);
}
if (type == JT_HASH_NEXT)
- key_str->append(hash_next_key.get_key_name());
+ {
+ key_name= hash_next_key.get_key_name();
+ key_str->append(key_name, strlen(key_name));
+ }
}
@@ -1290,8 +1294,8 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
push_str(thd, &item_list, join_type_str[type]);
else
{
- join_type_buf.append(join_type_str[type]);
- join_type_buf.append("|filter");
+ join_type_buf.append(join_type_str[type], strlen(join_type_str[type]));
+ join_type_buf.append(STRING_WITH_LEN("|filter"));
item_list.push_back(new (mem_root)
Item_string_sys(thd, join_type_buf.ptr(),
join_type_buf.length()),
@@ -1311,7 +1315,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
if (rowid_filter)
{
- key_str.append("|");
+ key_str.append('|');
StringBuffer<64> rowid_key_str;
rowid_filter->quick->print_key(&rowid_key_str);
key_str.append(rowid_key_str);
@@ -1354,10 +1358,10 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
if (rowid_filter)
{
- rows_str.append(" (");
+ rows_str.append(STRING_WITH_LEN(" ("));
rows_str.append_ulonglong((ulonglong) (round(rowid_filter->selectivity *
100.0)));
- rows_str.append("%)");
+ rows_str.append(STRING_WITH_LEN("%)"));
}
item_list.push_back(new (mem_root)
Item_string_sys(thd, rows_str.ptr(),
@@ -1380,13 +1384,13 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
Item_float *fl= new (mem_root) Item_float(thd, avg_rows, 2);
String tmp;
String *res= fl->val_str(&tmp);
- r_rows_str.append(res->ptr());
+ r_rows_str.append(*res);
if (rowid_filter)
{
- r_rows_str.append(" (");
+ r_rows_str.append(STRING_WITH_LEN(" ("));
r_rows_str.append_ulonglong(
(ulonglong) (rowid_filter->tracker->get_r_selectivity_pct() * 100.0));
- r_rows_str.append("%)");
+ r_rows_str.append(STRING_WITH_LEN("%)"));
}
item_list.push_back(new (mem_root)
Item_string_sys(thd, r_rows_str.ptr(),
@@ -1929,42 +1933,41 @@ void Explain_table_access::print_explain_json(Explain_query *query,
sql_explain.h
*/
-const char * extra_tag_text[]=
+const LEX_CSTRING extra_tag_text[]=
{
- "ET_none",
- "Using index condition",
- "Using index condition(BKA)",
- "Using ", // special handling
- "Range checked for each record (index map: 0x", // special handling
- "Using where with pushed condition",
- "Using where",
- "Not exists",
+ { STRING_WITH_LEN("ET_none") },
+ { STRING_WITH_LEN("Using index condition") },
+ { STRING_WITH_LEN("Using index condition(BKA)") },
+ { STRING_WITH_LEN("Using ") }, // special handling
+ { STRING_WITH_LEN("Range checked for each record (index map: 0x") }, // special handling
+ { STRING_WITH_LEN("Using where with pushed condition") },
+ { STRING_WITH_LEN("Using where") },
+ { STRING_WITH_LEN("Not exists") },
- "Using index",
- "Full scan on NULL key",
- "Skip_open_table",
- "Open_frm_only",
- "Open_full_table",
-
- "Scanned 0 databases",
- "Scanned 1 database",
- "Scanned all databases",
-
- "Using index for group-by", // special handling
-
- "USING MRR: DONT PRINT ME", // special handling
-
- "Distinct",
- "LooseScan",
- "Start temporary",
- "End temporary",
- "FirstMatch", // special handling
-
- "Using join buffer", // special handling
-
- "Const row not found",
- "Unique row not found",
- "Impossible ON condition",
+ { STRING_WITH_LEN("Using index") },
+ { STRING_WITH_LEN("Full scan on NULL key") },
+ { STRING_WITH_LEN("Skip_open_table") },
+ { STRING_WITH_LEN("Open_frm_only") },
+ { STRING_WITH_LEN("Open_full_table") },
+
+ { STRING_WITH_LEN("Scanned 0 databases") },
+ { STRING_WITH_LEN("Scanned 1 database") },
+ { STRING_WITH_LEN("Scanned all databases") },
+
+ { STRING_WITH_LEN("Using index for group-by") }, // special handling
+ { STRING_WITH_LEN("USING MRR: DONT PRINT ME") }, // special handling
+
+ { STRING_WITH_LEN("Distinct") },
+ { STRING_WITH_LEN("LooseScan") },
+ { STRING_WITH_LEN("Start temporary") },
+ { STRING_WITH_LEN("End temporary") },
+ { STRING_WITH_LEN("FirstMatch") }, // special handling
+
+ { STRING_WITH_LEN("Using join buffer") }, // special handling
+
+ { STRING_WITH_LEN("Const row not found") },
+ { STRING_WITH_LEN("Unique row not found") },
+ { STRING_WITH_LEN("Impossible ON condition") }
};
@@ -1984,7 +1987,8 @@ void Explain_table_access::append_tag_name(String *str, enum explain_extra_tag t
char buf[MAX_KEY / 4 + 1];
str->append(STRING_WITH_LEN("Range checked for each "
"record (index map: 0x"));
- str->append(range_checked_fer->keys_map.print(buf));
+ range_checked_fer->keys_map.print(buf);
+ str->append(buf, strlen(buf));
str->append(')');
break;
}
@@ -1998,12 +2002,16 @@ void Explain_table_access::append_tag_name(String *str, enum explain_extra_tag t
str->append(extra_tag_text[tag]);
str->append(STRING_WITH_LEN(" ("));
- const char *buffer_type= bka_type.incremental ? "incremental" : "flat";
+ LEX_CSTRING buffer_type;
+ if (bka_type.incremental)
+ buffer_type= { STRING_WITH_LEN("incremental") };
+ else
+ buffer_type= { STRING_WITH_LEN("flat") };
str->append(buffer_type);
str->append(STRING_WITH_LEN(", "));
- str->append(bka_type.join_alg);
+ str->append(bka_type.join_alg, strlen(bka_type.join_alg));
str->append(STRING_WITH_LEN(" join"));
- str->append(STRING_WITH_LEN(")"));
+ str->append(')');
if (bka_type.mrr_type.length())
{
str->append(STRING_WITH_LEN("; "));
@@ -2016,9 +2024,9 @@ void Explain_table_access::append_tag_name(String *str, enum explain_extra_tag t
{
if (firstmatch_table_name.length())
{
- str->append("FirstMatch(");
+ str->append(STRING_WITH_LEN("FirstMatch("));
str->append(firstmatch_table_name);
- str->append(")");
+ str->append(')');
}
else
str->append(extra_tag_text[tag]);
@@ -2028,10 +2036,10 @@ void Explain_table_access::append_tag_name(String *str, enum explain_extra_tag t
{
str->append(extra_tag_text[tag]);
if (loose_scan_is_scanning)
- str->append(" (scanning)");
+ str->append(STRING_WITH_LEN(" (scanning)"));
break;
case ET_TABLE_FUNCTION:
- str->append("Table function: json_table");
+ str->append(STRING_WITH_LEN("Table function: json_table"));
break;
}
default:
@@ -2086,13 +2094,16 @@ void Explain_quick_select::print_json(Json_writer *writer)
void Explain_quick_select::print_extra_recursive(String *str)
{
+ const char *name;
if (is_basic())
{
- str->append(range.get_key_name());
+ name= range.get_key_name();
+ str->append(name, strlen(name));
}
else
{
- str->append(get_name_by_type());
+ name= get_name_by_type();
+ str->append(name, strlen(name));
str->append('(');
List_iterator_fast<Explain_quick_select> it (children);
Explain_quick_select* child;
@@ -2141,7 +2152,7 @@ void Explain_quick_select::print_key(String *str)
{
if (str->length() > 0)
str->append(',');
- str->append(range.get_key_name());
+ str->append(range.get_key_name(), strlen(range.get_key_name()));
}
else
{
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index 8ce0f724e55..ce29846e2f8 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -297,10 +297,10 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations,
DBUG_ENTER("get_topics_for_keyword");
if ((iindex_topic=
- find_type(primary_key_name, &topics->s->keynames,
+ find_type(primary_key_name.str, &topics->s->keynames,
FIND_TYPE_NO_PREFIX) - 1) < 0 ||
(iindex_relations=
- find_type(primary_key_name, &relations->s->keynames,
+ find_type(primary_key_name.str, &relations->s->keynames,
FIND_TYPE_NO_PREFIX) - 1) < 0)
{
my_message(ER_CORRUPT_HELP_DB, ER_THD(thd, ER_CORRUPT_HELP_DB), MYF(0));
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index e0c8eae7f50..e8722f1a197 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -642,7 +642,7 @@ static int
create_insert_stmt_from_insert_delayed(THD *thd, String *buf)
{
/* Make a copy of thd->query() and then remove the "DELAYED" keyword */
- if (buf->append(thd->query()) ||
+ if (buf->append(thd->query(), thd->query_length()) ||
buf->replace(thd->lex->keyword_delayed_begin_offset,
thd->lex->keyword_delayed_end_offset -
thd->lex->keyword_delayed_begin_offset, NULL, 0))
@@ -4864,12 +4864,12 @@ bool binlog_drop_table(THD *thd, TABLE *table)
if (!thd->binlog_table_should_be_logged(&table->s->db))
return 0;
- query.append("DROP ");
+ query.append(STRING_WITH_LEN("DROP "));
if (table->s->tmp_table)
- query.append("TEMPORARY ");
- query.append("TABLE IF EXISTS ");
+ query.append(STRING_WITH_LEN("TEMPORARY "));
+ query.append(STRING_WITH_LEN("TABLE IF EXISTS "));
append_identifier(thd, &query, &table->s->db);
- query.append(".");
+ query.append('.');
append_identifier(thd, &query, &table->s->table_name);
return thd->binlog_query(THD::STMT_QUERY_TYPE,
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index faaeb57310a..8b562ab9b47 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -51,7 +51,8 @@ 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};
-
+const LEX_CSTRING NULL_clex_str= {STRING_WITH_LEN("NULL")};
+const LEX_CSTRING error_clex_str= {STRING_WITH_LEN("error")};
/**
Helper action for a case expression statement (the expr in 'CASE expr').
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 2869011e313..b901548bf23 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -877,18 +877,18 @@ static bool write_execute_load_query_log_event(THD *thd, const sql_exchange* ex,
{
List_iterator<Item> li(thd->lex->field_list);
- query_str.append(" (");
+ query_str.append(STRING_WITH_LEN(" ("));
n= 0;
while ((item= li++))
{
if (n++)
- query_str.append(", ");
+ query_str.append(STRING_WITH_LEN(", "));
const Load_data_outvar *var= item->get_load_data_outvar();
DBUG_ASSERT(var);
var->load_data_print_for_log_event(thd, &query_str);
}
- query_str.append(")");
+ query_str.append(')');
}
if (!thd->lex->update_list.is_empty())
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 74f2e1b33f1..d81af2026aa 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -2119,17 +2119,17 @@ static int add_keyword_string(String *str, const char *keyword,
bool quoted, const char *keystr)
{
int err= str->append(' ');
- err+= str->append(keyword);
+ err+= str->append(keyword, strlen(keyword));
str->append(STRING_WITH_LEN(" = "));
if (quoted)
{
err+= str->append('\'');
- err+= str->append_for_single_quote(keystr);
+ err+= str->append_for_single_quote(keystr, strlen(keystr));
err+= str->append('\'');
}
else
- err+= str->append(keystr);
+ err+= str->append(keystr, strlen(keystr));
return err;
}
@@ -2205,7 +2205,7 @@ static int add_keyword_path(String *str, const char *keyword,
static int add_keyword_int(String *str, const char *keyword, longlong num)
{
int err= str->append(' ');
- err+= str->append(keyword);
+ err+= str->append(keyword, strlen(keyword));
str->append(STRING_WITH_LEN(" = "));
return err + str->append_longlong(num);
}
@@ -2294,12 +2294,12 @@ static int add_column_list_values(String *str, partition_info *part_info,
if (col_val->max_value)
err+= str->append(STRING_WITH_LEN("MAXVALUE"));
else if (col_val->null_value)
- err+= str->append(STRING_WITH_LEN("NULL"));
+ err+= str->append(NULL_clex_str);
else
{
Item *item_expr= col_val->item_expression;
if (item_expr->null_value)
- err+= str->append(STRING_WITH_LEN("NULL"));
+ err+= str->append(NULL_clex_str);
else
{
CHARSET_INFO *field_cs;
@@ -2404,7 +2404,7 @@ static int add_partition_values(String *str, partition_info *part_info,
err+= str->append('(');
if (p_elem->has_null_value)
{
- err+= str->append(STRING_WITH_LEN("NULL"));
+ err+= str->append(NULL_clex_str);
if (num_items == 0)
{
err+= str->append(')');
@@ -7545,9 +7545,9 @@ void append_row_to_str(String &str, const uchar *row, TABLE *table)
field_ptr++)
{
Field *field= *field_ptr;
- str.append(" ");
+ str.append(' ');
str.append(&field->field_name);
- str.append(":");
+ str.append(':');
field_unpack(&str, field, rec, 0, false);
}
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index 55abee72a52..195d2e52c56 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -870,7 +870,7 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd)
{
const char *partition_name= partition_names_it++;
String *str_partition_name= new (thd->mem_root)
- String(partition_name, system_charset_info);
+ String(partition_name, strlen(partition_name), system_charset_info);
if (!str_partition_name)
DBUG_RETURN(true);
partition_names_list.push_back(str_partition_name, thd->mem_root);
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 49fd29a6a31..eb7524153a4 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -4323,7 +4323,9 @@ bool show_binlog_info(THD* thd)
LOG_INFO li;
mysql_bin_log.get_current_log(&li);
size_t dir_len = dirname_length(li.log_file_name);
- protocol->store(li.log_file_name + dir_len, &my_charset_bin);
+ const char *base= li.log_file_name + dir_len;
+
+ protocol->store(base, strlen(base), &my_charset_bin);
protocol->store((ulonglong) li.pos);
protocol->store(binlog_filter->get_do_db());
protocol->store(binlog_filter->get_ignore_db());
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 95e43ccd0e2..fed2ff9e456 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -804,7 +804,7 @@ void vers_select_conds_t::print(String *str, enum_query_type query_type) const
DBUG_ASSERT(0);
break;
case SYSTEM_TIME_ALL:
- str->append(" FOR SYSTEM_TIME ALL");
+ str->append(STRING_WITH_LEN(" FOR SYSTEM_TIME ALL"));
break;
}
}
@@ -13477,8 +13477,11 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
char buff[256];
String str(buff,sizeof(buff),system_charset_info);
str.length(0);
- str.append(tab->table? tab->table->alias.c_ptr() :"<no_table_name>");
- str.append(" final_pushdown_cond");
+ if (tab->table)
+ str.append(tab->table->alias);
+ else
+ str.append(STRING_WITH_LEN("<no_table_name>"));
+ str.append(STRING_WITH_LEN(" final_pushdown_cond"));
print_where(tab->select_cond, str.c_ptr_safe(), QT_ORDINARY););
}
uint n_top_tables= (uint)(join->join_tab_ranges.head()->end -
@@ -27733,13 +27736,13 @@ Index_hint::print(THD *thd, String *str)
case INDEX_HINT_USE: str->append(STRING_WITH_LEN("USE INDEX")); break;
case INDEX_HINT_FORCE: str->append(STRING_WITH_LEN("FORCE INDEX")); break;
}
- str->append (STRING_WITH_LEN(" ("));
+ str->append(STRING_WITH_LEN(" ("));
if (key_name.length)
{
if (thd && !system_charset_info->strnncoll(
(const uchar *)key_name.str, key_name.length,
- (const uchar *)primary_key_name,
- strlen(primary_key_name)))
+ (const uchar *)primary_key_name.str,
+ primary_key_name.length))
str->append(primary_key_name);
else
append_identifier(thd, str, &key_name);
@@ -27897,8 +27900,8 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
while ((hint= it++))
{
- str->append (STRING_WITH_LEN(" "));
- hint->print (thd, str);
+ str->append(' ');
+ hint->print(thd, str);
}
}
}
@@ -27920,21 +27923,21 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type)
thd->lex->all_selects_list->link_next &&
select_number != FAKE_SELECT_LEX_ID)
{
- str->append("/* select#");
+ str->append(STRING_WITH_LEN("/* select#"));
str->append_ulonglong(select_number);
if (thd->lex->describe & DESCRIBE_EXTENDED2)
{
- str->append("/");
+ str->append('/');
str->append_ulonglong(nest_level);
if (master_unit()->fake_select_lex &&
master_unit()->first_select() == this)
{
- str->append(" Filter Select: ");
+ str->append(STRING_WITH_LEN(" Filter Select: "));
master_unit()->fake_select_lex->print(thd, str, query_type);
}
}
- str->append(" */ ");
+ str->append(STRING_WITH_LEN(" */ "));
}
str->append(STRING_WITH_LEN("select "));
@@ -28034,7 +28037,7 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type)
if (cur_where)
cur_where->print(str, query_type);
else
- str->append(cond_value != Item::COND_FALSE ? "1" : "0");
+ str->append(cond_value != Item::COND_FALSE ? '1' : '0');
}
// group by & olap
@@ -28066,7 +28069,7 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type)
if (cur_having)
cur_having->print(str, query_type);
else
- str->append(having_value != Item::COND_FALSE ? "1" : "0");
+ str->append(having_value != Item::COND_FALSE ? '1' : '0');
}
if (order_list.elements)
@@ -28080,12 +28083,11 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type)
// lock type
if (select_lock == select_lock_type::IN_SHARE_MODE)
- str->append(" lock in share mode");
+ str->append(STRING_WITH_LEN(" lock in share mode"));
else if (select_lock == select_lock_type::FOR_UPDATE)
- str->append(" for update");
-
+ str->append(STRING_WITH_LEN(" for update"));
if (unlikely(skip_locked))
- str->append(" skip locked");
+ str->append(STRING_WITH_LEN(" skip locked"));
// PROCEDURE unsupported here
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index f1e08222359..8951ef82aa5 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -108,6 +108,10 @@ static const LEX_CSTRING trg_event_type_names[]=
{ STRING_WITH_LEN("DELETE") }
};
+
+LEX_CSTRING DATA_clex_str= { STRING_WITH_LEN("DATA") };
+LEX_CSTRING INDEX_clex_str= { STRING_WITH_LEN("INDEX") };
+
#ifndef NO_EMBEDDED_ACCESS_CHECKS
static const char *grant_names[]={
"select","insert","update","delete","create","drop","reload","shutdown",
@@ -119,7 +123,12 @@ static TYPELIB grant_types = { sizeof(grant_names)/sizeof(char **),
#endif
/* Match the values of enum ha_choice */
-static const char *ha_choice_values[] = {"", "0", "1"};
+static const LEX_CSTRING ha_choice_values[]=
+{
+ { STRING_WITH_LEN("") },
+ { STRING_WITH_LEN("0") },
+ { STRING_WITH_LEN("1") }
+};
static void store_key_options(THD *, String *, TABLE *, KEY *);
@@ -396,9 +405,11 @@ bool mysqld_show_authors(THD *thd)
for (authors= show_table_authors; authors->name; authors++)
{
protocol->prepare_for_resend();
- protocol->store(authors->name, system_charset_info);
- protocol->store(authors->location, system_charset_info);
- protocol->store(authors->comment, system_charset_info);
+ protocol->store(authors->name, strlen(authors->name), system_charset_info);
+ protocol->store(authors->location, strlen(authors->location),
+ system_charset_info);
+ protocol->store(authors->comment, strlen(authors->comment),
+ system_charset_info);
if (protocol->write())
DBUG_RETURN(TRUE);
}
@@ -435,9 +446,12 @@ bool mysqld_show_contributors(THD *thd)
for (contributors= show_table_contributors; contributors->name; contributors++)
{
protocol->prepare_for_resend();
- protocol->store(contributors->name, system_charset_info);
- protocol->store(contributors->location, system_charset_info);
- protocol->store(contributors->comment, system_charset_info);
+ protocol->store(contributors->name, strlen(contributors->name),
+ system_charset_info);
+ protocol->store(contributors->location, strlen(contributors->location),
+ system_charset_info);
+ protocol->store(contributors->comment, strlen(contributors->comment),
+ system_charset_info);
if (protocol->write())
DBUG_RETURN(TRUE);
}
@@ -528,9 +542,12 @@ bool mysqld_show_privileges(THD *thd)
for (privilege= sys_privileges; privilege->privilege ; privilege++)
{
protocol->prepare_for_resend();
- protocol->store(privilege->privilege, system_charset_info);
- protocol->store(privilege->context, system_charset_info);
- protocol->store(privilege->comment, system_charset_info);
+ protocol->store(privilege->privilege, strlen(privilege->privilege),
+ system_charset_info);
+ protocol->store(privilege->context, strlen(privilege->context),
+ system_charset_info);
+ protocol->store(privilege->comment, strlen(privilege->comment),
+ system_charset_info);
if (protocol->write())
DBUG_RETURN(TRUE);
}
@@ -1298,19 +1315,23 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
protocol->prepare_for_resend();
if (table_list->view)
- protocol->store(table_list->view_name.str, system_charset_info);
+ protocol->store(&table_list->view_name, system_charset_info);
else
{
if (table_list->schema_table)
- protocol->store(table_list->schema_table->table_name, system_charset_info);
+ protocol->store(table_list->schema_table->table_name,
+ strlen(table_list->schema_table->table_name),
+ system_charset_info);
else
- protocol->store(table_list->table->alias.c_ptr(), system_charset_info);
+ protocol->store(table_list->table->alias.ptr(),
+ table_list->table->alias.length(),
+ system_charset_info);
}
if (table_list->view)
{
- protocol->store(buffer.ptr(), buffer.length(),
- table_list->view_creation_ctx->get_client_cs());
+ buffer.set_charset(table_list->view_creation_ctx->get_client_cs());
+ protocol->store(&buffer);
protocol->store(table_list->view_creation_ctx->get_client_cs()->csname,
system_charset_info);
@@ -1319,7 +1340,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
system_charset_info);
}
else
- protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
+ protocol->store(&buffer);
if (protocol->write())
goto exit;
@@ -1419,11 +1440,13 @@ bool mysqld_show_create_db(THD *thd, LEX_CSTRING *dbname,
{
buffer.append(STRING_WITH_LEN(" /*!40100"));
buffer.append(STRING_WITH_LEN(" DEFAULT CHARACTER SET "));
- buffer.append(create.default_table_charset->csname);
+ buffer.append(create.default_table_charset->csname,
+ strlen(create.default_table_charset->csname));
if (!(create.default_table_charset->state & MY_CS_PRIMARY))
{
buffer.append(STRING_WITH_LEN(" COLLATE "));
- buffer.append(create.default_table_charset->name);
+ buffer.append(create.default_table_charset->name,
+ strlen(create.default_table_charset->name));
}
buffer.append(STRING_WITH_LEN(" */"));
}
@@ -1621,7 +1644,7 @@ int get_quote_char_for_identifier(THD *thd, const char *name, size_t length)
/* Append directory name (if exists) to CREATE INFO */
-static void append_directory(THD *thd, String *packet, const char *dir_type,
+static void append_directory(THD *thd, String *packet, LEX_CSTRING *dir_type,
const char *filename)
{
if (filename && !(thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE))
@@ -1879,11 +1902,13 @@ static void add_table_options(THD *thd, TABLE *table,
(create_info_arg->used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
{
packet->append(STRING_WITH_LEN(" DEFAULT CHARSET="));
- packet->append(share->table_charset->csname);
+ packet->append(share->table_charset->csname,
+ strlen(share->table_charset->csname));
if (!(share->table_charset->state & MY_CS_PRIMARY))
{
packet->append(STRING_WITH_LEN(" COLLATE="));
- packet->append(table->s->table_charset->name);
+ packet->append(table->s->table_charset->name,
+ strlen(table->s->table_charset->name));
}
}
}
@@ -1930,19 +1955,19 @@ static void add_table_options(THD *thd, TABLE *table,
if (create_info.page_checksum != HA_CHOICE_UNDEF)
{
packet->append(STRING_WITH_LEN(" PAGE_CHECKSUM="));
- packet->append(ha_choice_values[create_info.page_checksum], 1);
+ packet->append(ha_choice_values[create_info.page_checksum]);
}
if (create_info.options & HA_OPTION_DELAY_KEY_WRITE)
packet->append(STRING_WITH_LEN(" DELAY_KEY_WRITE=1"));
if (create_info.row_type != ROW_TYPE_DEFAULT)
{
packet->append(STRING_WITH_LEN(" ROW_FORMAT="));
- packet->append(ha_row_type[(uint) create_info.row_type]);
+ packet->append(&ha_row_type[(uint) create_info.row_type]);
}
if (share->transactional != HA_CHOICE_UNDEF)
{
packet->append(STRING_WITH_LEN(" TRANSACTIONAL="));
- packet->append(ha_choice_values[(uint) share->transactional], 1);
+ packet->append(ha_choice_values[(uint) share->transactional]);
}
if (share->table_type == TABLE_TYPE_SEQUENCE)
packet->append(STRING_WITH_LEN(" SEQUENCE=1"));
@@ -1966,8 +1991,8 @@ end_options:
}
append_create_options(thd, packet, share->option_list, check_options,
hton->table_options);
- append_directory(thd, packet, "DATA", create_info.data_file_name);
- append_directory(thd, packet, "INDEX", create_info.index_file_name);
+ append_directory(thd, packet, &DATA_clex_str, create_info.data_file_name);
+ append_directory(thd, packet, &INDEX_clex_str, create_info.index_file_name);
}
static void append_period(THD *thd, String *packet, const LEX_CSTRING &start,
@@ -2165,7 +2190,8 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
if (field->charset() != share->table_charset)
{
packet->append(STRING_WITH_LEN(" CHARACTER SET "));
- packet->append(field->charset()->csname);
+ packet->append(field->charset()->csname,
+ strlen(field->charset()->csname));
}
/*
For string types dump collation name only if
@@ -2179,7 +2205,7 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
field->charset() != field->vcol_info->expr->collation.collation))
{
packet->append(STRING_WITH_LEN(" COLLATE "));
- packet->append(field->charset()->name);
+ packet->append(field->charset()->name, strlen(field->charset()->name));
}
}
@@ -2287,7 +2313,7 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
bool found_primary=0;
packet->append(STRING_WITH_LEN(",\n "));
- if (i == primary_key && !strcmp(key_info->name.str, primary_key_name))
+ if (i == primary_key && !strcmp(key_info->name.str, primary_key_name.str))
{
found_primary=1;
/*
@@ -2900,22 +2926,23 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
ulonglong now= microsecond_interval_timer();
- while (auto thd_info= arg.thread_infos.get())
+ while (thread_info *thd_info= arg.thread_infos.get())
{
protocol->prepare_for_resend();
protocol->store(thd_info->thread_id);
- protocol->store(thd_info->user, system_charset_info);
- protocol->store(thd_info->host, system_charset_info);
- protocol->store(thd_info->db, system_charset_info);
+ protocol->store(thd_info->user, strlen(thd_info->user), system_charset_info);
+ protocol->store(thd_info->host, strlen(thd_info->host), system_charset_info);
+ protocol->store_string_or_null(thd_info->db, system_charset_info);
if (thd_info->proc_info)
- protocol->store(thd_info->proc_info, system_charset_info);
+ protocol->store(thd_info->proc_info, strlen(thd_info->proc_info),
+ system_charset_info);
else
- protocol->store(command_name[thd_info->command].str, system_charset_info);
+ protocol->store(&command_name[thd_info->command], system_charset_info);
if (thd_info->start_time && now > thd_info->start_time)
protocol->store_long((now - thd_info->start_time) / HRTIME_RESOLUTION);
else
protocol->store_null();
- protocol->store(thd_info->state_info, system_charset_info);
+ protocol->store_string_or_null(thd_info->state_info, system_charset_info);
if (thd_info->query_string.length())
protocol->store(thd_info->query_string.str(),
thd_info->query_string.length(),
@@ -3058,19 +3085,19 @@ void select_result_text_buffer::save_to(String *res)
{
List_iterator<char*> it(rows);
char **row;
- res->append("#\n");
+ res->append(STRING_WITH_LEN("#\n"));
while ((row= it++))
{
- res->append("# explain: ");
+ res->append(STRING_WITH_LEN("# explain: "));
for (int i=0; i < n_columns; i++)
{
if (i)
res->append('\t');
- res->append(row[i]);
+ res->append(row[i], strlen(row[i]));
}
- res->append("\n");
+ res->append('\n');
}
- res->append("#\n");
+ res->append(STRING_WITH_LEN("#\n"));
}
@@ -5514,7 +5541,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
if (share->page_checksum != HA_CHOICE_UNDEF)
{
str.qs_append(STRING_WITH_LEN(" page_checksum="));
- str.qs_append(ha_choice_values[(uint) share->page_checksum]);
+ str.qs_append(&ha_choice_values[(uint) share->page_checksum]);
}
if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
@@ -5523,7 +5550,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
if (share->row_type != ROW_TYPE_DEFAULT)
{
str.qs_append(STRING_WITH_LEN(" row_format="));
- str.qs_append(ha_row_type[(uint) share->row_type]);
+ str.qs_append(&ha_row_type[(uint) share->row_type]);
}
if (share->key_block_size)
@@ -5555,7 +5582,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
HA_CHOICE_NO : HA_CHOICE_YES);
str.qs_append(STRING_WITH_LEN(" transactional="));
- str.qs_append(ha_choice_values[choice]);
+ str.qs_append(&ha_choice_values[choice]);
}
append_create_options(thd, &str, share->option_list, false, 0);
@@ -5564,8 +5591,8 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
HA_CREATE_INFO create_info;
create_info.init();
file->update_create_info(&create_info);
- append_directory(thd, &str, "DATA", create_info.data_file_name);
- append_directory(thd, &str, "INDEX", create_info.index_file_name);
+ append_directory(thd, &str, &DATA_clex_str, create_info.data_file_name);
+ append_directory(thd, &str, &INDEX_clex_str, create_info.index_file_name);
}
if (str.length())
@@ -6978,7 +7005,7 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
if (i != primary_key && !(key_info->flags & HA_NOSAME))
continue;
- if (i == primary_key && !strcmp(key_info->name.str, primary_key_name))
+ if (i == primary_key && !strcmp(key_info->name.str, primary_key_name.str))
{
if (store_constraints(thd, table, db_name, table_name,
key_info->name.str, key_info->name.length,
@@ -7247,7 +7274,7 @@ static void collect_partition_expr(THD *thd, List<const char> &field_list,
{
append_identifier(thd, str, field_str, strlen(field_str));
if (--no_fields != 0)
- str->append(",");
+ str->append(',');
}
return;
}
@@ -7340,7 +7367,7 @@ static int get_partition_column_description(THD *thd, partition_info *part_info,
if (col_val->max_value)
tmp_str.append(STRING_WITH_LEN("MAXVALUE"));
else if (col_val->null_value)
- tmp_str.append("NULL");
+ tmp_str.append(NULL_clex_str);
else
{
Item *item= col_val->item_expression;
@@ -7353,7 +7380,7 @@ static int get_partition_column_description(THD *thd, partition_info *part_info,
tmp_str.append(val);
}
if (i != num_elements - 1)
- tmp_str.append(",");
+ tmp_str.append(',');
}
DBUG_RETURN(0);
}
@@ -7514,9 +7541,9 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
tmp_res.length(0);
if (part_elem->has_null_value)
{
- tmp_str.append(STRING_WITH_LEN("NULL"));
+ tmp_str.append(NULL_clex_str);
if (num_items > 0)
- tmp_str.append(",");
+ tmp_str.append(',');
}
while ((list_value= list_val_it++))
{
@@ -7528,7 +7555,7 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
tmp_str))
DBUG_RETURN(1);
if (part_info->part_field_list.elements > 1U)
- tmp_str.append(")");
+ tmp_str.append(')');
}
else
{
@@ -7539,7 +7566,7 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
tmp_str.append(tmp_res);
}
if (--num_items != 0)
- tmp_str.append(",");
+ tmp_str.append(',');
}
table->field[11]->store(tmp_str.ptr(), tmp_str.length(), cs);
table->field[11]->set_notnull();
@@ -8174,7 +8201,7 @@ int make_schemata_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
if (lex->wild && lex->wild->ptr())
{
buffer.append(STRING_WITH_LEN(" ("));
- buffer.append(lex->wild->ptr());
+ buffer.append(*lex->wild);
buffer.append(')');
}
field->set_name(thd, &buffer);
@@ -8198,7 +8225,7 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
if (lex->wild && lex->wild->ptr())
{
buffer.append(STRING_WITH_LEN(" ("));
- buffer.append(lex->wild->ptr());
+ buffer.append(*lex->wild);
buffer.append(')');
}
Item_field *field= new (thd->mem_root) Item_field(thd, context, field_name);
@@ -10076,19 +10103,19 @@ char *thd_get_error_context_description(THD *thd, char *buffer,
if (sctx->host)
{
str.append(' ');
- str.append(sctx->host);
+ str.append(sctx->host, strlen(sctx->host));
}
if (sctx->ip)
{
str.append(' ');
- str.append(sctx->ip);
+ str.append(sctx->ip, strlen(sctx->ip));
}
if (sctx->user)
{
str.append(' ');
- str.append(sctx->user);
+ str.append(sctx->user, strlen(sctx->user));
}
/* Don't wait if LOCK_thd_data is used as this could cause a deadlock */
@@ -10097,7 +10124,7 @@ char *thd_get_error_context_description(THD *thd, char *buffer,
if (const char *info= thread_state_info(thd))
{
str.append(' ');
- str.append(info);
+ str.append(info, strlen(info));
}
if (thd->query())
diff --git a/sql/sql_string.h b/sql/sql_string.h
index c731f6189c8..a4f6c8592d2 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -332,10 +332,6 @@ public:
int4store(Ptr + position,value);
}
- void qs_append(const char *str)
- {
- qs_append(str, (uint32)strlen(str));
- }
void qs_append(const LEX_CSTRING *ls)
{
DBUG_ASSERT(ls->length < UINT_MAX32 &&
@@ -390,9 +386,6 @@ public:
init_private_data();
(void) real_alloc(length_arg);
}
- explicit Binary_string(const char *str)
- :Binary_string(str, strlen(str))
- { }
/*
NOTE: If one intend to use the c_ptr() method, the following two
contructors need the size of memory for STR to be at least LEN+1 (to make
@@ -418,7 +411,10 @@ public:
alloced= thread_specific= 0;
}
- ~Binary_string() { free(); }
+ ~Binary_string()
+ {
+ free();
+ }
/* Mark variable thread specific it it's not allocated already */
inline void set_thread_specific()
@@ -500,10 +496,20 @@ public:
return old;
}
- inline void set_quick(char *str, size_t arg_length)
+ /*
+ This is used to set a new buffer for String.
+ However if the String already has an allocated buffer, it will
+ keep that one.
+ It's not to be used to set the value or length of the string.
+ */
+ inline void set_buffer_if_not_allocated(char *str, size_t arg_length)
{
if (!alloced)
{
+ /*
+ Following should really be set_str(str, 0), but some code may
+ depend on that the String lenth is same as buffer length.
+ */
Static_binary_string::set(str, arg_length);
Alloced_length= (uint32) arg_length;
}
@@ -660,8 +666,9 @@ public:
my_free(Ptr);
}
Alloced_length= extra_alloc= 0;
- Static_binary_string::set(NULL, 0); // Safety
+ Static_binary_string::set(NULL, 0); // Safety, probably not needed
}
+
inline bool alloc(size_t arg_length)
{
/*
@@ -771,10 +778,6 @@ public:
String(size_t length_arg)
:Binary_string(length_arg)
{ }
- String(const char *str, CHARSET_INFO *cs)
- :Charset(cs),
- Binary_string(str)
- { }
/*
NOTE: If one intend to use the c_ptr() method, the following two
contructors need the size of memory for STR to be at least LEN+1 (to make
@@ -809,9 +812,10 @@ public:
set_charset(cs);
}
bool set_ascii(const char *str, size_t arg_length);
- inline void set_quick(char *str,size_t arg_length, CHARSET_INFO *cs)
+ inline void set_buffer_if_not_allocated(char *str,size_t arg_length,
+ CHARSET_INFO *cs)
{
- Binary_string::set_quick(str, arg_length);
+ Binary_string::set_buffer_if_not_allocated(str, arg_length);
set_charset(cs);
}
bool set_int(longlong num, bool unsigned_flag, CHARSET_INFO *cs);
@@ -931,8 +935,8 @@ public:
bool append_introducer_and_hex(const String *str)
{
return
- append(STRING_WITH_LEN("_")) ||
- append(str->charset()->csname) ||
+ append('_') ||
+ append(str->charset()->csname, strlen(str->charset()->csname)) ||
append(STRING_WITH_LEN(" 0x")) ||
append_hex(str->ptr(), (uint32) str->length());
}
@@ -946,10 +950,6 @@ public:
}
// Append with optional character set conversion from ASCII (e.g. to UCS2)
- bool append(const char *s)
- {
- return append(s, strlen(s));
- }
bool append(const LEX_STRING *ls)
{
DBUG_ASSERT(ls->length < UINT_MAX32 &&
@@ -1015,12 +1015,6 @@ public:
{
return append_for_single_quote(s->ptr(), s->length());
}
- bool append_for_single_quote(const char *st)
- {
- size_t len= strlen(st);
- DBUG_ASSERT(len < UINT_MAX32);
- return append_for_single_quote(st, (uint32) len);
- }
void swap(String &s)
{
@@ -1083,18 +1077,6 @@ public:
BinaryStringBuffer() : Binary_string(buff, buff_sz) { length(0); }
};
-
-class String_space: public String
-{
-public:
- String_space(uint n)
- {
- if (fill(n, ' '))
- set("", 0, &my_charset_bin);
- }
-};
-
-
static inline bool check_if_only_end_space(CHARSET_INFO *cs,
const char *str,
const char *end)
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 794b46217c5..9b9a6653793 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -61,7 +61,11 @@
#include <io.h>
#endif
-const char *primary_key_name="PRIMARY";
+const LEX_CSTRING primary_key_name= { STRING_WITH_LEN("PRIMARY") };
+static const LEX_CSTRING generated_by_server=
+{ STRING_WITH_LEN(" /* generated by server */") };
+static const LEX_CSTRING SEQUENCE_clex_str= { STRING_WITH_LEN("SEQUENCE") };
+static const LEX_CSTRING TABLE_clex_str= { STRING_WITH_LEN("TABLE") };
static int check_if_keyname_exists(const char *name,KEY *start, KEY *end);
static char *make_unique_key_name(THD *, const char *, KEY *, KEY *);
@@ -2241,7 +2245,9 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
bool non_tmp_table_deleted= 0;
bool is_drop_tmp_if_exists_added= 0;
bool was_view= 0, was_table= 0, log_if_exists= if_exists;
- const char *object_to_drop= (drop_sequence) ? "SEQUENCE" : "TABLE";
+ const LEX_CSTRING *object_to_drop= ((drop_sequence) ?
+ &SEQUENCE_clex_str :
+ &TABLE_clex_str);
String normal_tables;
String built_trans_tmp_query, built_non_trans_tmp_query;
DBUG_ENTER("mysql_rm_table_no_locks");
@@ -2286,13 +2292,13 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
if (!dont_log_query)
{
built_trans_tmp_query.set_charset(system_charset_info);
- built_trans_tmp_query.append("DROP TEMPORARY ");
+ built_trans_tmp_query.append(STRING_WITH_LEN("DROP TEMPORARY "));
built_trans_tmp_query.append(object_to_drop);
built_trans_tmp_query.append(' ');
if (thd->is_current_stmt_binlog_format_row() || if_exists)
{
is_drop_tmp_if_exists_added= true;
- built_trans_tmp_query.append("IF EXISTS ");
+ built_trans_tmp_query.append(STRING_WITH_LEN("IF EXISTS "));
}
built_non_trans_tmp_query.set_charset(system_charset_info);
built_non_trans_tmp_query.copy(built_trans_tmp_query);
@@ -2400,10 +2406,10 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
is_drop_tmp_if_exists_added )
{
append_identifier(thd, built_ptr_query, &db);
- built_ptr_query->append(".");
+ built_ptr_query->append('.');
}
append_identifier(thd, built_ptr_query, &table_name);
- built_ptr_query->append(",");
+ built_ptr_query->append(',');
}
/*
This means that a temporary table was droped and as such there
@@ -2670,11 +2676,11 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
if (thd->db.str == NULL || cmp(&db, &thd->db) != 0)
{
append_identifier(thd, &normal_tables, &db);
- normal_tables.append(".");
+ normal_tables.append('.');
}
append_identifier(thd, &normal_tables, &table_name);
- normal_tables.append(",");
+ normal_tables.append(',');
}
DBUG_PRINT("table", ("table: %p s: %p", table->table,
table->table ? table->table->s : NULL));
@@ -2718,7 +2724,7 @@ err:
{
/* Chop of the last comma */
built_non_trans_tmp_query.chop();
- built_non_trans_tmp_query.append(" /* generated by server */");
+ built_non_trans_tmp_query.append(generated_by_server);
error |= (thd->binlog_query(THD::STMT_QUERY_TYPE,
built_non_trans_tmp_query.ptr(),
built_non_trans_tmp_query.length(),
@@ -2730,7 +2736,7 @@ err:
{
/* Chop of the last comma */
built_trans_tmp_query.chop();
- built_trans_tmp_query.append(" /* generated by server */");
+ built_trans_tmp_query.append(generated_by_server);
error |= (thd->binlog_query(THD::STMT_QUERY_TYPE,
built_trans_tmp_query.ptr(),
built_trans_tmp_query.length(),
@@ -2745,24 +2751,24 @@ err:
uint32 comment_len;
built_query.set_charset(thd->charset());
- built_query.append("DROP ");
+ built_query.append(STRING_WITH_LEN("DROP "));
built_query.append(object_to_drop);
built_query.append(' ');
if (log_if_exists)
- built_query.append("IF EXISTS ");
+ built_query.append(STRING_WITH_LEN("IF EXISTS "));
/* Preserve comment in original query */
if ((comment_len= comment_length(thd, if_exists ? 17:9,
&comment_start)))
{
built_query.append(comment_start, comment_len);
- built_query.append(" ");
+ built_query.append(' ');
}
/* Chop of the last comma */
normal_tables.chop();
built_query.append(normal_tables.ptr(), normal_tables.length());
- built_query.append(" /* generated by server */");
+ built_query.append(generated_by_server);
error |= (thd->binlog_query(THD::STMT_QUERY_TYPE,
built_query.ptr(),
built_query.length(),
@@ -2845,7 +2851,7 @@ bool log_drop_table(THD *thd, const LEX_CSTRING *db_name,
query.append(STRING_WITH_LEN("TEMPORARY "));
query.append(STRING_WITH_LEN("TABLE IF EXISTS "));
append_identifier(thd, &query, db_name);
- query.append(".");
+ query.append('.');
append_identifier(thd, &query, table_name);
query.append(STRING_WITH_LEN("/* Generated to handle "
"failed CREATE OR REPLACE */"));
@@ -2956,9 +2962,9 @@ static int sort_keys(KEY *a, KEY *b)
/* Sort NOT NULL keys before other keys */
return (a_flags & HA_NULL_PART_KEY) ? 1 : -1;
}
- if (a->name.str == primary_key_name)
+ if (a->name.str == primary_key_name.str)
return -1;
- if (b->name.str == primary_key_name)
+ if (b->name.str == primary_key_name.str)
return 1;
/* Sort keys don't containing partial segments before others */
if ((a_flags ^ b_flags) & HA_KEY_HAS_PART_KEY_SEG)
@@ -3616,7 +3622,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (!(file->ha_table_flags() & HA_CAN_TABLES_WITHOUT_ROLLBACK))
{
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0), file->table_type(),
- "SEQUENCE");
+ SEQUENCE_clex_str.str);
DBUG_RETURN(TRUE);
}
@@ -3864,13 +3870,14 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
else
(*key_count)--;
if (key->name.str && !tmp_table && (key->type != Key::PRIMARY) &&
- !my_strcasecmp(system_charset_info, key->name.str, primary_key_name))
+ !my_strcasecmp(system_charset_info, key->name.str,
+ primary_key_name.str))
{
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name.str);
DBUG_RETURN(TRUE);
}
if (key->type == Key::PRIMARY && key->name.str &&
- my_strcasecmp(system_charset_info, key->name.str, primary_key_name) != 0)
+ my_strcasecmp(system_charset_info, key->name.str, primary_key_name.str) != 0)
{
bool sav_abort_on_warning= thd->abort_on_warning;
thd->abort_on_warning= FALSE; /* Don't make an error out of this. */
@@ -3891,7 +3898,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
{
if (key->name.str == ignore_key || key->type == Key::FOREIGN_KEY)
continue;
- /* Create the key->ame based on the first column (if not given) */
+ /* Create the key name based on the first column (if not given) */
if (key->type == Key::PRIMARY)
{
if (primary_key)
@@ -3900,7 +3907,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
MYF(0));
DBUG_RETURN(true);
}
- key_name=primary_key_name;
+ key_name= primary_key_name.str;
primary_key=1;
}
else if (!(key_name= key->name.str))
@@ -5696,7 +5703,7 @@ make_unique_key_name(THD *thd, const char *field_name,KEY *start,KEY *end)
char buff[MAX_FIELD_NAME],*buff_end;
if (!check_if_keyname_exists(field_name,start,end) &&
- my_strcasecmp(system_charset_info,field_name,primary_key_name))
+ my_strcasecmp(system_charset_info,field_name,primary_key_name.str))
return (char*) field_name; // Use fieldname
buff_end=strmake(buff,field_name, sizeof(buff)-4);
@@ -6713,7 +6720,7 @@ drop_create_field:
key->type == Key::PRIMARY &&
table->s->primary_key != MAX_KEY &&
(keyname= table->s->key_info[table->s->primary_key].name.str) &&
- my_strcasecmp(system_charset_info, keyname, primary_key_name) == 0;
+ my_strcasecmp(system_charset_info, keyname, primary_key_name.str) == 0;
if (dup_primary_key)
goto remove_key;
@@ -6722,7 +6729,7 @@ drop_create_field:
if ((keyname= key->name.str) == NULL)
{
if (key->type == Key::PRIMARY)
- keyname= primary_key_name;
+ keyname= primary_key_name.str;
else
{
List_iterator<Key_part_spec> part_it(key->columns);
@@ -7437,7 +7444,7 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar,
const KEY* const new_pk= (ha_alter_info->key_count > 0 &&
(!my_strcasecmp(system_charset_info,
ha_alter_info->key_info_buffer->name.str,
- primary_key_name) ||
+ primary_key_name.str) ||
is_candidate_key(ha_alter_info->key_info_buffer))) ?
ha_alter_info->key_info_buffer : NULL;
const KEY *const old_pk= table->s->primary_key == MAX_KEY ? NULL :
@@ -8918,13 +8925,13 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
{
if (!my_strcasecmp(system_charset_info, key_name, rename_key->old_name.str))
{
- if (!my_strcasecmp(system_charset_info, key_name, primary_key_name))
+ if (!my_strcasecmp(system_charset_info, key_name, primary_key_name.str))
{
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), rename_key->old_name.str);
goto err;
}
else if (!my_strcasecmp(system_charset_info, rename_key->new_name.str,
- primary_key_name))
+ primary_key_name.str))
{
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), rename_key->new_name.str);
goto err;
@@ -9081,7 +9088,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
key_type= Key::SPATIAL;
else if (key_info->flags & HA_NOSAME)
{
- if (! my_strcasecmp(system_charset_info, key_name, primary_key_name))
+ if (! my_strcasecmp(system_charset_info, key_name, primary_key_name.str))
key_type= Key::PRIMARY;
else
key_type= Key::UNIQUE;
@@ -9144,7 +9151,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
goto err;
new_key_list.push_back(key, thd->mem_root);
if (key->name.str &&
- !my_strcasecmp(system_charset_info, key->name.str, primary_key_name))
+ !my_strcasecmp(system_charset_info, key->name.str,
+ primary_key_name.str))
{
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name.str);
goto err;
@@ -11837,11 +11845,13 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
/* Open one table after the other to keep lock time as short as possible. */
for (table= tables; table; table= table->next_local)
{
- char table_name[SAFE_NAME_LEN*2+2];
+ char table_name_buff[SAFE_NAME_LEN*2+2];
+ LEX_CSTRING table_name= { table_name_buff, 0};
TABLE *t;
TABLE_LIST *save_next_global;
- strxmov(table_name, table->db.str ,".", table->table_name.str, NullS);
+ table_name.length= strxmov(table_name_buff, table->db.str ,".",
+ table->table_name.str, NullS) - table_name_buff;
/* Remember old 'next' pointer and break the list. */
save_next_global= table->next_global;
@@ -11861,7 +11871,7 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
table->next_global= save_next_global;
protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
+ protocol->store(&table_name, system_charset_info);
if (!t)
{
diff --git a/sql/sql_table.h b/sql/sql_table.h
index 53741d934cc..51cf73db915 100644
--- a/sql/sql_table.h
+++ b/sql/sql_table.h
@@ -286,7 +286,7 @@ uint explain_filename(THD* thd, const char *from, char *to, uint to_length,
enum_explain_filename_mode explain_mode);
-extern MYSQL_PLUGIN_IMPORT const char *primary_key_name;
+extern MYSQL_PLUGIN_IMPORT const LEX_CSTRING primary_key_name;
extern mysql_mutex_t LOCK_gdl;
bool check_engine(THD *, const char *, const char *, HA_CREATE_INFO *);
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 8c9c56f1db7..e29bb3188f5 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -127,25 +127,26 @@ void TEST_filesort(SORT_FIELD *sortorder,uint s_length)
char buff[256],buff2[256];
String str(buff,sizeof(buff),system_charset_info);
String out(buff2,sizeof(buff2),system_charset_info);
- const char *sep;
+ DBUG_ASSERT(s_length > 0);
DBUG_ENTER("TEST_filesort");
out.length(0);
- for (sep=""; s_length-- ; sortorder++, sep=" ")
+ for (; s_length-- ; sortorder++)
{
- out.append(sep);
if (sortorder->reverse)
out.append('-');
if (sortorder->field)
{
if (sortorder->field->table_name)
{
- out.append(*sortorder->field->table_name);
+ const char *table_name= *sortorder->field->table_name;
+ out.append(table_name, strlen(table_name));
out.append('.');
}
- out.append(sortorder->field->field_name.str ?
- sortorder->field->field_name.str :
- "tmp_table_column");
+ const char *name= sortorder->field->field_name.str;
+ if (!name)
+ name= "tmp_table_column";
+ out.append(name, strlen(name));
}
else
{
@@ -153,7 +154,9 @@ void TEST_filesort(SORT_FIELD *sortorder,uint s_length)
sortorder->item->print(&str, QT_ORDINARY);
out.append(str);
}
+ out.append(' ');
}
+ out.chop(); // Remove last space
DBUG_LOCK_FILE;
(void) fputs("\nInfo about FILESORT\n",DBUG_FILE);
fprintf(DBUG_FILE,"Sortorder: %s\n",out.c_ptr_safe());
@@ -186,8 +189,9 @@ TEST_join(JOIN *join)
JOIN_TAB *tab= jt_range->start + i;
for (ref= 0; ref < tab->ref.key_parts; ref++)
{
- ref_key_parts[i].append(tab->ref.items[ref]->full_name());
- ref_key_parts[i].append(" ");
+ const char *full_name=(tab->ref.items[ref]->full_name());
+ ref_key_parts[i].append(full_name, strlen(full_name));
+ ref_key_parts[i].append(STRING_WITH_LEN(" "));
}
}
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc
index ab1ce65bae5..6ab644eb3ce 100644
--- a/sql/sql_truncate.cc
+++ b/sql/sql_truncate.cc
@@ -49,7 +49,7 @@ static bool fk_info_append_fields(THD *thd, String *str,
while ((field= it++))
{
res|= append_identifier(thd, str, field);
- res|= str->append(", ");
+ res|= str->append(STRING_WITH_LEN(", "));
}
str->chop();
@@ -81,17 +81,17 @@ static const char *fk_info_str(THD *thd, FOREIGN_KEY_INFO *fk_info)
*/
res|= append_identifier(thd, &str, fk_info->foreign_db);
- res|= str.append(".");
+ res|= str.append('.');
res|= append_identifier(thd, &str, fk_info->foreign_table);
- res|= str.append(", CONSTRAINT ");
+ res|= str.append(STRING_WITH_LEN(", CONSTRAINT "));
res|= append_identifier(thd, &str, fk_info->foreign_id);
- res|= str.append(" FOREIGN KEY (");
+ res|= str.append(STRING_WITH_LEN(" FOREIGN KEY ("));
res|= fk_info_append_fields(thd, &str, &fk_info->foreign_fields);
- res|= str.append(") REFERENCES ");
+ res|= str.append(STRING_WITH_LEN(") REFERENCES "));
res|= append_identifier(thd, &str, fk_info->referenced_db);
- res|= str.append(".");
+ res|= str.append('.');
res|= append_identifier(thd, &str, fk_info->referenced_table);
- res|= str.append(" (");
+ res|= str.append(STRING_WITH_LEN(" ("));
res|= fk_info_append_fields(thd, &str, &fk_info->referenced_fields);
res|= str.append(')');
diff --git a/sql/sql_type.cc b/sql/sql_type.cc
index af046817add..2ed15d54569 100644
--- a/sql/sql_type.cc
+++ b/sql/sql_type.cc
@@ -1294,8 +1294,9 @@ Type_numeric_attributes::aggregate_numeric_attributes_real(Item **items,
@retval False on success, true on error.
*/
-bool Type_std_attributes::aggregate_attributes_string(const char *func_name,
- Item **items, uint nitems)
+bool Type_std_attributes::
+aggregate_attributes_string(const LEX_CSTRING &func_name,
+ Item **items, uint nitems)
{
if (agg_arg_charsets_for_string_result(collation, func_name,
items, nitems, 1))
@@ -1424,10 +1425,10 @@ CHARSET_INFO *Type_handler::charset_for_protocol(const Item *item) const
bool
-Type_handler::Item_func_or_sum_illegal_param(const char *funcname) const
+Type_handler::Item_func_or_sum_illegal_param(const LEX_CSTRING &funcname) const
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- name().ptr(), funcname);
+ name().ptr(), funcname.str);
return true;
}
@@ -1435,7 +1436,7 @@ Type_handler::Item_func_or_sum_illegal_param(const char *funcname) const
bool
Type_handler::Item_func_or_sum_illegal_param(const Item_func_or_sum *it) const
{
- return Item_func_or_sum_illegal_param(it->func_name());
+ return Item_func_or_sum_illegal_param(it->func_name_cstring());
}
@@ -1831,10 +1832,9 @@ Type_handler::bit_and_int_mixture_handler(uint max_char_length)
@retval true - on error
*/
-bool
-Type_handler_hybrid_field_type::aggregate_for_result(const char *funcname,
- Item **items, uint nitems,
- bool treat_bit_as_number)
+bool Type_handler_hybrid_field_type::
+aggregate_for_result(const LEX_CSTRING &funcname, Item **items, uint nitems,
+ bool treat_bit_as_number)
{
bool bit_and_non_bit_mixture_found= false;
uint32 max_display_length;
@@ -1862,7 +1862,7 @@ Type_handler_hybrid_field_type::aggregate_for_result(const char *funcname,
if (aggregate_for_result(cur))
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION, MYF(0),
- type_handler()->name().ptr(), cur->name().ptr(), funcname);
+ type_handler()->name().ptr(), cur->name().ptr(), funcname.str);
return true;
}
}
@@ -2051,7 +2051,7 @@ Type_collection_std::aggregate_for_min_max(const Type_handler *ha,
bool
-Type_handler_hybrid_field_type::aggregate_for_min_max(const char *funcname,
+Type_handler_hybrid_field_type::aggregate_for_min_max(const LEX_CSTRING &funcname,
Item **items, uint nitems)
{
bool bit_and_non_bit_mixture_found= false;
@@ -2067,7 +2067,7 @@ Type_handler_hybrid_field_type::aggregate_for_min_max(const char *funcname,
if (aggregate_for_min_max(cur))
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION, MYF(0),
- type_handler()->name().ptr(), cur->name().ptr(), funcname);
+ type_handler()->name().ptr(), cur->name().ptr(), funcname.str);
return true;
}
}
@@ -4579,7 +4579,7 @@ Type_handler_timestamp_common::create_item_copy(THD *thd, Item *item) const
bool Type_handler_int_result::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -4605,7 +4605,7 @@ bool Type_handler_int_result::
bool Type_handler_real_result::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -4617,7 +4617,7 @@ bool Type_handler_real_result::
bool Type_handler_decimal_result::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -4630,7 +4630,7 @@ bool Type_handler_decimal_result::
bool Type_handler_string_result::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &func_name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -4646,7 +4646,7 @@ bool Type_handler_string_result::
*/
bool Type_handler_typelib::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &func_name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -4678,7 +4678,7 @@ bool Type_handler_typelib::
bool Type_handler_blob_common::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &func_name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -4692,7 +4692,7 @@ bool Type_handler_blob_common::
bool Type_handler_date_common::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -4704,7 +4704,7 @@ bool Type_handler_date_common::
bool Type_handler_time_common::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -4716,7 +4716,7 @@ bool Type_handler_time_common::
bool Type_handler_datetime_common::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -4728,7 +4728,7 @@ bool Type_handler_datetime_common::
bool Type_handler_timestamp_common::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -4748,7 +4748,7 @@ bool Type_handler::
with aggregating for CASE-alike functions (e.g. COALESCE)
for the majority of data type handlers.
*/
- return Item_hybrid_func_fix_attributes(thd, func->func_name(),
+ return Item_hybrid_func_fix_attributes(thd, func->func_name_cstring(),
func, func, items, nitems);
}
@@ -6209,9 +6209,9 @@ String *Type_handler_row::
if (tmp)
str->append(*tmp);
else
- str->append(STRING_WITH_LEN("NULL"));
+ str->append(NULL_clex_str);
}
- str->append(STRING_WITH_LEN(")"));
+ str->append(')');
return str;
}
@@ -6231,15 +6231,17 @@ String *Type_handler::
StringBuffer<STRING_BUFFER_USUAL_SIZE> buf(result->charset());
CHARSET_INFO *cs= thd->variables.character_set_client;
+ const char *res_cs_name= result->charset()->csname;
+ const char *collation_name= item->collation.collation->name;
buf.append('_');
- buf.append(result->charset()->csname);
+ buf.append(res_cs_name, strlen(res_cs_name));
if (cs->escape_with_backslash_is_dangerous)
buf.append(' ');
append_query_string(cs, &buf, result->ptr(), result->length(),
thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES);
- buf.append(" COLLATE '");
- buf.append(item->collation.collation->name);
+ buf.append(STRING_WITH_LEN(" COLLATE '"));
+ buf.append(collation_name, strlen(collation_name));
buf.append('\'');
str->copy(buf);
@@ -9219,7 +9221,7 @@ bool Type_handler::Column_definition_data_type_info_image(Binary_string *to,
// Have *some* columns write type info (let's use string fields as an example)
DBUG_EXECUTE_IF("frm_data_type_info_emulate",
if (cmp_type() == STRING_RESULT)
- return to->append("x", 1) ||
+ return to->append_char('x') ||
to->append(name().lex_cstring()););
if (type_collection() != &type_collection_std)
return to->append(name().lex_cstring());
@@ -9339,7 +9341,7 @@ bool Type_handler::partition_field_append_value(
String *res;
if (!(res= item_expr->val_str(&buf)))
- return str->append(STRING_WITH_LEN("NULL"), system_charset_info);
+ return str->append(NULL_clex_str, system_charset_info);
if (!res->length())
return str->append(STRING_WITH_LEN("''"), system_charset_info);
diff --git a/sql/sql_type.h b/sql/sql_type.h
index bf2c92b3f50..0d62d9738d6 100644
--- a/sql/sql_type.h
+++ b/sql/sql_type.h
@@ -3193,7 +3193,7 @@ public:
aggregate_numeric_attributes_decimal(items, nitems,
(unsigned_flag= unsigned_arg));
}
- bool aggregate_attributes_string(const char *func_name,
+ bool aggregate_attributes_string(const LEX_CSTRING &func_name,
Item **item, uint nitems);
void aggregate_attributes_temporal(uint int_part_length,
Item **item, uint nitems)
@@ -3201,10 +3201,11 @@ public:
fix_attributes_temporal(int_part_length, find_max_decimals(item, nitems));
}
- bool agg_item_collations(DTCollation &c, const char *name,
+ bool agg_item_collations(DTCollation &c, const LEX_CSTRING &name,
Item **items, uint nitems,
uint flags, int item_sep);
- bool agg_item_set_converter(const DTCollation &coll, const char *fname,
+ bool agg_item_set_converter(const DTCollation &coll,
+ const LEX_CSTRING &name,
Item **args, uint nargs,
uint flags, int item_sep);
@@ -3236,7 +3237,7 @@ public:
agg_item_charsets(coll, fname, &args[2], 2, flags, 3)
*/
- bool agg_arg_charsets(DTCollation &c, const char *func_name,
+ bool agg_arg_charsets(DTCollation &c, const LEX_CSTRING &func_name,
Item **items, uint nitems,
uint flags, int item_sep)
{
@@ -3249,7 +3250,8 @@ public:
- convert to @@character_set_connection if all arguments are numbers
- allow DERIVATION_NONE
*/
- bool agg_arg_charsets_for_string_result(DTCollation &c, const char *func_name,
+ bool agg_arg_charsets_for_string_result(DTCollation &c,
+ const LEX_CSTRING &func_name,
Item **items, uint nitems,
int item_sep)
{
@@ -3265,7 +3267,7 @@ public:
- disallow DERIVATION_NONE
*/
bool agg_arg_charsets_for_string_result_with_comparison(DTCollation &c,
- const char *func_name,
+ const LEX_CSTRING &func_name,
Item **items,
uint nitems,
int item_sep)
@@ -3283,7 +3285,7 @@ public:
- don't allow DERIVATION_NONE
*/
bool agg_arg_charsets_for_comparison(DTCollation &c,
- const char *func_name,
+ const LEX_CSTRING &func_name,
Item **items, uint nitems,
int item_sep)
{
@@ -3589,7 +3591,7 @@ protected:
longlong value,
const SORT_FIELD_ATTR *sort_field) const;
- bool Item_func_or_sum_illegal_param(const char *name) const;
+ bool Item_func_or_sum_illegal_param(const LEX_CSTRING &name) const;
bool Item_func_or_sum_illegal_param(const Item_func_or_sum *) const;
bool check_null(const Item *item, st_value *value) const;
bool Item_send_str(Item *item, Protocol *protocol, st_value *buf) const;
@@ -4190,7 +4192,7 @@ public:
virtual bool Item_eq_value(THD *thd, const Type_cmp_attributes *attr,
Item *a, Item *b) const= 0;
virtual bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items,
@@ -4523,7 +4525,7 @@ public:
}
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems)
@@ -4820,7 +4822,7 @@ public:
const override;
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems)
@@ -4956,7 +4958,7 @@ public:
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems)
@@ -5190,7 +5192,7 @@ public:
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems) const override;
@@ -5454,7 +5456,7 @@ public:
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems) const
@@ -6135,7 +6137,7 @@ public:
Item_cache *Item_get_cache(THD *thd, const Item *item) const override;
longlong Item_val_int_unsigned_typecast(Item *item) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems)
@@ -6329,7 +6331,7 @@ public:
bool Item_func_round_fix_length_and_dec(Item_func_round *) const override;
bool Item_func_int_val_fix_length_and_dec(Item_func_int_val*) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems) const
@@ -6470,7 +6472,7 @@ public:
const override;
bool Item_func_round_fix_length_and_dec(Item_func_round *) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems)
@@ -6634,7 +6636,7 @@ public:
my_decimal *) const override;
bool set_comparator_func(THD *thd, Arg_comparator *cmp) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems)
@@ -7121,7 +7123,7 @@ public:
const Column_definition &def,
const handler *file) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems) const
@@ -7253,7 +7255,7 @@ public:
bool Item_func_int_val_fix_length_and_dec(Item_func_int_val*) const override;
uint32 max_display_length_for_field(const Conv_source &src) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *,
Type_all_attributes *atrr,
Item **items, uint nitems)
@@ -7456,13 +7458,14 @@ public:
return (m_type_handler= Type_handler::get_handler_by_real_type(type));
}
bool aggregate_for_comparison(const Type_handler *other);
- bool aggregate_for_comparison(const char *funcname,
+ bool aggregate_for_comparison(const LEX_CSTRING &funcname,
Item **items, uint nitems,
bool treat_int_to_uint_as_decimal);
bool aggregate_for_result(const Type_handler *other);
- bool aggregate_for_result(const char *funcname,
+ bool aggregate_for_result(const LEX_CSTRING &funcname,
Item **item, uint nitems, bool treat_bit_as_number);
- bool aggregate_for_min_max(const char *funcname, Item **item, uint nitems);
+ bool aggregate_for_min_max(const LEX_CSTRING &funcname, Item **item,
+ uint nitems);
bool aggregate_for_num_op(const class Type_aggregator *aggregator,
const Type_handler *h0, const Type_handler *h1);
diff --git a/sql/sql_type_geom.cc b/sql/sql_type_geom.cc
index cfe71c8b51e..5732ae47217 100644
--- a/sql/sql_type_geom.cc
+++ b/sql/sql_type_geom.cc
@@ -205,8 +205,9 @@ bool Type_collection_geometry::init(Type_handler_data *data)
}
-bool Type_handler_geometry::check_type_geom_or_binary(const char *opname,
- const Item *item)
+bool Type_handler_geometry::
+check_type_geom_or_binary(const LEX_CSTRING &opname,
+ const Item *item)
{
const Type_handler *handler= item->type_handler();
if (handler->type_handler_for_comparison() == &type_handler_geometry ||
@@ -214,14 +215,15 @@ bool Type_handler_geometry::check_type_geom_or_binary(const char *opname,
item->collation.collation == &my_charset_bin))
return false;
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
- handler->name().ptr(), opname);
+ handler->name().ptr(), opname.str);
return true;
}
-bool Type_handler_geometry::check_types_geom_or_binary(const char *opname,
- Item* const *args,
- uint start, uint end)
+bool Type_handler_geometry::
+check_types_geom_or_binary(const LEX_CSTRING &opname,
+ Item* const *args,
+ uint start, uint end)
{
for (uint i= start; i < end ; i++)
{
@@ -491,7 +493,7 @@ Field *Type_handler_geometry::make_table_field(MEM_ROOT *root,
bool Type_handler_geometry::
Item_hybrid_func_fix_attributes(THD *thd,
- const char *func_name,
+ const LEX_CSTRING &func_name,
Type_handler_hybrid_field_type *handler,
Type_all_attributes *func,
Item **items, uint nitems) const
@@ -509,14 +511,16 @@ bool Type_handler_geometry::
bool Type_handler_geometry::
Item_sum_sum_fix_length_and_dec(Item_sum_sum *item) const
{
- return Item_func_or_sum_illegal_param("sum");
+ LEX_CSTRING name= {STRING_WITH_LEN("sum") };
+ return Item_func_or_sum_illegal_param(name);
}
bool Type_handler_geometry::
Item_sum_avg_fix_length_and_dec(Item_sum_avg *item) const
{
- return Item_func_or_sum_illegal_param("avg");
+ LEX_CSTRING name= {STRING_WITH_LEN("avg") };
+ return Item_func_or_sum_illegal_param(name);
}
diff --git a/sql/sql_type_geom.h b/sql/sql_type_geom.h
index fed988c3113..a2bcd45e0e8 100644
--- a/sql/sql_type_geom.h
+++ b/sql/sql_type_geom.h
@@ -34,8 +34,9 @@ public:
GEOM_MULTIPOINT = 4, GEOM_MULTILINESTRING = 5, GEOM_MULTIPOLYGON = 6,
GEOM_GEOMETRYCOLLECTION = 7
};
- static bool check_type_geom_or_binary(const char *opname, const Item *item);
- static bool check_types_geom_or_binary(const char *opname,
+ static bool check_type_geom_or_binary(const LEX_CSTRING &opname,
+ const Item *item);
+ static bool check_types_geom_or_binary(const LEX_CSTRING &opname,
Item * const *args,
uint start, uint end);
static const Type_handler_geometry *type_handler_geom_by_type(uint type);
@@ -155,7 +156,7 @@ public:
bool Item_func_abs_fix_length_and_dec(Item_func_abs *) const override;
bool Item_func_neg_fix_length_and_dec(Item_func_neg *) const override;
bool Item_hybrid_func_fix_attributes(THD *thd,
- const char *name,
+ const LEX_CSTRING &name,
Type_handler_hybrid_field_type *h,
Type_all_attributes *attr,
Item **items, uint nitems) const
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 055fcb90a31..fffe37a8054 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -689,11 +689,13 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
LEX_CSTRING *name;
int i;
+ buff.append('(');
for (i= 0; (name= names++); i++)
{
- buff.append(i ? ", " : "(");
append_identifier(thd, &buff, name);
+ buff.append(", ", 2);
}
+ buff.length(buff.length()-2);
buff.append(')');
}
buff.append(STRING_WITH_LEN(" AS "));
@@ -1843,11 +1845,11 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
if ((not_exist= my_access(path, F_OK)) || !dd_frm_is_view(thd, path))
{
char name[FN_REFLEN];
- my_snprintf(name, sizeof(name), "%s.%s", view->db.str,
- view->table_name.str);
+ size_t length= my_snprintf(name, sizeof(name), "%s.%s", view->db.str,
+ view->table_name.str);
if (non_existant_views.length())
non_existant_views.append(',');
- non_existant_views.append(name);
+ non_existant_views.append(name, length);
if (!not_exist)
{
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index d971ccbf81c..d819767a6ca 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -7793,7 +7793,7 @@ alter_list_item:
{
LEX *lex=Lex;
Alter_drop *ad= (new (thd->mem_root)
- Alter_drop(Alter_drop::KEY, primary_key_name,
+ Alter_drop(Alter_drop::KEY, primary_key_name.str,
FALSE));
if (unlikely(ad == NULL))
MYSQL_YYABORT;
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index 6c8fd24f780..9f178950fb0 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -365,7 +365,7 @@ const char *set_to_string(THD *thd, LEX_CSTRING *result, ulonglong set,
for (uint i= 0; set; i++, set >>= 1)
if (set & 1) {
- tmp.append(lib[i]);
+ tmp.append(lib[i], strlen(lib[i]));
tmp.append(',');
}
@@ -396,8 +396,11 @@ const char *flagset_to_string(THD *thd, LEX_CSTRING *result, ulonglong set,
// note that the last element is always "default", and it's ignored below
for (uint i= 0; lib[i+1]; i++, set >>= 1)
{
- tmp.append(lib[i]);
- tmp.append(set & 1 ? "=on," : "=off,");
+ tmp.append(lib[i], strlen(lib[i]));
+ if (set & 1)
+ tmp.append(STRING_WITH_LEN("=on,"));
+ else
+ tmp.append(STRING_WITH_LEN("=off,"));
}
result->str= thd->strmake(tmp.ptr(), tmp.length()-1);
diff --git a/sql/table.cc b/sql/table.cc
index 570f01efa28..fcbba0b0212 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2800,8 +2800,9 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
uint add_first_key_parts= 0;
longlong ha_option= handler_file->ha_table_flags();
keyinfo= share->key_info;
- uint primary_key= my_strcasecmp(system_charset_info, share->keynames.type_names[0],
- primary_key_name) ? MAX_KEY : 0;
+ uint primary_key= my_strcasecmp(system_charset_info,
+ share->keynames.type_names[0],
+ primary_key_name.str) ? MAX_KEY : 0;
KEY* key_first_info= NULL;
if (primary_key >= MAX_KEY && keyinfo->flags & HA_NOSAME &&
@@ -6157,10 +6158,10 @@ int TABLE::verify_constraints(bool ignore_failure)
vcol_type == VCOL_CHECK_FIELD);
if (vcol_type == VCOL_CHECK_FIELD)
{
- field_error.append(s->table_name.str);
- field_error.append(".");
+ field_error.append(s->table_name);
+ field_error.append('.');
}
- field_error.append((*chk)->name.str);
+ field_error.append((*chk)->name);
my_error(ER_CONSTRAINT_FAILED,
MYF(ignore_failure ? ME_WARNING : 0), field_error.c_ptr(),
s->db.str, s->table_name.str);
diff --git a/sql/tztime.cc b/sql/tztime.cc
index d34c2b7a0ca..0e334bec3dd 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -1769,7 +1769,8 @@ end_with_setting_default_tz:
/* If we have default time zone try to load it */
if (default_tzname)
{
- String tmp_tzname2(default_tzname, &my_charset_latin1);
+ String tmp_tzname2(default_tzname, strlen(default_tzname),
+ &my_charset_latin1);
/*
Time zone tables may be open here, and my_tz_find() may open
most of them once more, but this is OK for system tables open
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 64fa8db26fc..b953854479d 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -2130,11 +2130,14 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len)
LEX_CSTRING *name;
int i;
+ buff.append('(');
for (i= 0; (name= names++); i++)
{
- buff.append(i ? ", " : "(");
append_identifier(thd, &buff, name);
+ buff.append(", ", 2);
}
+ if (i)
+ buff.length(buff.length()-2);
buff.append(')');
}
buff.append(STRING_WITH_LEN(" AS "));
@@ -2172,25 +2175,25 @@ static int wsrep_drop_table_query(THD* thd, uchar** buf, size_t* buf_len)
if (found_temp_table)
{
- buff.append("DROP TABLE ");
+ buff.append(STRING_WITH_LEN("DROP TABLE "));
if (lex->check_exists)
- buff.append("IF EXISTS ");
+ buff.append(STRING_WITH_LEN("IF EXISTS "));
for (TABLE_LIST* table= first_table; table; table= table->next_global)
{
if (!thd->find_temporary_table(table->db.str, table->table_name.str))
{
append_identifier(thd, &buff, table->db.str, table->db.length);
- buff.append(".");
+ buff.append('.');
append_identifier(thd, &buff,
table->table_name.str, table->table_name.length);
- buff.append(",");
+ buff.append(',');
}
}
/* Chop the last comma */
buff.chop();
- buff.append(" /* generated by wsrep */");
+ buff.append(STRING_WITH_LEN(" /* generated by wsrep */"));
WSREP_DEBUG("Rewrote '%s' as '%s'", thd->query(), buff.ptr());
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 1474af92933..e263d7eeb55 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -2586,11 +2586,9 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
qry->Append('\'');
if (kpart->key_part_flag & HA_VAR_LENGTH_PART) {
- String varchar;
- uint var_length= uint2korr(ptr);
-
- varchar.set_quick((char*)ptr + HA_KEY_BLOB_LENGTH,
- var_length, &my_charset_bin);
+ uint var_length= uint2korr(ptr);
+ String varchar((char*) ptr + HA_KEY_BLOB_LENGTH,
+ var_length, &my_charset_bin);
qry->Append(varchar.ptr(), varchar.length(), nq);
} else {
char strbuff[MAX_FIELD_WIDTH];
@@ -3484,7 +3482,7 @@ bool ha_connect::get_error_message(int error, String* buf)
strlen(g->Message),
&my_charset_latin1).lex_cstring());
} else
- buf->append(STRING_WITH_LEN("Cannot retrieve error message"));
+ buf->append(STRING_WITH_LEN("Cannot retrieve error message"));
DBUG_RETURN(false);
} // end of get_error_message
@@ -5422,10 +5420,10 @@ static bool add_field(String* sql, TABTYPE ttp, const char* field_name, int typ,
bool q, error = false;
const char* type = PLGtoMYSQLtype(typ, dbf, var);
- error |= sql->append('`');
- error |= sql->append(field_name);
- error |= sql->append("` ");
- error |= sql->append(type);
+ error|= sql->append('`');
+ error|= sql->append(field_name, strlen(field_name));
+ error|= sql->append(STRING_WITH_LEN("` "));
+ error|= sql->append(type, strlen(type));
if (typ == TYPE_STRING ||
(len && typ != TYPE_DATE && (typ != TYPE_DOUBLE || dec >= 0))) {
@@ -5446,20 +5444,20 @@ static bool add_field(String* sql, TABTYPE ttp, const char* field_name, int typ,
} // endif len
if (v == 'U')
- error |= sql->append(" UNSIGNED");
+ error |= sql->append(STRING_WITH_LEN(" UNSIGNED"));
else if (v == 'Z')
- error |= sql->append(" ZEROFILL");
+ error |= sql->append(STRING_WITH_LEN(" ZEROFILL"));
if (key && *key) {
- error |= sql->append(" ");
- error |= sql->append(key);
+ error |= sql->append(' ');
+ error |= sql->append(key, strlen(key));
} // endif key
if (tm)
error |= sql->append(STRING_WITH_LEN(" NOT NULL"), system_charset_info);
if (dft && *dft) {
- error |= sql->append(" DEFAULT ");
+ error |= sql->append(STRING_WITH_LEN(" DEFAULT "));
if (typ == TYPE_DATE)
q = (strspn(dft, "0123456789 -:/") == strlen(dft));
@@ -5467,41 +5465,41 @@ static bool add_field(String* sql, TABTYPE ttp, const char* field_name, int typ,
q = !IsTypeNum(typ);
if (q) {
- error |= sql->append("'");
+ error |= sql->append(STRING_WITH_LEN("'"));
error |= sql->append_for_single_quote(dft, strlen(dft));
- error |= sql->append("'");
+ error |= sql->append('\'');
} else
- error |= sql->append(dft);
+ error |= sql->append(dft, strlen(dft));
} // endif dft
if (xtra && *xtra) {
- error |= sql->append(" ");
- error |= sql->append(xtra);
+ error |= sql->append(' ');
+ error |= sql->append(xtra, strlen(xtra));
} // endif rem
if (rem && *rem) {
- error |= sql->append(" COMMENT '");
+ error |= sql->append(STRING_WITH_LEN(" COMMENT '"));
error |= sql->append_for_single_quote(rem, strlen(rem));
- error |= sql->append("'");
+ error |= sql->append(STRING_WITH_LEN("'"));
} // endif rem
if (fmt && *fmt) {
switch (ttp) {
- case TAB_JSON: error |= sql->append(" JPATH='"); break;
+ case TAB_JSON: error |= sql->append(STRING_WITH_LEN(" JPATH='")); break;
#if defined(BSON_SUPPORT)
- case TAB_BSON: error |= sql->append(" JPATH='"); break;
+ case TAB_BSON: error |= sql->append(STRING_WITH_LEN(" JPATH='")); break;
#endif // BSON_SUPPORT
- case TAB_XML: error |= sql->append(" XPATH='"); break;
- default: error |= sql->append(" FIELD_FORMAT='");
+ case TAB_XML: error |= sql->append(STRING_WITH_LEN(" XPATH='")); break;
+ default: error |= sql->append(STRING_WITH_LEN(" FIELD_FORMAT='"));
} // endswitch ttp
error |= sql->append_for_single_quote(fmt, strlen(fmt));
- error |= sql->append("'");
+ error |= sql->append('\'');
} // endif flag
if (flag) {
- error |= sql->append(" FLAG=");
+ error |= sql->append(STRING_WITH_LEN(" FLAG="));
error |= sql->append_ulonglong(flag);
} // endif flag
@@ -5537,7 +5535,7 @@ static int init_table_share(THD* thd,
if (vull != opt->def_value) {
oom|= sql->append(' ');
- oom|= sql->append(opt->name);
+ oom|= sql->append(opt->name, strlen(opt->name));
oom|= sql->append('=');
oom|= sql->append_ulonglong(vull);
} // endif vull
@@ -5548,8 +5546,8 @@ static int init_table_share(THD* thd,
if (vstr) {
oom|= sql->append(' ');
- oom|= sql->append(opt->name);
- oom|= sql->append("='");
+ oom|= sql->append(opt->name, strlen(opt->name));
+ oom|= sql->append(STRING_WITH_LEN("='"));
oom|= sql->append_for_single_quote(vstr, strlen(vstr));
oom|= sql->append('\'');
} // endif vstr
@@ -5560,9 +5558,12 @@ static int init_table_share(THD* thd,
if (vull != opt->def_value) {
oom|= sql->append(' ');
- oom|= sql->append(opt->name);
+ oom|= sql->append(opt->name, strlen(opt->name));
oom|= sql->append('=');
- oom|= sql->append(vull ? "YES" : "NO");
+ if (vull)
+ oom|= sql->append("YES", 3);
+ else
+ oom|= sql->append("NO", 2);
} // endif vull
break;
@@ -5577,7 +5578,7 @@ static int init_table_share(THD* thd,
if (create_info->connect_string.length) {
oom|= sql->append(' ');
- oom|= sql->append("CONNECTION='");
+ oom|= sql->append(STRING_WITH_LEN("CONNECTION='"));
oom|= sql->append_for_single_quote(create_info->connect_string.str,
create_info->connect_string.length);
oom|= sql->append('\'');
@@ -5589,8 +5590,9 @@ static int init_table_share(THD* thd,
if (create_info->default_table_charset) {
oom|= sql->append(' ');
- oom|= sql->append("CHARSET=");
- oom|= sql->append(create_info->default_table_charset->csname);
+ oom|= sql->append(STRING_WITH_LEN("CHARSET="));
+ oom|= sql->append(create_info->default_table_charset->csname,
+ strlen(create_info->default_table_charset->csname));
if (oom)
return HA_ERR_OUT_OF_MEM;
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index 64a80808d6f..88222f79df8 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -1000,19 +1000,17 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
}
else if (part->key_part_flag & HA_BLOB_PART)
{
- String blob;
uint blob_length= uint2korr(ptr);
- blob.set_quick((char*) ptr+HA_KEY_BLOB_LENGTH,
- blob_length, &my_charset_bin);
+ String blob((char*) ptr+HA_KEY_BLOB_LENGTH,
+ blob_length, &my_charset_bin);
if (to->append_for_single_quote(&blob))
DBUG_RETURN(1);
}
else if (part->key_part_flag & HA_VAR_LENGTH_PART)
{
- String varchar;
uint var_length= uint2korr(ptr);
- varchar.set_quick((char*) ptr+HA_KEY_BLOB_LENGTH,
- var_length, &my_charset_bin);
+ String varchar((char*) ptr+HA_KEY_BLOB_LENGTH,
+ var_length, &my_charset_bin);
if (to->append_for_single_quote(&varchar))
DBUG_RETURN(1);
}
@@ -1392,7 +1390,7 @@ bool ha_federated::create_where_from_key(String *to,
case HA_READ_AFTER_KEY:
if (eq_range_arg)
{
- if (tmp.append("1=1")) // Dummy
+ if (tmp.append(STRING_WITH_LEN("1=1"))) // Dummy
goto err;
break;
}
@@ -2428,7 +2426,7 @@ int ha_federated::index_read_idx_with_result_set(uchar *buf, uint index,
index_string.length(0);
sql_query.length(0);
- sql_query.append(share->select_query);
+ sql_query.append(share->select_query, strlen(share->select_query));
range.key= key;
range.length= key_len;
@@ -2512,7 +2510,7 @@ int ha_federated::read_range_first(const key_range *start_key,
DBUG_ASSERT(!(start_key == NULL && end_key == NULL));
sql_query.length(0);
- sql_query.append(share->select_query);
+ sql_query.append(share->select_query, strlen(share->select_query));
create_where_from_key(&sql_query,
&table->key_info[active_index],
start_key, end_key, 0, eq_range_arg);
@@ -3168,16 +3166,17 @@ int ha_federated::real_connect()
We have established a connection, lets try a simple dummy query just
to check that the table and expected columns are present.
*/
- sql_query.append(share->select_query);
+ sql_query.append(share->select_query, strlen(share->select_query));
sql_query.append(STRING_WITH_LEN(" WHERE 1=0"));
if (mysql_real_query(mysql, sql_query.ptr(), sql_query.length()))
{
sql_query.length(0);
- sql_query.append("error: ");
+ sql_query.append(STRING_WITH_LEN("error: "));
sql_query.qs_append(mysql_errno(mysql));
- sql_query.append(" '");
- sql_query.append(mysql_error(mysql));
- sql_query.append("'");
+ sql_query.append(STRING_WITH_LEN(" '"));
+ const char *errmsg= mysql_error(mysql);
+ sql_query.append(errmsg, strlen(errmsg));
+ sql_query.append('\'');
mysql_close(mysql);
mysql= NULL;
my_error(ER_FOREIGN_DATA_SOURCE_DOESNT_EXIST, MYF(0), sql_query.ptr());
@@ -3242,7 +3241,7 @@ bool ha_federated::get_error_message(int error, String* buf)
buf->append(STRING_WITH_LEN("Error on remote system: "));
buf->qs_append(remote_error_number);
buf->append(STRING_WITH_LEN(": "));
- buf->append(remote_error_buf);
+ buf->append(remote_error_buf, strlen(remote_error_buf));
remote_error_number= 0;
remote_error_buf[0]= '\0';
diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc
index 6d9bcc1b7c9..75856a76c3a 100644
--- a/storage/federatedx/ha_federatedx.cc
+++ b/storage/federatedx/ha_federatedx.cc
@@ -937,19 +937,17 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
}
else if (part->key_part_flag & HA_BLOB_PART)
{
- String blob;
uint blob_length= uint2korr(ptr);
- blob.set_quick((char*) ptr+HA_KEY_BLOB_LENGTH,
- blob_length, &my_charset_bin);
+ String blob((char*) ptr+HA_KEY_BLOB_LENGTH,
+ blob_length, &my_charset_bin);
if (to->append_for_single_quote(&blob))
DBUG_RETURN(1);
}
else if (part->key_part_flag & HA_VAR_LENGTH_PART)
{
- String varchar;
uint var_length= uint2korr(ptr);
- varchar.set_quick((char*) ptr+HA_KEY_BLOB_LENGTH,
- var_length, &my_charset_bin);
+ String varchar((char*) ptr+HA_KEY_BLOB_LENGTH,
+ var_length, &my_charset_bin);
if (to->append_for_single_quote(&varchar))
DBUG_RETURN(1);
}
@@ -1271,14 +1269,18 @@ bool ha_federatedx::create_where_from_key(String *to,
{
if (*ptr++)
{
+ LEX_CSTRING constraint;
+ if (ranges[i]->flag == HA_READ_KEY_EXACT)
+ constraint= {STRING_WITH_LEN(" IS NULL ") };
+ else
+ constraint= {STRING_WITH_LEN(" IS NOT NULL ") };
/*
We got "IS [NOT] NULL" condition against nullable column. We
distinguish between "IS NOT NULL" and "IS NULL" by flag. For
"IS NULL", flag is set to HA_READ_KEY_EXACT.
*/
if (emit_key_part_name(&tmp, key_part) ||
- tmp.append(ranges[i]->flag == HA_READ_KEY_EXACT ?
- " IS NULL " : " IS NOT NULL "))
+ tmp.append(constraint))
goto err;
/*
We need to adjust pointer and length to be prepared for next
@@ -1330,7 +1332,7 @@ bool ha_federatedx::create_where_from_key(String *to,
case HA_READ_AFTER_KEY:
if (eq_range)
{
- if (tmp.append("1=1")) // Dummy
+ if (tmp.append(STRING_WITH_LEN("1=1"))) // Dummy
goto err;
break;
}
@@ -1439,13 +1441,16 @@ static void fill_server(MEM_ROOT *mem_root, FEDERATEDX_SERVER *server,
FEDERATEDX_SHARE *share, CHARSET_INFO *table_charset)
{
char buffer[STRING_BUFFER_USUAL_SIZE];
+ const char *socket_arg= share->socket ? share->socket : "";
+ const char *password_arg= share->password ? share->password : "";
+
String key(buffer, sizeof(buffer), &my_charset_bin);
- String scheme(share->scheme, &my_charset_latin1);
- String hostname(share->hostname, &my_charset_latin1);
- String database(share->database, system_charset_info);
- String username(share->username, system_charset_info);
- String socket(share->socket ? share->socket : "", files_charset_info);
- String password(share->password ? share->password : "", &my_charset_bin);
+ String scheme(share->scheme, strlen(share->scheme), &my_charset_latin1);
+ String hostname(share->hostname, strlen(share->hostname), &my_charset_latin1);
+ String database(share->database, strlen(share->database), system_charset_info);
+ String username(share->username, strlen(share->username), system_charset_info);
+ String socket(socket_arg, strlen(socket_arg), files_charset_info);
+ String password(password_arg, strlen(password_arg), &my_charset_bin);
DBUG_ENTER("fill_server");
/* Do some case conversions */
@@ -1529,13 +1534,16 @@ static FEDERATEDX_SERVER *get_server(FEDERATEDX_SHARE *share, TABLE *table)
FEDERATEDX_SERVER *server= NULL, tmp_server;
MEM_ROOT mem_root;
char buffer[STRING_BUFFER_USUAL_SIZE];
+ const char *socket_arg= share->socket ? share->socket : "";
+ const char *password_arg= share->password ? share->password : "";
+
String key(buffer, sizeof(buffer), &my_charset_bin);
- String scheme(share->scheme, &my_charset_latin1);
- String hostname(share->hostname, &my_charset_latin1);
- String database(share->database, system_charset_info);
- String username(share->username, system_charset_info);
- String socket(share->socket ? share->socket : "", files_charset_info);
- String password(share->password ? share->password : "", &my_charset_bin);
+ String scheme(share->scheme, strlen(share->scheme), &my_charset_latin1);
+ String hostname(share->hostname, strlen(share->hostname), &my_charset_latin1);
+ String database(share->database, strlen(share->database), system_charset_info);
+ String username(share->username, strlen(share->username), system_charset_info);
+ String socket(socket_arg, strlen(socket_arg), files_charset_info);
+ String password(password_arg, strlen(password_arg), &my_charset_bin);
DBUG_ENTER("ha_federated.cc::get_server");
mysql_mutex_assert_owner(&federatedx_mutex);
@@ -1637,13 +1645,14 @@ static FEDERATEDX_SHARE *get_share(const char *table_name, TABLE *table)
if (!(share= (FEDERATEDX_SHARE *) memdup_root(&mem_root, (char*)&tmp_share, sizeof(*share))) ||
!(share->share_key= (char*) memdup_root(&mem_root, tmp_share.share_key, tmp_share.share_key_length+1)) ||
- !(share->select_query= (char*) strmake_root(&mem_root, query.ptr(), query.length())))
+ !(share->select_query.str= (char*) strmake_root(&mem_root, query.ptr(), query.length())))
goto error;
+ share->select_query.length= query.length();
share->mem_root= mem_root;
DBUG_PRINT("info",
- ("share->select_query %s", share->select_query));
+ ("share->select_query %s", share->select_query.str));
if (!(share->s= get_server(share, table)))
goto error;
@@ -2822,8 +2831,7 @@ int ha_federatedx::rnd_init(bool scan)
if (stored_result)
(void) free_result();
- if (io->query(share->select_query,
- strlen(share->select_query)))
+ if (io->query(share->select_query.str, share->select_query.length))
goto error;
stored_result= io->store_result();
@@ -3476,7 +3484,7 @@ bool ha_federatedx::get_error_message(int error, String* buf)
buf->append(STRING_WITH_LEN("Error on remote system: "));
buf->qs_append(remote_error_number);
buf->append(STRING_WITH_LEN(": "));
- buf->append(remote_error_buf);
+ buf->append(remote_error_buf, strlen(remote_error_buf));
/* Ensure string ends with \0 */
(void) buf->c_ptr_safe();
diff --git a/storage/federatedx/ha_federatedx.h b/storage/federatedx/ha_federatedx.h
index 473d3ecd3e2..38eae265edf 100644
--- a/storage/federatedx/ha_federatedx.h
+++ b/storage/federatedx/ha_federatedx.h
@@ -104,7 +104,7 @@ typedef struct st_federatedx_share {
/*
the primary select query to be used in rnd_init
*/
- char *select_query;
+ LEX_CSTRING select_query;
/*
remote host info, parse_url supplies
*/
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 79d32886659..84c81d9f7b3 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -390,9 +390,9 @@ static void init_aria_psi_keys(void)
#define init_aria_psi_keys() /* no-op */
#endif /* HAVE_PSI_INTERFACE */
-const char *MA_CHECK_INFO= "info";
-const char *MA_CHECK_WARNING= "warning";
-const char *MA_CHECK_ERROR= "error";
+const LEX_CSTRING MA_CHECK_INFO= { STRING_WITH_LEN("info") };
+const LEX_CSTRING MA_CHECK_WARNING= { STRING_WITH_LEN("warning") };
+const LEX_CSTRING MA_CHECK_ERROR= { STRING_WITH_LEN("error") };
/*****************************************************************************
** MARIA tables
@@ -406,13 +406,13 @@ static handler *maria_create_handler(handlerton *hton,
}
-static void _ma_check_print(HA_CHECK *param, const char* msg_type,
+static void _ma_check_print(HA_CHECK *param, const LEX_CSTRING *msg_type,
const char *msgbuf)
{
- if (msg_type == MA_CHECK_INFO)
+ if (msg_type == &MA_CHECK_INFO)
sql_print_information("%s.%s: %s", param->db_name, param->table_name,
msgbuf);
- else if (msg_type == MA_CHECK_WARNING)
+ else if (msg_type == &MA_CHECK_WARNING)
sql_print_warning("%s.%s: %s", param->db_name, param->table_name,
msgbuf);
else
@@ -422,7 +422,7 @@ static void _ma_check_print(HA_CHECK *param, const char* msg_type,
// collect errors printed by maria_check routines
-static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
+static void _ma_check_print_msg(HA_CHECK *param, const LEX_CSTRING *msg_type,
const char *fmt, va_list args)
{
THD *thd= (THD *) param->thd;
@@ -437,7 +437,7 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
msg_length= my_vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
msgbuf[sizeof(msgbuf) - 1]= 0; // healthy paranoia
- DBUG_PRINT(msg_type, ("message: %s", msgbuf));
+ DBUG_PRINT(msg_type->str, ("message: %s", msgbuf));
if (!thd->vio_ok())
{
@@ -449,9 +449,9 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
(T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | T_AUTO_REPAIR))
{
myf flag= 0;
- if (msg_type == MA_CHECK_INFO)
+ if (msg_type == &MA_CHECK_INFO)
flag= ME_NOTE;
- else if (msg_type == MA_CHECK_WARNING)
+ else if (msg_type == &MA_CHECK_WARNING)
flag= ME_WARNING;
my_message(ER_NOT_KEYFILE, msgbuf, MYF(flag));
if (thd->variables.log_warnings > 2)
@@ -470,9 +470,9 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
*/
protocol->prepare_for_resend();
protocol->store(name, (uint)length, system_charset_info);
- protocol->store(param->op_name, system_charset_info);
+ protocol->store(param->op_name, strlen(param->op_name), system_charset_info);
protocol->store(msg_type, system_charset_info);
- protocol->store(msgbuf, (uint)msg_length, system_charset_info);
+ protocol->store(msgbuf, msg_length, system_charset_info);
if (protocol->write())
sql_print_error("Failed on my_net_write, writing to stderr instead: %s.%s: %s\n",
param->db_name, param->table_name, msgbuf);
@@ -910,7 +910,7 @@ void _ma_check_print_error(HA_CHECK *param, const char *fmt, ...)
if (param->testflag & T_SUPPRESS_ERR_HANDLING)
DBUG_VOID_RETURN;
va_start(args, fmt);
- _ma_check_print_msg(param, MA_CHECK_ERROR, fmt, args);
+ _ma_check_print_msg(param, &MA_CHECK_ERROR, fmt, args);
va_end(args);
DBUG_VOID_RETURN;
}
@@ -921,7 +921,7 @@ void _ma_check_print_info(HA_CHECK *param, const char *fmt, ...)
va_list args;
DBUG_ENTER("_ma_check_print_info");
va_start(args, fmt);
- _ma_check_print_msg(param, MA_CHECK_INFO, fmt, args);
+ _ma_check_print_msg(param, &MA_CHECK_INFO, fmt, args);
va_end(args);
DBUG_VOID_RETURN;
}
@@ -934,7 +934,7 @@ void _ma_check_print_warning(HA_CHECK *param, const char *fmt, ...)
param->warning_printed++;
param->out_flag |= O_DATA_LOST;
va_start(args, fmt);
- _ma_check_print_msg(param, MA_CHECK_WARNING, fmt, args);
+ _ma_check_print_msg(param, &MA_CHECK_WARNING, fmt, args);
va_end(args);
DBUG_VOID_RETURN;
}
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 23a0adcaf2a..2a49971f6db 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -96,9 +96,9 @@ static MYSQL_THDVAR_ENUM(stats_method, PLUGIN_VAR_RQCMDARG,
"and NULLS_IGNORED", NULL, NULL,
MI_STATS_METHOD_NULLS_NOT_EQUAL, &myisam_stats_method_typelib);
-const char *MI_CHECK_INFO= "info";
-const char *MI_CHECK_WARNING= "warning";
-const char *MI_CHECK_ERROR= "error";
+const LEX_CSTRING MI_CHECK_INFO= { STRING_WITH_LEN("info") };
+const LEX_CSTRING MI_CHECK_WARNING= { STRING_WITH_LEN("warning") };
+const LEX_CSTRING MI_CHECK_ERROR= { STRING_WITH_LEN("error") };
#ifndef DBUG_OFF
/**
@@ -135,13 +135,13 @@ static handler *myisam_create_handler(handlerton *hton,
}
-static void mi_check_print(HA_CHECK *param, const char* msg_type,
+static void mi_check_print(HA_CHECK *param, const LEX_CSTRING* msg_type,
const char *msgbuf)
{
- if (msg_type == MI_CHECK_INFO)
+ if (msg_type == &MI_CHECK_INFO)
sql_print_information("%s.%s: %s", param->db_name, param->table_name,
msgbuf);
- else if (msg_type == MI_CHECK_WARNING)
+ else if (msg_type == &MI_CHECK_WARNING)
sql_print_warning("%s.%s: %s", param->db_name, param->table_name,
msgbuf);
else
@@ -150,7 +150,7 @@ static void mi_check_print(HA_CHECK *param, const char* msg_type,
// collect errors printed by mi_check routines
-static void mi_check_print_msg(HA_CHECK *param, const char* msg_type,
+static void mi_check_print_msg(HA_CHECK *param, const LEX_CSTRING *msg_type,
const char *fmt, va_list args)
{
THD* thd = (THD*)param->thd;
@@ -165,7 +165,7 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type,
msg_length= my_vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
msgbuf[sizeof(msgbuf) - 1] = 0; // healthy paranoia
- DBUG_PRINT(msg_type,("message: %s",msgbuf));
+ DBUG_PRINT(msg_type->str,("message: %s",msgbuf));
if (!thd->vio_ok())
{
@@ -177,9 +177,9 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type,
T_AUTO_REPAIR))
{
myf flag= 0;
- if (msg_type == MI_CHECK_INFO)
+ if (msg_type == &MI_CHECK_INFO)
flag= ME_NOTE;
- else if (msg_type == MI_CHECK_WARNING)
+ else if (msg_type == &MI_CHECK_WARNING)
flag= ME_WARNING;
my_message(ER_NOT_KEYFILE, msgbuf, MYF(flag));
if (thd->variables.log_warnings > 2 && ! thd->log_all_errors)
@@ -201,7 +201,7 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type,
protocol->prepare_for_resend();
protocol->store(name, length, system_charset_info);
- protocol->store(param->op_name, system_charset_info);
+ protocol->store(param->op_name, strlen(param->op_name), system_charset_info);
protocol->store(msg_type, system_charset_info);
protocol->store(msgbuf, msg_length, system_charset_info);
if (protocol->write())
@@ -615,7 +615,7 @@ void mi_check_print_error(HA_CHECK *param, const char *fmt,...)
return;
va_list args;
va_start(args, fmt);
- mi_check_print_msg(param, MI_CHECK_ERROR, fmt, args);
+ mi_check_print_msg(param, &MI_CHECK_ERROR, fmt, args);
va_end(args);
}
@@ -623,7 +623,7 @@ void mi_check_print_info(HA_CHECK *param, const char *fmt,...)
{
va_list args;
va_start(args, fmt);
- mi_check_print_msg(param, MI_CHECK_INFO, fmt, args);
+ mi_check_print_msg(param, &MI_CHECK_INFO, fmt, args);
param->note_printed= 1;
va_end(args);
}
@@ -634,7 +634,7 @@ void mi_check_print_warning(HA_CHECK *param, const char *fmt,...)
param->out_flag|= O_DATA_LOST;
va_list args;
va_start(args, fmt);
- mi_check_print_msg(param, MI_CHECK_WARNING, fmt, args);
+ mi_check_print_msg(param, &MI_CHECK_WARNING, fmt, args);
va_end(args);
}
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 2a7ca8d51f8..70a4d6aa284 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -1593,8 +1593,10 @@ void ha_myisammrg::append_create_info(String *packet)
if (file->merge_insert_method != MERGE_INSERT_DISABLED)
{
+ const char *type;
packet->append(STRING_WITH_LEN(" INSERT_METHOD="));
- packet->append(get_type(&merge_insert_method,file->merge_insert_method-1));
+ type= get_type(&merge_insert_method,file->merge_insert_method-1);
+ packet->append(type, strlen(type));
}
/*
There is no sence adding UNION clause in case there is no underlying
diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc
index 79cec499a77..c2f52e2e5a2 100644
--- a/storage/oqgraph/ha_oqgraph.cc
+++ b/storage/oqgraph/ha_oqgraph.cc
@@ -149,12 +149,13 @@ static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table,
" KEY (latch, destid, origid) USING HASH "\
" ) "
-#define append_opt(NAME,VAL) \
- if (share->option_struct->VAL) \
- { \
- sql.append(STRING_WITH_LEN(" " NAME "='")); \
- sql.append_for_single_quote(share->option_struct->VAL); \
- sql.append('\''); \
+#define append_opt(NAME,VAL) \
+ if (share->option_struct->VAL) \
+ { \
+ const char *val= share->option_struct->VAL; \
+ sql.append(STRING_WITH_LEN(" " NAME "='")); \
+ sql.append_for_single_quote(val, strlen(val)); \
+ sql.append('\''); \
}
int oqgraph_discover_table_structure(handlerton *hton, THD* thd,
@@ -162,7 +163,6 @@ int oqgraph_discover_table_structure(handlerton *hton, THD* thd,
{
StringBuffer<1024> sql(system_charset_info);
sql.copy(STRING_WITH_LEN(OQGRAPH_CREATE_TABLE), system_charset_info);
-
append_opt("data_table", table_name);
append_opt("origid", origid);
append_opt("destid", destid);
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index c0b87871f47..18101aa9bab 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -2278,14 +2278,14 @@ String timeout_message(const char *command, const char *name1,
const char *name2)
{
String msg;
- msg.append("Timeout on ");
- msg.append(command);
- msg.append(": ");
- msg.append(name1);
+ msg.append(STRING_WITH_LEN("Timeout on "));
+ msg.append(command, strlen(command));
+ msg.append(STRING_WITH_LEN(": "));
+ msg.append(name1, strlen(name1));
if (name2 && name2[0])
{
- msg.append(".");
- msg.append(name2);
+ msg.append('.');
+ msg.append(name2, strlen(name2));
}
return msg;
}
@@ -2473,7 +2473,8 @@ protected:
"Query: %s",
user_host_buff, thd->query());
}
- m_detailed_error = String(" (snapshot conflict)", system_charset_info);
+ m_detailed_error = String(STRING_WITH_LEN(" (snapshot conflict)"),
+ system_charset_info);
table_handler->m_deadlock_counter.inc();
return HA_ERR_ROCKSDB_STATUS_BUSY;
}
@@ -6908,7 +6909,8 @@ bool ha_rocksdb::get_error_message(const int error, String *const buf) {
}
if (error >= HA_ERR_ROCKSDB_FIRST && error <= HA_ERR_ROCKSDB_LAST) {
- buf->append(rdb_error_messages[error - HA_ERR_ROCKSDB_FIRST]);
+ const char *msg= rdb_error_messages[error - HA_ERR_ROCKSDB_FIRST];
+ buf->append(msg, strlen(msg));
}
// We can be called with the values which are < HA_ERR_FIRST because most
diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc
index 5f46fd8acad..6c61cbfb728 100644
--- a/storage/rocksdb/rdb_datadic.cc
+++ b/storage/rocksdb/rdb_datadic.cc
@@ -3780,10 +3780,10 @@ bool Rdb_validate_tbls::check_frm_file(const std::string &fullpath,
const std::string &tablename,
bool *has_errors) {
/* Check this .frm file to see what engine it uses */
- String fullfilename(fullpath.c_str(), &my_charset_bin);
- fullfilename.append(FN_DIRSEP);
- fullfilename.append(tablename.c_str());
- fullfilename.append(".frm");
+ String fullfilename(fullpath.data(), fullpath.length(), &my_charset_bin);
+ fullfilename.append(STRING_WITH_LEN(FN_DIRSEP));
+ fullfilename.append(tablename.data(), tablename.length());
+ fullfilename.append(STRING_WITH_LEN(".frm"));
/*
This function will return the legacy_db_type of the table. Currently
diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc
index 0ca08bc3c47..e2f1909e8e2 100644
--- a/storage/sphinx/ha_sphinx.cc
+++ b/storage/sphinx/ha_sphinx.cc
@@ -2325,30 +2325,32 @@ int ha_sphinx::write_row ( const byte * )
// SphinxQL inserts only, pretty much similar to abandoned federated
char sQueryBuf[1024];
char sValueBuf[1024];
-
String sQuery ( sQueryBuf, sizeof(sQueryBuf), &my_charset_bin );
String sValue ( sValueBuf, sizeof(sQueryBuf), &my_charset_bin );
+ const char *query;
sQuery.length ( 0 );
sValue.length ( 0 );
CSphSEThreadTable * pTable = GetTls ();
- sQuery.append ( pTable && pTable->m_bReplace ? "REPLACE INTO " : "INSERT INTO " );
- sQuery.append ( m_pShare->m_sIndex );
- sQuery.append ( " (" );
+ query= pTable && pTable->m_bReplace ? "REPLACE INTO " : "INSERT INTO ";
+ sQuery.append (query, strlen(query));
+ sQuery.append ( m_pShare->m_sIndex, strlen(m_pShare->m_sIndex ));
+ sQuery.append (STRING_WITH_LEN(" (" ));
for ( Field ** ppField = table->field; *ppField; ppField++ )
{
- sQuery.append ( (*ppField)->field_name.str );
+ sQuery.append ( (*ppField)->field_name.str,
+ strlen((*ppField)->field_name.str));
if ( ppField[1] )
- sQuery.append ( ", " );
+ sQuery.append (STRING_WITH_LEN(", "));
}
- sQuery.append ( ") VALUES (" );
+ sQuery.append (STRING_WITH_LEN( ") VALUES (" ));
for ( Field ** ppField = table->field; *ppField; ppField++ )
{
if ( (*ppField)->is_null() )
{
- sQuery.append ( "''" );
+ sQuery.append (STRING_WITH_LEN( "''" ));
} else
{
@@ -2360,23 +2362,23 @@ int ha_sphinx::write_row ( const byte * )
pConv->quick_fix_field();
unsigned int uTs = (unsigned int) pConv->val_int();
- snprintf ( sValueBuf, sizeof(sValueBuf), "'%u'", uTs );
- sQuery.append ( sValueBuf );
+ uint len= my_snprintf ( sValueBuf, sizeof(sValueBuf), "'%u'", uTs );
+ sQuery.append ( sValueBuf, len );
} else
{
(*ppField)->val_str ( &sValue );
- sQuery.append ( "'" );
+ sQuery.append ( '\'' );
sValue.print ( &sQuery );
- sQuery.append ( "'" );
+ sQuery.append ( '\'' );
sValue.length(0);
}
}
if ( ppField[1] )
- sQuery.append ( ", " );
+ sQuery.append (STRING_WITH_LEN(", "));
}
- sQuery.append ( ")" );
+ sQuery.append ( ')' );
// FIXME? pretty inefficient to reconnect every time under high load,
// but this was intentionally written for a low load scenario..
@@ -2432,13 +2434,14 @@ int ha_sphinx::delete_row ( const byte * )
String sQuery ( sQueryBuf, sizeof(sQueryBuf), &my_charset_bin );
sQuery.length ( 0 );
- sQuery.append ( "DELETE FROM " );
- sQuery.append ( m_pShare->m_sIndex );
- sQuery.append ( " WHERE id=" );
+ sQuery.append (STRING_WITH_LEN( "DELETE FROM " ));
+ sQuery.append ( m_pShare->m_sIndex, strlen(m_pShare->m_sIndex));
+ sQuery.append (STRING_WITH_LEN( " WHERE id=" ));
char sValue[32];
- snprintf ( sValue, sizeof(sValue), "%lld", table->field[0]->val_int() );
- sQuery.append ( sValue );
+ uint length= my_snprintf ( sValue, sizeof(sValue), "%lld",
+ table->field[0]->val_int() );
+ sQuery.append ( sValue, length );
// FIXME? pretty inefficient to reconnect every time under high load,
// but this was intentionally written for a low load scenario..
diff --git a/storage/spider/hs_client/config.hpp b/storage/spider/hs_client/config.hpp
index 2880f2f5a33..6d85c7e3d7c 100644
--- a/storage/spider/hs_client/config.hpp
+++ b/storage/spider/hs_client/config.hpp
@@ -60,7 +60,7 @@ struct config {
conf_param *find(const String& key) const;
conf_param *find(const char *key) const;
String get_str(const String& key, const String& def =
- String("", &my_charset_bin)) const;
+ String("", 0, &my_charset_bin)) const;
String get_str(const char *key, const char *def = "") const;
long long get_int(const String& key, long long def = 0) const;
long long get_int(const char *key, long long def = 0) const;
diff --git a/storage/spider/hs_client/hstcpcli.cpp b/storage/spider/hs_client/hstcpcli.cpp
index 4c93b5a3a49..b3dea208f8f 100644
--- a/storage/spider/hs_client/hstcpcli.cpp
+++ b/storage/spider/hs_client/hstcpcli.cpp
@@ -196,9 +196,9 @@ hstcpcli::read_more()
errno = 0;
continue;
}
- error_str = String("read: failed", &my_charset_bin);
+ error_str = String(STRING_WITH_LEN("read: failed"), &my_charset_bin);
} else {
- error_str = String("read: eof", &my_charset_bin);
+ error_str = String(STRING_WITH_LEN("read: eof"), &my_charset_bin);
}
return rlen;
}
@@ -503,7 +503,7 @@ hstcpcli::response_recv(size_t& num_flds_r)
char *const err_end = start;
String e = String(err_begin, (uint32)(err_end - err_begin), &my_charset_bin);
if (!e.length()) {
- e = String("unknown_error", &my_charset_bin);
+ e = String(STRING_WITH_LEN("unknown_error"), &my_charset_bin);
}
return set_error(resp_code, e);
}
diff --git a/storage/spider/hs_client/socket.cpp b/storage/spider/hs_client/socket.cpp
index 45b8100e64c..e4541ce7273 100644
--- a/storage/spider/hs_client/socket.cpp
+++ b/storage/spider/hs_client/socket.cpp
@@ -63,7 +63,8 @@ socket_args::set(const config& conf)
} else {
const char *nd = !node.length() ? 0 : node.c_ptr();
if (resolve(nd, port.c_ptr()) != 0) {
- String message("getaddrinfo failed: ", &my_charset_bin);
+ String message(STRING_WITH_LEN("getaddrinfo failed: "),
+ &my_charset_bin);
message.reserve(node.length() + sizeof(":") - 1 + port.length());
message.append(node);
message.q_append(":", sizeof(":") - 1);
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index 2305173ab00..ea7714f2002 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -9694,8 +9694,8 @@ int spider_db_open_item_cond(
int error_num = 0;
List_iterator_fast<Item> lif(*(item_cond->argument_list()));
Item *item;
- char *func_name = NULL;
- int func_name_length = 0, restart_pos = 0;
+ LEX_CSTRING func_name= {0,0};
+ int restart_pos = 0;
DBUG_ENTER("spider_db_open_item_cond");
if (str)
{
@@ -9731,15 +9731,13 @@ restart_first:
if (str)
{
restart_pos = str->length();
- if (!func_name)
- {
- func_name = (char*) item_cond->func_name();
- func_name_length = strlen(func_name);
- }
- if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN * 2))
+ if (!func_name.str)
+ func_name= item_cond->func_name_cstring();
+
+ if (str->reserve(func_name.length + SPIDER_SQL_SPACE_LEN * 2))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN);
- str->q_append(func_name, func_name_length);
+ str->q_append(func_name.str, func_name.length);
str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN);
}
diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc
index edc9ee33477..030201e61ae 100644
--- a/storage/spider/spd_db_handlersocket.cc
+++ b/storage/spider/spd_db_handlersocket.cc
@@ -2877,6 +2877,7 @@ int spider_db_handlersocket_util::open_item_func(
int error_num;
Item *item, **item_list = item_func->arguments();
uint roop_count, item_count = item_func->argument_count(), start_item = 0;
+ LEX_CSTRING func_name_c;
const char *func_name = SPIDER_SQL_NULL_CHAR_STR,
*separator_str = SPIDER_SQL_NULL_CHAR_STR,
*last_str = SPIDER_SQL_NULL_CHAR_STR;
@@ -2904,8 +2905,9 @@ int spider_db_handlersocket_util::open_item_func(
last_str_length = SPIDER_SQL_IS_NOT_NULL_LEN;
break;
case Item_func::UNKNOWN_FUNC:
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.length;
DBUG_PRINT("info",("spider func_name = %s", func_name));
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
if (func_name_length == 1 &&
@@ -3104,11 +3106,13 @@ int spider_db_handlersocket_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3142,11 +3146,13 @@ int spider_db_handlersocket_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3276,11 +3282,13 @@ int spider_db_handlersocket_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3330,11 +3338,13 @@ int spider_db_handlersocket_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3371,11 +3381,13 @@ int spider_db_handlersocket_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3410,11 +3422,13 @@ int spider_db_handlersocket_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3465,11 +3479,13 @@ int spider_db_handlersocket_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3564,11 +3580,13 @@ int spider_db_handlersocket_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3654,8 +3672,9 @@ int spider_db_handlersocket_util::open_item_func(
}
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.length;
if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(func_name, func_name_length);
@@ -3665,8 +3684,9 @@ int spider_db_handlersocket_util::open_item_func(
case Item_func::NEG_FUNC:
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.length;
if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(func_name, func_name_length);
@@ -3699,8 +3719,9 @@ int spider_db_handlersocket_util::open_item_func(
separator_str = SPIDER_SQL_AND_STR;
separator_str_length = SPIDER_SQL_AND_LEN;
} else {
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.length;
separator_str = SPIDER_SQL_AND_STR;
separator_str_length = SPIDER_SQL_AND_LEN;
}
@@ -3712,8 +3733,9 @@ int spider_db_handlersocket_util::open_item_func(
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.length;
DBUG_PRINT("info",("spider func_name = %s", func_name));
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN))
@@ -3791,8 +3813,9 @@ int spider_db_handlersocket_util::open_item_func(
case Item_func::SP_OVERLAPS_FUNC:
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.length;
DBUG_PRINT("info",("spider func_name = %s", func_name));
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
if (str->reserve(
@@ -3824,8 +3847,9 @@ int spider_db_handlersocket_util::open_item_func(
case Item_func::LIKE_FUNC:
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.length;
}
break;
default:
@@ -3836,8 +3860,9 @@ int spider_db_handlersocket_util::open_item_func(
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.length;
}
break;
}
@@ -3958,8 +3983,9 @@ int spider_db_handlersocket_util::open_item_sum_func(
case Item_sum::MIN_FUNC:
case Item_sum::MAX_FUNC:
{
- const char *func_name = item_sum->func_name();
- uint func_name_length = strlen(func_name);
+ LEX_CSTRING func_name_c = item_sum->func_name_cstring();
+ const char *func_name = func_name_c.str;
+ uint func_name_length = func_name_c.length;
Item *item, **args = item_sum->get_args();
if (str)
{
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index 6821e36e445..5b257444bfc 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -3825,13 +3825,14 @@ size_t spider_db_mbase::escape_string(
const char *from,
size_t from_length
) {
+ my_bool overflow;
DBUG_ENTER("spider_db_mbase::escape_string");
DBUG_PRINT("info",("spider this=%p", this));
if (db_conn->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)
DBUG_RETURN(escape_quotes_for_mysql(db_conn->charset, to, 0,
- from, from_length));
+ from, from_length, &overflow));
DBUG_RETURN(escape_string_for_mysql(db_conn->charset, to, 0,
- from, from_length));
+ from, from_length, &overflow));
}
bool spider_db_mbase::have_lock_table_list()
@@ -5799,6 +5800,8 @@ int spider_db_mbase_util::open_item_func(
Item *item, **item_list = item_func->arguments();
Field *field;
uint roop_count, item_count = item_func->argument_count(), start_item = 0;
+ LEX_CSTRING org_func_name= {SPIDER_SQL_NULL_CHAR_STR,
+ SPIDER_SQL_NULL_CHAR_LEN};
const char *func_name = SPIDER_SQL_NULL_CHAR_STR,
*separator_str = SPIDER_SQL_NULL_CHAR_STR,
*last_str = SPIDER_SQL_NULL_CHAR_STR;
@@ -5826,8 +5829,9 @@ int spider_db_mbase_util::open_item_func(
last_str_length = SPIDER_SQL_IS_NOT_NULL_LEN;
break;
case Item_func::UNKNOWN_FUNC:
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ org_func_name= item_func->func_name_cstring();
+ func_name= org_func_name.str;
+ func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider func_name = %s", func_name));
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
if (func_name_length == 1 &&
@@ -6028,9 +6032,10 @@ int spider_db_mbase_util::open_item_func(
{
const char *child_func_name;
int child_func_name_length;
+ LEX_CSTRING org_func_name= ifunc->func_name_cstring();
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name = org_func_name.str;
+ child_func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -6066,9 +6071,10 @@ int spider_db_mbase_util::open_item_func(
{
const char *child_func_name;
int child_func_name_length;
+ LEX_CSTRING org_func_name= ifunc->func_name_cstring();
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name = org_func_name.str;
+ child_func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -6200,9 +6206,10 @@ int spider_db_mbase_util::open_item_func(
{
const char *child_func_name;
int child_func_name_length;
+ LEX_CSTRING org_func_name= ifunc->func_name_cstring();
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name = org_func_name.str;
+ child_func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -6254,9 +6261,10 @@ int spider_db_mbase_util::open_item_func(
{
const char *child_func_name;
int child_func_name_length;
+ LEX_CSTRING org_func_name= ifunc->func_name_cstring();
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name = org_func_name.str;
+ child_func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -6295,9 +6303,10 @@ int spider_db_mbase_util::open_item_func(
{
const char *child_func_name;
int child_func_name_length;
+ LEX_CSTRING org_func_name= ifunc->func_name_cstring();
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name = org_func_name.str;
+ child_func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -6334,9 +6343,10 @@ int spider_db_mbase_util::open_item_func(
{
const char *child_func_name;
int child_func_name_length;
+ LEX_CSTRING org_func_name= ifunc->func_name_cstring();
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name = org_func_name.str;
+ child_func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -6389,9 +6399,10 @@ int spider_db_mbase_util::open_item_func(
{
const char *child_func_name;
int child_func_name_length;
+ LEX_CSTRING org_func_name= ifunc->func_name_cstring();
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name = org_func_name.str;
+ child_func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -6488,9 +6499,10 @@ int spider_db_mbase_util::open_item_func(
{
const char *child_func_name;
int child_func_name_length;
+ LEX_CSTRING org_func_name= ifunc->func_name_cstring();
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name = org_func_name.str;
+ child_func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -6576,8 +6588,9 @@ int spider_db_mbase_util::open_item_func(
}
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ LEX_CSTRING org_func_name= item_func->func_name_cstring();
+ func_name = org_func_name.str;
+ func_name_length = org_func_name.length;
if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(func_name, func_name_length);
@@ -6587,8 +6600,9 @@ int spider_db_mbase_util::open_item_func(
case Item_func::NEG_FUNC:
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ LEX_CSTRING org_func_name= item_func->func_name_cstring();
+ func_name = org_func_name.str;
+ func_name_length = org_func_name.length;
if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(func_name, func_name_length);
@@ -6621,8 +6635,9 @@ int spider_db_mbase_util::open_item_func(
separator_str = SPIDER_SQL_AND_STR;
separator_str_length = SPIDER_SQL_AND_LEN;
} else {
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ LEX_CSTRING org_func_name= item_func->func_name_cstring();
+ func_name = org_func_name.str;
+ func_name_length = org_func_name.length;
separator_str = SPIDER_SQL_AND_STR;
separator_str_length = SPIDER_SQL_AND_LEN;
}
@@ -6635,8 +6650,9 @@ int spider_db_mbase_util::open_item_func(
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ LEX_CSTRING org_func_name= item_func->func_name_cstring();
+ func_name = org_func_name.str;
+ func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider func_name = %s", func_name));
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN))
@@ -6714,8 +6730,9 @@ int spider_db_mbase_util::open_item_func(
case Item_func::SP_OVERLAPS_FUNC:
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ LEX_CSTRING org_func_name= item_func->func_name_cstring();
+ func_name = org_func_name.str;
+ func_name_length = org_func_name.length;
DBUG_PRINT("info",("spider func_name = %s", func_name));
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
if (str->reserve(
@@ -6746,8 +6763,9 @@ int spider_db_mbase_util::open_item_func(
case Item_func::GT_FUNC:
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ LEX_CSTRING org_func_name= item_func->func_name_cstring();
+ func_name = org_func_name.str;
+ func_name_length = org_func_name.length;
}
break;
case Item_func::LIKE_FUNC:
@@ -6761,8 +6779,9 @@ int spider_db_mbase_util::open_item_func(
}
else
{
- func_name = (char*)item_func->func_name();
- func_name_length = strlen(func_name);
+ LEX_CSTRING org_func_name= item_func->func_name_cstring();
+ func_name = org_func_name.str;
+ func_name_length = org_func_name.length;
}
}
break;
@@ -6777,8 +6796,9 @@ int spider_db_mbase_util::open_item_func(
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ LEX_CSTRING org_func_name= item_func->func_name_cstring();
+ func_name = org_func_name.str;
+ func_name_length = org_func_name.length;
}
break;
}
@@ -6911,8 +6931,9 @@ int spider_db_mbase_util::open_item_sum_func(
case Item_sum::MIN_FUNC:
case Item_sum::MAX_FUNC:
{
- const char *func_name = item_sum->func_name();
- uint func_name_length = strlen(func_name);
+ LEX_CSTRING org_func_name= item_sum->func_name_cstring();
+ const char *func_name = org_func_name.str;
+ uint func_name_length = org_func_name.length;
Item *item, **args = item_sum->get_args();
if (str)
{
@@ -6957,8 +6978,9 @@ int spider_db_mbase_util::open_item_sum_func(
{
if (!use_fields)
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
- const char *func_name = item_sum->func_name();
- uint func_name_length = strlen(func_name);
+ LEX_CSTRING org_func_name= item_sum->func_name_cstring();
+ const char *func_name = org_func_name.str;
+ uint func_name_length = org_func_name.length;
Item *item, **args = item_sum->get_args();
if (str)
{
diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc
index 92b4556a198..77d3c808b70 100644
--- a/storage/spider/spd_db_oracle.cc
+++ b/storage/spider/spd_db_oracle.cc
@@ -3124,6 +3124,7 @@ int spider_db_oracle_util::open_item_func(
int error_num;
Item *item, **item_list = item_func->arguments();
Field *field;
+ LEX_CSTRING func_name_c;
uint roop_count, item_count = item_func->argument_count(), start_item = 0;
const char *func_name = SPIDER_SQL_NULL_CHAR_STR,
*separator_str = SPIDER_SQL_NULL_CHAR_STR,
@@ -3152,8 +3153,9 @@ int spider_db_oracle_util::open_item_func(
last_str_length = SPIDER_SQL_IS_NOT_NULL_LEN;
break;
case Item_func::UNKNOWN_FUNC:
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.lengthstr;
DBUG_PRINT("info",("spider func_name = %s", func_name));
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
if (func_name_length == 1 &&
@@ -3352,11 +3354,13 @@ int spider_db_oracle_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3390,11 +3394,13 @@ int spider_db_oracle_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3524,11 +3530,13 @@ int spider_db_oracle_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3578,11 +3586,13 @@ int spider_db_oracle_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3619,11 +3629,13 @@ int spider_db_oracle_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3658,11 +3670,13 @@ int spider_db_oracle_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3713,11 +3727,13 @@ int spider_db_oracle_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -3948,11 +3964,13 @@ int spider_db_oracle_util::open_item_func(
Item_func *ifunc = (Item_func *) item;
if (ifunc->functype() == Item_func::UNKNOWN_FUNC)
{
+ LEX_CSTRING child_func_name_c;
const char *child_func_name;
int child_func_name_length;
DBUG_PRINT("info",("spider child is UNKNOWN_FUNC"));
- child_func_name = (char*) ifunc->func_name();
- child_func_name_length = strlen(child_func_name);
+ child_func_name_c = ifunc->func_name_cstring();
+ child_func_name = child_func_name_c.str;
+ child_func_name_length = child_func_name_c.length;
DBUG_PRINT("info",("spider child func_name is %s", child_func_name));
if (
child_func_name_length == 10 &&
@@ -4038,8 +4056,9 @@ int spider_db_oracle_util::open_item_func(
}
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.lengthstr;
if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(func_name, func_name_length);
@@ -4049,8 +4068,9 @@ int spider_db_oracle_util::open_item_func(
case Item_func::NEG_FUNC:
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.lengthstr;
if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(func_name, func_name_length);
@@ -4083,8 +4103,9 @@ int spider_db_oracle_util::open_item_func(
separator_str = SPIDER_SQL_AND_STR;
separator_str_length = SPIDER_SQL_AND_LEN;
} else {
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.lengthstr;
separator_str = SPIDER_SQL_AND_STR;
separator_str_length = SPIDER_SQL_AND_LEN;
}
@@ -4097,8 +4118,9 @@ int spider_db_oracle_util::open_item_func(
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.lengthstr;
DBUG_PRINT("info",("spider func_name = %s", func_name));
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN))
@@ -4176,8 +4198,9 @@ int spider_db_oracle_util::open_item_func(
case Item_func::SP_OVERLAPS_FUNC:
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.lengthstr;
DBUG_PRINT("info",("spider func_name = %s", func_name));
DBUG_PRINT("info",("spider func_name_length = %d", func_name_length));
if (str->reserve(
@@ -4208,8 +4231,9 @@ int spider_db_oracle_util::open_item_func(
case Item_func::GT_FUNC:
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.lengthstr;
}
break;
case Item_func::LIKE_FUNC:
@@ -4223,8 +4247,9 @@ int spider_db_oracle_util::open_item_func(
}
else
{
- func_name = (char*)item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.lengthstr;
}
}
break;
@@ -4239,8 +4264,9 @@ int spider_db_oracle_util::open_item_func(
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
if (str)
{
- func_name = (char*) item_func->func_name();
- func_name_length = strlen(func_name);
+ func_name_c = item_func->func_name_cstring();
+ func_name = func_name_c.str;
+ func_name_length = func_name_c.lengthstr;
}
break;
}
@@ -4366,8 +4392,9 @@ int spider_db_oracle_util::open_item_sum_func(
case Item_sum::MIN_FUNC:
case Item_sum::MAX_FUNC:
{
- const char *func_name = item_sum->func_name();
- uint func_name_length = strlen(func_name);
+ LEX_CSTRING func_name_c= item_sum->func_name_cstring();
+ const char *func_name = func_name_c.str;
+ uint func_name_length = func_name_c.length;
Item *item, **args = item_sum->get_args();
if (str)
{
@@ -4427,10 +4454,11 @@ size_t spider_db_oracle_util::escape_string(
size_t from_length,
CHARSET_INFO *access_charset
) {
+ my_bool overflow;
DBUG_ENTER("spider_db_oracle::escape_string");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(escape_quotes_for_mysql(access_charset, to, 0,
- from, from_length));
+ from, from_length, &overflow));
}
int spider_db_oracle_util::append_escaped_util(
diff --git a/storage/spider/spd_malloc.cc b/storage/spider/spd_malloc.cc
index d16574c6ac2..8a99e648afc 100644
--- a/storage/spider/spd_malloc.cc
+++ b/storage/spider/spd_malloc.cc
@@ -292,7 +292,7 @@ spider_string::spider_string(
spider_string::spider_string(
const char *str,
CHARSET_INFO *cs
-) : str(str, cs), next(NULL)
+) : str(str, strlen(str), cs), next(NULL)
{
DBUG_ENTER("spider_string::spider_string");
DBUG_PRINT("info",("spider this=%p", this));
@@ -853,7 +853,7 @@ bool spider_string::append(
DBUG_ASSERT(mem_calc_inited);
DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) ||
current_alloc_mem == str.alloced_length());
- bool res = str.append(s);
+ bool res = str.append(s, strlen(s));
SPIDER_STRING_CALC_MEM;
DBUG_RETURN(res);
}
@@ -1216,13 +1216,15 @@ void spider_string::append_escape_string(
const char *st,
uint len
) {
+ my_bool overflow;
DBUG_ENTER("spider_string::append_escape_string");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(mem_calc_inited);
DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) ||
current_alloc_mem == str.alloced_length());
str.length(str.length() + escape_string_for_mysql(
- str.charset(), (char *) str.ptr() + str.length(), 0, st, len));
+ str.charset(), (char *) str.ptr() + str.length(), 0, st, len,
+ &overflow));
DBUG_VOID_RETURN;
}
@@ -1231,13 +1233,14 @@ void spider_string::append_escape_string(
uint len,
CHARSET_INFO *cs
) {
+ my_bool overflow;
DBUG_ENTER("spider_string::append_escape_string");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_ASSERT(mem_calc_inited);
DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) ||
current_alloc_mem == str.alloced_length());
str.length(str.length() + escape_string_for_mysql(
- cs, (char *) str.ptr() + str.length(), 0, st, len));
+ cs, (char *) str.ptr() + str.length(), 0, st, len, &overflow));
DBUG_VOID_RETURN;
}
@@ -1286,7 +1289,7 @@ bool spider_string::append_for_single_quote(
DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) ||
current_alloc_mem == str.alloced_length());
#ifdef SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE
- bool res = str.append_for_single_quote(st);
+ bool res = str.append_for_single_quote(st, strlen(st));
#else
String ststr(st, str.charset());
bool res = append_escaped(&str, &ststr);