diff options
author | Sergei Golubchik <serg@mariadb.org> | 2023-03-27 18:50:49 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2023-03-27 21:27:27 +0200 |
commit | c2b69163934016afa4bb3b274cddaacec92fcb61 (patch) | |
tree | e626bb791fdfb7438e1bdd340da47970926c95b9 | |
parent | d9808f79de992964ed802d27984c9031d72e7b9a (diff) | |
download | mariadb-git-c2b69163934016afa4bb3b274cddaacec92fcb61.tar.gz |
MDEV-19629 post-merge fixesbb-11.0-serg
* it isn't "pfs" function, don't call it Item_func_pfs,
don't use item_pfsfunc.*
* tests don't depend on performance schema, put in the main suite
* inherit from Item_str_ascii_func
* use connection collation, not utf8mb3_general_ci
* set result length in fix_length_and_dec
* do not set maybe_null
* use my_snprintf() where possible
* don't set m_value.ptr on every invocation
* update sys schema to use the format_pico_time()
* len must be size_t (compilation error on Windows)
* the correct function name for double->double is fabs()
* drop volatile hack
86 files changed, 347 insertions, 430 deletions
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 8727aa54992..5d5cc35e1be 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -64,7 +64,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/item.cc ../sql/item_create.cc ../sql/item_func.cc ../sql/item_geofunc.cc ../sql/item_row.cc ../sql/item_strfunc.cc ../sql/item_subselect.cc ../sql/item_sum.cc ../sql/item_timefunc.cc - ../sql/item_xmlfunc.cc ../sql/item_jsonfunc.cc ../sql/item_pfsfunc.cc + ../sql/item_xmlfunc.cc ../sql/item_jsonfunc.cc ../sql/key.cc ../sql/lock.cc ../sql/log.cc ../sql/log_event.cc ../sql/log_event_server.cc ../sql/mf_iocache.cc ../sql/my_decimal.cc diff --git a/mysql-test/suite/perfschema/r/pfs_functions.result b/mysql-test/main/func_format.result index 322f64c1ce7..322f64c1ce7 100644 --- a/mysql-test/suite/perfschema/r/pfs_functions.result +++ b/mysql-test/main/func_format.result diff --git a/mysql-test/suite/perfschema/t/pfs_functions.test b/mysql-test/main/func_format.test index a175d3edeea..a175d3edeea 100644 --- a/mysql-test/suite/perfschema/t/pfs_functions.test +++ b/mysql-test/main/func_format.test diff --git a/mysql-test/suite/sysschema/r/v_host_summary.result b/mysql-test/suite/sysschema/r/v_host_summary.result index b619a8a55fd..6eef4a41532 100644 --- a/mysql-test/suite/sysschema/r/v_host_summary.result +++ b/mysql-test/suite/sysschema/r/v_host_summary.result @@ -2,11 +2,11 @@ DESC sys.host_summary; Field Type Null Key Default Extra host varchar(255) YES NULL statements decimal(64,0) YES NULL -statement_latency text YES NULL -statement_avg_latency text YES NULL +statement_latency varchar(12) YES NULL +statement_avg_latency varchar(12) YES NULL table_scans decimal(65,0) YES NULL file_ios decimal(64,0) YES NULL -file_io_latency text YES NULL +file_io_latency varchar(12) YES NULL current_connections decimal(41,0) YES NULL total_connections decimal(41,0) YES NULL unique_users bigint(21) NO 0 diff --git a/mysql-test/suite/sysschema/r/v_host_summary_by_file_io.result b/mysql-test/suite/sysschema/r/v_host_summary_by_file_io.result index 8e257163da7..979d4a719d1 100644 --- a/mysql-test/suite/sysschema/r/v_host_summary_by_file_io.result +++ b/mysql-test/suite/sysschema/r/v_host_summary_by_file_io.result @@ -2,7 +2,7 @@ DESC sys.host_summary_by_file_io; Field Type Null Key Default Extra host varchar(255) YES NULL ios decimal(42,0) YES NULL -io_latency text YES NULL +io_latency varchar(12) YES NULL SELECT * FROM sys.host_summary_by_file_io; DESC sys.x$host_summary_by_file_io; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_host_summary_by_file_io_type.result b/mysql-test/suite/sysschema/r/v_host_summary_by_file_io_type.result index c9a56aa9943..9844b8b7c03 100644 --- a/mysql-test/suite/sysschema/r/v_host_summary_by_file_io_type.result +++ b/mysql-test/suite/sysschema/r/v_host_summary_by_file_io_type.result @@ -3,8 +3,8 @@ Field Type Null Key Default Extra host varchar(255) YES NULL event_name varchar(128) NO NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL -max_latency text YES NULL +total_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL SELECT * FROM sys.host_summary_by_file_io_type; DESC sys.x$host_summary_by_file_io_type; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_host_summary_by_stages.result b/mysql-test/suite/sysschema/r/v_host_summary_by_stages.result index 0ee6f25562c..3910ed6e1a6 100644 --- a/mysql-test/suite/sysschema/r/v_host_summary_by_stages.result +++ b/mysql-test/suite/sysschema/r/v_host_summary_by_stages.result @@ -3,8 +3,8 @@ Field Type Null Key Default Extra host varchar(255) YES NULL event_name varchar(128) NO NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL -avg_latency text YES NULL +total_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL SELECT * FROM sys.host_summary_by_stages; DESC sys.x$host_summary_by_stages; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_host_summary_by_statement_latency.result b/mysql-test/suite/sysschema/r/v_host_summary_by_statement_latency.result index 882a30b71a1..e7f906e615c 100644 --- a/mysql-test/suite/sysschema/r/v_host_summary_by_statement_latency.result +++ b/mysql-test/suite/sysschema/r/v_host_summary_by_statement_latency.result @@ -2,9 +2,9 @@ DESC sys.host_summary_by_statement_latency; Field Type Null Key Default Extra host varchar(255) YES NULL total decimal(42,0) YES NULL -total_latency text YES NULL -max_latency text YES NULL -lock_latency text YES NULL +total_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL +lock_latency varchar(12) YES NULL rows_sent decimal(42,0) YES NULL rows_examined decimal(42,0) YES NULL rows_affected decimal(42,0) YES NULL diff --git a/mysql-test/suite/sysschema/r/v_host_summary_by_statement_type.result b/mysql-test/suite/sysschema/r/v_host_summary_by_statement_type.result index eec8f8695c6..14e58d7d135 100644 --- a/mysql-test/suite/sysschema/r/v_host_summary_by_statement_type.result +++ b/mysql-test/suite/sysschema/r/v_host_summary_by_statement_type.result @@ -3,9 +3,9 @@ Field Type Null Key Default Extra host varchar(255) YES NULL statement varchar(128) YES NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL -max_latency text YES NULL -lock_latency text YES NULL +total_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL +lock_latency varchar(12) YES NULL rows_sent bigint(20) unsigned NO NULL rows_examined bigint(20) unsigned NO NULL rows_affected bigint(20) unsigned NO NULL diff --git a/mysql-test/suite/sysschema/r/v_io_by_thread_by_latency.result b/mysql-test/suite/sysschema/r/v_io_by_thread_by_latency.result index fddd2f266df..bed684ae7c8 100644 --- a/mysql-test/suite/sysschema/r/v_io_by_thread_by_latency.result +++ b/mysql-test/suite/sysschema/r/v_io_by_thread_by_latency.result @@ -2,10 +2,10 @@ DESC sys.io_by_thread_by_latency; Field Type Null Key Default Extra user varchar(384) YES NULL total decimal(42,0) YES NULL -total_latency text YES NULL -min_latency text YES NULL -avg_latency text YES NULL -max_latency text YES NULL +total_latency varchar(12) YES NULL +min_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL thread_id bigint(20) unsigned NO NULL processlist_id bigint(20) unsigned YES NULL SELECT * FROM sys.io_by_thread_by_latency; diff --git a/mysql-test/suite/sysschema/r/v_io_global_by_file_by_latency.result b/mysql-test/suite/sysschema/r/v_io_global_by_file_by_latency.result index 32d992c2751..c56d02f641f 100644 --- a/mysql-test/suite/sysschema/r/v_io_global_by_file_by_latency.result +++ b/mysql-test/suite/sysschema/r/v_io_global_by_file_by_latency.result @@ -2,13 +2,13 @@ DESC sys.io_global_by_file_by_latency; Field Type Null Key Default Extra file varchar(512) YES NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL +total_latency varchar(12) YES NULL count_read bigint(20) unsigned NO NULL -read_latency text YES NULL +read_latency varchar(12) YES NULL count_write bigint(20) unsigned NO NULL -write_latency text YES NULL +write_latency varchar(12) YES NULL count_misc bigint(20) unsigned NO NULL -misc_latency text YES NULL +misc_latency varchar(12) YES NULL SELECT * FROM sys.io_global_by_file_by_latency; DESC sys.x$io_global_by_file_by_latency; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_io_global_by_wait_by_bytes.result b/mysql-test/suite/sysschema/r/v_io_global_by_wait_by_bytes.result index 3d5dcbffbf6..d47dc9df085 100644 --- a/mysql-test/suite/sysschema/r/v_io_global_by_wait_by_bytes.result +++ b/mysql-test/suite/sysschema/r/v_io_global_by_wait_by_bytes.result @@ -2,10 +2,10 @@ DESC sys.io_global_by_wait_by_bytes; Field Type Null Key Default Extra event_name varchar(128) YES NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL -min_latency text YES NULL -avg_latency text YES NULL -max_latency text YES NULL +total_latency varchar(12) YES NULL +min_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL count_read bigint(20) unsigned NO NULL total_read text YES NULL avg_read text YES NULL diff --git a/mysql-test/suite/sysschema/r/v_io_global_by_wait_by_latency.result b/mysql-test/suite/sysschema/r/v_io_global_by_wait_by_latency.result index 1c5db297964..62399c7953d 100644 --- a/mysql-test/suite/sysschema/r/v_io_global_by_wait_by_latency.result +++ b/mysql-test/suite/sysschema/r/v_io_global_by_wait_by_latency.result @@ -2,12 +2,12 @@ DESC sys.io_global_by_wait_by_latency; Field Type Null Key Default Extra event_name varchar(128) YES NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL -avg_latency text YES NULL -max_latency text YES NULL -read_latency text YES NULL -write_latency text YES NULL -misc_latency text YES NULL +total_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL +read_latency varchar(12) YES NULL +write_latency varchar(12) YES NULL +misc_latency varchar(12) YES NULL count_read bigint(20) unsigned NO NULL total_read text YES NULL avg_read text YES NULL diff --git a/mysql-test/suite/sysschema/r/v_latest_file_io.result b/mysql-test/suite/sysschema/r/v_latest_file_io.result index a65cdb2dd10..8bdc02145f6 100644 --- a/mysql-test/suite/sysschema/r/v_latest_file_io.result +++ b/mysql-test/suite/sysschema/r/v_latest_file_io.result @@ -2,7 +2,7 @@ DESC sys.latest_file_io; Field Type Null Key Default Extra thread varchar(214) YES NULL file varchar(512) YES NULL -latency text YES NULL +latency varchar(12) YES NULL operation varchar(32) NO NULL requested text YES NULL SELECT * FROM sys.latest_file_io; diff --git a/mysql-test/suite/sysschema/r/v_processlist.result b/mysql-test/suite/sysschema/r/v_processlist.result index dfc048143d6..f242497907f 100644 --- a/mysql-test/suite/sysschema/r/v_processlist.result +++ b/mysql-test/suite/sysschema/r/v_processlist.result @@ -8,9 +8,9 @@ command varchar(16) YES NULL state varchar(64) YES NULL time bigint(20) YES NULL current_statement longtext YES NULL -statement_latency mediumtext YES NULL +statement_latency varchar(12) YES NULL progress decimal(26,2) YES NULL -lock_latency text YES NULL +lock_latency varchar(12) YES NULL rows_examined bigint(20) unsigned YES NULL rows_sent bigint(20) unsigned YES NULL rows_affected bigint(20) unsigned YES NULL @@ -18,12 +18,12 @@ tmp_tables bigint(20) unsigned YES NULL tmp_disk_tables bigint(20) unsigned YES NULL full_scan varchar(3) YES NULL last_statement longtext YES NULL -last_statement_latency mediumtext YES NULL +last_statement_latency varchar(12) YES NULL current_memory text YES NULL last_wait varchar(128) YES NULL -last_wait_latency mediumtext YES NULL +last_wait_latency varchar(13) YES NULL source varchar(64) YES NULL -trx_latency text YES NULL +trx_latency varchar(12) YES NULL trx_state enum('ACTIVE','COMMITTED','ROLLED BACK') YES NULL trx_autocommit enum('YES','NO') YES NULL pid varchar(1024) YES NULL diff --git a/mysql-test/suite/sysschema/r/v_schema_index_statistics.result b/mysql-test/suite/sysschema/r/v_schema_index_statistics.result index 63cf1931e79..959f8628145 100644 --- a/mysql-test/suite/sysschema/r/v_schema_index_statistics.result +++ b/mysql-test/suite/sysschema/r/v_schema_index_statistics.result @@ -4,13 +4,13 @@ table_schema varchar(64) YES NULL table_name varchar(64) YES NULL index_name varchar(64) YES NULL rows_selected bigint(20) unsigned NO NULL -select_latency text YES NULL +select_latency varchar(12) YES NULL rows_inserted bigint(20) unsigned NO NULL -insert_latency text YES NULL +insert_latency varchar(12) YES NULL rows_updated bigint(20) unsigned NO NULL -update_latency text YES NULL +update_latency varchar(12) YES NULL rows_deleted bigint(20) unsigned NO NULL -delete_latency text YES NULL +delete_latency varchar(12) YES NULL SELECT * FROM sys.schema_index_statistics; DESC sys.x$schema_index_statistics; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_schema_table_statistics.result b/mysql-test/suite/sysschema/r/v_schema_table_statistics.result index fda0d7da310..0ca9096d937 100644 --- a/mysql-test/suite/sysschema/r/v_schema_table_statistics.result +++ b/mysql-test/suite/sysschema/r/v_schema_table_statistics.result @@ -2,23 +2,23 @@ DESC sys.schema_table_statistics; Field Type Null Key Default Extra table_schema varchar(64) YES NULL table_name varchar(64) YES NULL -total_latency text YES NULL +total_latency varchar(12) YES NULL rows_fetched bigint(20) unsigned NO NULL -fetch_latency text YES NULL +fetch_latency varchar(12) YES NULL rows_inserted bigint(20) unsigned NO NULL -insert_latency text YES NULL +insert_latency varchar(12) YES NULL rows_updated bigint(20) unsigned NO NULL -update_latency text YES NULL +update_latency varchar(12) YES NULL rows_deleted bigint(20) unsigned NO NULL -delete_latency text YES NULL +delete_latency varchar(12) YES NULL io_read_requests decimal(42,0) YES NULL io_read text YES NULL -io_read_latency text YES NULL +io_read_latency varchar(12) YES NULL io_write_requests decimal(42,0) YES NULL io_write text YES NULL -io_write_latency text YES NULL +io_write_latency varchar(12) YES NULL io_misc_requests decimal(42,0) YES NULL -io_misc_latency text YES NULL +io_misc_latency varchar(12) YES NULL SELECT * FROM sys.schema_table_statistics; DESC sys.x$schema_table_statistics; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_schema_table_statistics_with_buffer.result b/mysql-test/suite/sysschema/r/v_schema_table_statistics_with_buffer.result index 809e8a4e823..28f5ee84f98 100644 --- a/mysql-test/suite/sysschema/r/v_schema_table_statistics_with_buffer.result +++ b/mysql-test/suite/sysschema/r/v_schema_table_statistics_with_buffer.result @@ -3,21 +3,21 @@ Field Type Null Key Default Extra table_schema varchar(64) YES NULL table_name varchar(64) YES NULL rows_fetched bigint(20) unsigned NO NULL -fetch_latency text YES NULL +fetch_latency varchar(12) YES NULL rows_inserted bigint(20) unsigned NO NULL -insert_latency text YES NULL +insert_latency varchar(12) YES NULL rows_updated bigint(20) unsigned NO NULL -update_latency text YES NULL +update_latency varchar(12) YES NULL rows_deleted bigint(20) unsigned NO NULL -delete_latency text YES NULL +delete_latency varchar(12) YES NULL io_read_requests decimal(42,0) YES NULL io_read text YES NULL -io_read_latency text YES NULL +io_read_latency varchar(12) YES NULL io_write_requests decimal(42,0) YES NULL io_write text YES NULL -io_write_latency text YES NULL +io_write_latency varchar(12) YES NULL io_misc_requests decimal(42,0) YES NULL -io_misc_latency text YES NULL +io_misc_latency varchar(12) YES NULL innodb_buffer_allocated text YES NULL innodb_buffer_data text YES NULL innodb_buffer_free text YES NULL diff --git a/mysql-test/suite/sysschema/r/v_schema_tables_with_full_table_scans.result b/mysql-test/suite/sysschema/r/v_schema_tables_with_full_table_scans.result index a6aca341f2e..9516071ca9b 100644 --- a/mysql-test/suite/sysschema/r/v_schema_tables_with_full_table_scans.result +++ b/mysql-test/suite/sysschema/r/v_schema_tables_with_full_table_scans.result @@ -3,7 +3,7 @@ Field Type Null Key Default Extra object_schema varchar(64) YES NULL object_name varchar(64) YES NULL rows_full_scanned bigint(20) unsigned NO NULL -latency text YES NULL +latency varchar(12) YES NULL SELECT * FROM sys.schema_tables_with_full_table_scans; DESC sys.x$schema_tables_with_full_table_scans; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_session.result b/mysql-test/suite/sysschema/r/v_session.result index fd88b8f1d6a..21e237ed3f6 100644 --- a/mysql-test/suite/sysschema/r/v_session.result +++ b/mysql-test/suite/sysschema/r/v_session.result @@ -8,9 +8,9 @@ command varchar(16) YES NULL state varchar(64) YES NULL time bigint(20) YES NULL current_statement longtext YES NULL -statement_latency mediumtext YES NULL +statement_latency varchar(12) YES NULL progress decimal(26,2) YES NULL -lock_latency text YES NULL +lock_latency varchar(12) YES NULL rows_examined bigint(20) unsigned YES NULL rows_sent bigint(20) unsigned YES NULL rows_affected bigint(20) unsigned YES NULL @@ -18,12 +18,12 @@ tmp_tables bigint(20) unsigned YES NULL tmp_disk_tables bigint(20) unsigned YES NULL full_scan varchar(3) YES NULL last_statement longtext YES NULL -last_statement_latency mediumtext YES NULL +last_statement_latency varchar(12) YES NULL current_memory text YES NULL last_wait varchar(128) YES NULL -last_wait_latency mediumtext YES NULL +last_wait_latency varchar(13) YES NULL source varchar(64) YES NULL -trx_latency text YES NULL +trx_latency varchar(12) YES NULL trx_state enum('ACTIVE','COMMITTED','ROLLED BACK') YES NULL trx_autocommit enum('YES','NO') YES NULL pid varchar(1024) YES NULL diff --git a/mysql-test/suite/sysschema/r/v_statement_analysis.result b/mysql-test/suite/sysschema/r/v_statement_analysis.result index c3dd167c9fa..510e17d6d7a 100644 --- a/mysql-test/suite/sysschema/r/v_statement_analysis.result +++ b/mysql-test/suite/sysschema/r/v_statement_analysis.result @@ -6,10 +6,10 @@ full_scan varchar(1) NO exec_count bigint(20) unsigned NO NULL err_count bigint(20) unsigned NO NULL warn_count bigint(20) unsigned NO NULL -total_latency text YES NULL -max_latency text YES NULL -avg_latency text YES NULL -lock_latency text YES NULL +total_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL +lock_latency varchar(12) YES NULL rows_sent bigint(20) unsigned NO NULL rows_sent_avg decimal(21,0) NO 0 rows_examined bigint(20) unsigned NO NULL diff --git a/mysql-test/suite/sysschema/r/v_statements_with_full_table_scans.result b/mysql-test/suite/sysschema/r/v_statements_with_full_table_scans.result index a762cfd7d3e..f543c8adfcc 100644 --- a/mysql-test/suite/sysschema/r/v_statements_with_full_table_scans.result +++ b/mysql-test/suite/sysschema/r/v_statements_with_full_table_scans.result @@ -3,7 +3,7 @@ Field Type Null Key Default Extra query longtext YES NULL db varchar(64) YES NULL exec_count bigint(20) unsigned NO NULL -total_latency text YES NULL +total_latency varchar(12) YES NULL no_index_used_count bigint(20) unsigned NO NULL no_good_index_used_count bigint(20) unsigned NO NULL no_index_used_pct decimal(24,0) NO 0 diff --git a/mysql-test/suite/sysschema/r/v_statements_with_runtimes_in_95th_percentile.result b/mysql-test/suite/sysschema/r/v_statements_with_runtimes_in_95th_percentile.result index 5cc05f276f8..90ea51a424b 100644 --- a/mysql-test/suite/sysschema/r/v_statements_with_runtimes_in_95th_percentile.result +++ b/mysql-test/suite/sysschema/r/v_statements_with_runtimes_in_95th_percentile.result @@ -6,9 +6,9 @@ full_scan varchar(1) NO exec_count bigint(20) unsigned NO NULL err_count bigint(20) unsigned NO NULL warn_count bigint(20) unsigned NO NULL -total_latency text YES NULL -max_latency text YES NULL -avg_latency text YES NULL +total_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL rows_sent bigint(20) unsigned NO NULL rows_sent_avg decimal(21,0) NO 0 rows_examined bigint(20) unsigned NO NULL diff --git a/mysql-test/suite/sysschema/r/v_statements_with_sorting.result b/mysql-test/suite/sysschema/r/v_statements_with_sorting.result index 034987b8e72..b3a715731a4 100644 --- a/mysql-test/suite/sysschema/r/v_statements_with_sorting.result +++ b/mysql-test/suite/sysschema/r/v_statements_with_sorting.result @@ -3,7 +3,7 @@ Field Type Null Key Default Extra query longtext YES NULL db varchar(64) YES NULL exec_count bigint(20) unsigned NO NULL -total_latency text YES NULL +total_latency varchar(12) YES NULL sort_merge_passes bigint(20) unsigned NO NULL avg_sort_merges decimal(21,0) NO 0 sorts_using_scans bigint(20) unsigned NO NULL diff --git a/mysql-test/suite/sysschema/r/v_statements_with_temp_tables.result b/mysql-test/suite/sysschema/r/v_statements_with_temp_tables.result index 52683a561b2..73ea1ae00c2 100644 --- a/mysql-test/suite/sysschema/r/v_statements_with_temp_tables.result +++ b/mysql-test/suite/sysschema/r/v_statements_with_temp_tables.result @@ -3,7 +3,7 @@ Field Type Null Key Default Extra query longtext YES NULL db varchar(64) YES NULL exec_count bigint(20) unsigned NO NULL -total_latency text YES NULL +total_latency varchar(12) YES NULL memory_tmp_tables bigint(20) unsigned NO NULL disk_tmp_tables bigint(20) unsigned NO NULL avg_tmp_tables_per_query decimal(21,0) NO 0 diff --git a/mysql-test/suite/sysschema/r/v_user_summary.result b/mysql-test/suite/sysschema/r/v_user_summary.result index 233fcccc5c8..9caa02008f8 100644 --- a/mysql-test/suite/sysschema/r/v_user_summary.result +++ b/mysql-test/suite/sysschema/r/v_user_summary.result @@ -2,11 +2,11 @@ DESC sys.user_summary; Field Type Null Key Default Extra user varchar(128) YES NULL statements decimal(64,0) YES NULL -statement_latency text YES NULL -statement_avg_latency text YES NULL +statement_latency varchar(12) YES NULL +statement_avg_latency varchar(12) YES NULL table_scans decimal(65,0) YES NULL file_ios decimal(64,0) YES NULL -file_io_latency text YES NULL +file_io_latency varchar(12) YES NULL current_connections decimal(41,0) YES NULL total_connections decimal(41,0) YES NULL unique_hosts bigint(21) NO 0 diff --git a/mysql-test/suite/sysschema/r/v_user_summary_by_file_io.result b/mysql-test/suite/sysschema/r/v_user_summary_by_file_io.result index f6f106a5015..d4429b8e66c 100644 --- a/mysql-test/suite/sysschema/r/v_user_summary_by_file_io.result +++ b/mysql-test/suite/sysschema/r/v_user_summary_by_file_io.result @@ -2,7 +2,7 @@ DESC sys.user_summary_by_file_io; Field Type Null Key Default Extra user varchar(128) YES NULL ios decimal(42,0) YES NULL -io_latency text YES NULL +io_latency varchar(12) YES NULL SELECT * FROM sys.user_summary_by_file_io; DESC sys.x$user_summary_by_file_io; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_user_summary_by_file_io_type.result b/mysql-test/suite/sysschema/r/v_user_summary_by_file_io_type.result index c143697c068..cff57e77adb 100644 --- a/mysql-test/suite/sysschema/r/v_user_summary_by_file_io_type.result +++ b/mysql-test/suite/sysschema/r/v_user_summary_by_file_io_type.result @@ -3,8 +3,8 @@ Field Type Null Key Default Extra user varchar(128) YES NULL event_name varchar(128) NO NULL total bigint(20) unsigned NO NULL -latency text YES NULL -max_latency text YES NULL +latency varchar(12) YES NULL +max_latency varchar(12) YES NULL SELECT * FROM sys.user_summary_by_file_io_type; DESC sys.x$user_summary_by_file_io_type; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_user_summary_by_stages.result b/mysql-test/suite/sysschema/r/v_user_summary_by_stages.result index 9b90fe9cf47..655660a25aa 100644 --- a/mysql-test/suite/sysschema/r/v_user_summary_by_stages.result +++ b/mysql-test/suite/sysschema/r/v_user_summary_by_stages.result @@ -3,8 +3,8 @@ Field Type Null Key Default Extra user varchar(128) YES NULL event_name varchar(128) NO NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL -avg_latency text YES NULL +total_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL SELECT * FROM sys.user_summary_by_stages; DESC sys.x$user_summary_by_stages; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_user_summary_by_statement_latency.result b/mysql-test/suite/sysschema/r/v_user_summary_by_statement_latency.result index 36dadc2925b..b5a7fcc2737 100644 --- a/mysql-test/suite/sysschema/r/v_user_summary_by_statement_latency.result +++ b/mysql-test/suite/sysschema/r/v_user_summary_by_statement_latency.result @@ -2,9 +2,9 @@ DESC sys.user_summary_by_statement_latency; Field Type Null Key Default Extra user varchar(128) YES NULL total decimal(42,0) YES NULL -total_latency text YES NULL -max_latency text YES NULL -lock_latency text YES NULL +total_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL +lock_latency varchar(12) YES NULL rows_sent decimal(42,0) YES NULL rows_examined decimal(42,0) YES NULL rows_affected decimal(42,0) YES NULL diff --git a/mysql-test/suite/sysschema/r/v_user_summary_by_statement_type.result b/mysql-test/suite/sysschema/r/v_user_summary_by_statement_type.result index bd006c871b9..70a7ea3f9f5 100644 --- a/mysql-test/suite/sysschema/r/v_user_summary_by_statement_type.result +++ b/mysql-test/suite/sysschema/r/v_user_summary_by_statement_type.result @@ -3,9 +3,9 @@ Field Type Null Key Default Extra user varchar(128) YES NULL statement varchar(128) YES NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL -max_latency text YES NULL -lock_latency text YES NULL +total_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL +lock_latency varchar(12) YES NULL rows_sent bigint(20) unsigned NO NULL rows_examined bigint(20) unsigned NO NULL rows_affected bigint(20) unsigned NO NULL diff --git a/mysql-test/suite/sysschema/r/v_wait_classes_global_by_avg_latency.result b/mysql-test/suite/sysschema/r/v_wait_classes_global_by_avg_latency.result index f6559cb7dd7..52d506ea575 100644 --- a/mysql-test/suite/sysschema/r/v_wait_classes_global_by_avg_latency.result +++ b/mysql-test/suite/sysschema/r/v_wait_classes_global_by_avg_latency.result @@ -2,10 +2,10 @@ DESC sys.wait_classes_global_by_avg_latency; Field Type Null Key Default Extra event_class varchar(128) YES NULL total decimal(42,0) YES NULL -total_latency text YES NULL -min_latency text YES NULL -avg_latency text YES NULL -max_latency text YES NULL +total_latency varchar(12) YES NULL +min_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL SELECT * FROM sys.wait_classes_global_by_avg_latency; DESC sys.x$wait_classes_global_by_avg_latency; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_wait_classes_global_by_latency.result b/mysql-test/suite/sysschema/r/v_wait_classes_global_by_latency.result index 10db5ead78b..95f619619eb 100644 --- a/mysql-test/suite/sysschema/r/v_wait_classes_global_by_latency.result +++ b/mysql-test/suite/sysschema/r/v_wait_classes_global_by_latency.result @@ -2,10 +2,10 @@ DESC sys.wait_classes_global_by_latency; Field Type Null Key Default Extra event_class varchar(128) YES NULL total decimal(42,0) YES NULL -total_latency text YES NULL -min_latency text YES NULL -avg_latency text YES NULL -max_latency text YES NULL +total_latency varchar(12) YES NULL +min_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL SELECT * FROM sys.wait_classes_global_by_latency; DESC sys.x$wait_classes_global_by_latency; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_waits_by_host_by_latency.result b/mysql-test/suite/sysschema/r/v_waits_by_host_by_latency.result index 5e595d9cf85..cbbed779a59 100644 --- a/mysql-test/suite/sysschema/r/v_waits_by_host_by_latency.result +++ b/mysql-test/suite/sysschema/r/v_waits_by_host_by_latency.result @@ -3,9 +3,9 @@ Field Type Null Key Default Extra host varchar(255) YES NULL event varchar(128) NO NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL -avg_latency text YES NULL -max_latency text YES NULL +total_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL SELECT * FROM sys.waits_by_host_by_latency; DESC sys.x$waits_by_host_by_latency; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_waits_by_user_by_latency.result b/mysql-test/suite/sysschema/r/v_waits_by_user_by_latency.result index 860db68cc50..369b3a18423 100644 --- a/mysql-test/suite/sysschema/r/v_waits_by_user_by_latency.result +++ b/mysql-test/suite/sysschema/r/v_waits_by_user_by_latency.result @@ -3,9 +3,9 @@ Field Type Null Key Default Extra user varchar(128) YES NULL event varchar(128) NO NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL -avg_latency text YES NULL -max_latency text YES NULL +total_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL SELECT * FROM sys.waits_by_user_by_latency; DESC sys.x$waits_by_user_by_latency; Field Type Null Key Default Extra diff --git a/mysql-test/suite/sysschema/r/v_waits_global_by_latency.result b/mysql-test/suite/sysschema/r/v_waits_global_by_latency.result index 1e32a9b8ff0..0fafb72389e 100644 --- a/mysql-test/suite/sysschema/r/v_waits_global_by_latency.result +++ b/mysql-test/suite/sysschema/r/v_waits_global_by_latency.result @@ -2,9 +2,9 @@ DESC sys.waits_global_by_latency; Field Type Null Key Default Extra events varchar(128) NO NULL total bigint(20) unsigned NO NULL -total_latency text YES NULL -avg_latency text YES NULL -max_latency text YES NULL +total_latency varchar(12) YES NULL +avg_latency varchar(12) YES NULL +max_latency varchar(12) YES NULL SELECT * FROM sys.waits_global_by_latency; DESC sys.x$waits_global_by_latency; Field Type Null Key Default Extra diff --git a/scripts/sys_schema/README.md b/scripts/sys_schema/README.md index 3c90f41f8e0..2f1dc74e055 100644 --- a/scripts/sys_schema/README.md +++ b/scripts/sys_schema/README.md @@ -5323,8 +5323,8 @@ mysql> CREATE OR REPLACE VIEW mydb.my_statements AS -> SELECT sys.format_statement(DIGEST_TEXT) AS query, -> SCHEMA_NAME AS db, -> COUNT_STAR AS exec_count, - -> sys.format_time(SUM_TIMER_WAIT) AS total_latency, - -> sys.format_time(AVG_TIMER_WAIT) AS avg_latency, + -> format_pico_time(SUM_TIMER_WAIT) AS total_latency, + -> format_pico_time(AVG_TIMER_WAIT) AS avg_latency, -> ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg, -> ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg, -> ROUND(IFNULL(SUM_ROWS_AFFECTED / NULLIF(COUNT_STAR, 0), 0)) AS rows_affected_avg, diff --git a/scripts/sys_schema/functions/format_time.sql b/scripts/sys_schema/functions/format_time.sql index f828f791e96..47ee0b85cb0 100644 --- a/scripts/sys_schema/functions/format_time.sql +++ b/scripts/sys_schema/functions/format_time.sql @@ -26,7 +26,9 @@ CREATE DEFINER='mariadb.sys'@'localhost' FUNCTION format_time ( COMMENT ' Description ----------- - + + OBSOLETE. USE BUILT-IN format_pico_time() INSTEAD + Takes a raw picoseconds value, and converts it to a human readable form. Picoseconds are the precision that all latency values are printed in diff --git a/scripts/sys_schema/functions/ps_thread_trx_info.sql b/scripts/sys_schema/functions/ps_thread_trx_info.sql index 12ab6aefc56..e0f7d17970d 100644 --- a/scripts/sys_schema/functions/ps_thread_trx_info.sql +++ b/scripts/sys_schema/functions/ps_thread_trx_info.sql @@ -172,7 +172,7 @@ BEGIN GROUP_CONCAT( IFNULL( CONCAT('\n {\n', - ' "time": "', IFNULL(sys.format_time(trxi.timer_wait), ''), '",\n', + ' "time": "', IFNULL(format_pico_time(trxi.timer_wait), ''), '",\n', ' "state": "', IFNULL(trxi.state, ''), '",\n', ' "mode": "', IFNULL(trxi.access_mode, ''), '",\n', ' "autocommitted": "', IFNULL(trxi.autocommit, ''), '",\n', @@ -200,7 +200,7 @@ BEGIN IFNULL( CONCAT('\n {\n', ' "sql_text": "', IFNULL(sys.format_statement(REPLACE(sql_text, '\\', '\\\\')), ''), '",\n', - ' "time": "', IFNULL(sys.format_time(timer_wait), ''), '",\n', + ' "time": "', IFNULL(format_pico_time(timer_wait), ''), '",\n', ' "schema": "', IFNULL(current_schema, ''), '",\n', ' "rows_examined": ', IFNULL(rows_examined, ''), ',\n', ' "rows_affected": ', IFNULL(rows_affected, ''), ',\n', diff --git a/scripts/sys_schema/procedures/diagnostics.sql b/scripts/sys_schema/procedures/diagnostics.sql index 2e79c5c1c2a..2d2f4664a2d 100644 --- a/scripts/sys_schema/procedures/diagnostics.sql +++ b/scripts/sys_schema/procedures/diagnostics.sql @@ -355,7 +355,7 @@ BEGIN ) THEN CONCAT(''sys.format_bytes('', COLUMN_NAME, '') AS '', COLUMN_NAME) WHEN SUBSTRING(COLUMN_NAME, -8) = ''_latency'' - THEN CONCAT(''sys.format_time('', COLUMN_NAME, '') AS '', COLUMN_NAME) + THEN CONCAT(''format_pico_time('', COLUMN_NAME, '') AS '', COLUMN_NAME) WHEN SUBSTRING(COLUMN_NAME, -7) = ''_memory'' OR SUBSTRING(COLUMN_NAME, -17) = ''_memory_allocated'' OR ((SUBSTRING(COLUMN_NAME, -5) = ''_read'' OR SUBSTRING(COLUMN_NAME, -8) = ''_written'' OR SUBSTRING(COLUMN_NAME, -6) = ''_write'') AND SUBSTRING(COLUMN_NAME, 1, 6) <> ''COUNT_'') THEN CONCAT(''sys.format_bytes('', COLUMN_NAME, '') AS '', COLUMN_NAME) @@ -385,15 +385,15 @@ BEGIN ) THEN CONCAT(''sys.format_bytes(e.'', COLUMN_NAME, ''-IFNULL(s.'', COLUMN_NAME, '', 0)) AS '', COLUMN_NAME) WHEN SUBSTRING(COLUMN_NAME, 1, 4) IN (''max_'', ''min_'') AND SUBSTRING(COLUMN_NAME, -8) = ''_latency'' - THEN CONCAT(''sys.format_time(e.'', COLUMN_NAME, '') AS '', COLUMN_NAME) + THEN CONCAT(''format_pico_time(e.'', COLUMN_NAME, '') AS '', COLUMN_NAME) WHEN COLUMN_NAME = ''avg_latency'' - THEN CONCAT(''sys.format_time((e.total_latency - IFNULL(s.total_latency, 0))'', + THEN CONCAT(''format_pico_time((e.total_latency - IFNULL(s.total_latency, 0))'', ''/NULLIF(e.total - IFNULL(s.total, 0), 0)) AS '', COLUMN_NAME) WHEN SUBSTRING(COLUMN_NAME, -12) = ''_avg_latency'' - THEN CONCAT(''sys.format_time((e.'', SUBSTRING(COLUMN_NAME FROM 1 FOR CHAR_LENGTH(COLUMN_NAME)-12), ''_latency - IFNULL(s.'', SUBSTRING(COLUMN_NAME FROM 1 FOR CHAR_LENGTH(COLUMN_NAME)-12), ''_latency, 0))'', + THEN CONCAT(''format_pico_time((e.'', SUBSTRING(COLUMN_NAME FROM 1 FOR CHAR_LENGTH(COLUMN_NAME)-12), ''_latency - IFNULL(s.'', SUBSTRING(COLUMN_NAME FROM 1 FOR CHAR_LENGTH(COLUMN_NAME)-12), ''_latency, 0))'', ''/NULLIF(e.'', SUBSTRING(COLUMN_NAME FROM 1 FOR CHAR_LENGTH(COLUMN_NAME)-12), ''s - IFNULL(s.'', SUBSTRING(COLUMN_NAME FROM 1 FOR CHAR_LENGTH(COLUMN_NAME)-12), ''s, 0), 0)) AS '', COLUMN_NAME) WHEN SUBSTRING(COLUMN_NAME, -8) = ''_latency'' - THEN CONCAT(''sys.format_time(e.'', COLUMN_NAME, '' - IFNULL(s.'', COLUMN_NAME, '', 0)) AS '', COLUMN_NAME) + THEN CONCAT(''format_pico_time(e.'', COLUMN_NAME, '' - IFNULL(s.'', COLUMN_NAME, '', 0)) AS '', COLUMN_NAME) WHEN COLUMN_NAME IN (''avg_read'', ''avg_write'', ''avg_written'') THEN CONCAT(''sys.format_bytes(IFNULL((e.total_'', IF(COLUMN_NAME = ''avg_read'', ''read'', ''written''), ''-IFNULL(s.total_'', IF(COLUMN_NAME = ''avg_read'', ''read'', ''written''), '', 0))'', ''/NULLIF(e.count_'', IF(COLUMN_NAME = ''avg_read'', ''read'', ''write''), ''-IFNULL(s.count_'', IF(COLUMN_NAME = ''avg_read'', ''read'', ''write''), '', 0), 0), 0)) AS '', @@ -1061,4 +1061,4 @@ SELECT ''UNIX_TIMESTAMP()'' AS Variable_name, ROUND(UNIX_TIMESTAMP(NOW(3)), 3) A END IF; END$$ -DELIMITER ;
\ No newline at end of file +DELIMITER ; diff --git a/scripts/sys_schema/procedures/ps_trace_statement_digest.sql b/scripts/sys_schema/procedures/ps_trace_statement_digest.sql index f9bb4d3b09e..6ad01e4d8d8 100644 --- a/scripts/sys_schema/procedures/ps_trace_statement_digest.sql +++ b/scripts/sys_schema/procedures/ps_trace_statement_digest.sql @@ -240,8 +240,8 @@ BEGIN SELECT "SUMMARY STATISTICS"; SELECT COUNT(*) executions, - sys.format_time(SUM(timer_wait)) AS exec_time, - sys.format_time(SUM(lock_time)) AS lock_time, + format_pico_time(SUM(timer_wait)) AS exec_time, + format_pico_time(SUM(lock_time)) AS lock_time, SUM(rows_sent) AS rows_sent, SUM(rows_affected) AS rows_affected, SUM(rows_examined) AS rows_examined, @@ -251,7 +251,7 @@ BEGIN SELECT event_name, COUNT(*) as count, - sys.format_time(SUM(timer_wait)) as latency + format_pico_time(SUM(timer_wait)) as latency FROM stmt_stages GROUP BY event_name ORDER BY SUM(timer_wait) DESC; @@ -259,8 +259,8 @@ BEGIN SELECT "LONGEST RUNNING STATEMENT"; SELECT thread_id, - sys.format_time(timer_wait) AS exec_time, - sys.format_time(lock_time) AS lock_time, + format_pico_time(timer_wait) AS exec_time, + format_pico_time(lock_time) AS lock_time, rows_sent, rows_affected, rows_examined, @@ -279,7 +279,7 @@ BEGIN IF (@sql_id IS NOT NULL) THEN SELECT event_name, - sys.format_time(timer_wait) as latency + format_pico_time(timer_wait) as latency FROM stmt_stages WHERE stmt_id = @sql_id ORDER BY event_id; diff --git a/scripts/sys_schema/procedures/ps_trace_thread.sql b/scripts/sys_schema/procedures/ps_trace_thread.sql index 1a2ede79a77..4d5ba14a84d 100644 --- a/scripts/sys_schema/procedures/ps_trace_thread.sql +++ b/scripts/sys_schema/procedures/ps_trace_thread.sql @@ -116,7 +116,7 @@ BEGIN SELECT CONCAT(IF(nesting_event_id IS NOT NULL, CONCAT(nesting_event_id, ' -> '), ''), event_id, '; ', event_id, ' [label="', -- Convert from picoseconds to microseconds - '(', sys.format_time(timer_wait), ') ', + '(', format_pico_time(timer_wait), ') ', IF (event_name NOT LIKE 'wait/io%', SUBSTRING_INDEX(event_name, '/', -2), IF (event_name NOT LIKE 'wait/io/file%' OR event_name NOT LIKE 'wait/io/socket%', @@ -170,7 +170,7 @@ BEGIN CONCAT(sql_text, '\\n', 'errors: ', errors, '\\n', 'warnings: ', warnings, '\\n', - 'lock time: ', sys.format_time(lock_time),'\\n', + 'lock time: ', format_pico_time(lock_time),'\\n', 'rows affected: ', rows_affected, '\\n', 'rows sent: ', rows_sent, '\\n', 'rows examined: ', rows_examined, '\\n', diff --git a/scripts/sys_schema/procedures/ps_trace_thread_57.sql b/scripts/sys_schema/procedures/ps_trace_thread_57.sql index 33dc7961089..d88f824cebf 100644 --- a/scripts/sys_schema/procedures/ps_trace_thread_57.sql +++ b/scripts/sys_schema/procedures/ps_trace_thread_57.sql @@ -116,7 +116,7 @@ BEGIN SELECT CONCAT(IF(nesting_event_id IS NOT NULL, CONCAT(nesting_event_id, ' -> '), ''), event_id, '; ', event_id, ' [label="', -- Convert from picoseconds to microseconds - '(', sys.format_time(timer_wait), ') ', + '(', format_pico_time(timer_wait), ') ', IF (event_name NOT LIKE 'wait/io%', SUBSTRING_INDEX(event_name, '/', -2), IF (event_name NOT LIKE 'wait/io/file%' OR event_name NOT LIKE 'wait/io/socket%', @@ -188,7 +188,7 @@ BEGIN CONCAT('statement: ', sql_text, '\\n', 'errors: ', errors, '\\n', 'warnings: ', warnings, '\\n', - 'lock time: ', sys.format_time(lock_time),'\\n', + 'lock time: ', format_pico_time(lock_time),'\\n', 'rows affected: ', rows_affected, '\\n', 'rows sent: ', rows_sent, '\\n', 'rows examined: ', rows_examined, '\\n', diff --git a/scripts/sys_schema/procedures/statement_performance_analyzer.sql b/scripts/sys_schema/procedures/statement_performance_analyzer.sql index f98596ef913..3c26fd0b812 100644 --- a/scripts/sys_schema/procedures/statement_performance_analyzer.sql +++ b/scripts/sys_schema/procedures/statement_performance_analyzer.sql @@ -196,8 +196,8 @@ CREATE DEFINER='mariadb.sys'@'localhost' PROCEDURE statement_performance_analyze -> SELECT sys.format_statement(DIGEST_TEXT) AS query, -> SCHEMA_NAME AS db, -> COUNT_STAR AS exec_count, - -> sys.format_time(SUM_TIMER_WAIT) AS total_latency, - -> sys.format_time(AVG_TIMER_WAIT) AS avg_latency, + -> format_pico_time(SUM_TIMER_WAIT) AS total_latency, + -> format_pico_time(AVG_TIMER_WAIT) AS avg_latency, -> ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg, -> ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg, -> ROUND(IFNULL(SUM_ROWS_AFFECTED / NULLIF(COUNT_STAR, 0), 0)) AS rows_affected_avg, @@ -720,4 +720,4 @@ HAVING percentile > 0.95 END IF; END$$ -DELIMITER ;
\ No newline at end of file +DELIMITER ; diff --git a/scripts/sys_schema/views/p_s/host_summary.sql b/scripts/sys_schema/views/p_s/host_summary.sql index 080100a4241..99ed0942a9c 100644 --- a/scripts/sys_schema/views/p_s/host_summary.sql +++ b/scripts/sys_schema/views/p_s/host_summary.sql @@ -46,11 +46,11 @@ VIEW host_summary ( ) AS SELECT IF(accounts.host IS NULL, 'background', accounts.host) AS host, SUM(stmt.total) AS statements, - sys.format_time(SUM(stmt.total_latency)) AS statement_latency, - sys.format_time(IFNULL(SUM(stmt.total_latency) / NULLIF(SUM(stmt.total), 0), 0)) AS statement_avg_latency, + format_pico_time(SUM(stmt.total_latency)) AS statement_latency, + format_pico_time(IFNULL(SUM(stmt.total_latency) / NULLIF(SUM(stmt.total), 0), 0)) AS statement_avg_latency, SUM(stmt.full_scans) AS table_scans, SUM(io.ios) AS file_ios, - sys.format_time(SUM(io.io_latency)) AS file_io_latency, + format_pico_time(SUM(io.io_latency)) AS file_io_latency, SUM(accounts.current_connections) AS current_connections, SUM(accounts.total_connections) AS total_connections, COUNT(DISTINCT accounts.user) AS unique_users diff --git a/scripts/sys_schema/views/p_s/host_summary_57.sql b/scripts/sys_schema/views/p_s/host_summary_57.sql index cd0739f495f..dc5fb1e9006 100644 --- a/scripts/sys_schema/views/p_s/host_summary_57.sql +++ b/scripts/sys_schema/views/p_s/host_summary_57.sql @@ -49,11 +49,11 @@ VIEW host_summary ( ) AS SELECT IF(accounts.host IS NULL, 'background', accounts.host) AS host, SUM(stmt.total) AS statements, - sys.format_time(SUM(stmt.total_latency)) AS statement_latency, - sys.format_time(IFNULL(SUM(stmt.total_latency) / NULLIF(SUM(stmt.total), 0), 0)) AS statement_avg_latency, + format_pico_time(SUM(stmt.total_latency)) AS statement_latency, + format_pico_time(IFNULL(SUM(stmt.total_latency) / NULLIF(SUM(stmt.total), 0), 0)) AS statement_avg_latency, SUM(stmt.full_scans) AS table_scans, SUM(io.ios) AS file_ios, - sys.format_time(SUM(io.io_latency)) AS file_io_latency, + format_pico_time(SUM(io.io_latency)) AS file_io_latency, SUM(accounts.current_connections) AS current_connections, SUM(accounts.total_connections) AS total_connections, COUNT(DISTINCT user) AS unique_users, diff --git a/scripts/sys_schema/views/p_s/host_summary_by_file_io.sql b/scripts/sys_schema/views/p_s/host_summary_by_file_io.sql index e1fbf2ea29d..c8aa6f8bf87 100644 --- a/scripts/sys_schema/views/p_s/host_summary_by_file_io.sql +++ b/scripts/sys_schema/views/p_s/host_summary_by_file_io.sql @@ -40,7 +40,7 @@ VIEW host_summary_by_file_io ( ) AS SELECT IF(host IS NULL, 'background', host) AS host, SUM(count_star) AS ios, - sys.format_time(SUM(sum_timer_wait)) AS io_latency + format_pico_time(SUM(sum_timer_wait)) AS io_latency FROM performance_schema.events_waits_summary_by_host_by_event_name WHERE event_name LIKE 'wait/io/file/%' GROUP BY IF(host IS NULL, 'background', host) diff --git a/scripts/sys_schema/views/p_s/host_summary_by_file_io_type.sql b/scripts/sys_schema/views/p_s/host_summary_by_file_io_type.sql index 58567e3f7f2..f85c18a0724 100644 --- a/scripts/sys_schema/views/p_s/host_summary_by_file_io_type.sql +++ b/scripts/sys_schema/views/p_s/host_summary_by_file_io_type.sql @@ -58,8 +58,8 @@ VIEW host_summary_by_file_io_type ( SELECT IF(host IS NULL, 'background', host) AS host, event_name, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, - sys.format_time(max_timer_wait) AS max_latency + format_pico_time(sum_timer_wait) AS total_latency, + format_pico_time(max_timer_wait) AS max_latency FROM performance_schema.events_waits_summary_by_host_by_event_name WHERE event_name LIKE 'wait/io/file%' AND count_star > 0 diff --git a/scripts/sys_schema/views/p_s/host_summary_by_stages.sql b/scripts/sys_schema/views/p_s/host_summary_by_stages.sql index 97e5a7eef98..063c8a89d4b 100644 --- a/scripts/sys_schema/views/p_s/host_summary_by_stages.sql +++ b/scripts/sys_schema/views/p_s/host_summary_by_stages.sql @@ -57,8 +57,8 @@ VIEW host_summary_by_stages ( SELECT IF(host IS NULL, 'background', host) AS host, event_name, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, - sys.format_time(avg_timer_wait) AS avg_latency + format_pico_time(sum_timer_wait) AS total_latency, + format_pico_time(avg_timer_wait) AS avg_latency FROM performance_schema.events_stages_summary_by_host_by_event_name WHERE sum_timer_wait != 0 ORDER BY IF(host IS NULL, 'background', host), sum_timer_wait DESC; diff --git a/scripts/sys_schema/views/p_s/host_summary_by_statement_latency.sql b/scripts/sys_schema/views/p_s/host_summary_by_statement_latency.sql index 9eeb4c30d80..b0a902c79a2 100644 --- a/scripts/sys_schema/views/p_s/host_summary_by_statement_latency.sql +++ b/scripts/sys_schema/views/p_s/host_summary_by_statement_latency.sql @@ -45,9 +45,9 @@ VIEW host_summary_by_statement_latency ( ) AS SELECT IF(host IS NULL, 'background', host) AS host, SUM(count_star) AS total, - sys.format_time(SUM(sum_timer_wait)) AS total_latency, - sys.format_time(MAX(max_timer_wait)) AS max_latency, - sys.format_time(SUM(sum_lock_time)) AS lock_latency, + format_pico_time(SUM(sum_timer_wait)) AS total_latency, + format_pico_time(MAX(max_timer_wait)) AS max_latency, + format_pico_time(SUM(sum_lock_time)) AS lock_latency, SUM(sum_rows_sent) AS rows_sent, SUM(sum_rows_examined) AS rows_examined, SUM(sum_rows_affected) AS rows_affected, diff --git a/scripts/sys_schema/views/p_s/host_summary_by_statement_type.sql b/scripts/sys_schema/views/p_s/host_summary_by_statement_type.sql index b529cd8c68d..3a85478ecdb 100644 --- a/scripts/sys_schema/views/p_s/host_summary_by_statement_type.sql +++ b/scripts/sys_schema/views/p_s/host_summary_by_statement_type.sql @@ -52,9 +52,9 @@ VIEW host_summary_by_statement_type ( SELECT IF(host IS NULL, 'background', host) AS host, SUBSTRING_INDEX(event_name, '/', -1) AS statement, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, - sys.format_time(max_timer_wait) AS max_latency, - sys.format_time(sum_lock_time) AS lock_latency, + format_pico_time(sum_timer_wait) AS total_latency, + format_pico_time(max_timer_wait) AS max_latency, + format_pico_time(sum_lock_time) AS lock_latency, sum_rows_sent AS rows_sent, sum_rows_examined AS rows_examined, sum_rows_affected AS rows_affected, diff --git a/scripts/sys_schema/views/p_s/io_by_thread_by_latency.sql b/scripts/sys_schema/views/p_s/io_by_thread_by_latency.sql index c5bf1c693c2..a4e87dd7ace 100644 --- a/scripts/sys_schema/views/p_s/io_by_thread_by_latency.sql +++ b/scripts/sys_schema/views/p_s/io_by_thread_by_latency.sql @@ -56,10 +56,10 @@ SELECT IF(processlist_id IS NULL, CONCAT(processlist_user, '@', processlist_host) ) user, SUM(count_star) total, - sys.format_time(SUM(sum_timer_wait)) total_latency, - sys.format_time(MIN(min_timer_wait)) min_latency, - sys.format_time(AVG(avg_timer_wait)) avg_latency, - sys.format_time(MAX(max_timer_wait)) max_latency, + format_pico_time(SUM(sum_timer_wait)) total_latency, + format_pico_time(MIN(min_timer_wait)) min_latency, + format_pico_time(AVG(avg_timer_wait)) avg_latency, + format_pico_time(MAX(max_timer_wait)) max_latency, thread_id, processlist_id FROM performance_schema.events_waits_summary_by_thread_by_event_name diff --git a/scripts/sys_schema/views/p_s/io_global_by_file_by_latency.sql b/scripts/sys_schema/views/p_s/io_global_by_file_by_latency.sql index 97b0aae97c1..793d4bd7a2d 100644 --- a/scripts/sys_schema/views/p_s/io_global_by_file_by_latency.sql +++ b/scripts/sys_schema/views/p_s/io_global_by_file_by_latency.sql @@ -47,12 +47,12 @@ VIEW io_global_by_file_by_latency ( ) AS SELECT sys.format_path(file_name) AS file, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, + format_pico_time(sum_timer_wait) AS total_latency, count_read, - sys.format_time(sum_timer_read) AS read_latency, + format_pico_time(sum_timer_read) AS read_latency, count_write, - sys.format_time(sum_timer_write) AS write_latency, + format_pico_time(sum_timer_write) AS write_latency, count_misc, - sys.format_time(sum_timer_misc) AS misc_latency + format_pico_time(sum_timer_misc) AS misc_latency FROM performance_schema.file_summary_by_instance ORDER BY sum_timer_wait DESC; diff --git a/scripts/sys_schema/views/p_s/io_global_by_wait_by_bytes.sql b/scripts/sys_schema/views/p_s/io_global_by_wait_by_bytes.sql index edf6b994303..0ec1a26c6b6 100644 --- a/scripts/sys_schema/views/p_s/io_global_by_wait_by_bytes.sql +++ b/scripts/sys_schema/views/p_s/io_global_by_wait_by_bytes.sql @@ -62,10 +62,10 @@ VIEW io_global_by_wait_by_bytes ( ) AS SELECT SUBSTRING_INDEX(event_name, '/', -2) event_name, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, - sys.format_time(min_timer_wait) AS min_latency, - sys.format_time(avg_timer_wait) AS avg_latency, - sys.format_time(max_timer_wait) AS max_latency, + format_pico_time(sum_timer_wait) AS total_latency, + format_pico_time(min_timer_wait) AS min_latency, + format_pico_time(avg_timer_wait) AS avg_latency, + format_pico_time(max_timer_wait) AS max_latency, count_read, sys.format_bytes(sum_number_of_bytes_read) AS total_read, sys.format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read, diff --git a/scripts/sys_schema/views/p_s/io_global_by_wait_by_latency.sql b/scripts/sys_schema/views/p_s/io_global_by_wait_by_latency.sql index 5783e98ca4e..8391aae887f 100644 --- a/scripts/sys_schema/views/p_s/io_global_by_wait_by_latency.sql +++ b/scripts/sys_schema/views/p_s/io_global_by_wait_by_latency.sql @@ -63,12 +63,12 @@ VIEW io_global_by_wait_by_latency ( ) AS SELECT SUBSTRING_INDEX(event_name, '/', -2) AS event_name, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, - sys.format_time(avg_timer_wait) AS avg_latency, - sys.format_time(max_timer_wait) AS max_latency, - sys.format_time(sum_timer_read) AS read_latency, - sys.format_time(sum_timer_write) AS write_latency, - sys.format_time(sum_timer_misc) AS misc_latency, + format_pico_time(sum_timer_wait) AS total_latency, + format_pico_time(avg_timer_wait) AS avg_latency, + format_pico_time(max_timer_wait) AS max_latency, + format_pico_time(sum_timer_read) AS read_latency, + format_pico_time(sum_timer_write) AS write_latency, + format_pico_time(sum_timer_misc) AS misc_latency, count_read, sys.format_bytes(sum_number_of_bytes_read) AS total_read, sys.format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read, diff --git a/scripts/sys_schema/views/p_s/latest_file_io.sql b/scripts/sys_schema/views/p_s/latest_file_io.sql index 9803cc6cd8b..5289a831a2d 100644 --- a/scripts/sys_schema/views/p_s/latest_file_io.sql +++ b/scripts/sys_schema/views/p_s/latest_file_io.sql @@ -46,7 +46,7 @@ SELECT IF(id IS NULL, CONCAT(user, '@', host, ':', id) ) thread, sys.format_path(object_name) file, - sys.format_time(timer_wait) AS latency, + format_pico_time(timer_wait) AS latency, operation, sys.format_bytes(number_of_bytes) AS requested FROM performance_schema.events_waits_history_long diff --git a/scripts/sys_schema/views/p_s/processlist.sql b/scripts/sys_schema/views/p_s/processlist.sql index 33e8969f73f..e289a07bd34 100644 --- a/scripts/sys_schema/views/p_s/processlist.sql +++ b/scripts/sys_schema/views/p_s/processlist.sql @@ -82,9 +82,9 @@ SELECT pps.thread_id AS thd_id, pps.processlist_time AS time, sys.format_statement(pps.processlist_info) AS current_statement, IF(esc.end_event_id IS NULL, - sys.format_time(esc.timer_wait), + format_pico_time(esc.timer_wait), NULL) AS statement_latency, - sys.format_time(esc.lock_time) AS lock_latency, + format_pico_time(esc.lock_time) AS lock_latency, esc.rows_examined AS rows_examined, esc.rows_sent AS rows_sent, esc.rows_affected AS rows_affected, @@ -95,12 +95,12 @@ SELECT pps.thread_id AS thd_id, sys.format_statement(esc.sql_text), NULL) AS last_statement, IF(esc.end_event_id IS NOT NULL, - sys.format_time(esc.timer_wait), + format_pico_time(esc.timer_wait), NULL) AS last_statement_latency, ewc.event_name AS last_wait, IF(ewc.end_event_id IS NULL AND ewc.event_name IS NOT NULL, 'Still Waiting', - sys.format_time(ewc.timer_wait)) last_wait_latency, + format_pico_time(ewc.timer_wait)) last_wait_latency, ewc.source FROM performance_schema.threads AS pps LEFT JOIN performance_schema.events_waits_current AS ewc USING (thread_id) diff --git a/scripts/sys_schema/views/p_s/processlist_57.sql b/scripts/sys_schema/views/p_s/processlist_57.sql index 4e4f21ead3f..2cb30bd09f4 100644 --- a/scripts/sys_schema/views/p_s/processlist_57.sql +++ b/scripts/sys_schema/views/p_s/processlist_57.sql @@ -98,12 +98,12 @@ SELECT pps.thread_id AS thd_id, pps.processlist_time AS time, sys.format_statement(pps.processlist_info) AS current_statement, IF(esc.end_event_id IS NULL, - sys.format_time(esc.timer_wait), + format_pico_time(esc.timer_wait), NULL) AS statement_latency, IF(esc.end_event_id IS NULL, ROUND(100 * (estc.work_completed / estc.work_estimated), 2), NULL) AS progress, - sys.format_time(esc.lock_time) AS lock_latency, + format_pico_time(esc.lock_time) AS lock_latency, esc.rows_examined AS rows_examined, esc.rows_sent AS rows_sent, esc.rows_affected AS rows_affected, @@ -114,15 +114,15 @@ SELECT pps.thread_id AS thd_id, sys.format_statement(esc.sql_text), NULL) AS last_statement, IF(esc.end_event_id IS NOT NULL, - sys.format_time(esc.timer_wait), + format_pico_time(esc.timer_wait), NULL) AS last_statement_latency, sys.format_bytes(mem.current_allocated) AS current_memory, ewc.event_name AS last_wait, IF(ewc.end_event_id IS NULL AND ewc.event_name IS NOT NULL, 'Still Waiting', - sys.format_time(ewc.timer_wait)) last_wait_latency, + format_pico_time(ewc.timer_wait)) last_wait_latency, ewc.source, - sys.format_time(etc.timer_wait) AS trx_latency, + format_pico_time(etc.timer_wait) AS trx_latency, etc.state AS trx_state, etc.autocommit AS trx_autocommit, conattr_pid.attr_value as pid, diff --git a/scripts/sys_schema/views/p_s/schema_index_statistics.sql b/scripts/sys_schema/views/p_s/schema_index_statistics.sql index 84ce7ead5cf..794af16d199 100644 --- a/scripts/sys_schema/views/p_s/schema_index_statistics.sql +++ b/scripts/sys_schema/views/p_s/schema_index_statistics.sql @@ -53,13 +53,13 @@ SELECT OBJECT_SCHEMA AS table_schema, OBJECT_NAME AS table_name, INDEX_NAME as index_name, COUNT_FETCH AS rows_selected, - sys.format_time(SUM_TIMER_FETCH) AS select_latency, + format_pico_time(SUM_TIMER_FETCH) AS select_latency, COUNT_INSERT AS rows_inserted, - sys.format_time(SUM_TIMER_INSERT) AS insert_latency, + format_pico_time(SUM_TIMER_INSERT) AS insert_latency, COUNT_UPDATE AS rows_updated, - sys.format_time(SUM_TIMER_UPDATE) AS update_latency, + format_pico_time(SUM_TIMER_UPDATE) AS update_latency, COUNT_DELETE AS rows_deleted, - sys.format_time(SUM_TIMER_INSERT) AS delete_latency + format_pico_time(SUM_TIMER_INSERT) AS delete_latency FROM performance_schema.table_io_waits_summary_by_index_usage WHERE index_name IS NOT NULL ORDER BY sum_timer_wait DESC; diff --git a/scripts/sys_schema/views/p_s/schema_table_statistics.sql b/scripts/sys_schema/views/p_s/schema_table_statistics.sql index 198d2e0ee7c..45d714a1e36 100644 --- a/scripts/sys_schema/views/p_s/schema_table_statistics.sql +++ b/scripts/sys_schema/views/p_s/schema_table_statistics.sql @@ -70,23 +70,23 @@ VIEW schema_table_statistics ( ) AS SELECT pst.object_schema AS table_schema, pst.object_name AS table_name, - sys.format_time(pst.sum_timer_wait) AS total_latency, + format_pico_time(pst.sum_timer_wait) AS total_latency, pst.count_fetch AS rows_fetched, - sys.format_time(pst.sum_timer_fetch) AS fetch_latency, + format_pico_time(pst.sum_timer_fetch) AS fetch_latency, pst.count_insert AS rows_inserted, - sys.format_time(pst.sum_timer_insert) AS insert_latency, + format_pico_time(pst.sum_timer_insert) AS insert_latency, pst.count_update AS rows_updated, - sys.format_time(pst.sum_timer_update) AS update_latency, + format_pico_time(pst.sum_timer_update) AS update_latency, pst.count_delete AS rows_deleted, - sys.format_time(pst.sum_timer_delete) AS delete_latency, + format_pico_time(pst.sum_timer_delete) AS delete_latency, fsbi.count_read AS io_read_requests, sys.format_bytes(fsbi.sum_number_of_bytes_read) AS io_read, - sys.format_time(fsbi.sum_timer_read) AS io_read_latency, + format_pico_time(fsbi.sum_timer_read) AS io_read_latency, fsbi.count_write AS io_write_requests, sys.format_bytes(fsbi.sum_number_of_bytes_write) AS io_write, - sys.format_time(fsbi.sum_timer_write) AS io_write_latency, + format_pico_time(fsbi.sum_timer_write) AS io_write_latency, fsbi.count_misc AS io_misc_requests, - sys.format_time(fsbi.sum_timer_misc) AS io_misc_latency + format_pico_time(fsbi.sum_timer_misc) AS io_misc_latency FROM performance_schema.table_io_waits_summary_by_table AS pst LEFT JOIN x$ps_schema_table_statistics_io AS fsbi ON pst.object_schema = fsbi.table_schema diff --git a/scripts/sys_schema/views/p_s/schema_table_statistics_with_buffer.sql b/scripts/sys_schema/views/p_s/schema_table_statistics_with_buffer.sql index acdaefb355f..73342194e9e 100644 --- a/scripts/sys_schema/views/p_s/schema_table_statistics_with_buffer.sql +++ b/scripts/sys_schema/views/p_s/schema_table_statistics_with_buffer.sql @@ -87,21 +87,21 @@ VIEW schema_table_statistics_with_buffer ( SELECT pst.object_schema AS table_schema, pst.object_name AS table_name, pst.count_fetch AS rows_fetched, - sys.format_time(pst.sum_timer_fetch) AS fetch_latency, + format_pico_time(pst.sum_timer_fetch) AS fetch_latency, pst.count_insert AS rows_inserted, - sys.format_time(pst.sum_timer_insert) AS insert_latency, + format_pico_time(pst.sum_timer_insert) AS insert_latency, pst.count_update AS rows_updated, - sys.format_time(pst.sum_timer_update) AS update_latency, + format_pico_time(pst.sum_timer_update) AS update_latency, pst.count_delete AS rows_deleted, - sys.format_time(pst.sum_timer_delete) AS delete_latency, + format_pico_time(pst.sum_timer_delete) AS delete_latency, fsbi.count_read AS io_read_requests, sys.format_bytes(fsbi.sum_number_of_bytes_read) AS io_read, - sys.format_time(fsbi.sum_timer_read) AS io_read_latency, + format_pico_time(fsbi.sum_timer_read) AS io_read_latency, fsbi.count_write AS io_write_requests, sys.format_bytes(fsbi.sum_number_of_bytes_write) AS io_write, - sys.format_time(fsbi.sum_timer_write) AS io_write_latency, + format_pico_time(fsbi.sum_timer_write) AS io_write_latency, fsbi.count_misc AS io_misc_requests, - sys.format_time(fsbi.sum_timer_misc) AS io_misc_latency, + format_pico_time(fsbi.sum_timer_misc) AS io_misc_latency, sys.format_bytes(ibp.allocated) AS innodb_buffer_allocated, sys.format_bytes(ibp.data) AS innodb_buffer_data, sys.format_bytes(ibp.allocated - ibp.data) AS innodb_buffer_free, diff --git a/scripts/sys_schema/views/p_s/schema_tables_with_full_table_scans.sql b/scripts/sys_schema/views/p_s/schema_tables_with_full_table_scans.sql index 6199d244dd2..5d7c898f5ec 100644 --- a/scripts/sys_schema/views/p_s/schema_tables_with_full_table_scans.sql +++ b/scripts/sys_schema/views/p_s/schema_tables_with_full_table_scans.sql @@ -44,7 +44,7 @@ VIEW schema_tables_with_full_table_scans ( SELECT object_schema, object_name, count_read AS rows_full_scanned, - sys.format_time(sum_timer_wait) AS latency + format_pico_time(sum_timer_wait) AS latency FROM performance_schema.table_io_waits_summary_by_index_usage WHERE index_name IS NULL AND count_read > 0 diff --git a/scripts/sys_schema/views/p_s/statement_analysis.sql b/scripts/sys_schema/views/p_s/statement_analysis.sql index 0d9c9cef32c..c1853311adf 100644 --- a/scripts/sys_schema/views/p_s/statement_analysis.sql +++ b/scripts/sys_schema/views/p_s/statement_analysis.sql @@ -82,10 +82,10 @@ SELECT sys.format_statement(DIGEST_TEXT) AS query, COUNT_STAR AS exec_count, SUM_ERRORS AS err_count, SUM_WARNINGS AS warn_count, - sys.format_time(SUM_TIMER_WAIT) AS total_latency, - sys.format_time(MAX_TIMER_WAIT) AS max_latency, - sys.format_time(AVG_TIMER_WAIT) AS avg_latency, - sys.format_time(SUM_LOCK_TIME) AS lock_latency, + format_pico_time(SUM_TIMER_WAIT) AS total_latency, + format_pico_time(MAX_TIMER_WAIT) AS max_latency, + format_pico_time(AVG_TIMER_WAIT) AS avg_latency, + format_pico_time(SUM_LOCK_TIME) AS lock_latency, SUM_ROWS_SENT AS rows_sent, ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg, SUM_ROWS_EXAMINED AS rows_examined, diff --git a/scripts/sys_schema/views/p_s/statements_with_full_table_scans.sql b/scripts/sys_schema/views/p_s/statements_with_full_table_scans.sql index 842173645f5..820a5a9c11c 100644 --- a/scripts/sys_schema/views/p_s/statements_with_full_table_scans.sql +++ b/scripts/sys_schema/views/p_s/statements_with_full_table_scans.sql @@ -64,7 +64,7 @@ VIEW statements_with_full_table_scans ( SELECT sys.format_statement(DIGEST_TEXT) AS query, SCHEMA_NAME as db, COUNT_STAR AS exec_count, - sys.format_time(SUM_TIMER_WAIT) AS total_latency, + format_pico_time(SUM_TIMER_WAIT) AS total_latency, SUM_NO_INDEX_USED AS no_index_used_count, SUM_NO_GOOD_INDEX_USED AS no_good_index_used_count, ROUND(IFNULL(SUM_NO_INDEX_USED / NULLIF(COUNT_STAR, 0), 0) * 100) AS no_index_used_pct, diff --git a/scripts/sys_schema/views/p_s/statements_with_runtimes_in_95th_percentile.sql b/scripts/sys_schema/views/p_s/statements_with_runtimes_in_95th_percentile.sql index 6e2489ed84c..51c5e0b1028 100644 --- a/scripts/sys_schema/views/p_s/statements_with_runtimes_in_95th_percentile.sql +++ b/scripts/sys_schema/views/p_s/statements_with_runtimes_in_95th_percentile.sql @@ -58,9 +58,9 @@ SELECT sys.format_statement(DIGEST_TEXT) AS query, COUNT_STAR AS exec_count, SUM_ERRORS AS err_count, SUM_WARNINGS AS warn_count, - sys.format_time(SUM_TIMER_WAIT) AS total_latency, - sys.format_time(MAX_TIMER_WAIT) AS max_latency, - sys.format_time(AVG_TIMER_WAIT) AS avg_latency, + format_pico_time(SUM_TIMER_WAIT) AS total_latency, + format_pico_time(MAX_TIMER_WAIT) AS max_latency, + format_pico_time(AVG_TIMER_WAIT) AS avg_latency, SUM_ROWS_SENT AS rows_sent, ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg, SUM_ROWS_EXAMINED AS rows_examined, diff --git a/scripts/sys_schema/views/p_s/statements_with_sorting.sql b/scripts/sys_schema/views/p_s/statements_with_sorting.sql index 0216a12ed4d..a26910a0749 100644 --- a/scripts/sys_schema/views/p_s/statements_with_sorting.sql +++ b/scripts/sys_schema/views/p_s/statements_with_sorting.sql @@ -58,7 +58,7 @@ VIEW statements_with_sorting ( SELECT sys.format_statement(DIGEST_TEXT) AS query, SCHEMA_NAME db, COUNT_STAR AS exec_count, - sys.format_time(SUM_TIMER_WAIT) AS total_latency, + format_pico_time(SUM_TIMER_WAIT) AS total_latency, SUM_SORT_MERGE_PASSES AS sort_merge_passes, ROUND(IFNULL(SUM_SORT_MERGE_PASSES / NULLIF(COUNT_STAR, 0), 0)) AS avg_sort_merges, SUM_SORT_SCAN AS sorts_using_scans, diff --git a/scripts/sys_schema/views/p_s/statements_with_temp_tables.sql b/scripts/sys_schema/views/p_s/statements_with_temp_tables.sql index 3f9dfbc6299..687b303f40e 100644 --- a/scripts/sys_schema/views/p_s/statements_with_temp_tables.sql +++ b/scripts/sys_schema/views/p_s/statements_with_temp_tables.sql @@ -55,7 +55,7 @@ VIEW statements_with_temp_tables ( SELECT sys.format_statement(DIGEST_TEXT) AS query, SCHEMA_NAME as db, COUNT_STAR AS exec_count, - sys.format_time(SUM_TIMER_WAIT) as total_latency, + format_pico_time(SUM_TIMER_WAIT) as total_latency, SUM_CREATED_TMP_TABLES AS memory_tmp_tables, SUM_CREATED_TMP_DISK_TABLES AS disk_tmp_tables, ROUND(IFNULL(SUM_CREATED_TMP_TABLES / NULLIF(COUNT_STAR, 0), 0)) AS avg_tmp_tables_per_query, diff --git a/scripts/sys_schema/views/p_s/user_summary.sql b/scripts/sys_schema/views/p_s/user_summary.sql index 85f08878972..a0d1e308656 100644 --- a/scripts/sys_schema/views/p_s/user_summary.sql +++ b/scripts/sys_schema/views/p_s/user_summary.sql @@ -46,11 +46,11 @@ VIEW user_summary ( ) AS SELECT IF(accounts.user IS NULL, 'background', accounts.user) AS user, SUM(stmt.total) AS statements, - sys.format_time(SUM(stmt.total_latency)) AS statement_latency, - sys.format_time(IFNULL(SUM(stmt.total_latency) / NULLIF(SUM(stmt.total), 0), 0)) AS statement_avg_latency, + format_pico_time(SUM(stmt.total_latency)) AS statement_latency, + format_pico_time(IFNULL(SUM(stmt.total_latency) / NULLIF(SUM(stmt.total), 0), 0)) AS statement_avg_latency, SUM(stmt.full_scans) AS table_scans, SUM(io.ios) AS file_ios, - sys.format_time(SUM(io.io_latency)) AS file_io_latency, + format_pico_time(SUM(io.io_latency)) AS file_io_latency, SUM(accounts.current_connections) AS current_connections, SUM(accounts.total_connections) AS total_connections, COUNT(DISTINCT host) AS unique_hosts diff --git a/scripts/sys_schema/views/p_s/user_summary_57.sql b/scripts/sys_schema/views/p_s/user_summary_57.sql index a3147a17714..07695689f84 100644 --- a/scripts/sys_schema/views/p_s/user_summary_57.sql +++ b/scripts/sys_schema/views/p_s/user_summary_57.sql @@ -49,11 +49,11 @@ VIEW user_summary ( ) AS SELECT IF(accounts.user IS NULL, 'background', accounts.user) AS user, SUM(stmt.total) AS statements, - sys.format_time(SUM(stmt.total_latency)) AS statement_latency, - sys.format_time(IFNULL(SUM(stmt.total_latency) / NULLIF(SUM(stmt.total), 0), 0)) AS statement_avg_latency, + format_pico_time(SUM(stmt.total_latency)) AS statement_latency, + format_pico_time(IFNULL(SUM(stmt.total_latency) / NULLIF(SUM(stmt.total), 0), 0)) AS statement_avg_latency, SUM(stmt.full_scans) AS table_scans, SUM(io.ios) AS file_ios, - sys.format_time(SUM(io.io_latency)) AS file_io_latency, + format_pico_time(SUM(io.io_latency)) AS file_io_latency, SUM(accounts.current_connections) AS current_connections, SUM(accounts.total_connections) AS total_connections, COUNT(DISTINCT host) AS unique_hosts, diff --git a/scripts/sys_schema/views/p_s/user_summary_by_file_io.sql b/scripts/sys_schema/views/p_s/user_summary_by_file_io.sql index 85862d50ecd..9afc2028c27 100644 --- a/scripts/sys_schema/views/p_s/user_summary_by_file_io.sql +++ b/scripts/sys_schema/views/p_s/user_summary_by_file_io.sql @@ -40,7 +40,7 @@ VIEW user_summary_by_file_io ( ) AS SELECT IF(user IS NULL, 'background', user) AS user, SUM(count_star) AS ios, - sys.format_time(SUM(sum_timer_wait)) AS io_latency + format_pico_time(SUM(sum_timer_wait)) AS io_latency FROM performance_schema.events_waits_summary_by_user_by_event_name WHERE event_name LIKE 'wait/io/file/%' GROUP BY IF(user IS NULL, 'background', user) diff --git a/scripts/sys_schema/views/p_s/user_summary_by_file_io_type.sql b/scripts/sys_schema/views/p_s/user_summary_by_file_io_type.sql index 37b4b14bc8f..665f65c339b 100644 --- a/scripts/sys_schema/views/p_s/user_summary_by_file_io_type.sql +++ b/scripts/sys_schema/views/p_s/user_summary_by_file_io_type.sql @@ -58,8 +58,8 @@ VIEW user_summary_by_file_io_type ( SELECT IF(user IS NULL, 'background', user) AS user, event_name, count_star AS total, - sys.format_time(sum_timer_wait) AS latency, - sys.format_time(max_timer_wait) AS max_latency + format_pico_time(sum_timer_wait) AS latency, + format_pico_time(max_timer_wait) AS max_latency FROM performance_schema.events_waits_summary_by_user_by_event_name WHERE event_name LIKE 'wait/io/file%' AND count_star > 0 diff --git a/scripts/sys_schema/views/p_s/user_summary_by_stages.sql b/scripts/sys_schema/views/p_s/user_summary_by_stages.sql index ab34a3ee107..8706fe06c95 100644 --- a/scripts/sys_schema/views/p_s/user_summary_by_stages.sql +++ b/scripts/sys_schema/views/p_s/user_summary_by_stages.sql @@ -57,8 +57,8 @@ VIEW user_summary_by_stages ( SELECT IF(user IS NULL, 'background', user) AS user, event_name, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, - sys.format_time(avg_timer_wait) AS avg_latency + format_pico_time(sum_timer_wait) AS total_latency, + format_pico_time(avg_timer_wait) AS avg_latency FROM performance_schema.events_stages_summary_by_user_by_event_name WHERE sum_timer_wait != 0 ORDER BY user, sum_timer_wait DESC; diff --git a/scripts/sys_schema/views/p_s/user_summary_by_statement_latency.sql b/scripts/sys_schema/views/p_s/user_summary_by_statement_latency.sql index 2c6e0b50ccf..a07989a4ad6 100644 --- a/scripts/sys_schema/views/p_s/user_summary_by_statement_latency.sql +++ b/scripts/sys_schema/views/p_s/user_summary_by_statement_latency.sql @@ -45,9 +45,9 @@ VIEW user_summary_by_statement_latency ( ) AS SELECT IF(user IS NULL, 'background', user) AS user, SUM(count_star) AS total, - sys.format_time(SUM(sum_timer_wait)) AS total_latency, - sys.format_time(SUM(max_timer_wait)) AS max_latency, - sys.format_time(SUM(sum_lock_time)) AS lock_latency, + format_pico_time(SUM(sum_timer_wait)) AS total_latency, + format_pico_time(SUM(max_timer_wait)) AS max_latency, + format_pico_time(SUM(sum_lock_time)) AS lock_latency, SUM(sum_rows_sent) AS rows_sent, SUM(sum_rows_examined) AS rows_examined, SUM(sum_rows_affected) AS rows_affected, diff --git a/scripts/sys_schema/views/p_s/user_summary_by_statement_type.sql b/scripts/sys_schema/views/p_s/user_summary_by_statement_type.sql index f9ddc2bb4ff..f5a3cfc94cd 100644 --- a/scripts/sys_schema/views/p_s/user_summary_by_statement_type.sql +++ b/scripts/sys_schema/views/p_s/user_summary_by_statement_type.sql @@ -52,9 +52,9 @@ VIEW user_summary_by_statement_type ( SELECT IF(user IS NULL, 'background', user) AS user, SUBSTRING_INDEX(event_name, '/', -1) AS statement, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, - sys.format_time(max_timer_wait) AS max_latency, - sys.format_time(sum_lock_time) AS lock_latency, + format_pico_time(sum_timer_wait) AS total_latency, + format_pico_time(max_timer_wait) AS max_latency, + format_pico_time(sum_lock_time) AS lock_latency, sum_rows_sent AS rows_sent, sum_rows_examined AS rows_examined, sum_rows_affected AS rows_affected, diff --git a/scripts/sys_schema/views/p_s/wait_classes_global_by_avg_latency.sql b/scripts/sys_schema/views/p_s/wait_classes_global_by_avg_latency.sql index faee58230a9..b707eb27b6c 100644 --- a/scripts/sys_schema/views/p_s/wait_classes_global_by_avg_latency.sql +++ b/scripts/sys_schema/views/p_s/wait_classes_global_by_avg_latency.sql @@ -45,10 +45,10 @@ VIEW wait_classes_global_by_avg_latency ( ) AS SELECT SUBSTRING_INDEX(event_name,'/', 3) AS event_class, SUM(COUNT_STAR) AS total, - sys.format_time(CAST(SUM(sum_timer_wait) AS UNSIGNED)) AS total_latency, - sys.format_time(MIN(min_timer_wait)) AS min_latency, - sys.format_time(IFNULL(SUM(sum_timer_wait) / NULLIF(SUM(COUNT_STAR), 0), 0)) AS avg_latency, - sys.format_time(CAST(MAX(max_timer_wait) AS UNSIGNED)) AS max_latency + format_pico_time(CAST(SUM(sum_timer_wait) AS UNSIGNED)) AS total_latency, + format_pico_time(MIN(min_timer_wait)) AS min_latency, + format_pico_time(IFNULL(SUM(sum_timer_wait) / NULLIF(SUM(COUNT_STAR), 0), 0)) AS avg_latency, + format_pico_time(CAST(MAX(max_timer_wait) AS UNSIGNED)) AS max_latency FROM performance_schema.events_waits_summary_global_by_event_name WHERE sum_timer_wait > 0 AND event_name != 'idle' diff --git a/scripts/sys_schema/views/p_s/wait_classes_global_by_latency.sql b/scripts/sys_schema/views/p_s/wait_classes_global_by_latency.sql index 5675c3f589a..c89bf46e6de 100644 --- a/scripts/sys_schema/views/p_s/wait_classes_global_by_latency.sql +++ b/scripts/sys_schema/views/p_s/wait_classes_global_by_latency.sql @@ -45,10 +45,10 @@ VIEW wait_classes_global_by_latency ( ) AS SELECT SUBSTRING_INDEX(event_name,'/', 3) AS event_class, SUM(COUNT_STAR) AS total, - sys.format_time(SUM(sum_timer_wait)) AS total_latency, - sys.format_time(MIN(min_timer_wait)) min_latency, - sys.format_time(IFNULL(SUM(sum_timer_wait) / NULLIF(SUM(COUNT_STAR), 0), 0)) AS avg_latency, - sys.format_time(MAX(max_timer_wait)) AS max_latency + format_pico_time(SUM(sum_timer_wait)) AS total_latency, + format_pico_time(MIN(min_timer_wait)) min_latency, + format_pico_time(IFNULL(SUM(sum_timer_wait) / NULLIF(SUM(COUNT_STAR), 0), 0)) AS avg_latency, + format_pico_time(MAX(max_timer_wait)) AS max_latency FROM performance_schema.events_waits_summary_global_by_event_name WHERE sum_timer_wait > 0 AND event_name != 'idle' diff --git a/scripts/sys_schema/views/p_s/waits_by_host_by_latency.sql b/scripts/sys_schema/views/p_s/waits_by_host_by_latency.sql index 5587fee210f..2ddad55d4e1 100644 --- a/scripts/sys_schema/views/p_s/waits_by_host_by_latency.sql +++ b/scripts/sys_schema/views/p_s/waits_by_host_by_latency.sql @@ -45,9 +45,9 @@ VIEW waits_by_host_by_latency ( SELECT IF(host IS NULL, 'background', host) AS host, event_name AS event, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, - sys.format_time(avg_timer_wait) AS avg_latency, - sys.format_time(max_timer_wait) AS max_latency + format_pico_time(sum_timer_wait) AS total_latency, + format_pico_time(avg_timer_wait) AS avg_latency, + format_pico_time(max_timer_wait) AS max_latency FROM performance_schema.events_waits_summary_by_host_by_event_name WHERE event_name != 'idle' AND sum_timer_wait > 0 diff --git a/scripts/sys_schema/views/p_s/waits_by_user_by_latency.sql b/scripts/sys_schema/views/p_s/waits_by_user_by_latency.sql index 5a6a618ecc6..63c71b3e1ae 100644 --- a/scripts/sys_schema/views/p_s/waits_by_user_by_latency.sql +++ b/scripts/sys_schema/views/p_s/waits_by_user_by_latency.sql @@ -55,9 +55,9 @@ VIEW waits_by_user_by_latency ( SELECT IF(user IS NULL, 'background', user) AS user, event_name AS event, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, - sys.format_time(avg_timer_wait) AS avg_latency, - sys.format_time(max_timer_wait) AS max_latency + format_pico_time(sum_timer_wait) AS total_latency, + format_pico_time(avg_timer_wait) AS avg_latency, + format_pico_time(max_timer_wait) AS max_latency FROM performance_schema.events_waits_summary_by_user_by_event_name WHERE event_name != 'idle' AND user IS NOT NULL diff --git a/scripts/sys_schema/views/p_s/waits_global_by_latency.sql b/scripts/sys_schema/views/p_s/waits_global_by_latency.sql index a41be3b1448..67b1a533131 100644 --- a/scripts/sys_schema/views/p_s/waits_global_by_latency.sql +++ b/scripts/sys_schema/views/p_s/waits_global_by_latency.sql @@ -43,9 +43,9 @@ VIEW waits_global_by_latency ( ) AS SELECT event_name AS event, count_star AS total, - sys.format_time(sum_timer_wait) AS total_latency, - sys.format_time(avg_timer_wait) AS avg_latency, - sys.format_time(max_timer_wait) AS max_latency + format_pico_time(sum_timer_wait) AS total_latency, + format_pico_time(avg_timer_wait) AS avg_latency, + format_pico_time(max_timer_wait) AS max_latency FROM performance_schema.events_waits_summary_global_by_event_name WHERE event_name != 'idle' AND sum_timer_wait > 0 diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index be0e2d214e0..4938f8da02b 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -104,7 +104,7 @@ SET (SQL_SOURCE handler.cc hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc item_create.cc item_func.cc item_geofunc.cc item_row.cc - item_strfunc.cc item_subselect.cc item_sum.cc item_timefunc.cc item_pfsfunc.cc + item_strfunc.cc item_subselect.cc item_sum.cc item_timefunc.cc key.cc log.cc lock.cc log_event.cc log_event_server.cc rpl_record.cc rpl_reporting.cc diff --git a/sql/item.h b/sql/item.h index 515a9abb310..5956b810d51 100644 --- a/sql/item.h +++ b/sql/item.h @@ -6371,7 +6371,6 @@ public: #include "item_jsonfunc.h" #include "item_create.h" #include "item_vers.h" -#include "item_pfsfunc.h" #endif /** diff --git a/sql/item_create.cc b/sql/item_create.cc index dc8359346a0..704d86d0ec3 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -3588,7 +3588,7 @@ Create_func_format_pico_time Create_func_format_pico_time::s_singleton; Item* Create_func_format_pico_time::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_pfs_format_pico_time(thd, arg1); + return new (thd->mem_root) Item_func_format_pico_time(thd, arg1); } diff --git a/sql/item_pfsfunc.cc b/sql/item_pfsfunc.cc deleted file mode 100644 index 8ac7df50866..00000000000 --- a/sql/item_pfsfunc.cc +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (c) 2000, 2023, 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, - 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 - 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, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -/** - @file - - @brief - This file defines all performance schema native functions - FORMAT_PICO_TIME() -*/ - -#ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation -#endif - -#include "mariadb.h" // HAVE_* - -/* - It is necessary to include set_var.h instead of item.h because there - are dependencies on include order for set_var.h and item.h. This - will be resolved later. -*/ -#include "set_var.h" - -/** format_pico_time() */ - -bool Item_func_pfs_format_pico_time::fix_length_and_dec(THD *) -{ - set_maybe_null(); - /* Format is 'AAAA.BB UUU' = 11 characters or 'AAA ps' = 6 characters. */ - m_value.set_charset(&my_charset_utf8mb3_general_ci); - return false; -} - - -String *Item_func_pfs_format_pico_time::val_str(String *str __attribute__ ((__unused__))) -{ - /* Evaluate the argument */ - double time_val= args[0]->val_real(); - - /* If argument is null, return null. */ - null_value= args[0]->null_value; - if (null_value) - return 0; - - constexpr uint64_t nano{1000}; - constexpr uint64_t micro{1000 * nano}; - constexpr uint64_t milli{1000 * micro}; - constexpr uint64_t sec{1000 * milli}; - constexpr uint64_t min{60 * sec}; - constexpr uint64_t hour{60 * min}; - constexpr uint64_t day{24 * hour}; - - /* Declaring 'volatile' as workaround for 32-bit optimization bug. */ - volatile double time_abs= abs(time_val); - - uint64_t divisor; - int len; - const char *unit; - - /* SI-approved time units. */ - if (time_abs >= day) - { - divisor= day; - unit= "d"; - } - else if (time_abs >= hour) - { - divisor= hour; - unit= "h"; - } - else if (time_abs >= min) - { - divisor= min; - unit= "min"; - } - else if (time_abs >= sec) - { - divisor= sec; - unit= "s"; - } - else if (time_abs >= milli) - { - divisor= milli; - unit= "ms"; - } - else if (time_abs >= micro) - { - divisor= micro; - unit= "us"; - } - else if (time_abs >= nano) - { - divisor= nano; - unit= "ns"; - } - else - { - divisor= 1; - unit= "ps"; - } - - if (divisor == 1) - len= snprintf(m_value_buffer, sizeof(m_value_buffer), "%3d %s", (int)time_val, unit); - else - { - double value= time_val / divisor; - if (abs(value) >= 100000.0) - len= snprintf(m_value_buffer, sizeof(m_value_buffer), "%4.2e %s", value, unit); - else - len= snprintf(m_value_buffer, sizeof(m_value_buffer), "%4.2f %s", value, unit); - } - - m_value.set(m_value_buffer, len, &my_charset_utf8mb3_general_ci); - return &m_value; -} diff --git a/sql/item_pfsfunc.h b/sql/item_pfsfunc.h deleted file mode 100644 index ee3c111e15c..00000000000 --- a/sql/item_pfsfunc.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef ITEM_PFS_FUNC_INCLUDED -#define ITEM_PFS_FUNC_INCLUDED - -/* Copyright (c) 2000, 2023, 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, - 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 - 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, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#ifdef USE_PRAGMA_INTERFACE -#pragma interface /* gcc class implementation */ -#endif - -#include "item_func.h" // Item_str_func, Item_int_func - -/** format_pico_time() */ - -class Item_func_pfs_format_pico_time : public Item_str_func { - String m_value; - char m_value_buffer[12]; - -public: - Item_func_pfs_format_pico_time(THD *thd, Item *a) - : Item_str_func(thd, a){}; - String *val_str(String *str __attribute__ ((__unused__))) override; - LEX_CSTRING func_name_cstring() const override - { - static LEX_CSTRING name= {STRING_WITH_LEN("format_pico_time")}; - return name; - } - bool fix_length_and_dec(THD *thd) override; - Item *get_copy(THD *thd) override - { - return get_item_copy<Item_func_pfs_format_pico_time>(thd, this); - } -}; - -#endif diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b38d7086548..4b2f1aecf45 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -5824,6 +5824,84 @@ bool Item_func_natural_sort_key::check_vcol_func_processor(void *arg) VCOL_NON_DETERMINISTIC); } +String *Item_func_format_pico_time::val_str_ascii(String *) +{ + double time_val= args[0]->val_real(); + + null_value= args[0]->null_value; + if (null_value) + return 0; + + constexpr ulonglong nano{1000}; + constexpr ulonglong micro{1000 * nano}; + constexpr ulonglong milli{1000 * micro}; + constexpr ulonglong sec{1000 * milli}; + constexpr ulonglong min{60 * sec}; + constexpr ulonglong hour{60 * min}; + constexpr ulonglong day{24 * hour}; + + double time_abs= fabs(time_val); + + ulonglong divisor; + size_t len; + const char *unit; + + /* SI-approved time units. */ + if (time_abs >= day) + { + divisor= day; + unit= "d"; + } + else if (time_abs >= hour) + { + divisor= hour; + unit= "h"; + } + else if (time_abs >= min) + { + divisor= min; + unit= "min"; + } + else if (time_abs >= sec) + { + divisor= sec; + unit= "s"; + } + else if (time_abs >= milli) + { + divisor= milli; + unit= "ms"; + } + else if (time_abs >= micro) + { + divisor= micro; + unit= "us"; + } + else if (time_abs >= nano) + { + divisor= nano; + unit= "ns"; + } + else + { + divisor= 1; + unit= "ps"; + } + + if (divisor == 1) + len= my_snprintf(m_value_buffer, sizeof(m_value_buffer), "%3d %s", (int)time_val, unit); + else + { + double value= time_val / divisor; + if (fabs(value) >= 100000.0) + len= snprintf(m_value_buffer, sizeof(m_value_buffer), "%4.2e %s", value, unit); + else + len= my_snprintf(m_value_buffer, sizeof(m_value_buffer), "%4.2f %s", value, unit); + } + m_value.length(len); + return &m_value; +} + #ifdef WITH_WSREP #include "wsrep_mysqld.h" #include "wsrep_server_state.h" diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 3a3c53385b0..ad68ceea3f6 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -2220,6 +2220,33 @@ public: Item *get_copy(THD *thd) override { return get_item_copy<Item_temptable_rowid>(thd, this); } }; + +class Item_func_format_pico_time : public Item_str_ascii_func +{ + /* Format is 'AAAA.BB UUU' = 11 characters or 'AAA ps' = 6 characters. */ + char m_value_buffer[12]; + String m_value; + +public: + Item_func_format_pico_time(THD *thd, Item *a): Item_str_ascii_func(thd, a) {} + String *val_str_ascii(String *) override; + LEX_CSTRING func_name_cstring() const override + { + static LEX_CSTRING name= {STRING_WITH_LEN("format_pico_time")}; + return name; + } + bool fix_length_and_dec(THD *thd) override + { + m_value.set(m_value_buffer, sizeof(m_value_buffer), default_charset()); + fix_length_and_charset(sizeof(m_value_buffer), default_charset()); + return false; + } + Item *get_copy(THD *thd) override + { + return get_item_copy<Item_func_format_pico_time>(thd, this); + } +}; + #ifdef WITH_WSREP #include "wsrep_api.h" |