summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2017-06-19 06:34:38 +0300
committerSergei Golubchik <serg@mariadb.org>2017-08-24 01:05:49 +0200
commit458d5ed8aabc60e6540de8fb9e94fb0577612fa1 (patch)
tree7271d205dcf6b735bbb395cf1bdfd2fc84333955
parenta70f7aad55fbb3b6a9a3cdeb8a83bd50df3f00e2 (diff)
downloadmariadb-git-458d5ed8aabc60e6540de8fb9e94fb0577612fa1.tar.gz
Lots of small cleanups
- Simplified use_trans_cache() to return at once if is_transactional is set - Indentation and spelling errors fixed - Don't call signal_update() if update_binlog_end_pos() is called as the function already calls signal_update() - Removed not used function wait_for_update_bin_log(), which would cause errors if ever used. - Simplified handler::clone() by always allocating 'ref' in ha_open(). To do this I added an optional MEM_ROOT argument to ha_open() to be used when allocating 'ref' - Changed arguments to get_system_var() from LEX_CSTRING to LEX_CSTRING* - Added THD as argument to create_select_for_variable(). Changed also char* argument to LEX_CSTRING to avoid strlen() call. - Change calls to append() to use LEX_CSTRING
-rw-r--r--extra/mariabackup/ds_archive.c1
-rw-r--r--extra/mariabackup/encryption_plugin.cc15
-rw-r--r--extra/mariabackup/fil_cur.cc1
-rw-r--r--extra/mariabackup/xtrabackup.cc1
-rw-r--r--mysys/thr_mutex.c5
-rw-r--r--sql/event_data_objects.cc4
-rw-r--r--sql/event_scheduler.cc2
-rw-r--r--sql/handler.cc32
-rw-r--r--sql/handler.h3
-rw-r--r--sql/item.cc12
-rw-r--r--sql/item_func.cc36
-rw-r--r--sql/item_func.h4
-rw-r--r--sql/item_subselect.cc7
-rw-r--r--sql/log.cc66
-rw-r--r--sql/log.h1
-rw-r--r--sql/log_event.cc2
-rw-r--r--sql/session_tracker.cc2
-rw-r--r--sql/sp_head.cc14
-rw-r--r--sql/sql_acl.cc6
-rw-r--r--sql/sql_load.cc2
-rw-r--r--sql/sql_parse.cc11
-rw-r--r--sql/sql_parse.h2
-rw-r--r--sql/sql_show.cc6
-rw-r--r--sql/sql_string.h4
-rw-r--r--sql/sql_trigger.cc6
-rw-r--r--sql/sql_view.cc5
-rw-r--r--sql/sql_yacc.yy12
-rw-r--r--sql/sql_yacc_ora.yy12
-rw-r--r--sql/unireg.cc2
-rw-r--r--sql/wsrep_mysqld.cc9
-rw-r--r--storage/connect/json.h2
-rw-r--r--storage/connect/jsonudf.cpp2
-rw-r--r--storage/connect/tabjson.cpp2
33 files changed, 147 insertions, 144 deletions
diff --git a/extra/mariabackup/ds_archive.c b/extra/mariabackup/ds_archive.c
index 50afcce4bc7..ae473bc3385 100644
--- a/extra/mariabackup/ds_archive.c
+++ b/extra/mariabackup/ds_archive.c
@@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*******************************************************/
+#include <my_global.h>
#include <my_base.h>
#include <archive.h>
#include <archive_entry.h>
diff --git a/extra/mariabackup/encryption_plugin.cc b/extra/mariabackup/encryption_plugin.cc
index 208a6b8e419..b88c149673b 100644
--- a/extra/mariabackup/encryption_plugin.cc
+++ b/extra/mariabackup/encryption_plugin.cc
@@ -1,3 +1,18 @@
+/* Copyright (c) 2017, MariaDB Corporation.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
+
#include <my_global.h>
#include <mysqld.h>
#include <mysql.h>
diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc
index e00827076d6..fa6cad57016 100644
--- a/extra/mariabackup/fil_cur.cc
+++ b/extra/mariabackup/fil_cur.cc
@@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include <my_global.h>
#include <my_base.h>
-
#include <fil0fil.h>
#include <fsp0fsp.h>
#include <srv0start.h>
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 83c40a14bbd..4904d7b7b35 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -43,6 +43,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
//#define XTRABACKUP_TARGET_IS_PLUGIN
+#include <my_global.h>
#include <my_config.h>
#include <unireg.h>
#include <mysql_version.h>
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 9256af4aa98..49cb3ea600f 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -149,10 +149,11 @@ static inline void remove_from_active_list(safe_mutex_t *mp)
}
/*
- We initialise the hashes for deadlock detection lazily.
- This greatly helps with performance when lots of mutexes are initiased but
+ We initialize the hashes for deadlock detection lazily.
+ This greatly helps with performance when lots of mutexes are initialized but
only a few of them are actually used (eg. InnoDB).
*/
+
static int safe_mutex_lazy_init_deadlock_detection(safe_mutex_t *mp)
{
if (!my_multi_malloc(MY_FAE | MY_WME,
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 631e3388084..02ac5633d65 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -1236,7 +1236,7 @@ Event_timed::get_create_event(THD *thd, String *buf)
append_unescaped(buf, comment.str, comment.length);
}
buf->append(STRING_WITH_LEN(" DO "));
- buf->append(body.str, body.length);
+ buf->append(&body);
DBUG_RETURN(0);
}
@@ -1284,7 +1284,7 @@ Event_job_data::construct_sp_sql(THD *thd, String *sp_sql)
*/
sp_sql->append(C_STRING_WITH_LEN("() SQL SECURITY INVOKER "));
- sp_sql->append(body.str, body.length);
+ sp_sql->append(&body);
DBUG_RETURN(thd->is_fatal_error);
}
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index a38425a7c4e..e8b586801d6 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -85,7 +85,7 @@ Event_worker_thread::print_warnings(THD *thd, Event_job_data *et)
char prefix_buf[5 * STRING_BUFFER_USUAL_SIZE];
String prefix(prefix_buf, sizeof(prefix_buf), system_charset_info);
prefix.length(0);
- prefix.append("Event Scheduler: [");
+ prefix.append(STRING_WITH_LEN("Event Scheduler: ["));
prefix.append(et->definer.str, et->definer.length, system_charset_info);
prefix.append("][", 2);
diff --git a/sql/handler.cc b/sql/handler.cc
index adff97c395b..926551fdd60 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -2360,6 +2360,18 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
/****************************************************************************
** General handler functions
****************************************************************************/
+
+
+/**
+ Clone a handler
+
+ @param name name of new table instance
+ @param mem_root Where 'this->ref' should be allocated. It can't be
+ in this->table->mem_root as otherwise we will not be
+ able to reclaim that memory when the clone handler
+ object is destroyed.
+*/
+
handler *handler::clone(const char *name, MEM_ROOT *mem_root)
{
handler *new_handler= get_new_handler(table->s, mem_root, ht);
@@ -2370,16 +2382,6 @@ handler *handler::clone(const char *name, MEM_ROOT *mem_root)
goto err;
/*
- Allocate handler->ref here because otherwise ha_open will allocate it
- on this->table->mem_root and we will not be able to reclaim that memory
- when the clone handler object is destroyed.
- */
-
- if (!(new_handler->ref= (uchar*) alloc_root(mem_root,
- ALIGN_SIZE(ref_length)*2)))
- goto err;
-
- /*
TODO: Implement a more efficient way to have more than one index open for
the same table instance. The ha_open call is not cachable for clone.
@@ -2387,7 +2389,7 @@ handler *handler::clone(const char *name, MEM_ROOT *mem_root)
and should be able to use the original instance of the table.
*/
if (new_handler->ha_open(table, name, table->db_stat,
- HA_OPEN_IGNORE_IF_LOCKED))
+ HA_OPEN_IGNORE_IF_LOCKED, mem_root))
goto err;
return new_handler;
@@ -2465,7 +2467,7 @@ PSI_table_share *handler::ha_table_share_psi() const
Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set
*/
int handler::ha_open(TABLE *table_arg, const char *name, int mode,
- uint test_if_locked)
+ uint test_if_locked, MEM_ROOT *mem_root)
{
int error;
DBUG_ENTER("handler::ha_open");
@@ -2512,9 +2514,9 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode,
table->db_stat|=HA_READ_ONLY;
(void) extra(HA_EXTRA_NO_READCHECK); // Not needed in SQL
- /* ref is already allocated for us if we're called from handler::clone() */
- if (!ref && !(ref= (uchar*) alloc_root(&table->mem_root,
- ALIGN_SIZE(ref_length)*2)))
+ /* Allocate ref in thd or on the table's mem_root */
+ if (!(ref= (uchar*) alloc_root(mem_root ? mem_root : &table->mem_root,
+ ALIGN_SIZE(ref_length)*2)))
{
ha_close();
error=HA_ERR_OUT_OF_MEM;
diff --git a/sql/handler.h b/sql/handler.h
index 75205dda957..86287596ca3 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -2832,7 +2832,8 @@ public:
}
/* ha_ methods: pubilc wrappers for private virtual API */
- int ha_open(TABLE *table, const char *name, int mode, uint test_if_locked);
+ int ha_open(TABLE *table, const char *name, int mode, uint test_if_locked,
+ MEM_ROOT *mem_root= 0);
int ha_index_init(uint idx, bool sorted)
{
DBUG_EXECUTE_IF("ha_index_init_fail", return HA_ERR_TABLE_DEF_CHANGED;);
diff --git a/sql/item.cc b/sql/item.cc
index d67301e8d04..fe20687bf51 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1691,7 +1691,7 @@ Item_splocal::this_item_addr(THD *thd, Item **)
void Item_splocal::print(String *str, enum_query_type)
{
str->reserve(m_name.length+8);
- str->append(m_name.str, m_name.length);
+ str->append(&m_name);
str->append('@');
str->qs_append(m_var_idx);
}
@@ -1816,9 +1816,9 @@ Item_splocal_row_field::this_item_addr(THD *thd, Item **)
void Item_splocal_row_field::print(String *str, enum_query_type)
{
str->reserve(m_name.length + m_field_name.length + 8);
- str->append(m_name.str, m_name.length);
+ str->append(&m_name);
str->append('.');
- str->append(m_field_name.str, m_field_name.length);
+ str->append(&m_field_name);
str->append('@');
str->qs_append(m_var_idx);
str->append('[');
@@ -1854,13 +1854,13 @@ void Item_splocal_row_field_by_name::print(String *str, enum_query_type)
// +16 should be enough for .NNN@[""]
if (str->reserve(m_name.length + 2 * m_field_name.length + 16))
return;
- str->qs_append(m_name.str, m_name.length);
+ str->qs_append(&m_name);
str->qs_append('.');
- str->qs_append(m_field_name.str, m_field_name.length);
+ str->qs_append(&m_field_name);
str->qs_append('@');
str->qs_append(m_var_idx);
str->qs_append("[\"", 2);
- str->qs_append(m_field_name.str, m_field_name.length);
+ str->qs_append(&m_field_name);
str->qs_append("\"]", 2);
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 4a91f9a4938..7d00e868bae 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4995,7 +4995,7 @@ bool Item_func_set_user_var::is_null_result()
void Item_func_set_user_var::print(String *str, enum_query_type query_type)
{
str->append(STRING_WITH_LEN("@"));
- str->append(name.str, name.length);
+ str->append(&name);
str->append(STRING_WITH_LEN(":="));
args[0]->print_parenthesised(str, query_type, precedence());
}
@@ -5005,7 +5005,7 @@ void Item_func_set_user_var::print_as_stmt(String *str,
enum_query_type query_type)
{
str->append(STRING_WITH_LEN("set @"));
- str->append(name.str, name.length);
+ str->append(&name);
str->append(STRING_WITH_LEN(":="));
args[0]->print_parenthesised(str, query_type, precedence());
}
@@ -5588,7 +5588,7 @@ void Item_func_get_system_var::fix_length_and_dec()
void Item_func_get_system_var::print(String *str, enum_query_type query_type)
{
if (name.length)
- str->append(name.str, name.length);
+ str->append(&name);
else
{
str->append(STRING_WITH_LEN("@@"));
@@ -6122,39 +6122,41 @@ longlong Item_func_bit_xor::val_int()
*/
-Item *get_system_var(THD *thd, enum_var_type var_type, LEX_CSTRING name,
- LEX_CSTRING component)
+Item *get_system_var(THD *thd, enum_var_type var_type,
+ const LEX_CSTRING *name,
+ const LEX_CSTRING *component)
{
sys_var *var;
- LEX_CSTRING *base_name, *component_name;
+ LEX_CSTRING base_name, component_name;
- if (component.str)
+ if (component->str)
{
- base_name= &component;
- component_name= &name;
+ base_name= *component;
+ component_name= *name;
}
else
{
- base_name= &name;
- component_name= &component; // Empty string
+ base_name= *name;
+ component_name= *component; // Empty string
}
- if (!(var= find_sys_var(thd, base_name->str, base_name->length)))
+ if (!(var= find_sys_var(thd, base_name.str, base_name.length)))
return 0;
- if (component.str)
+ if (component->str)
{
if (!var->is_struct())
{
- my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), base_name->str);
+ my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), base_name.str);
return 0;
}
}
thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
- set_if_smaller(component_name->length, MAX_SYS_VAR_LENGTH);
+ set_if_smaller(component_name.length, MAX_SYS_VAR_LENGTH);
- return new (thd->mem_root) Item_func_get_system_var(thd, var, var_type, component_name,
- NULL, 0);
+ return new (thd->mem_root) Item_func_get_system_var(thd, var, var_type,
+ &component_name,
+ NULL, 0);
}
diff --git a/sql/item_func.h b/sql/item_func.h
index 9a6254438f0..a25d9aed4d7 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -2975,8 +2975,8 @@ public:
};
-Item *get_system_var(THD *thd, enum_var_type var_type, LEX_CSTRING name,
- LEX_CSTRING component);
+Item *get_system_var(THD *thd, enum_var_type var_type,
+ const LEX_CSTRING *name, const LEX_CSTRING *component);
extern bool check_reserved_words(const LEX_CSTRING *name);
Item *find_date_time_item(Item **args, uint nargs, uint col);
double my_double_round(double value, longlong dec, bool dec_unsigned,
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index b184ba86ea4..cdcb5ed9421 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -949,7 +949,7 @@ void Item_subselect::print(String *str, enum_query_type query_type)
{
if (query_type & QT_ITEM_SUBSELECT_ID_ONLY)
{
- str->append("(subquery#");
+ str->append(STRING_WITH_LEN("(subquery#"));
if (unit && unit->first_select())
{
char buf[64];
@@ -4358,7 +4358,6 @@ void subselect_union_engine::print(String *str, enum_query_type query_type)
void subselect_uniquesubquery_engine::print(String *str,
enum_query_type query_type)
{
- const char *table_name= tab->table->s->table_name.str;
str->append(STRING_WITH_LEN("<primary_index_lookup>("));
tab->ref.items[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" in "));
@@ -4371,7 +4370,7 @@ void subselect_uniquesubquery_engine::print(String *str,
str->append(STRING_WITH_LEN("<temporary table>"));
}
else
- str->append(table_name, tab->table->s->table_name.length);
+ str->append(&tab->table->s->table_name);
KEY *key_info= tab->table->key_info+ tab->ref.key;
str->append(STRING_WITH_LEN(" on "));
str->append(key_info->name);
@@ -4395,7 +4394,7 @@ void subselect_uniquesubquery_engine::print(String *str)
for (uint i= 0; i < key_info->user_defined_key_parts; i++)
tab->ref.items[i]->print(str);
str->append(STRING_WITH_LEN(" in "));
- str->append(tab->table->s->table_name.str, tab->table->s->table_name.length);
+ str->append(&tab->table->s->table_name);
str->append(STRING_WITH_LEN(" on "));
str->append(key_info->name);
if (cond)
diff --git a/sql/log.cc b/sql/log.cc
index 20ab472d04a..deba614d096 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2887,27 +2887,27 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host,
DBUG_EXECUTE_IF("reset_log_last_time", last_time= 0;);
/* Note that my_b_write() assumes it knows the length for this */
- if (event_time != last_time)
- {
- last_time= event_time;
+ if (event_time != last_time)
+ {
+ last_time= event_time;
- localtime_r(&event_time, &start);
+ localtime_r(&event_time, &start);
- time_buff_len= my_snprintf(local_time_buff, MAX_TIME_SIZE,
- "%02d%02d%02d %2d:%02d:%02d\t",
- start.tm_year % 100, start.tm_mon + 1,
- start.tm_mday, start.tm_hour,
- start.tm_min, start.tm_sec);
+ time_buff_len= my_snprintf(local_time_buff, MAX_TIME_SIZE,
+ "%02d%02d%02d %2d:%02d:%02d\t",
+ start.tm_year % 100, start.tm_mon + 1,
+ start.tm_mday, start.tm_hour,
+ start.tm_min, start.tm_sec);
- if (my_b_write(&log_file, (uchar*) local_time_buff, time_buff_len))
- goto err;
- }
- else
- if (my_b_write(&log_file, (uchar*) "\t\t" ,2) < 0)
- goto err;
+ if (my_b_write(&log_file, (uchar*) local_time_buff, time_buff_len))
+ goto err;
+ }
+ else
+ if (my_b_write(&log_file, (uchar*) "\t\t" ,2) < 0)
+ goto err;
- /* command_type, thread_id */
- size_t length= my_snprintf(buff, 32, "%6llu ", thread_id_arg);
+ /* command_type, thread_id */
+ size_t length= my_snprintf(buff, 32, "%6llu ", thread_id_arg);
if (my_b_write(&log_file, (uchar*) buff, length))
goto err;
@@ -5433,13 +5433,14 @@ stmt_has_updated_trans_table(const THD *thd)
*/
bool use_trans_cache(const THD* thd, bool is_transactional)
{
+ if (is_transactional)
+ return 1;
binlog_cache_mngr *const cache_mngr=
(binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
- return
- ((thd->is_current_stmt_binlog_format_row() ||
- thd->variables.binlog_direct_non_trans_update) ? is_transactional :
- (is_transactional || !cache_mngr->trx_cache.empty()));
+ return ((thd->is_current_stmt_binlog_format_row() ||
+ thd->variables.binlog_direct_non_trans_update) ? 0 :
+ !cache_mngr->trx_cache.empty());
}
/**
@@ -6360,7 +6361,6 @@ err:
*/
update_binlog_end_pos(offset);
- signal_update();
if ((error= rotate(false, &check_purge)))
check_purge= false;
}
@@ -7675,7 +7675,6 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
else
{
bool any_error= false;
- bool all_error= true;
mysql_mutex_assert_not_owner(&LOCK_prepare_ordered);
mysql_mutex_assert_owner(&LOCK_log);
@@ -7697,8 +7696,6 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
current->error_cache= NULL;
any_error= true;
}
- else
- all_error= false;
first= false;
}
@@ -7712,8 +7709,6 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
if (any_error)
sql_print_error("Failed to run 'after_flush' hooks");
- if (!all_error)
- signal_update();
}
/*
@@ -8117,23 +8112,6 @@ void MYSQL_BIN_LOG::wait_for_update_relay_log(THD* thd)
LOCK_log is released by the caller.
*/
-int MYSQL_BIN_LOG::wait_for_update_bin_log(THD* thd,
- const struct timespec *timeout)
-{
- int ret= 0;
- DBUG_ENTER("wait_for_update_bin_log");
-
- thd_wait_begin(thd, THD_WAIT_BINLOG);
- mysql_mutex_assert_owner(&LOCK_log);
- if (!timeout)
- mysql_cond_wait(&update_cond, &LOCK_log);
- else
- ret= mysql_cond_timedwait(&update_cond, &LOCK_log,
- const_cast<struct timespec *>(timeout));
- thd_wait_end(thd);
- DBUG_RETURN(ret);
-}
-
int MYSQL_BIN_LOG::wait_for_update_binlog_end_pos(THD* thd,
struct timespec *timeout)
{
diff --git a/sql/log.h b/sql/log.h
index f57693f9d2a..30829bdb33c 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -711,7 +711,6 @@ public:
void wait_for_sufficient_commits();
void binlog_trigger_immediate_group_commit();
void wait_for_update_relay_log(THD* thd);
- int wait_for_update_bin_log(THD* thd, const struct timespec * timeout);
void init(ulong max_size);
void init_pthread_objects();
void cleanup();
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 2f02d1db2c8..b9d802f7927 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -319,7 +319,7 @@ public:
LEX_STRING tmp_str;
if (copy_event_cache_to_string_and_reinit(m_cache, &tmp_str))
exit(1);
- m_ev->output_buf.append(tmp_str.str, tmp_str.length);
+ m_ev->output_buf.append(&tmp_str);
my_free(tmp_str.str);
}
#else /* MySQL_SERVER */
diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc
index 61680fb17f6..8d64fb29332 100644
--- a/sql/session_tracker.cc
+++ b/sql/session_tracker.cc
@@ -1216,7 +1216,7 @@ bool Transaction_state_tracker::store(THD *thd, String *buf)
tx_isolation_typelib as it hyphenates its items.
*/
buf->append(STRING_WITH_LEN("SET TRANSACTION ISOLATION LEVEL "));
- buf->append(isol[tx_isol_level - 1].str, isol[tx_isol_level - 1].length);
+ buf->append(&isol[tx_isol_level - 1]);
buf->append(STRING_WITH_LEN("; "));
}
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 11f4a0dcfde..a199a181be2 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -3357,7 +3357,7 @@ sp_instr_set::print(String *str)
str->qs_append(STRING_WITH_LEN("set "));
if (var)
{
- str->qs_append(var->name.str, var->name.length);
+ str->qs_append(&var->name);
str->qs_append('@');
}
str->qs_append(m_offset);
@@ -3403,9 +3403,9 @@ sp_instr_set_row_field::print(String *str)
if (str->reserve(rsrv))
return;
str->qs_append(STRING_WITH_LEN("set "));
- str->qs_append(var->name.str, var->name.length);
+ str->qs_append(&var->name);
str->qs_append('.');
- str->qs_append(def->field_name.str, def->field_name.length);
+ str->qs_append(&def->field_name);
str->qs_append('@');
str->qs_append(m_offset);
str->qs_append('[');
@@ -3461,13 +3461,13 @@ sp_instr_set_row_field_by_name::print(String *str)
if (str->reserve(rsrv))
return;
str->qs_append(STRING_WITH_LEN("set "));
- str->qs_append(var->name.str, var->name.length);
+ str->qs_append(&var->name);
str->qs_append('.');
- str->qs_append(m_field_name.str, m_field_name.length);
+ str->qs_append(&m_field_name);
str->qs_append('@');
str->qs_append(m_offset);
str->qs_append("[\"",2);
- str->qs_append(m_field_name.str, m_field_name.length);
+ str->qs_append(&m_field_name);
str->qs_append("\"]",2);
str->qs_append(' ');
m_value->print(str, enum_query_type(QT_ORDINARY |
@@ -4120,7 +4120,7 @@ sp_instr_cfetch::print(String *str)
if (str->reserve(pv->name.length+SP_INSTR_UINT_MAXLEN+2))
return;
str->qs_append(' ');
- str->qs_append(pv->name.str, pv->name.length);
+ str->qs_append(&pv->name);
str->qs_append('@');
str->qs_append(pv->offset);
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index faadcb3dcf1..15c55ccaef0 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -8381,18 +8381,18 @@ static void add_user_parameters(String *result, ACL_USER* acl_user,
{
DBUG_ASSERT(acl_user->salt_len);
result->append(STRING_WITH_LEN(" IDENTIFIED BY PASSWORD '"));
- result->append(acl_user->auth_string.str, acl_user->auth_string.length);
+ result->append(&acl_user->auth_string);
result->append('\'');
}
}
else
{
result->append(STRING_WITH_LEN(" IDENTIFIED VIA "));
- result->append(acl_user->plugin.str, acl_user->plugin.length);
+ result->append(&acl_user->plugin);
if (acl_user->auth_string.length)
{
result->append(STRING_WITH_LEN(" USING '"));
- result->append(acl_user->auth_string.str, acl_user->auth_string.length);
+ result->append(&acl_user->auth_string);
result->append('\'');
}
}
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 8550fc187c1..e3c46515c4d 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -837,7 +837,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
if (n++)
query_str.append(STRING_WITH_LEN(", "));
append_identifier(thd, &query_str, item->name.str, item->name.length);
- query_str.append(val->name.str, val->name.length);
+ query_str.append(&val->name);
}
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 3e29853d703..00f009feb4a 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -7644,28 +7644,23 @@ mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *select_lex)
@param var_name Variable name
*/
-void create_select_for_variable(const char *var_name)
+void create_select_for_variable(THD *thd, LEX_CSTRING *var_name)
{
- THD *thd;
LEX *lex;
- LEX_CSTRING tmp;
Item *var;
char buff[MAX_SYS_VAR_LENGTH*2+4+8], *end;
DBUG_ENTER("create_select_for_variable");
- thd= current_thd;
lex= thd->lex;
mysql_init_select(lex);
lex->sql_command= SQLCOM_SELECT;
- tmp.str= var_name;
- tmp.length=strlen(var_name);
/*
We set the name of Item to @@session.var_name because that then is used
as the column name in the output.
*/
- if ((var= get_system_var(thd, OPT_SESSION, tmp, null_clex_str)))
+ if ((var= get_system_var(thd, OPT_SESSION, var_name, &null_clex_str)))
{
- end= strxmov(buff, "@@session.", var_name, NullS);
+ end= strxmov(buff, "@@session.", var_name->str, NullS);
var->set_name(thd, buff, end-buff, system_charset_info);
add_item_to_list(thd, var);
}
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index 02318442686..b0371a2cb81 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -93,7 +93,7 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
Parser_state *parser_state, bool is_com_multi,
bool is_next_command);
bool mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *sel);
-void create_select_for_variable(const char *var_name);
+void create_select_for_variable(THD *thd, LEX_CSTRING *var_name);
void create_table_set_open_action_and_adjust_tables(LEX *lex);
void mysql_init_multi_delete(LEX *lex);
bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 7e29d7867b9..6d9f3f23138 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1773,7 +1773,7 @@ static void append_create_options(THD *thd, String *packet,
if (opt->quoted_value)
append_unescaped(packet, opt->value.str, opt->value.length);
else
- packet->append(opt->value.str, opt->value.length);
+ packet->append(&opt->value);
}
if (in_comment)
packet->append(STRING_WITH_LEN(" */"));
@@ -7089,7 +7089,7 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
tmp_res.length(0);
if (part_elem->has_null_value)
{
- tmp_str.append("NULL");
+ tmp_str.append(STRING_WITH_LEN("NULL"));
if (num_items > 0)
tmp_str.append(",");
}
@@ -7098,7 +7098,7 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
if (part_info->column_list)
{
if (part_info->part_field_list.elements > 1U)
- tmp_str.append("(");
+ tmp_str.append(STRING_WITH_LEN("("));
if (get_partition_column_description(thd,
part_info,
list_value,
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 1551ef361f3..5dbb110135f 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -575,6 +575,10 @@ public:
{
qs_append(str, (uint32)strlen(str));
}
+ void qs_append(const LEX_CSTRING *str)
+ {
+ qs_append(str->str, str->length);
+ }
void qs_append(const char *str, uint32 len);
void qs_append_hex(const char *str, uint32 len);
void qs_append(double d);
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 502d151a60a..7e3f047ef91 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -688,7 +688,7 @@ static void build_trig_stmt_query(THD *thd, TABLE_LIST *tables,
/* Create statement for storing trigger (without trigger order) */
if (lex->trg_chistics.ordering_clause == TRG_ORDER_NONE)
- trigger_def->append(stmt_definition.str, stmt_definition.length);
+ trigger_def->append(&stmt_definition);
else
{
/* Copy data before FOLLOWS/PRECEDES trigger_name */
@@ -923,8 +923,8 @@ err_without_cleanup:
if (trigger_dropped)
{
String drop_trg_query;
- drop_trg_query.append("DROP TRIGGER /* generated by failed CREATE TRIGGER */ ");
- drop_trg_query.append(lex->spname->m_name.str);
+ drop_trg_query.append(STRING_WITH_LEN("DROP TRIGGER /* generated by failed CREATE TRIGGER */ "));
+ drop_trg_query.append(&lex->spname->m_name);
/*
We dropped an existing trigger and was not able to recreate it because
of an internal error. Ensure it's also dropped on the slave.
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index d6b972d2d73..0547a3cb343 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -647,8 +647,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
{ C_STRING_WITH_LEN("ALTER ") },
{ C_STRING_WITH_LEN("CREATE OR REPLACE ") }};
- buff.append(command[thd->lex->create_view->mode].str,
- command[thd->lex->create_view->mode].length);
+ buff.append(&command[thd->lex->create_view->mode]);
view_store_options(thd, views, &buff);
buff.append(STRING_WITH_LEN("VIEW "));
@@ -680,7 +679,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
buff.append(')');
}
buff.append(STRING_WITH_LEN(" AS "));
- buff.append(views->source.str, views->source.length);
+ buff.append(&views->source);
int errcode= query_error_code(thd, TRUE);
/*
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index e337b624e4c..e02e5f9d5f1 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -10726,7 +10726,7 @@ variable_aux:
thd->parse_error();
MYSQL_YYABORT;
}
- if (!($$= get_system_var(thd, $2, $3, $4)))
+ if (!($$= get_system_var(thd, $2, &$3, &$4)))
MYSQL_YYABORT;
if (!((Item_func_get_system_var*) $$)->is_written_to_binlog())
Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_VARIABLE);
@@ -13035,9 +13035,15 @@ show_param:
lex->sql_command= SQLCOM_SHOW_PRIVILEGES;
}
| COUNT_SYM '(' '*' ')' WARNINGS
- { (void) create_select_for_variable("warning_count"); }
+ {
+ LEX_CSTRING var= {STRING_WITH_LEN("warning_count")};
+ (void) create_select_for_variable(thd, &var);
+ }
| COUNT_SYM '(' '*' ')' ERRORS
- { (void) create_select_for_variable("error_count"); }
+ {
+ LEX_CSTRING var= {STRING_WITH_LEN("error_count")};
+ (void) create_select_for_variable(thd, &var);
+ }
| WARNINGS opt_limit_clause
{ Lex->sql_command = SQLCOM_SHOW_WARNS;}
| ERRORS opt_limit_clause
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index 4a093373b49..b25baab22fb 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -10781,7 +10781,7 @@ variable_aux:
thd->parse_error();
MYSQL_YYABORT;
}
- if (!($$= get_system_var(thd, $2, $3, $4)))
+ if (!($$= get_system_var(thd, $2, &$3, &$4)))
MYSQL_YYABORT;
if (!((Item_func_get_system_var*) $$)->is_written_to_binlog())
Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_VARIABLE);
@@ -13123,9 +13123,15 @@ show_param:
lex->sql_command= SQLCOM_SHOW_PRIVILEGES;
}
| COUNT_SYM '(' '*' ')' WARNINGS
- { (void) create_select_for_variable("warning_count"); }
+ {
+ LEX_CSTRING var= {STRING_WITH_LEN("warning_count")};
+ (void) create_select_for_variable(thd, &var);
+ }
| COUNT_SYM '(' '*' ')' ERRORS
- { (void) create_select_for_variable("error_count"); }
+ {
+ LEX_CSTRING var= {STRING_WITH_LEN("error_count")};
+ (void) create_select_for_variable(thd, &var);
+ }
| WARNINGS opt_limit_clause
{ Lex->sql_command = SQLCOM_SHOW_WARNS;}
| ERRORS opt_limit_clause
diff --git a/sql/unireg.cc b/sql/unireg.cc
index cc5e19d1104..5b970b3c555 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -539,7 +539,7 @@ static bool pack_expression(String *buf, Virtual_column_info *vcol,
size_t len_off= buf->length();
buf->q_append2b(0); // to be added later
buf->q_append((char)vcol->name.length);
- buf->q_append(vcol->name.str, vcol->name.length);
+ buf->q_append(&vcol->name);
size_t expr_start= buf->length();
vcol->print(buf);
size_t expr_len= buf->length() - expr_start;
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 05ec182b318..e64ce00cd47 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -1325,22 +1325,17 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len)
SELECT_LEX *select_lex= &lex->select_lex;
TABLE_LIST *first_table= select_lex->table_list.first;
TABLE_LIST *views = first_table;
-
+ LEX_USER *definer;
String buff;
const LEX_STRING command[3]=
{{ C_STRING_WITH_LEN("CREATE ") },
{ C_STRING_WITH_LEN("ALTER ") },
{ C_STRING_WITH_LEN("CREATE OR REPLACE ") }};
- buff.append(command[thd->lex->create_view->mode].str,
- command[thd->lex->create_view->mode].length);
-
- LEX_USER *definer;
+ buff.append(&command[thd->lex->create_view->mode]);
if (lex->definer)
- {
definer= get_current_user(thd, lex->definer);
- }
else
{
/*
diff --git a/storage/connect/json.h b/storage/connect/json.h
index 685c1dddcf2..de3288b1b58 100644
--- a/storage/connect/json.h
+++ b/storage/connect/json.h
@@ -52,6 +52,8 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty);
bool SerializeArray(JOUT *js, PJAR jarp, bool b);
bool SerializeObject(JOUT *js, PJOB jobp);
bool SerializeValue(JOUT *js, PJVAL jvp);
+bool IsNum(PSZ s);
+char *NextChr(PSZ s, char sep);
/***********************************************************************/
/* Class JOUT. Used by Serialize. */
diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp
index b44e9c1309b..00139b4b820 100644
--- a/storage/connect/jsonudf.cpp
+++ b/storage/connect/jsonudf.cpp
@@ -1815,7 +1815,7 @@ char *json_make_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
return str;
} // end of json_make_array
-void json_array_deinit(UDF_INIT* initid)
+static void json_array_deinit(UDF_INIT* initid)
{
JsonFreeMem((PGLOBAL)initid->ptr);
} // end of json_make_array_deinit
diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp
index 823c82b9ceb..84c3947b68b 100644
--- a/storage/connect/tabjson.cpp
+++ b/storage/connect/tabjson.cpp
@@ -53,8 +53,6 @@
/* External functions. */
/***********************************************************************/
USETEMP UseTemp(void);
-bool IsNum(PSZ s);
-char *NextChr(PSZ s, char sep);
typedef struct _jncol {
struct _jncol *Next;