mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
P_S 5.7.28
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
@@ -21,12 +21,40 @@
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
|
||||
|
||||
#include "my_global.h"
|
||||
#include "my_pthread.h"
|
||||
#include "my_thread.h"
|
||||
#include "table_threads.h"
|
||||
#include "sql_parse.h"
|
||||
#include "pfs_instr_class.h"
|
||||
#include "pfs_instr.h"
|
||||
|
||||
static const LEX_CSTRING vio_type_names[] =
|
||||
{
|
||||
{ STRING_WITH_LEN("Error") }, // cannot happen
|
||||
{ STRING_WITH_LEN("TCP/IP") },
|
||||
{ STRING_WITH_LEN("Socket") },
|
||||
{ STRING_WITH_LEN("Named Pipe") },
|
||||
{ STRING_WITH_LEN("SSL/TLS") },
|
||||
{ STRING_WITH_LEN("Shared Memory") }
|
||||
};
|
||||
|
||||
static void get_vio_type_name(enum enum_vio_type vio_type, const char **str, int *len)
|
||||
{
|
||||
int index;
|
||||
|
||||
if ((vio_type >= FIRST_VIO_TYPE) && (vio_type <= LAST_VIO_TYPE))
|
||||
{
|
||||
index= vio_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
index= 0;
|
||||
}
|
||||
*str= vio_type_names[index].str;
|
||||
*len= vio_type_names[index].length;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
THR_LOCK table_threads::m_table_lock;
|
||||
|
||||
PFS_engine_table_share
|
||||
@@ -34,11 +62,10 @@ table_threads::m_share=
|
||||
{
|
||||
{ C_STRING_WITH_LEN("threads") },
|
||||
&pfs_updatable_acl,
|
||||
&table_threads::create,
|
||||
table_threads::create,
|
||||
NULL, /* write_row */
|
||||
NULL, /* delete_all_rows */
|
||||
NULL, /* get_row_count */
|
||||
1000, /* records */
|
||||
cursor_by_thread::get_row_count,
|
||||
sizeof(PFS_simple_index), /* ref length */
|
||||
&m_table_lock,
|
||||
{ C_STRING_WITH_LEN("CREATE TABLE threads("
|
||||
@@ -46,7 +73,7 @@ table_threads::m_share=
|
||||
"NAME VARCHAR(128) not null,"
|
||||
"TYPE VARCHAR(10) not null,"
|
||||
"PROCESSLIST_ID BIGINT unsigned,"
|
||||
"PROCESSLIST_USER VARCHAR(16),"
|
||||
"PROCESSLIST_USER VARCHAR(" USERNAME_CHAR_LENGTH_STR "),"
|
||||
"PROCESSLIST_HOST VARCHAR(60),"
|
||||
"PROCESSLIST_DB VARCHAR(64),"
|
||||
"PROCESSLIST_COMMAND VARCHAR(16),"
|
||||
@@ -55,7 +82,11 @@ table_threads::m_share=
|
||||
"PROCESSLIST_INFO LONGTEXT,"
|
||||
"PARENT_THREAD_ID BIGINT unsigned,"
|
||||
"ROLE VARCHAR(64),"
|
||||
"INSTRUMENTED ENUM ('YES', 'NO') not null)") }
|
||||
"INSTRUMENTED ENUM ('YES', 'NO') not null,"
|
||||
"HISTORY ENUM ('YES', 'NO') not null,"
|
||||
"CONNECTION_TYPE VARCHAR(16)"
|
||||
"THREAD_OS_ID BIGINT unsigned)") },
|
||||
false /* perpetual */
|
||||
};
|
||||
|
||||
PFS_engine_table* table_threads::create()
|
||||
@@ -70,9 +101,9 @@ table_threads::table_threads()
|
||||
|
||||
void table_threads::make_row(PFS_thread *pfs)
|
||||
{
|
||||
pfs_lock lock;
|
||||
pfs_lock session_lock;
|
||||
pfs_lock stmt_lock;
|
||||
pfs_optimistic_state lock;
|
||||
pfs_optimistic_state session_lock;
|
||||
pfs_optimistic_state stmt_lock;
|
||||
PFS_stage_class *stage_class;
|
||||
PFS_thread_class *safe_class;
|
||||
|
||||
@@ -88,6 +119,7 @@ void table_threads::make_row(PFS_thread *pfs)
|
||||
m_row.m_thread_internal_id= pfs->m_thread_internal_id;
|
||||
m_row.m_parent_thread_internal_id= pfs->m_parent_thread_internal_id;
|
||||
m_row.m_processlist_id= pfs->m_processlist_id;
|
||||
m_row.m_thread_os_id= pfs->m_thread_os_id;
|
||||
m_row.m_name= safe_class->m_name;
|
||||
m_row.m_name_length= safe_class->m_name_length;
|
||||
|
||||
@@ -165,8 +197,12 @@ void table_threads::make_row(PFS_thread *pfs)
|
||||
{
|
||||
m_row.m_processlist_state_length= 0;
|
||||
}
|
||||
m_row.m_connection_type = pfs->m_connection_type;
|
||||
|
||||
m_row.m_enabled_ptr= &pfs->m_enabled;
|
||||
|
||||
m_row.m_enabled= pfs->m_enabled;
|
||||
m_row.m_history= pfs->m_history;
|
||||
m_row.m_psi= pfs;
|
||||
|
||||
if (pfs->m_lock.end_optimistic_lock(& lock))
|
||||
m_row_exists= true;
|
||||
@@ -178,6 +214,8 @@ int table_threads::read_row_values(TABLE *table,
|
||||
bool read_all)
|
||||
{
|
||||
Field *f;
|
||||
const char *str= NULL;
|
||||
int len= 0;
|
||||
|
||||
if (unlikely(! m_row_exists))
|
||||
return HA_ERR_RECORD_DELETED;
|
||||
@@ -250,23 +288,16 @@ int table_threads::read_row_values(TABLE *table,
|
||||
f->set_null();
|
||||
break;
|
||||
case 9: /* PROCESSLIST_STATE */
|
||||
/* This column's datatype is declared as varchar(64). Thread's state
|
||||
message cannot be more than 64 characters. Otherwise, we will end up
|
||||
in 'data truncated' warning/error (depends sql_mode setting) when
|
||||
server is updating this column for those threads. To prevent this
|
||||
kind of issue, an assert is added.
|
||||
*/
|
||||
DBUG_ASSERT(m_row.m_processlist_state_length <= f->char_length());
|
||||
if (m_row.m_processlist_state_length > 0)
|
||||
{
|
||||
/* This column's datatype is declared as varchar(64). But in current
|
||||
code, there are few process state messages which are greater than
|
||||
64 characters(Eg:stage_slave_has_read_all_relay_log).
|
||||
In those cases, we will end up in 'data truncated'
|
||||
warning/error (depends sql_mode setting) when server is updating
|
||||
this column for those threads. Since 5.6 is GAed, neither the
|
||||
metadata of this column can be changed, nor those state messages.
|
||||
So server will silently truncate the state message to 64 characters
|
||||
if it is longer. In Upper versions(5.7+), these state messages are
|
||||
changed to less than or equal to 64 characters.
|
||||
*/
|
||||
set_field_varchar_utf8(f, m_row.m_processlist_state_ptr,
|
||||
MY_MIN(m_row.m_processlist_state_length,
|
||||
f->char_length()));
|
||||
}
|
||||
m_row.m_processlist_state_length);
|
||||
else
|
||||
f->set_null();
|
||||
break;
|
||||
@@ -287,7 +318,23 @@ int table_threads::read_row_values(TABLE *table,
|
||||
f->set_null();
|
||||
break;
|
||||
case 13: /* INSTRUMENTED */
|
||||
set_field_enum(f, (*m_row.m_enabled_ptr) ? ENUM_YES : ENUM_NO);
|
||||
set_field_enum(f, m_row.m_enabled ? ENUM_YES : ENUM_NO);
|
||||
break;
|
||||
case 14: /* HISTORY */
|
||||
set_field_enum(f, m_row.m_history ? ENUM_YES : ENUM_NO);
|
||||
break;
|
||||
case 15: /* CONNECTION_TYPE */
|
||||
get_vio_type_name(m_row.m_connection_type, & str, & len);
|
||||
if (len > 0)
|
||||
set_field_varchar_utf8(f, str, len);
|
||||
else
|
||||
f->set_null();
|
||||
break;
|
||||
case 16: /* THREAD_OS_ID */
|
||||
if (m_row.m_thread_os_id > 0)
|
||||
set_field_ulonglong(f, m_row.m_thread_os_id);
|
||||
else
|
||||
f->set_null();
|
||||
break;
|
||||
default:
|
||||
DBUG_ASSERT(false);
|
||||
@@ -327,8 +374,15 @@ int table_threads::update_row_values(TABLE *table,
|
||||
return HA_ERR_WRONG_COMMAND;
|
||||
case 13: /* INSTRUMENTED */
|
||||
value= (enum_yes_no) get_field_enum(f);
|
||||
*m_row.m_enabled_ptr= (value == ENUM_YES) ? true : false;
|
||||
m_row.m_psi->set_enabled((value == ENUM_YES) ? true : false);
|
||||
break;
|
||||
case 14: /* HISTORY */
|
||||
value= (enum_yes_no) get_field_enum(f);
|
||||
m_row.m_psi->set_history((value == ENUM_YES) ? true : false);
|
||||
break;
|
||||
case 15: /* CONNECTION_TYPE */
|
||||
case 16: /* THREAD_OS_ID */
|
||||
return HA_ERR_WRONG_COMMAND;
|
||||
default:
|
||||
DBUG_ASSERT(false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user