Skip to content

Commit

Permalink
Merge branch 'merge-perfschema-5.7' into 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Aug 2, 2022
2 parents 4d0c53a + 61d08f7 commit b043e10
Show file tree
Hide file tree
Showing 308 changed files with 4,683 additions and 404 deletions.
2 changes: 1 addition & 1 deletion include/mysql/psi/mysql_file.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
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,
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/mysql_idle.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2011, 2021, Oracle and/or its affiliates
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/mysql_mdl.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2012, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
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,
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/mysql_memory.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2012, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
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,
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/mysql_ps.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
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,
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/mysql_socket.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2010, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/mysql_sp.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2013, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
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,
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/mysql_stage.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2010, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
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,
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/mysql_statement.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2010, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
Expand Down
9 changes: 8 additions & 1 deletion include/mysql/psi/mysql_thread.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -1339,6 +1339,13 @@ static inline void inline_mysql_thread_set_psi_THD(THD *thd)
}
#endif /* __cplusplus */

static inline void mysql_thread_set_peer_port(uint port __attribute__ ((unused))) {
#ifdef HAVE_PSI_THREAD_INTERFACE
struct PSI_thread *psi = PSI_THREAD_CALL(get_thread)();
PSI_THREAD_CALL(set_thread_peer_port)(psi, port);
#endif
}

#endif

#endif /* DISABLE_MYSQL_THREAD_H */
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/mysql_transaction.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2013, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
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,
Expand Down
13 changes: 12 additions & 1 deletion include/mysql/psi/psi.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
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,
Expand Down Expand Up @@ -1692,6 +1692,15 @@ typedef void (*set_thread_info_v1_t)(const char* info, uint info_len);
*/
typedef void (*set_thread_v1_t)(struct PSI_thread *thread);

/**
Assign the remote (peer) port to the instrumented thread.
@param thread pointer to the thread instrumentation
@param port the remote port
*/
typedef void (*set_thread_peer_port_v1_t)(PSI_thread *thread,
unsigned int port);

/** Delete the current thread instrumentation. */
typedef void (*delete_current_thread_v1_t)(void);

Expand Down Expand Up @@ -2737,6 +2746,8 @@ struct PSI_v1

start_metadata_wait_v1_t start_metadata_wait;
end_metadata_wait_v1_t end_metadata_wait;

set_thread_peer_port_v1_t set_thread_peer_port;
};

