summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-11-13 14:07:58 +0100
committerSergei Golubchik <sergii@pisem.net>2013-11-13 14:07:58 +0100
commitbdd883ed9a68ff1e82528cc6b33316d98894cfd2 (patch)
tree93081c72225d399ac93ae0d8bb301a13cfc9a50c /sql
parent2cba9e0cdccfac6f93a54e2ba12eb9926cfaa0a1 (diff)
parentf3a78f392dad24391c19464731833e2bdf19bdef (diff)
downloadmariadb-git-bdd883ed9a68ff1e82528cc6b33316d98894cfd2.tar.gz
5.5. merge
Diffstat (limited to 'sql')
-rw-r--r--sql/event_data_objects.cc2
-rw-r--r--sql/item_cmpfunc.h4
-rw-r--r--sql/log_event.cc6
-rw-r--r--sql/log_event_old.cc2
-rw-r--r--sql/mysqld.cc8
-rw-r--r--sql/opt_subselect.cc6
-rw-r--r--sql/opt_sum.cc24
-rw-r--r--sql/rpl_gtid.cc2
-rw-r--r--sql/rpl_rli.cc2
-rw-r--r--sql/share/errmsg-utf8.txt48
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_parse.cc31
-rw-r--r--sql/sql_parse.h2
-rw-r--r--sql/sql_plugin.cc8
-rw-r--r--sql/sql_prepare.cc8
-rw-r--r--sql/sql_select.cc6
-rw-r--r--sql/sql_show.cc3
18 files changed, 92 insertions, 73 deletions
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 14b1003d308..bc683a76ecb 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -1337,7 +1337,7 @@ Event_job_data::execute(THD *thd, bool drop)
DBUG_ENTER("Event_job_data::execute");
- mysql_reset_thd_for_next_command(thd, 0);
+ mysql_reset_thd_for_next_command(thd);
/*
MySQL parser currently assumes that current database is either
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 6c814429122..a438139bcfe 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -516,8 +516,8 @@ public:
bool fix_fields(THD *thd, Item **ref)
{return Item_func::fix_fields(thd, ref);}
virtual void print(String *str, enum_query_type query_type);
- void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; };
- void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; };
+ void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; test_sub_item= 0; };
+ void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; test_sum_item= 0;};
bool empty_underlying_subquery();
Item *neg_transformer(THD *thd);
};
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 6e65928a579..764144419be 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -5633,7 +5633,7 @@ int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi,
*/
lex_start(thd);
thd->lex->local_file= local_fname;
- mysql_reset_thd_for_next_command(thd, 0);
+ mysql_reset_thd_for_next_command(thd);
/*
We test replicate_*_db rules. Note that we have already prepared
@@ -8326,7 +8326,7 @@ int Append_block_log_event::do_apply_event(rpl_group_info *rgi)
as the present method does not call mysql_parse().
*/
lex_start(thd);
- mysql_reset_thd_for_next_command(thd, 0);
+ mysql_reset_thd_for_next_command(thd);
/* old copy may exist already */
mysql_file_delete(key_file_log_event_data, fname, MYF(0));
if ((fd= mysql_file_create(key_file_log_event_data,
@@ -9288,7 +9288,7 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
*/
delete_explain_query(thd->lex);
lex_start(thd);
- mysql_reset_thd_for_next_command(thd, 0);
+ mysql_reset_thd_for_next_command(thd);
/*
The current statement is just about to begin and
has not yet modified anything. Note, all.modified is reset
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index 674d6af025f..d9de0615eb5 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -89,7 +89,7 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi)
*/
delete_explain_query(thd->lex);
lex_start(ev_thd);
- mysql_reset_thd_for_next_command(ev_thd, 0);
+ mysql_reset_thd_for_next_command(ev_thd);
/*
This is a row injection, so we flag the "statement" as
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index de9d79b0ecd..dd9c1ef7365 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3432,7 +3432,6 @@ static bool init_global_datetime_format(timestamp_type format_type,
SHOW_VAR com_status_vars[]= {
{"admin_commands", (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS},
- {"assign_to_keycache", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS},
{"alter_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
{"alter_db_upgrade", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB_UPGRADE]), SHOW_LONG_STATUS},
{"alter_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_EVENT]), SHOW_LONG_STATUS},
@@ -3442,6 +3441,7 @@ SHOW_VAR com_status_vars[]= {
{"alter_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
{"alter_tablespace", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_TABLESPACE]), SHOW_LONG_STATUS},
{"analyze", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
+ {"assign_to_keycache", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS},
{"begin", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
{"binlog", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_BINLOG_BASE64_EVENT]), SHOW_LONG_STATUS},
{"call_procedure", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CALL]), SHOW_LONG_STATUS},
@@ -3513,7 +3513,6 @@ SHOW_VAR com_status_vars[]= {
{"savepoint", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
{"select", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SELECT]), SHOW_LONG_STATUS},
{"set_option", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
- {"signal", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SIGNAL]), SHOW_LONG_STATUS},
{"show_authors", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_AUTHORS]), SHOW_LONG_STATUS},
{"show_binlog_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOG_EVENTS]), SHOW_LONG_STATUS},
{"show_binlogs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOGS]), SHOW_LONG_STATUS},
@@ -3531,8 +3530,8 @@ SHOW_VAR com_status_vars[]= {
{"show_engine_logs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_LOGS]), SHOW_LONG_STATUS},
{"show_engine_mutex", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_MUTEX]), SHOW_LONG_STATUS},
{"show_engine_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_STATUS]), SHOW_LONG_STATUS},
- {"show_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_EVENTS]), SHOW_LONG_STATUS},
{"show_errors", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS},
+ {"show_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_EVENTS]), SHOW_LONG_STATUS},
{"show_explain", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_EXPLAIN]), SHOW_LONG_STATUS},
{"show_fields", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_FIELDS]), SHOW_LONG_STATUS},
#ifndef DBUG_OFF
@@ -3540,8 +3539,8 @@ SHOW_VAR com_status_vars[]= {
#endif
{"show_function_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS_FUNC]), SHOW_LONG_STATUS},
{"show_grants", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_GRANTS]), SHOW_LONG_STATUS},
- {"show_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS},
{"show_index_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_INDEX_STATS]), SHOW_LONG_STATUS},
+ {"show_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS},
{"show_master_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_MASTER_STAT]), SHOW_LONG_STATUS},
{"show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
{"show_plugins", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
@@ -3566,6 +3565,7 @@ SHOW_VAR com_status_vars[]= {
{"show_variables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS},
{"show_warnings", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
{"shutdown", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHUTDOWN]), SHOW_LONG_STATUS},
+ {"signal", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SIGNAL]), SHOW_LONG_STATUS},
{"start_all_slaves", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_ALL_START]), SHOW_LONG_STATUS},
{"start_slave", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SLAVE_START]), SHOW_LONG_STATUS},
{"stmt_close", (char*) offsetof(STATUS_VAR, com_stmt_close), SHOW_LONG_STATUS},
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index de5448ace63..0daf7aee3a9 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -437,9 +437,7 @@ Currently, solution #2 is implemented.
static
bool subquery_types_allow_materialization(Item_in_subselect *in_subs);
-static bool replace_where_subcondition(JOIN *join, Item **expr,
- Item *old_cond, Item *new_cond,
- bool do_fix_fields);
+static bool replace_where_subcondition(JOIN *, Item **, Item *, Item *, bool);
static int subq_sj_candidate_cmp(Item_in_subselect* el1, Item_in_subselect* el2,
void *arg);
static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred);
@@ -1313,7 +1311,7 @@ static bool replace_where_subcondition(JOIN *join, Item **expr,
}
else if (item->type() == Item::COND_ITEM)
{
- DBUG_ASSERT(!(*expr)->fixed);
+ DBUG_ASSERT(!do_fix_fields || !(*expr)->fixed);
replace_where_subcondition(join, li.ref(),
old_cond, new_cond,
do_fix_fields);
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 069fe6452e8..aa8b17a2c85 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -479,6 +479,24 @@ int opt_sum_query(THD *thd,
}
+/*
+ Check if both item1 and item2 are strings, and item1 has fewer characters
+ than item2.
+*/
+
+static bool check_item1_shorter_item2(Item *item1, Item *item2)
+{
+ if (item1->cmp_type() == STRING_RESULT &&
+ item2->cmp_type() == STRING_RESULT)
+ {
+ int len1= item1->max_length / item1->collation.collation->mbmaxlen;
+ int len2= item2->max_length / item2->collation.collation->mbmaxlen;
+ return len1 < len2;
+ }
+ return false; /* When the check is not applicable, it means "not bigger" */
+}
+
+
/**
Test if the predicate compares a field with constants.
@@ -509,7 +527,7 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order)
if (!(item= it++))
return 0;
args[0]= item->real_item();
- if (args[0]->max_length < args[1]->max_length)
+ if (check_item1_shorter_item2(args[0], args[1]))
return 0;
if (it++)
return 0;
@@ -544,7 +562,7 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order)
}
else
return 0;
- if (args[0]->max_length < args[1]->max_length)
+ if (check_item1_shorter_item2(args[0], args[1]))
return 0;
break;
case 3:
@@ -559,7 +577,7 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order)
if (!item->const_item())
return 0;
args[i]= item;
- if (args[0]->max_length < args[i]->max_length)
+ if (check_item1_shorter_item2(args[0], args[1]))
return 0;
}
}
diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc
index abaf97efe71..1b3dca95391 100644
--- a/sql/rpl_gtid.cc
+++ b/sql/rpl_gtid.cc
@@ -328,7 +328,7 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id,
}
if (!in_statement)
- mysql_reset_thd_for_next_command(thd, 0);
+ mysql_reset_thd_for_next_command(thd);
DBUG_EXECUTE_IF("gtid_inject_record_gtid",
{
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 8a0328dd89c..3bf6a0cff76 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -1324,7 +1324,7 @@ rpl_load_gtid_slave_state(THD *thd)
goto end;
array_inited= true;
- mysql_reset_thd_for_next_command(thd, 0);
+ mysql_reset_thd_for_next_command(thd);
tlist.init_one_table(STRING_WITH_LEN("mysql"),
rpl_gtid_slave_state_table_name.str,
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index ab3459bfb16..b74ffecf82e 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -2913,30 +2913,30 @@ ER_UDF_EXISTS
swe "Funktionen '%-.192s' finns redan"
ukr "Функція '%-.192s' вже існує"
ER_CANT_OPEN_LIBRARY
- cze "Nemohu otev-Břít sdílenou knihovnu '%-.192s' (errno: %d %-.128s)"
- dan "Kan ikke åbne delt bibliotek '%-.192s' (errno: %d %-.128s)"
- nla "Kan shared library '%-.192s' niet openen (Errcode: %d %-.128s)"
- eng "Can't open shared library '%-.192s' (errno: %d %-.128s)"
- jps "shared library '%-.192s' を開く事ができません (errno: %d %-.128s)",
- est "Ei suuda avada jagatud teeki '%-.192s' (veakood: %d %-.128s)"
- fre "Impossible d'ouvrir la bibliothèque partagée '%-.192s' (errno: %d %-.128s)"
- ger "Kann Shared Library '%-.192s' nicht öffnen (Fehler: %d %-.128s)"
- greek "Δεν είναι δυνατή η ανάγνωση της shared library '%-.192s' (κωδικός λάθους: %d %-.128s)"
- hun "A(z) '%-.192s' megosztott konyvtar nem hasznalhato (hibakod: %d %-.128s)"
- ita "Impossibile aprire la libreria condivisa '%-.192s' (errno: %d %-.128s)"
- jpn "shared library '%-.192s' を開く事ができません (errno: %d %-.128s)"
- kor "'%-.192s' 공유 라이버러리를 열수 없습니다.(에러번호: %d %-.128s)"
- nor "Can't open shared library '%-.192s' (errno: %d %-.128s)"
- norwegian-ny "Can't open shared library '%-.192s' (errno: %d %-.128s)"
- pol "Can't open shared library '%-.192s' (errno: %d %-.128s)"
- por "Não pode abrir biblioteca compartilhada '%-.192s' (erro no. %d '%-.128s')"
- rum "Nu pot deschide libraria shared '%-.192s' (Eroare: %d %-.128s)"
- rus "Невозможно открыть динамическую библиотеку '%-.192s' (ошибка: %d %-.128s)"
- serbian "Ne mogu da otvorim share-ovanu biblioteku '%-.192s' (errno: %d %-.128s)"
- slo "Nemôžem otvoriť zdieľanú knižnicu '%-.192s' (chybový kód: %d %-.128s)"
- spa "No puedo abrir libraria conjugada '%-.192s' (errno: %d %-.128s)"
- swe "Kan inte öppna det dynamiska biblioteket '%-.192s' (Felkod: %d %-.128s)"
- ukr "Не можу відкрити розділювану бібліотеку '%-.192s' (помилка: %d %-.128s)"
+ cze "Nemohu otev-Břít sdílenou knihovnu '%-.192s' (errno: %d, %-.128s)"
+ dan "Kan ikke åbne delt bibliotek '%-.192s' (errno: %d, %-.128s)"
+ nla "Kan shared library '%-.192s' niet openen (Errcode: %d, %-.128s)"
+ eng "Can't open shared library '%-.192s' (errno: %d, %-.128s)"
+ jps "shared library '%-.192s' を開く事ができません (errno: %d, %-.128s)",
+ est "Ei suuda avada jagatud teeki '%-.192s' (veakood: %d, %-.128s)"
+ fre "Impossible d'ouvrir la bibliothèque partagée '%-.192s' (errno: %d, %-.128s)"
+ ger "Kann Shared Library '%-.192s' nicht öffnen (Fehler: %d, %-.128s)"
+ greek "Δεν είναι δυνατή η ανάγνωση της shared library '%-.192s' (κωδικός λάθους: %d, %-.128s)"
+ hun "A(z) '%-.192s' megosztott konyvtar nem hasznalhato (hibakod: %d, %-.128s)"
+ ita "Impossibile aprire la libreria condivisa '%-.192s' (errno: %d, %-.128s)"
+ jpn "shared library '%-.192s' を開く事ができません (errno: %d, %-.128s)"
+ kor "'%-.192s' 공유 라이버러리를 열수 없습니다.(에러번호: %d, %-.128s)"
+ nor "Can't open shared library '%-.192s' (errno: %d, %-.128s)"
+ norwegian-ny "Can't open shared library '%-.192s' (errno: %d, %-.128s)"
+ pol "Can't open shared library '%-.192s' (errno: %d, %-.128s)"
+ por "Não pode abrir biblioteca compartilhada '%-.192s' (erro no. %d, %-.128s)"
+ rum "Nu pot deschide libraria shared '%-.192s' (Eroare: %d, %-.128s)"
+ rus "Невозможно открыть динамическую библиотеку '%-.192s' (ошибка: %d, %-.128s)"
+ serbian "Ne mogu da otvorim share-ovanu biblioteku '%-.192s' (errno: %d, %-.128s)"
+ slo "Nemôžem otvoriť zdieľanú knižnicu '%-.192s' (chybový kód: %d, %-.128s)"
+ spa "No puedo abrir libraria conjugada '%-.192s' (errno: %d, %-.128s)"
+ swe "Kan inte öppna det dynamiska biblioteket '%-.192s' (Felkod: %d, %-.128s)"
+ ukr "Не можу відкрити розділювану бібліотеку '%-.192s' (помилка: %d, %-.128s)"
ER_CANT_FIND_DL_ENTRY
cze "Nemohu naj-Bít funkci '%-.128s' v knihovně"
dan "Kan ikke finde funktionen '%-.128s' i bibliotek"
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 42981e9936c..5ead1914af0 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1265,6 +1265,7 @@ void THD::init(void)
reset_current_stmt_binlog_format_row();
set_status_var_init();
bzero((char *) &org_status_var, sizeof(org_status_var));
+ start_bytes_received= 0;
if (variables.sql_log_bin)
variables.option_bits|= OPTION_BIN_LOG;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index de3357212a3..13e72f11829 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1712,7 +1712,7 @@ public:
/* Used to SLAVE SQL thread */
Rpl_filter* rpl_filter;
- void reset_for_next_command(bool calculate_userstat);
+ void reset_for_next_command();
/*
Constant for THD::where initialization in the beginning of every query.
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 5929f4da41a..9ad1282d8ec 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -742,7 +742,6 @@ bool do_command(THD *thd)
net_new_transaction(net);
-
/* Save for user statistics */
thd->start_bytes_received= thd->status_var.bytes_received;
@@ -960,6 +959,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (!(server_command_flags[command] & CF_SKIP_QUESTIONS))
statistic_increment(thd->status_var.questions, &LOCK_status);
+ /* Copy data for user stats */
+ if ((thd->userstat_running= opt_userstat_running))
+ {
+ thd->start_cpu_time= my_getcputime();
+ memcpy(&thd->org_status_var, &thd->status_var, sizeof(thd->status_var));
+ thd->select_commands= thd->update_commands= thd->other_commands= 0;
+ }
+
/**
Clear the set of flags that are expected to be cleared at the
beginning of each command.
@@ -1211,7 +1218,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
}
packet= arg_end + 1;
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
lex_start(thd);
/* Must be before we init the table list. */
if (lower_case_table_names)
@@ -5747,15 +5754,15 @@ bool my_yyoverflow(short **yyss, YYSTYPE **yyvs, ulong *yystacksize)
@todo Call it after we use THD for queries, not before.
*/
-void mysql_reset_thd_for_next_command(THD *thd, my_bool calculate_userstat)
+void mysql_reset_thd_for_next_command(THD *thd)
{
- thd->reset_for_next_command(calculate_userstat);
+ thd->reset_for_next_command();
}
-void THD::reset_for_next_command(bool calculate_userstat)
+void THD::reset_for_next_command()
{
THD *thd= this;
- DBUG_ENTER("mysql_reset_thd_for_next_command");
+ DBUG_ENTER("THD::reset_for_next_command");
DBUG_ASSERT(!thd->spcont); /* not for substatements of routines */
DBUG_ASSERT(! thd->in_sub_stmt);
DBUG_ASSERT(thd->transaction.on);
@@ -5801,14 +5808,6 @@ void THD::reset_for_next_command(bool calculate_userstat)
thd->sent_row_count= thd->examined_row_count= 0;
thd->accessed_rows_and_keys= 0;
- /* Copy data for user stats */
- if ((thd->userstat_running= calculate_userstat))
- {
- thd->start_cpu_time= my_getcputime();
- memcpy(&thd->org_status_var, &thd->status_var, sizeof(thd->status_var));
- thd->select_commands= thd->update_commands= thd->other_commands= 0;
- }
-
thd->query_plan_flags= QPLAN_INIT;
thd->query_plan_fsort_passes= 0;
@@ -6017,7 +6016,7 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
FIXME: cleanup the dependencies in the code to simplify this.
*/
lex_start(thd);
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
if (query_cache_send_result_to_client(thd, rawbuf, length) <= 0)
{
@@ -6120,7 +6119,7 @@ bool mysql_test_parse_for_slave(THD *thd, char *rawbuf, uint length)
if (!(error= parser_state.init(thd, rawbuf, length)))
{
lex_start(thd);
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
if (!parse_sql(thd, & parser_state, NULL) &&
all_tables_not_ok(thd, lex->select_lex.table_list.first))
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index 16b5280a7c7..b56edf5b4f7 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -85,7 +85,7 @@ bool alloc_query(THD *thd, const char *packet, uint packet_length);
void mysql_init_select(LEX *lex);
void mysql_parse(THD *thd, char *rawbuf, uint length,
Parser_state *parser_state);
-void mysql_reset_thd_for_next_command(THD *thd, my_bool calculate_userstat);
+void mysql_reset_thd_for_next_command(THD *thd);
bool mysql_new_select(LEX *lex, bool move_down);
void create_select_for_variable(const char *var_name);
void create_table_set_open_action_and_adjust_tables(LEX *lex);
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 4b7963f91f4..d311d84d9de 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -635,7 +635,7 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl,
if (plugin_dl->mariaversion < min_maria_plugin_interface_version ||
(plugin_dl->mariaversion >> 8) > (MARIA_PLUGIN_INTERFACE_VERSION >> 8))
{
- report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, 0,
+ report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, ENOEXEC,
"plugin interface version mismatch");
DBUG_RETURN(TRUE);
}
@@ -779,7 +779,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
my_snprintf(buf, sizeof(buf),
"service '%s' interface version mismatch",
list_of_services[i].name);
- report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, 0, buf);
+ report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, ENOEXEC, buf);
goto ret;
}
*(void**)sym= list_of_services[i].service;
@@ -1069,7 +1069,7 @@ static bool plugin_add(MEM_ROOT *tmp_root,
plugin_type_names[plugin->type].str,
" plugin ", tmp.name.str,
" not supported by this version of the server", NullS);
- report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, 0, buf);
+ report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, ENOEXEC, buf);
goto err;
}
if (plugin_maturity_map[plugin->maturity] < plugin_maturity)
@@ -1081,7 +1081,7 @@ static bool plugin_add(MEM_ROOT *tmp_root,
" is prohibited by --plugin-maturity=",
plugin_maturity_names[plugin_maturity],
NullS);
- report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, 0, buf);
+ report_error(report, ER_CANT_OPEN_LIBRARY, dl->str, EPERM, buf);
goto err;
}
tmp.plugin= plugin;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 07b90fd406c..b4a313e344a 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -2276,7 +2276,7 @@ void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length)
DBUG_PRINT("prep_query", ("%s", packet));
/* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
if (! (stmt= new Prepared_statement(thd)))
goto end; /* out of memory: error is set in Sql_alloc */
@@ -2667,7 +2667,7 @@ void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length)
packet+= 9; /* stmt_id + 5 bytes of flags */
/* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
if (!(stmt= find_prepared_statement(thd, stmt_id)))
{
@@ -2766,7 +2766,7 @@ void mysqld_stmt_fetch(THD *thd, char *packet, uint packet_length)
DBUG_ENTER("mysqld_stmt_fetch");
/* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
status_var_increment(thd->status_var.com_stmt_fetch);
if (!(stmt= find_prepared_statement(thd, stmt_id)))
@@ -2826,7 +2826,7 @@ void mysqld_stmt_reset(THD *thd, char *packet)
DBUG_ENTER("mysqld_stmt_reset");
/* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
status_var_increment(thd->status_var.com_stmt_reset);
if (!(stmt= find_prepared_statement(thd, stmt_id)))
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 02ad3b8e0e5..246af046d4f 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -12923,12 +12923,14 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
/*
If we're inside an SJM-nest (current_sjm!=NULL), and the multi-equality
doesn't include a constant, we should produce equality with the first
- of the equals in this SJM.
+ of the equal items in this SJM (except for the first element inside the
+ SJM. For that, we produce the equality with the "head" item).
In other cases, get the "head" item, which is either first of the
equals on top level, or the constant.
*/
- Item *head_item= (!item_const && current_sjm)? current_sjm_head: head;
+ Item *head_item= (!item_const && current_sjm &&
+ current_sjm_head != field_item) ? current_sjm_head: head;
Item *head_real_item= head_item->real_item();
if (head_real_item->type() == Item::FIELD_ITEM)
head_item= head_real_item;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index b61bfe2aa57..ff5f732108b 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2646,7 +2646,8 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
command_name[tmp->command].length, cs);
/* MYSQL_TIME */
ulonglong start_utime= tmp->start_time * HRTIME_RESOLUTION + tmp->start_time_sec_part;
- ulonglong utime= start_utime < unow.val ? unow.val - start_utime : 0;
+ ulonglong utime= start_utime && start_utime < unow.val
+ ? unow.val - start_utime : 0;
table->field[5]->store(utime / HRTIME_RESOLUTION, TRUE);
/* STATE */
if ((val= thread_state_info(tmp)))