mariadb/storage/perfschema/pfs_server.h

312 lines
9.3 KiB
C
Raw Normal View History

/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
2020-01-19 12:52:07 +01:00
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is also distributed with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have included with MySQL.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020-01-19 12:52:07 +01:00
GNU General Public License, version 2.0, for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#ifndef PFS_SERVER_H
#define PFS_SERVER_H
MDEV-31340 Remove MY_COLLATION_HANDLER::strcasecmp() This patch also fixes: MDEV-33050 Build-in schemas like oracle_schema are accent insensitive MDEV-33084 LASTVAL(t1) and LASTVAL(T1) do not work well with lower-case-table-names=0 MDEV-33085 Tables T1 and t1 do not work well with ENGINE=CSV and lower-case-table-names=0 MDEV-33086 SHOW OPEN TABLES IN DB1 -- is case insensitive with lower-case-table-names=0 MDEV-33088 Cannot create triggers in the database `MYSQL` MDEV-33103 LOCK TABLE t1 AS t2 -- alias is not case sensitive with lower-case-table-names=0 MDEV-33109 DROP DATABASE MYSQL -- does not drop SP with lower-case-table-names=0 MDEV-33110 HANDLER commands are case insensitive with lower-case-table-names=0 MDEV-33119 User is case insensitive in INFORMATION_SCHEMA.VIEWS MDEV-33120 System log table names are case insensitive with lower-cast-table-names=0 - Removing the virtual function strnncoll() from MY_COLLATION_HANDLER - Adding a wrapper function CHARSET_INFO::streq(), to compare two strings for equality. For now it calls strnncoll() internally. In the future it will turn into a virtual function. - Adding new accent sensitive case insensitive collations: - utf8mb4_general1400_as_ci - utf8mb3_general1400_as_ci They implement accent sensitive case insensitive comparison. The weight of a character is equal to the code point of its upper case variant. These collations use Unicode-14.0.0 casefolding data. The result of my_charset_utf8mb3_general1400_as_ci.strcoll() is very close to the former my_charset_utf8mb3_general_ci.strcasecmp() There is only a difference in a couple dozen rare characters, because: - the switch from "tolower" to "toupper" comparison, to make utf8mb3_general1400_as_ci closer to utf8mb3_general_ci - the switch from Unicode-3.0.0 to Unicode-14.0.0 This difference should be tolarable. See the list of affected characters in the MDEV description. Note, utf8mb4_general1400_as_ci correctly handles non-BMP characters! Unlike utf8mb4_general_ci, it does not treat all BMP characters as equal. - Adding classes representing names of the file based database objects: Lex_ident_db Lex_ident_table Lex_ident_trigger Their comparison collation depends on the underlying file system case sensitivity and on --lower-case-table-names and can be either my_charset_bin or my_charset_utf8mb3_general1400_as_ci. - Adding classes representing names of other database objects, whose names have case insensitive comparison style, using my_charset_utf8mb3_general1400_as_ci: Lex_ident_column Lex_ident_sys_var Lex_ident_user_var Lex_ident_sp_var Lex_ident_ps Lex_ident_i_s_table Lex_ident_window Lex_ident_func Lex_ident_partition Lex_ident_with_element Lex_ident_rpl_filter Lex_ident_master_info Lex_ident_host Lex_ident_locale Lex_ident_plugin Lex_ident_engine Lex_ident_server Lex_ident_savepoint Lex_ident_charset engine_option_value::Name - All the mentioned Lex_ident_xxx classes implement a method streq(): if (ident1.streq(ident2)) do_equal(); This method works as a wrapper for CHARSET_INFO::streq(). - Changing a lot of "LEX_CSTRING name" to "Lex_ident_xxx name" in class members and in function/method parameters. - Replacing all calls like system_charset_info->coll->strcasecmp(ident1, ident2) to ident1.streq(ident2) - Taking advantage of the c++11 user defined literal operator for LEX_CSTRING (see m_strings.h) and Lex_ident_xxx (see lex_ident.h) data types. Use example: const Lex_ident_column primary_key_name= "PRIMARY"_Lex_ident_column; is now a shorter version of: const Lex_ident_column primary_key_name= Lex_ident_column({STRING_WITH_LEN("PRIMARY")});
2023-04-26 15:27:01 +04:00
#include "m_string.h" /* LEX_CSTRING */
/**
@file storage/perfschema/pfs_server.h
Private interface for the server (declarations).
*/
2019-12-10 15:35:00 +01:00
#define PFS_AUTOSCALE_VALUE (-1)
#define PFS_AUTOSIZE_VALUE (-1)
#ifndef PFS_MAX_MUTEX_CLASS
2019-12-10 15:35:00 +01:00
#define PFS_MAX_MUTEX_CLASS 210
#endif
#ifndef PFS_MAX_RWLOCK_CLASS
2019-12-10 15:35:00 +01:00
#define PFS_MAX_RWLOCK_CLASS 50
#endif
#ifndef PFS_MAX_COND_CLASS
#define PFS_MAX_COND_CLASS 90
#endif
#ifndef PFS_MAX_THREAD_CLASS
#define PFS_MAX_THREAD_CLASS 50
#endif
#ifndef PFS_MAX_FILE_CLASS
2019-12-10 15:35:00 +01:00
#define PFS_MAX_FILE_CLASS 80
#endif
#ifndef PFS_MAX_FILE_HANDLE
#define PFS_MAX_FILE_HANDLE 32768
#endif
#ifndef PFS_MAX_SOCKET_CLASS
#define PFS_MAX_SOCKET_CLASS 10
#endif
#ifndef PFS_MAX_STAGE_CLASS
Add more execution stages (commit, rollback, etc) This was done to get more information about where time is spent. Now we can get proper timing for time spent in commit, rollback, binlog write etc. Following stages was added: - Commit - Commit_implicit - Rollback - Rollback implicit - Binlog write - Init for update - This is used instead of "Init" for insert, update and delete. - Staring cleanup Following stages where changed: - "Unlocking tables" stage reset stage to previous stage at end - "binlog write" stage resets stage to previous stage at end - "end" -> "end of update loop" - "cleaning up" -> "Reset for next command" - Added stage_searching_rows_for_update when searching for rows to be deleted. Other things: - Renamed all stages to start with big letter (before there was no consitency) - Increased performance_schema_max_stage_classes from 150 to 160. - Most of the test changes in performance schema comes from renaming of stages. - Removed duplicate output of variables and inital state in a lot of performance schema tests. This was done to make it easier to change a default value for a performance variable without affecting all tests. - Added start_server_variables.test to check configuration - Removed some duplicate "closing tables" stages - Updated position for "stage_init_update" and "stage_updating" for delete, insert and update to be just before update loop (for more exact timing). - Don't set "Checking permissions" twice in a row. - Remove stage_end stage from creating views (not done for create table either). - Updated default performance history size from 10 to 20 because of new stages - Ensure that ps_enabled is correct (to be used in a later patch)
2017-11-05 17:04:20 +02:00
#define PFS_MAX_STAGE_CLASS 160
#endif
#ifndef PFS_STATEMENTS_STACK_SIZE
#define PFS_STATEMENTS_STACK_SIZE 10
#endif
2019-12-10 15:35:00 +01:00
#ifndef PFS_MAX_MEMORY_CLASS
#define PFS_MAX_MEMORY_CLASS 320
2013-10-03 18:00:44 +03:00
#endif
2013-03-26 00:03:13 +02:00
2019-12-10 15:35:00 +01:00
/** Sizing hints, from the server configuration. */
2013-03-26 00:03:13 +02:00
struct PFS_sizing_hints
{
2019-12-10 15:35:00 +01:00
/** Value of @c Sys_table_def_size */
2013-03-26 00:03:13 +02:00
long m_table_definition_cache;
2019-12-10 15:35:00 +01:00
/** Value of @c Sys_table_cache_size */
2013-03-26 00:03:13 +02:00
long m_table_open_cache;
2019-12-10 15:35:00 +01:00
/** Value of @c Sys_max_connections */
2013-03-26 00:03:13 +02:00
long m_max_connections;
2019-12-10 15:35:00 +01:00
/** Value of @c Sys_open_files_limit */
2013-03-26 00:03:13 +02:00
long m_open_files_limit;
2019-12-10 15:35:00 +01:00
/** Value of @c Sys_max_prepared_stmt_count */
long m_max_prepared_stmt_count;
2013-03-26 00:03:13 +02:00
};
/** Performance schema global sizing parameters. */
struct PFS_global_param
{
/** True if the performance schema is enabled. */
2013-03-26 00:03:13 +02:00
bool m_enabled;
/** Default values for SETUP_CONSUMERS. */
bool m_consumer_events_stages_current_enabled;
bool m_consumer_events_stages_history_enabled;
bool m_consumer_events_stages_history_long_enabled;
bool m_consumer_events_statements_current_enabled;
bool m_consumer_events_statements_history_enabled;
bool m_consumer_events_statements_history_long_enabled;
2019-12-10 15:35:00 +01:00
bool m_consumer_events_transactions_current_enabled;
bool m_consumer_events_transactions_history_enabled;
bool m_consumer_events_transactions_history_long_enabled;
bool m_consumer_events_waits_current_enabled;
bool m_consumer_events_waits_history_enabled;
bool m_consumer_events_waits_history_long_enabled;
bool m_consumer_global_instrumentation_enabled;
bool m_consumer_thread_instrumentation_enabled;
bool m_consumer_statement_digest_enabled;
/** Default instrument configuration option. */
char *m_pfs_instrument;
/**
Maximum number of instrumented mutex classes.
@sa mutex_class_lost.
*/
ulong m_mutex_class_sizing;
/**
Maximum number of instrumented rwlock classes.
@sa rwlock_class_lost.
*/
ulong m_rwlock_class_sizing;
/**
Maximum number of instrumented cond classes.
@sa cond_class_lost.
*/
ulong m_cond_class_sizing;
/**
Maximum number of instrumented thread classes.
@sa thread_class_lost.
*/
ulong m_thread_class_sizing;
/**
Maximum number of instrumented table share.
@sa table_share_lost.
*/
2013-03-26 00:03:13 +02:00
long m_table_share_sizing;
2019-12-10 15:35:00 +01:00
/**
Maximum number of lock statistics collected for tables.
@sa table_lock_stat_lost.
*/
long m_table_lock_stat_sizing;
/**
Maximum number of index statistics collected for tables.
@sa table_index_lost.
*/
long m_index_stat_sizing;
/**
Maximum number of instrumented file classes.
@sa file_class_lost.
*/
ulong m_file_class_sizing;
/**
Maximum number of instrumented mutex instances.
@sa mutex_lost.
*/
2013-03-26 00:03:13 +02:00
long m_mutex_sizing;
/**
Maximum number of instrumented rwlock instances.
@sa rwlock_lost.
*/
2013-03-26 00:03:13 +02:00
long m_rwlock_sizing;
/**
Maximum number of instrumented cond instances.
@sa cond_lost.
*/
2013-03-26 00:03:13 +02:00
long m_cond_sizing;
/**
Maximum number of instrumented thread instances.
@sa thread_lost.
*/
2013-03-26 00:03:13 +02:00
long m_thread_sizing;
/**
Maximum number of instrumented table handles.
@sa table_lost.
*/
2013-03-26 00:03:13 +02:00
long m_table_sizing;
/**
Maximum number of instrumented file instances.
@sa file_lost.
*/
2013-03-26 00:03:13 +02:00
long m_file_sizing;
/**
Maximum number of instrumented file handles.
@sa file_handle_lost.
*/
2013-03-26 00:03:13 +02:00
long m_file_handle_sizing;
/**
Maxium number of instrumented socket instances
2019-12-10 15:35:00 +01:00
@sa socket_lost
*/
2013-03-26 00:03:13 +02:00
long m_socket_sizing;
/**
Maximum number of instrumented socket classes.
@sa socket_class_lost.
*/
ulong m_socket_class_sizing;
/** Maximum number of rows per thread in table EVENTS_WAITS_HISTORY. */
2013-03-26 00:03:13 +02:00
long m_events_waits_history_sizing;
/** Maximum number of rows in table EVENTS_WAITS_HISTORY_LONG. */
2013-03-26 00:03:13 +02:00
long m_events_waits_history_long_sizing;
/** Maximum number of rows in table SETUP_ACTORS. */
2019-12-10 15:35:00 +01:00
long m_setup_actor_sizing;
/** Maximum number of rows in table SETUP_OBJECTS. */
2019-12-10 15:35:00 +01:00
long m_setup_object_sizing;
/** Maximum number of rows in table HOSTS. */
2013-03-26 00:03:13 +02:00
long m_host_sizing;
/** Maximum number of rows in table USERS. */
2013-03-26 00:03:13 +02:00
long m_user_sizing;
/** Maximum number of rows in table ACCOUNTS. */
2013-03-26 00:03:13 +02:00
long m_account_sizing;
/**
Maximum number of instrumented stage classes.
@sa stage_class_lost.
*/
ulong m_stage_class_sizing;
/** Maximum number of rows per thread in table EVENTS_STAGES_HISTORY. */
2013-03-26 00:03:13 +02:00
long m_events_stages_history_sizing;
/** Maximum number of rows in table EVENTS_STAGES_HISTORY_LONG. */
2013-03-26 00:03:13 +02:00
long m_events_stages_history_long_sizing;
/**
Maximum number of instrumented statement classes.
@sa statement_class_lost.
*/
ulong m_statement_class_sizing;
2019-12-10 15:35:00 +01:00
/** Maximum number of rows per thread in table EVENTS_STATEMENTS_HISTORY. */
2013-03-26 00:03:13 +02:00
long m_events_statements_history_sizing;
/** Maximum number of rows in table EVENTS_STATEMENTS_HISTORY_LONG. */
2013-03-26 00:03:13 +02:00
long m_events_statements_history_long_sizing;
/** Maximum number of digests to be captured */
2013-03-26 00:03:13 +02:00
long m_digest_sizing;
2019-12-10 15:35:00 +01:00
/** Maximum number of programs to be captured */
long m_program_sizing;
/** Maximum number of prepared statements to be captured */
long m_prepared_stmt_sizing;
/** Maximum number of rows per thread in table EVENTS_TRANSACTIONS_HISTORY. */
long m_events_transactions_history_sizing;
/** Maximum number of rows in table EVENTS_TRANSACTIONS_HISTORY_LONG. */
long m_events_transactions_history_long_sizing;
2013-03-26 00:03:13 +02:00
/** Maximum number of session attribute strings per thread */
long m_session_connect_attrs_sizing;
2019-12-10 15:35:00 +01:00
/** Maximum size of statement stack */
ulong m_statement_stack_sizing;
/**
Maximum number of instrumented memory classes.
@sa memory_class_lost.
*/
ulong m_memory_class_sizing;
long m_metadata_lock_sizing;
2013-03-26 00:03:13 +02:00
2015-08-03 13:05:40 +02:00
long m_max_digest_length;
2019-12-10 15:35:00 +01:00
ulong m_max_sql_text_length;
2015-05-04 22:16:00 +02:00
2013-03-26 00:03:13 +02:00
/** Sizing hints, for auto tuning. */
PFS_sizing_hints m_hints;
};
/**
Performance schema sizing values for the server.
This global variable is set when parsing server startup options.
*/
extern PFS_global_param pfs_param;
2019-12-10 15:35:00 +01:00
/**
Null initialization.
Disable all instrumentation, size all internal buffers to 0.
This pre initialization step is needed to ensure that events can be collected
and discarded, until such time @c initialize_performance_schema() is called.
*/
void pre_initialize_performance_schema();
/**
Initialize the performance schema.
@param param Size parameters to use.
2019-12-10 15:35:00 +01:00
@return A bootstrap handle, or NULL.
*/
struct PSI_bootstrap*
2013-03-26 00:03:13 +02:00
initialize_performance_schema(PFS_global_param *param);
void pfs_automated_sizing(PFS_global_param *param);
/**
Initialize the performance schema ACL.
ACL is strictly enforced when the server is running in normal mode,
to enforce that only legal operations are allowed.
2019-12-10 15:35:00 +01:00
When running in bootstrap mode, ACL restrictions are relaxed,
to allow the bootstrap scripts to DROP / CREATE performance schema tables.
@sa ACL_internal_schema_registry
@param bootstrap True if the server is starting in bootstrap mode.
*/
void initialize_performance_schema_acl(bool bootstrap);
2019-12-10 15:35:00 +01:00
/**
Reset the aggregated status counter stats.
*/
void reset_pfs_status_stats();
/**
Initialize the dynamic array holding individual instrument settings collected
from the server configuration options.
*/
void init_pfs_instrument_array();
/**
Process one PFS_INSTRUMENT configuration string.
*/
MDEV-31340 Remove MY_COLLATION_HANDLER::strcasecmp() This patch also fixes: MDEV-33050 Build-in schemas like oracle_schema are accent insensitive MDEV-33084 LASTVAL(t1) and LASTVAL(T1) do not work well with lower-case-table-names=0 MDEV-33085 Tables T1 and t1 do not work well with ENGINE=CSV and lower-case-table-names=0 MDEV-33086 SHOW OPEN TABLES IN DB1 -- is case insensitive with lower-case-table-names=0 MDEV-33088 Cannot create triggers in the database `MYSQL` MDEV-33103 LOCK TABLE t1 AS t2 -- alias is not case sensitive with lower-case-table-names=0 MDEV-33109 DROP DATABASE MYSQL -- does not drop SP with lower-case-table-names=0 MDEV-33110 HANDLER commands are case insensitive with lower-case-table-names=0 MDEV-33119 User is case insensitive in INFORMATION_SCHEMA.VIEWS MDEV-33120 System log table names are case insensitive with lower-cast-table-names=0 - Removing the virtual function strnncoll() from MY_COLLATION_HANDLER - Adding a wrapper function CHARSET_INFO::streq(), to compare two strings for equality. For now it calls strnncoll() internally. In the future it will turn into a virtual function. - Adding new accent sensitive case insensitive collations: - utf8mb4_general1400_as_ci - utf8mb3_general1400_as_ci They implement accent sensitive case insensitive comparison. The weight of a character is equal to the code point of its upper case variant. These collations use Unicode-14.0.0 casefolding data. The result of my_charset_utf8mb3_general1400_as_ci.strcoll() is very close to the former my_charset_utf8mb3_general_ci.strcasecmp() There is only a difference in a couple dozen rare characters, because: - the switch from "tolower" to "toupper" comparison, to make utf8mb3_general1400_as_ci closer to utf8mb3_general_ci - the switch from Unicode-3.0.0 to Unicode-14.0.0 This difference should be tolarable. See the list of affected characters in the MDEV description. Note, utf8mb4_general1400_as_ci correctly handles non-BMP characters! Unlike utf8mb4_general_ci, it does not treat all BMP characters as equal. - Adding classes representing names of the file based database objects: Lex_ident_db Lex_ident_table Lex_ident_trigger Their comparison collation depends on the underlying file system case sensitivity and on --lower-case-table-names and can be either my_charset_bin or my_charset_utf8mb3_general1400_as_ci. - Adding classes representing names of other database objects, whose names have case insensitive comparison style, using my_charset_utf8mb3_general1400_as_ci: Lex_ident_column Lex_ident_sys_var Lex_ident_user_var Lex_ident_sp_var Lex_ident_ps Lex_ident_i_s_table Lex_ident_window Lex_ident_func Lex_ident_partition Lex_ident_with_element Lex_ident_rpl_filter Lex_ident_master_info Lex_ident_host Lex_ident_locale Lex_ident_plugin Lex_ident_engine Lex_ident_server Lex_ident_savepoint Lex_ident_charset engine_option_value::Name - All the mentioned Lex_ident_xxx classes implement a method streq(): if (ident1.streq(ident2)) do_equal(); This method works as a wrapper for CHARSET_INFO::streq(). - Changing a lot of "LEX_CSTRING name" to "Lex_ident_xxx name" in class members and in function/method parameters. - Replacing all calls like system_charset_info->coll->strcasecmp(ident1, ident2) to ident1.streq(ident2) - Taking advantage of the c++11 user defined literal operator for LEX_CSTRING (see m_strings.h) and Lex_ident_xxx (see lex_ident.h) data types. Use example: const Lex_ident_column primary_key_name= "PRIMARY"_Lex_ident_column; is now a shorter version of: const Lex_ident_column primary_key_name= Lex_ident_column({STRING_WITH_LEN("PRIMARY")});
2023-04-26 15:27:01 +04:00
int add_pfs_instr_to_array(const LEX_CSTRING &name, const LEX_CSTRING &value);
/**
Shutdown the performance schema.
*/
void shutdown_performance_schema();
#endif