diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-07-21 16:39:19 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-07-21 16:39:19 +0200 |
commit | b7b5f6f1ab49948b0e15b762266d4640b3d6b7fb (patch) | |
tree | 7c302c2025184dbd053aa6135f0ff28c8ce6f359 /storage/perfschema/table_threads.cc | |
parent | 5f6380adde2dac3f32b40339b9b702c0135eb7d6 (diff) | |
parent | c1d6a2d7e194225ccc19a68ea5d0f368632620d0 (diff) | |
download | mariadb-git-b7b5f6f1ab49948b0e15b762266d4640b3d6b7fb.tar.gz |
10.0-monty merge
includes:
* remove some remnants of "Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING"
* introduce LOCK_share, now LOCK_ha_data is strictly for engines
* rea_create_table() always creates .par file (even in "frm-only" mode)
* fix a 5.6 bug, temp file leak on dummy ALTER TABLE
Diffstat (limited to 'storage/perfschema/table_threads.cc')
-rw-r--r-- | storage/perfschema/table_threads.cc | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/storage/perfschema/table_threads.cc b/storage/perfschema/table_threads.cc index 2104c24b65c..ef6c272c0a2 100644 --- a/storage/perfschema/table_threads.cc +++ b/storage/perfschema/table_threads.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2013, 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 as published by @@ -26,7 +26,7 @@ static const TABLE_FIELD_TYPE field_types[]= { { { C_STRING_WITH_LEN("THREAD_ID") }, - { C_STRING_WITH_LEN("int(11)") }, + { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { @@ -41,7 +41,7 @@ static const TABLE_FIELD_TYPE field_types[]= }, { { C_STRING_WITH_LEN("PROCESSLIST_ID") }, - { C_STRING_WITH_LEN("int(11)") }, + { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { @@ -81,7 +81,7 @@ static const TABLE_FIELD_TYPE field_types[]= }, { { C_STRING_WITH_LEN("PARENT_THREAD_ID") }, - { C_STRING_WITH_LEN("int(11)") }, + { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { @@ -129,6 +129,7 @@ table_threads::table_threads() void table_threads::make_row(PFS_thread *pfs) { pfs_lock lock; + pfs_lock processlist_lock; PFS_thread_class *safe_class; m_row_exists= false; @@ -142,7 +143,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_thread_id= pfs->m_thread_id; + m_row.m_processlist_id= pfs->m_processlist_id; m_row.m_name= safe_class->m_name; m_row.m_name_length= safe_class->m_name_length; @@ -166,12 +167,30 @@ void table_threads::make_row(PFS_thread *pfs) m_row.m_command= pfs->m_command; m_row.m_start_time= pfs->m_start_time; + + /* Protect this reader against attribute changes. */ + pfs->m_processlist_lock.begin_optimistic_lock(&processlist_lock); + /* FIXME: need to copy it ? */ m_row.m_processlist_state_ptr= pfs->m_processlist_state_ptr; m_row.m_processlist_state_length= pfs->m_processlist_state_length; /* FIXME: need to copy it ? */ m_row.m_processlist_info_ptr= pfs->m_processlist_info_ptr; m_row.m_processlist_info_length= pfs->m_processlist_info_length; + + if (! pfs->m_processlist_lock.end_optimistic_lock(& processlist_lock)) + { + /* + Columns PROCESSLIST_STATE or PROCESSLIST_INFO are being + updated while we read them, and are unsafe to use. + Do not discard the entire row. + Do not loop waiting for a stable value. + Just return NULL values for these columns. + */ + m_row.m_processlist_state_length= 0; + m_row.m_processlist_info_length= 0; + } + m_row.m_enabled_ptr= &pfs->m_enabled; if (pfs->m_lock.end_optimistic_lock(& lock)) @@ -200,20 +219,20 @@ int table_threads::read_row_values(TABLE *table, switch(f->field_index) { case 0: /* THREAD_ID */ - set_field_ulong(f, m_row.m_thread_internal_id); + set_field_ulonglong(f, m_row.m_thread_internal_id); break; case 1: /* NAME */ set_field_varchar_utf8(f, m_row.m_name, m_row.m_name_length); break; case 2: /* TYPE */ - if (m_row.m_thread_id != 0) + if (m_row.m_processlist_id != 0) set_field_varchar_utf8(f, "FOREGROUND", 10); else set_field_varchar_utf8(f, "BACKGROUND", 10); break; case 3: /* PROCESSLIST_ID */ - if (m_row.m_thread_id != 0) - set_field_ulong(f, m_row.m_thread_id); + if (m_row.m_processlist_id != 0) + set_field_ulonglong(f, m_row.m_processlist_id); else f->set_null(); break; @@ -239,7 +258,7 @@ int table_threads::read_row_values(TABLE *table, f->set_null(); break; case 7: /* PROCESSLIST_COMMAND */ - if (m_row.m_thread_id != 0) + if (m_row.m_processlist_id != 0) set_field_varchar_utf8(f, command_name[m_row.m_command].str, command_name[m_row.m_command].length); else @@ -271,7 +290,7 @@ int table_threads::read_row_values(TABLE *table, break; case 11: /* PARENT_THREAD_ID */ if (m_row.m_parent_thread_internal_id != 0) - set_field_ulong(f, m_row.m_parent_thread_internal_id); + set_field_ulonglong(f, m_row.m_parent_thread_internal_id); else f->set_null(); break; |