Skip to content

Commit 6daa276

Browse files
committed
Bug#33607959 CODE CLEANUP FOR pfs_processlist_enabled
This fix is a code cleanup, no change in behavior. Before this fix, the variable pfs_processlist_enabled was located inside the performance_schema implementation. This is incorrect, as pfs_processlist_enabled: - does not control the instrumentation itself - only controls the behavior of SHOW PROCESSLIST in the SQL layer. This fix moves pfs_processlist_enabled to the SQL layer, and removes dead code. Change-Id: Icfee49e94e26f30715a13b0508d8bf840bbc1517
1 parent 652da12 commit 6daa276

9 files changed

+19
-33
lines changed

sql/log_event.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include "sql/my_decimal.h" // my_decimal
7272
#include "sql/rpl_handler.h" // RUN_HOOK
7373
#include "sql/rpl_tblmap.h"
74+
#include "sql/sql_show_processlist.h" // pfs_processlist_enabled
7475
#include "sql/system_variables.h"
7576
#include "sql/tc_log.h"
7677
#include "sql_const.h"
@@ -174,8 +175,6 @@ PSI_memory_key key_memory_log_event;
174175
PSI_memory_key key_memory_Incident_log_event_message;
175176
PSI_memory_key key_memory_Rows_query_log_event_rows_query;
176177

177-
extern bool pfs_processlist_enabled;
178-
179178
using std::max;
180179
using std::min;
181180

sql/parse_tree_nodes.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@
9393
#include "sql_string.h"
9494
#include "template_utils.h"
9595

96-
extern bool pfs_processlist_enabled;
97-
9896
namespace {
9997

10098
template <typename Context, typename Node>
@@ -2348,8 +2346,11 @@ Sql_cmd *PT_show_processlist::make_cmd(THD *thd) {
23482346
LEX *lex = thd->lex;
23492347
lex->sql_command = m_sql_command;
23502348

2351-
m_sql_cmd.set_use_pfs(pfs_processlist_enabled);
2352-
if (pfs_processlist_enabled) {
2349+
// Read once, to avoid race conditions.
2350+
bool use_pfs = pfs_processlist_enabled;
2351+
2352+
m_sql_cmd.set_use_pfs(use_pfs);
2353+
if (use_pfs) {
23532354
if (build_processlist_query(m_pos, thd, m_sql_cmd.verbose()))
23542355
return nullptr;
23552356
}

sql/sql_show.h

-3
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ class Sql_cmd_show : public Sql_cmd_select {
162162
bool execute(THD *thd) override;
163163

164164
protected:
165-
// Use for SHOW commands that operate on a single table.
166-
bool check_privileges_for_table(THD *thd, bool is_temporary);
167165
enum_sql_command m_sql_command;
168166
};
169167

@@ -475,7 +473,6 @@ class Sql_cmd_show_processlist : public Sql_cmd_show {
475473

476474
private:
477475
bool use_pfs() { return m_use_pfs; }
478-
bool execute_with_performance_schema(THD *thd);
479476

480477
const bool m_verbose{false};
481478
bool m_use_pfs{false};

sql/sql_show_processlist.cc

+7-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
along with this program; if not, write to the Free Software
2121
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2222

23-
#include "sql/sql_show_processlist.h"
24-
2523
#include <stddef.h>
2624

25+
#include "sql/sql_show_processlist.h"
26+
2727
#include "lex_string.h"
2828
#include "m_string.h" // STRING_WITH_LEN
2929
#include "sql/auth/auth_acls.h"
@@ -40,7 +40,10 @@
4040
#include "sql/strfunc.h"
4141
#include "sql_string.h"
4242

43-
extern bool pfs_processlist_enabled;
43+
/**
44+
Implement SHOW PROCESSLIST by using performance schema.processlist
45+
*/
46+
bool pfs_processlist_enabled = false;
4447

4548
static const LEX_CSTRING field_id = {STRING_WITH_LEN("ID")};
4649
static const LEX_CSTRING alias_id = {STRING_WITH_LEN("Id")};
@@ -143,7 +146,7 @@ bool build_processlist_query(const POS &pos, THD *thd, bool verbose) {
143146
new (thd->mem_root) PTI_simple_ident_ident(pos, field_info);
144147
if (ident_info == nullptr) return true;
145148

146-
/* Info length is either "25" or "100" depending on verbose */
149+
/* Info length is either "100" or "1024" depending on verbose */
147150
Item_int *item_info_len = new (thd->mem_root) Item_int(pos, info_len);
148151
if (item_info_len == nullptr) return true;
149152

sql/sql_show_processlist.h

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
class THD;
2929

30+
extern bool pfs_processlist_enabled;
31+
3032
bool build_processlist_query(const POS &pos, THD *thd, bool verbose);
3133

3234
#endif /* SQL_SHOW_PROCESSLIST_H */

sql/sys_vars.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@
126126
#include "sql/sp_head.h" // SP_PSI_STATEMENT_INFO_COUNT
127127
#include "sql/sql_backup_lock.h" // is_instance_backup_locked
128128
#include "sql/sql_lex.h"
129-
#include "sql/sql_locale.h" // my_locale_by_number
130-
#include "sql/sql_parse.h" // killall_non_super_threads
131-
#include "sql/sql_tmp_table.h" // internal_tmp_mem_storage_engine_names
129+
#include "sql/sql_locale.h" // my_locale_by_number
130+
#include "sql/sql_parse.h" // killall_non_super_threads
131+
#include "sql/sql_show_processlist.h" // pfs_processlist_enabled
132+
#include "sql/sql_tmp_table.h" // internal_tmp_mem_storage_engine_names
132133
#include "sql/ssl_acceptor_context_operator.h"
133134
#include "sql/system_variables.h"
134135
#include "sql/table_cache.h" // Table_cache_manager

storage/perfschema/pfs_instr_class.cc

-8
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,6 @@
6666
*/
6767
bool pfs_enabled = true;
6868

69-
/**
70-
Global flag used to enable and disable SHOW PROCESSLIST in the
71-
performance schema. This flag only takes effect if the performance schema
72-
is configured to support SHOW PROCESSLIST.
73-
@sa performance-schema-enable-processlist
74-
*/
75-
bool pfs_processlist_enabled = false;
76-
7769
/**
7870
Global performance schema reference count for plugin and component events.
7971
Incremented when a shared library is being unloaded, decremented when

storage/perfschema/pfs_instr_class.h

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class PFS_opaque_container_page;
8282
*/
8383

8484
extern bool pfs_enabled;
85-
extern bool pfs_processlist_enabled;
8685

8786
/** Global ref count for plugin and component events. */
8887
extern std::atomic<uint32> pfs_unload_plugin_ref_count;

storage/perfschema/pfs_server.h

-8
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,6 @@ struct PFS_global_param {
296296
*/
297297
extern PFS_global_param pfs_param;
298298

299-
/**
300-
Global flag used to enable and disable SHOW PROCESSLIST in the
301-
performance schema. This flag only takes effect if the performance schema
302-
is configured to support SHOW PROCESSLIST.
303-
@sa performance-schema-enable-processlist
304-
*/
305-
extern bool pfs_processlist_enabled;
306-
307299
/**
308300
Null initialization.
309301
Disable all instrumentation, size all internal buffers to 0.

0 commit comments

Comments
 (0)