summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc111
1 files changed, 16 insertions, 95 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 718d2424463..e3884922587 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -519,100 +519,6 @@ extern "C"
}
-/**
- Dumps a text description of a thread, its security context
- (user, host) and the current query.
-
- @param thd thread context
- @param buffer pointer to preferred result buffer
- @param length length of buffer
- @param max_query_len how many chars of query to copy (0 for all)
-
- @return Pointer to string
-*/
-
-extern "C"
-char *thd_get_error_context_description(THD *thd, char *buffer,
- unsigned int length,
- unsigned int max_query_len)
-{
- String str(buffer, length, &my_charset_latin1);
- const Security_context *sctx= &thd->main_security_ctx;
- char header[256];
- size_t len;
-
- /*
- The pointers thd->query and thd->proc_info might change since they are
- being modified concurrently. This is acceptable for proc_info since its
- values doesn't have to very accurate and the memory it points to is static,
- but we need to attempt a snapshot on the pointer values to avoid using NULL
- values. The pointer to thd->query however, doesn't point to static memory
- and has to be protected by thd->LOCK_thd_data or risk pointing to
- uninitialized memory.
- */
- const char *proc_info= thd->proc_info;
-
- len= my_snprintf(header, sizeof(header),
- "MySQL thread id %u, OS thread handle %lu, query id %llu",
- (uint)thd->thread_id, (ulong) thd->real_id, (ulonglong) thd->query_id);
- str.length(0);
- str.append(header, len);
-
- if (sctx->host)
- {
- str.append(' ');
- str.append(sctx->host);
- }
-
- if (sctx->ip)
- {
- str.append(' ');
- str.append(sctx->ip);
- }
-
- if (sctx->user)
- {
- str.append(' ');
- str.append(sctx->user);
- }
-
- if (proc_info)
- {
- str.append(' ');
- str.append(proc_info);
- }
-
- /* Don't wait if LOCK_thd_data is used as this could cause a deadlock */
- if (!mysql_mutex_trylock(&thd->LOCK_thd_data))
- {
- if (thd->query())
- {
- if (max_query_len < 1)
- len= thd->query_length();
- else
- len= MY_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
- mysql_mutex_unlock(&thd->LOCK_thd_data);
- }
-
- if (str.c_ptr_safe() == buffer)
- return buffer;
-
- /*
- We have to copy the new string to the destination buffer because the string
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
- length= MY_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
- return buffer;
-}
-
-
#if MARIA_PLUGIN_INTERFACE_VERSION < 0x0200
/**
TODO: This function is for API compatibility, remove it eventually.
@@ -1305,7 +1211,7 @@ void THD::init(bool skip_lock)
bzero((char *) &org_status_var, sizeof(org_status_var));
status_in_global= 0;
start_bytes_received= 0;
- last_commit_gtid.seq_no= 0;
+ m_last_commit_gtid.seq_no= 0;
last_stmt= NULL;
/* Reset status of last insert id */
arg_of_last_insert_id_function= FALSE;
@@ -7352,6 +7258,21 @@ THD::signal_wakeup_ready()
mysql_cond_signal(&COND_wakeup_ready);
}
+void THD::set_last_commit_gtid(rpl_gtid &gtid)
+{
+#ifndef EMBEDDED_LIBRARY
+ bool changed_gtid= (m_last_commit_gtid.seq_no != gtid.seq_no);
+#endif
+ m_last_commit_gtid= gtid;
+#ifndef EMBEDDED_LIBRARY
+ if (changed_gtid &&
+ session_tracker.get_tracker(SESSION_SYSVARS_TRACKER)->is_enabled())
+ {
+ session_tracker.get_tracker(SESSION_SYSVARS_TRACKER)->
+ mark_as_changed(this, (LEX_CSTRING*)Sys_last_gtid_ptr);
+ }
+#endif
+}
void
wait_for_commit::reinit()