/** @} (end of group Group_PSI_v1) */
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/psi_abi_v0.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2011, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
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,
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/psi_abi_v1.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
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,
Expand Down
3 changes: 3 additions & 0 deletions include/mysql/psi/psi_abi_v1.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@
typedef void (*set_thread_state_v1_t)(const char* state);
typedef void (*set_thread_info_v1_t)(const char* info, uint info_len);
typedef void (*set_thread_v1_t)(struct PSI_thread *thread);
typedef void (*set_thread_peer_port_v1_t)(PSI_thread *thread,
unsigned int port);
typedef void (*delete_current_thread_v1_t)(void);
typedef void (*delete_thread_v1_t)(struct PSI_thread *thread);
typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t)
Expand Down Expand Up @@ -829,6 +831,7 @@
destroy_metadata_lock_v1_t destroy_metadata_lock;
start_metadata_wait_v1_t start_metadata_wait;
end_metadata_wait_v1_t end_metadata_wait;
set_thread_peer_port_v1_t set_thread_peer_port;
};
typedef struct PSI_v1 PSI;
typedef struct PSI_mutex_info_v1 PSI_mutex_info;
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/psi_abi_v2.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
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,
Expand Down
8 changes: 7 additions & 1 deletion include/mysql/psi/psi_base.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
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,
Expand Down Expand Up @@ -94,6 +94,12 @@ extern "C" {
*/
#define PSI_FLAG_VOLATILITY_SESSION (1 << 6)

/**
System thread flag.
Indicates that the instrumented object exists on a system thread.
*/
#define PSI_FLAG_THREAD_SYSTEM (1 << 9)

#ifdef HAVE_PSI_INTERFACE

/**
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/psi_memory.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2013, 2021, Oracle and/or its affiliates.
/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
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,
Expand Down
2 changes: 2 additions & 0 deletions include/pfs_thread_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ void pfs_set_thread_info_v1(const char* info, uint info_len);

void pfs_set_thread_v1(PSI_thread* thread);

void pfs_set_thread_peer_port_v1(PSI_thread *thread, uint port);

void pfs_delete_current_thread_v1(void);

void pfs_delete_thread_v1(PSI_thread *thread);
Expand Down
36 changes: 36 additions & 0 deletions mysql-test/include/have_query_cache_disabled.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Skip the test if 'query cache' is disabled.
# Note : There are 2 techniques to disable query cache :
# (1) Set query_cache_type to 0 or OFF
# (2) Set query_cache_size to 0

disable_query_log;

let $do_skip=0;

let $qc_var_1= query_get_value("SELECT COUNT(*) AS var1 FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME = 'have_query_cache' AND variable_value = 'YES'", var1, 1);
if ($qc_var_1 == 1)
{
let $do_skip=1;
}

# Check if 'query_cache_type' is OFF
let $qc_var_2= query_get_value("SELECT COUNT(*) AS var2 FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME = 'query_cache_type' AND VARIABLE_VALUE = 'OFF'", var2, 1);
if ($qc_var_2 == 1)
{
let $do_skip=0;
}

# Check if 'query_cache_size' is 0
let $qc_var_3= query_get_value("SELECT COUNT(*) AS var3 FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME = 'query_cache_size' AND VARIABLE_VALUE = 0", var3, 1);

if ($qc_var_3 == 1)
{
let $do_skip=0;
}

if ($do_skip)
{
skip Query Cache enabled, skipping test;
}

enable_query_log;
10 changes: 10 additions & 0 deletions mysql-test/suite/perfschema/disabled.def
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,13 @@ show_misc: todo
show_plugin: todo

status_reprepare:why P_S filters out Com_* variables?

processlist: todo
processlist_acl: todo
processlist_port: todo
processlist_no_pfs: todo
ddl_processlist: todo
dml_processlist: todo
processlist_57: todo
processlist_anonymous: todo
processlist_reg_user: todo
39 changes: 39 additions & 0 deletions mysql-test/suite/perfschema/include/processlist_load.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ../include/processlist_load.inc
#
# SUMMARY
#
# Execute PROCESSLIST queries, sorted by user
#
# USAGE
#
# Example: Using processlist_set.inc to set @@global.performance_schema_show_processlist
#
# let $pfs_spl = on/off
# --source ../include/processlist_set.inc
# --source ../include/processlist_load.inc
#
# Columns
# 1 <Id> 2 <User> 3 <Host> 4 <db> 5 <Command> 6 <Time> 7 <State> 8 <Info>

# Sort SHOW PROCESSLIST by User instead of Id because Id is not zero-padded
# Unique usernames give best results
--echo
--replace_column 1 <Id> 3 <Host> 6 <Time> 7 <State>
--replace_regex /Daemon/<Command>/ /Connect/<Command>/ /Sleep/<Command>/
--sorted_result
SHOW FULL PROCESSLIST;

--echo
--echo # Performance Schema processlist table
--echo
--replace_column 1 <Id> 3 <Host> 6 <Time> 7 <State>
--replace_regex /Daemon/<Command>/ /Connect/<Command>/ /Sleep/<Command>/
select * from performance_schema.processlist order by user, id;

--echo
--echo # Information Schema processlist table
--echo
--replace_column 1 <Id> 3 <Host> 6 <Time> 7 <State>
--replace_regex /Daemon/<Command>/ /Connect/<Command>/ /Sleep/<Command>/
select * from information_schema.processlist order by user, id;

17 changes: 17 additions & 0 deletions mysql-test/suite/perfschema/include/processlist_set.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ../include/processlist_set.inc
#
# SUMMARY
#
# Set the value of performance_schema_show_proceslist then
# wait for the operation to complete
#
# USAGE
#
# let $pfs_spl = on;
# --source ../include/processlist_set.inc

eval set @@global.performance_schema_show_processlist = $pfs_spl;

let $wait_condition = show variables where variable_name like '%show_processlist%' and value = '$pfs_spl';
--source include/wait_condition.inc

20 changes: 20 additions & 0 deletions mysql-test/suite/perfschema/r/ddl_processlist.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
select @@global.performance_schema_show_processlist into @save_processlist;
set @@global.performance_schema_show_processlist = 'on';
alter table performance_schema.processlist
add column foo integer;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
truncate table performance_schema.processlist;
ERROR HY000: Invalid performance_schema usage.
alter table performance_schema.processlist
add index test_index(info);
ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
create unique index test_index
on performance_schema.processlist(host);
ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
drop index `PRIMARY`
on performance_schema.processlist;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
CREATE TABLE test.create_select
AS SELECT * from performance_schema.processlist;
DROP TABLE test.create_select;
set @@global.performance_schema_show_processlist = @save_processlist;
24 changes: 24 additions & 0 deletions mysql-test/suite/perfschema/r/dml_processlist.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
select @@global.performance_schema_show_processlist into @save_processlist;
set @@global.performance_schema_show_processlist = 'on';
select * from performance_schema.processlist
where user like 'event_scheduler';
select * from performance_schema.processlist
where user = 'FOO';
insert into performance_schema.processlist
values (12, 'foo', 'bar', 'test', null, 1000, 'state', 'info');
ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'processlist'
update performance_schema.processlist
set id=12, user='foo';
ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'processlist'
delete from performance_schema.processlist
where id <> 99;
ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'processlist'
delete from performance_schema.processlist;
ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'processlist'
LOCK TABLES performance_schema.processlist READ;
ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'processlist'
UNLOCK TABLES;
LOCK TABLES performance_schema.processlist WRITE;
ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'processlist'
UNLOCK TABLES;
set @@global.performance_schema_show_processlist = @save_processlist;
Loading

0 comments on commit b043e10

Please sign in to comment.