summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-10-28 07:50:05 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-10-28 07:50:05 +0300
commit657bcf928eb1c6a80ee2c82f0dcdd59ab02927e4 (patch)
treec692f1600c06da934cf44240228516eed88c868f /sql
parente97b785d764f85009412947600195001be01a706 (diff)
parent563daec123728f69dc56d898d1d8b198e9e2d411 (diff)
downloadmariadb-git-657bcf928eb1c6a80ee2c82f0dcdd59ab02927e4.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/item_timefunc.cc1
-rw-r--r--sql/protocol.cc19
-rw-r--r--sql/sql_explain.cc2
-rw-r--r--sql/sql_insert.cc14
-rw-r--r--sql/sql_string.cc2
-rw-r--r--sql/sys_vars.cc18
6 files changed, 30 insertions, 26 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index cb5754c3b05..c36b42c206a 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2823,7 +2823,6 @@ bool Item_func_timediff::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
DBUG_ASSERT(fixed == 1);
int l_sign= 1;
MYSQL_TIME l_time1,l_time2,l_time3;
- ErrConvTime str(&l_time3);
/* the following may be true in, for example, date_add(timediff(...), ... */
if (fuzzy_date & TIME_NO_ZERO_IN_DATE)
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 26cc686ad0a..a4a70e71fa3 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -218,8 +218,6 @@ net_send_ok(THD *thd,
NET *net= &thd->net;
StringBuffer<MYSQL_ERRMSG_SIZE + 10> store;
- bool state_changed= false;
-
bool error= FALSE;
DBUG_ENTER("net_send_ok");
@@ -246,6 +244,11 @@ net_send_ok(THD *thd,
/* last insert id */
store.q_net_store_length(id);
+ /* if client has not session tracking capability, don't send state change flag*/
+ if (!(thd->client_capabilities & CLIENT_SESSION_TRACK)) {
+ server_status &= ~SERVER_SESSION_STATE_CHANGED;
+ }
+
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{
DBUG_PRINT("info",
@@ -266,21 +269,17 @@ net_send_ok(THD *thd,
}
thd->get_stmt_da()->set_overwrite_status(true);
- state_changed=
- (thd->client_capabilities & CLIENT_SESSION_TRACK) &&
- (server_status & SERVER_SESSION_STATE_CHANGED);
-
- if (state_changed || (message && message[0]))
+ if ((server_status & SERVER_SESSION_STATE_CHANGED) || (message && message[0]))
{
DBUG_ASSERT(safe_strlen(message) <= MYSQL_ERRMSG_SIZE);
store.q_net_store_data((uchar*) safe_str(message), safe_strlen(message));
}
- if (unlikely(state_changed))
+ if (unlikely(server_status & SERVER_SESSION_STATE_CHANGED))
{
store.set_charset(thd->variables.collation_database);
-
thd->session_tracker.store(thd, &store);
+ thd->server_status&= ~SERVER_SESSION_STATE_CHANGED;
}
DBUG_ASSERT(store.length() <= MAX_PACKET_LENGTH);
@@ -289,8 +288,6 @@ net_send_ok(THD *thd,
if (likely(!error) && (!skip_flush || is_eof))
error= net_flush(net);
- thd->server_status&= ~SERVER_SESSION_STATE_CHANGED;
-
thd->get_stmt_da()->set_overwrite_status(false);
DBUG_PRINT("info", ("OK sent, so no more error sending allowed"));
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 95ff94273b4..3a29826ee2a 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1794,7 +1794,7 @@ void Explain_table_access::print_explain_json(Explain_query *query,
/*
- Elements in this array match members of enum Extra_tag, defined in
+ Elements in this array match members of enum explain_extra_tag, defined in
sql_explain.h
*/
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 201567c0853..a9f5c01ed41 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -4849,12 +4849,6 @@ void select_create::abort_result_set()
/* possible error of writing binary log is ignored deliberately */
(void) thd->binlog_flush_pending_rows_event(TRUE, TRUE);
- if (create_info->table_was_deleted)
- {
- /* Unlock locked table that was dropped by CREATE */
- thd->locked_tables_list.unlock_locked_table(thd,
- create_info->mdl_ticket);
- }
if (table)
{
bool tmp_table= table->s->tmp_table;
@@ -4893,5 +4887,13 @@ void select_create::abort_result_set()
tmp_table);
}
}
+
+ if (create_info->table_was_deleted)
+ {
+ /* Unlock locked table that was dropped by CREATE. */
+ (void) trans_rollback_stmt(thd);
+ thd->locked_tables_list.unlock_locked_table(thd, create_info->mdl_ticket);
+ }
+
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 2b40a72edf3..3195f797e25 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -433,7 +433,7 @@ bool String::copy(const char *str, size_t arg_length,
{
uint32 offset;
- DBUG_ASSERT(!str || str != Ptr);
+ DBUG_ASSERT(!str || str != Ptr || !alloced);
if (!needs_conversion(arg_length, from_cs, to_cs, &offset))
{
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 86d02fe11c5..5fe0fb69963 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -4388,12 +4388,16 @@ static Sys_var_session_special Sys_identity(
*/
static bool update_insert_id(THD *thd, set_var *var)
{
- if (!var->value)
- {
- my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str);
- return true;
- }
- thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
+ /*
+ If we set the insert_id to the DEFAULT or 0
+ it means we 'reset' it so it's value doesn't
+ affect the INSERT.
+ */
+ if (!var->value ||
+ var->save_result.ulonglong_value == 0)
+ thd->auto_inc_intervals_forced.empty();
+ else
+ thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
return false;
}
@@ -4401,6 +4405,8 @@ static ulonglong read_insert_id(THD *thd)
{
return thd->auto_inc_intervals_forced.minimum();
}
+
+
static Sys_var_session_special Sys_insert_id(
"insert_id", "The value to be used by the following INSERT "
"or ALTER TABLE statement when inserting an AUTO_INCREMENT value",