summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/completion_hash.cc6
-rw-r--r--client/mysql.cc43
-rw-r--r--client/mysql_plugin.c42
-rw-r--r--client/mysqladmin.cc8
-rw-r--r--client/mysqlbinlog.cc17
-rw-r--r--client/mysqlcheck.c29
-rw-r--r--client/mysqldump.c42
-rw-r--r--client/mysqlimport.c7
-rw-r--r--client/mysqlshow.c2
-rw-r--r--client/mysqlslap.c72
-rw-r--r--client/mysqltest.cc106
-rw-r--r--client/readline.cc18
-rw-r--r--extra/comp_err.c36
-rw-r--r--extra/mariabackup/backup_mysql.cc8
-rw-r--r--extra/mariabackup/ds_buffer.cc11
-rw-r--r--extra/mariabackup/ds_compress.cc21
-rw-r--r--extra/mariabackup/ds_local.cc6
-rw-r--r--extra/mariabackup/ds_stdout.cc10
-rw-r--r--extra/mariabackup/ds_tmpfile.cc15
-rw-r--r--extra/mariabackup/ds_xbstream.cc9
-rw-r--r--extra/mariabackup/innobackupex.cc3
-rw-r--r--extra/mariabackup/xbstream.cc8
-rw-r--r--extra/mariabackup/xbstream_read.cc4
-rw-r--r--extra/mariabackup/xbstream_write.cc4
-rw-r--r--extra/mariabackup/xtrabackup.cc2
-rw-r--r--extra/my_print_defaults.c3
-rw-r--r--extra/replace.c49
-rw-r--r--extra/resolve_stack_dump.c4
-rw-r--r--include/hash.h8
-rw-r--r--include/my_alloc.h6
-rw-r--r--include/my_stack_alloc.h4
-rw-r--r--include/my_sys.h38
-rw-r--r--include/mysql.h.pp9
-rw-r--r--libmysqld/emb_qcache.cc2
-rw-r--r--libmysqld/lib_sql.cc16
-rw-r--r--libmysqld/libmysql.c28
-rw-r--r--libmysqld/libmysqld.c4
-rw-r--r--mysys/array.c25
-rw-r--r--mysys/charset.c6
-rw-r--r--mysys/file_logger.c3
-rw-r--r--mysys/get_password.c4
-rw-r--r--mysys/hash.c7
-rw-r--r--mysys/lf_alloc-pin.c6
-rw-r--r--mysys/lf_dynarray.c14
-rw-r--r--mysys/lf_hash.c6
-rw-r--r--mysys/list.c2
-rw-r--r--mysys/ma_dyncol.c37
-rw-r--r--mysys/mf_iocache.c4
-rw-r--r--mysys/mf_keycache.c18
-rw-r--r--mysys/mf_sort.c3
-rw-r--r--mysys/mf_tempdir.c5
-rw-r--r--mysys/mulalloc.c8
-rw-r--r--mysys/my_alloc.c42
-rw-r--r--mysys/my_bitmap.c3
-rw-r--r--mysys/my_compress.c13
-rw-r--r--mysys/my_default.c7
-rw-r--r--mysys/my_error.c3
-rw-r--r--mysys/my_file.c3
-rw-r--r--mysys/my_fopen.c7
-rw-r--r--mysys/my_getopt.c8
-rw-r--r--mysys/my_lib.c18
-rw-r--r--mysys/my_likely.c5
-rw-r--r--mysys/my_malloc.c176
-rw-r--r--mysys/my_open.c2
-rw-r--r--mysys/my_safehash.c6
-rw-r--r--mysys/my_static.c30
-rw-r--r--mysys/my_windac.c4
-rw-r--r--mysys/mysys_priv.h30
-rw-r--r--mysys/queues.c5
-rw-r--r--mysys/string.c12
-rw-r--r--mysys/thr_alarm.c3
-rw-r--r--mysys/thr_mutex.c20
-rw-r--r--mysys/tree.c4
-rw-r--r--mysys/waiting_threads.c6
-rw-r--r--plugin/daemon_example/daemon_example.cc2
-rw-r--r--plugin/feedback/feedback.cc2
-rw-r--r--plugin/feedback/url_base.cc6
-rw-r--r--plugin/feedback/url_http.cc6
-rw-r--r--plugin/handler_socket/handlersocket/database.cpp2
-rw-r--r--plugin/server_audit/server_audit.c2
-rw-r--r--sql-common/client.c135
-rw-r--r--sql-common/client_plugin.c41
-rw-r--r--sql/create_options.cc2
-rw-r--r--sql/datadict.cc2
-rw-r--r--sql/debug_sync.cc5
-rw-r--r--sql/derror.cc8
-rw-r--r--sql/discover.cc3
-rw-r--r--sql/event_data_objects.cc10
-rw-r--r--sql/event_data_objects.h2
-rw-r--r--sql/event_queue.cc2
-rw-r--r--sql/event_scheduler.cc3
-rw-r--r--sql/events.cc9
-rw-r--r--sql/events.h2
-rw-r--r--sql/field.cc2
-rw-r--r--sql/filesort.cc11
-rw-r--r--sql/filesort_utils.cc10
-rw-r--r--sql/gcalc_slicescan.cc2
-rw-r--r--sql/gstream.cc4
-rw-r--r--sql/ha_partition.cc81
-rw-r--r--sql/handler.cc13
-rw-r--r--sql/hash_filo.h27
-rw-r--r--sql/hostname.cc13
-rw-r--r--sql/item.cc3
-rw-r--r--sql/item_create.cc2
-rw-r--r--sql/item_func.cc13
-rw-r--r--sql/item_subselect.cc10
-rw-r--r--sql/keycaches.cc10
-rw-r--r--sql/lock.cc5
-rw-r--r--sql/log.cc28
-rw-r--r--sql/log.h2
-rw-r--r--sql/log_event.cc61
-rw-r--r--sql/log_event.h8
-rw-r--r--sql/log_event_client.cc20
-rw-r--r--sql/log_event_old.cc18
-rw-r--r--sql/log_event_server.cc34
-rw-r--r--sql/mdl.cc14
-rw-r--r--sql/mysqld.cc271
-rw-r--r--sql/mysqld.h130
-rw-r--r--sql/net_serv.cc25
-rw-r--r--sql/opt_range.cc52
-rw-r--r--sql/opt_split.cc12
-rw-r--r--sql/opt_subselect.cc4
-rw-r--r--sql/opt_trace.cc2
-rw-r--r--sql/partition_info.cc3
-rw-r--r--sql/proxy_protocol.cc3
-rw-r--r--sql/repl_failsafe.cc5
-rw-r--r--sql/rpl_filter.cc20
-rw-r--r--sql/rpl_gtid.cc58
-rw-r--r--sql/rpl_injector.cc3
-rw-r--r--sql/rpl_mi.cc15
-rw-r--r--sql/rpl_parallel.cc10
-rw-r--r--sql/rpl_rli.cc16
-rw-r--r--sql/rpl_tblmap.cc11
-rw-r--r--sql/rpl_utility.cc3
-rw-r--r--sql/rpl_utility_server.cc2
-rw-r--r--sql/semisync_master.cc4
-rw-r--r--sql/semisync_master.h2
-rw-r--r--sql/session_tracker.cc10
-rw-r--r--sql/session_tracker.h13
-rw-r--r--sql/set_var.cc7
-rw-r--r--sql/slave.cc10
-rw-r--r--sql/sp.cc2
-rw-r--r--sql/sp_cache.cc3
-rw-r--r--sql/sp_head.cc23
-rw-r--r--sql/sp_pcontext.cc6
-rw-r--r--sql/sp_rcontext.cc1
-rw-r--r--sql/sql_acl.cc91
-rw-r--r--sql/sql_array.h10
-rw-r--r--sql/sql_audit.cc2
-rw-r--r--sql/sql_base.cc11
-rw-r--r--sql/sql_binlog.cc5
-rw-r--r--sql/sql_cache.cc6
-rw-r--r--sql/sql_class.cc39
-rw-r--r--sql/sql_class.h10
-rw-r--r--sql/sql_connect.cc18
-rw-r--r--sql/sql_db.cc10
-rw-r--r--sql/sql_error.cc2
-rw-r--r--sql/sql_explain.h2
-rw-r--r--sql/sql_handler.cc7
-rw-r--r--sql/sql_hset.h9
-rw-r--r--sql/sql_insert.cc9
-rw-r--r--sql/sql_join_cache.cc15
-rw-r--r--sql/sql_lex.cc9
-rw-r--r--sql/sql_lex.h6
-rw-r--r--sql/sql_list.h3
-rw-r--r--sql/sql_manager.cc3
-rw-r--r--sql/sql_parse.cc11
-rw-r--r--sql/sql_partition.cc2
-rw-r--r--sql/sql_plugin.cc72
-rw-r--r--sql/sql_prepare.cc11
-rw-r--r--sql/sql_profile.cc5
-rw-r--r--sql/sql_profile.h4
-rw-r--r--sql/sql_repl.cc11
-rw-r--r--sql/sql_select.cc28
-rw-r--r--sql/sql_select.h2
-rw-r--r--sql/sql_servers.cc17
-rw-r--r--sql/sql_show.cc35
-rw-r--r--sql/sql_sort.h2
-rw-r--r--sql/sql_statistics.cc2
-rw-r--r--sql/sql_string.cc30
-rw-r--r--sql/sql_string.h31
-rw-r--r--sql/sql_table.cc10
-rw-r--r--sql/sql_test.cc6
-rw-r--r--sql/sql_time.cc3
-rw-r--r--sql/sql_trigger.cc8
-rw-r--r--sql/sql_type.h2
-rw-r--r--sql/sql_udf.cc15
-rw-r--r--sql/sql_window.cc6
-rw-r--r--sql/sys_vars.cc3
-rw-r--r--sql/sys_vars.ic3
-rw-r--r--sql/table.cc25
-rw-r--r--sql/table.h4
-rw-r--r--sql/table_cache.cc5
-rw-r--r--sql/temporary_tables.cc9
-rw-r--r--sql/thr_malloc.cc7
-rw-r--r--sql/thr_malloc.h4
-rw-r--r--sql/threadpool_generic.cc3
-rw-r--r--sql/tztime.cc24
-rw-r--r--sql/uniques.cc12
-rw-r--r--sql/unireg.cc4
-rw-r--r--sql/wsrep_binlog.cc2
-rw-r--r--sql/wsrep_mysqld.cc4
-rw-r--r--sql/wsrep_sst.cc14
-rw-r--r--sql/wsrep_var.cc30
-rw-r--r--storage/archive/ha_archive.cc16
-rw-r--r--storage/blackhole/ha_blackhole.cc8
-rw-r--r--storage/cassandra/ha_cassandra.cc12
-rw-r--r--storage/connect/myconn.cpp8
-rw-r--r--storage/csv/ha_tina.cc54
-rw-r--r--storage/csv/transparent_file.cc5
-rw-r--r--storage/csv/transparent_file.h1
-rw-r--r--storage/federated/ha_federated.cc6
-rw-r--r--storage/federatedx/federatedx_io_mysql.cc2
-rw-r--r--storage/federatedx/ha_federatedx.cc10
-rw-r--r--storage/heap/ha_heap.cc3
-rw-r--r--storage/heap/heapdef.h6
-rw-r--r--storage/heap/hp_block.c2
-rw-r--r--storage/heap/hp_create.c8
-rw-r--r--storage/heap/hp_open.c4
-rw-r--r--storage/heap/hp_rename.c3
-rw-r--r--storage/heap/hp_static.c21
-rw-r--r--storage/innobase/handler/ha_innodb.cc30
-rw-r--r--storage/innobase/handler/i_s.cc4
-rw-r--r--storage/innobase/include/sync0rw.ic7
-rw-r--r--storage/innobase/include/ut0new.h62
-rw-r--r--storage/innobase/log/log0log.cc4
-rw-r--r--storage/innobase/log/log0recv.cc2
-rw-r--r--storage/maria/ha_maria.cc2
-rw-r--r--storage/maria/lockman.c2
-rw-r--r--storage/maria/ma_backup.c2
-rw-r--r--storage/maria/ma_bitmap.c4
-rw-r--r--storage/maria/ma_blockrec.c21
-rw-r--r--storage/maria/ma_check.c30
-rw-r--r--storage/maria/ma_checkpoint.c10
-rw-r--r--storage/maria/ma_close.c2
-rw-r--r--storage/maria/ma_create.c9
-rw-r--r--storage/maria/ma_crypt.c10
-rw-r--r--storage/maria/ma_ft_boolean_search.c4
-rw-r--r--storage/maria/ma_ft_nlq_search.c2
-rw-r--r--storage/maria/ma_ft_parser.c4
-rw-r--r--storage/maria/ma_init.c3
-rw-r--r--storage/maria/ma_loghandler.c18
-rw-r--r--storage/maria/ma_open.c15
-rw-r--r--storage/maria/ma_packrec.c8
-rw-r--r--storage/maria/ma_pagecache.c12
-rw-r--r--storage/maria/ma_preload.c2
-rw-r--r--storage/maria/ma_recovery.c10
-rw-r--r--storage/maria/ma_rt_index.c2
-rw-r--r--storage/maria/ma_sort.c10
-rw-r--r--storage/maria/ma_state.c7
-rw-r--r--storage/maria/ma_test2.c2
-rw-r--r--storage/maria/ma_write.c7
-rw-r--r--storage/maria/maria_chk.c4
-rw-r--r--storage/maria/maria_pack.c36
-rw-r--r--storage/maria/maria_read_log.c3
-rw-r--r--storage/maria/test_ma_backup.c2
-rw-r--r--storage/maria/trnman.c8
-rw-r--r--storage/maria/unittest/ma_pagecache_single.c8
-rw-r--r--storage/maria/unittest/sequence_storage.c2
-rw-r--r--storage/maria/unittest/test_file.c2
-rw-r--r--storage/maria/unittest/trnman-t.c2
-rw-r--r--storage/mroonga/mrn_mysql_compat.h67
-rw-r--r--storage/myisam/ft_boolean_search.c4
-rw-r--r--storage/myisam/ft_nlq_search.c2
-rw-r--r--storage/myisam/ft_parser.c7
-rw-r--r--storage/myisam/ft_stopwords.c9
-rw-r--r--storage/myisam/ha_myisam.cc2
-rw-r--r--storage/myisam/mi_check.c21
-rw-r--r--storage/myisam/mi_create.c3
-rw-r--r--storage/myisam/mi_dynrec.c2
-rw-r--r--storage/myisam/mi_open.c9
-rw-r--r--storage/myisam/mi_packrec.c12
-rw-r--r--storage/myisam/mi_preload.c3
-rw-r--r--storage/myisam/mi_static.c50
-rw-r--r--storage/myisam/mi_test2.c2
-rw-r--r--storage/myisam/mi_write.c9
-rw-r--r--storage/myisam/myisamdef.h22
-rw-r--r--storage/myisam/myisamlog.c8
-rw-r--r--storage/myisam/myisampack.c20
-rw-r--r--storage/myisam/rt_index.c7
-rw-r--r--storage/myisam/sort.c17
-rw-r--r--storage/myisammrg/ha_myisammrg.cc2
-rw-r--r--storage/myisammrg/myrg_def.h5
-rw-r--r--storage/myisammrg/myrg_open.c12
-rw-r--r--storage/myisammrg/myrg_static.c12
-rw-r--r--storage/oqgraph/ha_oqgraph.cc2
-rw-r--r--storage/rocksdb/ha_rocksdb.cc27
-rw-r--r--storage/rocksdb/rdb_converter.cc2
-rw-r--r--storage/rocksdb/rdb_datadic.cc8
-rw-r--r--storage/sphinx/ha_sphinx.cc4
-rw-r--r--storage/spider/hs_client/config.cpp2
-rw-r--r--storage/spider/hs_client/hs_compat.h7
-rw-r--r--storage/spider/spd_conn.cc7
-rw-r--r--storage/spider/spd_db_mysql.cc2
-rw-r--r--storage/spider/spd_malloc.cc4
-rw-r--r--storage/spider/spd_table.cc23
-rw-r--r--storage/spider/spd_trx.cc8
-rw-r--r--strings/ctype-tis620.c4
-rw-r--r--strings/my_vsnprintf.c2
-rw-r--r--strings/xml.c4
-rw-r--r--tests/async_queries.c6
-rw-r--r--tests/mysql_client_fw.c4
-rw-r--r--tests/mysql_client_test.c4
-rw-r--r--unittest/mysys/my_malloc-t.c6
-rw-r--r--vio/vio.c29
-rw-r--r--vio/vio_priv.h4
-rw-r--r--vio/viosslfactories.c3
307 files changed, 2620 insertions, 1741 deletions
diff --git a/client/completion_hash.cc b/client/completion_hash.cc
index 0d88aa9b15e..0bfb4e879e4 100644
--- a/client/completion_hash.cc
+++ b/client/completion_hash.cc
@@ -41,15 +41,15 @@ uint hashpjw(const char *arKey, uint nKeyLength)
int completion_hash_init(HashTable *ht, uint nSize)
{
- ht->arBuckets = (Bucket **) my_malloc(nSize* sizeof(Bucket *),
- MYF(MY_ZEROFILL | MY_WME));
+ ht->arBuckets = (Bucket **) my_malloc(PSI_NOT_INSTRUMENTED,
+ nSize* sizeof(Bucket *), MYF(MY_ZEROFILL | MY_WME));
if (!ht->arBuckets)
{
ht->initialized = 0;
return FAILURE;
}
- init_alloc_root(&ht->mem_root, "completion_hash", 8192, 0, MYF(0));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &ht->mem_root, 8192, 0, MYF(0));
ht->pHashFunction = hashpjw;
ht->nTableSize = nSize;
ht->initialized = 1;
diff --git a/client/mysql.cc b/client/mysql.cc
index c30139cd96b..f3c936e3028 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1133,10 +1133,10 @@ int main(int argc,char *argv[])
charset_index= get_command_index('C');
delimiter_index= get_command_index('d');
delimiter_str= delimiter;
- default_prompt = my_strdup(getenv("MYSQL_PS1") ?
+ default_prompt = my_strdup(PSI_NOT_INSTRUMENTED, getenv("MYSQL_PS1") ?
getenv("MYSQL_PS1") :
"\\N [\\d]> ",MYF(MY_WME));
- current_prompt = my_strdup(default_prompt,MYF(MY_WME));
+ current_prompt = my_strdup(PSI_NOT_INSTRUMENTED, default_prompt,MYF(MY_WME));
prompt_counter=0;
aborted= 0;
sf_leaking_memory= 1; /* no memory leak reports yet */
@@ -1204,7 +1204,7 @@ int main(int argc,char *argv[])
sf_leaking_memory= 0;
glob_buffer.realloc(512);
completion_hash_init(&ht, 128);
- init_alloc_root(&hash_mem_root, "hash", 16384, 0, MYF(0));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &hash_mem_root, 16384, 0, MYF(0));
if (sql_connect(current_host,current_db,current_user,opt_password,
opt_silent))
{
@@ -1246,12 +1246,11 @@ int main(int argc,char *argv[])
{
/* read-history from file, default ~/.mysql_history*/
if (getenv("MYSQL_HISTFILE"))
- histfile=my_strdup(getenv("MYSQL_HISTFILE"),MYF(MY_WME));
+ histfile=my_strdup(PSI_NOT_INSTRUMENTED, getenv("MYSQL_HISTFILE"),MYF(MY_WME));
else if (getenv("HOME"))
{
- histfile=(char*) my_malloc((uint) strlen(getenv("HOME"))
- + (uint) strlen("/.mysql_history")+2,
- MYF(MY_WME));
+ histfile=(char*) my_malloc(PSI_NOT_INSTRUMENTED,
+ strlen(getenv("HOME")) + strlen("/.mysql_history")+2, MYF(MY_WME));
if (histfile)
sprintf(histfile,"%s/.mysql_history",getenv("HOME"));
char link_name[FN_REFLEN];
@@ -1273,8 +1272,8 @@ int main(int argc,char *argv[])
if (verbose)
tee_fprintf(stdout, "Reading history-file %s\n",histfile);
read_history(histfile);
- if (!(histfile_tmp= (char*) my_malloc((uint) strlen(histfile) + 5,
- MYF(MY_WME))))
+ if (!(histfile_tmp= (char*) my_malloc(PSI_NOT_INSTRUMENTED,
+ strlen(histfile) + 5, MYF(MY_WME))))
{
fprintf(stderr, "Couldn't allocate memory for temp histfile!\n");
exit(1);
@@ -1810,7 +1809,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
}
if (embedded_server_arg_count == MAX_SERVER_ARGS-1 ||
!(embedded_server_args[embedded_server_arg_count++]=
- my_strdup(argument, MYF(MY_FAE))))
+ my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE))))
{
put_info("Can't use server argument", INFO_ERROR);
return 0;
@@ -1846,7 +1845,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
{
char *start= argument;
my_free(opt_password);
- opt_password= my_strdup(argument, MYF(MY_FAE));
+ opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; // Destroy argument
if (*start)
start[1]=0 ;
@@ -1909,7 +1908,7 @@ static int get_options(int argc, char **argv)
tmp= (char *) getenv("MYSQL_HOST");
if (tmp)
- current_host= my_strdup(tmp, MYF(MY_WME));
+ current_host= my_strdup(PSI_NOT_INSTRUMENTED, tmp, MYF(MY_WME));
pagpoint= getenv("PAGER");
if (!((char*) (pagpoint)))
@@ -1951,7 +1950,7 @@ static int get_options(int argc, char **argv)
{
skip_updates= 0;
my_free(current_db);
- current_db= my_strdup(*argv, MYF(MY_WME));
+ current_db= my_strdup(PSI_NOT_INSTRUMENTED, *argv, MYF(MY_WME));
}
if (tty_password)
opt_password= get_tty_password(NullS);
@@ -2975,7 +2974,7 @@ static void get_current_db()
{
MYSQL_ROW row= mysql_fetch_row(res);
if (row && row[0])
- current_db= my_strdup(row[0], MYF(MY_WME));
+ current_db= my_strdup(PSI_NOT_INSTRUMENTED, row[0], MYF(MY_WME));
mysql_free_result(res);
}
}
@@ -4331,12 +4330,12 @@ com_connect(String *buffer, char *line)
if (tmp && *tmp)
{
my_free(current_db);
- current_db= my_strdup(tmp, MYF(MY_WME));
+ current_db= my_strdup(PSI_NOT_INSTRUMENTED, tmp, MYF(MY_WME));
tmp= get_arg(buff, GET_NEXT);
if (tmp)
{
my_free(current_host);
- current_host=my_strdup(tmp,MYF(MY_WME));
+ current_host=my_strdup(PSI_NOT_INSTRUMENTED, tmp,MYF(MY_WME));
}
}
else
@@ -4521,7 +4520,7 @@ com_use(String *buffer __attribute__((unused)), char *line)
return put_error(&mysql);
}
my_free(current_db);
- current_db=my_strdup(tmp,MYF(MY_WME));
+ current_db=my_strdup(PSI_NOT_INSTRUMENTED, tmp,MYF(MY_WME));
#ifdef HAVE_READLINE
if (select_db > 1)
build_completion_hash(opt_rehash, 1);
@@ -4929,7 +4928,7 @@ server_version_string(MYSQL *con)
/* version, space, comment, \0 */
size_t len= strlen(mysql_get_server_info(con)) + strlen(cur[0]) + 2;
- if ((server_version= (char *) my_malloc(len, MYF(MY_WME))))
+ if ((server_version= (char *) my_malloc(PSI_NOT_INSTRUMENTED, len, MYF(MY_WME))))
{
char *bufp;
bufp = strmov(server_version, mysql_get_server_info(con));
@@ -4946,7 +4945,7 @@ server_version_string(MYSQL *con)
*/
if (server_version == NULL)
- server_version= my_strdup(mysql_get_server_info(con), MYF(MY_WME));
+ server_version= my_strdup(PSI_NOT_INSTRUMENTED, mysql_get_server_info(con), MYF(MY_WME));
}
return server_version ? server_version : "";
@@ -5348,8 +5347,8 @@ static void init_username()
(result=mysql_use_result(&mysql)))
{
MYSQL_ROW cur=mysql_fetch_row(result);
- full_username=my_strdup(cur[0],MYF(MY_WME));
- part_username=my_strdup(strtok(cur[0],"@"),MYF(MY_WME));
+ full_username=my_strdup(PSI_NOT_INSTRUMENTED, cur[0],MYF(MY_WME));
+ part_username=my_strdup(PSI_NOT_INSTRUMENTED, strtok(cur[0],"@"),MYF(MY_WME));
(void) mysql_fetch_row(result); // Read eof
}
}
@@ -5360,7 +5359,7 @@ static int com_prompt(String *buffer __attribute__((unused)),
char *ptr=strchr(line, ' ');
prompt_counter = 0;
my_free(current_prompt);
- current_prompt=my_strdup(ptr ? ptr+1 : default_prompt,MYF(MY_WME));
+ current_prompt=my_strdup(PSI_NOT_INSTRUMENTED, ptr ? ptr+1 : default_prompt,MYF(MY_WME));
if (!ptr)
tee_fprintf(stdout, "Returning to default PROMPT of %s\n", default_prompt);
else
diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c
index 998524ac1f1..15bbc71183d 100644
--- a/client/mysql_plugin.c
+++ b/client/mysql_plugin.c
@@ -191,7 +191,7 @@ static char *get_value(char *line, const char *item)
char *s= 0;
s = line + item_len + 1;
- destination= my_strndup(s, line_len - start, MYF(MY_FAE));
+ destination= my_strndup(PSI_NOT_INSTRUMENTED, s, line_len - start, MYF(MY_FAE));
destination[line_len - item_len - 2]= 0;
}
return destination;
@@ -259,7 +259,7 @@ static int has_spaces(const char *path)
static char *convert_path(const char *argument)
{
/* Convert / to \\ to make Windows paths */
- char *winfilename= my_strdup(argument, MYF(MY_FAE));
+ char *winfilename= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
char *pos, *end;
size_t length= strlen(argument);
@@ -291,7 +291,7 @@ static char *add_quotes(const char *path)
else
snprintf(windows_cmd_friendly, sizeof(windows_cmd_friendly),
"%s", path);
- return my_strdup(windows_cmd_friendly, MYF(MY_FAE));
+ return my_strdup(PSI_NOT_INSTRUMENTED, windows_cmd_friendly, MYF(MY_FAE));
}
#endif
@@ -376,19 +376,19 @@ static int get_default_values()
if ((opt_datadir == 0) && ((value= get_value(line, "--datadir"))))
{
- opt_datadir= my_strdup(value, MYF(MY_FAE));
+ opt_datadir= my_strdup(PSI_NOT_INSTRUMENTED, value, MYF(MY_FAE));
}
if ((opt_basedir == 0) && ((value= get_value(line, "--basedir"))))
{
- opt_basedir= my_strdup(value, MYF(MY_FAE));
+ opt_basedir= my_strdup(PSI_NOT_INSTRUMENTED, value, MYF(MY_FAE));
}
if ((opt_plugin_dir == 0) && ((value= get_value(line, "--plugin_dir"))))
{
- opt_plugin_dir= my_strdup(value, MYF(MY_FAE));
+ opt_plugin_dir= my_strdup(PSI_NOT_INSTRUMENTED, value, MYF(MY_FAE));
}
if ((opt_plugin_ini == 0) && ((value= get_value(line, "--plugin_ini"))))
{
- opt_plugin_ini= my_strdup(value, MYF(MY_FAE));
+ opt_plugin_ini= my_strdup(PSI_NOT_INSTRUMENTED, value, MYF(MY_FAE));
}
}
}
@@ -497,22 +497,22 @@ get_one_option(const struct my_option *opt,
usage();
exit(0);
case 'd':
- opt_datadir= my_strdup(argument, MYF(MY_FAE));
+ opt_datadir= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
break;
case 'b':
- opt_basedir= my_strdup(argument, MYF(MY_FAE));
+ opt_basedir= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
break;
case 'p':
- opt_plugin_dir= my_strdup(argument, MYF(MY_FAE));
+ opt_plugin_dir= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
break;
case 'i':
- opt_plugin_ini= my_strdup(argument, MYF(MY_FAE));
+ opt_plugin_ini= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
break;
case 'm':
- opt_mysqld= my_strdup(argument, MYF(MY_FAE));
+ opt_mysqld= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
break;
case 'f':
- opt_my_print_defaults= my_strdup(argument, MYF(MY_FAE));
+ opt_my_print_defaults= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
break;
}
return 0;
@@ -620,7 +620,7 @@ static int load_plugin_data(char *plugin_name, char *config_file)
if (opt_plugin_ini == 0)
{
fn_format(path, config_file, opt_plugin_dir, "", MYF(0));
- opt_plugin_ini= my_strdup(path, MYF(MY_FAE));
+ opt_plugin_ini= my_strdup(PSI_NOT_INSTRUMENTED, path, MYF(MY_FAE));
}
if (!file_exists(opt_plugin_ini))
{
@@ -636,7 +636,7 @@ static int load_plugin_data(char *plugin_name, char *config_file)
}
/* save name */
- plugin_data.name= my_strdup(plugin_name, MYF(MY_WME));
+ plugin_data.name= my_strdup(PSI_NOT_INSTRUMENTED, plugin_name, MYF(MY_WME));
/* Read plugin components */
while (i < 16)
@@ -666,14 +666,14 @@ static int load_plugin_data(char *plugin_name, char *config_file)
/* Add proper file extension for soname */
strcat(line, FN_SOEXT);
/* save so_name */
- plugin_data.so_name= my_strdup(line, MYF(MY_WME|MY_ZEROFILL));
+ plugin_data.so_name= my_strdup(PSI_NOT_INSTRUMENTED, line, MYF(MY_WME|MY_ZEROFILL));
i++;
}
else
{
if (strlen(line) > 0)
{
- plugin_data.components[i]= my_strdup(line, MYF(MY_WME));
+ plugin_data.components[i]= my_strdup(PSI_NOT_INSTRUMENTED, line, MYF(MY_WME));
i++;
}
else
@@ -739,21 +739,21 @@ static int check_options(int argc, char **argv, char *operation)
else if ((strncasecmp(argv[i], basedir_prefix, basedir_len) == 0) &&
!opt_basedir)
{
- opt_basedir= my_strndup(argv[i]+basedir_len,
+ opt_basedir= my_strndup(PSI_NOT_INSTRUMENTED, argv[i]+basedir_len,
strlen(argv[i])-basedir_len, MYF(MY_FAE));
num_found++;
}
else if ((strncasecmp(argv[i], datadir_prefix, datadir_len) == 0) &&
!opt_datadir)
{
- opt_datadir= my_strndup(argv[i]+datadir_len,
+ opt_datadir= my_strndup(PSI_NOT_INSTRUMENTED, argv[i]+datadir_len,
strlen(argv[i])-datadir_len, MYF(MY_FAE));
num_found++;
}
else if ((strncasecmp(argv[i], plugin_dir_prefix, plugin_dir_len) == 0) &&
!opt_plugin_dir)
{
- opt_plugin_dir= my_strndup(argv[i]+plugin_dir_len,
+ opt_plugin_dir= my_strndup(PSI_NOT_INSTRUMENTED, argv[i]+plugin_dir_len,
strlen(argv[i])-plugin_dir_len, MYF(MY_FAE));
num_found++;
}
@@ -866,7 +866,7 @@ static int process_options(int argc, char *argv[], char *operation)
#endif
buff[sizeof(buff) - 1]= 0;
my_free(opt_basedir);
- opt_basedir= my_strdup(buff, MYF(MY_FAE));
+ opt_basedir= my_strdup(PSI_NOT_INSTRUMENTED, buff, MYF(MY_FAE));
}
}
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index bc1403b283a..1a128e61533 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -254,7 +254,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
{
char *start=argument;
my_free(opt_password);
- opt_password=my_strdup(argument,MYF(MY_FAE));
+ opt_password=my_strdup(PSI_NOT_INSTRUMENTED, argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
@@ -1357,11 +1357,11 @@ static char **mask_password(int argc, char ***argv)
if (!argc)
return NULL;
- temp_argv= (char **)(my_malloc(sizeof(char *) * argc, MYF(MY_WME)));
+ temp_argv= (char **)(my_malloc(PSI_NOT_INSTRUMENTED, sizeof(char *) * argc, MYF(MY_WME)));
argc--;
while (argc > 0)
{
- temp_argv[argc]= my_strdup((*argv)[argc], MYF(MY_FAE));
+ temp_argv[argc]= my_strdup(PSI_NOT_INSTRUMENTED, (*argv)[argc], MYF(MY_FAE));
if (find_type((*argv)[argc - 1],&command_typelib, FIND_TYPE_BASIC) == ADMIN_PASSWORD ||
find_type((*argv)[argc - 1],&command_typelib, FIND_TYPE_BASIC) == ADMIN_OLD_PASSWORD)
{
@@ -1374,7 +1374,7 @@ static char **mask_password(int argc, char ***argv)
}
argc--;
}
- temp_argv[argc]= my_strdup((*argv)[argc], MYF(MY_FAE));
+ temp_argv[argc]= my_strdup(PSI_NOT_INSTRUMENTED, (*argv)[argc], MYF(MY_FAE));
return(temp_argv);
}
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 47a7f9e01b2..309743723cc 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -61,6 +61,9 @@
extern "C" unsigned char *mysql_net_store_length(unsigned char *packet, size_t length);
#define net_store_length mysql_net_store_length
+#define key_memory_TABLE_RULE_ENT 0
+#define key_memory_rpl_filter 0
+
Rpl_filter *binlog_filter= 0;
#define BIN_LOG_HEADER_SIZE 4
@@ -196,7 +199,7 @@ Log_event* read_remote_annotate_event(uchar* net_buf, ulong event_len,
uchar *event_buf;
Log_event* event;
- if (!(event_buf= (uchar*) my_malloc(event_len + 1, MYF(MY_WME))))
+ if (!(event_buf= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, event_len + 1, MYF(MY_WME))))
{
error("Out of memory");
return 0;
@@ -308,7 +311,7 @@ public:
int init()
{
- return my_init_dynamic_array(&file_names, sizeof(File_name_record),
+ return my_init_dynamic_array(&file_names, PSI_NOT_INSTRUMENTED, sizeof(File_name_record),
100, 100, MYF(0));
}
@@ -543,7 +546,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
File_name_record rec;
DBUG_ENTER("Load_log_processor::process_first_event");
- if (!(fname= (char*) my_malloc(full_len,MYF(MY_WME))))
+ if (!(fname= (char*) my_malloc(PSI_NOT_INSTRUMENTED, full_len,MYF(MY_WME))))
{
error("Out of memory.");
delete ce;
@@ -1958,7 +1961,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
{
my_free(pass);
char *start=argument;
- pass= my_strdup(argument,MYF(MY_FAE));
+ pass= my_strdup(PSI_NOT_INSTRUMENTED, argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
@@ -3044,9 +3047,9 @@ int main(int argc, char** argv)
if (opt_flashback)
{
- my_init_dynamic_array(&binlog_events, sizeof(LEX_STRING), 1024, 1024,
+ my_init_dynamic_array(&binlog_events, PSI_NOT_INSTRUMENTED, sizeof(LEX_STRING), 1024, 1024,
MYF(0));
- my_init_dynamic_array(&events_in_stmt, sizeof(Rows_log_event*), 1024, 1024,
+ my_init_dynamic_array(&events_in_stmt, PSI_NOT_INSTRUMENTED, sizeof(Rows_log_event*), 1024, 1024,
MYF(0));
}
if (opt_stop_never)
@@ -3095,7 +3098,7 @@ int main(int argc, char** argv)
retval= ERROR_STOP;
goto err;
}
- dirname_for_local_load= my_strdup(my_tmpdir(&tmpdir), MY_WME);
+ dirname_for_local_load= my_strdup(PSI_NOT_INSTRUMENTED, my_tmpdir(&tmpdir), MY_WME);
}
if (load_processor.init())
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index e949c8059bf..a8dc25163c6 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -326,7 +326,7 @@ get_one_option(const struct my_option *opt,
{
char *start = argument;
my_free(opt_password);
- opt_password = my_strdup(argument, MYF(MY_FAE));
+ opt_password = my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
start[1] = 0; /* Cut length of argument */
@@ -567,7 +567,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
tot_length+= fixed_name_length(*(table_names + i)) + 2;
if (!(table_names_comma_sep = (char *)
- my_malloc((sizeof(char) * tot_length) + 4, MYF(MY_WME))))
+ my_malloc(PSI_NOT_INSTRUMENTED, tot_length + 4, MYF(MY_WME))))
DBUG_RETURN(1);
for (end = table_names_comma_sep + 1; tables > 0;
@@ -678,12 +678,12 @@ static int process_all_tables_in_db(char *database)
}
mysql_data_seek(res, 0);
- if (!(tables=(char *) my_malloc(sizeof(char)*tot_length+4, MYF(MY_WME))))
+ if (!(tables=(char *) my_malloc(PSI_NOT_INSTRUMENTED, tot_length+4, MYF(MY_WME))))
{
mysql_free_result(res);
DBUG_RETURN(1);
}
- if (!(views=(char *) my_malloc(sizeof(char)*tot_views_length+4, MYF(MY_WME))))
+ if (!(views=(char *) my_malloc(PSI_NOT_INSTRUMENTED, tot_views_length+4, MYF(MY_WME))))
{
my_free(tables);
mysql_free_result(res);
@@ -799,8 +799,7 @@ static int rebuild_table(char *name)
int rc= 0;
DBUG_ENTER("rebuild_table");
- query= (char*)my_malloc(sizeof(char) * (12 + strlen(name) + 6 + 1),
- MYF(MY_WME));
+ query= (char*)my_malloc(PSI_NOT_INSTRUMENTED, 12+strlen(name)+6+1, MYF(MY_WME));
if (!query)
DBUG_RETURN(1);
ptr= strxmov(query, "ALTER TABLE ", name, " FORCE", NullS);
@@ -938,7 +937,7 @@ static int handle_request_for_tables(char *tables, size_t length,
DBUG_RETURN(fix_table_storage_name(tables));
}
- if (!(query =(char *) my_malloc(query_size, MYF(MY_WME))))
+ if (!(query =(char *) my_malloc(PSI_NOT_INSTRUMENTED, query_size, MYF(MY_WME))))
DBUG_RETURN(1);
if (dont_quote)
{
@@ -1195,14 +1194,14 @@ int main(int argc, char **argv)
}
if (opt_auto_repair &&
- (my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16,
- 64, MYF(0)) ||
- my_init_dynamic_array(&views4repair, sizeof(char)*(NAME_LEN*2+2),16,
- 64, MYF(0)) ||
- my_init_dynamic_array(&tables4rebuild, sizeof(char)*(NAME_LEN*2+2),16,
- 64, MYF(0)) ||
- my_init_dynamic_array(&alter_table_cmds, MAX_ALTER_STR_SIZE, 0, 1,
- MYF(0))))
+ (my_init_dynamic_array(&tables4repair, PSI_NOT_INSTRUMENTED,
+ NAME_LEN*2+2, 16, 64, MYF(0)) ||
+ my_init_dynamic_array(&views4repair, PSI_NOT_INSTRUMENTED,
+ NAME_LEN*2+2, 16, 64, MYF(0)) ||
+ my_init_dynamic_array(&tables4rebuild, PSI_NOT_INSTRUMENTED,
+ NAME_LEN*2+2, 16, 64, MYF(0)) ||
+ my_init_dynamic_array(&alter_table_cmds, PSI_NOT_INSTRUMENTED,
+ MAX_ALTER_STR_SIZE, 0, 1, MYF(0))))
goto end;
if (opt_alldbs)
diff --git a/client/mysqldump.c b/client/mysqldump.c
index f932420aef0..26866b6cb14 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -826,7 +826,7 @@ get_one_option(const struct my_option *opt,
{
char *start=argument;
my_free(opt_password);
- opt_password=my_strdup(argument,MYF(MY_FAE));
+ opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
@@ -908,7 +908,8 @@ get_one_option(const struct my_option *opt,
opt_databases=0;
break;
case (int) OPT_IGNORE_DATABASE:
- if (my_hash_insert(&ignore_database, (uchar*) my_strdup(argument, MYF(0))))
+ if (my_hash_insert(&ignore_database,
+ (uchar*) my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(0))))
exit(EX_EOM);
break;
case (int) OPT_IGNORE_TABLE:
@@ -918,7 +919,8 @@ get_one_option(const struct my_option *opt,
fprintf(stderr, "Illegal use of option --ignore-table=<database>.<table>\n");
exit(1);
}
- if (my_hash_insert(&ignore_table, (uchar*)my_strdup(argument, MYF(0))))
+ if (my_hash_insert(&ignore_table,
+ (uchar*)my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(0))))
exit(EX_EOM);
break;
}
@@ -1000,22 +1002,22 @@ static int get_options(int *argc, char ***argv)
defaults_argv= *argv;
if (my_hash_init(&ignore_database, charset_info, 16, 0, 0,
- (my_hash_get_key) get_table_key, my_free, 0))
+ (my_hash_get_key) get_table_key, my_free, 0, PSI_NOT_INSTRUMENTED))
return(EX_EOM);
if (my_hash_init(&ignore_table, charset_info, 16, 0, 0,
- (my_hash_get_key) get_table_key, my_free, 0))
+ (my_hash_get_key) get_table_key, my_free, 0, PSI_NOT_INSTRUMENTED))
return(EX_EOM);
/* Don't copy internal log tables */
- if (my_hash_insert(&ignore_table,
- (uchar*) my_strdup("mysql.apply_status", MYF(MY_WME))) ||
- my_hash_insert(&ignore_table,
- (uchar*) my_strdup("mysql.schema", MYF(MY_WME))) ||
- my_hash_insert(&ignore_table,
- (uchar*) my_strdup("mysql.general_log", MYF(MY_WME))) ||
- my_hash_insert(&ignore_table,
- (uchar*) my_strdup("mysql.slow_log", MYF(MY_WME))) ||
- my_hash_insert(&ignore_table,
- (uchar*) my_strdup("mysql.transaction_registry", MYF(MY_WME))))
+ if (my_hash_insert(&ignore_table, (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.apply_status", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table, (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.schema", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table, (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.general_log", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table, (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.slow_log", MYF(MY_WME))) ||
+ my_hash_insert(&ignore_table, (uchar*) my_strdup(PSI_NOT_INSTRUMENTED,
+ "mysql.transaction_registry", MYF(MY_WME))))
return(EX_EOM);
if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))
@@ -1793,7 +1795,7 @@ static void unescape(FILE *file,char *pos, size_t length)
{
char *tmp;
DBUG_ENTER("unescape");
- if (!(tmp=(char*) my_malloc(length*2+1, MYF(MY_WME))))
+ if (!(tmp=(char*) my_malloc(PSI_NOT_INSTRUMENTED, length*2+1, MYF(MY_WME))))
die(EX_MYSQLERR, "Couldn't allocate memory");
mysql_real_escape_string(&mysql_connection, tmp, pos, (ulong)length);
@@ -2876,7 +2878,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
/* save "show create" statement for later */
if ((row= mysql_fetch_row(result)) && (scv_buff=row[1]))
- scv_buff= my_strdup(scv_buff, MYF(0));
+ scv_buff= my_strdup(PSI_NOT_INSTRUMENTED, scv_buff, MYF(0));
mysql_free_result(result);
@@ -3677,7 +3679,7 @@ static char *alloc_query_str(size_t size)
{
char *query;
- if (!(query= (char*) my_malloc(size, MYF(MY_WME))))
+ if (!(query= (char*) my_malloc(PSI_NOT_INSTRUMENTED, size, MYF(MY_WME))))
die(EX_MYSQLERR, "Couldn't allocate a query string.");
return query;
@@ -5067,7 +5069,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
if (init_dumping(db, init_dumping_tables))
DBUG_RETURN(1);
- init_alloc_root(&glob_root, "glob_root", 8192, 0, MYF(0));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &glob_root, 8192, 0, MYF(0));
if (!(dump_tables= pos= (char**) alloc_root(&glob_root,
tables * sizeof(char *))))
die(EX_EOM, "alloc_root failure.");
@@ -5819,7 +5821,7 @@ static char *primary_key_fields(const char *table_name)
{
char *end;
/* result (terminating \0 is already in result_length) */
- result= my_malloc(result_length + 10, MYF(MY_WME));
+ result= my_malloc(PSI_NOT_INSTRUMENTED, result_length + 10, MYF(MY_WME));
if (!result)
{
fprintf(stderr, "Error: Not enough memory to store ORDER BY clause\n");
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 76923e036b5..9e197e4e199 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -232,7 +232,7 @@ get_one_option(const struct my_option *opt, char *argument,
{
char *start=argument;
my_free(opt_password);
- opt_password=my_strdup(argument,MYF(MY_FAE));
+ opt_password=my_strdup(PSI_NOT_INSTRUMENTED, argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
@@ -672,9 +672,8 @@ int main(int argc, char **argv)
table_count++;
argv= save_argv;
- if (!(worker_threads= (pthread_t*) my_malloc(table_count *
- sizeof(*worker_threads),
- MYF(0))))
+ if (!(worker_threads= (pthread_t*) my_malloc(PSI_NOT_INSTRUMENTED,
+ table_count * sizeof(*worker_threads), MYF(0))))
return -2;
for (; *argv != NULL; argv++) /* Loop through tables */
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index d71a8aa5132..2b0cae6dc98 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -303,7 +303,7 @@ get_one_option(const struct my_option *opt, char *argument,
{
char *start=argument;
my_free(opt_password);
- opt_password=my_strdup(argument,MYF(MY_FAE));
+ opt_password=my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 996f9bb79c6..7d3c5747b18 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -433,8 +433,8 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
unsigned long long client_limit;
int sysret;
- head_sptr= (stats *)my_malloc(sizeof(stats) * iterations,
- MYF(MY_ZEROFILL|MY_FAE|MY_WME));
+ head_sptr= (stats *)my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(stats) * iterations, MYF(MY_ZEROFILL|MY_FAE|MY_WME));
bzero(&conclusion, sizeof(conclusions));
@@ -741,7 +741,7 @@ get_one_option(const struct my_option *opt, char *argument,
{
char *start= argument;
my_free(opt_password);
- opt_password= my_strdup(argument,MYF(MY_FAE));
+ opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument,MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
start[1]= 0; /* Cut length of argument */
@@ -918,9 +918,9 @@ build_table_string(void)
}
dynstr_append(&table_string, ")");
- ptr= (statement *)my_malloc(sizeof(statement),
+ ptr= (statement *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(statement),
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
- ptr->string = (char *)my_malloc(table_string.length+1,
+ ptr->string = (char *)my_malloc(PSI_NOT_INSTRUMENTED, table_string.length+1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
ptr->length= table_string.length+1;
ptr->type= CREATE_TABLE_TYPE;
@@ -986,10 +986,10 @@ build_update_string(void)
dynstr_append(&update_string, " WHERE id = ");
- ptr= (statement *)my_malloc(sizeof(statement),
+ ptr= (statement *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(statement),
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
- ptr->string= (char *)my_malloc(update_string.length + 1,
+ ptr->string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, update_string.length + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
ptr->length= update_string.length+1;
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)
@@ -1082,9 +1082,9 @@ build_insert_string(void)
dynstr_append_mem(&insert_string, ")", 1);
- ptr= (statement *)my_malloc(sizeof(statement),
+ ptr= (statement *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(statement),
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
- ptr->string= (char *)my_malloc(insert_string.length + 1,
+ ptr->string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, insert_string.length + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
ptr->length= insert_string.length+1;
ptr->type= INSERT_TYPE;
@@ -1146,9 +1146,9 @@ build_select_string(my_bool key)
(auto_generate_sql_autoincrement || auto_generate_sql_guid_primary))
dynstr_append(&query_string, " WHERE id = ");
- ptr= (statement *)my_malloc(sizeof(statement),
+ ptr= (statement *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(statement),
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
- ptr->string= (char *)my_malloc(query_string.length + 1,
+ ptr->string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, query_string.length + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
ptr->length= query_string.length+1;
if ((key) &&
@@ -1405,7 +1405,7 @@ get_options(int *argc,char ***argv)
fprintf(stderr,"%s: Could not open create file\n", my_progname);
exit(1);
}
- tmp_string= (char *)my_malloc((size_t)sbuf.st_size + 1,
+ tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, (size_t)sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0';
@@ -1432,7 +1432,7 @@ get_options(int *argc,char ***argv)
fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
exit(1);
}
- tmp_string= (char *)my_malloc((size_t)sbuf.st_size + 1,
+ tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, (size_t)sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0';
@@ -1463,7 +1463,7 @@ get_options(int *argc,char ***argv)
fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
exit(1);
}
- tmp_string= (char *)my_malloc((size_t)sbuf.st_size + 1,
+ tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, (size_t)sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0';
@@ -1494,7 +1494,7 @@ get_options(int *argc,char ***argv)
fprintf(stderr,"%s: Could not open query supplied file\n", my_progname);
exit(1);
}
- tmp_string= (char *)my_malloc((size_t)sbuf.st_size + 1,
+ tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, (size_t)sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0';
@@ -1560,11 +1560,11 @@ generate_primary_key_list(MYSQL *mysql, option_string *engine_stmt)
strstr(engine_stmt->string, "blackhole")))
{
primary_keys_number_of= 1;
- primary_keys= (char **)my_malloc((uint)(sizeof(char *) *
- primary_keys_number_of),
- MYF(MY_ZEROFILL|MY_FAE|MY_WME));
+ primary_keys= (char **)my_malloc(PSI_NOT_INSTRUMENTED,
+ (size_t)(sizeof(char *) * primary_keys_number_of),
+ MYF(MY_ZEROFILL|MY_FAE|MY_WME));
/* Yes, we strdup a const string to simplify the interface */
- primary_keys[0]= my_strdup("796c4422-1d94-102a-9d6d-00e0812d", MYF(0));
+ primary_keys[0]= my_strdup(PSI_NOT_INSTRUMENTED, "796c4422-1d94-102a-9d6d-00e0812d", MYF(0));
}
else
{
@@ -1589,13 +1589,13 @@ generate_primary_key_list(MYSQL *mysql, option_string *engine_stmt)
/*
We create the structure and loop and create the items.
*/
- primary_keys= (char **)my_malloc((uint)(sizeof(char *) *
- primary_keys_number_of),
- MYF(MY_ZEROFILL|MY_FAE|MY_WME));
+ primary_keys= (char **)my_malloc(PSI_NOT_INSTRUMENTED,
+ (size_t)(sizeof(char *) * primary_keys_number_of),
+ MYF(MY_ZEROFILL|MY_FAE|MY_WME));
row= mysql_fetch_row(result);
for (counter= 0; counter < primary_keys_number_of;
counter++, row= mysql_fetch_row(result))
- primary_keys[counter]= my_strdup(row[0], MYF(0));
+ primary_keys[counter]= my_strdup(PSI_NOT_INSTRUMENTED, row[0], MYF(0));
}
mysql_free_result(result);
@@ -2006,10 +2006,10 @@ parse_option(const char *origin, option_string **stmt, char delm)
size_t length= strlen(origin);
uint count= 0; /* We know that there is always one */
- for (tmp= *sptr= (option_string *)my_malloc(sizeof(option_string),
+ for (tmp= *sptr= (option_string *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(option_string),
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
(retstr= strchr(ptr, delm));
- tmp->next= (option_string *)my_malloc(sizeof(option_string),
+ tmp->next= (option_string *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(option_string),
MYF(MY_ZEROFILL|MY_FAE|MY_WME)),
tmp= tmp->next)
{
@@ -2040,18 +2040,18 @@ parse_option(const char *origin, option_string **stmt, char delm)
char *option_ptr;
tmp->length= (size_t)(buffer_ptr - buffer);
- tmp->string= my_strndup(ptr, (uint)tmp->length, MYF(MY_FAE));
+ tmp->string= my_strndup(PSI_NOT_INSTRUMENTED, ptr, (uint)tmp->length, MYF(MY_FAE));
option_ptr= ptr + 1 + tmp->length;
/* Move past the : and the first string */
tmp->option_length= (size_t)(retstr - option_ptr);
- tmp->option= my_strndup(option_ptr, (uint)tmp->option_length,
+ tmp->option= my_strndup(PSI_NOT_INSTRUMENTED, option_ptr, (uint)tmp->option_length,
MYF(MY_FAE));
}
else
{
- tmp->string= my_strndup(ptr, (size_t)(retstr - ptr), MYF(MY_FAE));
+ tmp->string= my_strndup(PSI_NOT_INSTRUMENTED, ptr, (size_t)(retstr - ptr), MYF(MY_FAE));
tmp->length= (size_t)(retstr - ptr);
}
@@ -2079,19 +2079,19 @@ parse_option(const char *origin, option_string **stmt, char delm)
char *option_ptr;
tmp->length= (size_t)(origin_ptr - ptr);
- tmp->string= my_strndup(ptr, tmp->length, MYF(MY_FAE));
+ tmp->string= my_strndup(PSI_NOT_INSTRUMENTED, ptr, tmp->length, MYF(MY_FAE));
option_ptr= (char *)ptr + 1 + tmp->length;
/* Move past the : and the first string */
tmp->option_length= strlen(option_ptr);
- tmp->option= my_strndup(option_ptr, tmp->option_length,
+ tmp->option= my_strndup(PSI_NOT_INSTRUMENTED, option_ptr, tmp->option_length,
MYF(MY_FAE));
}
else
{
tmp->length= strlen(ptr);
- tmp->string= my_strndup(ptr, tmp->length, MYF(MY_FAE));
+ tmp->string= my_strndup(PSI_NOT_INSTRUMENTED, ptr, tmp->length, MYF(MY_FAE));
}
count++;
@@ -2111,15 +2111,15 @@ parse_delimiter(const char *script, statement **stmt, char delm)
size_t length= strlen(script);
uint count= 0; /* We know that there is always one */
- for (tmp= *sptr= (statement *)my_malloc(sizeof(statement),
+ for (tmp= *sptr= (statement *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(statement),
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
(retstr= strchr(ptr, delm));
- tmp->next= (statement *)my_malloc(sizeof(statement),
+ tmp->next= (statement *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(statement),
MYF(MY_ZEROFILL|MY_FAE|MY_WME)),
tmp= tmp->next)
{
count++;
- tmp->string= my_strndup(ptr, (uint)(retstr - ptr), MYF(MY_FAE));
+ tmp->string= my_strndup(PSI_NOT_INSTRUMENTED, ptr, (uint)(retstr - ptr), MYF(MY_FAE));
tmp->length= (size_t)(retstr - ptr);
ptr+= retstr - ptr + 1;
if (isspace(*ptr))
@@ -2128,7 +2128,7 @@ parse_delimiter(const char *script, statement **stmt, char delm)
if (ptr != script+length)
{
- tmp->string= my_strndup(ptr, (uint)((script + length) - ptr),
+ tmp->string= my_strndup(PSI_NOT_INSTRUMENTED, ptr, (uint)((script + length) - ptr),
MYF(MY_FAE));
tmp->length= (size_t)((script + length) - ptr);
count++;
@@ -2150,7 +2150,7 @@ parse_comma(const char *string, uint **range)
if (*ptr == ',') count++;
/* One extra spot for the NULL */
- nptr= *range= (uint *)my_malloc(sizeof(uint) * (count + 1),
+ nptr= *range= (uint *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(uint) * (count + 1),
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
ptr= (char *)string;
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 910db0f714e..8e88aefb6ac 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -1770,7 +1770,7 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
len= (size_t) my_seek(fd, 0, SEEK_END, MYF(0));
my_seek(fd, 0, SEEK_SET, MYF(0));
if (len == (size_t)MY_FILEPOS_ERROR ||
- !(buff= (char*)my_malloc(len + 1, MYF(0))))
+ !(buff= (char*)my_malloc(PSI_NOT_INSTRUMENTED, len + 1, MYF(0))))
{
my_close(fd, MYF(0));
return 1;
@@ -2428,7 +2428,7 @@ VAR *var_init(VAR *v, const char *name, size_t name_len, const char *val, size_t
if (!val)
val_len= 0;
val_alloc_len = val_len + 16; /* room to grow */
- if (!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var)
+ if (!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(*tmp_var)
+ name_len+2, MYF(MY_WME))))
die("Out of memory");
@@ -2443,7 +2443,7 @@ VAR *var_init(VAR *v, const char *name, size_t name_len, const char *val, size_t
tmp_var->alloced = (v == 0);
- if (!(tmp_var->str_val = (char*)my_malloc(val_alloc_len+1, MYF(MY_WME))))
+ if (!(tmp_var->str_val = (char*)my_malloc(PSI_NOT_INSTRUMENTED, val_alloc_len+1, MYF(MY_WME))))
die("Out of memory");
if (val)
@@ -2991,8 +2991,8 @@ void var_copy(VAR *dest, VAR *src)
/* Alloc/realloc data for str_val in dest */
if (dest->alloced_len < src->alloced_len &&
!(dest->str_val= dest->str_val
- ? (char*)my_realloc(dest->str_val, src->alloced_len, MYF(MY_WME))
- : (char*)my_malloc(src->alloced_len, MYF(MY_WME))))
+ ? (char*)my_realloc(PSI_NOT_INSTRUMENTED, dest->str_val, src->alloced_len, MYF(MY_WME))
+ : (char*)my_malloc(PSI_NOT_INSTRUMENTED, src->alloced_len, MYF(MY_WME))))
die("Out of memory");
else
dest->alloced_len= src->alloced_len;
@@ -3069,8 +3069,8 @@ void eval_expr(VAR *v, const char *p, const char **p_end,
MIN_VAR_ALLOC : new_val_len + 1;
if (!(v->str_val =
v->str_val ?
- (char*)my_realloc(v->str_val, v->alloced_len+1, MYF(MY_WME)) :
- (char*)my_malloc(v->alloced_len+1, MYF(MY_WME))))
+ (char*)my_realloc(PSI_NOT_INSTRUMENTED, v->str_val, v->alloced_len+1, MYF(MY_WME)) :
+ (char*)my_malloc(PSI_NOT_INSTRUMENTED, v->alloced_len+1, MYF(MY_WME))))
die("Out of memory");
}
v->str_val_len = new_val_len;
@@ -3091,7 +3091,7 @@ bool open_and_set_current(const char *name)
cur_file++;
cur_file->file= opened;
- cur_file->file_name= my_strdup(name, MYF(MY_FAE));
+ cur_file->file_name= my_strdup(PSI_NOT_INSTRUMENTED, name, MYF(MY_FAE));
cur_file->lineno=1;
return true;
}
@@ -4846,7 +4846,7 @@ void do_sync_with_master(struct st_command *command)
p++;
while (*p && my_isspace(charset_info, *p))
p++;
- start= buff= (char*)my_malloc(strlen(p)+1,MYF(MY_WME | MY_FAE));
+ start= buff= (char*)my_malloc(PSI_NOT_INSTRUMENTED, strlen(p)+1,MYF(MY_WME | MY_FAE));
get_string(&buff, &p, command);
}
command->last_argument= p;
@@ -5651,7 +5651,7 @@ void do_close_connection(struct st_command *command)
When the connection is closed set name to "-closed_connection-"
to make it possible to reuse the connection name.
*/
- if (!(con->name = my_strdup("-closed_connection-", MYF(MY_WME))))
+ if (!(con->name = my_strdup(PSI_NOT_INSTRUMENTED, "-closed_connection-", MYF(MY_WME))))
die("Out of memory");
if (con == cur_con)
@@ -6122,7 +6122,7 @@ void do_connect(struct st_command *command)
{
DBUG_PRINT("info", ("Inserting connection %s in connection pool",
ds_connection_name.str));
- if (!(con_slot->name= my_strdup(ds_connection_name.str, MYF(MY_WME))))
+ if (!(con_slot->name= my_strdup(PSI_NOT_INSTRUMENTED, ds_connection_name.str, MYF(MY_WME))))
die("Out of memory");
con_slot->name_len= strlen(con_slot->name);
set_current_connection(con_slot);
@@ -6573,7 +6573,7 @@ int read_line()
if (p >= buf_end)
{
my_ptrdiff_t off= p - read_command_buf;
- read_command_buf= (char*)my_realloc(read_command_buf,
+ read_command_buf= (char*)my_realloc(PSI_NOT_INSTRUMENTED, read_command_buf,
read_command_buflen*2, MYF(MY_FAE));
p= read_command_buf + off;
read_command_buflen*= 2;
@@ -6920,7 +6920,7 @@ int read_command(struct st_command** command_ptr)
DBUG_RETURN(0);
}
if (!(*command_ptr= command=
- (struct st_command*) my_malloc(sizeof(*command),
+ (struct st_command*) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(*command),
MYF(MY_WME|MY_ZEROFILL))) ||
insert_dynamic(&q_lines, &command))
die("Out of memory");
@@ -6955,7 +6955,7 @@ int read_command(struct st_command** command_ptr)
while (*p && my_isspace(charset_info, *p))
p++;
- if (!(command->query_buf= command->query= my_strdup(p, MYF(MY_WME))))
+ if (!(command->query_buf= command->query= my_strdup(PSI_NOT_INSTRUMENTED, p, MYF(MY_WME))))
die("Out of memory");
/*
@@ -7168,7 +7168,7 @@ void read_embedded_server_arguments(const char *name)
{
*(strend(str)-1)=0; /* Remove end newline */
if (!(embedded_server_args[embedded_server_arg_count]=
- my_strdup(str, MYF(MY_WME))))
+ my_strdup(PSI_NOT_INSTRUMENTED, str, MYF(MY_WME))))
{
my_fclose(file,MYF(0));
die("Out of memory");
@@ -7211,7 +7211,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
if (!(cur_file->file=
fopen(buff, "rb")))
die("Could not open '%s' for reading, errno: %d", buff, errno);
- cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
+ cur_file->file_name= my_strdup(PSI_NOT_INSTRUMENTED, buff, MYF(MY_FAE));
cur_file->lineno= 1;
break;
}
@@ -7234,7 +7234,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
if (argument)
{
my_free(opt_pass);
- opt_pass= my_strdup(argument, MYF(MY_FAE));
+ opt_pass= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
tty_password= 0;
}
@@ -7253,7 +7253,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
}
if (embedded_server_arg_count == MAX_EMBEDDED_SERVER_ARGS-1 ||
!(embedded_server_args[embedded_server_arg_count++]=
- my_strdup(argument, MYF(MY_FAE))))
+ my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE))))
{
die("Can't use server argument");
}
@@ -7427,7 +7427,7 @@ void init_win_path_patterns()
DBUG_ENTER("init_win_path_patterns");
- my_init_dynamic_array(&patterns, sizeof(const char*), 16, 16, MYF(0));
+ my_init_dynamic_array(&patterns, PSI_NOT_INSTRUMENTED, sizeof(const char*), 16, 16, MYF(0));
/* Loop through all paths in the array */
for (i= 0; i < num_paths; i++)
@@ -7436,10 +7436,10 @@ void init_win_path_patterns()
if (*(paths[i]) == '$')
{
v= var_get(paths[i], 0, 0, 0);
- p= my_strdup(v->str_val, MYF(MY_FAE));
+ p= my_strdup(PSI_NOT_INSTRUMENTED, v->str_val, MYF(MY_FAE));
}
else
- p= my_strdup(paths[i], MYF(MY_FAE));
+ p= my_strdup(PSI_NOT_INSTRUMENTED, paths[i], MYF(MY_FAE));
/* Don't insert zero length strings in patterns array */
if (strlen(p) == 0)
@@ -7623,11 +7623,11 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
int error;
/* Allocate array with bind structs, lengths and NULL flags */
- my_bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND),
+ my_bind= (MYSQL_BIND*) my_malloc(PSI_NOT_INSTRUMENTED, num_fields * sizeof(MYSQL_BIND),
MYF(MY_WME | MY_FAE | MY_ZEROFILL));
- length= (ulong*) my_malloc(num_fields * sizeof(ulong),
+ length= (ulong*) my_malloc(PSI_NOT_INSTRUMENTED, num_fields * sizeof(ulong),
MYF(MY_WME | MY_FAE));
- is_null= (my_bool*) my_malloc(num_fields * sizeof(my_bool),
+ is_null= (my_bool*) my_malloc(PSI_NOT_INSTRUMENTED, num_fields * sizeof(my_bool),
MYF(MY_WME | MY_FAE));
/* Allocate data for the result of each field */
@@ -7635,7 +7635,7 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
{
uint max_length= fields[i].max_length + 1;
my_bind[i].buffer_type= MYSQL_TYPE_STRING;
- my_bind[i].buffer= my_malloc(max_length, MYF(MY_WME | MY_FAE));
+ my_bind[i].buffer= my_malloc(PSI_NOT_INSTRUMENTED, max_length, MYF(MY_WME | MY_FAE));
my_bind[i].buffer_length= max_length;
my_bind[i].is_null= &is_null[i];
my_bind[i].length= &length[i];
@@ -9185,10 +9185,10 @@ int main(int argc, char **argv)
cur_block->ok= TRUE; /* Outer block should always be executed */
cur_block->cmd= cmd_none;
- my_init_dynamic_array(&q_lines, sizeof(struct st_command*), 1024, 1024, MYF(0));
+ my_init_dynamic_array(&q_lines, PSI_NOT_INSTRUMENTED, sizeof(struct st_command*), 1024, 1024, MYF(0));
if (my_hash_init2(&var_hash, 64, charset_info,
- 128, 0, 0, get_var_key, 0, var_free, MYF(0)))
+ 128, 0, 0, get_var_key, 0, var_free, MYF(0), PSI_NOT_INSTRUMENTED))
die("Variable hash initialization failed");
{
@@ -9218,10 +9218,10 @@ int main(int argc, char **argv)
init_win_path_patterns();
#endif
- read_command_buf= (char*)my_malloc(read_command_buflen= 65536, MYF(MY_FAE));
+ read_command_buf= (char*)my_malloc(PSI_NOT_INSTRUMENTED, read_command_buflen= 65536, MYF(MY_FAE));
init_dynamic_string(&ds_res, "", 2048, 2048);
- init_alloc_root(&require_file_root, "require_file", 1024, 1024, MYF(0));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &require_file_root, 1024, 1024, MYF(0));
parse_args(argc, argv);
@@ -9235,7 +9235,7 @@ int main(int argc, char **argv)
/* Init connections, allocate 1 extra as buffer + 1 for default */
connections= (struct st_connection*)
- my_malloc((opt_max_connections+2) * sizeof(struct st_connection),
+ my_malloc(PSI_NOT_INSTRUMENTED, (opt_max_connections+2) * sizeof(struct st_connection),
MYF(MY_WME | MY_ZEROFILL));
connections_end= connections + opt_max_connections +1;
next_con= connections + 1;
@@ -9266,7 +9266,7 @@ int main(int argc, char **argv)
if (cur_file == file_stack && cur_file->file == 0)
{
cur_file->file= stdin;
- cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME));
+ cur_file->file_name= my_strdup(PSI_NOT_INSTRUMENTED, "<stdin>", MYF(MY_WME));
cur_file->lineno= 1;
}
var_set_string("MYSQLTEST_FILE", cur_file->file_name);
@@ -9319,7 +9319,7 @@ int main(int argc, char **argv)
}
#endif
- if (!(con->name = my_strdup("default", MYF(MY_WME))))
+ if (!(con->name = my_strdup(PSI_NOT_INSTRUMENTED, "default", MYF(MY_WME))))
die("Out of memory");
mysql_options(con->mysql, MYSQL_OPT_NONBLOCK, 0);
@@ -9915,7 +9915,7 @@ void do_get_replace_column(struct st_command *command)
die("Missing argument in %s", command->query);
/* Allocate a buffer for results */
- start= buff= (char*)my_malloc(strlen(from)+1,MYF(MY_WME | MY_FAE));
+ start= buff= (char*)my_malloc(PSI_NOT_INSTRUMENTED, strlen(from)+1,MYF(MY_WME | MY_FAE));
while (*from)
{
char *to;
@@ -9928,7 +9928,7 @@ void do_get_replace_column(struct st_command *command)
command->query);
to= get_string(&buff, &from, command);
my_free(replace_column[column_number-1]);
- replace_column[column_number-1]= my_strdup(to, MYF(MY_WME | MY_FAE));
+ replace_column[column_number-1]= my_strdup(PSI_NOT_INSTRUMENTED, to, MYF(MY_WME | MY_FAE));
set_if_bigger(max_replace_column, column_number);
}
my_free(start);
@@ -9995,7 +9995,7 @@ void do_get_replace(struct st_command *command)
bzero(&from_array,sizeof(from_array));
if (!*from)
die("Missing argument in %s", command->query);
- start= buff= (char*)my_malloc(strlen(from)+1,MYF(MY_WME | MY_FAE));
+ start= buff= (char*)my_malloc(PSI_NOT_INSTRUMENTED, strlen(from)+1,MYF(MY_WME | MY_FAE));
while (*from)
{
char *to= buff;
@@ -10157,17 +10157,17 @@ struct st_replace_regex* init_replace_regex(char* expr)
size_t expr_len= strlen(expr);
/* my_malloc() will die on fail with MY_FAE */
- res=(struct st_replace_regex*)my_malloc(
+ res=(struct st_replace_regex*)my_malloc(PSI_NOT_INSTRUMENTED,
sizeof(*res)+8192 ,MYF(MY_FAE+MY_WME));
- my_init_dynamic_array(&res->regex_arr,sizeof(struct st_regex), 128, 128, MYF(0));
+ my_init_dynamic_array(&res->regex_arr,PSI_NOT_INSTRUMENTED, sizeof(struct st_regex), 128, 128, MYF(0));
expr_end= expr + expr_len;
buf_p= (char*)res + sizeof(*res);
append_replace_regex(expr, expr_end, res, &buf_p);
res->odd_buf_len= res->even_buf_len= 8192;
- res->even_buf= (char*)my_malloc(res->even_buf_len,MYF(MY_WME+MY_FAE));
- res->odd_buf= (char*)my_malloc(res->odd_buf_len,MYF(MY_WME+MY_FAE));
+ res->even_buf= (char*)my_malloc(PSI_NOT_INSTRUMENTED, res->even_buf_len,MYF(MY_WME+MY_FAE));
+ res->odd_buf= (char*)my_malloc(PSI_NOT_INSTRUMENTED, res->odd_buf_len,MYF(MY_WME+MY_FAE));
res->buf= res->even_buf;
return res;
@@ -10350,7 +10350,7 @@ void free_replace_regex()
#define SECURE_REG_BUF if (buf_len < need_buf_len) \
{ \
ssize_t off= res_p - buf; \
- buf= (char*)my_realloc(buf,need_buf_len,MYF(MY_WME+MY_FAE)); \
+ buf= (char*)my_realloc(PSI_NOT_INSTRUMENTED, buf,need_buf_len,MYF(MY_WME+MY_FAE)); \
res_p= buf + off; \
buf_len= need_buf_len; \
} \
@@ -10403,7 +10403,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
return 1;
}
- subs= (regmatch_t*)my_malloc(sizeof(regmatch_t) * (r.re_nsub+1),
+ subs= (regmatch_t*)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(regmatch_t) * (r.re_nsub+1),
MYF(MY_WME+MY_FAE));
*res_p= 0;
@@ -10651,7 +10651,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
if (init_sets(&sets,states))
DBUG_RETURN(0);
found_sets=0;
- if (!(found_set= (FOUND_SET*) my_malloc(sizeof(FOUND_SET)*max_length*count,
+ if (!(found_set= (FOUND_SET*) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(FOUND_SET)*max_length*count,
MYF(MY_WME))))
{
free_sets(&sets);
@@ -10662,7 +10662,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
used_sets=-1;
word_states=make_new_set(&sets); /* Start of new word */
start_states=make_new_set(&sets); /* This is first state */
- if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME))))
+ if (!(follow=(FOLLOWS*) my_malloc(PSI_NOT_INSTRUMENTED, (states+2)*sizeof(FOLLOWS),MYF(MY_WME))))
{
free_sets(&sets);
my_free(found_set);
@@ -10826,7 +10826,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
/* Alloc replace structure for the replace-state-machine */
- if ((replace=(REPLACE*) my_malloc(sizeof(REPLACE)*(sets.count)+
+ if ((replace=(REPLACE*) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(REPLACE)*(sets.count)+
sizeof(REPLACE_STRING)*(found_sets+1)+
sizeof(char *)*count+result_len,
MYF(MY_WME | MY_ZEROFILL))))
@@ -10871,10 +10871,10 @@ int init_sets(REP_SETS *sets,uint states)
{
bzero(sets, sizeof(*sets));
sets->size_of_bits=((states+7)/8);
- if (!(sets->set_buffer=(REP_SET*) my_malloc(sizeof(REP_SET)*SET_MALLOC_HUNC,
+ if (!(sets->set_buffer=(REP_SET*) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(REP_SET)*SET_MALLOC_HUNC,
MYF(MY_WME))))
return 1;
- if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits*
+ if (!(sets->bit_buffer=(uint*) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(uint)*sets->size_of_bits*
SET_MALLOC_HUNC,MYF(MY_WME))))
{
my_free(sets->set);
@@ -10909,12 +10909,12 @@ REP_SET *make_new_set(REP_SETS *sets)
return set;
}
count=sets->count+sets->invisible+SET_MALLOC_HUNC;
- if (!(set=(REP_SET*) my_realloc(sets->set_buffer, sizeof(REP_SET)*count,
+ if (!(set=(REP_SET*) my_realloc(PSI_NOT_INSTRUMENTED, sets->set_buffer, sizeof(REP_SET)*count,
MYF(MY_WME))))
return 0;
sets->set_buffer=set;
sets->set=set+sets->invisible;
- if (!(bit_buffer=(uint*) my_realloc(sets->bit_buffer,
+ if (!(bit_buffer=(uint*) my_realloc(PSI_NOT_INSTRUMENTED, sets->bit_buffer,
(sizeof(uint)*sets->size_of_bits)*count,
MYF(MY_WME))))
return 0;
@@ -11069,11 +11069,11 @@ int insert_pointer_name(POINTER_ARRAY *pa,char * name)
if (! pa->typelib.count)
{
if (!(pa->typelib.type_names=(const char **)
- my_malloc(((PC_MALLOC-MALLOC_OVERHEAD)/
+ my_malloc(PSI_NOT_INSTRUMENTED, ((PC_MALLOC-MALLOC_OVERHEAD)/
(sizeof(char *)+sizeof(*pa->flag))*
(sizeof(char *)+sizeof(*pa->flag))),MYF(MY_WME))))
DBUG_RETURN(-1);
- if (!(pa->str= (uchar*) my_malloc(PS_MALLOC - MALLOC_OVERHEAD,
+ if (!(pa->str= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, PS_MALLOC - MALLOC_OVERHEAD,
MYF(MY_WME))))
{
my_free(pa->typelib.type_names);
@@ -11089,7 +11089,7 @@ int insert_pointer_name(POINTER_ARRAY *pa,char * name)
length=(uint) strlen(name)+1;
if (pa->length+length >= pa->max_length)
{
- if (!(new_pos= (uchar*) my_realloc(pa->str, pa->length + length + PS_MALLOC,
+ if (!(new_pos= (uchar*) my_realloc(PSI_NOT_INSTRUMENTED, pa->str, pa->length + length + PS_MALLOC,
MYF(MY_WME))))
DBUG_RETURN(1);
if (new_pos != pa->str)
@@ -11107,7 +11107,7 @@ int insert_pointer_name(POINTER_ARRAY *pa,char * name)
int len;
pa->array_allocs++;
len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD);
- if (!(new_array=(const char **) my_realloc(pa->typelib.type_names,
+ if (!(new_array=(const char **) my_realloc(PSI_NOT_INSTRUMENTED, pa->typelib.type_names,
len/
(sizeof(uchar*)+sizeof(*pa->flag))*
(sizeof(uchar*)+sizeof(*pa->flag)),
@@ -11230,7 +11230,7 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input,
if (!*start)
DBUG_VOID_RETURN; /* No input */
- my_init_dynamic_array(&lines, sizeof(const char*), 32, 32, MYF(0));
+ my_init_dynamic_array(&lines, PSI_NOT_INSTRUMENTED, sizeof(const char*), 32, 32, MYF(0));
if (keep_header)
{
diff --git a/client/readline.cc b/client/readline.cc
index 12df8b312ad..8d3d97b8585 100644
--- a/client/readline.cc
+++ b/client/readline.cc
@@ -43,7 +43,8 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
#endif
if (!(line_buff=(LINE_BUFFER*)
- my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL))))
+ my_malloc(PSI_NOT_INSTRUMENTED, sizeof(*line_buff),
+ MYF(MY_WME | MY_ZEROFILL))))
return 0;
if (init_line_buffer(line_buff,my_fileno(file),IO_SIZE,max_size))
{
@@ -93,7 +94,8 @@ LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, char * str)
{
if (!line_buff)
if (!(line_buff=(LINE_BUFFER*)
- my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL))))
+ my_malloc(PSI_NOT_INSTRUMENTED, sizeof(*line_buff),
+ MYF(MY_WME | MY_ZEROFILL))))
return 0;
if (init_line_buffer_from_string(line_buff,str))
{
@@ -114,8 +116,8 @@ init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer)
buffer->file=file;
buffer->bufread=size;
buffer->max_size=max_buffer;
- if (!(buffer->buffer = (char*) my_malloc(buffer->bufread+1,
- MYF(MY_WME | MY_FAE))))
+ if (!(buffer->buffer = (char*) my_malloc(PSI_NOT_INSTRUMENTED,
+ buffer->bufread+1, MYF(MY_WME | MY_FAE))))
return 1;
buffer->end_of_line=buffer->end=buffer->buffer;
buffer->buffer[0]=0; /* For easy start test */
@@ -132,8 +134,8 @@ static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str)
uint old_length=(uint)(buffer->end - buffer->buffer);
uint length= (uint) strlen(str);
if (!(buffer->buffer= buffer->start_of_line= buffer->end_of_line=
- (char*) my_realloc((uchar*) buffer->buffer, old_length+length+2,
- MYF(MY_FAE|MY_ALLOW_ZERO_PTR))))
+ (char*) my_realloc(PSI_NOT_INSTRUMENTED, buffer->buffer,
+ old_length+length+2, MYF(MY_FAE|MY_ALLOW_ZERO_PTR))))
return 1;
buffer->end= buffer->buffer + old_length;
if (old_length)
@@ -179,8 +181,8 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
return 0;
}
buffer->bufread *= 2;
- if (!(buffer->buffer = (char*) my_realloc(buffer->buffer,
- buffer->bufread+1,
+ if (!(buffer->buffer = (char*) my_realloc(PSI_NOT_INSTRUMENTED,
+ buffer->buffer, buffer->bufread+1,
MYF(MY_WME | MY_FAE))))
{
buffer->error= my_errno;
diff --git a/extra/comp_err.c b/extra/comp_err.c
index e6ea9acccb9..c83a416d2a7 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -886,7 +886,7 @@ static char *get_word(char **str)
DBUG_ENTER("get_word");
*str= find_end_of_word(start);
- DBUG_RETURN(my_strndup(start, (uint) (*str - start),
+ DBUG_RETURN(my_strndup(PSI_NOT_INSTRUMENTED, start, (uint) (*str - start),
MYF(MY_WME | MY_FAE)));
}
@@ -920,7 +920,7 @@ static struct message *parse_message_string(struct message *new_message,
while (*str != ' ' && *str != '\t' && *str)
str++;
if (!(new_message->lang_short_name=
- my_strndup(start, (uint) (str - start),
+ my_strndup(PSI_NOT_INSTRUMENTED, start, (uint) (str - start),
MYF(MY_WME | MY_FAE))))
DBUG_RETURN(0); /* Fatal error */
DBUG_PRINT("info", ("msg_slang: %s", new_message->lang_short_name));
@@ -940,9 +940,9 @@ static struct message *parse_message_string(struct message *new_message,
start= str + 1;
str= parse_text_line(start);
- if (!(new_message->text= my_strndup(start, (uint) (str - start),
- MYF(MY_WME | MY_FAE))))
- DBUG_RETURN(0); /* Fatal error */
+ if (!(new_message->text= my_strndup(PSI_NOT_INSTRUMENTED, start,
+ (uint) (str - start), MYF(MY_WME | MY_FAE))))
+ DBUG_RETURN(0);
DBUG_PRINT("info", ("msg_text: %s", new_message->text));
DBUG_RETURN(new_message);
@@ -955,11 +955,11 @@ static struct errors *generate_empty_message(uint d_code, my_bool skip)
struct message message;
/* create a new element */
- if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error),
- MYF(MY_WME))))
+ if (!(new_error= (struct errors *) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(*new_error), MYF(MY_WME))))
return(0);
- if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 1,
- MYF(0)))
+ if (my_init_dynamic_array(&new_error->msg, PSI_NOT_INSTRUMENTED,
+ sizeof(struct message), 0, 1, MYF(0)))
return(0); /* OOM: Fatal error */
new_error->er_name= NULL;
@@ -970,8 +970,10 @@ static struct errors *generate_empty_message(uint d_code, my_bool skip)
message.text= 0; /* If skip set, don't generate a text */
- if (!(message.lang_short_name= my_strdup(default_language, MYF(MY_WME))) ||
- (!skip && !(message.text= my_strdup("", MYF(MY_WME)))))
+ if (!(message.lang_short_name= my_strdup(PSI_NOT_INSTRUMENTED,
+ default_language, MYF(MY_WME))) ||
+ (!skip && !(message.text= my_strdup(PSI_NOT_INSTRUMENTED,
+ "", MYF(MY_WME)))))
return(0);
/* Can't fail as msg is preallocated */
@@ -992,13 +994,14 @@ static struct errors *parse_error_string(char *str, int er_count)
DBUG_PRINT("enter", ("str: %s", str));
/* create a new element */
- if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error),
- MYF(MY_WME))))
+ if (!(new_error= (struct errors *) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(*new_error), MYF(MY_WME))))
DBUG_RETURN(0);
new_error->next_error= 0;
- if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 0, MYF(0)))
- DBUG_RETURN(0); /* OOM: Fatal error */
+ if (my_init_dynamic_array(&new_error->msg, PSI_NOT_INSTRUMENTED,
+ sizeof(struct message), 0, 0, MYF(0)))
+ DBUG_RETURN(0);
/* getting the error name */
str= skip_delimiters(str);
@@ -1084,7 +1087,8 @@ static struct languages *parse_charset_string(char *str)
do
{
/*creating new element of the linked list */
- new_lang= (struct languages *) my_malloc(sizeof(*new_lang), MYF(MY_WME));
+ new_lang= (struct languages *) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(*new_lang), MYF(MY_WME));
new_lang->next_lang= head;
head= new_lang;
diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc
index df8d1c0956b..847340e6dc7 100644
--- a/extra/mariabackup/backup_mysql.cc
+++ b/extra/mariabackup/backup_mysql.cc
@@ -462,23 +462,23 @@ get_mysql_vars(MYSQL *connection)
}
if (innodb_data_file_path_var && *innodb_data_file_path_var) {
- innobase_data_file_path = my_strdup(
+ innobase_data_file_path = my_strdup(PSI_NOT_INSTRUMENTED,
innodb_data_file_path_var, MYF(MY_FAE));
}
if (innodb_data_home_dir_var) {
- innobase_data_home_dir = my_strdup(
+ innobase_data_home_dir = my_strdup(PSI_NOT_INSTRUMENTED,
innodb_data_home_dir_var, MYF(MY_FAE));
}
if (innodb_log_group_home_dir_var
&& *innodb_log_group_home_dir_var) {
- srv_log_group_home_dir = my_strdup(
+ srv_log_group_home_dir = my_strdup(PSI_NOT_INSTRUMENTED,
innodb_log_group_home_dir_var, MYF(MY_FAE));
}
if (innodb_undo_directory_var && *innodb_undo_directory_var) {
- srv_undo_dir = my_strdup(
+ srv_undo_dir = my_strdup(PSI_NOT_INSTRUMENTED,
innodb_undo_directory_var, MYF(MY_FAE));
}
diff --git a/extra/mariabackup/ds_buffer.cc b/extra/mariabackup/ds_buffer.cc
index 720a329c238..308070ab3b3 100644
--- a/extra/mariabackup/ds_buffer.cc
+++ b/extra/mariabackup/ds_buffer.cc
@@ -71,13 +71,13 @@ buffer_init(const char *root)
ds_ctxt_t *ctxt;
ds_buffer_ctxt_t *buffer_ctxt;
- ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_buffer_ctxt_t),
- MYF(MY_FAE));
+ ctxt = (ds_ctxt_t *)my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(ds_ctxt_t) + sizeof(ds_buffer_ctxt_t), MYF(MY_FAE));
buffer_ctxt = (ds_buffer_ctxt_t *) (ctxt + 1);
buffer_ctxt->buffer_size = DS_DEFAULT_BUFFER_SIZE;
ctxt->ptr = buffer_ctxt;
- ctxt->root = my_strdup(root, MYF(MY_FAE));
+ ctxt->root = my_strdup(PSI_NOT_INSTRUMENTED, root, MYF(MY_FAE));
return ctxt;
}
@@ -101,9 +101,8 @@ buffer_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
buffer_ctxt = (ds_buffer_ctxt_t *) ctxt->ptr;
- file = (ds_file_t *) my_malloc(sizeof(ds_file_t) +
- sizeof(ds_buffer_file_t) +
- buffer_ctxt->buffer_size,
+ file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(ds_file_t) +
+ sizeof(ds_buffer_file_t) + buffer_ctxt->buffer_size,
MYF(MY_FAE));
buffer_file = (ds_buffer_file_t *) (file + 1);
diff --git a/extra/mariabackup/ds_compress.cc b/extra/mariabackup/ds_compress.cc
index 487718e2ac0..54c49deac16 100644
--- a/extra/mariabackup/ds_compress.cc
+++ b/extra/mariabackup/ds_compress.cc
@@ -100,16 +100,15 @@ compress_init(const char *root)
return NULL;
}
- ctxt = (ds_ctxt_t *) my_malloc(sizeof(ds_ctxt_t) +
- sizeof(ds_compress_ctxt_t),
- MYF(MY_FAE));
+ ctxt = (ds_ctxt_t *) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(ds_ctxt_t) + sizeof(ds_compress_ctxt_t), MYF(MY_FAE));
compress_ctxt = (ds_compress_ctxt_t *) (ctxt + 1);
compress_ctxt->threads = threads;
compress_ctxt->nthreads = xtrabackup_compress_threads;
ctxt->ptr = compress_ctxt;
- ctxt->root = my_strdup(root, MYF(MY_FAE));
+ ctxt->root = my_strdup(PSI_NOT_INSTRUMENTED, root, MYF(MY_FAE));
return ctxt;
}
@@ -159,9 +158,8 @@ compress_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
goto err;
}
- file = (ds_file_t *) my_malloc(sizeof(ds_file_t) +
- sizeof(ds_compress_file_t),
- MYF(MY_FAE));
+ file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(ds_file_t) + sizeof(ds_compress_file_t), MYF(MY_FAE));
comp_file = (ds_compress_file_t *) (file + 1);
comp_file->dest_file = dest_file;
comp_file->comp_ctxt = comp_ctxt;
@@ -336,8 +334,8 @@ create_worker_threads(uint n)
comp_thread_ctxt_t *threads;
uint i;
- threads = (comp_thread_ctxt_t *)
- my_malloc(sizeof(comp_thread_ctxt_t) * n, MYF(MY_FAE));
+ threads = (comp_thread_ctxt_t *) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(comp_thread_ctxt_t) * n, MYF(MY_FAE));
for (i = 0; i < n; i++) {
comp_thread_ctxt_t *thd = threads + i;
@@ -347,9 +345,8 @@ create_worker_threads(uint n)
thd->cancelled = FALSE;
thd->data_avail = FALSE;
- thd->to = (char *) my_malloc(COMPRESS_CHUNK_SIZE +
- MY_QLZ_COMPRESS_OVERHEAD,
- MYF(MY_FAE));
+ thd->to = (char *) my_malloc(PSI_NOT_INSTRUMENTED,
+ COMPRESS_CHUNK_SIZE + MY_QLZ_COMPRESS_OVERHEAD, MYF(MY_FAE));
/* Initialize the control mutex and condition var */
if (pthread_mutex_init(&thd->ctrl_mutex, NULL) ||
diff --git a/extra/mariabackup/ds_local.cc b/extra/mariabackup/ds_local.cc
index fb2ea0a1629..06b061f3646 100644
--- a/extra/mariabackup/ds_local.cc
+++ b/extra/mariabackup/ds_local.cc
@@ -69,9 +69,9 @@ local_init(const char *root)
return NULL;
}
- ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t), MYF(MY_FAE));
+ ctxt = (ds_ctxt_t *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(ds_ctxt_t), MYF(MY_FAE));
- ctxt->root = my_strdup(root, MYF(MY_FAE));
+ ctxt->root = my_strdup(PSI_NOT_INSTRUMENTED, root, MYF(MY_FAE));
return ctxt;
}
@@ -109,7 +109,7 @@ local_open(ds_ctxt_t *ctxt, const char *path,
path_len = strlen(fullpath) + 1; /* terminating '\0' */
- file = (ds_file_t *) my_malloc(sizeof(ds_file_t) +
+ file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(ds_file_t) +
sizeof(ds_local_file_t) +
path_len,
MYF(MY_FAE));
diff --git a/extra/mariabackup/ds_stdout.cc b/extra/mariabackup/ds_stdout.cc
index 85dbb83865b..d30c105d258 100644
--- a/extra/mariabackup/ds_stdout.cc
+++ b/extra/mariabackup/ds_stdout.cc
@@ -49,9 +49,9 @@ stdout_init(const char *root)
{
ds_ctxt_t *ctxt;
- ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t), MYF(MY_FAE));
+ ctxt = (ds_ctxt_t *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(ds_ctxt_t), MYF(MY_FAE));
- ctxt->root = my_strdup(root, MYF(MY_FAE));
+ ctxt->root = my_strdup(PSI_NOT_INSTRUMENTED, root, MYF(MY_FAE));
return ctxt;
}
@@ -69,10 +69,8 @@ stdout_open(ds_ctxt_t *ctxt __attribute__((unused)),
pathlen = strlen(fullpath) + 1;
- file = (ds_file_t *) my_malloc(sizeof(ds_file_t) +
- sizeof(ds_stdout_file_t) +
- pathlen,
- MYF(MY_FAE));
+ file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(ds_file_t) +
+ sizeof(ds_stdout_file_t) + pathlen, MYF(MY_FAE));
stdout_file = (ds_stdout_file_t *) (file + 1);
diff --git a/extra/mariabackup/ds_tmpfile.cc b/extra/mariabackup/ds_tmpfile.cc
index 22dff165aa0..4851c2f0263 100644
--- a/extra/mariabackup/ds_tmpfile.cc
+++ b/extra/mariabackup/ds_tmpfile.cc
@@ -61,8 +61,8 @@ tmpfile_init(const char *root)
ds_ctxt_t *ctxt;
ds_tmpfile_ctxt_t *tmpfile_ctxt;
- ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_tmpfile_ctxt_t),
- MYF(MY_FAE));
+ ctxt = (ds_ctxt_t *)my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(ds_ctxt_t) + sizeof(ds_tmpfile_ctxt_t), MYF(MY_FAE));
tmpfile_ctxt = (ds_tmpfile_ctxt_t *) (ctxt + 1);
tmpfile_ctxt->file_list = NULL;
if (pthread_mutex_init(&tmpfile_ctxt->mutex, NULL)) {
@@ -72,7 +72,7 @@ tmpfile_init(const char *root)
}
ctxt->ptr = tmpfile_ctxt;
- ctxt->root = my_strdup(root, MYF(MY_FAE));
+ ctxt->root = my_strdup(PSI_NOT_INSTRUMENTED, root, MYF(MY_FAE));
return ctxt;
}
@@ -100,9 +100,8 @@ tmpfile_open(ds_ctxt_t *ctxt, const char *path,
path_len = strlen(path) + 1; /* terminating '\0' */
- file = (ds_file_t *) my_malloc(sizeof(ds_file_t) +
- sizeof(ds_tmp_file_t) + path_len,
- MYF(MY_FAE));
+ file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(ds_file_t) + sizeof(ds_tmp_file_t) + path_len, MYF(MY_FAE));
tmp_file = (ds_tmp_file_t *) (file + 1);
tmp_file->file = file;
@@ -114,7 +113,7 @@ tmpfile_open(ds_ctxt_t *ctxt, const char *path,
memcpy(tmp_file->orig_path, path, path_len);
/* Store the real temporary file name in file->path */
- file->path = my_strdup(tmp_path, MYF(MY_FAE));
+ file->path = my_strdup(PSI_NOT_INSTRUMENTED, tmp_path, MYF(MY_FAE));
file->ptr = tmp_file;
/* Store the file object in the list to be piped later */
@@ -170,7 +169,7 @@ tmpfile_deinit(ds_ctxt_t *ctxt)
pipe_ctxt = ctxt->pipe_ctxt;
xb_a(pipe_ctxt != NULL);
- buf = my_malloc(buf_size, MYF(MY_FAE));
+ buf = my_malloc(PSI_NOT_INSTRUMENTED, buf_size, MYF(MY_FAE));
tmpfile_ctxt = (ds_tmpfile_ctxt_t *) ctxt->ptr;
list = tmpfile_ctxt->file_list;
diff --git a/extra/mariabackup/ds_xbstream.cc b/extra/mariabackup/ds_xbstream.cc
index 5a753b08474..7522510ab27 100644
--- a/extra/mariabackup/ds_xbstream.cc
+++ b/extra/mariabackup/ds_xbstream.cc
@@ -79,8 +79,8 @@ xbstream_init(const char *root __attribute__((unused)))
ds_stream_ctxt_t *stream_ctxt;
xb_wstream_t *xbstream;
- ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_stream_ctxt_t),
- MYF(MY_FAE));
+ ctxt = (ds_ctxt_t *)my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(ds_ctxt_t) + sizeof(ds_stream_ctxt_t), MYF(MY_FAE));
stream_ctxt = (ds_stream_ctxt_t *)(ctxt + 1);
if (pthread_mutex_init(&stream_ctxt->mutex, NULL)) {
@@ -131,9 +131,8 @@ xbstream_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
}
pthread_mutex_unlock(&stream_ctxt->mutex);
- file = (ds_file_t *) my_malloc(sizeof(ds_file_t) +
- sizeof(ds_stream_file_t),
- MYF(MY_FAE));
+ file = (ds_file_t *) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(ds_file_t) + sizeof(ds_stream_file_t), MYF(MY_FAE));
stream_file = (ds_stream_file_t *) (file + 1);
xbstream = stream_ctxt->xbstream;
diff --git a/extra/mariabackup/innobackupex.cc b/extra/mariabackup/innobackupex.cc
index e23adb047ee..319399b97c5 100644
--- a/extra/mariabackup/innobackupex.cc
+++ b/extra/mariabackup/innobackupex.cc
@@ -774,7 +774,8 @@ ibx_get_one_option(const struct my_option *opt,
{
char *start = argument;
my_free(opt_ibx_password);
- opt_ibx_password= my_strdup(argument, MYF(MY_FAE));
+ opt_ibx_password= my_strdup(PSI_NOT_INSTRUMENTED,
+ argument, MYF(MY_FAE));
/* Destroy argument */
while (*argument)
*argument++= 'x';
diff --git a/extra/mariabackup/xbstream.cc b/extra/mariabackup/xbstream.cc
index d22437427fa..34576434eb4 100644
--- a/extra/mariabackup/xbstream.cc
+++ b/extra/mariabackup/xbstream.cc
@@ -226,7 +226,7 @@ stream_one_file(File file, xb_wstream_file_t *xbfile)
posix_fadvise(file, 0, 0, POSIX_FADV_SEQUENTIAL);
offset = my_tell(file, MYF(MY_WME));
- buf = (uchar*)(my_malloc(XBSTREAM_BUFFER_SIZE, MYF(MY_FAE)));
+ buf = (uchar*)(my_malloc(PSI_NOT_INSTRUMENTED, XBSTREAM_BUFFER_SIZE, MYF(MY_FAE)));
while ((bytes = (ssize_t)my_read(file, buf, XBSTREAM_BUFFER_SIZE,
MYF(MY_WME))) > 0) {
@@ -321,13 +321,13 @@ file_entry_new(extract_ctxt_t *ctxt, const char *path, uint pathlen)
file_entry_t *entry;
ds_file_t *file;
- entry = (file_entry_t *) my_malloc(sizeof(file_entry_t),
+ entry = (file_entry_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(file_entry_t),
MYF(MY_WME | MY_ZEROFILL));
if (entry == NULL) {
return NULL;
}
- entry->path = my_strndup(path, pathlen, MYF(MY_WME));
+ entry->path = my_strndup(PSI_NOT_INSTRUMENTED, path, pathlen, MYF(MY_WME));
if (entry->path == NULL) {
goto err;
}
@@ -497,7 +497,7 @@ mode_extract(int n_threads, int argc __attribute__((unused)),
if (my_hash_init(&filehash, &my_charset_bin, START_FILE_HASH_SIZE,
0, 0, (my_hash_get_key) get_file_entry_key,
- (my_hash_free_key) file_entry_free, MYF(0))) {
+ (my_hash_free_key) file_entry_free, MYF(0), PSI_NOT_INSTRUMENTED)) {
msg("%s: failed to initialize file hash.", my_progname);
return 1;
}
diff --git a/extra/mariabackup/xbstream_read.cc b/extra/mariabackup/xbstream_read.cc
index ff13800fd94..3880dd50ed5 100644
--- a/extra/mariabackup/xbstream_read.cc
+++ b/extra/mariabackup/xbstream_read.cc
@@ -42,7 +42,7 @@ xb_stream_read_new(void)
{
xb_rstream_t *stream;
- stream = (xb_rstream_t *) my_malloc(sizeof(xb_rstream_t), MYF(MY_FAE));
+ stream = (xb_rstream_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(xb_rstream_t), MYF(MY_FAE));
#ifdef __WIN__
setmode(fileno(stdin), _O_BINARY);
@@ -190,7 +190,7 @@ xb_stream_read_chunk(xb_rstream_t *stream, xb_rstream_chunk_t *chunk)
/* Reallocate the buffer if needed */
if (chunk->length > chunk->buflen) {
- chunk->data = my_realloc(chunk->data, chunk->length,
+ chunk->data = my_realloc(PSI_NOT_INSTRUMENTED, chunk->data, chunk->length,
MYF(MY_WME | MY_ALLOW_ZERO_PTR));
if (chunk->data == NULL) {
msg("xb_stream_read_chunk(): failed to increase buffer "
diff --git a/extra/mariabackup/xbstream_write.cc b/extra/mariabackup/xbstream_write.cc
index fcf92f40acd..b6fd9c294a5 100644
--- a/extra/mariabackup/xbstream_write.cc
+++ b/extra/mariabackup/xbstream_write.cc
@@ -65,7 +65,7 @@ xb_stream_write_new(void)
{
xb_wstream_t *stream;
- stream = (xb_wstream_t *) my_malloc(sizeof(xb_wstream_t), MYF(MY_FAE));
+ stream = (xb_wstream_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(xb_wstream_t), MYF(MY_FAE));
pthread_mutex_init(&stream->mutex, NULL);
return stream;;
@@ -87,7 +87,7 @@ xb_stream_write_open(xb_wstream_t *stream, const char *path,
return NULL;
}
- file = (xb_wstream_file_t *) my_malloc(sizeof(xb_wstream_file_t) +
+ file = (xb_wstream_file_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(xb_wstream_file_t) +
path_len + 1, MYF(MY_FAE));
file->path = (char *) (file + 1);
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 7fade671e93..aac87c61742 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -1723,7 +1723,7 @@ xb_get_one_option(const struct my_option *opt,
{
char *start= argument;
my_free(opt_password);
- opt_password= my_strdup(argument, MYF(MY_FAE));
+ opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; // Destroy argument
if (*start)
start[1]=0 ;
diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c
index 85827b74466..09bd26c59ea 100644
--- a/extra/my_print_defaults.c
+++ b/extra/my_print_defaults.c
@@ -170,7 +170,8 @@ int main(int argc, char **argv)
if (nargs < 2)
usage();
- load_default_groups=(char**) my_malloc(nargs*sizeof(char*), MYF(MY_WME));
+ load_default_groups=(char**) my_malloc(PSI_NOT_INSTRUMENTED,
+ nargs*sizeof(char*), MYF(MY_WME));
if (!load_default_groups)
exit(1);
if (opt_mysqld)
diff --git a/extra/replace.c b/extra/replace.c
index 717bc92d0c4..0d35c6d0194 100644
--- a/extra/replace.c
+++ b/extra/replace.c
@@ -259,12 +259,12 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
if (! pa->typelib.count)
{
if (!(pa->typelib.type_names=(const char **)
- my_malloc(((PC_MALLOC-MALLOC_OVERHEAD)/
+ my_malloc(PSI_NOT_INSTRUMENTED, ((PC_MALLOC-MALLOC_OVERHEAD)/
(sizeof(char *)+sizeof(*pa->flag))*
(sizeof(char *)+sizeof(*pa->flag))),MYF(MY_WME))))
DBUG_RETURN(-1);
- if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD),
- MYF(MY_WME))))
+ if (!(pa->str= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED,
+ PS_MALLOC-MALLOC_OVERHEAD, MYF(MY_WME))))
{
my_free((void*) pa->typelib.type_names);
DBUG_RETURN (-1);
@@ -281,9 +281,8 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
{
pa->max_length=(pa->length+length+MALLOC_OVERHEAD+PS_MALLOC-1)/PS_MALLOC;
pa->max_length=pa->max_length*PS_MALLOC-MALLOC_OVERHEAD;
- if (!(new_pos= (uchar*) my_realloc((uchar*) pa->str,
- (uint) pa->max_length,
- MYF(MY_WME))))
+ if (!(new_pos= (uchar*) my_realloc(PSI_NOT_INSTRUMENTED, (uchar*) pa->str,
+ (uint) pa->max_length, MYF(MY_WME))))
DBUG_RETURN(1);
if (new_pos != pa->str)
{
@@ -299,7 +298,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
int len;
pa->array_allocs++;
len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD);
- if (!(new_array=(const char **) my_realloc((uchar*) pa->typelib.type_names,
+ if (!(new_array=(const char **) my_realloc(PSI_NOT_INSTRUMENTED, (void*)(pa->typelib.type_names),
(uint) len/
(sizeof(uchar*)+sizeof(*pa->flag))*
(sizeof(uchar*)+sizeof(*pa->flag)),
@@ -431,7 +430,8 @@ static REPLACE *init_replace(char * *from, char * *to,uint count,
if (init_sets(&sets,states))
DBUG_RETURN(0);
found_sets=0;
- if (!(found_set= (FOUND_SET*) my_malloc(sizeof(FOUND_SET)*max_length*count,
+ if (!(found_set= (FOUND_SET*) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(FOUND_SET)*max_length*count,
MYF(MY_WME))))
{
free_sets(&sets);
@@ -442,7 +442,8 @@ static REPLACE *init_replace(char * *from, char * *to,uint count,
used_sets=-1;
word_states=make_new_set(&sets); /* Start of new word */
start_states=make_new_set(&sets); /* This is first state */
- if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME))))
+ if (!(follow=(FOLLOWS*) my_malloc(PSI_NOT_INSTRUMENTED,
+ (states+2)*sizeof(FOLLOWS), MYF(MY_WME))))
{
free_sets(&sets);
my_free(found_set);
@@ -634,7 +635,8 @@ static REPLACE *init_replace(char * *from, char * *to,uint count,
/* Alloc replace structure for the replace-state-machine */
- if ((replace=(REPLACE*) my_malloc(sizeof(REPLACE)*(sets.count)+
+ if ((replace=(REPLACE*) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(REPLACE)*(sets.count)+
sizeof(REPLACE_STRING)*(found_sets+1)+
sizeof(char *)*count+result_len,
MYF(MY_WME | MY_ZEROFILL))))
@@ -679,10 +681,12 @@ static int init_sets(REP_SETS *sets,uint states)
{
bzero((char*) sets,sizeof(*sets));
sets->size_of_bits=((states+7)/8);
- if (!(sets->set_buffer=(REP_SET*) my_malloc(sizeof(REP_SET)*SET_MALLOC_HUNC,
+ if (!(sets->set_buffer=(REP_SET*) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(REP_SET)*SET_MALLOC_HUNC,
MYF(MY_WME))))
return 1;
- if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits*
+ if (!(sets->bit_buffer=(uint*) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(uint)*sets->size_of_bits*
SET_MALLOC_HUNC,MYF(MY_WME))))
{
my_free(sets->set);
@@ -717,15 +721,14 @@ static REP_SET *make_new_set(REP_SETS *sets)
return set;
}
count=sets->count+sets->invisible+SET_MALLOC_HUNC;
- if (!(set=(REP_SET*) my_realloc((uchar*) sets->set_buffer,
- sizeof(REP_SET)*count,
- MYF(MY_WME))))
+ if (!(set=(REP_SET*) my_realloc(PSI_NOT_INSTRUMENTED, sets->set_buffer,
+ sizeof(REP_SET)*count, MYF(MY_WME))))
return 0;
sets->set_buffer=set;
sets->set=set+sets->invisible;
- if (!(bit_buffer=(uint*) my_realloc((uchar*) sets->bit_buffer,
- (sizeof(uint)*sets->size_of_bits)*count,
- MYF(MY_WME))))
+ if (!(bit_buffer=(uint*) my_realloc(PSI_NOT_INSTRUMENTED, sets->bit_buffer,
+ (sizeof(uint)*sets->size_of_bits)*count,
+ MYF(MY_WME))))
return 0;
sets->bit_buffer=bit_buffer;
for (i=0 ; i < count ; i++)
@@ -898,7 +901,7 @@ static uint replace_strings(REPLACE *rep, char **start, uint *max_length,
if (to == end)
{
(*max_length)+=8192;
- if (!(new=my_realloc(*start,*max_length,MYF(MY_WME))))
+ if (!(new=my_realloc(PSI_NOT_INSTRUMENTED, *start,*max_length,MYF(MY_WME))))
return (uint) -1;
to=new+(to - *start);
end=(*start=new)+ *max_length-1;
@@ -914,7 +917,7 @@ static uint replace_strings(REPLACE *rep, char **start, uint *max_length,
if (to == end)
{
(*max_length)*=2;
- if (!(new=my_realloc(*start,*max_length,MYF(MY_WME))))
+ if (!(new=my_realloc(PSI_NOT_INSTRUMENTED, *start,*max_length,MYF(MY_WME))))
return (uint) -1;
to=new+(to - *start);
end=(*start=new)+ *max_length-1;
@@ -938,11 +941,11 @@ static int initialize_buffer()
{
bufread = 8192;
bufalloc = bufread + bufread / 2;
- if (!(buffer = my_malloc(bufalloc+1,MYF(MY_WME))))
+ if (!(buffer = my_malloc(PSI_NOT_INSTRUMENTED, bufalloc+1, MYF(MY_WME))))
return 1;
bufbytes=my_eof=0;
out_length=bufread;
- if (!(out_buff=my_malloc(out_length,MYF(MY_WME))))
+ if (!(out_buff=my_malloc(PSI_NOT_INSTRUMENTED, out_length, MYF(MY_WME))))
return(1);
return 0;
}
@@ -979,7 +982,7 @@ int n;
bufalloc *= 2;
bufread *= 2;
}
- buffer = my_realloc(buffer, bufalloc+1, MYF(MY_WME));
+ buffer = my_realloc(PSI_NOT_INSTRUMENTED, buffer, bufalloc+1, MYF(MY_WME));
if (! buffer)
return(-1);
}
diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c
index 1aae413d2a9..15a2a0e9bf1 100644
--- a/extra/resolve_stack_dump.c
+++ b/extra/resolve_stack_dump.c
@@ -224,8 +224,8 @@ static int init_sym_entry(SYM_ENTRY* se, char* buf)
static void init_sym_table()
{
char buf[512];
- if (my_init_dynamic_array(&sym_table, sizeof(SYM_ENTRY), INIT_SYM_TABLE,
- INC_SYM_TABLE, MYF(0)))
+ if (my_init_dynamic_array(&sym_table, PSI_NOT_INSTRUMENTED, sizeof(SYM_ENTRY),
+ INIT_SYM_TABLE, INC_SYM_TABLE, MYF(0)))
die("Failed in my_init_dynamic_array() -- looks like out of memory problem");
while (fgets(buf, sizeof(buf), fp_sym))
diff --git a/include/hash.h b/include/hash.h
index fd64bf4c5df..19d7189cf4d 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -63,13 +63,13 @@ typedef struct st_hash {
/* A search iterator state */
typedef uint HASH_SEARCH_STATE;
-#define my_hash_init(A,B,C,D,E,F,G,H) my_hash_init2(A,0,B,C,D,E,F,0,G,H)
+#define my_hash_init(A,B,C,D,E,F,G,H,I) my_hash_init2(A,0,B,C,D,E,F,0,G,H,I)
my_bool my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
ulong default_array_elements, size_t key_offset,
size_t key_length, my_hash_get_key get_key,
my_hash_function hash_function,
void (*free_element)(void*),
- uint flags);
+ uint flags, PSI_memory_key psi_key);
void my_hash_free(HASH *tree);
void my_hash_reset(HASH *hash);
uchar *my_hash_element(HASH *hash, size_t idx);
@@ -99,8 +99,8 @@ my_bool my_hash_iterate(HASH *hash, my_hash_walk_action action, void *argument);
#define my_hash_clear(H) bzero((char*) (H), sizeof(*(H)))
#define my_hash_inited(H) ((H)->blength != 0)
-#define my_hash_init_opt(A,B,C,D,E,F,G,H) \
- (!my_hash_inited(A) && my_hash_init(A,B,C,D,E,F,G,H))
+#define my_hash_init_opt(A,B,C,D,E,F,G,H, I) \
+ (!my_hash_inited(A) && my_hash_init(A,B,C,D,E,F,G,H, I))
#ifdef __cplusplus
}
diff --git a/include/my_alloc.h b/include/my_alloc.h
index 9b0aad26956..181f637c093 100644
--- a/include/my_alloc.h
+++ b/include/my_alloc.h
@@ -20,6 +20,8 @@
#ifndef _my_alloc_h
#define _my_alloc_h
+#include <mysql/psi/psi_memory.h>
+
#define ALLOC_MAX_BLOCK_TO_DROP 4096
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
@@ -43,7 +45,6 @@ typedef struct st_mem_root
/* if block have less memory it will be put in 'used' list */
size_t min_malloc;
size_t block_size; /* initial block size */
- size_t total_alloc;
unsigned int block_num; /* allocated blocks counter */
/*
first free block in queue test counter (if it exceed
@@ -52,7 +53,8 @@ typedef struct st_mem_root
unsigned int first_block_usage;
void (*error_handler)(void);
- const char *name;
+
+ PSI_memory_key m_psi_key;
} MEM_ROOT;
#ifdef __cplusplus
diff --git a/include/my_stack_alloc.h b/include/my_stack_alloc.h
index 2d5a721856d..95e746d6fe7 100644
--- a/include/my_stack_alloc.h
+++ b/include/my_stack_alloc.h
@@ -68,14 +68,14 @@ do \
else \
{ \
(must_be_freed)= 1; \
- (res)= my_malloc(size, MYF(MY_THREAD_SPECIFIC | MY_WME)); \
+ (res)= my_malloc(PSI_INSTRUMENT_ME, size, MYF(MY_THREAD_SPECIFIC | MY_WME)); \
} \
} while(0)
#else
#define alloc_on_stack(stack_end, res, must_be_freed, size) \
do { \
(must_be_freed)= 1; \
- (res)= my_malloc(size, MYF(MY_THREAD_SPECIFIC | MY_WME)); \
+ (res)= my_malloc(PSI_INSTRUMENT_ME, size, MYF(MY_THREAD_SPECIFIC | MY_WME)); \
} while(0)
#endif /* HAVE_ALLOCA */
diff --git a/include/my_sys.h b/include/my_sys.h
index 31e59b6bf47..5c0917e2648 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -18,6 +18,7 @@
#define _my_sys_h
#include <m_string.h>
+#include <mysql/psi/mysql_memory.h>
C_MODE_START
@@ -89,14 +90,12 @@ typedef struct my_aio_result {
#define MY_ZEROFILL 32U /* my_malloc(), fill array with zero */
#define MY_ALLOW_ZERO_PTR 64U /* my_realloc() ; zero ptr -> malloc */
#define MY_FREE_ON_ERROR 128U /* my_realloc() ; Free old ptr on error */
-#define MY_HOLD_ON_ERROR 256U /* my_realloc() ; Return old ptr on error */
#define MY_DONT_OVERWRITE_FILE 2048U /* my_copy: Don't overwrite file */
#define MY_THREADSAFE 2048U /* my_seek(): lock fd mutex */
#define MY_SYNC 4096U /* my_copy(): sync dst file */
#define MY_SYNC_DIR 32768U /* my_create/delete/rename: sync directory */
#define MY_SYNC_FILESIZE 65536U /* my_sync(): safe sync when file is extended */
#define MY_THREAD_SPECIFIC 0x10000U /* my_malloc(): thread specific */
-#define MY_THREAD_MOVE 0x20000U /* realloc(); Memory can move */
/* Tree that should delete things automatically */
#define MY_TREE_WITH_DELETE 0x40000U
@@ -168,14 +167,14 @@ typedef void (*MALLOC_SIZE_CB) (long long size, my_bool is_thread_specific);
extern void set_malloc_size_cb(MALLOC_SIZE_CB func);
/* defines when allocating data */
-extern void *my_malloc(size_t Size,myf MyFlags);
-extern void *my_multi_malloc(myf MyFlags, ...);
-extern void *my_multi_malloc_large(myf MyFlags, ...);
-extern void *my_realloc(void *oldpoint, size_t Size, myf MyFlags);
+extern void *my_malloc(PSI_memory_key key, size_t size, myf MyFlags);
+extern void *my_multi_malloc(PSI_memory_key key, myf MyFlags, ...);
+extern void *my_multi_malloc_large(PSI_memory_key key, myf MyFlags, ...);
+extern void *my_realloc(PSI_memory_key key, void *ptr, size_t size, myf MyFlags);
extern void my_free(void *ptr);
-extern void *my_memdup(const void *from,size_t length,myf MyFlags);
-extern char *my_strdup(const char *from,myf MyFlags);
-extern char *my_strndup(const char *from, size_t length, myf MyFlags);
+extern void *my_memdup(PSI_memory_key key, const void *from,size_t length,myf MyFlags);
+extern char *my_strdup(PSI_memory_key key, const char *from,myf MyFlags);
+extern char *my_strndup(PSI_memory_key key, const char *from, size_t length, myf MyFlags);
#ifdef HAVE_LINUX_LARGE_PAGES
extern uint my_get_large_page_size(void);
@@ -211,11 +210,11 @@ extern my_bool my_may_have_atomic_write;
#define MAX_ALLOCA_SZ 4096
#define my_safe_alloca(size) (((size) <= MAX_ALLOCA_SZ) ? \
my_alloca(size) : \
- my_malloc((size), MYF(MY_THREAD_SPECIFIC|MY_WME)))
+ my_malloc(PSI_NOT_INSTRUMENTED, (size), MYF(MY_THREAD_SPECIFIC|MY_WME)))
#define my_safe_afree(ptr, size) \
do { if ((size) > MAX_ALLOCA_SZ) my_free(ptr); } while(0)
#else
-#define my_alloca(SZ) my_malloc(SZ,MYF(MY_FAE))
+#define my_alloca(SZ) my_malloc(PSI_NOT_INSTRUMENTED, SZ,MYF(MY_FAE))
#define my_afree(PTR) my_free(PTR)
#define my_safe_alloca(size) my_alloca(size)
#define my_safe_afree(ptr, size) my_afree(ptr)
@@ -353,6 +352,7 @@ typedef struct st_dynamic_array
uint elements,max_element;
uint alloc_increment;
uint size_of_element;
+ PSI_memory_key m_psi_key;
myf malloc_flags;
} DYNAMIC_ARRAY;
@@ -835,11 +835,12 @@ extern my_bool real_open_cached_file(IO_CACHE *cache);
extern void close_cached_file(IO_CACHE *cache);
File create_temp_file(char *to, const char *dir, const char *pfx,
int mode, myf MyFlags);
-#define my_init_dynamic_array(A,B,C,D,E) init_dynamic_array2(A,B,NULL,C,D,E)
-#define my_init_dynamic_array2(A,B,C,D,E,F) init_dynamic_array2(A,B,C,D,E,F)
-extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
- void *init_buffer, uint init_alloc,
- uint alloc_increment, myf my_flags);
+#define my_init_dynamic_array(A,B,C,D,E,F) init_dynamic_array2(A,B,C,NULL,D,E,F)
+#define my_init_dynamic_array2(A,B,C,D,E,F,G) init_dynamic_array2(A,B,C,D,E,F,G)
+extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, PSI_memory_key psi_key,
+ uint element_size, void *init_buffer,
+ uint init_alloc, uint alloc_increment,
+ myf my_flags);
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void* element);
extern void *alloc_dynamic(DYNAMIC_ARRAY *array);
extern void *pop_dynamic(DYNAMIC_ARRAY*);
@@ -886,13 +887,14 @@ extern uint32 copy_and_convert_extended(char *to, uint32 to_length,
extern void *my_malloc_lock(size_t length,myf flags);
extern void my_free_lock(void *ptr);
#else
-#define my_malloc_lock(A,B) my_malloc((A),(B))
+#define my_malloc_lock(A,B) my_malloc(PSI_INSTRUMENT_ME, (A),(B))
#define my_free_lock(A) my_free((A))
#endif
+#define root_name(A) ""
#define alloc_root_inited(A) ((A)->min_malloc != 0)
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
-extern void init_alloc_root(MEM_ROOT *mem_root, const char *name,
+extern void init_alloc_root(PSI_memory_key key, MEM_ROOT *mem_root,
size_t block_size, size_t pre_alloc_size,
myf my_flags);
extern void *alloc_root(MEM_ROOT *mem_root, size_t Size);
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index 705bf7e712c..051821c2d37 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -240,6 +240,12 @@ typedef char **MYSQL_ROW;
typedef unsigned int MYSQL_FIELD_OFFSET;
typedef unsigned long long my_ulonglong;
extern "C" {
+}
+extern "C" {
+struct PSI_thread;
+typedef unsigned int PSI_memory_key;
+}
+extern "C" {
typedef struct st_used_mem
{
struct st_used_mem *next;
@@ -253,11 +259,10 @@ typedef struct st_mem_root
USED_MEM *pre_alloc;
size_t min_malloc;
size_t block_size;
- size_t total_alloc;
unsigned int block_num;
unsigned int first_block_usage;
void (*error_handler)(void);
- const char *name;
+ PSI_memory_key m_psi_key;
} MEM_ROOT;
}
typedef struct st_typelib {
diff --git a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc
index fb623f91458..33de60e92ac 100644
--- a/libmysqld/emb_qcache.cc
+++ b/libmysqld/emb_qcache.cc
@@ -418,7 +418,7 @@ int emb_load_querycache_result(THD *thd, Querycache_stream *src)
if (!data)
goto err;
- init_alloc_root(&data->alloc, "embedded_query_cache", 8192,0,MYF(0));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &data->alloc, 8192, 0, MYF(0));
f_alloc= &data->alloc;
data->fields= src->load_int();
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index c6a7486e399..d5810f5e48e 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -491,8 +491,8 @@ char **copy_arguments(int argc, char **argv)
for (from=argv ; from != end ; from++)
length+= strlen(*from);
- if ((res= (char**) my_malloc(sizeof(argv)*(argc+1)+length+argc,
- MYF(MY_WME))))
+ if ((res= (char**) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(argv)*(argc+1)+length+argc, MYF(MY_WME))))
{
char **to= res, *to_str= (char*) (res+argc+1);
for (from=argv ; from != end ;)
@@ -664,7 +664,7 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag)
thd->mysql= mysql;
mysql->server_version= server_version;
mysql->client_flag= client_flag;
- init_alloc_root(&mysql->field_alloc, "fields", 8192, 0, MYF(0));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &mysql->field_alloc, 8192, 0, MYF(0));
}
/**
@@ -758,7 +758,7 @@ int check_embedded_connection(MYSQL *mysql, const char *db)
sctx->host_or_ip= sctx->host= (char*) my_localhost;
strmake_buf(sctx->priv_host, (char*) my_localhost);
strmake_buf(sctx->priv_user, mysql->user);
- sctx->user= my_strdup(mysql->user, MYF(0));
+ sctx->user= my_strdup(PSI_NOT_INSTRUMENTED, mysql->user, MYF(0));
sctx->proxy_user[0]= 0;
sctx->master_access= GLOBAL_ACLS; // Full rights
emb_transfer_connect_attrs(mysql);
@@ -918,10 +918,8 @@ MYSQL_DATA *THD::alloc_new_dataset()
{
MYSQL_DATA *data;
struct embedded_query_result *emb_data;
- if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
- &data, sizeof(*data),
- &emb_data, sizeof(*emb_data),
- NULL))
+ if (!my_multi_malloc(PSI_NOT_INSTRUMENTED, MYF(MY_WME | MY_ZEROFILL),
+ &data, sizeof(*data), &emb_data, sizeof(*emb_data), NULL))
return NULL;
emb_data->prev_ptr= &data->data;
@@ -984,7 +982,7 @@ bool Protocol::begin_dataset()
return 1;
alloc= &data->alloc;
/* Assume rowlength < 8192 */
- init_alloc_root(alloc, "protocol", 8192, 0, MYF(0));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, alloc, 8192, 0, MYF(0));
alloc->min_malloc= sizeof(MYSQL_ROWS);
return 0;
}
diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c
index 8ede487e413..dce7a000c0c 100644
--- a/libmysqld/libmysql.c
+++ b/libmysqld/libmysql.c
@@ -399,9 +399,9 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
my_free(saved_db);
/* alloc new connect information */
- mysql->user= my_strdup(mysql->user, MYF(MY_WME));
- mysql->passwd= my_strdup(mysql->passwd, MYF(MY_WME));
- mysql->db= db ? my_strdup(db, MYF(MY_WME)) : 0;
+ mysql->user= my_strdup(PSI_NOT_INSTRUMENTED, mysql->user, MYF(MY_WME));
+ mysql->passwd= my_strdup(PSI_NOT_INSTRUMENTED, mysql->passwd, MYF(MY_WME));
+ mysql->db= db ? my_strdup(PSI_NOT_INSTRUMENTED, db, MYF(MY_WME)) : 0;
}
else
{
@@ -482,7 +482,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename)
}
/* copy filename into local memory and allocate read buffer */
- if (!(buf=my_malloc(packet_length, MYF(0))))
+ if (!(buf=my_malloc(PSI_NOT_INSTRUMENTED, packet_length, MYF(0))))
{
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
DBUG_RETURN(1);
@@ -580,7 +580,8 @@ static int default_local_infile_init(void **ptr, const char *filename,
char tmp_name[FN_REFLEN];
if (!(*ptr= data= ((default_local_infile_data *)
- my_malloc(sizeof(default_local_infile_data), MYF(0)))))
+ my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(default_local_infile_data), MYF(0)))))
return 1; /* out of memory */
data->error_msg[0]= 0;
@@ -865,7 +866,7 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild)
!(fields= (*mysql->methods->list_fields)(mysql)))
DBUG_RETURN(NULL);
- if (!(result = (MYSQL_RES *) my_malloc(sizeof(MYSQL_RES),
+ if (!(result = (MYSQL_RES *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(MYSQL_RES),
MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(NULL);
@@ -1543,10 +1544,10 @@ mysql_stmt_init(MYSQL *mysql)
DBUG_ENTER("mysql_stmt_init");
if (!(stmt=
- (MYSQL_STMT *) my_malloc(sizeof (MYSQL_STMT),
+ (MYSQL_STMT *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof (MYSQL_STMT),
MYF(MY_WME | MY_ZEROFILL))) ||
!(stmt->extension=
- (MYSQL_STMT_EXT *) my_malloc(sizeof (MYSQL_STMT_EXT),
+ (MYSQL_STMT_EXT *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof (MYSQL_STMT_EXT),
MYF(MY_WME | MY_ZEROFILL))))
{
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
@@ -1554,9 +1555,8 @@ mysql_stmt_init(MYSQL *mysql)
DBUG_RETURN(NULL);
}
- init_alloc_root(&stmt->mem_root, "stmt", 2048,2048, MYF(MY_THREAD_SPECIFIC));
- init_alloc_root(&stmt->result.alloc, "result", 4096, 4096,
- MYF(MY_THREAD_SPECIFIC));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &stmt->mem_root, 2048,2048, MYF(MY_THREAD_SPECIFIC));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &stmt->result.alloc, 4096, 4096, MYF(MY_THREAD_SPECIFIC));
stmt->result.alloc.min_malloc= sizeof(MYSQL_ROWS);
mysql->stmts= list_add(mysql->stmts, &stmt->list);
stmt->list.data= stmt;
@@ -1567,7 +1567,7 @@ mysql_stmt_init(MYSQL *mysql)
strmov(stmt->sqlstate, not_error_sqlstate);
/* The rest of statement members was bzeroed inside malloc */
- init_alloc_root(&stmt->extension->fields_mem_root, "extension", 2048, 0,
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &stmt->extension->fields_mem_root, 2048, 0,
MYF(MY_THREAD_SPECIFIC));
DBUG_RETURN(stmt);
@@ -1854,7 +1854,7 @@ mysql_stmt_result_metadata(MYSQL_STMT *stmt)
if (!stmt->field_count)
DBUG_RETURN(0);
- if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result),
+ if (!(result=(MYSQL_RES*) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(*result),
MYF(MY_WME | MY_ZEROFILL))))
{
set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate, NULL);
@@ -2212,7 +2212,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
}
length= (ulong) (net->write_pos - net->buff);
/* TODO: Look into avoding the following memdup */
- if (!(param_data= my_memdup(net->buff, length, MYF(0))))
+ if (!(param_data= my_memdup(PSI_NOT_INSTRUMENTED, net->buff, length, MYF(0))))
{
set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate, NULL);
DBUG_RETURN(1);
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index 6de86927a38..d29126467e2 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -157,7 +157,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
put extra 'my_free's in mysql_close.
So we alloc it with the 'user' string to be freed at once
*/
- mysql->user= my_strdup(user, MYF(0));
+ mysql->user= my_strdup(PSI_NOT_INSTRUMENTED, user, MYF(0));
port=0;
unix_socket=0;
@@ -175,7 +175,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (db)
client_flag|=CLIENT_CONNECT_WITH_DB;
- mysql->info_buffer= my_malloc(MYSQL_ERRMSG_SIZE, MYF(0));
+ mysql->info_buffer= my_malloc(PSI_NOT_INSTRUMENTED, MYSQL_ERRMSG_SIZE, MYF(0));
mysql->thd= create_embedded_thd(client_flag);
init_embedded_mysql(mysql, client_flag);
diff --git a/mysys/array.c b/mysys/array.c
index 07abc460de7..20767efdf9e 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -40,9 +40,9 @@
FALSE Ok
*/
-my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
- void *init_buffer, uint init_alloc,
- uint alloc_increment, myf my_flags)
+my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, PSI_memory_key psi_key,
+ uint element_size, void *init_buffer,
+ uint init_alloc, uint alloc_increment, myf my_flags)
{
DBUG_ENTER("init_dynamic_array2");
if (!alloc_increment)
@@ -55,6 +55,7 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
array->max_element=init_alloc;
array->alloc_increment=alloc_increment;
array->size_of_element=element_size;
+ array->m_psi_key= psi_key;
array->malloc_flags= my_flags;
DBUG_ASSERT((my_flags & MY_INIT_BUFFER_USED) == 0);
if ((array->buffer= init_buffer))
@@ -67,7 +68,7 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
should not throw an error
*/
if (init_alloc &&
- !(array->buffer= (uchar*) my_malloc(element_size*init_alloc,
+ !(array->buffer= (uchar*) my_malloc(psi_key, element_size*init_alloc,
MYF(my_flags))))
array->max_element=0;
DBUG_RETURN(FALSE);
@@ -133,7 +134,8 @@ void *alloc_dynamic(DYNAMIC_ARRAY *array)
In this scenario, the buffer is statically preallocated,
so we have to create an all-new malloc since we overflowed
*/
- if (!(new_ptr= (char *) my_malloc((array->max_element+
+ if (!(new_ptr= (char *) my_malloc(array->m_psi_key,
+ (array->max_element+
array->alloc_increment) *
array->size_of_element,
MYF(array->malloc_flags | MY_WME))))
@@ -143,8 +145,8 @@ void *alloc_dynamic(DYNAMIC_ARRAY *array)
array->malloc_flags&= ~MY_INIT_BUFFER_USED;
}
else if (!(new_ptr=(char*)
- my_realloc(array->buffer,(array->max_element+
- array->alloc_increment)*
+ my_realloc(array->m_psi_key, array->buffer,
+ (array->max_element+ array->alloc_increment) *
array->size_of_element,
MYF(MY_WME | MY_ALLOW_ZERO_PTR |
array->malloc_flags))))
@@ -241,7 +243,7 @@ my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements)
In this senerio, the buffer is statically preallocated,
so we have to create an all-new malloc since we overflowed
*/
- if (!(new_ptr= (uchar *) my_malloc(size *
+ if (!(new_ptr= (uchar *) my_malloc(array->m_psi_key, size *
array->size_of_element,
MYF(array->malloc_flags | MY_WME))))
DBUG_RETURN(0);
@@ -249,7 +251,8 @@ my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements)
array->elements * array->size_of_element);
array->malloc_flags&= ~MY_INIT_BUFFER_USED;
}
- else if (!(new_ptr= (uchar*) my_realloc(array->buffer,size*
+ else if (!(new_ptr= (uchar*) my_realloc(array->m_psi_key,
+ array->buffer,size *
array->size_of_element,
MYF(MY_WME | MY_ALLOW_ZERO_PTR |
array->malloc_flags))))
@@ -362,8 +365,8 @@ void freeze_size(DYNAMIC_ARRAY *array)
elements= MY_MAX(array->elements, 1);
if (array->buffer && array->max_element > elements)
{
- array->buffer=(uchar*) my_realloc(array->buffer,
- elements*array->size_of_element,
+ array->buffer=(uchar*) my_realloc(array->m_psi_key, array->buffer,
+ elements * array->size_of_element,
MYF(MY_WME | array->malloc_flags));
array->max_element= elements;
}
diff --git a/mysys/charset.c b/mysys/charset.c
index 9c61fa85481..5e999c8435d 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -463,12 +463,12 @@ my_once_alloc_c(size_t size)
static void *
my_malloc_c(size_t size)
-{ return my_malloc(size, MYF(MY_WME)); }
+{ return my_malloc(key_memory_charset_loader, size, MYF(MY_WME)); }
static void *
my_realloc_c(void *old, size_t size)
-{ return my_realloc(old, size, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); }
+{ return my_realloc(key_memory_charset_loader, old, size, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); }
/**
@@ -506,7 +506,7 @@ my_read_charset_file(MY_CHARSET_LOADER *loader,
if (!my_stat(filename, &stat_info, MYF(myflags)) ||
((len= (uint)stat_info.st_size) > MY_MAX_ALLOWED_BUF) ||
- !(buf= (uchar*) my_malloc(len,myflags)))
+ !(buf= (uchar*) my_malloc(key_memory_charset_loader,len,myflags)))
return TRUE;
if ((fd= mysql_file_open(key_file_charset, filename, O_RDONLY, myflags)) < 0)
diff --git a/mysys/file_logger.c b/mysys/file_logger.c
index 71394be7afc..eb5579fb8a9 100644
--- a/mysys/file_logger.c
+++ b/mysys/file_logger.c
@@ -84,7 +84,8 @@ LOGGER_HANDLE *logger_open(const char *path,
return 0;
}
- if (!(l_perm= (LOGGER_HANDLE *) my_malloc(sizeof(LOGGER_HANDLE), MYF(0))))
+ if (!(l_perm= (LOGGER_HANDLE *) my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(LOGGER_HANDLE), MYF(0))))
{
my_close(new_log.file, MYF(0));
new_log.file= -1;
diff --git a/mysys/get_password.c b/mysys/get_password.c
index e20800f4213..2a5ddc9a4d7 100644
--- a/mysys/get_password.c
+++ b/mysys/get_password.c
@@ -90,7 +90,7 @@ char *get_tty_password(const char *opt_message)
pos--; /* Allow dummy space at end */
*pos=0;
_cputs("\n");
- DBUG_RETURN(my_strdup(to,MYF(MY_FAE)));
+ DBUG_RETURN(my_strdup(PSI_INSTRUMENT_ME, to,MYF(MY_FAE)));
}
#else
@@ -201,7 +201,7 @@ char *get_tty_password(const char *opt_message)
fputc('\n',stderr);
#endif /* HAVE_GETPASS */
- DBUG_RETURN(my_strdup(buff,MYF(MY_FAE)));
+ DBUG_RETURN(my_strdup(PSI_INSTRUMENT_ME, buff, MYF(MY_FAE)));
}
#endif /*__WIN__*/
diff --git a/mysys/hash.c b/mysys/hash.c
index ba2aa8fc30e..ddb146af5e0 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -80,7 +80,7 @@ my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
ulong size, size_t key_offset, size_t key_length,
my_hash_get_key get_key,
my_hash_function hash_function,
- void (*free_element)(void*), uint flags)
+ void (*free_element)(void*), uint flags, PSI_memory_key psi_key)
{
my_bool res;
DBUG_ENTER("my_hash_init2");
@@ -95,7 +95,7 @@ my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
hash->free=free_element;
hash->flags=flags;
hash->charset=charset;
- res= init_dynamic_array2(&hash->array, sizeof(HASH_LINK), NULL, size,
+ res= init_dynamic_array2(&hash->array, psi_key, sizeof(HASH_LINK), NULL, size,
growth_size, MYF((flags & HASH_THREAD_SPECIFIC ?
MY_THREAD_SPECIFIC : 0)));
DBUG_RETURN(res);
@@ -890,7 +890,8 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
printf("my_hash_init\n");
if (my_hash_init2(&hash_test, 100, &my_charset_bin, 20,
- 0, 0, (my_hash_get_key) test_get_key, 0, 0, HASH_UNIQUE))
+ 0, 0, (my_hash_get_key) test_get_key, 0, 0, HASH_UNIQUE,
+ PSI_INSTRUMENT_ME))
{
fprintf(stderr, "hash init failed\n");
exit(1);
diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c
index b98684556c3..86464b3eaeb 100644
--- a/mysys/lf_alloc-pin.c
+++ b/mysys/lf_alloc-pin.c
@@ -99,8 +99,7 @@
between THD's (LF_PINS::stack_ends_here being a primary reason
for this limitation).
*/
-#include <my_global.h>
-#include <my_sys.h>
+#include "mysys_priv.h"
#include <lf.h>
/*
@@ -500,7 +499,8 @@ void *lf_alloc_new(LF_PINS *pins)
} while (node != allocator->top && LF_BACKOFF());
if (!node)
{
- node= (void *)my_malloc(allocator->element_size, MYF(MY_WME));
+ node= (void *)my_malloc(key_memory_lf_node, allocator->element_size,
+ MYF(MY_WME));
if (allocator->constructor)
allocator->constructor(node);
#ifdef MY_LF_EXTRA_DEBUG
diff --git a/mysys/lf_dynarray.c b/mysys/lf_dynarray.c
index be23690c70b..6a4ea3d3d96 100644
--- a/mysys/lf_dynarray.c
+++ b/mysys/lf_dynarray.c
@@ -35,9 +35,8 @@
Actually, it's wait-free, not lock-free ;-)
*/
-#include <my_global.h>
+#include "mysys_priv.h"
#include <m_string.h>
-#include <my_sys.h>
#include <lf.h>
void lf_dynarray_init(LF_DYNARRAY *array, uint element_size)
@@ -106,8 +105,8 @@ void *lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
{
if (!(ptr= *ptr_ptr))
{
- void *alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * sizeof(void *),
- MYF(MY_WME|MY_ZEROFILL));
+ void *alloc= my_malloc(key_memory_lf_dynarray, LF_DYNARRAY_LEVEL_LENGTH *
+ sizeof(void *), MYF(MY_WME|MY_ZEROFILL));
if (unlikely(!alloc))
return(NULL);
if (my_atomic_casptr(ptr_ptr, &ptr, alloc))
@@ -121,9 +120,10 @@ void *lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
if (!(ptr= *ptr_ptr))
{
uchar *alloc, *data;
- alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * array->size_of_element +
- MY_MAX(array->size_of_element, sizeof(void *)),
- MYF(MY_WME|MY_ZEROFILL));
+ alloc= my_malloc(key_memory_lf_dynarray,
+ LF_DYNARRAY_LEVEL_LENGTH * array->size_of_element +
+ MY_MAX(array->size_of_element, sizeof(void *)),
+ MYF(MY_WME|MY_ZEROFILL));
if (unlikely(!alloc))
return(NULL);
/* reserve the space for free() address */
diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c
index 73b9f874598..6a1e69f529f 100644
--- a/mysys/lf_hash.c
+++ b/mysys/lf_hash.c
@@ -22,9 +22,8 @@
for non-unique hash, count only _distinct_ values
(but how to do it in lf_hash_delete ?)
*/
-#include <my_global.h>
+#include "mysys_priv.h"
#include <m_string.h>
-#include <my_sys.h>
#include <mysys_err.h>
#include <my_bit.h>
#include <lf.h>
@@ -543,7 +542,8 @@ static int initialize_bucket(LF_HASH *hash, LF_SLIST * volatile *node,
uint bucket, LF_PINS *pins)
{
uint parent= my_clear_highest_bit(bucket);
- LF_SLIST *dummy= (LF_SLIST *)my_malloc(sizeof(LF_SLIST), MYF(MY_WME));
+ LF_SLIST *dummy= (LF_SLIST *)my_malloc(key_memory_lf_slist,
+ sizeof(LF_SLIST), MYF(MY_WME));
LF_SLIST **tmp= 0, *cur;
LF_SLIST * volatile *el= lf_dynarray_lvalue(&hash->array, parent);
if (unlikely(!el || !dummy))
diff --git a/mysys/list.c b/mysys/list.c
index 10dfd7ec6ef..1770b201dd4 100644
--- a/mysys/list.c
+++ b/mysys/list.c
@@ -70,7 +70,7 @@ void list_free(LIST *root, uint free_data)
LIST *list_cons(void *data, LIST *list)
{
- LIST *new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
+ LIST *new_charset=(LIST*) my_malloc(key_memory_LIST, sizeof(LIST),MYF(MY_FAE));
if (!new_charset)
return 0;
new_charset->data=data;
diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c
index 2068d0d818c..edd476b4188 100644
--- a/mysys/ma_dyncol.c
+++ b/mysys/ma_dyncol.c
@@ -2417,8 +2417,8 @@ dynamic_column_list(DYNAMIC_COLUMN *str, DYNAMIC_ARRAY *array_of_uint)
str->length)
return ER_DYNCOL_FORMAT;
- if (my_init_dynamic_array(array_of_uint, sizeof(uint), header.column_count,
- 0, MYF(0)))
+ if (my_init_dynamic_array(array_of_uint, PSI_INSTRUMENT_ME,
+ sizeof(uint), header.column_count, 0, MYF(0)))
return ER_DYNCOL_RESOURCE;
for (i= 0, read= header.header;
@@ -2463,7 +2463,7 @@ mariadb_dyncol_list_num(DYNAMIC_COLUMN *str, uint *count, uint **nums)
str->length)
return ER_DYNCOL_FORMAT;
- if (!((*nums)= my_malloc(sizeof(uint) * header.column_count, MYF(0))))
+ if (!((*nums)= my_malloc(PSI_INSTRUMENT_ME, sizeof(uint) * header.column_count, MYF(0))))
return ER_DYNCOL_RESOURCE;
for (i= 0, read= header.header;
@@ -2510,12 +2510,17 @@ mariadb_dyncol_list_named(DYNAMIC_COLUMN *str, uint *count, LEX_STRING **names)
str->length)
return ER_DYNCOL_FORMAT;
- if (header.format == dyncol_fmt_num)
- *names= my_malloc(sizeof(LEX_STRING) * header.column_count +
- DYNCOL_NUM_CHAR * header.column_count, MYF(0));
- else
- *names= my_malloc(sizeof(LEX_STRING) * header.column_count +
- header.nmpool_size + header.column_count, MYF(0));
+ {
+ size_t size;
+ if (header.format == dyncol_fmt_num)
+ size= DYNCOL_NUM_CHAR * header.column_count;
+ else
+ size= header.nmpool_size + header.column_count;
+
+ *names= my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(LEX_STRING) * header.column_count + size, MYF(0));
+ }
+
if (!(*names))
return ER_DYNCOL_RESOURCE;
pool= ((char *)(*names)) + sizeof(LEX_STRING) * header.column_count;
@@ -3327,7 +3332,8 @@ dynamic_column_update_many_fmt(DYNAMIC_COLUMN *str,
if (IN_PLACE_PLAN > add_column_count)
plan= in_place_plan;
else if (!(alloc_plan= plan=
- my_malloc(sizeof(PLAN) * (add_column_count + 1), MYF(0))))
+ my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(PLAN) * (add_column_count + 1), MYF(0))))
return ER_DYNCOL_RESOURCE;
not_null= add_column_count;
@@ -3923,7 +3929,7 @@ mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val,
&dummy_errors);
return ER_DYNCOL_OK;
}
- if ((alloc= (char *)my_malloc(bufflen, MYF(0))))
+ if ((alloc= (char *)my_malloc(PSI_INSTRUMENT_ME, bufflen, MYF(0))))
{
len= my_convert(alloc, bufflen, cs, from, (uint32)len,
val->x.string.charset, &dummy_errors);
@@ -4298,16 +4304,19 @@ mariadb_dyncol_unpack(DYNAMIC_COLUMN *str,
str->length)
return ER_DYNCOL_FORMAT;
- *vals= my_malloc(sizeof(DYNAMIC_COLUMN_VALUE)* header.column_count, MYF(0));
+ *vals= my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(DYNAMIC_COLUMN_VALUE)* header.column_count, MYF(0));
if (header.format == dyncol_fmt_num)
{
- *names= my_malloc(sizeof(LEX_STRING) * header.column_count +
+ *names= my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(LEX_STRING) * header.column_count +
DYNCOL_NUM_CHAR * header.column_count, MYF(0));
nm= (char *)((*names) + header.column_count);
}
else
{
- *names= my_malloc(sizeof(LEX_STRING) * header.column_count, MYF(0));
+ *names= my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(LEX_STRING) * header.column_count, MYF(0));
nm= 0;
}
if (!(*vals) || !(*names))
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 54b89007b4c..a9d4270cc71 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -244,7 +244,7 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
if (cachesize == min_cache)
flags|= (myf) MY_WME;
- if ((info->buffer= (uchar*) my_malloc(buffer_block, flags)) != 0)
+ if ((info->buffer= (uchar*) my_malloc(key_memory_IO_CACHE, buffer_block, flags)) != 0)
{
if (type == SEQ_READ_APPEND)
info->write_buffer= info->buffer + cachesize;
@@ -324,7 +324,7 @@ int init_slave_io_cache(IO_CACHE *master, IO_CACHE *slave)
DBUG_ASSERT(!master->share);
DBUG_ASSERT(master->alloced_buffer);
- if (!(slave_buf= (uchar*)my_malloc(master->buffer_length, MYF(0))))
+ if (!(slave_buf= (uchar*)my_malloc(PSI_INSTRUMENT_ME, master->buffer_length, MYF(0))))
{
return 1;
}
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 07dd8f3e1ef..94b720b1006 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -554,7 +554,7 @@ int init_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
Allocate memory for blocks, hash_links and hash entries;
For each block 2 hash links are allocated
*/
- if (my_multi_malloc_large(MYF(MY_ZEROFILL),
+ if (my_multi_malloc_large(key_memory_KEY_CACHE, MYF(MY_ZEROFILL),
&keycache->block_root,
(ulonglong) (blocks * sizeof(BLOCK_LINK)),
&keycache->hash_root,
@@ -3949,8 +3949,8 @@ static int flush_key_blocks_int(SIMPLE_KEY_CACHE_CB *keycache,
changed blocks appear while we need to wait for something.
*/
if ((count > FLUSH_CACHE) &&
- !(cache= (BLOCK_LINK**) my_malloc(sizeof(BLOCK_LINK*)*count,
- MYF(0))))
+ !(cache= (BLOCK_LINK**) my_malloc(key_memory_KEY_CACHE,
+ sizeof(BLOCK_LINK*)*count, MYF(0))))
cache= cache_buff;
/*
After a restart there could be more changed blocks than now.
@@ -5113,7 +5113,8 @@ int init_partitioned_key_cache(PARTITIONED_KEY_CACHE_CB *keycache,
else
{
if(!(partition_ptr=
- (SIMPLE_KEY_CACHE_CB **) my_malloc(sizeof(SIMPLE_KEY_CACHE_CB *) *
+ (SIMPLE_KEY_CACHE_CB **) my_malloc(key_memory_KEY_CACHE,
+ sizeof(SIMPLE_KEY_CACHE_CB *) *
partitions, MYF(MY_WME))))
DBUG_RETURN(-1);
bzero(partition_ptr, sizeof(SIMPLE_KEY_CACHE_CB *) * partitions);
@@ -5131,7 +5132,8 @@ int init_partitioned_key_cache(PARTITIONED_KEY_CACHE_CB *keycache,
else
{
if (!(partition=
- (SIMPLE_KEY_CACHE_CB *) my_malloc(sizeof(SIMPLE_KEY_CACHE_CB),
+ (SIMPLE_KEY_CACHE_CB *) my_malloc(key_memory_KEY_CACHE,
+ sizeof(SIMPLE_KEY_CACHE_CB),
MYF(MY_WME))))
continue;
partition->key_cache_inited= 0;
@@ -5909,7 +5911,8 @@ int init_key_cache_internal(KEY_CACHE *keycache, uint key_cache_block_size,
{
if (partitions == 0)
{
- if (!(keycache_cb= (void *) my_malloc(sizeof(SIMPLE_KEY_CACHE_CB),
+ if (!(keycache_cb= (void *) my_malloc(key_memory_KEY_CACHE,
+ sizeof(SIMPLE_KEY_CACHE_CB),
MYF(0))))
return 0;
((SIMPLE_KEY_CACHE_CB *) keycache_cb)->key_cache_inited= 0;
@@ -5918,7 +5921,8 @@ int init_key_cache_internal(KEY_CACHE *keycache, uint key_cache_block_size,
}
else
{
- if (!(keycache_cb= (void *) my_malloc(sizeof(PARTITIONED_KEY_CACHE_CB),
+ if (!(keycache_cb= (void *) my_malloc(key_memory_KEY_CACHE,
+ sizeof(PARTITIONED_KEY_CACHE_CB),
MYF(0))))
return 0;
((PARTITIONED_KEY_CACHE_CB *) keycache_cb)->key_cache_inited= 0;
diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c
index 3cbad020cb1..24e875b813e 100644
--- a/mysys/mf_sort.c
+++ b/mysys/mf_sort.c
@@ -24,7 +24,8 @@ void my_string_ptr_sort(uchar *base, uint items, size_t size)
uchar **ptr=0;
if (radixsort_is_appliccable(items, size) &&
- (ptr= (uchar**) my_malloc(items*sizeof(char*),MYF(0))))
+ (ptr= (uchar**) my_malloc(PSI_NOT_INSTRUMENTED,
+ items * sizeof(char*),MYF(0))))
{
radixsort_for_str_ptr((uchar**) base,items,size,ptr);
my_free(ptr);
diff --git a/mysys/mf_tempdir.c b/mysys/mf_tempdir.c
index 39de3570fad..1883c5578f8 100644
--- a/mysys/mf_tempdir.c
+++ b/mysys/mf_tempdir.c
@@ -30,7 +30,8 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
DBUG_PRINT("enter", ("pathlist: %s", pathlist ? pathlist : "NULL"));
mysql_mutex_init(key_TMPDIR_mutex, &tmpdir->mutex, MY_MUTEX_INIT_FAST);
- if (my_init_dynamic_array(&tmpdir->full_list, sizeof(char*), 1, 5, MYF(0)))
+ if (my_init_dynamic_array(&tmpdir->full_list, key_memory_MY_TMPDIR_full_list,
+ sizeof(char*), 1, 5, MYF(0)))
goto err;
if (!pathlist || !pathlist[0])
{
@@ -51,7 +52,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
end=strcend(pathlist, DELIM);
strmake(buff, pathlist, (uint) (end-pathlist));
length= cleanup_dirname(buff, buff);
- if (!(copy= my_strndup(buff, length, MYF(MY_WME))) ||
+ if (!(copy= my_strndup(key_memory_MY_TMPDIR_full_list, buff, length, MYF(MY_WME))) ||
insert_dynamic(&tmpdir->full_list, (uchar*) &copy))
DBUG_RETURN(TRUE);
pathlist=end+1;
diff --git a/mysys/mulalloc.c b/mysys/mulalloc.c
index 26f8253bc87..357f9315f2b 100644
--- a/mysys/mulalloc.c
+++ b/mysys/mulalloc.c
@@ -32,7 +32,7 @@
NULL
*/
-void* my_multi_malloc(myf myFlags, ...)
+void* my_multi_malloc(PSI_memory_key key, myf myFlags, ...)
{
va_list args;
char **ptr,*start,*res;
@@ -48,7 +48,7 @@ void* my_multi_malloc(myf myFlags, ...)
}
va_end(args);
- if (!(start=(char *) my_malloc(tot_length,myFlags)))
+ if (!(start=(char *) my_malloc(key, tot_length,myFlags)))
DBUG_RETURN(0); /* purecov: inspected */
va_start(args,myFlags);
@@ -76,7 +76,7 @@ void* my_multi_malloc(myf myFlags, ...)
NULL
*/
-void *my_multi_malloc_large(myf myFlags, ...)
+void *my_multi_malloc_large(PSI_memory_key key, myf myFlags, ...)
{
va_list args;
char **ptr,*start,*res;
@@ -92,7 +92,7 @@ void *my_multi_malloc_large(myf myFlags, ...)
}
va_end(args);
- if (!(start=(char *) my_malloc((size_t) tot_length, myFlags)))
+ if (!(start=(char *) my_malloc(key, (size_t) tot_length, myFlags)))
DBUG_RETURN(0); /* purecov: inspected */
va_start(args,myFlags);
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index 79e4ba9d563..3120ee50a59 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -54,35 +54,32 @@
Because of this, we store in MY_THREAD_SPECIFIC as bit 1 in block_size
*/
-void init_alloc_root(MEM_ROOT *mem_root, const char *name, size_t block_size,
+void init_alloc_root(PSI_memory_key key, MEM_ROOT *mem_root, size_t block_size,
size_t pre_alloc_size __attribute__((unused)),
myf my_flags)
{
DBUG_ENTER("init_alloc_root");
- DBUG_PRINT("enter",("root: %p name: %s prealloc: %zu", mem_root,
- name, pre_alloc_size));
+ DBUG_PRINT("enter",("root: %p prealloc: %zu", mem_root, pre_alloc_size));
mem_root->free= mem_root->used= mem_root->pre_alloc= 0;
mem_root->min_malloc= 32;
mem_root->block_size= (block_size - ALLOC_ROOT_MIN_BLOCK_SIZE) & ~1;
- if (MY_TEST(my_flags & MY_THREAD_SPECIFIC))
+ if (my_flags & MY_THREAD_SPECIFIC)
mem_root->block_size|= 1;
mem_root->error_handler= 0;
mem_root->block_num= 4; /* We shift this with >>2 */
mem_root->first_block_usage= 0;
- mem_root->total_alloc= 0;
- mem_root->name= name;
+ mem_root->m_psi_key= key;
#if !(defined(HAVE_valgrind) && defined(EXTRA_DEBUG))
if (pre_alloc_size)
{
+ size_t size= pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM));
if ((mem_root->free= mem_root->pre_alloc=
- (USED_MEM*) my_malloc(pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM)),
- MYF(my_flags))))
+ (USED_MEM*) my_malloc(key, size, MYF(my_flags))))
{
- mem_root->free->size= pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM));
- mem_root->total_alloc= pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM));
+ mem_root->free->size= size;
mem_root->free->left= pre_alloc_size;
mem_root->free->next= 0;
TRASH_MEM(mem_root->free);
@@ -141,19 +138,17 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
{
/* remove block from the list and free it */
*prev= mem->next;
- mem_root->total_alloc-= mem->size;
my_free(mem);
}
else
prev= &mem->next;
}
/* Allocate new prealloc block and add it to the end of free list */
- if ((mem= (USED_MEM *) my_malloc(size,
+ if ((mem= (USED_MEM *) my_malloc(mem_root->m_psi_key, size,
MYF(MALLOC_FLAG(mem_root->
block_size)))))
{
mem->size= size;
- mem_root->total_alloc+= size;
mem->left= pre_alloc_size;
mem->next= *prev;
*prev= mem_root->pre_alloc= mem;
@@ -178,7 +173,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
#if defined(HAVE_valgrind) && defined(EXTRA_DEBUG)
reg1 USED_MEM *next;
DBUG_ENTER("alloc_root");
- DBUG_PRINT("enter",("root: %p name: %s", mem_root, mem_root->name));
+ DBUG_PRINT("enter",("root: %p name: %s", mem_root, root_name(mem_root)));
DBUG_ASSERT(alloc_root_inited(mem_root));
@@ -203,10 +198,8 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
next->left= 0;
next->size= length;
mem_root->used= next;
- mem_root->total_alloc+= length;
- DBUG_PRINT("exit",("ptr: %p", (((char*) next)+
- ALIGN_SIZE(sizeof(USED_MEM)))));
- DBUG_RETURN((uchar*) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM))));
+ DBUG_PRINT("exit",("ptr: %p", (((char*)next)+ALIGN_SIZE(sizeof(USED_MEM)))));
+ DBUG_RETURN((((uchar*) next)+ALIGN_SIZE(sizeof(USED_MEM))));
#else
size_t get_size, block_size;
uchar* point;
@@ -214,7 +207,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
reg2 USED_MEM **prev;
size_t original_length = length;
DBUG_ENTER("alloc_root");
- DBUG_PRINT("enter",("root: %p name: %s", mem_root, mem_root->name));
+ DBUG_PRINT("enter",("root: %p name: %s", mem_root, root_name(mem_root)));
DBUG_ASSERT(alloc_root_inited(mem_root));
DBUG_EXECUTE_IF("simulate_out_of_memory",
@@ -247,7 +240,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
get_size= MY_MAX(get_size, block_size);
- if (!(next = (USED_MEM*) my_malloc(get_size,
+ if (!(next = (USED_MEM*) my_malloc(mem_root->m_psi_key, get_size,
MYF(MY_WME | ME_FATAL |
MALLOC_FLAG(mem_root->
block_size)))))
@@ -257,7 +250,6 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
DBUG_RETURN((void*) 0); /* purecov: inspected */
}
mem_root->block_num++;
- mem_root->total_alloc+= get_size;
next->next= *prev;
next->size= get_size;
next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM));
@@ -394,7 +386,7 @@ void free_root(MEM_ROOT *root, myf MyFlags)
{
reg1 USED_MEM *next,*old;
DBUG_ENTER("free_root");
- DBUG_PRINT("enter",("root: %p name: %s flags: %u", root, root->name,
+ DBUG_PRINT("enter",("root: %p name: %s flags: %u", root, root_name(root),
(uint) MyFlags));
#if !(defined(HAVE_valgrind) && defined(EXTRA_DEBUG))
@@ -415,19 +407,13 @@ void free_root(MEM_ROOT *root, myf MyFlags)
{
old=next; next= next->next ;
if (old != root->pre_alloc)
- {
- root->total_alloc-= old->size;
my_free(old);
- }
}
for (next=root->free ; next ;)
{
old=next; next= next->next;
if (old != root->pre_alloc)
- {
- root->total_alloc-= old->size;
my_free(old);
- }
}
root->used=root->free=0;
if (root->pre_alloc)
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index 8059b909788..b671d87a933 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -173,7 +173,8 @@ my_bool my_bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
size_in_bytes= ALIGN_SIZE(size_in_bytes);
extra= sizeof(mysql_mutex_t);
}
- if (!(buf= (my_bitmap_map*) my_malloc(size_in_bytes+extra, MYF(MY_WME))))
+ if (!(buf= (my_bitmap_map*) my_malloc(key_memory_MY_BITMAP_bitmap,
+ size_in_bytes+extra, MYF(MY_WME))))
DBUG_RETURN(1);
if (thread_safe)
{
diff --git a/mysys/my_compress.c b/mysys/my_compress.c
index 7cd85d57dd8..11603e7ba24 100644
--- a/mysys/my_compress.c
+++ b/mysys/my_compress.c
@@ -15,7 +15,7 @@
/* Written by Sinisa Milivojevic <sinisa@mysql.com> */
-#include <my_global.h>
+#include <mysys_priv.h>
#ifdef HAVE_COMPRESS
#include <my_sys.h>
#ifndef SCO
@@ -84,7 +84,8 @@ my_bool my_compress(uchar *packet, size_t *len, size_t *complen)
void *my_az_allocator(void *dummy __attribute__((unused)), unsigned int items,
unsigned int size)
{
- return my_malloc((size_t)items*(size_t)size, IF_VALGRIND(MY_ZEROFILL, MYF(0)));
+ return my_malloc(key_memory_my_compress_alloc, (size_t)items*(size_t)size,
+ IF_VALGRIND(MY_ZEROFILL, MYF(0)));
}
void my_az_free(void *dummy __attribute__((unused)), void *address)
@@ -133,8 +134,9 @@ uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen)
int res;
*complen= *len * 120 / 100 + 12;
- if (!(compbuf= (uchar *) my_malloc(*complen, MYF(MY_WME))))
- return 0; /* Not enough memory */
+ if (!(compbuf= (uchar *) my_malloc(key_memory_my_compress_alloc,
+ *complen, MYF(MY_WME))))
+ return 0;
res= my_compress_buffer(compbuf, complen, packet, *len);
@@ -180,7 +182,8 @@ my_bool my_uncompress(uchar *packet, size_t len, size_t *complen)
if (*complen) /* If compressed */
{
- uchar *compbuf= (uchar *) my_malloc(*complen,MYF(MY_WME));
+ uchar *compbuf= (uchar *) my_malloc(key_memory_my_compress_alloc,
+ *complen,MYF(MY_WME));
int error;
if (!compbuf)
DBUG_RETURN(1); /* Not enough memory */
diff --git a/mysys/my_default.c b/mysys/my_default.c
index 30c76c7f5ed..885bc6449fc 100644
--- a/mysys/my_default.c
+++ b/mysys/my_default.c
@@ -410,13 +410,14 @@ int my_load_defaults(const char *conf_file, const char **groups, int *argc,
const char **dirs;
DBUG_ENTER("my_load_defaults");
- init_alloc_root(&alloc, "my_load_defaults", 512, 0, MYF(0));
+ init_alloc_root(key_memory_defaults, &alloc, 512, 0, MYF(0));
if ((dirs= init_default_directories(&alloc)) == NULL)
goto err;
args_used= get_defaults_options(*argv);
- if (my_init_dynamic_array(&args, sizeof(char*), 128, 64, MYF(0)))
+ if (my_init_dynamic_array(&args, key_memory_defaults, sizeof(char*), 128, 64,
+ MYF(0)))
goto err;
insert_dynamic(&args, *argv);/* Name MUST be set, even by embedded library */
@@ -879,7 +880,7 @@ void my_print_default_files(const char *conf_file)
{
const char **dirs;
MEM_ROOT alloc;
- init_alloc_root(&alloc, "my_print_defaults", 512, 0, MYF(0));
+ init_alloc_root(key_memory_defaults, &alloc, 512, 0, MYF(0));
if ((dirs= init_default_directories(&alloc)) == NULL)
{
diff --git a/mysys/my_error.c b/mysys/my_error.c
index cb1fbfe1c04..4c3cd1435ac 100644
--- a/mysys/my_error.c
+++ b/mysys/my_error.c
@@ -224,7 +224,8 @@ int my_error_register(const char** (*get_errmsgs)(int error), uint first,
struct my_err_head **search_meh_pp;
/* Allocate a new header structure. */
- if (! (meh_p= (struct my_err_head*) my_malloc(sizeof(struct my_err_head),
+ if (! (meh_p= (struct my_err_head*) my_malloc(key_memory_my_err_head,
+ sizeof(struct my_err_head),
MYF(MY_WME))))
return 1;
meh_p->get_errmsgs= get_errmsgs;
diff --git a/mysys/my_file.c b/mysys/my_file.c
index 17b2493962a..c2b358f5e1e 100644
--- a/mysys/my_file.c
+++ b/mysys/my_file.c
@@ -102,7 +102,8 @@ uint my_set_max_open_files(uint files)
if (files <= MY_NFILE)
DBUG_RETURN(files);
- if (!(tmp= (struct st_my_file_info*) my_malloc(sizeof(*tmp) * files,
+ if (!(tmp= (struct st_my_file_info*) my_malloc(key_memory_my_file_info,
+ sizeof(*tmp) * files,
MYF(MY_WME))))
DBUG_RETURN(MY_NFILE);
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index ea13dfb6ee4..e7a94da5040 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -64,7 +64,7 @@ FILE *my_fopen(const char *filename, int flags, myf MyFlags)
statistic_increment(my_stream_opened,&THR_LOCK_open);
DBUG_RETURN(fd); /* safeguard */
}
- my_file_info[filedesc].name= (char*) my_strdup(filename,MyFlags);
+ my_file_info[filedesc].name= my_strdup(key_memory_my_file_info, filename, MyFlags);
statistic_increment(my_stream_opened, &THR_LOCK_open);
statistic_increment(my_file_total_opened, &THR_LOCK_open);
my_file_info[filedesc].type= STREAM_BY_FOPEN;
@@ -226,9 +226,10 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
}
else
{
- my_file_info[Filedes].name= my_strdup(name,MyFlags);
+ my_file_info[Filedes].name= my_strdup(key_memory_my_file_info,
+ name, MyFlags);
}
- my_file_info[Filedes].type = STREAM_BY_FDOPEN;
+ my_file_info[Filedes].type= STREAM_BY_FDOPEN;
}
}
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 9ebf63bf6ef..5576c8b5d5d 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -15,11 +15,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
-#include <my_global.h>
+#include <mysys_priv.h>
#include <my_default.h>
#include <m_string.h>
#include <stdlib.h>
-#include <my_sys.h>
#include <mysys_err.h>
#include <my_getopt.h>
#include <errno.h>
@@ -754,7 +753,8 @@ static int setval(const struct my_option *opts, void *value, char *argument,
break;
case GET_STR_ALLOC:
my_free(*((char**) value));
- if (!(*((char**) value)= my_strdup(argument == enabled_my_option ? "" :
+ if (!(*((char**) value)= my_strdup(key_memory_defaults,
+ argument == enabled_my_option ? "" :
argument, MYF(MY_WME))))
{
res= EXIT_OUT_OF_MEMORY;
@@ -1343,7 +1343,7 @@ static void init_one_value(const struct my_option *option, void *variable,
{
char **pstr= (char **) variable;
my_free(*pstr);
- *pstr= my_strdup((char*) (intptr) value, MYF(MY_WME));
+ *pstr= my_strdup(key_memory_defaults, (char*) (intptr) value, MYF(MY_WME));
}
break;
default: /* dummy default to avoid compiler warnings */
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 8715c4a3333..14431b3ae73 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -124,16 +124,17 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
if (!(dirp= opendir(tmp_path)))
goto error;
- if (!(dirh= my_malloc(sizeof(*dirh), MyFlags | MY_ZEROFILL)))
+ if (!(dirh= my_malloc(key_memory_MY_DIR, sizeof(*dirh),
+ MYF(MyFlags | MY_ZEROFILL))))
goto error;
- if (my_init_dynamic_array(&dirh->array, sizeof(FILEINFO),
+ if (my_init_dynamic_array(&dirh->array, key_memory_MY_DIR, sizeof(FILEINFO),
ENTRIES_START_SIZE, ENTRIES_INCREMENT,
MYF(MyFlags)))
goto error;
- init_alloc_root(&dirh->root, "dir", NAMES_START_SIZE, NAMES_START_SIZE,
- MYF(MyFlags));
+ init_alloc_root(key_memory_MY_DIR, &dirh->root, NAMES_START_SIZE,
+ NAMES_START_SIZE, MYF(MyFlags));
dp= (struct dirent*) dirent_tmp;
@@ -227,15 +228,15 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
tmp_file[2]='*';
tmp_file[3]='\0';
- if (!(dirh= my_malloc(sizeof(*dirh), MyFlags | MY_ZEROFILL)))
+ if (!(dirh= my_malloc(PSI_INSTRUMENT_ME, sizeof(*dirh), MyFlags | MY_ZEROFILL)))
goto error;
- if (my_init_dynamic_array(&dirh->array, sizeof(FILEINFO),
+ if (my_init_dynamic_array(&dirh->array, PSI_INSTRUMENT_ME, sizeof(FILEINFO),
ENTRIES_START_SIZE, ENTRIES_INCREMENT,
MYF(MyFlags)))
goto error;
- init_alloc_root(&dirh->root, "dir", NAMES_START_SIZE, NAMES_START_SIZE,
+ init_alloc_root(PSI_INSTRUMENT_ME, &dirh->root, NAMES_START_SIZE, NAMES_START_SIZE,
MYF(MyFlags));
if ((handle=_findfirst(tmp_path,&find)) == -1L)
@@ -341,7 +342,8 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
stat_area, my_flags));
if ((m_used= (stat_area == NULL)))
- if (!(stat_area= (MY_STAT *) my_malloc(sizeof(MY_STAT), my_flags)))
+ if (!(stat_area= (MY_STAT *) my_malloc(key_memory_MY_STAT, sizeof(MY_STAT),
+ my_flags)))
goto error;
#ifndef _WIN32
if (! stat((char *) path, (struct stat *) stat_area) )
diff --git a/mysys/my_likely.c b/mysys/my_likely.c
index c6fca5b7146..5b6c781ad06 100644
--- a/mysys/my_likely.c
+++ b/mysys/my_likely.c
@@ -48,10 +48,9 @@ HASH likely_hash;
void init_my_likely()
{
/* Allocate big enough to avoid malloc calls */
- my_hash_init2(&likely_hash, 10000, &my_charset_bin,
- 1024, 0, 0,
+ my_hash_init2(&likely_hash, 10000, &my_charset_bin, 1024, 0, 0,
(my_hash_get_key) get_likely_key, 0,
- free, HASH_UNIQUE);
+ free, HASH_UNIQUE, PSI_INSTRUMENT_ME);
likely_inited= 1;
pthread_mutex_init(&likely_mutex, MY_MUTEX_INIT_FAST);
}
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c
index d54270a7f20..33880f023a9 100644
--- a/mysys/my_malloc.c
+++ b/mysys/my_malloc.c
@@ -19,35 +19,17 @@
#include "mysys_err.h"
#include <m_string.h>
-/* If we have our own safemalloc (for debugging) */
-#if defined(SAFEMALLOC)
-#define MALLOC_SIZE_AND_FLAG(p,b) sf_malloc_usable_size(p,b)
-#define MALLOC_PREFIX_SIZE 0
-#define MALLOC_STORE_SIZE(a,b,c,d)
-#define MALLOC_FIX_POINTER_FOR_FREE(a) a
-#else
-/*
- * We use double as prefix size as this guarantees the correct
- * alignment on all platforms and will optimize things for
- * memcpy(), memcmp() etc.
- */
-#define MALLOC_PREFIX_SIZE (sizeof(double))
-#define MALLOC_SIZE(p) (*(size_t*) ((char*)(p) - MALLOC_PREFIX_SIZE))
-#define MALLOC_STORE_SIZE(p, type_of_p, size, flag) \
-{\
- *(size_t*) p= (size) | (flag); \
- (p)= (type_of_p) (((char*) (p)) + MALLOC_PREFIX_SIZE); \
-}
-static inline size_t malloc_size_and_flag(void *p, my_bool *is_thread_specific)
+struct my_memory_header
{
- size_t size= MALLOC_SIZE(p);
- *is_thread_specific= (size & 1);
- return size & ~ (ulonglong) 1;
-}
-#define MALLOC_SIZE_AND_FLAG(p,b) malloc_size_and_flag(p, b);
-#define MALLOC_FIX_POINTER_FOR_FREE(p) (((char*) (p)) - MALLOC_PREFIX_SIZE)
-#endif /* SAFEMALLOC */
+ PSI_thread *m_owner;
+ size_t m_size;
+ PSI_memory_key m_key;
+};
+typedef struct my_memory_header my_memory_header;
+#define HEADER_SIZE 24
+#define USER_TO_HEADER(P) ((my_memory_header*)((char *)(P) - HEADER_SIZE))
+#define HEADER_TO_USER(P) ((char*)(P) + HEADER_SIZE)
/**
Inform application that memory usage has changed
@@ -82,12 +64,13 @@ void set_malloc_size_cb(MALLOC_SIZE_CB func)
@return A pointer to the allocated memory block, or NULL on failure.
*/
-void *my_malloc(size_t size, myf my_flags)
+void *my_malloc(PSI_memory_key key, size_t size, myf my_flags)
{
- void* point;
+ my_memory_header *mh;
+ void *point;
DBUG_ENTER("my_malloc");
- DBUG_PRINT("my",("size: %lu my_flags: %lu", (ulong) size, my_flags));
- compile_time_assert(sizeof(size_t) <= sizeof(double));
+ DBUG_PRINT("my",("size: %zu flags: %lu", size, my_flags));
+ compile_time_assert(sizeof(my_memory_header) <= HEADER_SIZE);
if (!(my_flags & (MY_WME | MY_FAE)))
my_flags|= my_global_flags;
@@ -96,11 +79,15 @@ void *my_malloc(size_t size, myf my_flags)
if (!size)
size=1;
- /* We have to align size to be able to store markers in it */
+ /* We have to align size as we store MY_THREAD_SPECIFIC flag in the LSB */
size= ALIGN_SIZE(size);
- point= sf_malloc(size + MALLOC_PREFIX_SIZE, my_flags);
- if (point == NULL)
+ if (DBUG_EVALUATE_IF("simulate_out_of_memory", 1, 0))
+ mh= NULL;
+ else
+ mh= (my_memory_header*) sf_malloc(size + HEADER_SIZE, my_flags);
+
+ if (mh == NULL)
{
my_errno=errno;
if (my_flags & MY_FAE)
@@ -109,22 +96,19 @@ void *my_malloc(size_t size, myf my_flags)
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_ERROR_LOG+ME_FATAL),size);
if (my_flags & MY_FAE)
abort();
+ point= NULL;
}
else
{
- MALLOC_STORE_SIZE(point, void*, size,
- MY_TEST(my_flags & MY_THREAD_SPECIFIC));
- update_malloc_size(size + MALLOC_PREFIX_SIZE,
- MY_TEST(my_flags & MY_THREAD_SPECIFIC));
- TRASH_ALLOC(point, size);
- DBUG_EXECUTE_IF("simulate_out_of_memory",
- {
- /* my_free() handles memory accounting */
- my_free(point);
- point= NULL;
- });
+ int flag= MY_TEST(my_flags & MY_THREAD_SPECIFIC);
+ mh->m_size= size | flag;
+ mh->m_key= PSI_CALL_memory_alloc(key, size, & mh->m_owner);
+ update_malloc_size(size + HEADER_SIZE, flag);
+ point= HEADER_TO_USER(mh);
if (my_flags & MY_ZEROFILL)
bzero(point, size);
+ else
+ TRASH_ALLOC(point, size);
}
DBUG_PRINT("exit",("ptr: %p", point));
DBUG_RETURN(point);
@@ -134,62 +118,57 @@ void *my_malloc(size_t size, myf my_flags)
/**
@brief wrapper around realloc()
- @param oldpoint pointer to currently allocated area
+ @param old_point pointer to currently allocated area
@param size new size requested, must be >0
@param my_flags flags
@note if size==0 realloc() may return NULL; my_realloc() treats this as an
error which is not the intention of realloc()
*/
-void *my_realloc(void *oldpoint, size_t size, myf my_flags)
+void *my_realloc(PSI_memory_key key, void *old_point, size_t size, myf my_flags)
{
+ my_memory_header *old_mh, *mh;
void *point;
size_t old_size;
my_bool old_flags;
DBUG_ENTER("my_realloc");
- DBUG_PRINT("my",("ptr: %p size: %lu my_flags: %lu", oldpoint,
- (ulong) size, my_flags));
+ DBUG_PRINT("my",("ptr: %p size: %zu flags: %lu", old_point, size, my_flags));
DBUG_ASSERT(size > 0);
- if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
- DBUG_RETURN(my_malloc(size, my_flags));
+ if (!old_point && (my_flags & MY_ALLOW_ZERO_PTR))
+ DBUG_RETURN(my_malloc(key, size, my_flags));
+
+ old_mh= USER_TO_HEADER(old_point);
+ old_size= old_mh->m_size & ~1;
+ old_flags= old_mh->m_size & 1;
+
+ DBUG_ASSERT(old_mh->m_key == key || old_mh->m_key == PSI_NOT_INSTRUMENTED);
+ DBUG_ASSERT(old_flags == MY_TEST(my_flags & MY_THREAD_SPECIFIC));
size= ALIGN_SIZE(size);
- old_size= MALLOC_SIZE_AND_FLAG(oldpoint, &old_flags);
- /*
- Test that the new and old area are the same, if not MY_THREAD_MOVE is
- given
- */
- DBUG_ASSERT((MY_TEST(my_flags & MY_THREAD_SPECIFIC) == old_flags) ||
- (my_flags & MY_THREAD_MOVE));
- if ((point= sf_realloc(MALLOC_FIX_POINTER_FOR_FREE(oldpoint),
- size + MALLOC_PREFIX_SIZE, my_flags)) == NULL)
+ mh= sf_realloc(old_mh, size + HEADER_SIZE, my_flags);
+
+ if (mh == NULL)
{
+ if (size < old_size)
+ DBUG_RETURN(old_point);
+ my_errno=errno;
if (my_flags & MY_FREE_ON_ERROR)
{
/* my_free will take care of size accounting */
- my_free(oldpoint);
- oldpoint= 0;
+ my_free(old_point);
+ old_point= 0;
}
- if (my_flags & MY_HOLD_ON_ERROR)
- DBUG_RETURN(oldpoint);
- my_errno=errno;
if (my_flags & (MY_FAE+MY_WME))
my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_FATAL), size);
+ point= NULL;
}
else
{
- MALLOC_STORE_SIZE(point, void*, size,
- MY_TEST(my_flags & MY_THREAD_SPECIFIC));
- if (MY_TEST(my_flags & MY_THREAD_SPECIFIC) != old_flags)
- {
- /* memory moved between system and thread specific */
- update_malloc_size(-(longlong) old_size - MALLOC_PREFIX_SIZE, old_flags);
- update_malloc_size((longlong) size + MALLOC_PREFIX_SIZE,
- MY_TEST(my_flags & MY_THREAD_SPECIFIC));
- }
- else
- update_malloc_size((longlong)size - (longlong)old_size, old_flags);
+ mh->m_size= size | old_flags;
+ mh->m_key= PSI_CALL_memory_realloc(key, old_size, size, & mh->m_owner);
+ update_malloc_size((longlong)size - (longlong)old_size, old_flags);
+ point= HEADER_TO_USER(mh);
}
DBUG_PRINT("exit",("ptr: %p", point));
@@ -204,56 +183,63 @@ void *my_realloc(void *oldpoint, size_t size, myf my_flags)
*/
void my_free(void *ptr)
{
+ my_memory_header *mh;
+ size_t old_size;
+ my_bool old_flags;
DBUG_ENTER("my_free");
DBUG_PRINT("my",("ptr: %p", ptr));
- if (ptr)
- {
- size_t old_size;
- my_bool old_flags;
- old_size= MALLOC_SIZE_AND_FLAG(ptr, &old_flags);
- update_malloc_size(- (longlong) old_size - MALLOC_PREFIX_SIZE, old_flags);
+
+ if (ptr == NULL)
+ DBUG_VOID_RETURN;
+
+ mh= USER_TO_HEADER(ptr);
+ old_size= mh->m_size & ~1;
+ old_flags= mh->m_size & 1;
+ PSI_CALL_memory_free(mh->m_key, old_size, mh->m_owner);
+
+ update_malloc_size(- (longlong) old_size - HEADER_SIZE, old_flags);
+
#ifndef SAFEMALLOC
- /*
- Trash memory if not safemalloc. We don't have to do this if safemalloc
- is used as safemalloc will also do trashing
- */
- TRASH_FREE(ptr, old_size);
+ /*
+ Trash memory if not safemalloc. We don't have to do this if safemalloc
+ is used as safemalloc will also do trashing
+ */
+ TRASH_FREE(ptr, old_size);
#endif
- sf_free(MALLOC_FIX_POINTER_FOR_FREE(ptr));
- }
+ sf_free(mh);
DBUG_VOID_RETURN;
}
-void *my_memdup(const void *from, size_t length, myf my_flags)
+void *my_memdup(PSI_memory_key key, const void *from, size_t length, myf my_flags)
{
void *ptr;
DBUG_ENTER("my_memdup");
- if ((ptr= my_malloc(length,my_flags)) != 0)
+ if ((ptr= my_malloc(key, length,my_flags)) != 0)
memcpy(ptr, from, length);
DBUG_RETURN(ptr);
}
-char *my_strdup(const char *from, myf my_flags)
+char *my_strdup(PSI_memory_key key, const char *from, myf my_flags)
{
char *ptr;
size_t length= strlen(from)+1;
DBUG_ENTER("my_strdup");
- if ((ptr= (char*) my_malloc(length, my_flags)))
+ if ((ptr= (char*) my_malloc(key, length, my_flags)))
memcpy(ptr, from, length);
DBUG_RETURN(ptr);
}
-char *my_strndup(const char *from, size_t length, myf my_flags)
+char *my_strndup(PSI_memory_key key, const char *from, size_t length, myf my_flags)
{
char *ptr;
DBUG_ENTER("my_strndup");
- if ((ptr= (char*) my_malloc(length+1, my_flags)))
+ if ((ptr= (char*) my_malloc(key, length+1, my_flags)))
{
memcpy(ptr, from, length);
ptr[length]= 0;
diff --git a/mysys/my_open.c b/mysys/my_open.c
index 04324d13d71..a6cbffa0806 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -136,7 +136,7 @@ File my_register_filename(File fd, const char *FileName, enum file_type
thread_safe_increment32(&my_file_opened);
if ((uint) fd >= my_file_limit)
DBUG_RETURN(fd);
- my_file_info[fd].name = (char*) my_strdup(FileName, MyFlags);
+ my_file_info[fd].name = my_strdup(key_memory_my_file_info, FileName, MyFlags);
statistic_increment(my_file_total_opened,&THR_LOCK_open);
my_file_info[fd].type = type_of_file;
DBUG_PRINT("exit",("fd: %d",fd));
diff --git a/mysys/my_safehash.c b/mysys/my_safehash.c
index 7555f73fb30..39b73d603ef 100644
--- a/mysys/my_safehash.c
+++ b/mysys/my_safehash.c
@@ -102,7 +102,8 @@ my_bool safe_hash_init(SAFE_HASH *hash, uint elements,
DBUG_ENTER("safe_hash_init");
if (my_hash_init(&hash->hash, &my_charset_bin, elements,
0, 0, (my_hash_get_key) safe_hash_entry_get,
- (void (*)(void*)) safe_hash_entry_free, 0))
+ (void (*)(void*)) safe_hash_entry_free, 0,
+ key_memory_SAFE_HASH_ENTRY))
{
hash->default_value= 0;
DBUG_RETURN(1);
@@ -224,7 +225,8 @@ my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
}
else
{
- if (!(entry= (SAFE_HASH_ENTRY *) my_malloc(sizeof(*entry) + length,
+ if (!(entry= (SAFE_HASH_ENTRY *) my_malloc(key_memory_SAFE_HASH_ENTRY,
+ sizeof(*entry) + length,
MYF(MY_WME))))
{
error= 1;
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 7474b789839..a18b7adef61 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -24,6 +24,36 @@
#include "my_alarm.h"
+PSI_memory_key key_memory_DYNAMIC_STRING;
+PSI_memory_key key_memory_IO_CACHE;
+PSI_memory_key key_memory_KEY_CACHE;
+PSI_memory_key key_memory_LIST;
+PSI_memory_key key_memory_MY_BITMAP_bitmap;
+PSI_memory_key key_memory_MY_DIR;
+PSI_memory_key key_memory_MY_STAT;
+PSI_memory_key key_memory_MY_TMPDIR_full_list;
+PSI_memory_key key_memory_QUEUE;
+PSI_memory_key key_memory_SAFE_HASH_ENTRY;
+PSI_memory_key key_memory_THD_ALARM;
+PSI_memory_key key_memory_TREE;
+PSI_memory_key key_memory_charset_file;
+PSI_memory_key key_memory_charset_loader;
+PSI_memory_key key_memory_defaults;
+PSI_memory_key key_memory_lf_dynarray;
+PSI_memory_key key_memory_lf_node;
+PSI_memory_key key_memory_lf_slist;
+PSI_memory_key key_memory_max_alloca;
+PSI_memory_key key_memory_my_compress_alloc;
+PSI_memory_key key_memory_my_err_head;
+PSI_memory_key key_memory_my_file_info;
+PSI_memory_key key_memory_pack_frm;
+
+#ifdef _WIN32
+PSI_memory_key key_memory_win_SECURITY_ATTRIBUTES;
+PSI_memory_key key_memory_win_PACL;
+PSI_memory_key key_memory_win_IP_ADAPTER_ADDRESSES;
+#endif /* _WIN32 */
+
/* from my_init */
char *home_dir=0;
char *mysql_data_home= (char*) ".";
diff --git a/mysys/my_windac.c b/mysys/my_windac.c
index 9a2686a44f4..d53f34f20e7 100644
--- a/mysys/my_windac.c
+++ b/mysys/my_windac.c
@@ -96,7 +96,7 @@ int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
}
GetTokenInformation(htoken, TokenUser, 0, 0, &owner_token_length);
- if (! my_multi_malloc(MYF(MY_WME),
+ if (! my_multi_malloc(MYF(MY_WME), PSI_INSTRUMENT_ME,
&sa, ALIGN_SIZE(sizeof(SECURITY_ATTRIBUTES)) +
sizeof(My_security_attr),
&sd, sizeof(SECURITY_DESCRIPTOR),
@@ -126,7 +126,7 @@ int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
GetLengthSid(everyone_sid) + GetLengthSid(owner_sid);
/* Create an ACL */
- if (! (dacl= (PACL) my_malloc(dacl_length, MYF(MY_ZEROFILL|MY_WME))))
+ if (! (dacl= (PACL) my_malloc(PSI_INSTRUMENT_ME, dacl_length, MYF(MY_ZEROFILL|MY_WME))))
{
*perror= "Failed to allocate memory for DACL";
goto error;
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index 0fa6a4c553f..240d66a3b51 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -64,6 +64,36 @@ extern PSI_rwlock_key key_SAFEHASH_mutex;
extern PSI_stage_info stage_waiting_for_table_level_lock;
+/* These keys are always defined. */
+
+extern PSI_memory_key key_memory_DYNAMIC_STRING;
+extern PSI_memory_key key_memory_IO_CACHE;
+extern PSI_memory_key key_memory_KEY_CACHE;
+extern PSI_memory_key key_memory_LIST;
+extern PSI_memory_key key_memory_MY_BITMAP_bitmap;
+extern PSI_memory_key key_memory_MY_DIR;
+extern PSI_memory_key key_memory_MY_STAT;
+extern PSI_memory_key key_memory_MY_TMPDIR_full_list;
+extern PSI_memory_key key_memory_QUEUE;
+extern PSI_memory_key key_memory_SAFE_HASH_ENTRY;
+extern PSI_memory_key key_memory_TREE;
+extern PSI_memory_key key_memory_charset_file;
+extern PSI_memory_key key_memory_charset_loader;
+extern PSI_memory_key key_memory_defaults;
+extern PSI_memory_key key_memory_lf_dynarray;
+extern PSI_memory_key key_memory_lf_node;
+extern PSI_memory_key key_memory_lf_slist;
+extern PSI_memory_key key_memory_my_compress_alloc;
+extern PSI_memory_key key_memory_my_err_head;
+extern PSI_memory_key key_memory_my_file_info;
+extern PSI_memory_key key_memory_pack_frm;
+
+#ifdef _WIN32
+extern PSI_memory_key key_memory_win_SECURITY_ATTRIBUTES;
+extern PSI_memory_key key_memory_win_PACL;
+extern PSI_memory_key key_memory_win_IP_ADAPTER_ADDRESSES;
+#endif
+
extern mysql_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache;
extern mysql_mutex_t THR_LOCK_lock, THR_LOCK_net;
extern mysql_mutex_t THR_LOCK_charset;
diff --git a/mysys/queues.c b/mysys/queues.c
index 5d09ce2063f..aac70a4825d 100644
--- a/mysys/queues.c
+++ b/mysys/queues.c
@@ -76,7 +76,8 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
{
DBUG_ENTER("init_queue");
- if ((queue->root= (uchar **) my_malloc((max_elements + 1) * sizeof(void*),
+ if ((queue->root= (uchar **) my_malloc(key_memory_QUEUE,
+ (max_elements + 1) * sizeof(void*),
MYF(MY_WME))) == 0)
DBUG_RETURN(1);
queue->elements= 0;
@@ -148,7 +149,7 @@ int resize_queue(QUEUE *queue, uint max_elements)
DBUG_ENTER("resize_queue");
if (queue->max_elements == max_elements)
DBUG_RETURN(0);
- if ((new_root= (uchar **) my_realloc((void *)queue->root,
+ if ((new_root= (uchar **) my_realloc(key_memory_QUEUE, (void *)queue->root,
(max_elements + 1)* sizeof(void*),
MYF(MY_WME))) == 0)
DBUG_RETURN(1);
diff --git a/mysys/string.c b/mysys/string.c
index 7c56b95af25..b346393d91e 100644
--- a/mysys/string.c
+++ b/mysys/string.c
@@ -36,7 +36,8 @@ my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
if (!init_alloc)
init_alloc=alloc_increment;
- if (!(str->str=(char*) my_malloc(init_alloc,MYF(MY_WME))))
+ if (!(str->str=(char*) my_malloc(key_memory_DYNAMIC_STRING,
+ init_alloc, MYF(MY_WME))))
DBUG_RETURN(TRUE);
str->length=length-1;
if (init_str)
@@ -58,7 +59,8 @@ my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str)
str->alloc_increment;
if (!str->max_length)
str->max_length=str->alloc_increment;
- if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME))))
+ if (!(str->str=(char*) my_realloc(key_memory_DYNAMIC_STRING,
+ str->str, str->max_length, MYF(MY_WME))))
DBUG_RETURN(TRUE);
}
if (init_str)
@@ -81,7 +83,8 @@ my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size)
{
str->max_length=((str->length + additional_size+str->alloc_increment-1)/
str->alloc_increment)*str->alloc_increment;
- if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME))))
+ if (!(str->str=(char*) my_realloc(key_memory_DYNAMIC_STRING, str->str,
+ str->max_length, MYF(MY_WME))))
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
@@ -104,7 +107,8 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
size_t new_length=(str->length+length+str->alloc_increment)/
str->alloc_increment;
new_length*=str->alloc_increment;
- if (!(new_ptr=(char*) my_realloc(str->str,new_length,MYF(MY_WME))))
+ if (!(new_ptr=(char*) my_realloc(key_memory_DYNAMIC_STRING, str->str,
+ new_length, MYF(MY_WME))))
DBUG_RETURN(TRUE);
str->str=new_ptr;
str->max_length=new_length;
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 9bc70b283cb..92a471075c6 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -185,7 +185,8 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
now= my_time(0);
if (!alarm_data)
{
- if (!(alarm_data=(ALARM*) my_malloc(sizeof(ALARM),MYF(MY_WME))))
+ if (!(alarm_data=(ALARM*) my_malloc(PSI_INSTRUMENT_ME, sizeof(ALARM),
+ MYF(MY_WME))))
goto abort_no_unlock;
alarm_data->malloced= 1;
}
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 568ed3ecb46..1b0ad56a6d5 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -156,7 +156,7 @@ static inline void remove_from_active_list(safe_mutex_t *mp)
static int safe_mutex_lazy_init_deadlock_detection(safe_mutex_t *mp)
{
- if (!my_multi_malloc(MY_FAE | MY_WME,
+ if (!my_multi_malloc(PSI_NOT_INSTRUMENTED, MY_FAE | MY_WME,
&mp->locked_mutex, sizeof(*mp->locked_mutex),
&mp->used_mutex, sizeof(*mp->used_mutex), NullS))
{
@@ -169,16 +169,12 @@ static int safe_mutex_lazy_init_deadlock_detection(safe_mutex_t *mp)
pthread_mutex_lock(&THR_LOCK_mutex);
mp->id= ++safe_mutex_id;
pthread_mutex_unlock(&THR_LOCK_mutex);
- my_hash_init2(mp->locked_mutex, 64, &my_charset_bin,
- 128,
- offsetof(safe_mutex_deadlock_t, id),
- sizeof(mp->id),
- 0, 0, 0, HASH_UNIQUE);
- my_hash_init2(mp->used_mutex, 64, &my_charset_bin,
- 128,
- offsetof(safe_mutex_t, id),
- sizeof(mp->id),
- 0, 0, 0, HASH_UNIQUE);
+ my_hash_init2(mp->locked_mutex, 64, &my_charset_bin, 128,
+ offsetof(safe_mutex_deadlock_t, id), sizeof(mp->id), 0, 0, 0,
+ HASH_UNIQUE, PSI_NOT_INSTRUMENTED);
+ my_hash_init2(mp->used_mutex, 64, &my_charset_bin, 128,
+ offsetof(safe_mutex_t, id), sizeof(mp->id), 0, 0, 0,
+ HASH_UNIQUE, PSI_NOT_INSTRUMENTED);
return 0;
}
@@ -341,7 +337,7 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file,
safe_mutex_t *mutex;
/* Create object to store mutex info */
- if (!(deadlock= my_malloc(sizeof(*deadlock),
+ if (!(deadlock= my_malloc(PSI_NOT_INSTRUMENTED, sizeof(*deadlock),
MYF(MY_ZEROFILL | MY_WME | MY_FAE))))
goto abort_loop;
deadlock->name= mp->name;
diff --git a/mysys/tree.c b/mysys/tree.c
index 8cae30e2d3e..cd44f779e6f 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -128,7 +128,7 @@ void init_tree(TREE *tree, size_t default_alloc_size, size_t memory_limit,
}
if (!(tree->with_delete= MY_TEST(my_flags & MY_TREE_WITH_DELETE)))
{
- init_alloc_root(&tree->mem_root, "tree", default_alloc_size, 0,
+ init_alloc_root(key_memory_TREE, &tree->mem_root, default_alloc_size, 0,
MYF(my_flags));
tree->mem_root.min_malloc= sizeof(TREE_ELEMENT)+tree->size_of_element;
}
@@ -275,7 +275,7 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size,
key_size+=tree->size_of_element;
if (tree->with_delete)
- element=(TREE_ELEMENT *) my_malloc(alloc_size,
+ element=(TREE_ELEMENT *) my_malloc(key_memory_TREE, alloc_size,
MYF(tree->my_flags | MY_WME));
else
element=(TREE_ELEMENT *) alloc_root(&tree->mem_root,alloc_size);
diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c
index 4564059b31a..a930e1d203b 100644
--- a/mysys/waiting_threads.c
+++ b/mysys/waiting_threads.c
@@ -394,7 +394,8 @@ static void wt_resource_create(uchar *arg)
bzero(rc, sizeof(*rc));
rc_rwlock_init(rc);
mysql_cond_init(key_WT_RESOURCE_cond, &rc->cond, 0);
- my_init_dynamic_array(&rc->owners, sizeof(WT_THD *), 0, 5, MYF(0));
+ my_init_dynamic_array(&rc->owners, PSI_INSTRUMENT_ME,
+ sizeof(WT_THD *), 0, 5, MYF(0));
DBUG_VOID_RETURN;
}
@@ -507,7 +508,8 @@ void wt_thd_lazy_init(WT_THD *thd, const ulong *ds, const ulong *ts,
thd->deadlock_search_depth_long= dl;
thd->timeout_long= tl;
/* dynamic array is also initialized lazily - without memory allocations */
- my_init_dynamic_array(&thd->my_resources, sizeof(WT_RESOURCE *), 0, 5, MYF(0));
+ my_init_dynamic_array(&thd->my_resources, PSI_INSTRUMENT_ME,
+ sizeof(WT_RESOURCE *), 0, 5, MYF(0));
#ifndef DBUG_OFF
thd->name= my_thread_name();
#endif
diff --git a/plugin/daemon_example/daemon_example.cc b/plugin/daemon_example/daemon_example.cc
index 87f48a1fa69..50026e92be1 100644
--- a/plugin/daemon_example/daemon_example.cc
+++ b/plugin/daemon_example/daemon_example.cc
@@ -98,7 +98,7 @@ static int daemon_example_plugin_init(void *p __attribute__ ((unused)))
struct st_plugin_int *plugin= (struct st_plugin_int *)p;
con= (struct mysql_heartbeat_context *)
- my_malloc(sizeof(struct mysql_heartbeat_context), MYF(0));
+ my_malloc(PSI_NOT_INSTRUMENTED, sizeof(struct mysql_heartbeat_context), MYF(0));
fn_format(heartbeat_filename, "mysql-heartbeat", "", ".log",
MY_REPLACE_EXT | MY_UNPACK_FILENAME);
diff --git a/plugin/feedback/feedback.cc b/plugin/feedback/feedback.cc
index b0fbc1abcde..03cc4ab465a 100644
--- a/plugin/feedback/feedback.cc
+++ b/plugin/feedback/feedback.cc
@@ -280,7 +280,7 @@ static int init(void *p)
if (*s == ' ')
url_count++;
- urls= (Url **)my_malloc(url_count*sizeof(Url*), MYF(MY_WME));
+ urls= (Url **)my_malloc(PSI_INSTRUMENT_ME, url_count*sizeof(Url*), MYF(MY_WME));
if (!urls)
return 1;
diff --git a/plugin/feedback/url_base.cc b/plugin/feedback/url_base.cc
index 21661079c98..1ba21306bdf 100644
--- a/plugin/feedback/url_base.cc
+++ b/plugin/feedback/url_base.cc
@@ -27,7 +27,7 @@ Url* http_create(const char *url, size_t url_length);
*/
Url* Url::create(const char *url, size_t url_length)
{
- url= my_strndup(url, url_length, MYF(MY_WME));
+ url= my_strndup(PSI_INSTRUMENT_ME, url, url_length, MYF(MY_WME));
if (!url)
return NULL;
@@ -88,8 +88,8 @@ int Url::parse_proxy_server(const char *proxy_server, size_t proxy_length,
port->length= 2;
}
- host->str= my_strndup(host->str, host->length, MYF(MY_WME));
- port->str= my_strndup(port->str, port->length, MYF(MY_WME));
+ host->str= my_strndup(PSI_INSTRUMENT_ME, host->str, host->length, MYF(MY_WME));
+ port->str= my_strndup(PSI_INSTRUMENT_ME, port->str, port->length, MYF(MY_WME));
return 0;
}
diff --git a/plugin/feedback/url_http.cc b/plugin/feedback/url_http.cc
index db05adebdd2..98116dd04f1 100644
--- a/plugin/feedback/url_http.cc
+++ b/plugin/feedback/url_http.cc
@@ -143,9 +143,9 @@ Url* http_create(const char *url, size_t url_length)
if (!host.length || !port.length || path.str[0] != '/')
return NULL;
- host.str= my_strndup(host.str, host.length, MYF(MY_WME));
- port.str= my_strndup(port.str, port.length, MYF(MY_WME));
- path.str= my_strndup(path.str, path.length, MYF(MY_WME));
+ host.str= my_strndup(PSI_INSTRUMENT_ME, host.str, host.length, MYF(MY_WME));
+ port.str= my_strndup(PSI_INSTRUMENT_ME, port.str, port.length, MYF(MY_WME));
+ path.str= my_strndup(PSI_INSTRUMENT_ME, path.str, path.length, MYF(MY_WME));
if (!host.str || !port.str || !path.str)
{
diff --git a/plugin/handler_socket/handlersocket/database.cpp b/plugin/handler_socket/handlersocket/database.cpp
index 52ea8f2a8c4..8f172a95151 100644
--- a/plugin/handler_socket/handlersocket/database.cpp
+++ b/plugin/handler_socket/handlersocket/database.cpp
@@ -298,7 +298,7 @@ dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag)
thd->options |= OPTION_BIN_LOG;
#endif
safeFree((char*) thd->db.str);
- thd->db.str= my_strdup("handlersocket", MYF(0));
+ thd->db.str= my_strdup(PSI_NOT_INSTRUMENTED, "handlersocket", MYF(0));
thd->db.length= sizeof("handlersocket")-1;
}
thd->variables.option_bits |= OPTION_TABLE_LOCK;
diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c
index 609cf0f1ac1..4ec58249d68 100644
--- a/plugin/server_audit/server_audit.c
+++ b/plugin/server_audit/server_audit.c
@@ -124,7 +124,7 @@ static char *default_home= (char *)".";
#define my_rename(A, B, C) loc_rename(A, B)
#define my_tell(A, B) loc_tell(A)
#define my_write(A, B, C, D) loc_write(A, B, C)
-#define my_malloc(A, B) malloc(A)
+#define my_malloc(A, B, C) malloc(B)
#define my_free(A) free(A)
#ifdef my_errno
#undef my_errno
diff --git a/sql-common/client.c b/sql-common/client.c
index 98173224f76..a8c69c797b0 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -112,6 +112,52 @@ typedef enum {
#define native_password_plugin_name "mysql_native_password"
#define old_password_plugin_name "mysql_old_password"
+PSI_memory_key key_memory_mysql_options;
+PSI_memory_key key_memory_MYSQL_DATA;
+PSI_memory_key key_memory_MYSQL;
+PSI_memory_key key_memory_MYSQL_RES;
+PSI_memory_key key_memory_MYSQL_ROW;
+PSI_memory_key key_memory_MYSQL_state_change_info;
+PSI_memory_key key_memory_MYSQL_HANDSHAKE;
+
+#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
+PSI_memory_key key_memory_create_shared_memory;
+#endif /* _WIN32 && ! EMBEDDED_LIBRARY */
+
+#ifdef HAVE_PSI_INTERFACE
+/*
+ This code is common to the client and server,
+ and also used in the server when server A connects to server B,
+ for example with replication.
+ Therefore, the code is also instrumented.
+*/
+
+static PSI_memory_info all_client_memory[]=
+{
+#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
+ { &key_memory_create_shared_memory, "create_shared_memory", 0},
+#endif /* _WIN32 && ! EMBEDDED_LIBRARY */
+
+ { &key_memory_mysql_options, "mysql_options", 0},
+ { &key_memory_MYSQL_DATA, "MYSQL_DATA", 0},
+ { &key_memory_MYSQL, "MYSQL", 0},
+ { &key_memory_MYSQL_RES, "MYSQL_RES", 0},
+ { &key_memory_MYSQL_ROW, "MYSQL_ROW", 0},
+ { &key_memory_MYSQL_state_change_info, "MYSQL_STATE_CHANGE_INFO", 0},
+ { &key_memory_MYSQL_HANDSHAKE, "MYSQL_HANDSHAKE", 0}
+};
+
+void init_client_psi_keys(void)
+{
+ const char *category= "client";
+ int count;
+
+ count= array_elements(all_client_memory);
+ mysql_memory_register(category, all_client_memory, count);
+}
+
+#endif /* HAVE_PSI_INTERFACE */
+
uint mariadb_deinitialize_ssl= 1;
uint mysql_port=0;
char *mysql_unix_port= 0;
@@ -491,7 +537,7 @@ void free_old_query(MYSQL *mysql)
if (mysql->fields)
free_root(&mysql->field_alloc,MYF(0));
/* Assume rowlength < 8192 */
- init_alloc_root(&mysql->field_alloc, "fields", 8192, 0,
+ init_alloc_root(PSI_INSTRUMENT_ME, &mysql->field_alloc, 8192, 0,
MYF(mysql->options.use_thread_specific_memory ?
MY_THREAD_SPECIFIC : 0));
mysql->fields= 0;
@@ -753,6 +799,11 @@ enum option_id {
OPT_keep_this_one_last
};
+static char *opt_strdup(const char *from, myf my_flags)
+{
+ return my_strdup(key_memory_mysql_options, from, my_flags);
+}
+
static TYPELIB option_types={array_elements(default_options)-1,
"options",default_options, NULL};
@@ -762,12 +813,14 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
if (!options->init_commands)
{
- options->init_commands= (DYNAMIC_ARRAY*)my_malloc(sizeof(DYNAMIC_ARRAY),
+ options->init_commands= (DYNAMIC_ARRAY*)my_malloc(key_memory_mysql_options,
+ sizeof(DYNAMIC_ARRAY),
MYF(MY_WME));
- my_init_dynamic_array(options->init_commands,sizeof(char*),5, 5, MYF(0));
+ my_init_dynamic_array(options->init_commands, key_memory_mysql_options,
+ sizeof(char*),5, 5, MYF(0));
}
- if (!(tmp= my_strdup(cmd,MYF(MY_WME))) ||
+ if (!(tmp= opt_strdup(cmd,MYF(MY_WME))) ||
insert_dynamic(options->init_commands, &tmp))
{
my_free(tmp);
@@ -780,7 +833,8 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
#define ALLOCATE_EXTENSIONS(OPTS) \
(OPTS)->extension= (struct st_mysql_options_extention *) \
- my_malloc(sizeof(struct st_mysql_options_extention), \
+ my_malloc(key_memory_mysql_options, \
+ sizeof(struct st_mysql_options_extention), \
MYF(MY_WME | MY_ZEROFILL)) \
@@ -802,7 +856,7 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
} while (0)
#define EXTENSION_SET_STRING(OPTS, X, STR) \
- EXTENSION_SET_STRING_X(OPTS, X, STR, my_strdup)
+ EXTENSION_SET_STRING_X(OPTS, X, STR, opt_strdup)
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
@@ -816,7 +870,7 @@ static char *set_ssl_option_unpack_path(const char *arg, myf flags)
{
char buff[FN_REFLEN + 1];
unpack_filename(buff, (char *)arg);
- return my_strdup(buff, flags);
+ return opt_strdup(buff, flags);
}
#else
@@ -824,8 +878,8 @@ static char *set_ssl_option_unpack_path(const char *arg, myf flags)
#define EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, dup) do { } while(0)
#endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */
-#define SET_SSL_OPTION(OPTS, opt_var,arg) SET_SSL_OPTION_X(OPTS, opt_var, arg, my_strdup)
-#define EXTENSION_SET_SSL_STRING(OPTS, X, STR) EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, my_strdup)
+#define SET_SSL_OPTION(OPTS, opt_var,arg) SET_SSL_OPTION_X(OPTS, opt_var, arg, opt_strdup)
+#define EXTENSION_SET_SSL_STRING(OPTS, X, STR) EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, opt_strdup)
#define SET_SSL_PATH_OPTION(OPTS, opt_var,arg) SET_SSL_OPTION_X(OPTS, opt_var, arg, set_ssl_option_unpack_path)
#define EXTENSION_SET_SSL_PATH_STRING(OPTS, X, STR) EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, set_ssl_option_unpack_path)
@@ -876,7 +930,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
if (opt_arg)
{
my_free(options->unix_socket);
- options->unix_socket=my_strdup(opt_arg,MYF(MY_WME));
+ options->unix_socket=opt_strdup(opt_arg,MYF(MY_WME));
}
break;
case OPT_compress:
@@ -887,7 +941,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
if (opt_arg)
{
my_free(options->password);
- options->password=my_strdup(opt_arg,MYF(MY_WME));
+ options->password=opt_strdup(opt_arg,MYF(MY_WME));
}
break;
case OPT_pipe:
@@ -902,7 +956,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
if (opt_arg)
{
my_free(options->user);
- options->user=my_strdup(opt_arg,MYF(MY_WME));
+ options->user=opt_strdup(opt_arg,MYF(MY_WME));
}
break;
case OPT_init_command:
@@ -912,14 +966,14 @@ void mysql_read_default_options(struct st_mysql_options *options,
if (opt_arg)
{
my_free(options->host);
- options->host=my_strdup(opt_arg,MYF(MY_WME));
+ options->host=opt_strdup(opt_arg,MYF(MY_WME));
}
break;
case OPT_database:
if (opt_arg)
{
my_free(options->db);
- options->db=my_strdup(opt_arg,MYF(MY_WME));
+ options->db=opt_strdup(opt_arg,MYF(MY_WME));
}
break;
case OPT_debug:
@@ -953,11 +1007,11 @@ void mysql_read_default_options(struct st_mysql_options *options,
break;
case OPT_character_sets_dir:
my_free(options->charset_dir);
- options->charset_dir = my_strdup(opt_arg, MYF(MY_WME));
+ options->charset_dir = opt_strdup(opt_arg, MYF(MY_WME));
break;
case OPT_default_character_set:
my_free(options->charset_name);
- options->charset_name = my_strdup(opt_arg, MYF(MY_WME));
+ options->charset_name = opt_strdup(opt_arg, MYF(MY_WME));
break;
case OPT_interactive_timeout:
options->client_flag|= CLIENT_INTERACTIVE;
@@ -1201,14 +1255,14 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
if ((pkt_len= cli_safe_read(mysql)) == packet_error)
DBUG_RETURN(0);
if (pkt_len == 0) DBUG_RETURN(0);
- if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
+ if (!(result=(MYSQL_DATA*) my_malloc(key_memory_MYSQL_DATA, sizeof(MYSQL_DATA),
MYF(MY_WME | MY_ZEROFILL))))
{
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
DBUG_RETURN(0);
}
/* Assume rowlength < 8192 */
- init_alloc_root(&result->alloc, "result", 8192, 0,
+ init_alloc_root(key_memory_MYSQL_DATA, &result->alloc, 8192, 0,
MYF(mysql->options.use_thread_specific_memory ?
MY_THREAD_SPECIFIC : 0));
result->alloc.min_malloc=sizeof(MYSQL_ROWS);
@@ -1352,7 +1406,8 @@ mysql_init(MYSQL *mysql)
return 0;
if (!mysql)
{
- if (!(mysql=(MYSQL*) my_malloc(sizeof(*mysql),MYF(MY_WME | MY_ZEROFILL))))
+ if (!(mysql=(MYSQL*) my_malloc(key_memory_MYSQL,
+ sizeof(*mysql), MYF(MY_WME | MY_ZEROFILL))))
{
set_mysql_error(NULL, CR_OUT_OF_MEMORY, unknown_sqlstate);
return 0;
@@ -1664,7 +1719,7 @@ mysql_autodetect_character_set(MYSQL *mysql)
{
if (mysql->options.charset_name)
my_free(mysql->options.charset_name);
- if (!(mysql->options.charset_name= my_strdup(my_default_csname(),MYF(MY_WME))))
+ if (!(mysql->options.charset_name= opt_strdup(my_default_csname(),MYF(MY_WME))))
return 1;
return 0;
}
@@ -2191,7 +2246,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
if (mpvio->db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB))
{
end= strmake(end, mpvio->db, NAME_LEN) + 1;
- mysql->db= my_strdup(mpvio->db, MYF(MY_WME));
+ mysql->db= my_strdup(key_memory_MYSQL, mpvio->db, MYF(MY_WME));
}
if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH)
@@ -2985,7 +3040,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
goto error;
/* Save connection information */
- if (!my_multi_malloc(MYF(0),
+ if (!my_multi_malloc(key_memory_MYSQL, MYF(0),
&mysql->host_info, (uint) strlen(host_info)+1,
&mysql->host, (uint) strlen(host)+1,
&mysql->unix_socket,unix_socket ?
@@ -2993,8 +3048,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
&mysql->server_version,
(uint) (server_version_end - (char*) net->read_pos + 1),
NullS) ||
- !(mysql->user=my_strdup(user,MYF(0))) ||
- !(mysql->passwd=my_strdup(passwd,MYF(0))))
+ !(mysql->user=my_strdup(key_memory_MYSQL, user,MYF(0))) ||
+ !(mysql->passwd=my_strdup(key_memory_MYSQL, passwd,MYF(0))))
{
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
goto error;
@@ -3255,7 +3310,7 @@ mysql_select_db(MYSQL *mysql, const char *db)
(ulong) strlen(db),0)))
DBUG_RETURN(error);
my_free(mysql->db);
- mysql->db=my_strdup(db,MYF(MY_WME));
+ mysql->db=my_strdup(key_memory_MYSQL, db,MYF(MY_WME));
DBUG_RETURN(0);
}
@@ -3582,7 +3637,8 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql)
DBUG_RETURN(0);
}
mysql->status=MYSQL_STATUS_READY; /* server is ready */
- if (!(result=(MYSQL_RES*) my_malloc((uint) (sizeof(MYSQL_RES)+
+ if (!(result=(MYSQL_RES*) my_malloc(key_memory_MYSQL_RES,
+ (uint) (sizeof(MYSQL_RES)+
sizeof(ulong) *
mysql->field_count),
MYF(MY_WME | MY_ZEROFILL))))
@@ -3635,15 +3691,17 @@ static MYSQL_RES * cli_use_result(MYSQL *mysql)
set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
DBUG_RETURN(0);
}
- if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result)+
+ if (!(result=(MYSQL_RES*) my_malloc(key_memory_MYSQL_RES,
+ sizeof(*result)+
sizeof(ulong)*mysql->field_count,
MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(0);
result->lengths=(ulong*) (result+1);
result->methods= mysql->methods;
if (!(result->row=(MYSQL_ROW)
- my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME))))
- { /* Ptrs: to one row */
+ my_malloc(key_memory_MYSQL_ROW,
+ sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME))))
+ { /* Ptrs: to one row */
my_free(result);
DBUG_RETURN(0);
}
@@ -3773,19 +3831,19 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
break;
case MYSQL_READ_DEFAULT_FILE:
my_free(mysql->options.my_cnf_file);
- mysql->options.my_cnf_file=my_strdup(arg,MYF(MY_WME));
+ mysql->options.my_cnf_file= opt_strdup(arg,MYF(MY_WME));
break;
case MYSQL_READ_DEFAULT_GROUP:
my_free(mysql->options.my_cnf_group);
- mysql->options.my_cnf_group=my_strdup(arg,MYF(MY_WME));
+ mysql->options.my_cnf_group= opt_strdup(arg,MYF(MY_WME));
break;
case MYSQL_SET_CHARSET_DIR:
my_free(mysql->options.charset_dir);
- mysql->options.charset_dir=my_strdup(arg,MYF(MY_WME));
+ mysql->options.charset_dir= opt_strdup(arg,MYF(MY_WME));
break;
case MYSQL_SET_CHARSET_NAME:
my_free(mysql->options.charset_name);
- mysql->options.charset_name=my_strdup(arg,MYF(MY_WME));
+ mysql->options.charset_name= opt_strdup(arg,MYF(MY_WME));
break;
case MYSQL_OPT_PROTOCOL:
mysql->options.protocol= *(uint*) arg;
@@ -3797,7 +3855,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
break;
case MYSQL_SET_CLIENT_IP:
my_free(mysql->options.client_ip);
- mysql->options.client_ip= my_strdup(arg, MYF(MY_WME));
+ mysql->options.client_ip= opt_strdup(arg, MYF(MY_WME));
break;
case MYSQL_SECURE_AUTH:
mysql->options.secure_auth= *(my_bool *) arg;
@@ -3828,7 +3886,8 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
case MYSQL_PROGRESS_CALLBACK:
if (!mysql->options.extension)
mysql->options.extension= (struct st_mysql_options_extention *)
- my_malloc(sizeof(struct st_mysql_options_extention),
+ my_malloc(key_memory_mysql_options,
+ sizeof(struct st_mysql_options_extention),
MYF(MY_WME | MY_ZEROFILL));
if (mysql->options.extension)
mysql->options.extension->report_progress=
@@ -3848,7 +3907,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
my_free(ctxt);
}
if (!(ctxt= (struct mysql_async_context *)
- my_malloc(sizeof(*ctxt), MYF(MY_ZEROFILL))))
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(*ctxt), MYF(MY_ZEROFILL))))
{
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
DBUG_RETURN(1);
@@ -3990,13 +4049,13 @@ mysql_options4(MYSQL *mysql,enum mysql_option option,
{
if (my_hash_init(&mysql->options.extension->connection_attributes,
&my_charset_bin, 0, 0, 0, (my_hash_get_key) get_attr_key,
- my_free, HASH_UNIQUE))
+ my_free, HASH_UNIQUE, key_memory_mysql_options))
{
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
DBUG_RETURN(1);
}
}
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(key_memory_mysql_options, MYF(MY_WME),
&elt, 2 * sizeof(LEX_STRING),
&key, key_len + 1,
&value, value_len + 1,
diff --git a/sql-common/client_plugin.c b/sql-common/client_plugin.c
index af86b19f309..0a2e39f7daa 100644
--- a/sql-common/client_plugin.c
+++ b/sql-common/client_plugin.c
@@ -38,6 +38,36 @@
#include "errmsg.h"
#include <mysql/client_plugin.h>
+PSI_memory_key key_memory_root;
+PSI_memory_key key_memory_load_env_plugins;
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_mutex_LOCK_load_client_plugin;
+
+static PSI_mutex_info all_client_plugin_mutexes[]=
+{
+ {&key_mutex_LOCK_load_client_plugin, "LOCK_load_client_plugin", PSI_FLAG_GLOBAL}
+};
+
+static PSI_memory_info all_client_plugin_memory[]=
+{
+ {&key_memory_root, "root", PSI_FLAG_GLOBAL},
+ {&key_memory_load_env_plugins, "load_env_plugins", PSI_FLAG_GLOBAL}
+};
+
+static void init_client_plugin_psi_keys()
+{
+ const char* category= "sql";
+ int count;
+
+ count= array_elements(all_client_plugin_mutexes);
+ mysql_mutex_register(category, all_client_plugin_mutexes, count);
+
+ count= array_elements(all_client_plugin_memory);
+ mysql_memory_register(category, all_client_plugin_memory, count);
+}
+#endif /* HAVE_PSI_INTERFACE */
+
struct st_client_plugin_int {
struct st_client_plugin_int *next;
void *dlhandle;
@@ -209,7 +239,7 @@ static void load_env_plugins(MYSQL *mysql)
if (!s)
DBUG_VOID_RETURN;
- free_env= plugs= my_strdup(s, MYF(MY_WME));
+ free_env= plugs= my_strdup(key_memory_load_env_plugins, s, MYF(MY_WME));
do {
if ((s= strchr(plugs, ';')))
@@ -242,11 +272,16 @@ int mysql_client_plugin_init()
if (initialized)
DBUG_RETURN(0);
+#ifdef HAVE_PSI_INTERFACE
+ init_client_plugin_psi_keys();
+#endif /* HAVE_PSI_INTERFACE */
+
bzero(&mysql, sizeof(mysql)); /* dummy mysql for set_mysql_extended_error */
bzero(&unused, sizeof unused);
- mysql_mutex_init(0, &LOCK_load_client_plugin, MY_MUTEX_INIT_SLOW);
- init_alloc_root(&mem_root, "client_plugin", 128, 128, MYF(0));
+ mysql_mutex_init(key_mutex_LOCK_load_client_plugin,
+ &LOCK_load_client_plugin, MY_MUTEX_INIT_SLOW);
+ init_alloc_root(key_memory_root, &mem_root, 128, 128, MYF(0));
bzero(&plugin_list, sizeof(plugin_list));
diff --git a/sql/create_options.cc b/sql/create_options.cc
index 817c4ba46e0..04469120db1 100644
--- a/sql/create_options.cc
+++ b/sql/create_options.cc
@@ -407,7 +407,7 @@ static bool resolve_sysvars(handlerton *hton, ha_create_table_option *rules)
return 1;
}
DBUG_ASSERT(str.length());
- opt->values= my_strndup(str.ptr(), str.length()-1, MYF(MY_WME));
+ opt->values= my_strndup(PSI_INSTRUMENT_ME, str.ptr(), str.length()-1, MYF(MY_WME));
if (!opt->values)
return 1;
break;
diff --git a/sql/datadict.cc b/sql/datadict.cc
index da8376d8b1a..5cfda166b2b 100644
--- a/sql/datadict.cc
+++ b/sql/datadict.cc
@@ -25,7 +25,7 @@ static int read_string(File file, uchar**to, size_t length)
DBUG_ENTER("read_string");
/* This can't use MY_THREAD_SPECIFIC as it's used on server start */
- if (!(*to= (uchar*) my_malloc(length+1,MYF(MY_WME))) ||
+ if (!(*to= (uchar*) my_malloc(PSI_INSTRUMENT_ME, length+1,MYF(MY_WME))) ||
mysql_file_read(file, *to, length, MYF(MY_NABP)))
{
my_free(*to);
diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc
index af541b1bb32..759e28b8589 100644
--- a/sql/debug_sync.cc
+++ b/sql/debug_sync.cc
@@ -236,7 +236,8 @@ void debug_sync_init_thread(THD *thd)
if (opt_debug_sync_timeout)
{
thd->debug_sync_control= (st_debug_sync_control*)
- my_malloc(sizeof(st_debug_sync_control),
+ my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(st_debug_sync_control),
MYF(MY_WME | MY_ZEROFILL | MY_THREAD_SPECIFIC));
if (!thd->debug_sync_control)
{
@@ -657,7 +658,7 @@ static st_debug_sync_action *debug_sync_get_action(THD *thd,
if (ds_control->ds_active > ds_control->ds_allocated)
{
uint new_alloc= ds_control->ds_active + 3;
- void *new_action= my_realloc(ds_control->ds_action,
+ void *new_action= my_realloc(PSI_NOT_INSTRUMENTED, ds_control->ds_action,
new_alloc * sizeof(st_debug_sync_action),
MYF(MY_WME | MY_ALLOW_ZERO_PTR));
if (!new_action)
diff --git a/sql/derror.cc b/sql/derror.cc
index 7a79833c26c..1c10bdfdd92 100644
--- a/sql/derror.cc
+++ b/sql/derror.cc
@@ -120,8 +120,9 @@ bool init_errmessage(void)
all_errors+= errors_per_range[i];
if (!(original_error_messages= (const char***)
- my_malloc((all_errors + MAX_ERROR_RANGES)* sizeof(void*),
- MYF(MY_ZEROFILL))))
+ my_malloc(PSI_NOT_INSTRUMENTED,
+ (all_errors + MAX_ERROR_RANGES)*sizeof(void*),
+ MYF(MY_ZEROFILL))))
DBUG_RETURN(TRUE);
errmsgs= (const char**)(original_error_messages + MAX_ERROR_RANGES);
@@ -315,7 +316,8 @@ bool read_texts(const char *file_name, const char *language,
DBUG_RETURN(1);
if (!(*data= (const char***)
- my_malloc((size_t) ((MAX_ERROR_RANGES+1) * sizeof(char**) +
+ my_malloc(key_memory_errmsgs,
+ (size_t) ((MAX_ERROR_RANGES+1) * sizeof(char**) +
MY_MAX(msg_file.text_length, msg_file.errors * 2)+
msg_file.errors * sizeof(char*)),
MYF(MY_WME))))
diff --git a/sql/discover.cc b/sql/discover.cc
index 3e41388ed51..e49a2a3b0c0 100644
--- a/sql/discover.cc
+++ b/sql/discover.cc
@@ -76,7 +76,8 @@ int readfrm(const char *name, const uchar **frmdata, size_t *len)
// Read whole frm file
error= 3;
- if (!(read_data= (uchar*)my_malloc(read_len, MYF(MY_WME))))
+ if (!(read_data= (uchar*)my_malloc(key_memory_frm_string, read_len,
+ MYF(MY_WME))))
goto err;
if (mysql_file_read(file, read_data, read_len, MYF(MY_NABP)))
{
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 81e703b5653..39f1889142e 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -173,11 +173,13 @@ Event_creation_ctx::load_from_db(THD *thd,
*/
bool
-Event_queue_element_for_exec::init(const LEX_CSTRING *db, const LEX_CSTRING *n)
+Event_queue_element_for_exec::init(const LEX_CSTRING &db, const LEX_CSTRING &n)
{
- if (!(dbname.str= my_strndup(db->str, dbname.length= db->length, MYF(MY_WME))))
+ if (!(dbname.str= my_strndup(key_memory_Event_queue_element_for_exec_names,
+ db.str, dbname.length= db.length, MYF(MY_WME))))
return TRUE;
- if (!(name.str= my_strndup(n->str, name.length= n->length, MYF(MY_WME))))
+ if (!(name.str= my_strndup(key_memory_Event_queue_element_for_exec_names,
+ n.str, name.length= n.length, MYF(MY_WME))))
{
my_free(const_cast<char*>(dbname.str));
return TRUE;
@@ -211,7 +213,7 @@ Event_basic::Event_basic()
{
DBUG_ENTER("Event_basic::Event_basic");
/* init memory root */
- init_sql_alloc(&mem_root, "Event_basic", 256, 512, MYF(0));
+ init_sql_alloc(key_memory_event_basic_root, &mem_root, 256, 512, MYF(0));
dbname.str= name.str= NULL;
dbname.length= name.length= 0;
time_zone= NULL;
diff --git a/sql/event_data_objects.h b/sql/event_data_objects.h
index e5e3e4eb087..d7cfefaa948 100644
--- a/sql/event_data_objects.h
+++ b/sql/event_data_objects.h
@@ -37,7 +37,7 @@ public:
~Event_queue_element_for_exec();
bool
- init(const LEX_CSTRING *dbname, const LEX_CSTRING *name);
+ init(const LEX_CSTRING &dbname, const LEX_CSTRING &name);
LEX_CSTRING dbname;
LEX_CSTRING name;
diff --git a/sql/event_queue.cc b/sql/event_queue.cc
index 6b3f5777df3..89bd672671f 100644
--- a/sql/event_queue.cc
+++ b/sql/event_queue.cc
@@ -637,7 +637,7 @@ Event_queue::get_top_for_execution_if_time(THD *thd,
}
if (!(*event_name= new Event_queue_element_for_exec()) ||
- (*event_name)->init(&top->dbname, &top->name))
+ (*event_name)->init(top->dbname, top->name))
{
ret= TRUE;
break;
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index 9a8869e2fb3..bb9676f3bef 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -411,7 +411,8 @@ Event_scheduler::start(int *err_no)
/* This should not be marked with MY_THREAD_SPECIFIC */
scheduler_param_value=
- (struct scheduler_param *)my_malloc(sizeof(struct scheduler_param), MYF(0));
+ (struct scheduler_param *)my_malloc(key_memory_Event_scheduler_scheduler_param,
+ sizeof(struct scheduler_param), MYF(0));
scheduler_param_value->thd= new_thd;
scheduler_param_value->scheduler= this;
diff --git a/sql/events.cc b/sql/events.cc
index f4400abdeb5..0014ce42d28 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -1027,6 +1027,8 @@ PSI_stage_info stage_waiting_on_empty_queue= { 0, "Waiting on empty queue", 0};
PSI_stage_info stage_waiting_for_next_activation= { 0, "Waiting for next activation", 0};
PSI_stage_info stage_waiting_for_scheduler_to_stop= { 0, "Waiting for the scheduler to stop", 0};
+PSI_memory_key key_memory_event_basic_root;
+
#ifdef HAVE_PSI_INTERFACE
PSI_stage_info *all_events_stages[]=
{
@@ -1035,6 +1037,11 @@ PSI_stage_info *all_events_stages[]=
& stage_waiting_for_scheduler_to_stop
};
+static PSI_memory_info all_events_memory[]=
+{
+ { &key_memory_event_basic_root, "Event_basic::mem_root", PSI_FLAG_GLOBAL}
+};
+
static void init_events_psi_keys(void)
{
const char* category= "sql";
@@ -1052,6 +1059,8 @@ static void init_events_psi_keys(void)
count= array_elements(all_events_stages);
mysql_stage_register(category, all_events_stages, count);
+ count= array_elements(all_events_memory);
+ mysql_memory_register(category, all_events_memory, count);
}
#endif /* HAVE_PSI_INTERFACE */
diff --git a/sql/events.h b/sql/events.h
index 9e1651c767a..2fb13d7c807 100644
--- a/sql/events.h
+++ b/sql/events.h
@@ -31,6 +31,8 @@ extern PSI_cond_key key_event_scheduler_COND_state;
extern PSI_thread_key key_thread_event_scheduler, key_thread_event_worker;
#endif /* HAVE_PSI_INTERFACE */
+extern PSI_memory_key key_memory_event_basic_root;
+
/* Always defined, for SHOW PROCESSLIST. */
extern PSI_stage_info stage_waiting_on_empty_queue;
extern PSI_stage_info stage_waiting_for_next_activation;
diff --git a/sql/field.cc b/sql/field.cc
index 5a2dbdfa15c..460c26fbfd2 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -8074,7 +8074,7 @@ int Field_longstr::compress(char *to, uint to_length,
max_length < length)
{
set_if_smaller(max_length, static_cast<ulonglong>(mbmaxlen()) * length + 1);
- if (!(buf= (char*) my_malloc(max_length, MYF(MY_WME))))
+ if (!(buf= (char*) my_malloc(PSI_INSTRUMENT_ME, max_length, MYF(MY_WME))))
{
*out_length= 0;
return -1;
diff --git a/sql/filesort.cc b/sql/filesort.cc
index ea13e26c698..1e19d492220 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -312,7 +312,7 @@ SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort,
param.using_pq= false;
if ((multi_byte_charset || param.using_packed_sortkeys()) &&
- !(param.tmp_buffer= (char*) my_malloc(param.sort_length,
+ !(param.tmp_buffer= (char*) my_malloc(key_memory_Sort_param_tmp_buffer, param.sort_length,
MYF(MY_WME | MY_THREAD_SPECIFIC))))
goto err;
@@ -619,7 +619,8 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count,
if (count > UINT_MAX/sizeof(Merge_chunk))
return 0; /* sizeof(BUFFPEK)*count will overflow */
if (!tmp)
- tmp= (uchar *)my_malloc(length, MYF(MY_WME | MY_THREAD_SPECIFIC));
+ tmp= (uchar *)my_malloc(key_memory_Filesort_info_merge, length,
+ MYF(MY_WME | MY_THREAD_SPECIFIC));
if (tmp)
{
if (reinit_io_cache(buffpek_pointers,READ_CACHE,0L,0,0) ||
@@ -1452,8 +1453,8 @@ static bool save_index(Sort_param *param, uint count,
res_length= param->res_length;
offset= param->rec_length-res_length;
if (!(to= table_sort->record_pointers=
- (uchar*) my_malloc(res_length*count,
- MYF(MY_WME | MY_THREAD_SPECIFIC))))
+ (uchar*) my_malloc(key_memory_Filesort_info_record_pointers,
+ res_length*count, MYF(MY_WME | MY_THREAD_SPECIFIC))))
DBUG_RETURN(1); /* purecov: inspected */
for (uint ix= 0; ix < count; ++ix)
{
@@ -2380,7 +2381,7 @@ get_addon_fields(TABLE *table, uint sortlength,
if (!filesort_use_addons(table, sortlength, &length, &fields, &null_fields,
&packable_length) ||
- !(my_multi_malloc(MYF(MY_WME | MY_THREAD_SPECIFIC),
+ !(my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME | MY_THREAD_SPECIFIC),
&raw_mem, sizeof(Addon_fields),
&raw_mem_addon_field,
sizeof(SORT_ADDON_FIELD) * fields,
diff --git a/sql/filesort_utils.cc b/sql/filesort_utils.cc
index a3b493b4c7a..d178740d24b 100644
--- a/sql/filesort_utils.cc
+++ b/sql/filesort_utils.cc
@@ -20,6 +20,8 @@
#include "table.h"
+PSI_memory_key key_memory_Filesort_buffer_sort_keys;
+
namespace {
/**
A local helper function. See comments for get_merge_buffers_cost().
@@ -128,7 +130,8 @@ uchar *Filesort_buffer::alloc_sort_buffer(uint num_records,
the old values
*/
my_free(m_rawmem);
- if (!(m_rawmem= (uchar*) my_malloc(buff_size, MYF(MY_THREAD_SPECIFIC))))
+ if (!(m_rawmem= (uchar*) my_malloc(key_memory_Filesort_buffer_sort_keys,
+ buff_size, MYF(MY_THREAD_SPECIFIC))))
{
m_size_in_bytes= 0;
DBUG_RETURN(0);
@@ -137,7 +140,8 @@ uchar *Filesort_buffer::alloc_sort_buffer(uint num_records,
}
else
{
- if (!(m_rawmem= (uchar*) my_malloc(buff_size, MYF(MY_THREAD_SPECIFIC))))
+ if (!(m_rawmem= (uchar*) my_malloc(key_memory_Filesort_buffer_sort_keys,
+ buff_size, MYF(MY_THREAD_SPECIFIC))))
{
m_size_in_bytes= 0;
DBUG_RETURN(0);
@@ -177,7 +181,7 @@ void Filesort_buffer::sort_buffer(const Sort_param *param, uint count)
uchar **buffer= NULL;
if (!param->using_packed_sortkeys() &&
radixsort_is_appliccable(count, param->sort_length) &&
- (buffer= (uchar**) my_malloc(count*sizeof(char*),
+ (buffer= (uchar**) my_malloc(PSI_INSTRUMENT_ME, count*sizeof(char*),
MYF(MY_THREAD_SPECIFIC))))
{
radixsort_for_str_ptr(m_sort_keys, count, param->sort_length, buffer);
diff --git a/sql/gcalc_slicescan.cc b/sql/gcalc_slicescan.cc
index 4919e5b959b..6d7ab7e29c3 100644
--- a/sql/gcalc_slicescan.cc
+++ b/sql/gcalc_slicescan.cc
@@ -204,7 +204,7 @@ void Gcalc_dyn_list::format_blk(void* block)
Gcalc_dyn_list::Item *Gcalc_dyn_list::alloc_new_blk()
{
- void *new_block= my_malloc(m_blk_size, MYF(MY_WME));
+ void *new_block= my_malloc(PSI_INSTRUMENT_ME, m_blk_size, MYF(MY_WME));
if (!new_block)
return NULL;
*m_blk_hook= new_block;
diff --git a/sql/gstream.cc b/sql/gstream.cc
index b743140ba59..f8e84e70560 100644
--- a/sql/gstream.cc
+++ b/sql/gstream.cc
@@ -23,6 +23,7 @@
#include "sql_priv.h"
#include "gstream.h"
#include "m_string.h" // LEX_STRING
+#include "mysqld.h"
enum Gis_read_stream::enum_tok_types Gis_read_stream::get_next_toc_type()
{
@@ -140,6 +141,7 @@ bool Gis_read_stream::check_next_symbol(char symbol)
void Gis_read_stream::set_error_msg(const char *msg)
{
size_t len= strlen(msg); // ok in this context
- m_err_msg= (char *) my_realloc(m_err_msg, (uint) len + 1, MYF(MY_ALLOW_ZERO_PTR));
+ m_err_msg= (char *) my_realloc(key_memory_Gis_read_stream_err_msg,
+ m_err_msg, (uint) len + 1, MYF(MY_ALLOW_ZERO_PTR));
memcpy(m_err_msg, msg, len + 1);
}
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index d36a58aef20..e1a1e4d45de 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -102,22 +102,43 @@ static const char *ha_partition_ext[]=
ha_par_ext, NullS
};
+static PSI_memory_key key_memory_Partition_share;
+static PSI_memory_key key_memory_partition_sort_buffer;
+static PSI_memory_key key_memory_Partition_admin;
+
+static PSI_memory_key key_memory_ha_partition_file;
+static PSI_memory_key key_memory_ha_partition_engine_array;
+static PSI_memory_key key_memory_ha_partition_part_ids;
#ifdef HAVE_PSI_INTERFACE
PSI_mutex_key key_partition_auto_inc_mutex;
+PSI_file_key key_file_ha_partition_par;
static PSI_mutex_info all_partition_mutexes[]=
{
{ &key_partition_auto_inc_mutex, "Partition_share::auto_inc_mutex", 0}
};
+static PSI_memory_info all_partitioning_memory[]=
+{ { &key_memory_Partition_share, "Partition_share", 0},
+ { &key_memory_partition_sort_buffer, "partition_sort_buffer", 0},
+ { &key_memory_Partition_admin, "Partition_admin", 0},
+ { &key_memory_ha_partition_file, "ha_partition::file", 0},
+ { &key_memory_ha_partition_engine_array, "ha_partition::engine_array", 0},
+ { &key_memory_ha_partition_part_ids, "ha_partition::part_ids", 0} };
+static PSI_file_info all_partition_file[]=
+{ { &key_file_ha_partition_par, "ha_partition::parfile", 0} };
static void init_partition_psi_keys(void)
{
const char* category= "partition";
int count;
+ count= array_elements(all_partitioning_memory);
+ mysql_memory_register(category, all_partitioning_memory, count);
count= array_elements(all_partition_mutexes);
mysql_mutex_register(category, all_partition_mutexes, count);
+ count= array_elements(all_partition_file);
+ mysql_file_register(category, all_partition_file, count);
}
#endif /* HAVE_PSI_INTERFACE */
@@ -244,7 +265,7 @@ ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share)
void ha_partition::ha_partition_init()
{
- init_alloc_root(&m_mem_root, "ha_partition", 512, 512, MYF(0));
+ init_alloc_root(PSI_INSTRUMENT_ME, &m_mem_root, 512, 512, MYF(0));
init_handler_variables();
}
@@ -649,9 +670,9 @@ int ha_partition::create_partitioning_metadata(const char *path,
strxmov(name, path, ha_par_ext, NullS);
strxmov(old_name, old_path, ha_par_ext, NullS);
if ((action_flag == CHF_DELETE_FLAG &&
- mysql_file_delete(key_file_partition, name, MYF(MY_WME))) ||
+ mysql_file_delete(key_file_ha_partition_par, name, MYF(MY_WME))) ||
(action_flag == CHF_RENAME_FLAG &&
- mysql_file_rename(key_file_partition, old_name, name, MYF(MY_WME))))
+ mysql_file_rename(key_file_ha_partition_par, old_name, name, MYF(MY_WME))))
{
DBUG_RETURN(TRUE);
}
@@ -1333,7 +1354,7 @@ bool print_admin_msg(THD* thd, uint len,
char *msgbuf;
bool error= true;
- if (!(msgbuf= (char*) my_malloc(len, MYF(0))))
+ if (!(msgbuf= (char*) my_malloc(key_memory_Partition_admin, len, MYF(0))))
return true;
va_start(args, fmt);
msg_length= my_vsnprintf(msgbuf, len, fmt, args);
@@ -2749,7 +2770,8 @@ bool ha_partition::create_handler_file(const char *name)
/* 4 static words (tot words, checksum, tot partitions, name length) */
tot_len_words= 4 + tot_partition_words + tot_name_words;
tot_len_byte= PAR_WORD_SIZE * tot_len_words;
- if (!(file_buffer= (uchar *) my_malloc(tot_len_byte, MYF(MY_ZEROFILL))))
+ if (!(file_buffer= (uchar *) my_malloc(key_memory_ha_partition_file,
+ tot_len_byte, MYF(MY_ZEROFILL))))
DBUG_RETURN(TRUE);
engine_array= (file_buffer + PAR_ENGINES_OFFSET);
name_buffer_ptr= (char*) (engine_array + tot_partition_words * PAR_WORD_SIZE
@@ -2804,7 +2826,7 @@ bool ha_partition::create_handler_file(const char *name)
to be used at open, delete_table and rename_table
*/
fn_format(file_name, name, "", ha_par_ext, MY_APPEND_EXT);
- if ((file= mysql_file_create(key_file_partition,
+ if ((file= mysql_file_create(key_file_ha_partition_par,
file_name, CREATE_MODE, O_RDWR | O_TRUNC,
MYF(MY_WME))) >= 0)
{
@@ -2829,7 +2851,7 @@ bool ha_partition::create_handler_file(const char *name)
}
(void) mysql_file_close(file, MYF(0));
if (result)
- mysql_file_delete(key_file_partition, file_name, MYF(MY_WME));
+ mysql_file_delete(key_file_ha_partition_par, file_name, MYF(MY_WME));
}
else
result= TRUE;
@@ -2993,7 +3015,7 @@ bool ha_partition::read_par_file(const char *name)
fn_format(buff, name, "", ha_par_ext, MY_APPEND_EXT);
/* Following could be done with mysql_file_stat to read in whole file */
- if ((file= mysql_file_open(key_file_partition,
+ if ((file= mysql_file_open(key_file_ha_partition_par,
buff, O_RDONLY | O_SHARE, MYF(0))) < 0)
DBUG_RETURN(TRUE);
if (mysql_file_read(file, (uchar *) &buff[0], PAR_WORD_SIZE, MYF(MY_NABP)))
@@ -3219,7 +3241,7 @@ bool ha_partition::insert_partition_name_in_hash(const char *name, uint part_id,
Since we use my_multi_malloc, then my_free(part_def) will also free
part_name, as a part of my_hash_free.
*/
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(key_memory_Partition_share, MY_WME,
&part_def, sizeof(PART_NAME_DEF),
&part_name, part_name_length + 1,
NULL))
@@ -3270,7 +3292,7 @@ bool ha_partition::populate_partition_name_hash()
if (my_hash_init(&part_share->partition_name_hash,
system_charset_info, tot_names, 0, 0,
(my_hash_get_key) get_part_name,
- my_free, HASH_UNIQUE))
+ my_free, HASH_UNIQUE, key_memory_Partition_share))
{
unlock_shared_ha_data();
DBUG_RETURN(TRUE);
@@ -3506,7 +3528,8 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
if (!m_part_ids_sorted_by_num_of_records)
{
if (!(m_part_ids_sorted_by_num_of_records=
- (uint32*) my_malloc(m_tot_parts * sizeof(uint32), MYF(MY_WME))))
+ (uint32*) my_malloc(key_memory_ha_partition_part_ids,
+ m_tot_parts * sizeof(uint32), MYF(MY_WME))))
DBUG_RETURN(error);
uint32 i;
/* Initialize it with all partition ids. */
@@ -3524,7 +3547,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
/* Allocate memory used with MMR */
if (!(m_range_info= (void **)
- my_multi_malloc(MYF(MY_WME),
+ my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&m_range_info, sizeof(range_id_t) * m_tot_parts,
&m_stock_range_seq, sizeof(uint) * m_tot_parts,
&m_mrr_buffer, sizeof(HANDLER_BUFFER) * m_tot_parts,
@@ -3535,8 +3558,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
&m_part_mrr_range_current,
sizeof(PARTITION_PART_KEY_MULTI_RANGE *) * m_tot_parts,
&m_partition_part_key_multi_range_hld,
- sizeof(PARTITION_PART_KEY_MULTI_RANGE_HLD) *
- m_tot_parts,
+ sizeof(PARTITION_PART_KEY_MULTI_RANGE_HLD) * m_tot_parts,
NullS)))
goto err_alloc;
@@ -5315,7 +5337,8 @@ bool ha_partition::init_record_priority_queue()
/* Allocate a key for temporary use when setting up the scan. */
alloc_len+= table_share->max_key_length;
- if (!(m_ordered_rec_buffer= (uchar*)my_malloc(alloc_len, MYF(MY_WME))))
+ if (!(m_ordered_rec_buffer= (uchar*)my_malloc(key_memory_partition_sort_buffer,
+ alloc_len, MYF(MY_WME))))
DBUG_RETURN(true);
/*
@@ -6066,9 +6089,8 @@ int ha_partition::multi_range_key_create_key(RANGE_SEQ_IF *seq,
if (!m_mrr_range_first)
{
if (!(m_mrr_range_first= (PARTITION_KEY_MULTI_RANGE *)
- my_multi_malloc(MYF(MY_WME),
- &m_mrr_range_current,
- sizeof(PARTITION_KEY_MULTI_RANGE),
+ my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
+ &m_mrr_range_current, sizeof(PARTITION_KEY_MULTI_RANGE),
NullS)))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -6085,9 +6107,8 @@ int ha_partition::multi_range_key_create_key(RANGE_SEQ_IF *seq,
if (!m_part_mrr_range_first[i])
{
if (!(m_part_mrr_range_first[i]= (PARTITION_PART_KEY_MULTI_RANGE *)
- my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
- &m_part_mrr_range_current[i],
- sizeof(PARTITION_PART_KEY_MULTI_RANGE),
+ my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME | MY_ZEROFILL),
+ &m_part_mrr_range_current[i], sizeof(PARTITION_PART_KEY_MULTI_RANGE),
NullS)))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
@@ -6123,7 +6144,7 @@ int ha_partition::multi_range_key_create_key(RANGE_SEQ_IF *seq,
if (m_mrr_range_current->key[0])
my_free(m_mrr_range_current->key[0]);
if (!(m_mrr_range_current->key[0]=
- (uchar *) my_malloc(length, MYF(MY_WME))))
+ (uchar *) my_malloc(PSI_INSTRUMENT_ME, length, MYF(MY_WME))))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
m_mrr_range_current->length[0]= length;
}
@@ -6147,7 +6168,7 @@ int ha_partition::multi_range_key_create_key(RANGE_SEQ_IF *seq,
if (m_mrr_range_current->key[1])
my_free(m_mrr_range_current->key[1]);
if (!(m_mrr_range_current->key[1]=
- (uchar *) my_malloc(length, MYF(MY_WME))))
+ (uchar *) my_malloc(PSI_INSTRUMENT_ME, length, MYF(MY_WME))))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
m_mrr_range_current->length[1]= length;
}
@@ -6181,7 +6202,7 @@ int ha_partition::multi_range_key_create_key(RANGE_SEQ_IF *seq,
{
PARTITION_PART_KEY_MULTI_RANGE *tmp_part_mrr_range;
if (!(tmp_part_mrr_range= (PARTITION_PART_KEY_MULTI_RANGE *)
- my_malloc(sizeof(PARTITION_PART_KEY_MULTI_RANGE),
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(PARTITION_PART_KEY_MULTI_RANGE),
MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -6201,7 +6222,7 @@ int ha_partition::multi_range_key_create_key(RANGE_SEQ_IF *seq,
/* Add end of range sentinel */
PARTITION_KEY_MULTI_RANGE *tmp_mrr_range;
if (!(tmp_mrr_range= (PARTITION_KEY_MULTI_RANGE *)
- my_malloc(sizeof(PARTITION_KEY_MULTI_RANGE), MYF(MY_WME))))
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(PARTITION_KEY_MULTI_RANGE), MYF(MY_WME))))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
tmp_mrr_range->id= m_mrr_range_current->id + 1;
@@ -6472,7 +6493,7 @@ int ha_partition::multi_range_read_init(RANGE_SEQ_IF *seq,
if (m_mrr_full_buffer)
my_free(m_mrr_full_buffer);
if (!(m_mrr_full_buffer=
- (uchar *) my_malloc(m_mrr_new_full_buffer_size, MYF(MY_WME))))
+ (uchar *) my_malloc(PSI_INSTRUMENT_ME, m_mrr_new_full_buffer_size, MYF(MY_WME))))
{
m_mrr_full_buffer_size= 0;
error= HA_ERR_OUT_OF_MEM;
@@ -6870,11 +6891,9 @@ FT_INFO *ha_partition::ft_init_ext(uint flags, uint inx, String *key)
{
FT_INFO **tmp_ft_info;
if (!(ft_target= (st_partition_ft_info *)
- my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
- &ft_target,
- sizeof(st_partition_ft_info),
- &tmp_ft_info,
- sizeof(FT_INFO *) * m_tot_parts,
+ my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME | MY_ZEROFILL),
+ &ft_target, sizeof(st_partition_ft_info),
+ &tmp_ft_info, sizeof(FT_INFO *) * m_tot_parts,
NullS)))
{
my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATAL));
diff --git a/sql/handler.cc b/sql/handler.cc
index 109c7dd01bf..7f79ce98eec 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -361,7 +361,8 @@ int ha_init_errors(void)
/* Allocate a pointer array for the error message strings. */
/* Zerofill it to avoid uninitialized gaps. */
- if (! (handler_errmsgs= (const char**) my_malloc(HA_ERR_ERRORS * sizeof(char*),
+ if (! (handler_errmsgs= (const char**) my_malloc(key_memory_handler_errmsgs,
+ HA_ERR_ERRORS * sizeof(char*),
MYF(MY_WME | MY_ZEROFILL))))
return 1;
@@ -531,7 +532,7 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
DBUG_ENTER("ha_initialize_handlerton");
DBUG_PRINT("plugin", ("initialize plugin: '%s'", plugin->name.str));
- hton= (handlerton *)my_malloc(sizeof(handlerton),
+ hton= (handlerton *)my_malloc(key_memory_handlerton, sizeof(handlerton),
MYF(MY_WME | MY_ZEROFILL));
if (hton == NULL)
{
@@ -2216,7 +2217,7 @@ int ha_recover(HASH *commit_list)
info.list==0 && info.len > MIN_XID_LIST_SIZE; info.len/=2)
{
DBUG_EXECUTE_IF("min_xa_len", info.len = 16;);
- info.list=(XID *)my_malloc(info.len*sizeof(XID), MYF(0));
+ info.list=(XID *)my_malloc(key_memory_XID, info.len*sizeof(XID), MYF(0));
}
if (!info.list)
{
@@ -4941,7 +4942,7 @@ void handler::update_global_table_stats()
table->s->table_cache_key.length)))
{
if (!(table_stats = ((TABLE_STATS*)
- my_malloc(sizeof(TABLE_STATS),
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(TABLE_STATS),
MYF(MY_WME | MY_ZEROFILL)))))
{
/* Out of memory error already given */
@@ -5006,7 +5007,7 @@ void handler::update_global_index_stats()
key_length)))
{
if (!(index_stats = ((INDEX_STATS*)
- my_malloc(sizeof(INDEX_STATS),
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(INDEX_STATS),
MYF(MY_WME | MY_ZEROFILL)))))
goto end; // Error is already given
@@ -7221,7 +7222,7 @@ int del_global_table_stat(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *ta
cache_key_length= db->length + 1 + table->length + 1;
- if(!(cache_key= (uchar *)my_malloc(cache_key_length,
+ if(!(cache_key= (uchar *)my_malloc(PSI_INSTRUMENT_ME, cache_key_length,
MYF(MY_WME | MY_ZEROFILL))))
{
/* Out of memory error already given */
diff --git a/sql/hash_filo.h b/sql/hash_filo.h
index d815c428ac6..864e91594b2 100644
--- a/sql/hash_filo.h
+++ b/sql/hash_filo.h
@@ -48,6 +48,7 @@ private:
class hash_filo
{
private:
+ PSI_memory_key m_psi_key;
const uint key_offset, key_length;
const my_hash_get_key get_key;
/** Size of this hash table. */
@@ -61,15 +62,13 @@ public:
mysql_mutex_t lock;
HASH cache;
- hash_filo(uint size_arg, uint key_offset_arg , uint key_length_arg,
- my_hash_get_key get_key_arg, my_hash_free_key free_element_arg,
- CHARSET_INFO *hash_charset_arg)
- :key_offset(key_offset_arg), key_length(key_length_arg),
- get_key(get_key_arg), m_size(size_arg),
- free_element(free_element_arg),init(0),
- hash_charset(hash_charset_arg),
- first_link(NULL),
- last_link(NULL)
+ hash_filo(PSI_memory_key psi_key, uint size_arg, uint key_offset_arg,
+ uint key_length_arg, my_hash_get_key get_key_arg,
+ my_hash_free_key free_element_arg, CHARSET_INFO *hash_charset_arg)
+ : m_psi_key(psi_key), key_offset(key_offset_arg),
+ key_length(key_length_arg), get_key(get_key_arg), m_size(size_arg),
+ free_element(free_element_arg),init(0), hash_charset(hash_charset_arg),
+ first_link(NULL), last_link(NULL)
{
bzero((char*) &cache,sizeof(cache));
}
@@ -96,7 +95,7 @@ public:
last_link= NULL;
(void) my_hash_free(&cache);
(void) my_hash_init(&cache,hash_charset,m_size,key_offset,
- key_length, get_key, free_element,0);
+ key_length, get_key, free_element, 0, m_psi_key);
if (!locked)
mysql_mutex_unlock(&lock);
}
@@ -202,10 +201,10 @@ public:
template <class T> class Hash_filo: public hash_filo
{
public:
- Hash_filo(uint size_arg, uint key_offset_arg, uint key_length_arg,
- my_hash_get_key get_key_arg, my_hash_free_key free_element_arg,
- CHARSET_INFO *hash_charset_arg) :
- hash_filo(size_arg, key_offset_arg, key_length_arg,
+ Hash_filo(PSI_memory_key psi_key, uint size_arg, uint key_offset_arg, uint
+ key_length_arg, my_hash_get_key get_key_arg, my_hash_free_key
+ free_element_arg, CHARSET_INFO *hash_charset_arg) :
+ hash_filo(psi_key, size_arg, key_offset_arg, key_length_arg,
get_key_arg, free_element_arg, hash_charset_arg) {}
T* first() { return (T*)hash_filo::first(); }
T* last() { return (T*)hash_filo::last(); }
diff --git a/sql/hostname.cc b/sql/hostname.cc
index 968914fd56e..edf31c11081 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -150,10 +150,9 @@ bool hostname_cache_init()
Host_entry tmp;
uint key_offset= (uint) ((char*) (&tmp.ip_key) - (char*) &tmp);
- if (!(hostname_cache= new Hash_filo<Host_entry>(host_cache_size,
- key_offset, HOST_ENTRY_KEY_SIZE,
- NULL, (my_hash_free_key) free,
- &my_charset_bin)))
+ if (!(hostname_cache= new Hash_filo<Host_entry>(key_memory_host_cache_hostname,
+ host_cache_size, key_offset, HOST_ENTRY_KEY_SIZE,
+ NULL, (my_hash_free_key) free, &my_charset_bin)))
return 1;
hostname_cache->clear();
@@ -476,7 +475,8 @@ int ip_to_hostname(struct sockaddr_storage *ip_storage,
if (entry->m_host_validated)
{
if (entry->m_hostname_length)
- *hostname= my_strdup(entry->m_hostname, MYF(0));
+ *hostname= my_strdup(key_memory_host_cache_hostname,
+ entry->m_hostname, MYF(0));
DBUG_PRINT("info",("IP (%s) has been found in the cache. "
"Hostname: '%s'",
@@ -926,7 +926,8 @@ int ip_to_hostname(struct sockaddr_storage *ip_storage,
{
/* Copy host name string to be stored in the cache. */
- *hostname= my_strdup(hostname_buffer, MYF(0));
+ *hostname= my_strdup(key_memory_host_cache_hostname,
+ hostname_buffer, MYF(0));
if (!*hostname)
{
diff --git a/sql/item.cc b/sql/item.cc
index c7454b789fb..89e23173b0e 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2771,7 +2771,8 @@ Item_sp::execute_impl(THD *thd, Item **args, uint arg_count)
(m_sp->agg_type() == NOT_AGGREGATE && !func_ctx));
if (!func_ctx)
{
- init_sql_alloc(&sp_mem_root, "Item_sp", MEM_ROOT_BLOCK_SIZE, 0, MYF(0));
+ init_sql_alloc(key_memory_sp_head_call_root, &sp_mem_root,
+ MEM_ROOT_BLOCK_SIZE, 0, MYF(0));
*sp_query_arena= Query_arena(&sp_mem_root,
Query_arena::STMT_INITIALIZED_FOR_SP);
}
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 2bd605286d0..e437b3fc724 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -5624,7 +5624,7 @@ int item_create_init()
0,
(my_hash_get_key) get_native_fct_hash_key,
NULL, /* Nothing to free */
- MYF(0)))
+ MYF(0), key_memory_native_functions))
DBUG_RETURN(1);
if (native_func_registry_array.append_to_hash(&native_functions_hash))
diff --git a/sql/item_func.cc b/sql/item_func.cc
index a263391a41a..da7b523d830 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4020,7 +4020,8 @@ longlong Item_func_get_lock::val_int()
/* HASH entries are of type User_level_lock. */
if (! my_hash_inited(&thd->ull_hash) &&
my_hash_init(&thd->ull_hash, &my_charset_bin,
- 16 /* small hash */, 0, 0, ull_get_key, NULL, 0))
+ 16 /* small hash */, 0, 0, ull_get_key, NULL, 0,
+ key_memory_User_level_lock))
{
DBUG_RETURN(0);
}
@@ -4052,7 +4053,8 @@ longlong Item_func_get_lock::val_int()
DBUG_RETURN(0);
}
- ull= (User_level_lock*) my_malloc(sizeof(User_level_lock),
+ ull= (User_level_lock*) my_malloc(key_memory_User_level_lock,
+ sizeof(User_level_lock),
MYF(MY_WME|MY_THREAD_SPECIFIC));
if (ull == NULL)
{
@@ -4420,7 +4422,7 @@ user_var_entry *get_variable(HASH *hash, LEX_CSTRING *name,
size_t size=ALIGN_SIZE(sizeof(user_var_entry))+name->length+1+extra_size;
if (!my_hash_inited(hash))
return 0;
- if (!(entry = (user_var_entry*) my_malloc(size,
+ if (!(entry = (user_var_entry*) my_malloc(key_memory_user_var_entry, size,
MYF(MY_WME | ME_FATAL |
MY_THREAD_SPECIFIC))))
return 0;
@@ -4680,7 +4682,8 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, size_t length,
char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry));
if (entry->value == pos)
entry->value=0;
- entry->value= (char*) my_realloc(entry->value, length,
+ entry->value= (char*) my_realloc(key_memory_user_var_entry_value,
+ entry->value, length,
MYF(MY_ALLOW_ZERO_PTR | MY_WME |
ME_FATAL | MY_THREAD_SPECIFIC));
if (!entry->value)
@@ -6793,7 +6796,7 @@ longlong Item_func_nextval::val_int()
if (!(entry= ((SEQUENCE_LAST_VALUE*)
my_hash_search(&thd->sequences, (uchar*) key, length))))
{
- if (!(key= (char*) my_memdup(key, length, MYF(MY_WME))) ||
+ if (!(key= (char*) my_memdup(PSI_INSTRUMENT_ME, key, length, MYF(MY_WME))) ||
!(entry= new SEQUENCE_LAST_VALUE((uchar*) key, length)))
{
/* EOM, error given */
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 4b781152c33..e494e9d84e1 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -5808,8 +5808,9 @@ bool Ordered_key::alloc_keys_buffers()
{
DBUG_ASSERT(key_buff_elements > 0);
- if (!(key_buff= (rownum_t*) my_malloc((size_t)(key_buff_elements *
- sizeof(rownum_t)), MYF(MY_WME | MY_THREAD_SPECIFIC))))
+ if (!(key_buff= (rownum_t*) my_malloc(PSI_INSTRUMENT_ME,
+ static_cast<size_t>(key_buff_elements * sizeof(rownum_t)),
+ MYF(MY_WME | MY_THREAD_SPECIFIC))))
return TRUE;
/*
@@ -6240,8 +6241,9 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts,
sizeof(Ordered_key*))) ||
!(null_bitmaps= (MY_BITMAP**) thd->alloc(merge_keys_count *
sizeof(MY_BITMAP*))) ||
- !(row_num_to_rowid= (uchar*) my_malloc((size_t)(row_count * rowid_length),
- MYF(MY_WME | MY_THREAD_SPECIFIC))))
+ !(row_num_to_rowid= (uchar*) my_malloc(PSI_INSTRUMENT_ME,
+ static_cast<size_t>(row_count * rowid_length),
+ MYF(MY_WME | MY_THREAD_SPECIFIC))))
return TRUE;
/* Create the only non-NULL key if there is any. */
diff --git a/sql/keycaches.cc b/sql/keycaches.cc
index 60049cdd67d..10bec7c1de8 100644
--- a/sql/keycaches.cc
+++ b/sql/keycaches.cc
@@ -23,6 +23,9 @@
NAMED_ILIST key_caches;
NAMED_ILIST rpl_filters;
+extern "C" PSI_memory_key key_memory_KEY_CACHE;
+extern PSI_memory_key key_memory_NAMED_ILINK_name;
+
/**
ilink (intrusive list element) with a name
*/
@@ -37,7 +40,8 @@ public:
size_t name_length_arg, uchar* data_arg)
:name_length(name_length_arg), data(data_arg)
{
- name= my_strndup(name_arg, name_length, MYF(MY_WME));
+ name= my_strndup(key_memory_NAMED_ILINK_name, name_arg, name_length,
+ MYF(MY_WME));
links->push_back(this);
}
inline bool cmp(const char *name_cmp, size_t length)
@@ -118,8 +122,8 @@ KEY_CACHE *create_key_cache(const char *name, size_t length)
DBUG_ENTER("create_key_cache");
DBUG_PRINT("enter",("name: %.*s", (int)length, name));
- if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
- MYF(MY_ZEROFILL | MY_WME))))
+ if ((key_cache= (KEY_CACHE*) my_malloc(key_memory_KEY_CACHE,
+ sizeof(KEY_CACHE), MYF(MY_ZEROFILL | MY_WME))))
{
if (!new NAMED_ILINK(&key_caches, name, length, (uchar*) key_cache))
{
diff --git a/sql/lock.cc b/sql/lock.cc
index 6f86c0a38f6..92f4ea0c279 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -645,7 +645,7 @@ MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b)
a->lock_count, b->lock_count));
if (!(sql_lock= (MYSQL_LOCK*)
- my_malloc(sizeof(*sql_lock)+
+ my_malloc(key_memory_MYSQL_LOCK, sizeof(*sql_lock) +
sizeof(THR_LOCK_DATA*)*((a->lock_count+b->lock_count)*2) +
sizeof(TABLE*)*(a->table_count+b->table_count),MYF(MY_WME))))
DBUG_RETURN(0); // Fatal error
@@ -764,7 +764,8 @@ MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, uint flags)
sizeof(table_ptr) * table_count;
if (!(sql_lock= (MYSQL_LOCK*) (flags & GET_LOCK_ON_THD ?
thd->alloc(amount) :
- my_malloc(amount, MYF(0)))))
+ my_malloc(key_memory_MYSQL_LOCK, amount,
+ MYF(0)))))
DBUG_RETURN(0);
locks= locks_buf= sql_lock->locks= (THR_LOCK_DATA**) (sql_lock + 1);
to= table_buf= sql_lock->table= (TABLE**) (locks + lock_count * 2);
diff --git a/sql/log.cc b/sql/log.cc
index b2d971f3a4f..935bfda79d9 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -253,7 +253,7 @@ void make_default_log_name(char **out, const char* log_ext, bool once)
else
{
my_free(*out);
- *out= my_strdup(buff, MYF(MY_WME));
+ *out= my_strdup(PSI_INSTRUMENT_ME, buff, MYF(MY_WME));
}
}
@@ -2653,7 +2653,7 @@ bool MYSQL_LOG::open(
write_error= 0;
- if (!(name= my_strdup(log_name, MYF(MY_WME))))
+ if (!(name= my_strdup(key_memory_MYSQL_LOG_name, log_name, MYF(MY_WME))))
{
name= (char *)log_name; // for the error message
goto err;
@@ -4443,14 +4443,16 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
{
rli->last_inuse_relaylog= NULL;
included= 1;
- to_purge_if_included= my_strdup(ir->name, MYF(0));
+ to_purge_if_included= my_strdup(key_memory_Relay_log_info_group_relay_log_name,
+ ir->name, MYF(0));
}
rli->free_inuse_relaylog(ir);
ir= next;
}
rli->inuse_relaylog_list= ir;
if (ir)
- to_purge_if_included= my_strdup(ir->name, MYF(0));
+ to_purge_if_included= my_strdup(key_memory_Relay_log_info_group_relay_log_name,
+ ir->name, MYF(0));
/*
Read the next log file name from the index file and pass it back to
@@ -5589,7 +5591,8 @@ binlog_cache_mngr *THD::binlog_setup_trx_data()
if (cache_mngr)
DBUG_RETURN(cache_mngr); // Already set up
- cache_mngr= (binlog_cache_mngr*) my_malloc(sizeof(binlog_cache_mngr), MYF(MY_ZEROFILL));
+ cache_mngr= (binlog_cache_mngr*) my_malloc(key_memory_binlog_cache_mngr,
+ sizeof(binlog_cache_mngr), MYF(MY_ZEROFILL));
if (!cache_mngr ||
open_cached_file(&cache_mngr->stmt_cache.cache_log, mysql_tmpdir,
LOG_PREFIX, (size_t)binlog_stmt_cache_size, MYF(MY_WME)) ||
@@ -9109,7 +9112,8 @@ int TC_LOG_MMAP::open(const char *opt_name)
npages=(uint)file_length/tc_log_page_size;
if (npages < 3) // to guarantee non-empty pool
goto err;
- if (!(pages=(PAGE *)my_malloc(npages*sizeof(PAGE), MYF(MY_WME|MY_ZEROFILL))))
+ if (!(pages=(PAGE *)my_malloc(key_memory_TC_LOG_MMAP_pages,
+ npages*sizeof(PAGE), MYF(MY_WME|MY_ZEROFILL))))
goto err;
inited=3;
for (pg=pages, i=0; i < npages; i++, pg++)
@@ -9419,7 +9423,8 @@ int TC_LOG_MMAP::unlog(ulong cookie, my_xid xid)
{
uint32 size= sizeof(*pending_checkpoint) + sizeof(ulong) * (ncookies - 1);
if (!(pending_checkpoint=
- (pending_cookies *)my_malloc(size, MYF(MY_ZEROFILL))))
+ (pending_cookies *)my_malloc(PSI_INSTRUMENT_ME, size,
+ MYF(MY_ZEROFILL))))
{
my_error(ER_OUTOFMEMORY, MYF(0), size);
mysql_mutex_unlock(&LOCK_pending_checkpoint);
@@ -9559,7 +9564,7 @@ int TC_LOG_MMAP::recover()
}
if (my_hash_init(&xids, &my_charset_bin, tc_log_page_size/3, 0,
- sizeof(my_xid), 0, 0, MYF(0)))
+ sizeof(my_xid), 0, 0, MYF(0), PSI_INSTRUMENT_ME))
goto err1;
for ( ; p < end_p ; p++)
@@ -10073,12 +10078,13 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name,
if (! fdle->is_valid() ||
(do_xa && my_hash_init(&xids, &my_charset_bin, TC_LOG_PAGE_SIZE/3, 0,
- sizeof(my_xid), 0, 0, MYF(0))))
+ sizeof(my_xid), 0, 0, MYF(0),
+ key_memory_binlog_recover_exec)))
goto err1;
if (do_xa)
- init_alloc_root(&mem_root, "TC_LOG_BINLOG", TC_LOG_PAGE_SIZE,
- TC_LOG_PAGE_SIZE, MYF(0));
+ init_alloc_root(key_memory_binlog_recover_exec, &mem_root,
+ TC_LOG_PAGE_SIZE, TC_LOG_PAGE_SIZE, MYF(0));
fdle->flags&= ~LOG_EVENT_BINLOG_IN_USE_F; // abort on the first error
diff --git a/sql/log.h b/sql/log.h
index fa8b9fca37e..52e4d31ddd9 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -587,7 +587,7 @@ public:
:binlog_id(0), xid_count(0), notify_count(0)
{
binlog_name_len= log_file_name_len;
- binlog_name= (char *) my_malloc(binlog_name_len, MYF(MY_ZEROFILL));
+ binlog_name= (char *) my_malloc(PSI_INSTRUMENT_ME, binlog_name_len, MYF(MY_ZEROFILL));
if (binlog_name)
memcpy(binlog_name, log_file_name, binlog_name_len);
}
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 4c1c18fffff..7ee38a007d1 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -56,6 +56,10 @@
#define my_b_write_string(A, B) my_b_write((A), (uchar*)(B), (uint) (sizeof(B) - 1))
+PSI_memory_key key_memory_log_event;
+PSI_memory_key key_memory_Incident_log_event_message;
+PSI_memory_key key_memory_Rows_query_log_event_rows_query;
+
/**
BINLOG_CHECKSUM variable.
*/
@@ -410,7 +414,7 @@ query_event_uncompress(const Format_description_log_event *description_event,
}
else
{
- new_dst = (char *)my_malloc(alloc_size, MYF(MY_WME));
+ new_dst = (char *)my_malloc(PSI_INSTRUMENT_ME, alloc_size, MYF(MY_WME));
if (!new_dst)
return 1;
@@ -532,7 +536,7 @@ row_log_event_uncompress(const Format_description_log_event *description_event,
}
else
{
- new_dst = (char *)my_malloc(alloc_size, MYF(MY_WME));
+ new_dst = (char *)my_malloc(PSI_INSTRUMENT_ME, alloc_size, MYF(MY_WME));
if (!new_dst)
return 1;
@@ -873,7 +877,7 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
*/
sz += MY_AES_BLOCK_SIZE;
#endif
- char *newpkt= (char*)my_malloc(sz, MYF(MY_WME));
+ char *newpkt= (char*)my_malloc(PSI_INSTRUMENT_ME, sz, MYF(MY_WME));
if (!newpkt)
DBUG_RETURN(LOG_READ_MEM);
memcpy(newpkt, packet->ptr(), ev_offset);
@@ -1665,7 +1669,8 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
*/
#if !defined(MYSQL_CLIENT) && defined(HAVE_QUERY_CACHE)
- if (!(start= data_buf = (Log_event::Byte*) my_malloc(catalog_len + 1
+ if (!(start= data_buf = (Log_event::Byte*) my_malloc(PSI_INSTRUMENT_ME,
+ catalog_len + 1
+ time_zone_len + 1
+ user.length + 1
+ host.length + 1
@@ -1676,7 +1681,8 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
+ QUERY_CACHE_FLAGS_SIZE,
MYF(MY_WME))))
#else
- if (!(start= data_buf = (Log_event::Byte*) my_malloc(catalog_len + 1
+ if (!(start= data_buf = (Log_event::Byte*) my_malloc(PSI_INSTRUMENT_ME,
+ catalog_len + 1
+ time_zone_len + 1
+ user.length + 1
+ host.length + 1
@@ -1783,8 +1789,8 @@ Query_compressed_log_event::Query_compressed_log_event(const char *buf,
}
/* Reserve one byte for '\0' */
- query_buf = (Log_event::Byte*)my_malloc(ALIGN_SIZE(un_len + 1),
- MYF(MY_WME));
+ query_buf = (Log_event::Byte*)my_malloc(PSI_INSTRUMENT_ME,
+ ALIGN_SIZE(un_len + 1), MYF(MY_WME));
if(query_buf &&
!binlog_buf_uncompress(query, (char *)query_buf, q_len, &un_len))
{
@@ -2033,7 +2039,8 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver)
common_header_len= LOG_EVENT_HEADER_LEN;
number_of_event_types= LOG_EVENT_TYPES;
/* we'll catch my_malloc() error in is_valid() */
- post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8)
+ post_header_len=(uint8*) my_malloc(PSI_INSTRUMENT_ME,
+ number_of_event_types*sizeof(uint8)
+ BINLOG_CHECKSUM_ALG_DESC_LEN,
MYF(0));
/*
@@ -2159,8 +2166,8 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver)
make the slave detect less corruptions).
*/
number_of_event_types= FORMAT_DESCRIPTION_EVENT - 1;
- post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8),
- MYF(0));
+ post_header_len=(uint8*) my_malloc(PSI_INSTRUMENT_ME,
+ number_of_event_types*sizeof(uint8), MYF(0));
if (post_header_len)
{
post_header_len[START_EVENT_V3-1]= START_V3_HEADER_LEN;
@@ -2228,7 +2235,8 @@ Format_description_log_event(const char* buf,
common_header_len, number_of_event_types));
/* If alloc fails, we'll detect it in is_valid() */
- post_header_len= (uint8*) my_memdup((uchar*)buf+ST_COMMON_HEADER_LEN_OFFSET+1,
+ post_header_len= (uint8*) my_memdup(PSI_INSTRUMENT_ME,
+ buf+ST_COMMON_HEADER_LEN_OFFSET+1,
number_of_event_types*
sizeof(*post_header_len),
MYF(0));
@@ -2517,7 +2525,7 @@ Rotate_log_event::Rotate_log_event(const char* buf, uint event_len,
ident_len= (uint)(event_len - (LOG_EVENT_MINIMAL_HEADER_LEN + post_header_len));
ident_offset= post_header_len;
set_if_smaller(ident_len,FN_REFLEN-1);
- new_log_ident= my_strndup(buf + ident_offset, (uint) ident_len, MYF(MY_WME));
+ new_log_ident= my_strndup(PSI_INSTRUMENT_ME, buf + ident_offset, (uint) ident_len, MYF(MY_WME));
DBUG_PRINT("debug", ("new_log_ident: '%s'", new_log_ident));
DBUG_VOID_RETURN;
}
@@ -2544,7 +2552,7 @@ Binlog_checkpoint_log_event::Binlog_checkpoint_log_event(
binlog_file_len= uint4korr(buf);
if (event_len - (header_size + post_header_len) < binlog_file_len)
return;
- binlog_file_name= my_strndup(buf + post_header_len, binlog_file_len,
+ binlog_file_name= my_strndup(PSI_INSTRUMENT_ME, buf + post_header_len, binlog_file_len,
MYF(MY_WME));
return;
}
@@ -2603,8 +2611,8 @@ Gtid_list_log_event::Gtid_list_log_event(const char *buf, uint event_len,
gl_flags= val & ((uint32)0xf << 28);
buf+= 4;
if (event_len - (header_size + post_header_len) < count*element_size ||
- (!(list= (rpl_gtid *)my_malloc(count*sizeof(*list) + (count == 0),
- MYF(MY_WME)))))
+ (!(list= (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME,
+ count*sizeof(*list) + (count == 0), MYF(MY_WME)))))
return;
for (i= 0; i < count; ++i)
@@ -2621,7 +2629,8 @@ Gtid_list_log_event::Gtid_list_log_event(const char *buf, uint event_len,
if ((gl_flags & FLAG_IGN_GTIDS))
{
uint32 i;
- if (!(sub_id_list= (uint64 *)my_malloc(count*sizeof(uint64), MYF(MY_WME))))
+ if (!(sub_id_list= (uint64 *)my_malloc(PSI_INSTRUMENT_ME,
+ count*sizeof(uint64), MYF(MY_WME))))
{
my_free(list);
list= NULL;
@@ -2678,8 +2687,8 @@ Gtid_list_log_event::peek(const char *event_start, size_t event_len,
if (event_len < (uint32)fdev->common_header_len + GTID_LIST_HEADER_LEN +
16 * count)
return true;
- if (!(gtid_list= (rpl_gtid *)my_malloc(sizeof(rpl_gtid)*count + (count == 0),
- MYF(MY_WME))))
+ if (!(gtid_list= (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(rpl_gtid)*count + (count == 0), MYF(MY_WME))))
return true;
*out_gtid_list= gtid_list;
*out_list_len= count;
@@ -2886,7 +2895,7 @@ Create_file_log_event::Create_file_log_event(const char* buf, uint len,
uint header_len= description_event->common_header_len;
uint8 load_header_len= description_event->post_header_len[LOAD_EVENT-1];
uint8 create_file_header_len= description_event->post_header_len[CREATE_FILE_EVENT-1];
- if (!(event_buf= (char*) my_memdup(buf, len, MYF(MY_WME))) ||
+ if (!(event_buf= (char*) my_memdup(PSI_INSTRUMENT_ME, buf, len, MYF(MY_WME))) ||
copy_log_event(event_buf,len,
(((uchar)buf[EVENT_TYPE_OFFSET] == LOAD_EVENT) ?
load_header_len + header_len :
@@ -3188,7 +3197,7 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len,
/* Just store/use the first tag of this type, skip others */
if (likely(!m_extra_row_data))
{
- m_extra_row_data= (uchar*) my_malloc(infoLen,
+ m_extra_row_data= (uchar*) my_malloc(PSI_INSTRUMENT_ME, infoLen,
MYF(MY_WME));
if (likely(m_extra_row_data != NULL))
{
@@ -3277,7 +3286,7 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len,
DBUG_PRINT("info",("m_table_id: %llu m_flags: %d m_width: %lu data_size: %lu",
m_table_id, m_flags, m_width, (ulong) data_size));
- m_rows_buf= (uchar*) my_malloc(data_size, MYF(MY_WME));
+ m_rows_buf= (uchar*) my_malloc(PSI_INSTRUMENT_ME, data_size, MYF(MY_WME));
if (likely((bool)m_rows_buf))
{
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
@@ -3300,7 +3309,7 @@ void Rows_log_event::uncompress_buf()
if (!un_len)
return;
- uchar *new_buf= (uchar*) my_malloc(ALIGN_SIZE(un_len), MYF(MY_WME));
+ uchar *new_buf= (uchar*) my_malloc(PSI_INSTRUMENT_ME, ALIGN_SIZE(un_len), MYF(MY_WME));
if (new_buf)
{
if(!binlog_buf_uncompress((char *)m_rows_buf, (char *)new_buf,
@@ -3535,7 +3544,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
m_colcnt, (long) (ptr_colcnt-(const uchar*)vpart)));
/* Allocate mem for all fields in one go. If fails, caught in is_valid() */
- m_memory= (uchar*) my_multi_malloc(MYF(MY_WME),
+ m_memory= (uchar*) my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&m_dbnam, (uint) m_dblen + 1,
&m_tblnam, (uint) m_tbllen + 1,
&m_coltype, (uint) m_colcnt,
@@ -3554,7 +3563,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
if (m_field_metadata_size <= (m_colcnt * 2))
{
uint num_null_bytes= (m_colcnt + 7) / 8;
- m_meta_memory= (uchar *)my_multi_malloc(MYF(MY_WME),
+ m_meta_memory= (uchar *)my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&m_null_bits, num_null_bytes,
&m_field_metadata, m_field_metadata_size,
NULL);
@@ -3578,7 +3587,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
{
m_optional_metadata_len= event_len - bytes_read;
m_optional_metadata=
- static_cast<unsigned char*>(my_malloc(m_optional_metadata_len, MYF(MY_WME)));
+ static_cast<unsigned char*>(my_malloc(PSI_INSTRUMENT_ME, m_optional_metadata_len, MYF(MY_WME)));
memcpy(m_optional_metadata, ptr_after_colcnt, m_optional_metadata_len);
}
}
@@ -3958,7 +3967,7 @@ Incident_log_event::Incident_log_event(const char *buf, uint event_len,
m_incident= INCIDENT_NONE;
DBUG_VOID_RETURN;
}
- if (!(m_message.str= (char*) my_malloc(len+1, MYF(MY_WME))))
+ if (!(m_message.str= (char*) my_malloc(key_memory_log_event, len+1, MYF(MY_WME))))
{
/* Mark this event invalid */
m_incident= INCIDENT_NONE;
diff --git a/sql/log_event.h b/sql/log_event.h
index f2d27282a6f..67cf27b60a0 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -1357,7 +1357,8 @@ public:
static void *operator new(size_t size)
{
- return (void*) my_malloc((uint)size, MYF(MY_WME|MY_FAE));
+ extern PSI_memory_key key_memory_log_event;
+ return my_malloc(key_memory_log_event, size, MYF(MY_WME|MY_FAE));
}
static void operator delete(void *ptr, size_t)
@@ -5368,11 +5369,12 @@ public:
Incident_log_event(THD *thd_arg, Incident incident, const LEX_CSTRING *msg)
: Log_event(thd_arg, 0, FALSE), m_incident(incident)
{
+ extern PSI_memory_key key_memory_Incident_log_event_message;
DBUG_ENTER("Incident_log_event::Incident_log_event");
DBUG_PRINT("enter", ("m_incident: %d", m_incident));
m_message.length= 0;
- if (unlikely(!(m_message.str= (char*) my_malloc(msg->length+1,
- MYF(MY_WME)))))
+ if (!(m_message.str= (char*) my_malloc(key_memory_Incident_log_event_message,
+ msg->length + 1, MYF(MY_WME))))
{
/* Mark this event invalid */
m_incident= INCIDENT_NONE;
diff --git a/sql/log_event_client.cc b/sql/log_event_client.cc
index cae4842355a..83a7eaf06b0 100644
--- a/sql/log_event_client.cc
+++ b/sql/log_event_client.cc
@@ -1104,7 +1104,7 @@ void Rows_log_event::change_to_flashback_event(PRINT_EVENT_INFO *print_event_inf
if (((get_general_type_code() == WRITE_ROWS_EVENT) && (m_rows_buf==m_rows_end)))
goto end;
- (void) my_init_dynamic_array(&rows_arr, sizeof(LEX_STRING), 8, 8, MYF(0));
+ (void) my_init_dynamic_array(&rows_arr, PSI_NOT_INSTRUMENTED, sizeof(LEX_STRING), 8, 8, MYF(0));
for (uchar *value= m_rows_buf; value < m_rows_end; )
{
@@ -1119,7 +1119,7 @@ void Rows_log_event::change_to_flashback_event(PRINT_EVENT_INFO *print_event_inf
}
value+= length1;
- swap_buff1= (uchar *) my_malloc(length1, MYF(0));
+ swap_buff1= (uchar *) my_malloc(PSI_NOT_INSTRUMENTED, length1, MYF(0));
if (!swap_buff1)
{
fprintf(stderr, "\nError: Out of memory. "
@@ -1142,7 +1142,7 @@ void Rows_log_event::change_to_flashback_event(PRINT_EVENT_INFO *print_event_inf
}
value+= length2;
- swap_buff2= (uchar *) my_malloc(length2, MYF(0));
+ swap_buff2= (uchar *) my_malloc(PSI_NOT_INSTRUMENTED, length2, MYF(0));
if (!swap_buff2)
{
fprintf(stderr, "\nError: Out of memory. "
@@ -1170,7 +1170,7 @@ void Rows_log_event::change_to_flashback_event(PRINT_EVENT_INFO *print_event_inf
LEX_STRING one_row;
one_row.length= length1 + length2;
- one_row.str= (char *) my_malloc(one_row.length, MYF(0));
+ one_row.str= (char *) my_malloc(PSI_NOT_INSTRUMENTED, one_row.length, MYF(0));
memcpy(one_row.str, start_pos, one_row.length);
if (one_row.str == NULL || push_dynamic(&rows_arr, (uchar *) &one_row))
{
@@ -1637,7 +1637,7 @@ bool Log_event::print_base64(IO_CACHE* file,
{
size_t const tmp_str_sz= my_base64_needed_encoded_length((int) size);
char *tmp_str;
- if (!(tmp_str= (char *) my_malloc(tmp_str_sz, MYF(MY_WME))))
+ if (!(tmp_str= (char *) my_malloc(PSI_NOT_INSTRUMENTED, tmp_str_sz, MYF(MY_WME))))
goto err;
if (my_base64_encode(ptr, (size_t) size, tmp_str))
@@ -2491,7 +2491,7 @@ bool User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
bool error;
// 2 hex digits / byte
- hex_str= (char *) my_malloc(2 * val_len + 1 + 3, MYF(MY_WME));
+ hex_str= (char *) my_malloc(PSI_NOT_INSTRUMENTED, 2 * val_len + 1 + 3, MYF(MY_WME));
if (!hex_str)
goto err;
str_to_hex(hex_str, val, val_len);
@@ -2853,7 +2853,7 @@ bool copy_cache_to_string_wrapped(IO_CACHE *cache,
if (reinit_io_cache(cache, READ_CACHE, 0L, FALSE, FALSE))
goto err;
- if (!(to->str= (char*) my_malloc((size_t)cache->end_of_file + fmt_size,
+ if (!(to->str= (char*) my_malloc(PSI_NOT_INSTRUMENTED, (size_t)cache->end_of_file + fmt_size,
MYF(0))))
{
perror("Out of memory: can't allocate memory in "
@@ -3108,7 +3108,7 @@ int Table_map_log_event::rewrite_db(const char* new_db, size_t new_len,
// Create new temp_buf
ulong event_cur_len= uint4korr(temp_buf + EVENT_LEN_OFFSET);
ulong event_new_len= event_cur_len + len_diff;
- char* new_temp_buf= (char*) my_malloc(event_new_len, MYF(MY_WME));
+ char* new_temp_buf= (char*) my_malloc(PSI_NOT_INSTRUMENTED, event_new_len, MYF(MY_WME));
if (!new_temp_buf)
{
@@ -3150,7 +3150,7 @@ int Table_map_log_event::rewrite_db(const char* new_db, size_t new_len,
char const* tblnam= m_tblnam;
uchar* coltype= m_coltype;
- m_memory= (uchar*) my_multi_malloc(MYF(MY_WME),
+ m_memory= (uchar*) my_multi_malloc(PSI_NOT_INSTRUMENTED, MYF(MY_WME),
&m_dbnam, (uint) m_dblen + 1,
&m_tblnam, (uint) m_tbllen + 1,
&m_coltype, (uint) m_colcnt,
@@ -3801,7 +3801,7 @@ bool copy_event_cache_to_string_and_reinit(IO_CACHE *cache, LEX_STRING *to)
{
reinit_io_cache(cache, READ_CACHE, 0L, FALSE, FALSE);
if (cache->end_of_file > SIZE_T_MAX ||
- !(to->str= (char*) my_malloc((to->length= (size_t)cache->end_of_file), MYF(0))))
+ !(to->str= (char*) my_malloc(PSI_NOT_INSTRUMENTED, (to->length= (size_t)cache->end_of_file), MYF(0))))
{
perror("Out of memory: can't allocate memory in copy_event_cache_to_string_and_reinit().");
goto err;
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index e01488abbb3..c6ccfc5a2c0 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -32,6 +32,8 @@
#include "rpl_record_old.h"
#include "transaction.h"
+PSI_memory_key key_memory_log_event_old;
+
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
// Old implementation of do_apply_event()
@@ -899,7 +901,7 @@ int Delete_rows_log_event_old::do_before_row_operations(TABLE *table)
if (table->s->keys > 0)
{
- m_memory= (uchar*) my_multi_malloc(MYF(MY_WME),
+ m_memory= (uchar*) my_multi_malloc(key_memory_log_event_old, MYF(MY_WME),
&m_after_image,
(uint) table->s->reclength,
&m_key,
@@ -908,7 +910,7 @@ int Delete_rows_log_event_old::do_before_row_operations(TABLE *table)
}
else
{
- m_after_image= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME));
+ m_after_image= (uchar*) my_malloc(key_memory_log_event_old, table->s->reclength, MYF(MY_WME));
m_memory= (uchar*)m_after_image;
m_key= NULL;
}
@@ -997,7 +999,7 @@ int Update_rows_log_event_old::do_before_row_operations(TABLE *table)
if (table->s->keys > 0)
{
- m_memory= (uchar*) my_multi_malloc(MYF(MY_WME),
+ m_memory= (uchar*) my_multi_malloc(key_memory_log_event_old, MYF(MY_WME),
&m_after_image,
(uint) table->s->reclength,
&m_key,
@@ -1006,7 +1008,7 @@ int Update_rows_log_event_old::do_before_row_operations(TABLE *table)
}
else
{
- m_after_image= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME));
+ m_after_image= (uchar*) my_malloc(key_memory_log_event_old, table->s->reclength, MYF(MY_WME));
m_memory= m_after_image;
m_key= NULL;
}
@@ -1252,7 +1254,7 @@ Old_rows_log_event::Old_rows_log_event(const char *buf, uint event_len,
m_table_id, m_flags, m_width, data_size));
DBUG_DUMP("rows_data", (uchar*) ptr_rows_data, data_size);
- m_rows_buf= (uchar*) my_malloc(data_size, MYF(MY_WME));
+ m_rows_buf= (uchar*) my_malloc(key_memory_log_event_old, data_size, MYF(MY_WME));
if (likely((bool)m_rows_buf))
{
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
@@ -1326,7 +1328,7 @@ int Old_rows_log_event::do_add_row_data(uchar *row_data, size_t length)
my_ptrdiff_t const new_alloc=
block_size * ((cur_size + length + block_size - 1) / block_size);
- uchar* const new_buf= (uchar*)my_realloc((uchar*)m_rows_buf, (uint) new_alloc,
+ uchar* const new_buf= (uchar*)my_realloc(key_memory_log_event_old, (uchar*)m_rows_buf, (uint) new_alloc,
MYF(MY_ALLOW_ZERO_PTR|MY_WME));
if (unlikely(!new_buf))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -2555,7 +2557,7 @@ Delete_rows_log_event_old::do_before_row_operations(const Slave_reporting_capabi
if (m_table->s->keys > 0)
{
// Allocate buffer for key searches
- m_key= (uchar*)my_malloc(m_table->key_info->key_length, MYF(MY_WME));
+ m_key= (uchar*)my_malloc(key_memory_log_event_old, m_table->key_info->key_length, MYF(MY_WME));
if (!m_key)
return HA_ERR_OUT_OF_MEM;
}
@@ -2653,7 +2655,7 @@ Update_rows_log_event_old::do_before_row_operations(const Slave_reporting_capabi
if (m_table->s->keys > 0)
{
// Allocate buffer for key searches
- m_key= (uchar*)my_malloc(m_table->key_info->key_length, MYF(MY_WME));
+ m_key= (uchar*)my_malloc(key_memory_log_event_old, m_table->key_info->key_length, MYF(MY_WME));
if (!m_key)
return HA_ERR_OUT_OF_MEM;
}
diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc
index d371992c6c0..e2a200d3a3b 100644
--- a/sql/log_event_server.cc
+++ b/sql/log_event_server.cc
@@ -3014,7 +3014,7 @@ Rotate_log_event::Rotate_log_event(const char* new_log_ident_arg,
pos_arg, (ulong) flags));
cache_type= EVENT_NO_CACHE;
if (flags & DUP_NAME)
- new_log_ident= my_strndup(new_log_ident_arg, ident_len, MYF(MY_WME));
+ new_log_ident= my_strndup(PSI_INSTRUMENT_ME, new_log_ident_arg, ident_len, MYF(MY_WME));
if (flags & RELAY_LOG)
set_relay_log_event();
DBUG_VOID_RETURN;
@@ -3170,7 +3170,7 @@ Binlog_checkpoint_log_event::Binlog_checkpoint_log_event(
const char *binlog_file_name_arg,
uint binlog_file_len_arg)
:Log_event(),
- binlog_file_name(my_strndup(binlog_file_name_arg, binlog_file_len_arg,
+ binlog_file_name(my_strndup(PSI_INSTRUMENT_ME, binlog_file_name_arg, binlog_file_len_arg,
MYF(MY_WME))),
binlog_file_len(binlog_file_len_arg)
{
@@ -3443,8 +3443,8 @@ Gtid_list_log_event::Gtid_list_log_event(rpl_binlog_state *gtid_set,
cache_type= EVENT_NO_CACHE;
/* Failure to allocate memory will be caught by is_valid() returning false. */
if (count < (1<<28) &&
- (list = (rpl_gtid *)my_malloc(count * sizeof(*list) + (count == 0),
- MYF(MY_WME))))
+ (list = (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME,
+ count * sizeof(*list) + (count == 0), MYF(MY_WME))))
gtid_set->get_gtid_list(list, count);
}
@@ -3456,8 +3456,8 @@ Gtid_list_log_event::Gtid_list_log_event(slave_connection_state *gtid_set,
cache_type= EVENT_NO_CACHE;
/* Failure to allocate memory will be caught by is_valid() returning false. */
if (count < (1<<28) &&
- (list = (rpl_gtid *)my_malloc(count * sizeof(*list) + (count == 0),
- MYF(MY_WME))))
+ (list = (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME,
+ count * sizeof(*list) + (count == 0), MYF(MY_WME))))
{
gtid_set->get_gtid_list(list, count);
#if defined(HAVE_REPLICATION)
@@ -3465,8 +3465,8 @@ Gtid_list_log_event::Gtid_list_log_event(slave_connection_state *gtid_set,
{
uint32 i;
- if (!(sub_id_list= (uint64 *)my_malloc(count * sizeof(uint64),
- MYF(MY_WME))))
+ if (!(sub_id_list= (uint64 *)my_malloc(PSI_INSTRUMENT_ME,
+ count * sizeof(uint64), MYF(MY_WME))))
{
my_free(list);
list= NULL;
@@ -4691,7 +4691,7 @@ int Execute_load_log_event::do_apply_event(rpl_group_info *rgi)
don't want to overwrite it with the filename.
What we want instead is add the filename to the current error message.
*/
- char *tmp= my_strdup(rli->last_error().message, MYF(MY_WME));
+ char *tmp= my_strdup(PSI_INSTRUMENT_ME, rli->last_error().message, MYF(MY_WME));
if (tmp)
{
rli->report(ERROR_LEVEL, rli->last_error().number, rgi->gtid_info(),
@@ -4823,8 +4823,8 @@ Execute_load_query_log_event::do_apply_event(rpl_group_info *rgi)
int error;
Relay_log_info const *rli= rgi->rli;
- buf= (char*) my_malloc(q_len + 1 - (fn_pos_end - fn_pos_start) +
- (FN_REFLEN + 10) + 10 + 8 + 5, MYF(MY_WME));
+ buf= (char*) my_malloc(PSI_INSTRUMENT_ME, q_len + 1 -
+ (fn_pos_end - fn_pos_start) + (FN_REFLEN + 10) + 10 + 8 + 5, MYF(MY_WME));
DBUG_EXECUTE_IF("LOAD_DATA_INFILE_has_fatal_error", my_free(buf); buf= NULL;);
@@ -5036,8 +5036,8 @@ int Rows_log_event::do_add_row_data(uchar *row_data, size_t length)
size_t const new_alloc=
block_size * ((cur_size + length + block_size - 1) / block_size);
- uchar* const new_buf= (uchar*)my_realloc((uchar*)m_rows_buf, new_alloc,
- MYF(MY_ALLOW_ZERO_PTR|MY_WME));
+ uchar* const new_buf= (uchar*)my_realloc(PSI_INSTRUMENT_ME, m_rows_buf,
+ new_alloc, MYF(MY_ALLOW_ZERO_PTR|MY_WME));
if (unlikely(!new_buf))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -5990,7 +5990,7 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid,
m_flags|= TM_BIT_HAS_TRIGGERS_F;
/* If malloc fails, caught in is_valid() */
- if ((m_memory= (uchar*) my_malloc(m_colcnt, MYF(MY_WME))))
+ if ((m_memory= (uchar*) my_malloc(PSI_INSTRUMENT_ME, m_colcnt, MYF(MY_WME))))
{
m_coltype= reinterpret_cast<uchar*>(m_memory);
for (unsigned int i= 0 ; i < m_table->s->fields ; ++i)
@@ -6006,7 +6006,7 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid,
*/
uint num_null_bytes= (m_table->s->fields + 7) / 8;
m_data_size+= num_null_bytes;
- m_meta_memory= (uchar *)my_multi_malloc(MYF(MY_WME),
+ m_meta_memory= (uchar *)my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&m_null_bits, num_null_bytes,
&m_field_metadata, (m_colcnt * 2),
NULL);
@@ -6158,7 +6158,7 @@ int Table_map_log_event::do_apply_event(rpl_group_info *rgi)
/* Step the query id to mark what columns that are actually used. */
thd->set_query_id(next_query_id());
- if (!(memory= my_multi_malloc(MYF(MY_WME),
+ if (!(memory= my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&table_list, (uint) sizeof(RPL_TABLE_LIST),
&db_mem, (uint) NAME_LEN + 1,
&tname_mem, (uint) NAME_LEN + 1,
@@ -7438,7 +7438,7 @@ int Rows_log_event::find_key()
}
// Allocate buffer for key searches
- m_key= (uchar *) my_malloc(best_key->key_length, MYF(MY_WME));
+ m_key= (uchar *) my_malloc(PSI_INSTRUMENT_ME, best_key->key_length, MYF(MY_WME));
if (m_key == NULL)
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
m_key_info= best_key;
diff --git a/sql/mdl.cc b/sql/mdl.cc
index c4d6f89644b..0d6588cd6a4 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -26,6 +26,8 @@
#include <mysql/psi/mysql_stage.h>
#include <tpool.h>
+static PSI_memory_key key_memory_MDL_context_acquire_locks;
+
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key key_MDL_wait_LOCK_wait_status;
@@ -50,6 +52,11 @@ static PSI_cond_info all_mdl_conds[]=
{ &key_MDL_wait_COND_wait_status, "MDL_context::COND_wait_status", 0}
};
+static PSI_memory_info all_mdl_memory[]=
+{
+ { &key_memory_MDL_context_acquire_locks, "MDL_context::acquire_locks", 0}
+};
+
/**
Initialise all the performance schema instrumentation points
used by the MDL subsystem.
@@ -67,6 +74,9 @@ static void init_mdl_psi_keys(void)
count= array_elements(all_mdl_conds);
mysql_cond_register("sql", all_mdl_conds, count);
+ count= array_elements(all_mdl_memory);
+ mysql_memory_register("sql", all_mdl_memory, count);
+
MDL_key::init_psi_keys();
}
#endif /* HAVE_PSI_INTERFACE */
@@ -2435,8 +2445,8 @@ bool MDL_context::acquire_locks(MDL_request_list *mdl_requests,
DBUG_RETURN(FALSE);
/* Sort requests according to MDL_key. */
- if (! (sort_buf= (MDL_request **)my_malloc(req_count *
- sizeof(MDL_request*),
+ if (! (sort_buf= (MDL_request **)my_malloc(key_memory_MDL_context_acquire_locks,
+ req_count * sizeof(MDL_request*),
MYF(MY_WME))))
DBUG_RETURN(TRUE);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index a94ffa900eb..a153801c35f 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1109,7 +1109,7 @@ PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file,
key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load,
key_file_loadfile, key_file_log_event_data, key_file_log_event_info,
- key_file_master_info, key_file_misc, key_file_partition,
+ key_file_master_info, key_file_misc, key_file_partition_ddl_log,
key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog,
key_file_trg, key_file_trn, key_file_init;
PSI_file_key key_file_query_log, key_file_slow_log;
@@ -1291,7 +1291,7 @@ private:
void Buffered_logs::init()
{
- init_alloc_root(&m_root, "Buffered_logs", 1024, 0, MYF(0));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &m_root, 1024, 0, MYF(0));
}
void Buffered_logs::cleanup()
@@ -1671,7 +1671,7 @@ void kill_mysql(THD *thd)
make_user_name(thd, user_host_buff);
- if ((user= my_strdup(user_host_buff, MYF(0))) &&
+ if ((user= my_strdup(PSI_NOT_INSTRUMENTED, user_host_buff, MYF(0))) &&
!shutdown_user.compare_exchange_strong(expected_shutdown_user,
user,
std::memory_order_relaxed,
@@ -3205,10 +3205,18 @@ extern "C" void *my_str_malloc_mysqld(size_t size);
void *my_str_malloc_mysqld(size_t size)
{
- return my_malloc(size, MYF(MY_FAE));
+ return my_malloc(key_memory_my_str_malloc, size, MYF(MY_FAE));
}
+#if 0
+extern "C" void *my_str_realloc_mysqld(void *ptr, size_t size);
+void *my_str_realloc_mysqld(void *ptr, size_t size)
+{
+ return my_realloc(key_memory_my_str_malloc, ptr, size, MYF(MY_FAE));
+}
+#endif
+
#include <mysqld_default_groups.h>
#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
@@ -3631,10 +3639,8 @@ int json_unescape_json(const char *json_str, const char *json_end,
@returns Pointer to string containing the full file path, or NULL if
it was not possible to create the path.
*/
-static inline const char *
-rpl_make_log_name(const char *opt,
- const char *def,
- const char *ext)
+static const char *rpl_make_log_name(PSI_memory_key key, const char *opt,
+ const char *def, const char *ext)
{
DBUG_ENTER("rpl_make_log_name");
DBUG_PRINT("enter", ("opt: %s, def: %s, ext: %s", opt, def, ext));
@@ -3652,7 +3658,7 @@ rpl_make_log_name(const char *opt,
mysql_real_data_home_ptr= mysql_real_data_home;
if (fn_format(buff, base, mysql_real_data_home_ptr, ext, options))
- DBUG_RETURN(my_strdup(buff, MYF(MY_WME)));
+ DBUG_RETURN(my_strdup(key, buff, MYF(MY_WME)));
else
DBUG_RETURN(NULL);
}
@@ -4960,10 +4966,12 @@ static int init_server_components()
}
log_bin_basename=
- rpl_make_log_name(opt_bin_logname, pidfile_name,
+ rpl_make_log_name(key_memory_MYSQL_BIN_LOG_basename,
+ opt_bin_logname, pidfile_name,
opt_bin_logname ? "" : "-bin");
log_bin_index=
- rpl_make_log_name(opt_binlog_index_name, log_bin_basename, ".index");
+ rpl_make_log_name(key_memory_MYSQL_BIN_LOG_index,
+ opt_binlog_index_name, log_bin_basename, ".index");
if (log_bin_basename == NULL || log_bin_index == NULL)
{
sql_print_error("Unable to create replication path names:"
@@ -4981,10 +4989,12 @@ static int init_server_components()
if (opt_relay_logname)
{
relay_log_basename=
- rpl_make_log_name(opt_relay_logname, pidfile_name,
+ rpl_make_log_name(key_memory_MYSQL_RELAY_LOG_basename,
+ opt_relay_logname, pidfile_name,
opt_relay_logname ? "" : "-relay-bin");
relay_log_index=
- rpl_make_log_name(opt_relaylog_index_name, relay_log_basename, ".index");
+ rpl_make_log_name(key_memory_MYSQL_RELAY_LOG_index,
+ opt_relaylog_index_name, relay_log_basename, ".index");
if (relay_log_basename == NULL || relay_log_index == NULL)
{
sql_print_error("Unable to create replication path names:"
@@ -6357,7 +6367,8 @@ int handle_early_options()
my_getopt_skip_unknown= TRUE;
/* prepare all_early_options array */
- my_init_dynamic_array(&all_early_options, sizeof(my_option), 100, 25, MYF(0));
+ my_init_dynamic_array(&all_early_options, PSI_NOT_INSTRUMENTED,
+ sizeof(my_option), 100, 25, MYF(0));
add_many_options(&all_early_options, pfs_early_options,
array_elements(pfs_early_options));
sys_var_add_options(&all_early_options, sys_var::PARSE_EARLY);
@@ -7676,7 +7687,7 @@ static int option_cmp(my_option *a, my_option *b)
static void print_help()
{
MEM_ROOT mem_root;
- init_alloc_root(&mem_root, "help", 4096, 4096, MYF(0));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &mem_root, 4096, 4096, MYF(0));
pop_dynamic(&all_options);
add_many_options(&all_options, pfs_early_options,
@@ -8531,7 +8542,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
my_getopt_error_reporter= option_error_reporter;
/* prepare all_options array */
- my_init_dynamic_array(&all_options, sizeof(my_option),
+ my_init_dynamic_array(&all_options, PSI_INSTRUMENT_ME, sizeof(my_option),
array_elements(my_long_options) + sys_var_elements(),
array_elements(my_long_options)/4, MYF(0));
add_many_options(&all_options, my_long_options, array_elements(my_long_options));
@@ -8963,7 +8974,7 @@ static int fix_paths(void)
sql_print_warning("Failed to normalize the argument for --secure-file-priv.");
DBUG_RETURN(1);
}
- char *secure_file_real_path= (char *)my_malloc(FN_REFLEN, MYF(MY_FAE));
+ char *secure_file_real_path= (char *)my_malloc(PSI_INSTRUMENT_ME, FN_REFLEN, MYF(MY_FAE));
convert_dirname(secure_file_real_path, buff, NullS);
my_free(opt_secure_file_priv);
opt_secure_file_priv= secure_file_real_path;
@@ -9118,7 +9129,7 @@ static PSI_file_info all_server_files[]=
{ &key_file_log_event_info, "log_event_info", 0},
{ &key_file_master_info, "master_info", 0},
{ &key_file_misc, "misc", 0},
- { &key_file_partition, "partition", 0},
+ { &key_file_partition_ddl_log, "partition_ddl_log", 0},
{ &key_file_pid, "pid", 0},
{ &key_file_query_log, "query_log", 0},
{ &key_file_relay_log_info, "relay_log_info", 0},
@@ -9419,6 +9430,227 @@ static PSI_socket_info all_server_sockets[]=
{ &key_socket_client_connection, "client_connection", 0}
};
+
+PSI_memory_key key_memory_DATE_TIME_FORMAT;
+PSI_memory_key key_memory_DDL_LOG_MEMORY_ENTRY;
+PSI_memory_key key_memory_Event_queue_element_for_exec_names;
+PSI_memory_key key_memory_Event_scheduler_scheduler_param;
+PSI_memory_key key_memory_Filesort_info_merge;
+PSI_memory_key key_memory_Filesort_info_record_pointers;
+PSI_memory_key key_memory_Gis_read_stream_err_msg;
+PSI_memory_key key_memory_JOIN_CACHE;
+PSI_memory_key key_memory_MPVIO_EXT_auth_info;
+PSI_memory_key key_memory_MYSQL_BIN_LOG_basename;
+PSI_memory_key key_memory_MYSQL_BIN_LOG_index;
+PSI_memory_key key_memory_MYSQL_LOCK;
+PSI_memory_key key_memory_MYSQL_LOG_name;
+PSI_memory_key key_memory_MYSQL_RELAY_LOG_basename;
+PSI_memory_key key_memory_MYSQL_RELAY_LOG_index;
+PSI_memory_key key_memory_NAMED_ILINK_name;
+PSI_memory_key key_memory_PROFILE;
+PSI_memory_key key_memory_QUICK_RANGE_SELECT_mrr_buf_desc;
+PSI_memory_key key_memory_Query_cache;
+PSI_memory_key key_memory_Relay_log_info_group_relay_log_name;
+PSI_memory_key key_memory_Row_data_memory_memory;
+PSI_memory_key key_memory_Rpl_info_file_buffer;
+PSI_memory_key key_memory_SLAVE_INFO;
+PSI_memory_key key_memory_ST_SCHEMA_TABLE;
+PSI_memory_key key_memory_Sort_param_tmp_buffer;
+PSI_memory_key key_memory_Sys_var_charptr_value;
+PSI_memory_key key_memory_TABLE;
+PSI_memory_key key_memory_TABLE_RULE_ENT;
+PSI_memory_key key_memory_TC_LOG_MMAP_pages;
+PSI_memory_key key_memory_THD_db;
+PSI_memory_key key_memory_THD_handler_tables_hash;
+PSI_memory_key key_memory_THD_variables;
+PSI_memory_key key_memory_Table_trigger_dispatcher;
+PSI_memory_key key_memory_Unique_merge_buffer;
+PSI_memory_key key_memory_Unique_sort_buffer;
+PSI_memory_key key_memory_User_level_lock;
+PSI_memory_key key_memory_XID;
+PSI_memory_key key_memory_acl_cache;
+PSI_memory_key key_memory_acl_mem;
+PSI_memory_key key_memory_acl_memex;
+PSI_memory_key key_memory_binlog_cache_mngr;
+PSI_memory_key key_memory_binlog_pos;
+PSI_memory_key key_memory_binlog_recover_exec;
+PSI_memory_key key_memory_binlog_statement_buffer;
+PSI_memory_key key_memory_binlog_ver_1_event;
+PSI_memory_key key_memory_bison_stack;
+PSI_memory_key key_memory_blob_mem_storage;
+PSI_memory_key key_memory_dboptions_hash;
+PSI_memory_key key_memory_errmsgs;
+PSI_memory_key key_memory_frm_string;
+PSI_memory_key key_memory_gdl;
+PSI_memory_key key_memory_global_system_variables;
+PSI_memory_key key_memory_handler_errmsgs;
+PSI_memory_key key_memory_handlerton;
+PSI_memory_key key_memory_hash_index_key_buffer;
+PSI_memory_key key_memory_host_cache_hostname;
+PSI_memory_key key_memory_ignored_db;
+PSI_memory_key key_memory_locked_table_list;
+PSI_memory_key key_memory_locked_thread_list;
+PSI_memory_key key_memory_my_str_malloc;
+PSI_memory_key key_memory_native_functions;
+PSI_memory_key key_memory_prepared_statement_main_mem_root;
+PSI_memory_key key_memory_prepared_statement_map;
+PSI_memory_key key_memory_queue_item;
+PSI_memory_key key_memory_quick_range_select_root;
+PSI_memory_key key_memory_rpl_filter;
+PSI_memory_key key_memory_sp_cache;
+PSI_memory_key key_memory_sp_head_call_root;
+PSI_memory_key key_memory_sp_head_execute_root;
+PSI_memory_key key_memory_sp_head_main_root;
+PSI_memory_key key_memory_table_mapping_root;
+PSI_memory_key key_memory_table_share;
+PSI_memory_key key_memory_table_triggers_list;
+PSI_memory_key key_memory_thd_main_mem_root;
+PSI_memory_key key_memory_thd_transactions;
+PSI_memory_key key_memory_user_conn;
+PSI_memory_key key_memory_user_var_entry;
+PSI_memory_key key_memory_user_var_entry_value;
+
+PSI_memory_key key_memory_String_value;
+
+static PSI_memory_info all_server_memory[]=
+{
+ { &key_memory_locked_table_list, "Locked_tables_list::m_locked_tables_root", 0},
+ { &key_memory_locked_thread_list, "display_table_locks", PSI_FLAG_THREAD},
+ { &key_memory_thd_transactions, "THD::transactions::mem_root", PSI_FLAG_THREAD},
+// { &key_memory_delegate, "Delegate::memroot", 0},
+ { &key_memory_acl_mem, "sql_acl_mem", PSI_FLAG_GLOBAL},
+ { &key_memory_acl_memex, "sql_acl_memex", PSI_FLAG_GLOBAL},
+ { &key_memory_acl_cache, "acl_cache", PSI_FLAG_GLOBAL},
+ { &key_memory_thd_main_mem_root, "thd::main_mem_root", PSI_FLAG_THREAD},
+// { &key_memory_help, "help", 0},
+// { &key_memory_new_frm_mem, "new_frm_mem", 0},
+ { &key_memory_table_share, "TABLE_SHARE::mem_root", PSI_FLAG_GLOBAL}, /* table definition cache */
+ { &key_memory_gdl, "gdl", 0},
+ { &key_memory_table_triggers_list, "Table_triggers_list", 0},
+// { &key_memory_servers, "servers", 0},
+ { &key_memory_prepared_statement_map, "Prepared_statement_map", PSI_FLAG_THREAD},
+ { &key_memory_prepared_statement_main_mem_root, "Prepared_statement::main_mem_root", PSI_FLAG_THREAD},
+// { &key_memory_protocol_rset_root, "Protocol_local::m_rset_root", PSI_FLAG_THREAD},
+// { &key_memory_warning_info_warn_root, "Warning_info::m_warn_root", PSI_FLAG_THREAD},
+ { &key_memory_sp_cache, "THD::sp_cache", 0},
+ { &key_memory_sp_head_main_root, "sp_head::main_mem_root", 0},
+ { &key_memory_sp_head_execute_root, "sp_head::execute_mem_root", PSI_FLAG_THREAD},
+ { &key_memory_sp_head_call_root, "sp_head::call_mem_root", PSI_FLAG_THREAD},
+ { &key_memory_table_mapping_root, "table_mapping::m_mem_root", 0},
+ { &key_memory_quick_range_select_root, "QUICK_RANGE_SELECT::alloc", PSI_FLAG_THREAD},
+// { &key_memory_quick_index_merge_root, "QUICK_INDEX_MERGE_SELECT::alloc", PSI_FLAG_THREAD},
+// { &key_memory_quick_ror_intersect_select_root, "QUICK_ROR_INTERSECT_SELECT::alloc", PSI_FLAG_THREAD},
+// { &key_memory_quick_ror_union_select_root, "QUICK_ROR_UNION_SELECT::alloc", PSI_FLAG_THREAD},
+// { &key_memory_quick_group_min_max_select_root, "QUICK_GROUP_MIN_MAX_SELECT::alloc", PSI_FLAG_THREAD},
+// { &key_memory_test_quick_select_exec, "test_quick_select", PSI_FLAG_THREAD},
+// { &key_memory_prune_partitions_exec, "prune_partitions::exec", 0},
+ { &key_memory_binlog_recover_exec, "MYSQL_BIN_LOG::recover", 0},
+ { &key_memory_blob_mem_storage, "Blob_mem_storage::storage", 0},
+ { &key_memory_NAMED_ILINK_name, "NAMED_ILINK::name", 0},
+ { &key_memory_String_value, "String::value", 0},
+ { &key_memory_Sys_var_charptr_value, "Sys_var_charptr::value", 0},
+ { &key_memory_queue_item, "Queue::queue_item", 0},
+ { &key_memory_THD_db, "THD::db", 0},
+ { &key_memory_user_var_entry, "user_var_entry", 0},
+// { &key_memory_Slave_job_group_group_relay_log_name, "Slave_job_group::group_relay_log_name", 0},
+ { &key_memory_Relay_log_info_group_relay_log_name, "Relay_log_info::group_relay_log_name", 0},
+ { &key_memory_binlog_cache_mngr, "binlog_cache_mngr", 0},
+ { &key_memory_Row_data_memory_memory, "Row_data_memory::memory", 0},
+// { &key_memory_Gtid_set_to_string, "Gtid_set::to_string", 0},
+// { &key_memory_Gtid_state_to_string, "Gtid_state::to_string", 0},
+// { &key_memory_Owned_gtids_to_string, "Owned_gtids::to_string", 0},
+// { &key_memory_log_event, "Log_event", 0},
+// { &key_memory_Incident_log_event_message, "Incident_log_event::message", 0},
+// { &key_memory_Rows_query_log_event_rows_query, "Rows_query_log_event::rows_query", 0},
+ { &key_memory_Sort_param_tmp_buffer, "Sort_param::tmp_buffer", 0},
+ { &key_memory_Filesort_info_merge, "Filesort_info::merge", 0},
+ { &key_memory_Filesort_info_record_pointers, "Filesort_info::record_pointers", 0},
+// { &key_memory_Filesort_buffer_sort_keys, "Filesort_buffer::sort_keys", 0},
+ { &key_memory_handler_errmsgs, "handler::errmsgs", 0},
+ { &key_memory_handlerton, "handlerton", 0},
+ { &key_memory_XID, "XID", 0},
+ { &key_memory_host_cache_hostname, "host_cache::hostname", 0},
+ { &key_memory_user_var_entry_value, "user_var_entry::value", 0},
+ { &key_memory_User_level_lock, "User_level_lock", 0},
+ { &key_memory_MYSQL_LOG_name, "MYSQL_LOG::name", 0},
+ { &key_memory_TC_LOG_MMAP_pages, "TC_LOG_MMAP::pages", 0},
+// { &key_memory_my_bitmap_map, "my_bitmap_map", 0},
+ { &key_memory_QUICK_RANGE_SELECT_mrr_buf_desc, "QUICK_RANGE_SELECT::mrr_buf_desc", 0},
+ { &key_memory_Event_queue_element_for_exec_names, "Event_queue_element_for_exec::names", 0},
+ { &key_memory_my_str_malloc, "my_str_malloc", 0},
+ { &key_memory_MYSQL_BIN_LOG_basename, "MYSQL_BIN_LOG::basename", 0},
+ { &key_memory_MYSQL_BIN_LOG_index, "MYSQL_BIN_LOG::index", 0},
+ { &key_memory_MYSQL_RELAY_LOG_basename, "MYSQL_RELAY_LOG::basename", 0},
+ { &key_memory_MYSQL_RELAY_LOG_index, "MYSQL_RELAY_LOG::index", 0},
+ { &key_memory_rpl_filter, "rpl_filter memory", 0},
+ { &key_memory_errmsgs, "errmsgs", 0},
+ { &key_memory_Gis_read_stream_err_msg, "Gis_read_stream::err_msg", 0},
+// { &key_memory_Geometry_objects_data, "Geometry::ptr_and_wkb_data", 0},
+ { &key_memory_MYSQL_LOCK, "MYSQL_LOCK", 0},
+// { &key_memory_NET_buff, "NET::buff", 0},
+// { &key_memory_NET_compress_packet, "NET::compress_packet", 0},
+ { &key_memory_Event_scheduler_scheduler_param, "Event_scheduler::scheduler_param", 0},
+// { &key_memory_Gtid_set_Interval_chunk, "Gtid_set::Interval_chunk", 0},
+// { &key_memory_Owned_gtids_sidno_to_hash, "Owned_gtids::sidno_to_hash", 0},
+// { &key_memory_Sid_map_Node, "Sid_map::Node", 0},
+// { &key_memory_Gtid_state_group_commit_sidno, "Gtid_state::group_commit_sidno_locks", 0},
+// { &key_memory_Mutex_cond_array_Mutex_cond, "Mutex_cond_array::Mutex_cond", 0},
+ { &key_memory_TABLE_RULE_ENT, "TABLE_RULE_ENT", 0},
+// { &key_memory_Rpl_info_table, "Rpl_info_table", 0},
+ { &key_memory_Rpl_info_file_buffer, "Rpl_info_file::buffer", 0},
+// { &key_memory_db_worker_hash_entry, "db_worker_hash_entry", 0},
+// { &key_memory_rpl_slave_check_temp_dir, "rpl_slave::check_temp_dir", 0},
+// { &key_memory_rpl_slave_command_buffer, "rpl_slave::command_buffer", 0},
+ { &key_memory_binlog_ver_1_event, "binlog_ver_1_event", 0},
+ { &key_memory_SLAVE_INFO, "SLAVE_INFO", 0},
+ { &key_memory_binlog_pos, "binlog_pos", 0},
+// { &key_memory_HASH_ROW_ENTRY, "HASH_ROW_ENTRY", 0},
+ { &key_memory_binlog_statement_buffer, "binlog_statement_buffer", 0},
+// { &key_memory_partition_syntax_buffer, "partition_syntax_buffer", 0},
+// { &key_memory_READ_INFO, "READ_INFO", 0},
+ { &key_memory_JOIN_CACHE, "JOIN_CACHE", 0},
+// { &key_memory_TABLE_sort_io_cache, "TABLE::sort_io_cache", 0},
+// { &key_memory_frm, "frm", 0},
+ { &key_memory_Unique_sort_buffer, "Unique::sort_buffer", 0},
+ { &key_memory_Unique_merge_buffer, "Unique::merge_buffer", 0},
+ { &key_memory_TABLE, "TABLE", PSI_FLAG_GLOBAL}, /* Table cache */
+// { &key_memory_frm_extra_segment_buff, "frm::extra_segment_buff", 0},
+// { &key_memory_frm_form_pos, "frm::form_pos", 0},
+ { &key_memory_frm_string, "frm::string", 0},
+// { &key_memory_LOG_name, "LOG_name", 0},
+ { &key_memory_DATE_TIME_FORMAT, "DATE_TIME_FORMAT", 0},
+ { &key_memory_DDL_LOG_MEMORY_ENTRY, "DDL_LOG_MEMORY_ENTRY", 0},
+ { &key_memory_ST_SCHEMA_TABLE, "ST_SCHEMA_TABLE", 0},
+ { &key_memory_ignored_db, "ignored_db", 0},
+ { &key_memory_PROFILE, "PROFILE", 0},
+ { &key_memory_global_system_variables, "global_system_variables", 0},
+ { &key_memory_THD_variables, "THD::variables", 0},
+// { &key_memory_Security_context, "Security_context", 0},
+// { &key_memory_shared_memory_name, "Shared_memory_name", 0},
+ { &key_memory_bison_stack, "bison_stack", 0},
+ { &key_memory_THD_handler_tables_hash, "THD::handler_tables_hash", 0},
+ { &key_memory_hash_index_key_buffer, "hash_index_key_buffer", 0},
+ { &key_memory_dboptions_hash, "dboptions_hash", 0},
+ { &key_memory_user_conn, "user_conn", 0},
+// { &key_memory_LOG_POS_COORD, "LOG_POS_COORD", 0},
+// { &key_memory_XID_STATE, "XID_STATE", 0},
+ { &key_memory_MPVIO_EXT_auth_info, "MPVIO_EXT::auth_info", 0},
+// { &key_memory_opt_bin_logname, "opt_bin_logname", 0},
+ { &key_memory_Query_cache, "Query_cache", PSI_FLAG_GLOBAL},
+// { &key_memory_READ_RECORD_cache, "READ_RECORD_cache", 0},
+// { &key_memory_Quick_ranges, "Quick_ranges", 0},
+// { &key_memory_File_query_log_name, "File_query_log::name", 0},
+ { &key_memory_Table_trigger_dispatcher, "Table_trigger_dispatcher::m_mem_root", 0},
+// { &key_memory_thd_timer, "thd_timer", 0},
+// { &key_memory_THD_Session_tracker, "THD::Session_tracker", 0},
+// { &key_memory_THD_Session_sysvar_resource_manager, "THD::Session_sysvar_resource_manager", 0},
+// { &key_memory_show_slave_status_io_gtid_set, "show_slave_status_io_gtid_set", 0},
+// { &key_memory_write_set_extraction, "write_set_extraction", 0},
+// { &key_memory_get_all_tables, "get_all_tables", 0},
+// { &key_memory_fill_schema_schemata, "fill_schema_schemata", 0},
+ { &key_memory_native_functions, "native_functions", PSI_FLAG_GLOBAL},
+};
+
/**
Initialise all the performance schema instrumentation points
used by the server.
@@ -9449,6 +9681,9 @@ void init_server_psi_keys(void)
count= array_elements(all_server_sockets);
mysql_socket_register(category, all_server_sockets, count);
+ count= array_elements(all_server_memory);
+ mysql_memory_register(category, all_server_memory, count);
+
#ifdef HAVE_PSI_STATEMENT_INTERFACE
init_sql_statement_info();
count= array_elements(sql_statement_info);
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 4f4e608e811..74b71d397e5 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -394,7 +394,7 @@ extern PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file,
key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load,
key_file_loadfile, key_file_log_event_data, key_file_log_event_info,
- key_file_master_info, key_file_misc, key_file_partition,
+ key_file_master_info, key_file_misc, key_file_partition_ddl_log,
key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog,
key_file_trg, key_file_trn, key_file_init;
extern PSI_file_key key_file_query_log, key_file_slow_log;
@@ -406,6 +406,134 @@ extern PSI_file_key key_file_binlog_state;
void init_server_psi_keys();
#endif /* HAVE_PSI_INTERFACE */
+extern PSI_memory_key key_memory_locked_table_list;
+extern PSI_memory_key key_memory_locked_thread_list;
+extern PSI_memory_key key_memory_thd_transactions;
+extern PSI_memory_key key_memory_delegate;
+extern PSI_memory_key key_memory_acl_mem;
+extern PSI_memory_key key_memory_acl_memex;
+extern PSI_memory_key key_memory_acl_cache;
+extern PSI_memory_key key_memory_thd_main_mem_root;
+extern PSI_memory_key key_memory_help;
+extern PSI_memory_key key_memory_frm;
+extern PSI_memory_key key_memory_table_share;
+extern PSI_memory_key key_memory_gdl;
+extern PSI_memory_key key_memory_table_triggers_list;
+extern PSI_memory_key key_memory_prepared_statement_map;
+extern PSI_memory_key key_memory_prepared_statement_main_mem_root;
+extern PSI_memory_key key_memory_protocol_rset_root;
+extern PSI_memory_key key_memory_warning_info_warn_root;
+extern PSI_memory_key key_memory_sp_cache;
+extern PSI_memory_key key_memory_sp_head_main_root;
+extern PSI_memory_key key_memory_sp_head_execute_root;
+extern PSI_memory_key key_memory_sp_head_call_root;
+extern PSI_memory_key key_memory_table_mapping_root;
+extern PSI_memory_key key_memory_quick_range_select_root;
+extern PSI_memory_key key_memory_quick_index_merge_root;
+extern PSI_memory_key key_memory_quick_ror_intersect_select_root;
+extern PSI_memory_key key_memory_quick_ror_union_select_root;
+extern PSI_memory_key key_memory_quick_group_min_max_select_root;
+extern PSI_memory_key key_memory_test_quick_select_exec;
+extern PSI_memory_key key_memory_prune_partitions_exec;
+extern PSI_memory_key key_memory_binlog_recover_exec;
+extern PSI_memory_key key_memory_blob_mem_storage;
+
+extern PSI_memory_key key_memory_Sys_var_charptr_value;
+extern PSI_memory_key key_memory_THD_db;
+extern PSI_memory_key key_memory_user_var_entry;
+extern PSI_memory_key key_memory_user_var_entry_value;
+extern PSI_memory_key key_memory_Slave_job_group_group_relay_log_name;
+extern PSI_memory_key key_memory_Relay_log_info_group_relay_log_name;
+extern PSI_memory_key key_memory_binlog_cache_mngr;
+extern PSI_memory_key key_memory_Row_data_memory_memory;
+extern PSI_memory_key key_memory_errmsgs;
+extern PSI_memory_key key_memory_Event_queue_element_for_exec_names;
+extern PSI_memory_key key_memory_Event_scheduler_scheduler_param;
+extern PSI_memory_key key_memory_Gis_read_stream_err_msg;
+extern PSI_memory_key key_memory_Geometry_objects_data;
+extern PSI_memory_key key_memory_host_cache_hostname;
+extern PSI_memory_key key_memory_User_level_lock;
+extern PSI_memory_key key_memory_Filesort_info_record_pointers;
+extern PSI_memory_key key_memory_Sort_param_tmp_buffer;
+extern PSI_memory_key key_memory_Filesort_info_merge;
+extern PSI_memory_key key_memory_Filesort_buffer_sort_keys;
+extern PSI_memory_key key_memory_handler_errmsgs;
+extern PSI_memory_key key_memory_handlerton;
+extern PSI_memory_key key_memory_XID;
+extern PSI_memory_key key_memory_MYSQL_LOCK;
+extern PSI_memory_key key_memory_MYSQL_LOG_name;
+extern PSI_memory_key key_memory_TC_LOG_MMAP_pages;
+extern PSI_memory_key key_memory_my_str_malloc;
+extern PSI_memory_key key_memory_MYSQL_BIN_LOG_basename;
+extern PSI_memory_key key_memory_MYSQL_BIN_LOG_index;
+extern PSI_memory_key key_memory_MYSQL_RELAY_LOG_basename;
+extern PSI_memory_key key_memory_MYSQL_RELAY_LOG_index;
+extern PSI_memory_key key_memory_rpl_filter;
+extern PSI_memory_key key_memory_Security_context;
+extern PSI_memory_key key_memory_NET_buff;
+extern PSI_memory_key key_memory_NET_compress_packet;
+extern PSI_memory_key key_memory_my_bitmap_map;
+extern PSI_memory_key key_memory_QUICK_RANGE_SELECT_mrr_buf_desc;
+extern PSI_memory_key key_memory_TABLE_RULE_ENT;
+extern PSI_memory_key key_memory_Mutex_cond_array_Mutex_cond;
+extern PSI_memory_key key_memory_Owned_gtids_sidno_to_hash;
+extern PSI_memory_key key_memory_Sid_map_Node;
+extern PSI_memory_key key_memory_bison_stack;
+extern PSI_memory_key key_memory_TABLE_sort_io_cache;
+extern PSI_memory_key key_memory_DATE_TIME_FORMAT;
+extern PSI_memory_key key_memory_DDL_LOG_MEMORY_ENTRY;
+extern PSI_memory_key key_memory_ST_SCHEMA_TABLE;
+extern PSI_memory_key key_memory_ignored_db;
+extern PSI_memory_key key_memory_SLAVE_INFO;
+extern PSI_memory_key key_memory_log_event_old;
+extern PSI_memory_key key_memory_HASH_ROW_ENTRY;
+extern PSI_memory_key key_memory_table_def_memory;
+extern PSI_memory_key key_memory_MPVIO_EXT_auth_info;
+extern PSI_memory_key key_memory_LOG_POS_COORD;
+extern PSI_memory_key key_memory_XID_STATE;
+extern PSI_memory_key key_memory_Rpl_info_file_buffer;
+extern PSI_memory_key key_memory_Rpl_info_table;
+extern PSI_memory_key key_memory_binlog_pos;
+extern PSI_memory_key key_memory_db_worker_hash_entry;
+extern PSI_memory_key key_memory_rpl_slave_command_buffer;
+extern PSI_memory_key key_memory_binlog_ver_1_event;
+extern PSI_memory_key key_memory_rpl_slave_check_temp_dir;
+extern PSI_memory_key key_memory_TABLE;
+extern PSI_memory_key key_memory_binlog_statement_buffer;
+extern PSI_memory_key key_memory_user_conn;
+extern PSI_memory_key key_memory_dboptions_hash;
+extern PSI_memory_key key_memory_hash_index_key_buffer;
+extern PSI_memory_key key_memory_THD_handler_tables_hash;
+extern PSI_memory_key key_memory_JOIN_CACHE;
+extern PSI_memory_key key_memory_READ_INFO;
+extern PSI_memory_key key_memory_partition_syntax_buffer;
+extern PSI_memory_key key_memory_global_system_variables;
+extern PSI_memory_key key_memory_THD_variables;
+extern PSI_memory_key key_memory_PROFILE;
+extern PSI_memory_key key_memory_LOG_name;
+extern PSI_memory_key key_memory_string_iterator;
+extern PSI_memory_key key_memory_frm_extra_segment_buff;
+extern PSI_memory_key key_memory_frm_form_pos;
+extern PSI_memory_key key_memory_frm_string;
+extern PSI_memory_key key_memory_Unique_sort_buffer;
+extern PSI_memory_key key_memory_Unique_merge_buffer;
+extern PSI_memory_key key_memory_shared_memory_name;
+extern PSI_memory_key key_memory_opt_bin_logname;
+extern PSI_memory_key key_memory_Query_cache;
+extern PSI_memory_key key_memory_READ_RECORD_cache;
+extern PSI_memory_key key_memory_Quick_ranges;
+extern PSI_memory_key key_memory_File_query_log_name;
+extern PSI_memory_key key_memory_Table_trigger_dispatcher;
+extern PSI_memory_key key_memory_show_slave_status_io_gtid_set;
+extern PSI_memory_key key_memory_write_set_extraction;
+extern PSI_memory_key key_memory_thd_timer;
+extern PSI_memory_key key_memory_THD_Session_tracker;
+extern PSI_memory_key key_memory_THD_Session_sysvar_resource_manager;
+extern PSI_memory_key key_memory_get_all_tables;
+extern PSI_memory_key key_memory_fill_schema_schemata;
+extern PSI_memory_key key_memory_native_functions;
+extern PSI_memory_key key_memory_JSON;
+
/*
MAINTAINER: Please keep this list in order, to limit merge collisions.
Hint: grep PSI_stage_info | sort -u
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 4fecf8bffd0..840593cd2db 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -47,6 +47,9 @@
#include "probes_mysql.h"
#include "proxy_protocol.h"
+PSI_memory_key key_memory_NET_buff;
+PSI_memory_key key_memory_NET_compress_packet;
+
#ifdef EMBEDDED_LIBRARY
#undef MYSQL_SERVER
#undef MYSQL_CLIENT
@@ -176,8 +179,9 @@ my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags)
my_bool net_allocate_new_packet(NET *net, void *thd, uint my_flags)
{
DBUG_ENTER("net_allocate_new_packet");
- if (!(net->buff=(uchar*) my_malloc((size_t) net->max_packet+
- NET_HEADER_SIZE + COMP_HEADER_SIZE +1,
+ if (!(net->buff=(uchar*) my_malloc(key_memory_NET_buff,
+ (size_t) net->max_packet +
+ NET_HEADER_SIZE + COMP_HEADER_SIZE + 1,
MYF(MY_WME | my_flags))))
DBUG_RETURN(1);
net->buff_end=net->buff+net->max_packet;
@@ -221,11 +225,11 @@ my_bool net_realloc(NET *net, size_t length)
my_real_read() may actually read 4 bytes depending on build flags and
platform.
*/
- if (!(buff= (uchar*) my_realloc((char*) net->buff, pkt_length +
+ if (!(buff= (uchar*) my_realloc(key_memory_NET_buff,
+ (char*) net->buff, pkt_length +
NET_HEADER_SIZE + COMP_HEADER_SIZE + 1,
- MYF(MY_WME |
- (net->thread_specific_malloc ?
- MY_THREAD_SPECIFIC : 0)))))
+ MYF(MY_WME | (net->thread_specific_malloc
+ ? MY_THREAD_SPECIFIC : 0)))))
{
/* @todo: 1 and 2 codes are identical. */
net->error= 1;
@@ -636,11 +640,10 @@ net_real_write(NET *net,const uchar *packet, size_t len)
size_t complen;
uchar *b;
uint header_length=NET_HEADER_SIZE+COMP_HEADER_SIZE;
- if (!(b= (uchar*) my_malloc(len + NET_HEADER_SIZE +
- COMP_HEADER_SIZE + 1,
- MYF(MY_WME |
- (net->thread_specific_malloc ?
- MY_THREAD_SPECIFIC : 0)))))
+ if (!(b= (uchar*) my_malloc(key_memory_NET_compress_packet,
+ len + NET_HEADER_SIZE + COMP_HEADER_SIZE + 1,
+ MYF(MY_WME | (net->thread_specific_malloc
+ ? MY_THREAD_SPECIFIC : 0)))))
{
net->error= 2;
net->last_errno= ER_OUT_OF_RESOURCES;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index b4e2cfdf599..e3672d2c47f 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1267,9 +1267,8 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
if (!no_alloc && !parent_alloc)
{
// Allocates everything through the internal memroot
- init_sql_alloc(&alloc, "QUICK_RANGE_SELECT",
- thd->variables.range_alloc_block_size, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_quick_range_select_root, &alloc,
+ thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC));
thd->mem_root= &alloc;
}
else
@@ -1277,7 +1276,7 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
file= head->file;
record= head->record[0];
- my_init_dynamic_array2(&ranges, sizeof(QUICK_RANGE*),
+ my_init_dynamic_array2(&ranges, PSI_INSTRUMENT_ME, sizeof(QUICK_RANGE*),
thd->alloc(sizeof(QUICK_RANGE*) * 16), 16, 16,
MYF(MY_THREAD_SPECIFIC));
@@ -1363,9 +1362,8 @@ QUICK_INDEX_SORT_SELECT::QUICK_INDEX_SORT_SELECT(THD *thd_param, TABLE *table)
DBUG_ENTER("QUICK_INDEX_SORT_SELECT::QUICK_INDEX_SORT_SELECT");
index= MAX_KEY;
head= table;
- init_sql_alloc(&alloc, "QUICK_INDEX_SORT_SELECT",
- thd->variables.range_alloc_block_size, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_quick_range_select_root, &alloc,
+ thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC));
DBUG_VOID_RETURN;
}
@@ -1435,9 +1433,8 @@ QUICK_ROR_INTERSECT_SELECT::QUICK_ROR_INTERSECT_SELECT(THD *thd_param,
head= table;
record= head->record[0];
if (!parent_alloc)
- init_sql_alloc(&alloc, "QUICK_ROR_INTERSECT_SELECT",
- thd->variables.range_alloc_block_size, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_quick_range_select_root, &alloc,
+ thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC));
else
bzero(&alloc, sizeof(MEM_ROOT));
last_rowid= (uchar*) alloc_root(parent_alloc? parent_alloc : &alloc,
@@ -1713,9 +1710,8 @@ QUICK_ROR_UNION_SELECT::QUICK_ROR_UNION_SELECT(THD *thd_param,
head= table;
rowid_length= table->file->ref_length;
record= head->record[0];
- init_sql_alloc(&alloc, "QUICK_ROR_UNION_SELECT",
- thd->variables.range_alloc_block_size, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_quick_range_select_root, &alloc,
+ thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC));
thd_param->mem_root= &alloc;
}
@@ -2726,9 +2722,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
param.possible_keys.clear_all();
thd->no_errors=1; // Don't warn about NULL
- init_sql_alloc(&alloc, "test_quick_select",
- thd->variables.range_alloc_block_size, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_quick_range_select_root, &alloc,
+ thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC));
if (!(param.key_parts=
(KEY_PART*) alloc_root(&alloc,
sizeof(KEY_PART) *
@@ -3407,9 +3402,8 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
SEL_TREE *tree;
double rows;
- init_sql_alloc(&alloc, "calculate_cond_selectivity_for_table",
- thd->variables.range_alloc_block_size, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_quick_range_select_root, &alloc,
+ thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC));
param.thd= thd;
param.mem_root= &alloc;
param.old_root= thd->mem_root;
@@ -3839,9 +3833,8 @@ bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond)
my_bitmap_map *old_sets[2];
prune_param.part_info= part_info;
- init_sql_alloc(&alloc, "prune_partitions",
- thd->variables.range_alloc_block_size, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_quick_range_select_root, &alloc,
+ thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC));
range_par->mem_root= &alloc;
range_par->old_root= thd->mem_root;
@@ -12098,7 +12091,8 @@ int QUICK_RANGE_SELECT::reset()
if (mrr_buf_size && !mrr_buf_desc)
{
buf_size= mrr_buf_size;
- while (buf_size && !my_multi_malloc(MYF(MY_WME),
+ while (buf_size && !my_multi_malloc(key_memory_QUICK_RANGE_SELECT_mrr_buf_desc,
+ MYF(MY_WME),
&mrr_buf_desc, sizeof(*mrr_buf_desc),
&mrange_buff, buf_size,
NullS))
@@ -14450,10 +14444,10 @@ QUICK_GROUP_MIN_MAX_SELECT(TABLE *table, JOIN *join_arg, bool have_min_arg,
DBUG_ASSERT(!parent_alloc);
if (!parent_alloc)
{
- init_sql_alloc(&alloc, "QUICK_GROUP_MIN_MAX_SELECT",
- join->thd->variables.range_alloc_block_size, 0,
- MYF(MY_THREAD_SPECIFIC));
- join->thd->mem_root= &alloc;
+ THD *thd= join->thd;
+ init_sql_alloc(key_memory_quick_range_select_root, &alloc,
+ thd->variables.range_alloc_block_size, 0, MYF(MY_THREAD_SPECIFIC));
+ thd->mem_root= &alloc;
}
else
bzero(&alloc, sizeof(MEM_ROOT)); // ensure that it's not used
@@ -14513,8 +14507,8 @@ int QUICK_GROUP_MIN_MAX_SELECT::init()
if (min_max_arg_part)
{
- if (my_init_dynamic_array(&min_max_ranges, sizeof(QUICK_RANGE*), 16, 16,
- MYF(MY_THREAD_SPECIFIC)))
+ if (my_init_dynamic_array(&min_max_ranges, PSI_INSTRUMENT_ME,
+ sizeof(QUICK_RANGE*), 16, 16, MYF(MY_THREAD_SPECIFIC)))
return 1;
if (have_min)
diff --git a/sql/opt_split.cc b/sql/opt_split.cc
index 6f8248c315c..8fe3749c2df 100644
--- a/sql/opt_split.cc
+++ b/sql/opt_split.cc
@@ -341,7 +341,7 @@ bool JOIN::check_for_splittable_materialized()
return false;
ORDER *ord;
- Dynamic_array<SplM_field_ext_info> candidates;
+ Dynamic_array<SplM_field_ext_info> candidates(PSI_INSTRUMENT_MEM);
/*
Select from partition_list all candidates for splitting.
@@ -712,7 +712,7 @@ void JOIN::add_keyuses_for_splitting()
KEY_FIELD *added_key_field;
if (!spl_opt_info->added_key_fields.elements)
goto err;
- if (!(ext_keyuses_for_splitting= new Dynamic_array<KEYUSE_EXT>))
+ if (!(ext_keyuses_for_splitting= new Dynamic_array<KEYUSE_EXT>(PSI_INSTRUMENT_MEM)))
goto err;
while ((added_key_field= li++))
{
@@ -742,13 +742,11 @@ void JOIN::add_keyuses_for_splitting()
save_query_plan(save_qep);
if (!keyuse.buffer &&
- my_init_dynamic_array(&keyuse, sizeof(KEYUSE), 20, 64,
- MYF(MY_THREAD_SPECIFIC)))
+ my_init_dynamic_array(&keyuse, PSI_INSTRUMENT_ME, sizeof(KEYUSE),
+ 20, 64, MYF(MY_THREAD_SPECIFIC)))
goto err;
- if (allocate_dynamic(&keyuse,
- save_qep->keyuse.elements +
- added_keyuse_count))
+ if (allocate_dynamic(&keyuse, save_qep->keyuse.elements + added_keyuse_count))
goto err;
memcpy(keyuse.buffer,
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index c7d95fdadec..6c491300d17 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -4470,8 +4470,8 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd)
using_unique_constraint= TRUE;
/* STEP 3: Allocate memory for temptable description */
- init_sql_alloc(&own_root, "SJ_TMP_TABLE",
- TABLE_ALLOC_BLOCK_SIZE, 0, MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(PSI_INSTRUMENT_ME, &own_root, TABLE_ALLOC_BLOCK_SIZE, 0,
+ MYF(MY_THREAD_SPECIFIC));
if (!multi_alloc_root(&own_root,
&table, sizeof(*table),
&share, sizeof(*share),
diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc
index 7ff11e65a30..057c6f3cc0a 100644
--- a/sql/opt_trace.cc
+++ b/sql/opt_trace.cc
@@ -449,7 +449,7 @@ bool Opt_trace_context::is_enabled()
return false;
}
-Opt_trace_context::Opt_trace_context()
+Opt_trace_context::Opt_trace_context() : traces(PSI_INSTRUMENT_MEM)
{
current_trace= NULL;
max_mem_size= 0;
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 252744a3a73..5a0e7426713 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -734,7 +734,8 @@ char *partition_info::find_duplicate_name()
if (is_sub_partitioned())
max_names+= num_parts * num_subparts;
if (my_hash_init(&partition_names, system_charset_info, max_names, 0, 0,
- (my_hash_get_key) get_part_name_from_elem, 0, HASH_UNIQUE))
+ (my_hash_get_key) get_part_name_from_elem, 0, HASH_UNIQUE,
+ PSI_INSTRUMENT_ME))
{
DBUG_ASSERT(0);
curr_name= (const uchar*) "Internal failure";
diff --git a/sql/proxy_protocol.cc b/sql/proxy_protocol.cc
index 550813c6457..689d1af88f0 100644
--- a/sql/proxy_protocol.cc
+++ b/sql/proxy_protocol.cc
@@ -364,7 +364,8 @@ static int parse_networks(const char *subnets_str, subnet **out_subnets, size_t
}
max_subnets= MY_MAX(3,strlen(subnets_str)/2);
- subnets= (subnet *)my_malloc(max_subnets * sizeof(subnet),MY_ZEROFILL);
+ subnets= (subnet *)my_malloc(PSI_INSTRUMENT_ME,
+ max_subnets * sizeof(subnet), MY_ZEROFILL);
/* Check for special case '*'. */
if (strcmp(subnets_str, "*") == 0)
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 7905e112e2e..09b3269371e 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -101,7 +101,7 @@ void THD::unregister_slave()
mysql_mutex_lock(&LOCK_thd_data);
slave_info= 0;
mysql_mutex_unlock(&LOCK_thd_data);
- delete old_si;
+ my_free(old_si);
binlog_dump_thread_count--;
}
}
@@ -124,7 +124,8 @@ int THD::register_slave(uchar *packet, size_t packet_length)
if (check_access(this, REPL_SLAVE_ACL, any_db, NULL, NULL, 0, 0))
return 1;
- if (!(si= new Slave_info))
+ if (!(si= (Slave_info*)my_malloc(key_memory_SLAVE_INFO, sizeof(Slave_info),
+ MYF(MY_WME))))
return 1;
variables.server_id= si->server_id= uint4korr(p);
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index e96f9640098..d9dc7e499ea 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -286,7 +286,7 @@ Rpl_filter::parse_filter_rule(const char* spec, Add_filter add)
if (!spec)
return false;
- if (! (ptr= my_strdup(spec, MYF(MY_WME))))
+ if (! (ptr= my_strdup(key_memory_rpl_filter, spec, MYF(MY_WME))))
return true;
pstr= ptr;
@@ -461,8 +461,9 @@ Rpl_filter::add_table_rule(HASH* h, const char* table_spec)
if (!dot) return 1;
// len is always > 0 because we know the there exists a '.'
uint len = (uint)strlen(table_spec);
- TABLE_RULE_ENT* e = (TABLE_RULE_ENT*)my_malloc(sizeof(TABLE_RULE_ENT)
- + len, MYF(MY_WME));
+ TABLE_RULE_ENT* e = (TABLE_RULE_ENT*)my_malloc(key_memory_TABLE_RULE_ENT,
+ sizeof(TABLE_RULE_ENT) + len,
+ MYF(MY_WME));
if (!e) return 1;
e->db= (char*)e + sizeof(TABLE_RULE_ENT);
e->tbl_name= e->db + (dot - table_spec) + 1;
@@ -483,8 +484,9 @@ Rpl_filter::add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec)
const char* dot = strchr(table_spec, '.');
if (!dot) return 1;
uint len = (uint)strlen(table_spec);
- TABLE_RULE_ENT* e = (TABLE_RULE_ENT*)my_malloc(sizeof(TABLE_RULE_ENT)
- + len, MYF(MY_WME));
+ TABLE_RULE_ENT* e = (TABLE_RULE_ENT*)my_malloc(key_memory_TABLE_RULE_ENT,
+ sizeof(TABLE_RULE_ENT) + len,
+ MYF(MY_WME));
if (!e) return 1;
e->db= (char*)e + sizeof(TABLE_RULE_ENT);
e->tbl_name= e->db + (dot - table_spec) + 1;
@@ -500,7 +502,7 @@ Rpl_filter::add_string_list(I_List<i_string> *list, const char* spec)
char *str;
i_string *node;
- if (! (str= my_strdup(spec, MYF(MY_WME))))
+ if (! (str= my_strdup(key_memory_rpl_filter, spec, MYF(MY_WME))))
return true;
if (! (node= new i_string(str)))
@@ -572,7 +574,7 @@ void
Rpl_filter::init_table_rule_hash(HASH* h, bool* h_inited)
{
my_hash_init(h, system_charset_info,TABLE_RULE_HASH_SIZE,0,0,
- get_table_key, free_table_ent, 0);
+ get_table_key, free_table_ent, 0, key_memory_TABLE_RULE_ENT);
*h_inited = 1;
}
@@ -580,8 +582,8 @@ Rpl_filter::init_table_rule_hash(HASH* h, bool* h_inited)
void
Rpl_filter::init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited)
{
- my_init_dynamic_array(a, sizeof(TABLE_RULE_ENT*), TABLE_RULE_ARR_SIZE,
- TABLE_RULE_ARR_SIZE, MYF(0));
+ my_init_dynamic_array(a, key_memory_TABLE_RULE_ENT, sizeof(TABLE_RULE_ENT*),
+ TABLE_RULE_ARR_SIZE, TABLE_RULE_ARR_SIZE, MYF(0));
*a_inited = 1;
}
diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc
index 599129b98f4..e9c1dc8c5d7 100644
--- a/sql/rpl_gtid.cc
+++ b/sql/rpl_gtid.cc
@@ -249,8 +249,10 @@ rpl_slave_state::rpl_slave_state()
mysql_mutex_init(key_LOCK_slave_state, &LOCK_slave_state,
MY_MUTEX_INIT_SLOW);
my_hash_init(&hash, &my_charset_bin, 32, offsetof(element, domain_id),
- sizeof(uint32), NULL, rpl_slave_state_free_element, HASH_UNIQUE);
- my_init_dynamic_array(&gtid_sort_array, sizeof(rpl_gtid), 8, 8, MYF(0));
+ sizeof(uint32), NULL, rpl_slave_state_free_element, HASH_UNIQUE,
+ PSI_INSTRUMENT_ME);
+ my_init_dynamic_array(&gtid_sort_array, PSI_INSTRUMENT_ME, sizeof(rpl_gtid),
+ 8, 8, MYF(0));
}
@@ -333,7 +335,8 @@ rpl_slave_state::update(uint32 domain_id, uint32 server_id, uint64 sub_id,
rgi->gtid_ignore_duplicate_state= rpl_group_info::GTID_DUPLICATE_NULL;
}
- if (!(list_elem= (list_element *)my_malloc(sizeof(*list_elem), MYF(MY_WME))))
+ if (!(list_elem= (list_element *)my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(*list_elem), MYF(MY_WME))))
return 1;
list_elem->domain_id= domain_id;
list_elem->server_id= server_id;
@@ -367,7 +370,7 @@ rpl_slave_state::get_element(uint32 domain_id)
if (elem)
return elem;
- if (!(elem= (element *)my_malloc(sizeof(*elem), MYF(MY_WME))))
+ if (!(elem= (element *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*elem), MYF(MY_WME))))
return NULL;
elem->list= NULL;
elem->domain_id= domain_id;
@@ -1112,7 +1115,7 @@ rpl_slave_state::iterate(int (*cb)(rpl_gtid *, void *), void *data,
bool locked= false;
my_hash_init(&gtid_hash, &my_charset_bin, 32, offsetof(rpl_gtid, domain_id),
- sizeof(uint32), NULL, NULL, HASH_UNIQUE);
+ sizeof(uint32), NULL, NULL, HASH_UNIQUE, PSI_INSTRUMENT_ME);
for (i= 0; i < num_extra; ++i)
if (extra_gtids[i].server_id == global_system_variables.server_id &&
my_hash_insert(&gtid_hash, (uchar *)(&extra_gtids[i])))
@@ -1329,7 +1332,7 @@ gtid_parse_string_to_list(const char *str, size_t str_len, uint32 *out_len)
}
if ((!list || len >= alloc_len) &&
!(list=
- (rpl_gtid *)my_realloc(list,
+ (rpl_gtid *)my_realloc(PSI_INSTRUMENT_ME, list,
(alloc_len= alloc_len*2) * sizeof(rpl_gtid),
MYF(MY_FREE_ON_ERROR|MY_ALLOW_ZERO_PTR))))
return NULL;
@@ -1466,10 +1469,8 @@ rpl_slave_state::alloc_gtid_pos_table(LEX_CSTRING *table_name, void *hton,
struct gtid_pos_table *p;
char *allocated_str;
- if (!my_multi_malloc(MYF(MY_WME),
- &p, sizeof(*p),
- &allocated_str, table_name->length+1,
- NULL))
+ if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME), &p, sizeof(*p),
+ &allocated_str, table_name->length+1, NULL))
{
my_error(ER_OUTOFMEMORY, MYF(0), (int)(sizeof(*p) + table_name->length+1));
return NULL;
@@ -1487,8 +1488,8 @@ rpl_slave_state::alloc_gtid_pos_table(LEX_CSTRING *table_name, void *hton,
void rpl_binlog_state::init()
{
my_hash_init(&hash, &my_charset_bin, 32, offsetof(element, domain_id),
- sizeof(uint32), NULL, my_free, HASH_UNIQUE);
- my_init_dynamic_array(&gtid_sort_array, sizeof(rpl_gtid), 8, 8, MYF(0));
+ sizeof(uint32), NULL, my_free, HASH_UNIQUE, PSI_INSTRUMENT_ME);
+ my_init_dynamic_array(&gtid_sort_array, PSI_INSTRUMENT_ME, sizeof(rpl_gtid), 8, 8, MYF(0));
mysql_mutex_init(key_LOCK_binlog_state, &LOCK_binlog_state,
MY_MUTEX_INIT_SLOW);
initialized= 1;
@@ -1685,7 +1686,8 @@ rpl_binlog_state::element::update_element(const rpl_gtid *gtid)
}
/* Allocate a new GTID and insert it. */
- lookup_gtid= (rpl_gtid *)my_malloc(sizeof(*lookup_gtid), MYF(MY_WME));
+ lookup_gtid= (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*lookup_gtid),
+ MYF(MY_WME));
if (!lookup_gtid)
return 1;
memcpy(lookup_gtid, gtid, sizeof(*lookup_gtid));
@@ -1706,14 +1708,15 @@ rpl_binlog_state::alloc_element_nolock(const rpl_gtid *gtid)
rpl_gtid *lookup_gtid;
/* First time we see this domain_id; allocate a new element. */
- elem= (element *)my_malloc(sizeof(*elem), MYF(MY_WME));
- lookup_gtid= (rpl_gtid *)my_malloc(sizeof(*lookup_gtid), MYF(MY_WME));
+ elem= (element *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*elem), MYF(MY_WME));
+ lookup_gtid= (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*lookup_gtid),
+ MYF(MY_WME));
if (elem && lookup_gtid)
{
elem->domain_id= gtid->domain_id;
my_hash_init(&elem->hash, &my_charset_bin, 32,
offsetof(rpl_gtid, server_id), sizeof(uint32), NULL, my_free,
- HASH_UNIQUE);
+ HASH_UNIQUE, PSI_INSTRUMENT_ME);
elem->last_gtid= lookup_gtid;
elem->seq_no_counter= gtid->seq_no;
memcpy(lookup_gtid, gtid, sizeof(*lookup_gtid));
@@ -1784,7 +1787,8 @@ rpl_binlog_state::bump_seq_no_if_needed(uint32 domain_id, uint64 seq_no)
}
/* We need to allocate a new, empty element to remember the next seq_no. */
- if (!(elem= (element *)my_malloc(sizeof(*elem), MYF(MY_WME))))
+ if (!(elem= (element *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*elem),
+ MYF(MY_WME))))
{
res= 1;
goto end;
@@ -1793,7 +1797,7 @@ rpl_binlog_state::bump_seq_no_if_needed(uint32 domain_id, uint64 seq_no)
elem->domain_id= domain_id;
my_hash_init(&elem->hash, &my_charset_bin, 32,
offsetof(rpl_gtid, server_id), sizeof(uint32), NULL, my_free,
- HASH_UNIQUE);
+ HASH_UNIQUE, PSI_INSTRUMENT_ME);
elem->last_gtid= NULL;
elem->seq_no_counter= seq_no;
if (0 == my_hash_insert(&hash, (const uchar *)elem))
@@ -2006,8 +2010,8 @@ rpl_binlog_state::get_most_recent_gtid_list(rpl_gtid **list, uint32 *size)
out_size= 0;
mysql_mutex_lock(&LOCK_binlog_state);
alloc_size= hash.records;
- if (!(*list= (rpl_gtid *)my_malloc(alloc_size * sizeof(rpl_gtid),
- MYF(MY_WME))))
+ if (!(*list= (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME,
+ alloc_size * sizeof(rpl_gtid), MYF(MY_WME))))
{
res= 1;
goto end;
@@ -2122,7 +2126,7 @@ rpl_binlog_state::drop_domain(DYNAMIC_ARRAY *ids,
DBUG_ENTER("rpl_binlog_state::drop_domain");
- my_init_dynamic_array2(&domain_unique,
+ my_init_dynamic_array2(&domain_unique, PSI_INSTRUMENT_ME,
sizeof(element*), domain_unique_buffer,
sizeof(domain_unique_buffer) / sizeof(element*), 4, 0);
@@ -2249,8 +2253,8 @@ slave_connection_state::slave_connection_state()
{
my_hash_init(&hash, &my_charset_bin, 32,
offsetof(entry, gtid) + offsetof(rpl_gtid, domain_id),
- sizeof(uint32), NULL, my_free, HASH_UNIQUE);
- my_init_dynamic_array(&gtid_sort_array, sizeof(rpl_gtid), 8, 8, MYF(0));
+ sizeof(uint32), NULL, my_free, HASH_UNIQUE, PSI_INSTRUMENT_ME);
+ my_init_dynamic_array(&gtid_sort_array, PSI_INSTRUMENT_ME, sizeof(rpl_gtid), 8, 8, MYF(0));
}
@@ -2294,7 +2298,7 @@ slave_connection_state::load(const char *slave_request, size_t len)
return 0;
for (;;)
{
- if (!(rec= (uchar *)my_malloc(sizeof(entry), MYF(MY_WME))))
+ if (!(rec= (uchar *)my_malloc(PSI_INSTRUMENT_ME, sizeof(entry), MYF(MY_WME))))
return 1;
gtid= &((entry *)rec)->gtid;
if (gtid_parser_helper(&p, end, gtid))
@@ -2397,7 +2401,7 @@ slave_connection_state::update(const rpl_gtid *in_gtid)
return 0;
}
- if (!(e= (entry *)my_malloc(sizeof(*e), MYF(MY_WME))))
+ if (!(e= (entry *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*e), MYF(MY_WME))))
return 1;
e->gtid= *in_gtid;
e->flags= 0;
@@ -2875,7 +2879,7 @@ gtid_waiting::init()
{
my_hash_init(&hash, &my_charset_bin, 32,
offsetof(hash_element, domain_id), sizeof(uint32), NULL,
- free_hash_element, HASH_UNIQUE);
+ free_hash_element, HASH_UNIQUE, PSI_INSTRUMENT_ME);
mysql_mutex_init(key_LOCK_gtid_waiting, &LOCK_gtid_waiting, 0);
}
@@ -2910,7 +2914,7 @@ gtid_waiting::get_entry(uint32 domain_id)
if ((e= (hash_element *)my_hash_search(&hash, (const uchar *)&domain_id, 0)))
return e;
- if (!(e= (hash_element *)my_malloc(sizeof(*e), MYF(MY_WME))))
+ if (!(e= (hash_element *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*e), MYF(MY_WME))))
return NULL;
if (init_queue(&e->queue, 8, offsetof(queue_element, wait_seq_no), 0,
diff --git a/sql/rpl_injector.cc b/sql/rpl_injector.cc
index 597a357e4e2..b0b6e30bed6 100644
--- a/sql/rpl_injector.cc
+++ b/sql/rpl_injector.cc
@@ -37,7 +37,8 @@ injector::transaction::transaction(MYSQL_BIN_LOG *log, THD *thd)
LOG_INFO log_info;
log->get_current_log(&log_info);
/* !!! binlog_pos does not follow RAII !!! */
- m_start_pos.m_file_name= my_strdup(log_info.log_file_name, MYF(0));
+ m_start_pos.m_file_name= my_strdup(key_memory_binlog_pos,
+ log_info.log_file_name, MYF(0));
m_start_pos.m_file_pos= log_info.pos;
m_thd->lex->start_transaction_opt= 0; /* for begin_trans() */
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index f3c87517f21..fcbd988509d 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -58,7 +58,7 @@ Master_info::Master_info(LEX_CSTRING *connection_name_arg,
connection_name.length= cmp_connection_name.length=
connection_name_arg->length;
if ((connection_name.str= tmp= (char*)
- my_malloc(connection_name_arg->length*2+2, MYF(MY_WME))))
+ my_malloc(PSI_INSTRUMENT_ME, connection_name_arg->length*2+2, MYF(MY_WME))))
{
strmake(tmp, connection_name_arg->str, connection_name.length);
tmp+= connection_name_arg->length+1;
@@ -77,7 +77,7 @@ Master_info::Master_info(LEX_CSTRING *connection_name_arg,
parallel_mode= rpl_filter->get_parallel_mode();
- my_init_dynamic_array(&ignore_server_ids,
+ my_init_dynamic_array(&ignore_server_ids, PSI_INSTRUMENT_ME,
sizeof(global_system_variables.server_id), 16, 16,
MYF(0));
bzero((char*) &file, sizeof(file));
@@ -742,7 +742,8 @@ int flush_master_info(Master_info* mi,
char* ignore_server_ids_buf;
{
ignore_server_ids_buf=
- (char *) my_malloc((sizeof(global_system_variables.server_id) * 3 + 1) *
+ (char *) my_malloc(PSI_INSTRUMENT_ME,
+ (sizeof(global_system_variables.server_id) * 3 + 1) *
(1 + mi->ignore_server_ids.elements), MYF(MY_WME));
if (!ignore_server_ids_buf)
DBUG_RETURN(1); /* error */
@@ -1101,7 +1102,8 @@ bool Master_info_index::init_all_master_info()
if (my_hash_init(&master_info_hash, system_charset_info,
MAX_REPLICATION_THREAD, 0, 0,
(my_hash_get_key) get_key_master_info,
- (my_hash_free_key)free_key_master_info, HASH_UNIQUE))
+ (my_hash_free_key)free_key_master_info, HASH_UNIQUE,
+ PSI_INSTRUMENT_ME))
{
sql_print_error("Initializing Master_info hash table failed");
DBUG_RETURN(1);
@@ -1741,7 +1743,8 @@ Domain_id_filter::Domain_id_filter() : m_filter(false)
{
for (int i= DO_DOMAIN_IDS; i <= IGNORE_DOMAIN_IDS; i ++)
{
- my_init_dynamic_array(&m_domain_ids[i], sizeof(ulong), 16, 16, MYF(0));
+ my_init_dynamic_array(&m_domain_ids[i], PSI_INSTRUMENT_ME,
+ sizeof(ulong), 16, 16, MYF(0));
}
}
@@ -1904,7 +1907,7 @@ char *Domain_id_filter::as_string(enum_list_type type)
sz= (sizeof(ulong) * 3 + 1) * (1 + ids->elements);
- if (!(buf= (char *) my_malloc(sz, MYF(MY_WME))))
+ if (!(buf= (char *) my_malloc(PSI_INSTRUMENT_ME, sz, MYF(MY_WME))))
return NULL;
// Store the total number of elements followed by the individual elements.
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index 4313840119e..cbdc5a548be 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -1557,7 +1557,7 @@ rpl_parallel_change_thread_count(rpl_parallel_thread_pool *pool,
to allocate, and will not be left with a half-functional thread pool.
*/
if (new_count &&
- !my_multi_malloc(MYF(MY_WME|MY_ZEROFILL),
+ !my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME|MY_ZEROFILL),
&new_list, new_count*sizeof(*new_list),
&rpt_array, new_count*sizeof(*rpt_array),
NULL))
@@ -1789,7 +1789,7 @@ rpl_parallel_thread::get_qev_common(Log_event *ev, ulonglong event_size)
mysql_mutex_assert_owner(&LOCK_rpl_thread);
if ((qev= qev_free_list))
qev_free_list= qev->next;
- else if(!(qev= (queued_event *)my_malloc(sizeof(*qev), MYF(0))))
+ else if(!(qev= (queued_event *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*qev), MYF(0))))
{
my_error(ER_OUTOFMEMORY, MYF(0), (int)sizeof(*qev));
return NULL;
@@ -1952,7 +1952,7 @@ rpl_parallel_thread::get_gco(uint64 wait_count, group_commit_orderer *prev,
mysql_mutex_assert_owner(&LOCK_rpl_thread);
if ((gco= gco_free_list))
gco_free_list= gco->next_gco;
- else if(!(gco= (group_commit_orderer *)my_malloc(sizeof(*gco), MYF(0))))
+ else if(!(gco= (group_commit_orderer *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*gco), MYF(0))))
{
my_error(ER_OUTOFMEMORY, MYF(0), (int)sizeof(*gco));
return NULL;
@@ -2201,7 +2201,7 @@ rpl_parallel::rpl_parallel() :
{
my_hash_init(&domain_hash, &my_charset_bin, 32,
offsetof(rpl_parallel_entry, domain_id), sizeof(uint32),
- NULL, free_rpl_parallel_entry, HASH_UNIQUE);
+ NULL, free_rpl_parallel_entry, HASH_UNIQUE, PSI_INSTRUMENT_ME);
}
@@ -2233,7 +2233,7 @@ rpl_parallel::find(uint32 domain_id)
if (count == 0 || count > opt_slave_parallel_threads)
count= opt_slave_parallel_threads;
rpl_parallel_thread **p;
- if (!my_multi_malloc(MYF(MY_WME|MY_ZEROFILL),
+ if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME|MY_ZEROFILL),
&e, sizeof(*e),
&p, count*sizeof(*p),
NULL))
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 6d55b06b497..c4ca425aaa2 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -1435,14 +1435,15 @@ Relay_log_info::alloc_inuse_relaylog(const char *name)
uint32 gtid_count;
rpl_gtid *gtid_list;
- if (!(ir= (inuse_relaylog *)my_malloc(sizeof(*ir), MYF(MY_WME|MY_ZEROFILL))))
+ if (!(ir= (inuse_relaylog *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*ir),
+ MYF(MY_WME|MY_ZEROFILL))))
{
my_error(ER_OUTOFMEMORY, MYF(0), (int)sizeof(*ir));
return 1;
}
gtid_count= relay_log_state.count();
- if (!(gtid_list= (rpl_gtid *)my_malloc(sizeof(*gtid_list)*gtid_count,
- MYF(MY_WME))))
+ if (!(gtid_list= (rpl_gtid *)my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(*gtid_list)*gtid_count, MYF(MY_WME))))
{
my_free(ir);
my_error(ER_OUTOFMEMORY, MYF(0), (int)sizeof(*gtid_list)*gtid_count);
@@ -1589,8 +1590,8 @@ scan_one_gtid_slave_pos_table(THD *thd, HASH *hash, DYNAMIC_ARRAY *array,
}
else
{
- if (!(entry= (struct gtid_pos_element *)my_malloc(sizeof(*entry),
- MYF(MY_WME))))
+ if (!(entry= (struct gtid_pos_element *)my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(*entry), MYF(MY_WME))))
{
my_error(ER_OUTOFMEMORY, MYF(0), (int)sizeof(*entry));
err= 1;
@@ -1833,8 +1834,9 @@ rpl_load_gtid_slave_state(THD *thd)
cb_data.default_entry= NULL;
my_hash_init(&hash, &my_charset_bin, 32,
offsetof(gtid_pos_element, gtid) + offsetof(rpl_gtid, domain_id),
- sizeof(uint32), NULL, my_free, HASH_UNIQUE);
- if ((err= my_init_dynamic_array(&array, sizeof(gtid_pos_element), 0, 0, MYF(0))))
+ sizeof(uint32), NULL, my_free, HASH_UNIQUE, PSI_INSTRUMENT_ME);
+ if ((err= my_init_dynamic_array(&array, PSI_INSTRUMENT_ME,
+ sizeof(gtid_pos_element), 0, 0, MYF(0))))
goto end;
array_inited= true;
diff --git a/sql/rpl_tblmap.cc b/sql/rpl_tblmap.cc
index b2da9092e3a..db0c11473d1 100644
--- a/sql/rpl_tblmap.cc
+++ b/sql/rpl_tblmap.cc
@@ -34,6 +34,12 @@
table_mapping::table_mapping()
: m_free(0)
{
+#ifdef MYSQL_CLIENT
+ PSI_memory_key psi_key= PSI_NOT_INSTRUMENTED;
+#else
+ PSI_memory_key psi_key= key_memory_table_mapping_root;
+#endif
+
DBUG_ENTER("table_mapping::table_mapping");
/*
No "free_element" function for entries passed here, as the entries are
@@ -44,10 +50,9 @@ table_mapping::table_mapping()
*/
(void) my_hash_init(&m_table_ids,&my_charset_bin,TABLE_ID_HASH_SIZE,
offsetof(entry,table_id),sizeof(ulonglong),
- 0,0,0);
+ 0,0,0, psi_key);
/* We don't preallocate any block, this is consistent with m_free=0 above */
- init_alloc_root(&m_mem_root, "table_mapping",
- TABLE_ID_HASH_SIZE*sizeof(entry), 0, MYF(0));
+ init_alloc_root(psi_key, &m_mem_root, TABLE_ID_HASH_SIZE*sizeof(entry), 0, MYF(0));
DBUG_VOID_RETURN;
}
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index 1e4b59844b8..7c347eba51f 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -171,6 +171,7 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
return length;
}
+PSI_memory_key key_memory_table_def_memory;
table_def::table_def(unsigned char *types, ulong size,
uchar *field_metadata, int metadata_size,
@@ -179,7 +180,7 @@ table_def::table_def(unsigned char *types, ulong size,
m_field_metadata(0), m_null_bits(0), m_flags(flags),
m_memory(NULL)
{
- m_memory= (uchar *)my_multi_malloc(MYF(MY_WME),
+ m_memory= (uchar *)my_multi_malloc(key_memory_table_def_memory, MYF(MY_WME),
&m_type, size,
&m_field_metadata,
size * sizeof(uint16),
diff --git a/sql/rpl_utility_server.cc b/sql/rpl_utility_server.cc
index e58c9cf018e..00d4888bbe3 100644
--- a/sql/rpl_utility_server.cc
+++ b/sql/rpl_utility_server.cc
@@ -1123,7 +1123,7 @@ err:
Deferred_log_events::Deferred_log_events(Relay_log_info *rli) : last_added(NULL)
{
- my_init_dynamic_array(&array, sizeof(Log_event *), 32, 16, MYF(0));
+ my_init_dynamic_array(&array, PSI_INSTRUMENT_ME, sizeof(Log_event *), 32, 16, MYF(0));
}
Deferred_log_events::~Deferred_log_events()
diff --git a/sql/semisync_master.cc b/sql/semisync_master.cc
index b239a9776a7..79634d142eb 100644
--- a/sql/semisync_master.cc
+++ b/sql/semisync_master.cc
@@ -724,8 +724,8 @@ int Repl_semi_sync_master::report_binlog_update(THD* thd, const char *log_file,
if (!(log_info= thd->semisync_info))
{
- if(!(log_info=
- (Trans_binlog_info*) my_malloc(sizeof(Trans_binlog_info), MYF(0))))
+ if(!(log_info= (Trans_binlog_info*)my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(Trans_binlog_info), MYF(0))))
return 1;
thd->semisync_info= log_info;
}
diff --git a/sql/semisync_master.h b/sql/semisync_master.h
index 74f6c24c8ea..9f0acf57a60 100644
--- a/sql/semisync_master.h
+++ b/sql/semisync_master.h
@@ -231,7 +231,7 @@ private:
*/
int allocate_block()
{
- Block *block= (Block *)my_malloc(sizeof(Block), MYF(0));
+ Block *block= (Block *)my_malloc(PSI_INSTRUMENT_ME, sizeof(Block), MYF(0));
if (block)
{
block->next= NULL;
diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc
index 33ee6141658..e1c2ec37644 100644
--- a/sql/session_tracker.cc
+++ b/sql/session_tracker.cc
@@ -72,7 +72,8 @@ void Session_sysvars_tracker::vars_list::copy(vars_list* from, THD *thd)
bool Session_sysvars_tracker::vars_list::insert(const sys_var *svar)
{
sysvar_node_st *node;
- if (!(node= (sysvar_node_st *) my_malloc(sizeof(sysvar_node_st),
+ if (!(node= (sysvar_node_st *) my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(sysvar_node_st),
MYF(MY_WME |
(mysqld_server_initialized ?
MY_THREAD_SPECIFIC : 0)))))
@@ -326,7 +327,8 @@ void Session_sysvars_tracker::init(THD *thd)
global_system_variables.session_track_system_variables);
DBUG_ASSERT(global_system_variables.session_track_system_variables);
thd->variables.session_track_system_variables=
- my_strdup(global_system_variables.session_track_system_variables,
+ my_strdup(PSI_INSTRUMENT_ME,
+ global_system_variables.session_track_system_variables,
MYF(MY_WME | MY_THREAD_SPECIFIC));
}
@@ -383,11 +385,11 @@ bool Session_sysvars_tracker::update(THD *thd, set_var *var)
size_t length= 1;
if (var->save_result.string_value.str)
- copy= my_memdup(var->save_result.string_value.str,
+ copy= my_memdup(PSI_INSTRUMENT_ME, var->save_result.string_value.str,
(length= var->save_result.string_value.length + 1),
MYF(MY_WME | MY_THREAD_SPECIFIC));
else
- copy= my_strdup("", MYF(MY_WME | MY_THREAD_SPECIFIC));
+ copy= my_strdup(PSI_INSTRUMENT_ME, "", MYF(MY_WME | MY_THREAD_SPECIFIC));
if (!copy)
return true;
diff --git a/sql/session_tracker.h b/sql/session_tracker.h
index b91e588a34e..422ec98944a 100644
--- a/sql/session_tracker.h
+++ b/sql/session_tracker.h
@@ -143,9 +143,9 @@ class Session_sysvars_tracker: public State_tracker
void init()
{
my_hash_init(&m_registered_sysvars, &my_charset_bin, 0, 0, 0,
- (my_hash_get_key) sysvars_get_key, my_free,
- HASH_UNIQUE | (mysqld_server_initialized ?
- HASH_THREAD_SPECIFIC : 0));
+ (my_hash_get_key) sysvars_get_key, my_free, HASH_UNIQUE |
+ (mysqld_server_initialized ? HASH_THREAD_SPECIFIC : 0),
+ PSI_INSTRUMENT_ME);
}
void free_hash()
{
@@ -401,10 +401,9 @@ class User_variables_tracker: public State_tracker
Hash_set<const user_var_entry> m_changed_user_variables;
public:
User_variables_tracker():
- m_changed_user_variables(&my_charset_bin, 0, 0,
- sizeof(const user_var_entry*), 0, 0,
- HASH_UNIQUE | (mysqld_server_initialized ?
- HASH_THREAD_SPECIFIC : 0)) {}
+ m_changed_user_variables(PSI_INSTRUMENT_ME, &my_charset_bin, 0, 0,
+ sizeof(const user_var_entry*), 0, 0, HASH_UNIQUE |
+ mysqld_server_initialized ? HASH_THREAD_SPECIFIC : 0) {}
bool update(THD *thd, set_var *var);
bool store(THD *thd, String *buf);
void mark_as_changed(THD *thd, const user_var_entry *var)
diff --git a/sql/set_var.cc b/sql/set_var.cc
index fac409f8ef9..eadbfd4ba7d 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -65,7 +65,8 @@ int sys_var_init()
DBUG_ASSERT(system_charset_info != NULL);
if (my_hash_init(&system_variable_hash, system_charset_info, 700, 0,
- 0, (my_hash_get_key) get_sys_var_length, 0, HASH_UNIQUE))
+ 0, (my_hash_get_key) get_sys_var_length, 0, HASH_UNIQUE,
+ PSI_INSTRUMENT_ME))
goto error;
if (mysql_add_sys_var_chain(all_sys_vars.first))
@@ -1377,7 +1378,7 @@ resolve_engine_list(THD *thd, const char *str_arg, size_t str_arg_len,
if (temp_copy)
res= (plugin_ref *)thd->calloc((count+1)*sizeof(*res));
else
- res= (plugin_ref *)my_malloc((count+1)*sizeof(*res), MYF(MY_ZEROFILL|MY_WME));
+ res= (plugin_ref *)my_malloc(PSI_INSTRUMENT_ME, (count+1)*sizeof(*res), MYF(MY_ZEROFILL|MY_WME));
if (!res)
{
my_error(ER_OUTOFMEMORY, MYF(0), (int)((count+1)*sizeof(*res)));
@@ -1428,7 +1429,7 @@ copy_engine_list(plugin_ref *list)
for (p= list, count= 0; *p; ++p, ++count)
;
- p= (plugin_ref *)my_malloc((count+1)*sizeof(*p), MYF(0));
+ p= (plugin_ref *)my_malloc(PSI_INSTRUMENT_ME, (count+1)*sizeof(*p), MYF(0));
if (!p)
{
my_error(ER_OUTOFMEMORY, MYF(0), (int)((count+1)*sizeof(*p)));
diff --git a/sql/slave.cc b/sql/slave.cc
index 87c1cf6cb77..4ef20084678 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -583,7 +583,7 @@ slave_background_kill_request(THD *to_kill)
if (to_kill->rgi_slave->killed_for_retry)
return; // Already deadlock killed.
slave_background_kill_t *p=
- (slave_background_kill_t *)my_malloc(sizeof(*p), MYF(MY_WME));
+ (slave_background_kill_t *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*p), MYF(MY_WME));
if (p)
{
p->to_kill= to_kill;
@@ -611,7 +611,7 @@ slave_background_gtid_pos_create_request(
if (table_entry->state != rpl_slave_state::GTID_POS_AUTO_CREATE)
return;
- p= (slave_background_gtid_pos_create_t *)my_malloc(sizeof(*p), MYF(MY_WME));
+ p= (slave_background_gtid_pos_create_t *)my_malloc(PSI_INSTRUMENT_ME, sizeof(*p), MYF(MY_WME));
if (!p)
return;
mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state);
@@ -1809,7 +1809,8 @@ int init_dynarray_intvar_from_file(DYNAMIC_ARRAY* arr, IO_CACHE* f)
(decimal size + space) - 1 + `\n' + '\0'
*/
size_t max_size= (1 + num_items) * (sizeof(long)*3 + 1) + 1;
- buf_act= (char*) my_malloc(max_size, MYF(MY_WME));
+ buf_act= (char*) my_malloc(key_memory_Rpl_info_file_buffer, max_size,
+ MYF(MY_WME));
memcpy(buf_act, buf, read_size);
snd_size= my_b_gets(f, buf_act + read_size, max_size - read_size);
if (snd_size == 0 ||
@@ -6035,7 +6036,8 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
*/
if ((uchar)buf[EVENT_TYPE_OFFSET] == LOAD_EVENT)
{
- if (unlikely(!(tmp_buf=(char*)my_malloc(event_len+1,MYF(MY_WME)))))
+ if (unlikely(!(tmp_buf=(char*)my_malloc(key_memory_binlog_ver_1_event,
+ event_len+1,MYF(MY_WME)))))
{
mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, NULL,
ER(ER_SLAVE_FATAL_ERROR), "Memory allocation failed");
diff --git a/sql/sp.cc b/sql/sp.cc
index 15a5f9b287d..4cfbdde7228 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -2283,7 +2283,7 @@ bool sp_add_used_routine(Query_tables_list *prelocking_ctx, Query_arena *arena,
{
my_hash_init_opt(&prelocking_ctx->sroutines, system_charset_info,
Query_tables_list::START_SROUTINES_HASH_SIZE,
- 0, 0, sp_sroutine_key, 0, 0);
+ 0, 0, sp_sroutine_key, 0, 0, PSI_INSTRUMENT_ME);
if (!my_hash_search(&prelocking_ctx->sroutines, key->ptr(), key->length()))
{
diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc
index e4ffbdcb155..04172d56166 100644
--- a/sql/sp_cache.cc
+++ b/sql/sp_cache.cc
@@ -303,7 +303,8 @@ void
sp_cache::init()
{
my_hash_init(&m_hashtable, system_charset_info, 0, 0, 0,
- hash_get_key_for_sp_head, hash_free_sp_head, 0);
+ hash_get_key_for_sp_head, hash_free_sp_head, 0,
+ key_memory_sp_cache);
}
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 04595a6f32f..da02b0e680a 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -455,8 +455,8 @@ sp_head *sp_head::create(sp_package *parent, const Sp_handler *handler,
enum_sp_aggregate_type agg_type)
{
MEM_ROOT own_root;
- init_sql_alloc(&own_root, "sp_head", MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC,
- MYF(0));
+ init_sql_alloc(key_memory_sp_head_main_root, &own_root, MEM_ROOT_BLOCK_SIZE,
+ MEM_ROOT_PREALLOC, MYF(0));
sp_head *sp;
if (!(sp= new (&own_root) sp_head(&own_root, parent, handler, agg_type)))
free_root(&own_root, MYF(0));
@@ -537,11 +537,12 @@ sp_head::sp_head(MEM_ROOT *mem_root_arg, sp_package *parent,
m_backpatch_goto.empty();
m_cont_backpatch.empty();
m_lex.empty();
- my_init_dynamic_array(&m_instr, sizeof(sp_instr *), 16, 8, MYF(0));
- my_hash_init(&m_sptabs, system_charset_info, 0, 0, 0, sp_table_key, 0, 0);
+ my_init_dynamic_array(&m_instr, key_memory_sp_head_main_root,
+ sizeof(sp_instr *), 16, 8, MYF(0));
+ my_hash_init(&m_sptabs, system_charset_info, 0, 0, 0, sp_table_key, 0, 0,
+ key_memory_sp_head_main_root);
my_hash_init(&m_sroutines, system_charset_info, 0, 0, 0, sp_sroutine_key,
- 0, 0);
- m_security_ctx.init();
+ 0, 0, key_memory_sp_head_main_root);
DBUG_VOID_RETURN;
}
@@ -551,7 +552,7 @@ sp_package *sp_package::create(LEX *top_level_lex, const sp_name *name,
const Sp_handler *sph)
{
MEM_ROOT own_root;
- init_sql_alloc(&own_root, "sp_package", MEM_ROOT_BLOCK_SIZE,
+ init_sql_alloc(key_memory_sp_head_main_root, &own_root, MEM_ROOT_BLOCK_SIZE,
MEM_ROOT_PREALLOC, MYF(0));
sp_package *sp;
if (!(sp= new (&own_root) sp_package(&own_root, top_level_lex, name, sph)))
@@ -1038,7 +1039,7 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
{
DBUG_ENTER("subst_spvars");
- Dynamic_array<Rewritable_query_parameter*> rewritables;
+ Dynamic_array<Rewritable_query_parameter*> rewritables(PSI_INSTRUMENT_MEM);
char *pbuf;
StringBuffer<512> qbuf;
Copy_query_with_rewrite acc(thd, query_str->str, query_str->length, &qbuf);
@@ -1170,7 +1171,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
opt_trace_disable_if_no_security_context_access(thd);
/* init per-instruction memroot */
- init_sql_alloc(&execute_mem_root, "per_instruction_memroot",
+ init_sql_alloc(key_memory_sp_head_execute_root, &execute_mem_root,
MEM_ROOT_BLOCK_SIZE, 0, MYF(0));
DBUG_ASSERT(!(m_flags & IS_INVOKED));
@@ -1815,8 +1816,8 @@ sp_head::execute_trigger(THD *thd,
TODO: we should create sp_rcontext once per command and reuse it
on subsequent executions of a trigger.
*/
- init_sql_alloc(&call_mem_root, "execute_trigger", MEM_ROOT_BLOCK_SIZE, 0,
- MYF(0));
+ init_sql_alloc(key_memory_sp_head_call_root,
+ &call_mem_root, MEM_ROOT_BLOCK_SIZE, 0, MYF(0));
thd->set_n_backup_active_arena(&call_arena, &backup_arena);
Row_definition_list defs;
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
index 01841bb57b7..848d1f0c655 100644
--- a/sql/sp_pcontext.cc
+++ b/sql/sp_pcontext.cc
@@ -96,6 +96,9 @@ sp_pcontext::sp_pcontext()
: Sql_alloc(),
m_max_var_index(0), m_max_cursor_index(0),
m_parent(NULL), m_pboundary(0),
+ m_vars(PSI_INSTRUMENT_MEM), m_case_expr_ids(PSI_INSTRUMENT_MEM),
+ m_conditions(PSI_INSTRUMENT_MEM), m_cursors(PSI_INSTRUMENT_MEM),
+ m_handlers(PSI_INSTRUMENT_MEM), m_children(PSI_INSTRUMENT_MEM),
m_scope(REGULAR_SCOPE)
{
init(0, 0, 0);
@@ -106,6 +109,9 @@ sp_pcontext::sp_pcontext(sp_pcontext *prev, sp_pcontext::enum_scope scope)
: Sql_alloc(),
m_max_var_index(0), m_max_cursor_index(0),
m_parent(prev), m_pboundary(0),
+ m_vars(PSI_INSTRUMENT_MEM), m_case_expr_ids(PSI_INSTRUMENT_MEM),
+ m_conditions(PSI_INSTRUMENT_MEM), m_cursors(PSI_INSTRUMENT_MEM),
+ m_handlers(PSI_INSTRUMENT_MEM), m_children(PSI_INSTRUMENT_MEM),
m_scope(scope)
{
init(prev->m_var_offset + prev->m_max_var_index,
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 17b4c83b7bc..c4c19dd39f6 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -74,6 +74,7 @@ sp_rcontext::sp_rcontext(const sp_head *owner,
m_return_value_fld(return_value_fld),
m_return_value_set(false),
m_in_sub_stmt(in_sub_stmt),
+ m_handlers(PSI_INSTRUMENT_MEM), m_handler_call_stack(PSI_INSTRUMENT_MEM),
m_ccount(0)
{
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index c713f40cdf3..2ff8c5d8bdc 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -654,7 +654,7 @@ bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, const char *username,
#define ROLE_OPENED (1L << 3)
static DYNAMIC_ARRAY acl_hosts, acl_users, acl_proxy_users;
-static Dynamic_array<ACL_DB> acl_dbs(0U,50U);
+static Dynamic_array<ACL_DB> acl_dbs(PSI_INSTRUMENT_MEM, 0U, 50U);
typedef Dynamic_array<ACL_DB>::CMP_FUNC acl_dbs_cmp;
static HASH acl_roles;
/*
@@ -2307,9 +2307,9 @@ bool acl_init(bool dont_read_acl_tables)
bool return_val;
DBUG_ENTER("acl_init");
- acl_cache= new Hash_filo<acl_entry>(ACL_CACHE_SIZE, 0, 0,
+ acl_cache= new Hash_filo<acl_entry>(key_memory_acl_cache, ACL_CACHE_SIZE, 0, 0,
(my_hash_get_key) acl_entry_get_key,
- (my_hash_free_key) free,
+ (my_hash_free_key) my_free,
&my_charset_utf8mb3_bin);
/*
@@ -2384,7 +2384,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
grant_version++; /* Privileges updated */
const Host_table& host_table= tables.host_table();
- init_sql_alloc(&acl_memroot, "ACL", ACL_ALLOC_BLOCK_SIZE, 0, MYF(0));
+ init_sql_alloc(key_memory_acl_mem, &acl_memroot, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0));
if (host_table.table_exists()) // "host" table may not exist (e.g. in MySQL 5.6.7+)
{
if (host_table.init_read_record(&read_record_info))
@@ -2461,7 +2461,8 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
user.sort= get_magic_sort("hu", user.host.hostname, user.user.str);
user.hostname_length= safe_strlen(user.host.hostname);
- my_init_dynamic_array(&user.role_grants, sizeof(ACL_ROLE *), 0, 8, MYF(0));
+ my_init_dynamic_array(&user.role_grants, key_memory_acl_mem,
+ sizeof(ACL_ROLE *), 0, 8, MYF(0));
user.account_locked= user_table.get_account_locked();
@@ -2479,7 +2480,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
ACL_ROLE *entry= new (&acl_memroot) ACL_ROLE(&user, &acl_memroot);
entry->role_grants = user.role_grants;
- my_init_dynamic_array(&entry->parent_grantee,
+ my_init_dynamic_array(&entry->parent_grantee, key_memory_acl_mem,
sizeof(ACL_USER_BASE *), 0, 8, MYF(0));
my_hash_insert(&acl_roles, (uchar *)entry);
@@ -2624,7 +2625,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
DBUG_RETURN(TRUE);
MEM_ROOT temp_root;
- init_alloc_root(&temp_root, "ACL_tmp", ACL_ALLOC_BLOCK_SIZE, 0, MYF(0));
+ init_alloc_root(key_memory_acl_mem, &temp_root, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0));
while (!(read_record_info.read_record()))
{
char *hostname= safe_str(get_field(&temp_root, roles_mapping_table.host()));
@@ -2743,15 +2744,16 @@ bool acl_reload(THD *thd)
old_acl_roles_mappings= acl_roles_mappings;
old_acl_proxy_users= acl_proxy_users;
old_acl_dbs= acl_dbs;
- my_init_dynamic_array(&acl_hosts, sizeof(ACL_HOST), 20, 50, MYF(0));
- my_init_dynamic_array(&acl_users, sizeof(ACL_USER), 50, 100, MYF(0));
- acl_dbs.init(50, 100);
- my_init_dynamic_array(&acl_proxy_users, sizeof(ACL_PROXY_USER), 50, 100, MYF(0));
+ my_init_dynamic_array(&acl_hosts, key_memory_acl_mem, sizeof(ACL_HOST), 20, 50, MYF(0));
+ my_init_dynamic_array(&acl_users, key_memory_acl_mem, sizeof(ACL_USER), 50, 100, MYF(0));
+ acl_dbs.init(key_memory_acl_mem, 50, 100);
+ my_init_dynamic_array(&acl_proxy_users, key_memory_acl_mem, sizeof(ACL_PROXY_USER), 50, 100, MYF(0));
my_hash_init2(&acl_roles,50, &my_charset_utf8mb3_bin,
0, 0, 0, (my_hash_get_key) acl_role_get_key, 0,
- (void (*)(void *))free_acl_role, 0);
+ (void (*)(void *))free_acl_role, 0, key_memory_acl_mem);
my_hash_init2(&acl_roles_mappings, 50, &my_charset_utf8mb3_bin, 0, 0, 0,
- (my_hash_get_key) acl_role_map_get_key, 0, 0, 0);
+ (my_hash_get_key) acl_role_map_get_key, 0, 0, 0,
+ key_memory_acl_mem);
old_mem= acl_memroot;
delete_dynamic(&acl_wild_hosts);
my_hash_free(&acl_check_hosts);
@@ -3189,7 +3191,7 @@ ACL_USER::ACL_USER(THD *thd, const LEX_USER &combo,
sort= get_magic_sort("hu", host.hostname, user.str);
password_last_changed= thd->query_start();
password_lifetime= -1;
- my_init_dynamic_array(&role_grants, sizeof(ACL_USER *), 0, 8, MYF(0));
+ my_init_dynamic_array(&role_grants, PSI_INSTRUMENT_ME, sizeof(ACL_USER *), 0, 8, MYF(0));
}
@@ -3274,9 +3276,10 @@ static void acl_insert_role(const char *rolename, privilege_t privileges)
mysql_mutex_assert_owner(&acl_cache->lock);
entry= new (&acl_memroot) ACL_ROLE(rolename, privileges, &acl_memroot);
- my_init_dynamic_array(&entry->parent_grantee,
+ my_init_dynamic_array(&entry->parent_grantee, key_memory_acl_mem,
sizeof(ACL_USER_BASE *), 0, 8, MYF(0));
- my_init_dynamic_array(&entry->role_grants, sizeof(ACL_ROLE *), 0, 8, MYF(0));
+ my_init_dynamic_array(&entry->role_grants, key_memory_acl_mem,
+ sizeof(ACL_ROLE *), 0, 8, MYF(0));
my_hash_insert(&acl_roles, (uchar *)entry);
}
@@ -3423,7 +3426,8 @@ privilege_t acl_get(const char *host, const char *ip,
exit:
/* Save entry in cache for quick retrieval */
if (!db_is_pattern &&
- (entry= (acl_entry*) malloc(sizeof(acl_entry)+key_length)))
+ (entry= (acl_entry*) my_malloc(key_memory_acl_cache,
+ sizeof(acl_entry)+key_length, MYF(MY_WME))))
{
entry->access=(db_access & host_access);
DBUG_ASSERT(key_length < 0xffff);
@@ -3447,11 +3451,12 @@ exit:
static void init_check_host(void)
{
DBUG_ENTER("init_check_host");
- (void) my_init_dynamic_array(&acl_wild_hosts,sizeof(struct acl_host_and_ip),
+ (void) my_init_dynamic_array(&acl_wild_hosts, key_memory_acl_mem,
+ sizeof(struct acl_host_and_ip),
acl_users.elements, 1, MYF(0));
- (void) my_hash_init(&acl_check_hosts,system_charset_info,
- acl_users.elements, 0, 0,
- (my_hash_get_key) check_get_key, 0, 0);
+ (void) my_hash_init(&acl_check_hosts,system_charset_info, acl_users.elements,
+ 0, 0, (my_hash_get_key) check_get_key, 0, 0,
+ key_memory_acl_mem);
if (!allow_all_hosts)
{
for (uint i=0 ; i < acl_users.elements ; i++)
@@ -5097,7 +5102,8 @@ public:
void init_hash()
{
my_hash_init2(&hash_columns, 4, system_charset_info, 0, 0, 0,
- (my_hash_get_key) get_key_column, 0, 0, 0);
+ (my_hash_get_key) get_key_column, 0, 0, 0,
+ key_memory_acl_memex);
}
};
@@ -6284,7 +6290,7 @@ static int update_role_db(int merged, int first, privilege_t access,
static bool merge_role_db_privileges(ACL_ROLE *grantee, const char *dbname,
role_hash_t *rhash)
{
- Dynamic_array<int> dbs;
+ Dynamic_array<int> dbs(PSI_INSTRUMENT_MEM);
/*
Supposedly acl_dbs can be huge, but only a handful of db grants
@@ -6503,7 +6509,7 @@ static int update_role_table_columns(GRANT_TABLE *merged,
static bool merge_role_table_and_column_privileges(ACL_ROLE *grantee,
const char *db, const char *tname, role_hash_t *rhash)
{
- Dynamic_array<GRANT_TABLE *> grants;
+ Dynamic_array<GRANT_TABLE *> grants(PSI_INSTRUMENT_MEM);
DBUG_ASSERT(MY_TEST(db) == MY_TEST(tname)); // both must be set, or neither
/*
@@ -6632,7 +6638,7 @@ static bool merge_role_routine_grant_privileges(ACL_ROLE *grantee,
DBUG_ASSERT(MY_TEST(db) == MY_TEST(tname)); // both must be set, or neither
- Dynamic_array<GRANT_NAME *> grants;
+ Dynamic_array<GRANT_NAME *> grants(PSI_INSTRUMENT_MEM);
/* first, collect routine privileges granted to roles in question */
for (uint i=0 ; i < hash->records ; i++)
@@ -6693,7 +6699,7 @@ static int merge_role_privileges(ACL_ROLE *role __attribute__((unused)),
grantee->counter= 1; // Mark the grantee as merged.
/* if we'll do db/table/routine privileges, create a hash of role names */
- role_hash_t role_hash(role_key);
+ role_hash_t role_hash(PSI_INSTRUMENT_MEM, role_key);
if (data->what != PRIVS_TO_MERGE::GLOBAL)
{
role_hash.insert(grantee);
@@ -7647,16 +7653,21 @@ static bool grant_load(THD *thd,
(void) my_hash_init(&column_priv_hash, &my_charset_utf8mb3_bin,
0,0,0, (my_hash_get_key) get_grant_table,
- (my_hash_free_key) free_grant_table,0);
+ (my_hash_free_key) free_grant_table, 0,
+ key_memory_acl_memex);
(void) my_hash_init(&proc_priv_hash, &my_charset_utf8mb3_bin,
- 0,0,0, (my_hash_get_key) get_grant_table, 0,0);
+ 0,0,0, (my_hash_get_key) get_grant_table, 0,0,
+ key_memory_acl_memex);
(void) my_hash_init(&func_priv_hash, &my_charset_utf8mb3_bin,
- 0,0,0, (my_hash_get_key) get_grant_table, 0,0);
+ 0,0,0, (my_hash_get_key) get_grant_table, 0,0,
+ key_memory_acl_memex);
(void) my_hash_init(&package_spec_priv_hash, &my_charset_utf8mb3_bin,
- 0,0,0, (my_hash_get_key) get_grant_table, 0,0);
+ 0,0,0, (my_hash_get_key) get_grant_table, 0,0,
+ key_memory_acl_memex);
(void) my_hash_init(&package_body_priv_hash, &my_charset_utf8mb3_bin,
- 0,0,0, (my_hash_get_key) get_grant_table, 0,0);
- init_sql_alloc(&grant_memroot, "GRANT", ACL_ALLOC_BLOCK_SIZE, 0, MYF(0));
+ 0,0,0, (my_hash_get_key) get_grant_table, 0,0,
+ key_memory_acl_memex);
+ init_sql_alloc(key_memory_acl_mem, &grant_memroot, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0));
t_table= tables_priv.table();
c_table= columns_priv.table();
@@ -13180,7 +13191,8 @@ static bool parse_com_change_user_packet(MPVIO_EXT *mpvio, uint packet_length)
system_charset_info, user, user_len,
thd->charset(), &dummy_errors);
- if (!(sctx->user= my_strndup(user_buff, user_len, MYF(MY_WME))))
+ if (!(sctx->user= my_strndup(key_memory_MPVIO_EXT_auth_info, user_buff,
+ user_len, MYF(MY_WME))))
DBUG_RETURN(1);
/* Clear variables that are allocated */
@@ -13439,8 +13451,8 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
Security_context *sctx= thd->security_ctx;
- my_free((char*) sctx->user);
- if (!(sctx->user= my_strndup(user, user_len, MYF(MY_WME))))
+ my_free(const_cast<char*>(sctx->user));
+ if (!(sctx->user= my_strndup(key_memory_MPVIO_EXT_auth_info, user, user_len, MYF(MY_WME))))
return packet_error; /* The error is set by my_strdup(). */
@@ -14249,16 +14261,17 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
thd->net.net_skip_rest_factor= 2; // skip at most 2*max_packet_size
if (mpvio.auth_info.external_user[0])
- sctx->external_user= my_strdup(mpvio.auth_info.external_user, MYF(0));
+ sctx->external_user= my_strdup(key_memory_MPVIO_EXT_auth_info,
+ mpvio.auth_info.external_user, MYF(0));
if (res == CR_OK_HANDSHAKE_COMPLETE)
thd->get_stmt_da()->disable_status();
else
my_ok(thd);
- PSI_CALL_set_thread_user_host
- (thd->main_security_ctx.user, (uint)strlen(thd->main_security_ctx.user),
- thd->main_security_ctx.host_or_ip, (uint)strlen(thd->main_security_ctx.host_or_ip));
+ PSI_CALL_set_thread_account
+ (thd->main_security_ctx.user, strlen(thd->main_security_ctx.user),
+ thd->main_security_ctx.host_or_ip, strlen(thd->main_security_ctx.host_or_ip));
/* Ready to handle queries */
DBUG_RETURN(0);
diff --git a/sql/sql_array.h b/sql/sql_array.h
index 70aeaabc8ec..e0f2485e297 100644
--- a/sql/sql_array.h
+++ b/sql/sql_array.h
@@ -114,21 +114,21 @@ template <class Elem> class Dynamic_array
{
DYNAMIC_ARRAY array;
public:
- Dynamic_array(uint prealloc=16, uint increment=16)
+ Dynamic_array(PSI_memory_key psi_key, uint prealloc=16, uint increment=16)
{
- init(prealloc, increment);
+ init(psi_key, prealloc, increment);
}
Dynamic_array(MEM_ROOT *root, uint prealloc=16, uint increment=16)
{
void *init_buffer= alloc_root(root, sizeof(Elem) * prealloc);
- my_init_dynamic_array2(&array, sizeof(Elem), init_buffer,
+ init_dynamic_array2(&array, root->m_psi_key, sizeof(Elem), init_buffer,
prealloc, increment, MYF(0));
}
- void init(uint prealloc=16, uint increment=16)
+ void init(PSI_memory_key psi_key, uint prealloc=16, uint increment=16)
{
- init_dynamic_array2(&array, sizeof(Elem), 0, prealloc, increment, MYF(0));
+ init_dynamic_array2(&array, psi_key, sizeof(Elem), 0, prealloc, increment, MYF(0));
}
/**
diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc
index ed175ae4865..2fd92725194 100644
--- a/sql/sql_audit.cc
+++ b/sql/sql_audit.cc
@@ -88,7 +88,7 @@ static my_bool acquire_plugins(THD *thd, plugin_ref plugin, void *arg)
if (unlikely(!thd->audit_class_plugins.buffer))
{
/* specify some reasonable initialization defaults */
- my_init_dynamic_array(&thd->audit_class_plugins,
+ my_init_dynamic_array(&thd->audit_class_plugins, PSI_INSTRUMENT_ME,
sizeof(plugin_ref), 16, 16, MYF(0));
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 3d49ebc31c8..6a59202609d 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -566,12 +566,12 @@ bool flush_tables(THD *thd, flush_tables_type flag)
write after last time all tables was closed.
*/
- if (!(tmp_table= (TABLE*) my_malloc(sizeof(*tmp_table),
+ if (!(tmp_table= (TABLE*) my_malloc(PSI_INSTRUMENT_ME, sizeof(*tmp_table),
MYF(MY_WME | MY_THREAD_SPECIFIC))))
DBUG_RETURN(1);
- my_init_dynamic_array(&collect_arg.shares, sizeof(TABLE_SHARE*), 100, 100,
- MYF(0));
+ my_init_dynamic_array(&collect_arg.shares, PSI_INSTRUMENT_ME,
+ sizeof(TABLE_SHARE*), 100, 100, MYF(0));
collect_arg.flush_type= flag;
if (tdc_iterate(thd, (my_hash_walk_action) tc_collect_used_shares,
&collect_arg, true))
@@ -2064,7 +2064,8 @@ retry_share:
{
enum open_frm_error error;
/* make a new table */
- if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))
+ if (!(table=(TABLE*) my_malloc(key_memory_TABLE, sizeof(*table),
+ MYF(MY_WME))))
goto err_lock;
error= open_table_from_share(thd, share, &table_list->alias,
@@ -3004,7 +3005,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)
thd->clear_error();
- if (!(entry= (TABLE*)my_malloc(sizeof(TABLE), MYF(MY_WME))))
+ if (!(entry= (TABLE*)my_malloc(key_memory_TABLE, sizeof(TABLE), MYF(MY_WME))))
return result;
if (!(share= tdc_acquire_share(thd, table_list, GTS_TABLE)))
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc
index 44a885bf0eb..b98792bb43c 100644
--- a/sql/sql_binlog.cc
+++ b/sql/sql_binlog.cc
@@ -144,7 +144,7 @@ int binlog_defragment(THD *thd)
}
thd->lex->comment.str= // to be freed by the caller
- (char *) my_malloc(thd->lex->comment.length, MYF(MY_WME));
+ (char *) my_malloc(PSI_INSTRUMENT_ME, thd->lex->comment.length, MYF(MY_WME));
if (!thd->lex->comment.str)
{
my_error(ER_OUTOFMEMORY, MYF(ME_FATAL), 1);
@@ -242,7 +242,8 @@ void mysql_client_binlog_statement(THD* thd)
}
decoded_len= my_base64_needed_decoded_length((int)coded_len);
- if (!(buf= (char *) my_malloc(decoded_len, MYF(MY_WME))))
+ if (!(buf= (char *) my_malloc(key_memory_binlog_statement_buffer,
+ decoded_len, MYF(MY_WME))))
{
my_error(ER_OUTOFMEMORY, MYF(ME_FATAL), 1);
goto end;
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 5b649b739c6..858a97b66be 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -2728,7 +2728,7 @@ size_t Query_cache::init_cache()
DUMP(this);
(void) my_hash_init(&queries, &my_charset_bin, def_query_hash_size, 0, 0,
- query_cache_query_get_key, 0, 0);
+ query_cache_query_get_key, 0, 0, key_memory_Query_cache);
#ifndef FN_NO_CASE_SENSE
/*
If lower_case_table_names!=0 then db and table names are already
@@ -2739,7 +2739,7 @@ size_t Query_cache::init_cache()
and MY_TABLE cases and so again can use binary collation.
*/
(void) my_hash_init(&tables, &my_charset_bin, def_table_hash_size, 0, 0,
- query_cache_table_get_key, 0, 0);
+ query_cache_table_get_key, 0, 0, key_memory_Query_cache);
#else
/*
On windows, OS/2, MacOS X with HFS+ or any other case insensitive
@@ -2753,7 +2753,7 @@ size_t Query_cache::init_cache()
lower_case_table_names ? &my_charset_bin :
files_charset_info,
def_table_hash_size, 0, 0,query_cache_table_get_key,
- 0, 0);
+ 0, 0, PSI_INSTRUMENT_ME);
#endif
queries_in_cache = 0;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2ffb61a98f2..9066d939db6 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -633,7 +633,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
/* statement id */ 0),
rli_fake(0), rgi_fake(0), rgi_slave(NULL),
protocol_text(this), protocol_binary(this),
- m_current_stage_key(0),
+ m_current_stage_key(0), m_psi(0),
in_sub_stmt(0), log_all_errors(0),
binlog_unsafe_warning_flags(0),
binlog_table_maps(0),
@@ -743,8 +743,9 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
the destructor works OK in case of an error. The main_mem_root
will be re-initialized in init_for_queries().
*/
- init_sql_alloc(&main_mem_root, "THD::main_mem_root",
- ALLOC_ROOT_MIN_BLOCK_SIZE, 0, MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_thd_main_mem_root,
+ &main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0,
+ MYF(MY_THREAD_SPECIFIC));
/*
Allocation of user variables for binary logging is always done with main
@@ -845,10 +846,12 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
user_connect=(USER_CONN *)0;
my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
(my_hash_get_key) get_var_key,
- (my_hash_free_key) free_user_var, HASH_THREAD_SPECIFIC);
+ (my_hash_free_key) free_user_var, HASH_THREAD_SPECIFIC,
+ key_memory_user_var_entry);
my_hash_init(&sequences, system_charset_info, SEQUENCES_HASH_SIZE, 0, 0,
(my_hash_get_key) get_sequence_last_key,
- (my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC);
+ (my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC,
+ PSI_INSTRUMENT_ME);
sp_proc_cache= NULL;
sp_func_cache= NULL;
@@ -857,7 +860,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
/* For user vars replication*/
if (opt_bin_log)
- my_init_dynamic_array(&user_var_events,
+ my_init_dynamic_array(&user_var_events, key_memory_user_var_entry,
sizeof(BINLOG_USER_VAR_EVENT *), 16, 16, MYF(0));
else
bzero((char*) &user_var_events, sizeof(user_var_events));
@@ -885,7 +888,8 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
m_token_array= NULL;
if (max_digest_length > 0)
{
- m_token_array= (unsigned char*) my_malloc(max_digest_length,
+ m_token_array= (unsigned char*) my_malloc(PSI_INSTRUMENT_ME,
+ max_digest_length,
MYF(MY_WME|MY_THREAD_SPECIFIC));
}
@@ -1450,10 +1454,12 @@ void THD::change_user(void)
stmt_map.reset();
my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
(my_hash_get_key) get_var_key,
- (my_hash_free_key) free_user_var, 0);
+ (my_hash_free_key) free_user_var, HASH_THREAD_SPECIFIC,
+ key_memory_user_var_entry);
my_hash_init(&sequences, system_charset_info, SEQUENCES_HASH_SIZE, 0, 0,
(my_hash_get_key) get_sequence_last_key,
- (my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC);
+ (my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC,
+ key_memory_user_var_entry);
sp_cache_clear(&sp_proc_cache);
sp_cache_clear(&sp_func_cache);
sp_cache_clear(&sp_package_spec_cache);
@@ -1490,7 +1496,8 @@ bool THD::set_db(const LEX_CSTRING *new_db)
const char *tmp= NULL;
if (new_db->str)
{
- if (!(tmp= my_strndup(new_db->str, new_db->length, MYF(MY_WME | ME_FATAL))))
+ if (!(tmp= my_strndup(key_memory_THD_db, new_db->str, new_db->length,
+ MYF(MY_WME | ME_FATAL))))
result= 1;
}
@@ -3931,10 +3938,11 @@ Statement_map::Statement_map() :
};
my_hash_init(&st_hash, &my_charset_bin, START_STMT_HASH_SIZE, 0, 0,
get_statement_id_as_hash_key,
- delete_statement_as_hash_key, MYF(0));
+ delete_statement_as_hash_key, MYF(0),
+ key_memory_prepared_statement_map);
my_hash_init(&names_hash, system_charset_info, START_NAME_HASH_SIZE, 0, 0,
(my_hash_get_key) get_stmt_name_hash_key,
- NULL,MYF(0));
+ NULL, MYF(0), key_memory_prepared_statement_map);
}
@@ -4338,8 +4346,8 @@ void Security_context::skip_grants()
bool Security_context::set_user(char *user_arg)
{
- my_free((char*) user);
- user= my_strdup(user_arg, MYF(0));
+ my_free(const_cast<char*>(user));
+ user= my_strdup(key_memory_MPVIO_EXT_auth_info, user_arg, MYF(0));
return user == 0;
}
@@ -6601,7 +6609,8 @@ CPP_UNNAMED_NS_START
}
else
{
- m_memory= (uchar *) my_malloc(total_length, MYF(MY_WME));
+ m_memory= (uchar *) my_malloc(key_memory_Row_data_memory_memory,
+ total_length, MYF(MY_WME));
m_release_memory_on_destruction= TRUE;
}
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index d756b047ffe..41e6cb52d62 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1929,9 +1929,8 @@ public:
m_reopen_array(NULL),
m_locked_tables_count(0)
{
- init_sql_alloc(&m_locked_tables_root, "Locked_tables_list",
- MEM_ROOT_BLOCK_SIZE, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_locked_table_list, &m_locked_tables_root,
+ MEM_ROOT_BLOCK_SIZE, 0, MYF(MY_THREAD_SPECIFIC));
}
void unlock_locked_tables(THD *thd);
void unlock_locked_table(THD *thd, MDL_ticket *mdl_ticket);
@@ -2690,9 +2689,8 @@ public:
{
bzero((char*)this, sizeof(*this));
implicit_xid.null();
- init_sql_alloc(&mem_root, "THD::transactions",
- ALLOC_ROOT_MIN_BLOCK_SIZE, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_thd_transactions, &mem_root,
+ ALLOC_ROOT_MIN_BLOCK_SIZE, 0, MYF(MY_THREAD_SPECIFIC));
}
} transaction;
Global_read_lock global_read_lock;
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index e2a3c482ae4..7a8a2f7533a 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -81,8 +81,8 @@ int get_or_create_user_conn(THD *thd, const char *user,
{
/* First connection for user; Create a user connection object */
if (!(uc= ((struct user_conn*)
- my_malloc(sizeof(struct user_conn) + temp_len+1,
- MYF(MY_WME)))))
+ my_malloc(key_memory_user_conn,
+ sizeof(struct user_conn) + temp_len+1, MYF(MY_WME)))))
{
/* MY_WME ensures an error is set in THD. */
return_val= 1;
@@ -324,7 +324,7 @@ void init_max_user_conn(void)
#ifndef NO_EMBEDDED_ACCESS_CHECKS
my_hash_init(&hash_user_connections, system_charset_info, max_connections,
0, 0, (my_hash_get_key) get_key_conn,
- (my_hash_free_key) free_user, 0);
+ (my_hash_free_key) free_user, 0, key_memory_user_conn);
#endif
}
@@ -485,14 +485,14 @@ void init_global_user_stats(void)
{
my_hash_init(&global_user_stats, system_charset_info, max_connections,
0, 0, (my_hash_get_key) get_key_user_stats,
- (my_hash_free_key) free_user_stats, 0);
+ (my_hash_free_key) free_user_stats, 0, PSI_INSTRUMENT_ME);
}
void init_global_client_stats(void)
{
my_hash_init(&global_client_stats, system_charset_info, max_connections,
0, 0, (my_hash_get_key) get_key_user_stats,
- (my_hash_free_key) free_user_stats, 0);
+ (my_hash_free_key) free_user_stats, 0, PSI_INSTRUMENT_ME);
}
extern "C" uchar *get_key_table_stats(TABLE_STATS *table_stats, size_t *length,
@@ -511,7 +511,7 @@ void init_global_table_stats(void)
{
my_hash_init(&global_table_stats, system_charset_info, max_connections,
0, 0, (my_hash_get_key) get_key_table_stats,
- (my_hash_free_key) free_table_stats, 0);
+ (my_hash_free_key) free_table_stats, 0, PSI_INSTRUMENT_ME);
}
extern "C" uchar *get_key_index_stats(INDEX_STATS *index_stats, size_t *length,
@@ -530,7 +530,7 @@ void init_global_index_stats(void)
{
my_hash_init(&global_index_stats, system_charset_info, max_connections,
0, 0, (my_hash_get_key) get_key_index_stats,
- (my_hash_free_key) free_index_stats, 0);
+ (my_hash_free_key) free_index_stats, 0, PSI_INSTRUMENT_ME);
}
@@ -571,7 +571,7 @@ static bool increment_count_by_name(const char *name, size_t name_length,
{
/* First connection for this user or client */
if (!(user_stats= ((USER_STATS*)
- my_malloc(sizeof(USER_STATS),
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(USER_STATS),
MYF(MY_WME | MY_ZEROFILL)))))
return TRUE; // Out of memory
@@ -880,7 +880,7 @@ int thd_set_peer_addr(THD *thd,
}
my_free((void *)thd->main_security_ctx.ip);
- if (!(thd->main_security_ctx.ip = my_strdup(ip, MYF(MY_WME))))
+ if (!(thd->main_security_ctx.ip = my_strdup(PSI_INSTRUMENT_ME, ip, MYF(MY_WME))))
{
/*
No error accounting per IP in host_cache,
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index ae7f26370fa..b4d96b83dbe 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -188,7 +188,7 @@ bool my_dboptions_cache_init(void)
dboptions_init= 1;
error= my_hash_init(&dboptions, table_alias_charset,
32, 0, 0, (my_hash_get_key) dboptions_get_key,
- free_dbopt,0);
+ free_dbopt, 0, key_memory_dboptions_hash);
}
return error;
}
@@ -220,7 +220,7 @@ void my_dbopt_cleanup(void)
my_hash_free(&dboptions);
my_hash_init(&dboptions, table_alias_charset,
32, 0, 0, (my_hash_get_key) dboptions_get_key,
- free_dbopt,0);
+ free_dbopt, 0, key_memory_dboptions_hash);
mysql_rwlock_unlock(&LOCK_dboptions);
}
@@ -290,7 +290,7 @@ static my_bool put_dbopt(const char *dbname, Schema_specification_st *create)
/* Options are not in the hash, insert them */
char *tmp_name;
char *tmp_comment= NULL;
- if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ if (!my_multi_malloc(key_memory_dboptions_hash, MYF(MY_WME | MY_ZEROFILL),
&opt, (uint) sizeof(*opt), &tmp_name, (uint) length+1,
&tmp_comment, (uint) DATABASE_COMMENT_MAXLEN+1,
NullS))
@@ -1547,8 +1547,8 @@ uint mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name,
TODO: fix check_db_name().
*/
- new_db_file_name.str= my_strndup(new_db_name->str, new_db_name->length,
- MYF(MY_WME));
+ new_db_file_name.str= my_strndup(key_memory_THD_db, new_db_name->str,
+ new_db_name->length, MYF(MY_WME));
new_db_file_name.length= new_db_name->length;
if (new_db_file_name.str == NULL)
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 7e6ffb67b94..4045f30a6bd 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -506,7 +506,7 @@ void Warning_info::init()
{
/* Initialize sub structures */
DBUG_ASSERT(initialized == 0);
- init_sql_alloc(&m_warn_root, "Warning_info", WARN_ALLOC_BLOCK_SIZE,
+ init_sql_alloc(PSI_INSTRUMENT_ME, &m_warn_root, WARN_ALLOC_BLOCK_SIZE,
WARN_ALLOC_PREALLOC_SIZE, MYF(MY_THREAD_SPECIFIC));
initialized= 1;
}
diff --git a/sql/sql_explain.h b/sql/sql_explain.h
index bd8c8a4d499..041f77b6f42 100644
--- a/sql/sql_explain.h
+++ b/sql/sql_explain.h
@@ -342,7 +342,7 @@ class Explain_union : public Explain_node
{
public:
Explain_union(MEM_ROOT *root, bool is_analyze) :
- Explain_node(root),
+ Explain_node(root), union_members(PSI_INSTRUMENT_MEM),
is_recursive_cte(false),
fake_select_lex_explain(root, is_analyze)
{}
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 12119997430..6292631ea7d 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -292,7 +292,8 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
if (my_hash_init(&thd->handler_tables_hash, &my_charset_latin1,
HANDLER_TABLES_HASH_SIZE, 0, 0,
(my_hash_get_key) mysql_ha_hash_get_key,
- (my_hash_free_key) mysql_ha_hash_free, 0))
+ (my_hash_free_key) mysql_ha_hash_free, 0,
+ key_memory_THD_handler_tables_hash))
{
DBUG_PRINT("exit",("ERROR"));
DBUG_RETURN(TRUE);
@@ -384,14 +385,14 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
/* copy data to sql_handler */
if (!(sql_handler= new SQL_HANDLER(thd)))
goto err;
- init_alloc_root(&sql_handler->mem_root, "sql_handler", 1024, 0,
+ init_alloc_root(PSI_INSTRUMENT_ME, &sql_handler->mem_root, 1024, 0,
MYF(MY_THREAD_SPECIFIC));
sql_handler->db.length= tables->db.length;
sql_handler->table_name.length= tables->table_name.length;
sql_handler->handler_name.length= tables->alias.length;
- if (!(my_multi_malloc(MY_WME,
+ if (!(my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&sql_handler->base_data,
(uint) sql_handler->db.length + 1,
&sql_handler->table_name.str,
diff --git a/sql/sql_hset.h b/sql/sql_hset.h
index aaecef9f0d4..6af6e1df371 100644
--- a/sql/sql_hset.h
+++ b/sql/sql_hset.h
@@ -31,19 +31,20 @@ public:
Constructs an empty hash. Does not allocate memory, it is done upon
the first insert. Thus does not cause or return errors.
*/
- Hash_set(uchar *(*K)(const T *, size_t *, my_bool),
+ Hash_set(PSI_memory_key psi_key, uchar *(*K)(const T *, size_t *, my_bool),
CHARSET_INFO *cs= &my_charset_bin)
{
my_hash_clear(&m_hash);
m_hash.get_key= (my_hash_get_key)K;
m_hash.charset= cs;
+ m_hash.array.m_psi_key= psi_key;
}
- Hash_set(CHARSET_INFO *charset, ulong default_array_elements,
+ Hash_set(PSI_memory_key psi_key, CHARSET_INFO *charset, ulong default_array_elements,
size_t key_offset, size_t key_length, my_hash_get_key get_key,
void (*free_element)(void*), uint flags)
{
my_hash_init(&m_hash, charset, default_array_elements, key_offset,
- key_length, get_key, free_element, flags);
+ key_length, get_key, free_element, flags, psi_key);
}
/**
Destroy the hash by freeing the buckets table. Does
@@ -65,7 +66,7 @@ public:
bool insert(T *value)
{
my_hash_init_opt(&m_hash, m_hash.charset, START_SIZE, 0, 0,
- m_hash.get_key, 0, HASH_UNIQUE);
+ m_hash.get_key, 0, HASH_UNIQUE, m_hash.array.m_psi_key);
return my_hash_insert(&m_hash, reinterpret_cast<const uchar*>(value));
}
bool remove(T *value)
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 60b60ec1e54..8b1b27c67bf 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2402,7 +2402,8 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
di->thd.variables.binlog_annotate_row_events= 0;
di->thd.set_db(&table_list->db);
- di->thd.set_query(my_strndup(table_list->table_name.str,
+ di->thd.set_query(my_strndup(PSI_INSTRUMENT_ME,
+ table_list->table_name.str,
table_list->table_name.length,
MYF(MY_WME | ME_FATAL)),
table_list->table_name.length, system_charset_info);
@@ -2731,7 +2732,8 @@ int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic,
if (query.str)
{
char *str;
- if (!(str= my_strndup(query.str, query.length, MYF(MY_WME))))
+ if (!(str= my_strndup(PSI_INSTRUMENT_ME, query.str, query.length,
+ MYF(MY_WME))))
goto err;
query.str= str;
}
@@ -2754,7 +2756,8 @@ int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic,
ip_len= strlen(thd->security_ctx->ip) + 1;
}
/* This can't be THREAD_SPECIFIC as it's freed in delayed thread */
- if (!(row->record= (char*) my_malloc(table->s->reclength +
+ if (!(row->record= (char*) my_malloc(PSI_INSTRUMENT_ME,
+ table->s->reclength +
user_len + host_len + ip_len,
MYF(MY_WME))))
goto err;
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index 3a509b3d750..9c681061118 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -937,7 +937,8 @@ int JOIN_CACHE::alloc_buffer()
{
size_t next_buff_size;
- if ((buff= (uchar*) my_malloc(buff_size, MYF(MY_THREAD_SPECIFIC))))
+ if ((buff= (uchar*) my_malloc(key_memory_JOIN_CACHE, buff_size,
+ MYF(MY_THREAD_SPECIFIC))))
break;
next_buff_size= buff_size > buff_size_decr ? buff_size-buff_size_decr : 0;
@@ -1013,11 +1014,11 @@ bool JOIN_CACHE::shrink_join_buffer_in_ratio(ulonglong n, ulonglong d)
int JOIN_CACHE::realloc_buffer()
{
- int rc;
free();
- rc= MY_TEST(!(buff= (uchar*) my_malloc(buff_size, MYF(MY_THREAD_SPECIFIC))));
+ buff= (uchar*) my_malloc(key_memory_JOIN_CACHE, buff_size,
+ MYF(MY_THREAD_SPECIFIC));
reset(TRUE);
- return rc;
+ return buff == NULL;
}
@@ -2809,12 +2810,12 @@ int JOIN_CACHE_HASHED::init_hash_table()
int JOIN_CACHE_HASHED::realloc_buffer()
{
- int rc;
free();
- rc= MY_TEST(!(buff= (uchar*) my_malloc(buff_size, MYF(MY_THREAD_SPECIFIC))));
+ buff= (uchar*) my_malloc(key_memory_JOIN_CACHE, buff_size,
+ MYF(MY_THREAD_SPECIFIC));
init_hash_table();
reset(TRUE);
- return rc;
+ return buff == NULL;
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index d448cd0e59e..ae8f0afa18c 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -3826,12 +3826,13 @@ LEX::LEX()
default_used(0), is_lex_started(0), limit_rows_examined_cnt(ULONGLONG_MAX)
{
- init_dynamic_array2(&plugins, sizeof(plugin_ref), plugins_static_buffer,
+ init_dynamic_array2(&plugins, PSI_INSTRUMENT_ME,
+ sizeof(plugin_ref), plugins_static_buffer,
INITIAL_LEX_PLUGIN_LIST_SIZE,
INITIAL_LEX_PLUGIN_LIST_SIZE, 0);
reset_query_tables_list(TRUE);
mi.init();
- init_dynamic_array2(&delete_gtid_domain, sizeof(uint32),
+ init_dynamic_array2(&delete_gtid_domain, PSI_INSTRUMENT_ME, sizeof(uint32),
gtid_domain_static_buffer,
initial_gtid_domain_buffer_size,
initial_gtid_domain_buffer_size, 0);
@@ -5659,8 +5660,8 @@ bool LEX::set_arena_for_set_stmt(Query_arena *backup)
mem_root_for_set_stmt= new MEM_ROOT();
if (unlikely(!(mem_root_for_set_stmt)))
DBUG_RETURN(1);
- init_sql_alloc(mem_root_for_set_stmt, "set_stmt",
- ALLOC_ROOT_SET, ALLOC_ROOT_SET, MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(PSI_INSTRUMENT_ME, mem_root_for_set_stmt, ALLOC_ROOT_SET,
+ ALLOC_ROOT_SET, MYF(MY_THREAD_SPECIFIC));
}
if (unlikely(!(arena_for_set_stmt= new(mem_root_for_set_stmt)
Query_arena_memroot(mem_root_for_set_stmt,
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 84be6e43eaf..fefcdf99e12 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -510,11 +510,11 @@ struct LEX_MASTER_INFO
void init()
{
bzero(this, sizeof(*this));
- my_init_dynamic_array(&repl_ignore_server_ids,
+ my_init_dynamic_array(&repl_ignore_server_ids, PSI_INSTRUMENT_ME,
sizeof(::server_id), 0, 16, MYF(0));
- my_init_dynamic_array(&repl_do_domain_ids,
+ my_init_dynamic_array(&repl_do_domain_ids, PSI_INSTRUMENT_ME,
sizeof(ulong), 0, 16, MYF(0));
- my_init_dynamic_array(&repl_ignore_domain_ids,
+ my_init_dynamic_array(&repl_ignore_domain_ids, PSI_INSTRUMENT_ME,
sizeof(ulong), 0, 16, MYF(0));
sql_delay= -1;
}
diff --git a/sql/sql_list.h b/sql/sql_list.h
index 9d1c01a484d..91134bcbeb2 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -677,7 +677,8 @@ struct ilink
struct ilink **prev,*next;
static void *operator new(size_t size) throw ()
{
- return (void*)my_malloc((uint)size, MYF(MY_WME | MY_FAE | ME_FATAL));
+ return (void*)my_malloc(PSI_INSTRUMENT_ME,
+ (uint)size, MYF(MY_WME | MY_FAE | ME_FATAL));
}
static void operator delete(void* ptr_arg, size_t)
{
diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc
index 2ad8d8a914a..a3d1a7242e4 100644
--- a/sql/sql_manager.cc
+++ b/sql/sql_manager.cc
@@ -51,7 +51,8 @@ bool mysql_manager_submit(void (*action)())
cb= &(*cb)->next;
if (!*cb)
{
- *cb= (struct handler_cb *)my_malloc(sizeof(struct handler_cb), MYF(MY_WME));
+ *cb= (struct handler_cb *)my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(struct handler_cb), MYF(MY_WME));
if (!*cb)
result= TRUE;
else
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 470b5154c9c..055f2bc736d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1010,7 +1010,8 @@ int bootstrap(MYSQL_FILE *file)
thd->thread_stack= (char*) &thd;
thd->store_globals();
- thd->security_ctx->user= (char*) my_strdup("boot", MYF(MY_WME));
+ thd->security_ctx->user= (char*) my_strdup(key_memory_MPVIO_EXT_auth_info,
+ "boot", MYF(MY_WME));
thd->security_ctx->priv_user[0]= thd->security_ctx->priv_host[0]=
thd->security_ctx->priv_role[0]= 0;
/*
@@ -1464,7 +1465,7 @@ static void wsrep_copy_query(THD *thd)
if (thd->wsrep_retry_query) {
my_free(thd->wsrep_retry_query);
}
- thd->wsrep_retry_query = (char *)my_malloc(
+ thd->wsrep_retry_query = (char *)my_malloc(PSI_INSTRUMENT_ME,
thd->wsrep_retry_query_len + 1, MYF(0));
strncpy(thd->wsrep_retry_query, thd->query(), thd->wsrep_retry_query_len);
thd->wsrep_retry_query[thd->wsrep_retry_query_len] = '\0';
@@ -1908,7 +1909,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->m_statement_psi= MYSQL_START_STATEMENT(&thd->m_statement_state,
com_statement_info[command].m_key,
thd->db.str, thd->db.length,
- thd->charset());
+ thd->charset(), NULL);
THD_STAGE_INFO(thd, stage_init);
MYSQL_SET_STATEMENT_TEXT(thd->m_statement_psi, beginning_of_next_stmt,
length);
@@ -7366,11 +7367,11 @@ bool my_yyoverflow(short **yyss, YYSTYPE **yyvs, size_t *yystacksize)
old_info= *yystacksize;
*yystacksize= set_zone((int)(*yystacksize)*2,MY_YACC_INIT,MY_YACC_MAX);
if (!(state->yacc_yyvs= (uchar*)
- my_realloc(state->yacc_yyvs,
+ my_realloc(key_memory_bison_stack, state->yacc_yyvs,
*yystacksize*sizeof(**yyvs),
MYF(MY_ALLOW_ZERO_PTR | MY_FREE_ON_ERROR))) ||
!(state->yacc_yyss= (uchar*)
- my_realloc(state->yacc_yyss,
+ my_realloc(key_memory_bison_stack, state->yacc_yyss,
*yystacksize*sizeof(**yyss),
MYF(MY_ALLOW_ZERO_PTR | MY_FREE_ON_ERROR))))
return 1;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index d9de6e95b89..f722dc54fb4 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -7500,7 +7500,7 @@ void append_row_to_str(String &str, const uchar *row, TABLE *table)
rec= row;
/* Create a new array of all read fields. */
- fields= (Field**) my_malloc(sizeof(void*) * (num_fields + 1),
+ fields= (Field**) my_malloc(PSI_INSTRUMENT_ME, sizeof(void*) * (num_fields + 1),
MYF(0));
if (!fields)
return;
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index bbfbdc3a22e..468dbe9b999 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -42,6 +42,12 @@
#include <mysql/plugin_function.h>
#include "sql_plugin_compat.h"
+static PSI_memory_key key_memory_plugin_mem_root;
+static PSI_memory_key key_memory_plugin_int_mem_root;
+static PSI_memory_key key_memory_mysql_plugin;
+static PSI_memory_key key_memory_mysql_plugin_dl;
+static PSI_memory_key key_memory_plugin_bookmark;
+
#ifdef HAVE_LINK_H
#include <link.h>
#endif
@@ -573,7 +579,7 @@ static my_bool read_mysql_plugin_info(struct st_plugin_dl *plugin_dl,
/* no op */;
cur= (struct st_maria_plugin*)
- my_malloc((i + 1) * sizeof(struct st_maria_plugin),
+ my_malloc(key_memory_mysql_plugin, (i + 1) * sizeof(struct st_maria_plugin),
MYF(MY_ZEROFILL|MY_WME));
if (!cur)
{
@@ -693,7 +699,7 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl,
/* no op */;
cur= (struct st_maria_plugin*)
- my_malloc((i + 1) * sizeof(struct st_maria_plugin),
+ my_malloc(key_memory_mysql_plugin, (i + 1) * sizeof(struct st_maria_plugin),
MYF(MY_ZEROFILL|MY_WME));
if (!cur)
{
@@ -818,7 +824,8 @@ static st_plugin_dl *plugin_dl_add(const LEX_CSTRING *dl, myf MyFlags)
if (plugin_dl.nbackups)
{
size_t bytes= plugin_dl.nbackups * sizeof(plugin_dl.ptr_backup[0]);
- plugin_dl.ptr_backup= (st_ptr_backup *)my_malloc(bytes, MYF(0));
+ plugin_dl.ptr_backup= (st_ptr_backup *)my_malloc(key_memory_mysql_plugin_dl,
+ bytes, MYF(0));
if (!plugin_dl.ptr_backup)
{
restore_ptr_backup(plugin_dl.nbackups, tmp_backup);
@@ -830,7 +837,8 @@ static st_plugin_dl *plugin_dl_add(const LEX_CSTRING *dl, myf MyFlags)
/* Duplicate and convert dll name */
plugin_dl.dl.length= dl->length * files_charset_info->mbmaxlen + 1;
- if (! (plugin_dl.dl.str= (char*) my_malloc(plugin_dl.dl.length, MYF(0))))
+ if (! (plugin_dl.dl.str= (char*) my_malloc(key_memory_mysql_plugin_dl,
+ plugin_dl.dl.length, MYF(0))))
{
my_error(ER_OUTOFMEMORY, MyFlags,
static_cast<int>(plugin_dl.dl.length));
@@ -977,7 +985,8 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc,
memory manager and/or valgrind to track locked references and
double unlocks to aid resolving reference counting problems.
*/
- if (!(plugin= (plugin_ref) my_malloc(sizeof(pi), MYF(MY_WME))))
+ if (!(plugin= (plugin_ref) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(pi),
+ MYF(MY_WME))))
DBUG_RETURN(NULL);
*plugin= pi;
@@ -1186,7 +1195,8 @@ static enum install_status plugin_add(MEM_ROOT *tmp_root, bool if_not_exists,
goto err;
if (my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr))
tmp_plugin_ptr->state= PLUGIN_IS_FREED;
- init_alloc_root(&tmp_plugin_ptr->mem_root, "plugin", 4096, 4096, MYF(0));
+ init_alloc_root(key_memory_plugin_int_mem_root, &tmp_plugin_ptr->mem_root,
+ 4096, 4096, MYF(0));
if (name->str)
DBUG_RETURN(INSTALL_GOOD); // all done
@@ -1541,6 +1551,15 @@ static PSI_mutex_info all_plugin_mutexes[]=
{ &key_LOCK_plugin, "LOCK_plugin", PSI_FLAG_GLOBAL}
};
+static PSI_memory_info all_plugin_memory[]=
+{
+ { &key_memory_plugin_mem_root, "plugin_mem_root", PSI_FLAG_GLOBAL},
+ { &key_memory_plugin_int_mem_root, "plugin_int_mem_root", 0},
+ { &key_memory_mysql_plugin_dl, "mysql_plugin_dl", 0},
+ { &key_memory_mysql_plugin, "mysql_plugin", 0},
+ { &key_memory_plugin_bookmark, "plugin_bookmark", PSI_FLAG_GLOBAL}
+};
+
static void init_plugin_psi_keys(void)
{
const char* category= "sql";
@@ -1551,7 +1570,12 @@ static void init_plugin_psi_keys(void)
count= array_elements(all_plugin_mutexes);
PSI_server->register_mutex(category, all_plugin_mutexes, count);
+
+ count= array_elements(all_plugin_memory);
+ mysql_memory_register(category, all_plugin_memory, count);
}
+#else
+static void init_plugin_psi_keys(void) {}
#endif /* HAVE_PSI_INTERFACE */
/*
@@ -1578,28 +1602,32 @@ int plugin_init(int *argc, char **argv, int flags)
dlopen_count =0;
- init_alloc_root(&plugin_mem_root, "plugin", 4096, 4096, MYF(0));
- init_alloc_root(&plugin_vars_mem_root, "plugin_vars", 4096, 4096, MYF(0));
- init_alloc_root(&tmp_root, "plugin_tmp", 4096, 4096, MYF(0));
+ init_plugin_psi_keys();
+
+ init_alloc_root(key_memory_plugin_mem_root, &plugin_mem_root, 4096, 4096, MYF(0));
+ init_alloc_root(key_memory_plugin_mem_root, &plugin_vars_mem_root, 4096, 4096, MYF(0));
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &tmp_root, 4096, 4096, MYF(0));
if (my_hash_init(&bookmark_hash, &my_charset_bin, 32, 0, 0,
- get_bookmark_hash_key, NULL, HASH_UNIQUE))
+ get_bookmark_hash_key, NULL, HASH_UNIQUE,
+ key_memory_plugin_bookmark))
goto err;
/*
The 80 is from 2016-04-27 when we had 71 default plugins
Big enough to avoid many mallocs even in future
*/
- if (my_init_dynamic_array(&plugin_dl_array,
+ if (my_init_dynamic_array(&plugin_dl_array, key_memory_mysql_plugin_dl,
sizeof(struct st_plugin_dl *), 16, 16, MYF(0)) ||
- my_init_dynamic_array(&plugin_array,
+ my_init_dynamic_array(&plugin_array, key_memory_mysql_plugin,
sizeof(struct st_plugin_int *), 80, 32, MYF(0)))
goto err;
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
{
if (my_hash_init(&plugin_hash[i], system_charset_info, 32, 0, 0,
- get_plugin_hash_key, NULL, HASH_UNIQUE))
+ get_plugin_hash_key, NULL, HASH_UNIQUE,
+ key_memory_plugin_mem_root))
goto err;
}
@@ -2832,7 +2860,8 @@ static void update_func_str(THD *thd, struct st_mysql_sys_var *var,
{
char *old= *(char**) tgt;
if (value)
- *(char**) tgt= my_strdup(value, MYF(0));
+ *(char**) tgt= my_strdup(key_memory_global_system_variables,
+ value, MYF(0));
else
*(char**) tgt= 0;
my_free(old);
@@ -2976,10 +3005,12 @@ static st_bookmark *register_var(const char *plugin, const char *name,
if (new_size > global_variables_dynamic_size)
{
global_system_variables.dynamic_variables_ptr= (char*)
- my_realloc(global_system_variables.dynamic_variables_ptr, new_size,
+ my_realloc(key_memory_global_system_variables,
+ global_system_variables.dynamic_variables_ptr, new_size,
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
max_system_variables.dynamic_variables_ptr= (char*)
- my_realloc(max_system_variables.dynamic_variables_ptr, new_size,
+ my_realloc(key_memory_global_system_variables,
+ max_system_variables.dynamic_variables_ptr, new_size,
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
/*
Clear the new variable value space. This is required for string
@@ -3021,7 +3052,8 @@ void sync_dynamic_session_variables(THD* thd, bool global_lock)
uint idx;
thd->variables.dynamic_variables_ptr= (char*)
- my_realloc(thd->variables.dynamic_variables_ptr,
+ my_realloc(key_memory_THD_variables,
+ thd->variables.dynamic_variables_ptr,
global_variables_dynamic_size,
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
@@ -3055,7 +3087,7 @@ void sync_dynamic_session_variables(THD* thd, bool global_lock)
{
char **pp= (char**) (thd->variables.dynamic_variables_ptr + v->offset);
if (*pp)
- *pp= my_strdup(*pp, MYF(MY_WME|MY_FAE));
+ *pp= my_strdup(key_memory_THD_variables, *pp, MYF(MY_WME|MY_FAE));
}
}
@@ -3912,7 +3944,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
(opt->flags & PLUGIN_VAR_MEMALLOC))
{
char *def_val= *(char**)var_def_ptr(opt);
- *(char**)val= def_val ? my_strdup(def_val, MYF(0)) : NULL;
+ *(char**)val= def_val ? my_strdup(PSI_INSTRUMENT_ME, def_val, MYF(0)) : NULL;
}
else
memcpy(val, var_def_ptr(opt), var_storage_size(opt->flags));
@@ -4349,9 +4381,7 @@ int thd_setspecific(MYSQL_THD thd, MYSQL_THD_KEY_T key, void *value)
void plugin_mutex_init()
{
-#ifdef HAVE_PSI_INTERFACE
init_plugin_psi_keys();
-#endif
mysql_mutex_init(key_LOCK_plugin, &LOCK_plugin, MY_MUTEX_INIT_FAST);
}
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index dcf445f3cfb..d0f2ca512cc 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -3800,10 +3800,9 @@ Prepared_statement::Prepared_statement(THD *thd_arg)
read_types(0),
m_sql_mode(thd->variables.sql_mode)
{
- init_sql_alloc(&main_mem_root, "Prepared_statement",
- thd_arg->variables.query_alloc_block_size,
- thd_arg->variables.query_prealloc_size,
- MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_prepared_statement_main_mem_root,
+ &main_mem_root, thd_arg->variables.query_alloc_block_size,
+ thd_arg->variables.query_prealloc_size, MYF(MY_THREAD_SPECIFIC));
*last_error= '\0';
}
@@ -5388,8 +5387,8 @@ bool Protocol_local::send_result_set_metadata(List<Item> *columns, uint)
{
DBUG_ASSERT(m_rset == 0 && !alloc_root_inited(&m_rset_root));
- init_sql_alloc(&m_rset_root, "send_result_set_metadata",
- MEM_ROOT_BLOCK_SIZE, 0, MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(PSI_INSTRUMENT_ME, &m_rset_root, MEM_ROOT_BLOCK_SIZE, 0,
+ MYF(MY_THREAD_SPECIFIC));
if (! (m_rset= new (&m_rset_root) List<Ed_row>))
return TRUE;
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index cee55761a98..2a47aa846eb 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -200,7 +200,8 @@ void PROF_MEASUREMENT::set_label(const char *status_arg,
sizes[1]= (function_arg == NULL) ? 0 : strlen(function_arg) + 1;
sizes[2]= (file_arg == NULL) ? 0 : strlen(file_arg) + 1;
- allocated_status_memory= (char *) my_malloc(sizes[0] + sizes[1] + sizes[2], MYF(0));
+ allocated_status_memory= (char *) my_malloc(key_memory_PROFILE, sizes[0] +
+ sizes[1] + sizes[2], MYF(0));
DBUG_ASSERT(allocated_status_memory != NULL);
cursor= allocated_status_memory;
@@ -289,7 +290,7 @@ void QUERY_PROFILE::set_query_source(char *query_source_arg, size_t query_length
DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
if (query_source_arg != NULL)
- query_source= my_strndup(query_source_arg, length, MYF(0));
+ query_source= my_strndup(key_memory_PROFILE, query_source_arg, length, MYF(0));
}
void QUERY_PROFILE::new_status(const char *status_arg,
diff --git a/sql/sql_profile.h b/sql/sql_profile.h
index b0b1642ee02..85018a2598b 100644
--- a/sql/sql_profile.h
+++ b/sql/sql_profile.h
@@ -54,6 +54,7 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table);
#include <sys/resource.h>
#endif
+extern PSI_memory_key key_memory_queue_item;
class PROF_MEASUREMENT;
class QUERY_PROFILE;
@@ -100,7 +101,8 @@ public:
{
struct queue_item *new_item;
- new_item= (struct queue_item *) my_malloc(sizeof(struct queue_item), MYF(0));
+ new_item= (struct queue_item *) my_malloc(key_memory_queue_item,
+ sizeof(struct queue_item), MYF(0));
new_item->payload= payload;
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 5bfa29b72c4..73fc01618e3 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1221,7 +1221,8 @@ check_slave_start_position(binlog_send_info *info, const char **errormsg,
if (!delete_list)
{
if (!(delete_list= (slave_connection_state::entry **)
- my_malloc(sizeof(*delete_list) * st->hash.records, MYF(MY_WME))))
+ my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(*delete_list) * st->hash.records, MYF(MY_WME))))
{
*errormsg= "Out of memory while checking slave start position";
err= ER_OUT_OF_RESOURCES;
@@ -1283,8 +1284,9 @@ gtid_find_binlog_file(slave_connection_state *state, char *out_name,
const char *errormsg= NULL;
char buf[FN_REFLEN];
- init_alloc_root(&memroot, "gtid_find_binlog_file",
- 8192, 0, MYF(MY_THREAD_SPECIFIC));
+ init_alloc_root(PSI_INSTRUMENT_ME, &memroot,
+ 10*(FN_REFLEN+sizeof(binlog_file_entry)), 0,
+ MYF(MY_THREAD_SPECIFIC));
if (!(list= get_binlog_list(&memroot)))
{
errormsg= "Out of memory while looking for GTID position in binlog";
@@ -4307,8 +4309,7 @@ bool show_binlogs(THD* thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
- init_alloc_root(&mem_root, "binlog_file_list", 8192, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_alloc_root(PSI_INSTRUMENT_ME, &mem_root, 8192, 0, MYF(MY_THREAD_SPECIFIC));
retry:
/*
The current mutex handling here is to ensure we get the current log position
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index f48edc8c180..9d96de96ff0 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6769,7 +6769,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
/* set a barrier for the array of SARGABLE_PARAM */
(*sargables)[0].field= 0;
- if (my_init_dynamic_array2(keyuse, sizeof(KEYUSE),
+ if (my_init_dynamic_array2(keyuse, thd->mem_root->m_psi_key, sizeof(KEYUSE),
thd->alloc(sizeof(KEYUSE) * 20), 20, 64,
MYF(MY_THREAD_SPECIFIC)))
DBUG_RETURN(TRUE);
@@ -18237,7 +18237,7 @@ TABLE *Create_tmp_table::start(THD *thd,
if (param->precomputed_group_by)
copy_func_count+= param->sum_func_count;
- init_sql_alloc(&own_root, "tmp_table", TABLE_ALLOC_BLOCK_SIZE, 0,
+ init_sql_alloc(key_memory_TABLE, &own_root, TABLE_ALLOC_BLOCK_SIZE, 0,
MYF(MY_THREAD_SPECIFIC));
if (!multi_alloc_root(&own_root,
@@ -24009,21 +24009,21 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
Field **ptr;
DBUG_ENTER("remove_dup_with_hash_index");
- if (unlikely(!my_multi_malloc(MYF(MY_WME),
- &key_buffer,
- (uint) ((key_length + extra_length) *
- (long) file->stats.records),
- &field_lengths,
- (uint) (field_count*sizeof(*field_lengths)),
- NullS)))
+ if (!my_multi_malloc(key_memory_hash_index_key_buffer, MYF(MY_WME),
+ &key_buffer,
+ (uint) ((key_length + extra_length) *
+ (long) file->stats.records),
+ &field_lengths,
+ (uint) (field_count*sizeof(*field_lengths)),
+ NullS))
DBUG_RETURN(1);
for (ptr= first_field, field_length=field_lengths ; *ptr ; ptr++)
(*field_length++)= (*ptr)->sort_length();
- if (unlikely(my_hash_init(&hash, &my_charset_bin,
- (uint) file->stats.records, 0,
- key_length, (my_hash_get_key) 0, 0, 0)))
+ if (my_hash_init(&hash, &my_charset_bin, (uint) file->stats.records, 0,
+ key_length, (my_hash_get_key) 0, 0, 0,
+ key_memory_hash_index_key_buffer))
{
my_free(key_buffer);
DBUG_RETURN(1);
@@ -27834,8 +27834,8 @@ JOIN::reoptimize(Item *added_where, table_map join_tables,
reset_query_plan();
if (!keyuse.buffer &&
- my_init_dynamic_array(&keyuse, sizeof(KEYUSE), 20, 64,
- MYF(MY_THREAD_SPECIFIC)))
+ my_init_dynamic_array(&keyuse, thd->mem_root->m_psi_key, sizeof(KEYUSE),
+ 20, 64, MYF(MY_THREAD_SPECIFIC)))
{
delete_dynamic(&added_keyuse);
return REOPT_ERROR;
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 616d4769e2f..3788abce423 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1095,7 +1095,7 @@ protected:
keyuse.buffer= NULL;
keyuse.malloc_flags= 0;
best_positions= 0; /* To detect errors */
- error= my_multi_malloc(MYF(MY_WME),
+ error= my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&best_positions,
sizeof(*best_positions) * (tables + 1),
&join_tab_keyuse,
diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc
index 7913a7d2b9f..654e2ee7aac 100644
--- a/sql/sql_servers.cc
+++ b/sql/sql_servers.cc
@@ -93,6 +93,8 @@ static uchar *servers_cache_get_key(FOREIGN_SERVER *server, size_t *length,
DBUG_RETURN((uchar*) server->server_name);
}
+static PSI_memory_key key_memory_servers;
+
#ifdef HAVE_PSI_INTERFACE
static PSI_rwlock_key key_rwlock_THR_LOCK_servers;
@@ -101,6 +103,11 @@ static PSI_rwlock_info all_servers_cache_rwlocks[]=
{ &key_rwlock_THR_LOCK_servers, "THR_LOCK_servers", PSI_FLAG_GLOBAL}
};
+static PSI_memory_info all_servers_cache_memory[]=
+{
+ { &key_memory_servers, "servers_cache", PSI_FLAG_GLOBAL}
+};
+
static void init_servers_cache_psi_keys(void)
{
const char* category= "sql";
@@ -111,6 +118,9 @@ static void init_servers_cache_psi_keys(void)
count= array_elements(all_servers_cache_rwlocks);
PSI_server->register_rwlock(category, all_servers_cache_rwlocks, count);
+
+ count= array_elements(all_servers_cache_memory);
+ mysql_memory_register(category, all_servers_cache_memory, count);
}
#endif /* HAVE_PSI_INTERFACE */
@@ -149,14 +159,15 @@ bool servers_init(bool dont_read_servers_table)
/* initialise our servers cache */
if (my_hash_init(&servers_cache, system_charset_info, 32, 0, 0,
- (my_hash_get_key) servers_cache_get_key, 0, 0))
+ (my_hash_get_key) servers_cache_get_key, 0, 0,
+ key_memory_servers))
{
return_val= TRUE; /* we failed, out of memory? */
goto end;
}
/* Initialize the mem root for data */
- init_sql_alloc(&mem, "servers", ACL_ALLOC_BLOCK_SIZE, 0,
+ init_sql_alloc(key_memory_servers, &mem, ACL_ALLOC_BLOCK_SIZE, 0,
MYF(MY_THREAD_SPECIFIC));
if (dont_read_servers_table)
@@ -206,7 +217,7 @@ static bool servers_load(THD *thd, TABLE_LIST *tables)
my_hash_reset(&servers_cache);
free_root(&mem, MYF(0));
- init_sql_alloc(&mem, "servers_load", ACL_ALLOC_BLOCK_SIZE, 0, MYF(0));
+ init_sql_alloc(key_memory_servers, &mem, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0));
if (init_read_record(&read_record_info,thd,table=tables[0].table, NULL, NULL,
1,0, FALSE))
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 040545f8e1b..cc08dadf2b8 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -571,8 +571,8 @@ static bool skip_ignored_dir_check= TRUE;
bool
ignore_db_dirs_init()
{
- return my_init_dynamic_array(&ignore_db_dirs_array, sizeof(LEX_CSTRING *),
- 0, 0, MYF(0));
+ return my_init_dynamic_array(&ignore_db_dirs_array, key_memory_ignored_db,
+ sizeof(LEX_STRING *), 0, 0, MYF(0));
}
@@ -620,8 +620,8 @@ push_ignored_db_dir(char *path)
return true;
// No need to normalize, it's only a directory name, not a path.
- if (!my_multi_malloc(0,
- &new_elt, sizeof(LEX_CSTRING),
+ if (!my_multi_malloc(key_memory_ignored_db, MYF(0),
+ &new_elt, sizeof(LEX_STRING),
&new_elt_buffer, path_len + 1,
NullS))
return true;
@@ -701,7 +701,7 @@ void ignore_db_dirs_append(const char *dirname_arg)
LEX_STRING *new_entry;
size_t len= strlen(dirname_arg);
- if (!my_multi_malloc(0,
+ if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(0),
&new_entry, sizeof(LEX_STRING),
&new_entry_buf, len + 1,
NullS))
@@ -723,7 +723,7 @@ void ignore_db_dirs_append(const char *dirname_arg)
// Add one for comma and one for \0.
size_t newlen= curlen + len + 1 + 1;
char *new_db_dirs;
- if (!(new_db_dirs= (char*)my_malloc(newlen ,MYF(0))))
+ if (!(new_db_dirs= (char*)my_malloc(PSI_INSTRUMENT_ME, newlen, MYF(0))))
{
// This is not a critical condition
return;
@@ -754,7 +754,7 @@ ignore_db_dirs_process_additions()
character_set_filesystem : &my_charset_bin,
0, 0, 0, db_dirs_hash_get_key,
dispose_db_dir,
- HASH_UNIQUE))
+ HASH_UNIQUE, key_memory_ignored_db))
return true;
/* len starts from 1 because of the terminating zero. */
@@ -776,7 +776,8 @@ ignore_db_dirs_process_additions()
len--;
/* +1 the terminating zero */
- ptr= opt_ignore_db_dirs= (char *) my_malloc(len + 1, MYF(0));
+ ptr= opt_ignore_db_dirs= (char *) my_malloc(key_memory_ignored_db, len + 1,
+ MYF(0));
if (!ptr)
return true;
@@ -3362,7 +3363,8 @@ int add_status_vars(SHOW_VAR *list)
if (status_vars_inited)
mysql_rwlock_wrlock(&LOCK_all_status_vars);
if (!all_status_vars.buffer && // array is not allocated yet - do it now
- my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 250, 50, MYF(0)))
+ my_init_dynamic_array(&all_status_vars, PSI_INSTRUMENT_ME,
+ sizeof(SHOW_VAR), 250, 50, MYF(0)))
{
res= 1;
goto err;
@@ -4890,8 +4892,8 @@ static int fill_schema_table_from_frm(THD *thd, TABLE *table,
if (schema_table->i_s_requested_object & OPEN_TRIGGER_ONLY)
{
- init_sql_alloc(&tbl.mem_root, "fill_schema_table_from_frm",
- TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0));
+ init_sql_alloc(key_memory_table_triggers_list,
+ &tbl.mem_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0));
if (!Table_triggers_list::check_n_load(thd, db_name,
table_name, &tbl, 1))
{
@@ -5045,7 +5047,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
ST_SCHEMA_TABLE *schema_table= tables->schema_table;
IS_table_read_plan *plan= tables->is_table_read_plan;
enum enum_schema_tables schema_table_idx;
- Dynamic_array<LEX_CSTRING*> db_names;
+ Dynamic_array<LEX_CSTRING*> db_names(PSI_INSTRUMENT_MEM);
Item *partial_cond= plan->partial_cond;
int error= 1;
Open_tables_backup open_tables_state_backup;
@@ -5114,7 +5116,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
goto err;
/* Use tmp_mem_root to allocate data for opened tables */
- init_alloc_root(&tmp_mem_root, "get_all_tables", SHOW_ALLOC_BLOCK_SIZE,
+ init_alloc_root(PSI_INSTRUMENT_ME, &tmp_mem_root, SHOW_ALLOC_BLOCK_SIZE,
SHOW_ALLOC_BLOCK_SIZE, MY_THREAD_SPECIFIC);
for (size_t i=0; i < db_names.elements(); i++)
@@ -5129,7 +5131,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
acl_get(sctx->host, sctx->ip, sctx->priv_user, db_name->str, 0))
#endif
{
- Dynamic_array<LEX_CSTRING*> table_names;
+ Dynamic_array<LEX_CSTRING*> table_names(PSI_INSTRUMENT_MEM);
int res= make_table_name_list(thd, &table_names, lex,
&plan->lookup_field_vals, db_name);
if (unlikely(res == 2)) /* Not fatal error, continue */
@@ -5245,7 +5247,7 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
*/
LOOKUP_FIELD_VALUES lookup_field_vals;
- Dynamic_array<LEX_CSTRING*> db_names;
+ Dynamic_array<LEX_CSTRING*> db_names(PSI_INSTRUMENT_MEM);
Schema_specification_st create;
TABLE *table= tables->table;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -9533,7 +9535,8 @@ int initialize_schema_table(st_plugin_int *plugin)
ST_SCHEMA_TABLE *schema_table;
DBUG_ENTER("initialize_schema_table");
- if (!(schema_table= (ST_SCHEMA_TABLE *)my_malloc(sizeof(ST_SCHEMA_TABLE),
+ if (!(schema_table= (ST_SCHEMA_TABLE *)my_malloc(key_memory_ST_SCHEMA_TABLE,
+ sizeof(ST_SCHEMA_TABLE),
MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(1);
/* Historical Requirement */
diff --git a/sql/sql_sort.h b/sql/sql_sort.h
index 3635bc32974..5b3f5a67d17 100644
--- a/sql/sql_sort.h
+++ b/sql/sql_sort.h
@@ -183,7 +183,7 @@ public:
/// rr_unpack_from_tempfile needs an extra buffer when unpacking.
uchar *allocate_addon_buf(uint sz)
{
- m_addon_buf= (uchar *)my_malloc(sz, MYF(MY_WME | MY_THREAD_SPECIFIC));
+ m_addon_buf= (uchar *)my_malloc(PSI_INSTRUMENT_ME, sz, MYF(MY_WME | MY_THREAD_SPECIFIC));
if (m_addon_buf)
m_addon_buf_length= sz;
return m_addon_buf;
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index a94fb1196b4..55e8e52c052 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -1432,7 +1432,7 @@ public:
*/
bool init(uint n_keyparts)
{
- if (!(rowid_buf= (uchar*)my_malloc(rowid_size, MYF(0))))
+ if (!(rowid_buf= (uchar*)my_malloc(PSI_INSTRUMENT_ME, rowid_size, MYF(0))))
return true;
if (open_cached_file(&io_cache, mysql_tmpdir, TEMP_PREFIX,
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 4ddc467794f..2fc6ae0ad7d 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -41,8 +41,8 @@ bool Binary_string::real_alloc(size_t length)
if (Alloced_length < arg_length)
{
free();
- if (!(Ptr=(char*) my_malloc(arg_length,MYF(MY_WME |
- (thread_specific ?
+ if (!(Ptr=(char*) my_malloc(PSI_INSTRUMENT_ME,
+ arg_length,MYF(MY_WME | (thread_specific ?
MY_THREAD_SPECIFIC : 0)))))
return TRUE;
DBUG_ASSERT(length < UINT_MAX32);
@@ -92,13 +92,13 @@ bool Binary_string::realloc_raw(size_t alloc_length)
return TRUE; /* Overflow */
if (alloced)
{
- if (!(new_ptr= (char*) my_realloc(Ptr,len,
+ if (!(new_ptr= (char*) my_realloc(PSI_INSTRUMENT_ME, Ptr,len,
MYF(MY_WME |
(thread_specific ?
MY_THREAD_SPECIFIC : 0)))))
return TRUE; // Signal error
}
- else if ((new_ptr= (char*) my_malloc(len,
+ else if ((new_ptr= (char*) my_malloc(PSI_INSTRUMENT_ME, len,
MYF(MY_WME |
(thread_specific ?
MY_THREAD_SPECIFIC : 0)))))
@@ -1236,3 +1236,25 @@ bool String::append_semi_hex(const char *s, uint len, CHARSET_INFO *cs)
str_length+= nbytes;
return false;
}
+
+// Shrink the buffer, but only if it is allocated on the heap.
+void Binary_string::shrink(size_t arg_length)
+{
+ if (!is_alloced())
+ return;
+ if (ALIGN_SIZE(arg_length + 1) < Alloced_length)
+ {
+ char* new_ptr;
+ if (!(new_ptr = (char*)my_realloc(STRING_PSI_MEMORY_KEY, Ptr, arg_length,
+ MYF(thread_specific ? MY_THREAD_SPECIFIC : 0))))
+ {
+ Alloced_length = 0;
+ real_alloc(arg_length);
+ }
+ else
+ {
+ Ptr = new_ptr;
+ Alloced_length = (uint32)arg_length;
+ }
+ }
+}
diff --git a/sql/sql_string.h b/sql/sql_string.h
index eb69d21eaeb..4eeac0a8a82 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -30,6 +30,13 @@
#include "sql_list.h"
class String;
+#ifdef MYSQL_SERVER
+extern PSI_memory_key key_memory_String_value;
+#define STRING_PSI_MEMORY_KEY key_memory_String_value
+#else
+#define STRING_PSI_MEMORY_KEY PSI_NOT_INSTRUMENTED
+#endif
+
typedef struct st_io_cache IO_CACHE;
typedef struct st_mem_root MEM_ROOT;
@@ -659,28 +666,8 @@ public:
return realloc_with_extra(arg_length);
}
// Shrink the buffer, but only if it is allocated on the heap.
- inline void shrink(size_t arg_length)
- {
- if (!is_alloced())
- return;
- if (ALIGN_SIZE(arg_length+1) < Alloced_length)
- {
- char *new_ptr;
- if (unlikely(!(new_ptr=(char*)
- my_realloc(Ptr,
- arg_length,MYF((thread_specific ?
- MY_THREAD_SPECIFIC : 0))))))
- {
- Alloced_length= 0;
- real_alloc(arg_length);
- }
- else
- {
- Ptr= new_ptr;
- Alloced_length= (uint32) arg_length;
- }
- }
- }
+ void shrink(size_t arg_length);
+
void move(Binary_string &s)
{
set_alloced(s.Ptr, s.str_length, s.Alloced_length);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index e64fddad4c0..4239fcc8de7 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1127,8 +1127,8 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
ddl_log_entry->tmp_name));
handler_name.str= (char*)ddl_log_entry->handler_name;
handler_name.length= strlen(ddl_log_entry->handler_name);
- init_sql_alloc(&mem_root, "execute_ddl_log_action", TABLE_ALLOC_BLOCK_SIZE,
- 0, MYF(MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_gdl, &mem_root, TABLE_ALLOC_BLOCK_SIZE, 0,
+ MYF(MY_THREAD_SPECIFIC));
if (!strcmp(ddl_log_entry->handler_name, reg_ext))
frm_action= TRUE;
else
@@ -1162,7 +1162,7 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
strxmov(to_path, ddl_log_entry->name, par_ext, NullS);
- (void) mysql_file_delete(key_file_partition, to_path, MYF(MY_WME));
+ (void) mysql_file_delete(key_file_partition_ddl_log, to_path, MYF(MY_WME));
#endif
}
else
@@ -1200,7 +1200,7 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
#ifdef WITH_PARTITION_STORAGE_ENGINE
strxmov(to_path, ddl_log_entry->name, par_ext, NullS);
strxmov(from_path, ddl_log_entry->from_name, par_ext, NullS);
- (void) mysql_file_rename(key_file_partition, from_path, to_path, MYF(MY_WME));
+ (void) mysql_file_rename(key_file_partition_ddl_log, from_path, to_path, MYF(MY_WME));
#endif
}
else
@@ -1297,7 +1297,7 @@ static bool get_free_ddl_log_entry(DDL_LOG_MEMORY_ENTRY **active_entry,
if (global_ddl_log.first_free == NULL)
{
- if (!(used_entry= (DDL_LOG_MEMORY_ENTRY*)my_malloc(
+ if (!(used_entry= (DDL_LOG_MEMORY_ENTRY*)my_malloc(key_memory_DDL_LOG_MEMORY_ENTRY,
sizeof(DDL_LOG_MEMORY_ENTRY), MYF(MY_WME))))
{
sql_print_error("Failed to allocate memory for ddl log free list");
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 07e2d5e084e..c14f15908b1 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -466,8 +466,10 @@ static void display_table_locks(void)
void *saved_base;
DYNAMIC_ARRAY saved_table_locks;
- (void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO),
- tc_records() + 20, 50, MYF(0));
+ (void) my_init_dynamic_array(&saved_table_locks,
+ key_memory_locked_thread_list,
+ sizeof(TABLE_LOCK_INFO), tc_records() + 20, 50,
+ MYF(0));
mysql_mutex_lock(&THR_LOCK_lock);
for (list= thr_lock_thread_list; list; list= list_rest(list))
{
diff --git a/sql/sql_time.cc b/sql/sql_time.cc
index 8a9311ae577..c08e54bed87 100644
--- a/sql/sql_time.cc
+++ b/sql/sql_time.cc
@@ -830,7 +830,8 @@ DATE_TIME_FORMAT *date_time_format_copy(THD *thd, DATE_TIME_FORMAT *format)
if (thd)
new_format= (DATE_TIME_FORMAT *) thd->alloc(length);
else
- new_format= (DATE_TIME_FORMAT *) my_malloc(length, MYF(MY_WME));
+ new_format= (DATE_TIME_FORMAT *) my_malloc(key_memory_DATE_TIME_FORMAT,
+ length, MYF(MY_WME));
if (new_format)
{
/* Put format string after current pos */
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 0ae3d58b11f..d683bdc7055 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -1813,8 +1813,8 @@ bool Table_triggers_list::drop_all_triggers(THD *thd, const LEX_CSTRING *db,
DBUG_ENTER("Triggers::drop_all_triggers");
table.reset();
- init_sql_alloc(&table.mem_root, "Triggers::drop_all_triggers", 8192, 0,
- MYF(0));
+ init_sql_alloc(key_memory_Table_trigger_dispatcher,
+ &table.mem_root, 8192, 0, MYF(0));
if (Table_triggers_list::check_n_load(thd, db, name, &table, 1))
{
@@ -2065,8 +2065,8 @@ bool Table_triggers_list::change_table_name(THD *thd, const LEX_CSTRING *db,
DBUG_ENTER("Triggers::change_table_name");
table.reset();
- init_sql_alloc(&table.mem_root, "Triggers::change_table_name", 8192, 0,
- MYF(0));
+ init_sql_alloc(key_memory_Table_trigger_dispatcher,
+ &table.mem_root, 8192, 0, MYF(0));
/*
This method interfaces the mysql server code protected by
diff --git a/sql/sql_type.h b/sql/sql_type.h
index 588984f08bc..f87e398bd71 100644
--- a/sql/sql_type.h
+++ b/sql/sql_type.h
@@ -7287,7 +7287,7 @@ private:
const Type_handler *handler2) const;
public:
Type_aggregator(bool is_commutative= false)
- :m_is_commutative(is_commutative)
+ :m_is_commutative(is_commutative), m_array(PSI_INSTRUMENT_MEM)
{ }
bool add(const Type_handler *handler1,
const Type_handler *handler2,
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 35c799d4a86..38328c91db3 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -110,6 +110,8 @@ extern "C" uchar* get_hash_key(const uchar *buff, size_t *length,
return (uchar*) udf->name.str;
}
+static PSI_memory_key key_memory_udf_mem;
+
#ifdef HAVE_PSI_INTERFACE
static PSI_rwlock_key key_rwlock_THR_LOCK_udf;
@@ -118,6 +120,11 @@ static PSI_rwlock_info all_udf_rwlocks[]=
{ &key_rwlock_THR_LOCK_udf, "THR_LOCK_udf", PSI_FLAG_GLOBAL}
};
+static PSI_memory_info all_udf_memory[]=
+{
+ { &key_memory_udf_mem, "udf_mem", PSI_FLAG_GLOBAL}
+};
+
static void init_udf_psi_keys(void)
{
const char* category= "sql";
@@ -128,6 +135,9 @@ static void init_udf_psi_keys(void)
count= array_elements(all_udf_rwlocks);
PSI_server->register_rwlock(category, all_udf_rwlocks, count);
+
+ count= array_elements(all_udf_memory);
+ mysql_memory_register(category, all_udf_memory, count);
}
#endif
@@ -154,10 +164,11 @@ void udf_init()
mysql_rwlock_init(key_rwlock_THR_LOCK_udf, &THR_LOCK_udf);
- init_sql_alloc(&mem, "udf", UDF_ALLOC_BLOCK_SIZE, 0, MYF(0));
+ init_sql_alloc(key_memory_udf_mem, &mem, UDF_ALLOC_BLOCK_SIZE, 0, MYF(0));
THD *new_thd = new THD(0);
if (!new_thd ||
- my_hash_init(&udf_hash,system_charset_info,32,0,0,get_hash_key, NULL, 0))
+ my_hash_init(&udf_hash,system_charset_info,32,0,0,get_hash_key, NULL, 0,
+ key_memory_udf_mem))
{
sql_print_error("Can't allocate memory for udf structures");
my_hash_free(&udf_hash);
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 7e319c96000..a9a1dccf9f6 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -778,10 +778,10 @@ public:
{
//DBUG_ASSERT(info->read_record == rr_from_tempfile);
rownum= 0;
- io_cache= (IO_CACHE*)my_malloc(sizeof(IO_CACHE), MYF(0));
+ io_cache= (IO_CACHE*)my_malloc(PSI_INSTRUMENT_ME, sizeof(IO_CACHE), MYF(0));
init_slave_io_cache(info->io_cache, io_cache);
- ref_buffer= (uchar*)my_malloc(ref_length, MYF(0));
+ ref_buffer= (uchar*)my_malloc(PSI_INSTRUMENT_ME, ref_length, MYF(0));
ref_buffer_valid= false;
}
}
@@ -2816,7 +2816,7 @@ bool compute_window_func(THD *thd,
List_iterator_fast<Group_bound_tracker> iter_part_trackers(partition_trackers);
ha_rows rownum= 0;
- uchar *rowid_buf= (uchar*) my_malloc(tbl->file->ref_length, MYF(0));
+ uchar *rowid_buf= (uchar*) my_malloc(PSI_INSTRUMENT_ME, tbl->file->ref_length, MYF(0));
while (true)
{
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 0d67c00bdbb..0025d23725f 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -1935,7 +1935,8 @@ Sys_var_gtid_binlog_state::do_check(THD *thd, set_var *var)
my_error(ER_INCORRECT_GTID_STATE, MYF(0));
return true;
}
- if (!(data= (gtid_binlog_state_data *)my_malloc(sizeof(*data), MYF(0))))
+ if (!(data= (gtid_binlog_state_data *)my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(*data), MYF(0))))
{
my_free(list);
my_error(ER_OUT_OF_RESOURCES, MYF(0));
diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic
index f33f469b160..698062d9bed 100644
--- a/sql/sys_vars.ic
+++ b/sql/sys_vars.ic
@@ -529,7 +529,8 @@ public:
size_t len=var->save_result.string_value.length;
if (ptr)
{
- new_val= (char*)my_memdup(ptr, len+1, MYF(MY_WME));
+ new_val= (char*)my_memdup(key_memory_Sys_var_charptr_value,
+ ptr, len+1, MYF(MY_WME));
if (!new_val) return 0;
new_val[len]=0;
}
diff --git a/sql/table.cc b/sql/table.cc
index 8f5f5614cd8..7c982584d52 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -323,7 +323,8 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name,
path_length= build_table_filename(path, sizeof(path) - 1,
db, table_name, "", 0);
- init_sql_alloc(&mem_root, "table_share", TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0));
+ init_sql_alloc(key_memory_table_share, &mem_root, TABLE_ALLOC_BLOCK_SIZE, 0,
+ MYF(0));
if (multi_alloc_root(&mem_root,
&share, sizeof(*share),
&key_buff, key_length,
@@ -349,7 +350,7 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name,
table_alias_charset->strnncoll(key, 6, "mysql", 6) == 0)
share->not_usable_by_query_cache= 1;
- init_sql_alloc(&share->stats_cb.mem_root, "share_stats",
+ init_sql_alloc(PSI_INSTRUMENT_ME, &share->stats_cb.mem_root,
TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0));
memcpy((char*) &share->mem_root, (char*) &mem_root, sizeof(mem_root));
@@ -411,8 +412,9 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
This can't be MY_THREAD_SPECIFIC for slaves as they are freed
during cleanup() from Relay_log_info::close_temporary_tables()
*/
- init_sql_alloc(&share->mem_root, "tmp_table_share", TABLE_ALLOC_BLOCK_SIZE,
- 0, MYF(thd->slave_thread ? 0 : MY_THREAD_SPECIFIC));
+ init_sql_alloc(key_memory_table_share, &share->mem_root,
+ TABLE_ALLOC_BLOCK_SIZE, 0,
+ MYF(thd->slave_thread ? 0 : MY_THREAD_SPECIFIC));
share->table_category= TABLE_CATEGORY_TEMPORARY;
share->tmp_table= INTERNAL_TMP_TABLE;
share->db.str= (char*) key;
@@ -676,7 +678,8 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
frmlen= uint4korr(head+10);
set_if_smaller(frmlen, FRM_MAX_SIZE); // safety
- if (!(buf= (uchar*)my_malloc(frmlen, MYF(MY_THREAD_SPECIFIC|MY_WME))))
+ if (!(buf= (uchar*)my_malloc(PSI_INSTRUMENT_ME, frmlen,
+ MYF(MY_THREAD_SPECIFIC|MY_WME))))
goto err;
memcpy(buf, head, sizeof(head));
@@ -2195,10 +2198,10 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
use_hash= share->fields >= MAX_FIELDS_BEFORE_HASH;
if (use_hash)
- use_hash= !my_hash_init(&share->name_hash,
- system_charset_info,
- share->fields,0,0,
- (my_hash_get_key) get_field_name,0,0);
+ use_hash= !my_hash_init(&share->name_hash, system_charset_info,
+ share->fields, 0, 0,
+ (my_hash_get_key) get_field_name, 0, 0,
+ PSI_INSTRUMENT_ME);
if (share->mysql_version >= 50700 && share->mysql_version < 100000 &&
vcol_screen_length)
@@ -3756,8 +3759,8 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
error= OPEN_FRM_NEEDS_REBUILD;
goto err;
}
- init_sql_alloc(&outparam->mem_root, "table", TABLE_ALLOC_BLOCK_SIZE, 0,
- MYF(0));
+ init_sql_alloc(key_memory_TABLE, &outparam->mem_root, TABLE_ALLOC_BLOCK_SIZE,
+ 0, MYF(0));
/*
We have to store the original alias in mem_root as constraints and virtual
diff --git a/sql/table.h b/sql/table.h
index 416490a80a9..0a91df9c04c 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1075,8 +1075,8 @@ private:
public:
Blob_mem_storage() :truncated_value(false)
{
- init_alloc_root(&storage, "Blob_mem_storage", MAX_FIELD_VARCHARLENGTH, 0,
- MYF(0));
+ init_alloc_root(key_memory_blob_mem_storage,
+ &storage, MAX_FIELD_VARCHARLENGTH, 0, MYF(0));
}
~ Blob_mem_storage()
{
diff --git a/sql/table_cache.cc b/sql/table_cache.cc
index 8e5c3a8471d..5578bd59966 100644
--- a/sql/table_cache.cc
+++ b/sql/table_cache.cc
@@ -1257,10 +1257,9 @@ int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
if (no_dups)
{
- init_alloc_root(&no_dups_argument.root, "no_dups", 4096, 4096,
- MYF(alloc_flags));
+ init_alloc_root(PSI_INSTRUMENT_ME, &no_dups_argument.root, 4096, 4096, MYF(alloc_flags));
my_hash_init(&no_dups_argument.hash, &my_charset_bin, tdc_records(), 0, 0,
- eliminate_duplicates_get_key, 0, hash_flags);
+ eliminate_duplicates_get_key, 0, hash_flags, PSI_INSTRUMENT_ME);
no_dups_argument.action= action;
no_dups_argument.argument= argument;
action= (my_hash_walk_action) eliminate_duplicates;
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc
index 2e0f0a4918e..c675b11741a 100644
--- a/sql/temporary_tables.cc
+++ b/sql/temporary_tables.cc
@@ -955,7 +955,8 @@ TMP_TABLE_SHARE *THD::create_temporary_table(LEX_CUSTRING *frm,
/* Create the table definition key for the temporary table. */
key_length= create_tmp_table_def_key(key_cache, db, table_name);
- if (!(share= (TMP_TABLE_SHARE *) my_malloc(sizeof(TMP_TABLE_SHARE) +
+ if (!(share= (TMP_TABLE_SHARE *) my_malloc(key_memory_table_share,
+ sizeof(TMP_TABLE_SHARE) +
strlen(path) + 1 + key_length,
MYF(MY_WME))))
{
@@ -1002,7 +1003,8 @@ TMP_TABLE_SHARE *THD::create_temporary_table(LEX_CUSTRING *frm,
if (!temporary_tables)
{
if ((temporary_tables=
- (All_tmp_tables_list *) my_malloc(sizeof(All_tmp_tables_list),
+ (All_tmp_tables_list *) my_malloc(key_memory_table_share,
+ sizeof(All_tmp_tables_list),
MYF(MY_WME))))
{
temporary_tables->empty();
@@ -1107,7 +1109,8 @@ TABLE *THD::open_temporary_table(TMP_TABLE_SHARE *share,
DBUG_ENTER("THD::open_temporary_table");
- if (!(table= (TABLE *) my_malloc(sizeof(TABLE), MYF(MY_WME))))
+ if (!(table= (TABLE *) my_malloc(key_memory_TABLE, sizeof(TABLE),
+ MYF(MY_WME))))
{
DBUG_RETURN(NULL); /* Out of memory */
}
diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc
index d43e7c4c9b5..89ad359befa 100644
--- a/sql/thr_malloc.cc
+++ b/sql/thr_malloc.cc
@@ -58,11 +58,10 @@ extern "C" {
}
}
-void init_sql_alloc(MEM_ROOT *mem_root,
- const char *area_name __attribute__((unused)),
- uint block_size, uint pre_alloc, myf my_flags)
+void init_sql_alloc(PSI_memory_key key, MEM_ROOT *mem_root, uint block_size,
+ uint pre_alloc, myf my_flags)
{
- init_alloc_root(mem_root, area_name, block_size, pre_alloc, my_flags);
+ init_alloc_root(key, mem_root, block_size, pre_alloc, my_flags);
mem_root->error_handler=sql_alloc_error_handler;
}
diff --git a/sql/thr_malloc.h b/sql/thr_malloc.h
index a6ab5477d41..cc56666bcc9 100644
--- a/sql/thr_malloc.h
+++ b/sql/thr_malloc.h
@@ -18,8 +18,8 @@
typedef struct st_mem_root MEM_ROOT;
-void init_sql_alloc(MEM_ROOT *root, const char *area_name, uint block_size,
- uint pre_alloc_size, myf my_flags);
+void init_sql_alloc(PSI_memory_key key, MEM_ROOT *root, uint block_size, uint
+ pre_alloc_size, myf my_flags);
char *sql_strmake_with_convert(THD *thd, const char *str, size_t arg_length,
CHARSET_INFO *from_cs,
size_t max_res_length,
diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc
index e11a0613425..e8e3497eae4 100644
--- a/sql/threadpool_generic.cc
+++ b/sql/threadpool_generic.cc
@@ -1532,7 +1532,8 @@ int TP_pool_generic::init()
DBUG_ENTER("TP_pool_generic::TP_pool_generic");
threadpool_max_size= MY_MAX(threadpool_size, 128);
all_groups= (thread_group_t *)
- my_malloc(sizeof(thread_group_t) * threadpool_max_size, MYF(MY_WME|MY_ZEROFILL));
+ my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(thread_group_t) * threadpool_max_size, MYF(MY_WME|MY_ZEROFILL));
if (!all_groups)
{
threadpool_max_size= 0;
diff --git a/sql/tztime.cc b/sql/tztime.cc
index fbac2923a84..a38bb2b0fc8 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -1543,6 +1543,8 @@ tz_init_table_list(TABLE_LIST *tz_tabs)
}
}
+static PSI_memory_key key_memory_tz_storage;
+
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key key_tz_LOCK;
@@ -1551,6 +1553,11 @@ static PSI_mutex_info all_tz_mutexes[]=
{ & key_tz_LOCK, "tz_LOCK", PSI_FLAG_GLOBAL}
};
+static PSI_memory_info all_tz_memory[]=
+{
+ { &key_memory_tz_storage, "tz_storage", PSI_FLAG_GLOBAL}
+};
+
static void init_tz_psi_keys(void)
{
const char* category= "sql";
@@ -1561,6 +1568,9 @@ static void init_tz_psi_keys(void)
count= array_elements(all_tz_mutexes);
PSI_server->register_mutex(category, all_tz_mutexes, count);
+
+ count= array_elements(all_tz_memory);
+ mysql_memory_register(category, all_tz_memory, count);
}
#endif /* HAVE_PSI_INTERFACE */
@@ -1616,19 +1626,21 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
/* Init all memory structures that require explicit destruction */
if (my_hash_init(&tz_names, &my_charset_latin1, 20,
- 0, 0, (my_hash_get_key) my_tz_names_get_key, 0, 0))
+ 0, 0, (my_hash_get_key) my_tz_names_get_key, 0, 0,
+ key_memory_tz_storage))
{
sql_print_error("Fatal error: OOM while initializing time zones");
goto end;
}
if (my_hash_init(&offset_tzs, &my_charset_latin1, 26, 0, 0,
- (my_hash_get_key)my_offset_tzs_get_key, 0, 0))
+ (my_hash_get_key)my_offset_tzs_get_key, 0, 0,
+ key_memory_tz_storage))
{
sql_print_error("Fatal error: OOM while initializing time zones");
my_hash_free(&tz_names);
goto end;
}
- init_sql_alloc(&tz_storage, "timezone_storage", 32 * 1024, 0, MYF(0));
+ init_sql_alloc(key_memory_tz_storage, &tz_storage, 32 * 1024, 0, MYF(0));
mysql_mutex_init(key_tz_LOCK, &tz_LOCK, MY_MUTEX_INIT_FAST);
tz_inited= 1;
@@ -2568,8 +2580,8 @@ scan_tz_dir(char * name_end, uint symlink_recursion_level, uint verbose)
}
else if (MY_S_ISREG(cur_dir->dir_entry[i].mystat->st_mode))
{
- init_alloc_root(&tz_storage, "timezone_storage", 32768, 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_alloc_root(PSI_INSTRUMENT_ME, &tz_storage,
+ 32768, 0, MYF(MY_THREAD_SPECIFIC));
if (!tz_load(fullname, &tz_info, &tz_storage))
print_tz_as_sql(root_name_end + 1, &tz_info);
else
@@ -2758,7 +2770,7 @@ main(int argc, char **argv)
First argument is timezonefile.
The second is timezonename if opt_leap is not given
*/
- init_alloc_root(&tz_storage, "timezone_storage", 32768, 0, MYF(0));
+ init_alloc_root(PSI_INSTRUMENT_ME, &tz_storage, 32768, 0, MYF(0));
if (tz_load(argv[0], &tz_info, &tz_storage))
{
diff --git a/sql/uniques.cc b/sql/uniques.cc
index db9891158b0..6b486e48444 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -93,8 +93,8 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
init_tree(&tree, (max_in_memory_size / 16), 0, size, comp_func,
NULL, comp_func_fixed_arg, MYF(MY_THREAD_SPECIFIC));
/* If the following fail's the next add will also fail */
- my_init_dynamic_array(&file_ptrs, sizeof(Merge_chunk), 16, 16,
- MYF(MY_THREAD_SPECIFIC));
+ my_init_dynamic_array(&file_ptrs, PSI_INSTRUMENT_ME, sizeof(Merge_chunk), 16,
+ 16, MYF(MY_THREAD_SPECIFIC));
/*
If you change the following, change it in get_max_elements function, too.
*/
@@ -662,7 +662,8 @@ bool Unique::walk(TABLE *table, tree_walk_action action, void *walk_action_arg)
is needed when a piece of merge buffer is re-read, see merge_walk()
*/
size_t buff_sz= MY_MAX(MERGEBUFF2+1, max_in_memory_size/full_size+1) * full_size;
- if (!(merge_buffer = (uchar *)my_malloc(buff_sz, MYF(MY_WME))))
+ if (!(merge_buffer = (uchar *)my_malloc(key_memory_Unique_merge_buffer,
+ buff_sz, MYF(MY_THREAD_SPECIFIC|MY_WME))))
return 1;
if (buff_sz < full_size * (file_ptrs.elements + 1UL))
res= merge(table, merge_buffer, buff_sz,
@@ -782,7 +783,8 @@ bool Unique::get(TABLE *table)
{
/* Whole tree is in memory; Don't use disk if you don't need to */
if ((sort.record_pointers= (uchar*)
- my_malloc(size * tree.elements_in_tree, MYF(MY_THREAD_SPECIFIC))))
+ my_malloc(key_memory_Filesort_info_record_pointers,
+ size * tree.elements_in_tree, MYF(MY_THREAD_SPECIFIC))))
{
uchar *save_record_pointers= sort.record_pointers;
tree_walk_action action= min_dupl_count ?
@@ -801,7 +803,7 @@ bool Unique::get(TABLE *table)
if (flush())
DBUG_RETURN(1);
size_t buff_sz= (max_in_memory_size / full_size + 1) * full_size;
- if (!(sort_buffer= (uchar*) my_malloc(buff_sz,
+ if (!(sort_buffer= (uchar*) my_malloc(key_memory_Unique_sort_buffer, buff_sz,
MYF(MY_THREAD_SPECIFIC|MY_WME))))
DBUG_RETURN(1);
diff --git a/sql/unireg.cc b/sql/unireg.cc
index e4a43d3ace5..2aa46131efb 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -425,8 +425,8 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
DBUG_RETURN(frm);
}
- frm_ptr= (uchar*) my_malloc(frm.length, MYF(MY_WME | MY_ZEROFILL |
- MY_THREAD_SPECIFIC));
+ frm_ptr= (uchar*) my_malloc(PSI_INSTRUMENT_ME, frm.length,
+ MYF(MY_WME | MY_ZEROFILL | MY_THREAD_SPECIFIC));
if (!frm_ptr)
DBUG_RETURN(frm);
diff --git a/sql/wsrep_binlog.cc b/sql/wsrep_binlog.cc
index a81503a50da..f555480d2e0 100644
--- a/sql/wsrep_binlog.cc
+++ b/sql/wsrep_binlog.cc
@@ -64,7 +64,7 @@ int wsrep_write_cache_buf(IO_CACHE *cache, uchar **buf, size_t *buf_len)
wsrep_max_ws_size, total_length);
goto error;
}
- uchar* tmp= (uchar *)my_realloc(*buf, total_length,
+ uchar* tmp= (uchar *)my_realloc(PSI_INSTRUMENT_ME, *buf, total_length,
MYF(MY_ALLOW_ZERO_PTR));
if (!tmp)
{
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index ff01473e816..e170037956b 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -1270,7 +1270,7 @@ static bool wsrep_prepare_key_for_isolation(const char* db,
wsrep_key_arr_t* ka)
{
wsrep_key_t* tmp;
- tmp= (wsrep_key_t*)my_realloc(ka->keys,
+ tmp= (wsrep_key_t*)my_realloc(PSI_INSTRUMENT_ME, ka->keys,
(ka->keys_len + 1) * sizeof(wsrep_key_t),
MYF(MY_ALLOW_ZERO_PTR));
if (!tmp)
@@ -1280,7 +1280,7 @@ static bool wsrep_prepare_key_for_isolation(const char* db,
}
ka->keys= tmp;
if (!(ka->keys[ka->keys_len].key_parts= (wsrep_buf_t*)
- my_malloc(sizeof(wsrep_buf_t)*2, MYF(0))))
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(wsrep_buf_t)*2, MYF(0))))
{
WSREP_ERROR("Can't allocate memory for key_parts");
return false;
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index d478ea486cd..0bb8a9eb675 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -245,7 +245,7 @@ static bool sst_auth_real_set (const char* value)
if (value)
{
- v= my_strdup(value, MYF(0));
+ v= my_strdup(PSI_INSTRUMENT_ME, value, MYF(0));
}
else // its NULL
{
@@ -263,7 +263,7 @@ static bool sst_auth_real_set (const char* value)
if (strlen(sst_auth_real))
{
if (wsrep_sst_auth) { my_free((void*) wsrep_sst_auth); }
- wsrep_sst_auth= my_strdup(WSREP_SST_AUTH_MASK, MYF(0));
+ wsrep_sst_auth= my_strdup(PSI_INSTRUMENT_ME, WSREP_SST_AUTH_MASK, MYF(0));
}
return 0;
}
@@ -414,7 +414,7 @@ static char* generate_name_value(const char* name, const char* value)
size_t name_len= strlen(name);
size_t value_len= strlen(value);
char* buf=
- (char*) my_malloc((name_len + value_len + 5) * sizeof(char), MYF(0));
+ (char*) my_malloc(PSI_INSTRUMENT_ME, (name_len + value_len + 5), MYF(0));
if (buf)
{
char* ref= buf;
@@ -449,11 +449,11 @@ static int generate_binlog_opt_val(char** ret)
*ret= strcmp(opt_bin_logname, "0") ?
generate_name_value(WSREP_SST_OPT_BINLOG,
opt_bin_logname) :
- my_strdup("", MYF(0));
+ my_strdup(PSI_INSTRUMENT_ME, "", MYF(0));
}
else
{
- *ret= my_strdup("", MYF(0));
+ *ret= my_strdup(PSI_INSTRUMENT_ME, "", MYF(0));
}
if (!*ret) return -ENOMEM;
return 0;
@@ -468,11 +468,11 @@ static int generate_binlog_index_opt_val(char** ret)
*ret= strcmp(opt_binlog_index_name, "0") ?
generate_name_value(WSREP_SST_OPT_BINLOG_INDEX,
opt_binlog_index_name) :
- my_strdup("", MYF(0));
+ my_strdup(PSI_INSTRUMENT_ME, "", MYF(0));
}
else
{
- *ret= my_strdup("", MYF(0));
+ *ret= my_strdup(PSI_INSTRUMENT_ME, "", MYF(0));
}
if (!*ret) return -ENOMEM;
return 0;
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index 950e4aae34d..28dbe4096f7 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -30,17 +30,17 @@ ulong wsrep_reject_queries;
int wsrep_init_vars()
{
- wsrep_provider = my_strdup(WSREP_NONE, MYF(MY_WME));
- wsrep_provider_options= my_strdup("", MYF(MY_WME));
- wsrep_cluster_address = my_strdup("", MYF(MY_WME));
- wsrep_cluster_name = my_strdup(WSREP_CLUSTER_NAME, MYF(MY_WME));
- wsrep_node_name = my_strdup("", MYF(MY_WME));
- wsrep_node_address = my_strdup("", MYF(MY_WME));
- wsrep_node_incoming_address= my_strdup(WSREP_NODE_INCOMING_AUTO, MYF(MY_WME));
+ wsrep_provider = my_strdup(PSI_INSTRUMENT_ME, WSREP_NONE, MYF(MY_WME));
+ wsrep_provider_options= my_strdup(PSI_INSTRUMENT_ME, "", MYF(MY_WME));
+ wsrep_cluster_address = my_strdup(PSI_INSTRUMENT_ME, "", MYF(MY_WME));
+ wsrep_cluster_name = my_strdup(PSI_INSTRUMENT_ME, WSREP_CLUSTER_NAME, MYF(MY_WME));
+ wsrep_node_name = my_strdup(PSI_INSTRUMENT_ME, "", MYF(MY_WME));
+ wsrep_node_address = my_strdup(PSI_INSTRUMENT_ME, "", MYF(MY_WME));
+ wsrep_node_incoming_address= my_strdup(PSI_INSTRUMENT_ME, WSREP_NODE_INCOMING_AUTO, MYF(MY_WME));
if (wsrep_gtid_mode)
- wsrep_start_position = my_strdup(WSREP_START_POSITION_ZERO_GTID, MYF(MY_WME));
+ wsrep_start_position = my_strdup(PSI_INSTRUMENT_ME, WSREP_START_POSITION_ZERO_GTID, MYF(MY_WME));
else
- wsrep_start_position = my_strdup(WSREP_START_POSITION_ZERO, MYF(MY_WME));
+ wsrep_start_position = my_strdup(PSI_INSTRUMENT_ME, WSREP_START_POSITION_ZERO, MYF(MY_WME));
return 0;
}
@@ -50,7 +50,7 @@ static int get_provider_option_value(const char* opts,
{
int ret= 1;
ulong opt_value_tmp;
- char *opt_value_str, *s, *opts_copy= my_strdup(opts, MYF(MY_WME));
+ char *opt_value_str, *s, *opts_copy= my_strdup(PSI_INSTRUMENT_ME, opts, MYF(MY_WME));
if ((opt_value_str= strstr(opts_copy, opt_name)) == NULL)
goto end;
@@ -436,7 +436,7 @@ void wsrep_provider_init (const char* value)
}
if (wsrep_provider) my_free((void *)wsrep_provider);
- wsrep_provider= my_strdup(value, MYF(0));
+ wsrep_provider= my_strdup(PSI_INSTRUMENT_MEM, value, MYF(0));
}
bool wsrep_provider_options_check(sys_var *self, THD* thd, set_var* var)
@@ -466,7 +466,7 @@ void wsrep_provider_options_init(const char* value)
{
if (wsrep_provider_options && wsrep_provider_options != value)
my_free((void *)wsrep_provider_options);
- wsrep_provider_options= (value) ? my_strdup(value, MYF(0)) : NULL;
+ wsrep_provider_options= value ? my_strdup(PSI_INSTRUMENT_MEM, value, MYF(0)) : NULL;
}
bool wsrep_reject_queries_update(sys_var *self, THD* thd, enum_var_type type)
@@ -578,8 +578,8 @@ void wsrep_cluster_address_init (const char* value)
(wsrep_cluster_address) ? wsrep_cluster_address : "null",
(value) ? value : "null");
- my_free((void*) wsrep_cluster_address);
- wsrep_cluster_address= my_strdup(value ? value : "", MYF(0));
+ my_free(const_cast<char*>(wsrep_cluster_address));
+ wsrep_cluster_address= my_strdup(PSI_INSTRUMENT_MEM, safe_str(value), MYF(0));
}
/* wsrep_cluster_name cannot be NULL or an empty string. */
@@ -652,7 +652,7 @@ void wsrep_node_address_init (const char* value)
if (wsrep_node_address && strcmp(wsrep_node_address, value))
my_free ((void*)wsrep_node_address);
- wsrep_node_address= (value) ? my_strdup(value, MYF(0)) : NULL;
+ wsrep_node_address= value ? my_strdup(PSI_INSTRUMENT_MEM, value, MYF(0)) : NULL;
}
static void wsrep_slave_count_change_update ()
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index 0b352589fe3..259093d0f05 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -278,7 +278,7 @@ int archive_discover(handlerton *hton, THD* thd, TABLE_SHARE *share)
if (frm_stream.frm_length == 0)
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
- frm_ptr= (uchar *)my_malloc(sizeof(char) * frm_stream.frm_length,
+ frm_ptr= (uchar *)my_malloc(PSI_INSTRUMENT_ME, frm_stream.frm_length,
MYF(MY_THREAD_SPECIFIC | MY_WME));
if (!frm_ptr)
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -705,7 +705,7 @@ int ha_archive::frm_copy(azio_stream *src, azio_stream *dst)
return 0;
}
- if (!(frm_ptr= (uchar *) my_malloc(src->frm_length,
+ if (!(frm_ptr= (uchar *) my_malloc(PSI_INSTRUMENT_ME, src->frm_length,
MYF(MY_THREAD_SPECIFIC | MY_WME))))
return HA_ERR_OUT_OF_MEM;
@@ -1214,8 +1214,8 @@ bool ha_archive::fix_rec_buff(unsigned int length)
if (length > record_buffer->length)
{
uchar *newptr;
- if (!(newptr=(uchar*) my_realloc((uchar*) record_buffer->buffer,
- length,
+ if (!(newptr=(uchar*) my_realloc(PSI_INSTRUMENT_ME,
+ (uchar*) record_buffer->buffer, length,
MYF(MY_ALLOW_ZERO_PTR))))
DBUG_RETURN(1);
record_buffer->buffer= newptr;
@@ -1889,16 +1889,14 @@ archive_record_buffer *ha_archive::create_record_buffer(unsigned int length)
{
DBUG_ENTER("ha_archive::create_record_buffer");
archive_record_buffer *r;
- if (!(r=
- (archive_record_buffer*) my_malloc(sizeof(archive_record_buffer),
- MYF(MY_WME))))
+ if (!(r= (archive_record_buffer*) my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(archive_record_buffer), MYF(MY_WME))))
{
DBUG_RETURN(NULL); /* purecov: inspected */
}
r->length= (int)length;
- if (!(r->buffer= (uchar*) my_malloc(r->length,
- MYF(MY_WME))))
+ if (!(r->buffer= (uchar*) my_malloc(PSI_INSTRUMENT_ME, r->length, MYF(MY_WME))))
{
my_free(r);
DBUG_RETURN(NULL); /* purecov: inspected */
diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc
index c7803003398..700277f929e 100644
--- a/storage/blackhole/ha_blackhole.cc
+++ b/storage/blackhole/ha_blackhole.cc
@@ -323,9 +323,8 @@ static st_blackhole_share *get_share(const char *table_name)
my_hash_search(&blackhole_open_tables,
(uchar*) table_name, length)))
{
- if (!(share= (st_blackhole_share*) my_malloc(sizeof(st_blackhole_share) +
- length,
- MYF(MY_WME | MY_ZEROFILL))))
+ if (!(share= (st_blackhole_share*) my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(st_blackhole_share) + length, MYF(MY_WME | MY_ZEROFILL))))
goto error;
share->table_name_length= length;
@@ -406,7 +405,8 @@ static int blackhole_init(void *p)
&blackhole_mutex, MY_MUTEX_INIT_FAST);
(void) my_hash_init(&blackhole_open_tables, system_charset_info,32,0,0,
(my_hash_get_key) blackhole_get_key,
- (my_hash_free_key) blackhole_free_key, 0);
+ (my_hash_free_key) blackhole_free_key, 0,
+ PSI_INSTRUMENT_ME);
return 0;
}
diff --git a/storage/cassandra/ha_cassandra.cc b/storage/cassandra/ha_cassandra.cc
index 410150b088f..ac45bcaa862 100644
--- a/storage/cassandra/ha_cassandra.cc
+++ b/storage/cassandra/ha_cassandra.cc
@@ -243,7 +243,7 @@ static int cassandra_init_func(void *p)
cassandra_hton= (handlerton *)p;
mysql_mutex_init(ex_key_mutex_example, &cassandra_mutex, MY_MUTEX_INIT_FAST);
(void) my_hash_init(&cassandra_open_tables,system_charset_info,32,0,0,
- (my_hash_get_key) cassandra_get_key,0,0);
+ (my_hash_get_key) cassandra_get_key,0,0, PSI_INSTRUMENT_ME);
cassandra_hton->create= cassandra_create_handler;
/*
@@ -297,7 +297,7 @@ static CASSANDRA_SHARE *get_share(const char *table_name, TABLE *table)
length)))
{
if (!(share=(CASSANDRA_SHARE *)
- my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), PSI_INSTRUMENT_ME,
&share, sizeof(*share),
&tmp_name, length+1,
NullS)))
@@ -865,7 +865,7 @@ static void alloc_strings_memroot(MEM_ROOT *mem_root)
The mem_root used to allocate UUID (of length 36 + \0) so make
appropriate allocated size
*/
- init_alloc_root(mem_root, "cassandra",
+ init_alloc_root(PSI_INSTRUMENT_ME, mem_root,
(36 + 1 + ALIGN_SIZE(sizeof(USED_MEM))) * 10 +
ALLOC_ROOT_MIN_BLOCK_SIZE,
(36 + 1 + ALIGN_SIZE(sizeof(USED_MEM))) * 10 +
@@ -1446,7 +1446,7 @@ bool ha_cassandra::setup_field_converters(Field **field_arg, uint n_fields)
size_t memsize= sizeof(ColumnDataConverter*) * n_fields +
(sizeof(LEX_STRING) + sizeof(CASSANDRA_TYPE_DEF))*
(dyncol_set ? max_non_default_fields : 0);
- if (!(field_converters= (ColumnDataConverter**)my_malloc(memsize, MYF(0))))
+ if (!(field_converters= (ColumnDataConverter**)my_malloc(PSI_INSTRUMENT_ME, memsize, MYF(0))))
DBUG_RETURN(true);
bzero(field_converters, memsize);
n_field_converters= n_fields;
@@ -1458,12 +1458,12 @@ bool ha_cassandra::setup_field_converters(Field **field_arg, uint n_fields)
special_type_field_names=
((LEX_STRING*)(special_type_field_converters + max_non_default_fields));
- if (my_init_dynamic_array(&dynamic_values,
+ if (my_init_dynamic_array(&dynamic_values, PSI_INSTRUMENT_ME,
sizeof(DYNAMIC_COLUMN_VALUE),
DYNCOL_USUAL, DYNCOL_DELTA, MYF(0)))
DBUG_RETURN(true);
else
- if (my_init_dynamic_array(&dynamic_names,
+ if (my_init_dynamic_array(&dynamic_names, PSI_INSTRUMENT_ME,
sizeof(LEX_STRING),
DYNCOL_USUAL, DYNCOL_DELTA,MYF(0)))
{
diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp
index e07270aff8a..abb865cc61f 100644
--- a/storage/connect/myconn.cpp
+++ b/storage/connect/myconn.cpp
@@ -88,8 +88,8 @@ static MYSQL_RES *connect_use_result(MYSQL *mysql)
DBUG_RETURN(NULL);
} // endif status
- if (!(result = (MYSQL_RES*) my_malloc(sizeof(*result) +
- sizeof(ulong) * mysql->field_count,
+ if (!(result = (MYSQL_RES*) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(*result) + sizeof(ulong) * mysql->field_count,
MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(NULL);
@@ -97,8 +97,8 @@ static MYSQL_RES *connect_use_result(MYSQL *mysql)
result->methods = mysql->methods;
/* Ptrs: to one row */
- if (!(result->row = (MYSQL_ROW)my_malloc(sizeof(result->row[0]) *
- (mysql->field_count+1), MYF(MY_WME)))) {
+ if (!(result->row = (MYSQL_ROW)my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(result->row[0]) * (mysql->field_count+1), MYF(MY_WME)))) {
my_free(result);
DBUG_RETURN(NULL);
} // endif row
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index ac5a0eeb850..7fbf3afd830 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -112,6 +112,11 @@ static uchar* tina_get_key(TINA_SHARE *share, size_t *length,
return (uchar*) share->table_name;
}
+static PSI_memory_key csv_key_memory_tina_share;
+static PSI_memory_key csv_key_memory_blobroot;
+static PSI_memory_key csv_key_memory_tina_set;
+static PSI_memory_key csv_key_memory_row;
+
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key csv_key_mutex_tina, csv_key_mutex_TINA_SHARE_mutex;
@@ -132,6 +137,15 @@ static PSI_file_info all_tina_files[]=
{ &csv_key_file_update, "update", 0}
};
+static PSI_memory_info all_tina_memory[]=
+{
+ { &csv_key_memory_tina_share, "TINA_SHARE", PSI_FLAG_GLOBAL},
+ { &csv_key_memory_blobroot, "blobroot", 0},
+ { &csv_key_memory_tina_set, "tina_set", 0},
+ { &csv_key_memory_row, "row", 0},
+ { &csv_key_memory_Transparent_file, "Transparent_file", 0}
+};
+
static void init_tina_psi_keys(void)
{
const char* category= "csv";
@@ -142,6 +156,9 @@ static void init_tina_psi_keys(void)
count= array_elements(all_tina_files);
mysql_file_register(category, all_tina_files, count);
+
+ count= array_elements(all_tina_memory);
+ mysql_memory_register(category, all_tina_memory, count);
}
#endif /* HAVE_PSI_INTERFACE */
@@ -166,8 +183,9 @@ static int tina_init_func(void *p)
tina_hton= (handlerton *)p;
mysql_mutex_init(csv_key_mutex_tina, &tina_mutex, MY_MUTEX_INIT_FAST);
- (void) my_hash_init(&tina_open_tables,system_charset_info,32,0,0,
- (my_hash_get_key) tina_get_key,0,0);
+ (void) my_hash_init(&tina_open_tables, system_charset_info, 32, 0, 0,
+ (my_hash_get_key) tina_get_key, 0, 0,
+ csv_key_memory_tina_share);
tina_hton->db_type= DB_TYPE_CSV_DB;
tina_hton->create= tina_create_handler;
tina_hton->flags= (HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES |
@@ -204,14 +222,11 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
If share is not present in the hash, create a new share and
initialize its members.
*/
- if (!(share=(TINA_SHARE*) my_hash_search(&tina_open_tables,
- (uchar*) table_name,
- length)))
+ if (!(share=(TINA_SHARE*) my_hash_search(&tina_open_tables, (uchar*)
+ table_name, length)))
{
- if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
- &share, sizeof(*share),
- &tmp_name, length+1,
- NullS))
+ if (!my_multi_malloc(csv_key_memory_tina_share, MYF(MY_WME | MY_ZEROFILL),
+ &share, sizeof(*share), &tmp_name, length+1, NullS))
{
mysql_mutex_unlock(&tina_mutex);
return NULL;
@@ -513,7 +528,8 @@ ha_tina::ha_tina(handlerton *hton, TABLE_SHARE *table_arg)
buffer.set((char*)byte_buffer, IO_SIZE, &my_charset_bin);
chain= chain_buffer;
file_buff= new Transparent_file();
- init_alloc_root(&blobroot, "ha_tina", BLOB_MEMROOT_ALLOC_SIZE, 0, MYF(0));
+ init_alloc_root(csv_key_memory_blobroot, &blobroot, BLOB_MEMROOT_ALLOC_SIZE,
+ 0, MYF(0));
}
@@ -627,14 +643,15 @@ int ha_tina::chain_append()
chain_size += DEFAULT_CHAIN_LENGTH;
if (chain_alloced)
{
- /* Must cast since my_malloc unlike malloc doesn't have a void ptr */
- if ((chain= (tina_set *) my_realloc((uchar*)chain,
- chain_size, MYF(MY_WME))) == NULL)
+ if ((chain= (tina_set *) my_realloc(csv_key_memory_tina_set,
+ (uchar*)chain, chain_size,
+ MYF(MY_WME))) == NULL)
return -1;
}
else
{
- tina_set *ptr= (tina_set *) my_malloc(chain_size * sizeof(tina_set),
+ tina_set *ptr= (tina_set *) my_malloc(csv_key_memory_tina_set,
+ chain_size * sizeof(tina_set),
MYF(MY_WME));
memcpy(ptr, chain, DEFAULT_CHAIN_LENGTH * sizeof(tina_set));
chain= ptr;
@@ -975,7 +992,8 @@ int ha_tina::open(const char *name, int mode, uint open_options)
*/
thr_lock_data_init(&share->lock, &lock, (void*) this);
ref_length= sizeof(my_off_t);
- init_alloc_root(&blobroot, "ha_tina", BLOB_MEMROOT_ALLOC_SIZE, 0, MYF(0));
+ init_alloc_root(csv_key_memory_blobroot, &blobroot, BLOB_MEMROOT_ALLOC_SIZE,
+ 0, MYF(0));
share->lock.get_status= tina_get_status;
share->lock.update_status= tina_update_status;
@@ -1528,7 +1546,8 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
if (init_data_file())
DBUG_RETURN(HA_ERR_CRASHED_ON_REPAIR);
- if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME))))
+ if (!(buf= (uchar*) my_malloc(csv_key_memory_row, table->s->reclength,
+ MYF(MY_WME))))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
/*
Local_saved_data_file_length is initialized during the lock phase.
@@ -1742,7 +1761,8 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt)
if (init_data_file())
DBUG_RETURN(HA_ERR_CRASHED);
- if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME))))
+ if (!(buf= (uchar*) my_malloc(csv_key_memory_row, table->s->reclength,
+ MYF(MY_WME))))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
/*
diff --git a/storage/csv/transparent_file.cc b/storage/csv/transparent_file.cc
index 47d63f2caaf..443e61d08d8 100644
--- a/storage/csv/transparent_file.cc
+++ b/storage/csv/transparent_file.cc
@@ -23,9 +23,12 @@
#include "transparent_file.h"
#include "my_sys.h" // MY_WME, MY_ALLOW_ZERO_PTR, MY_SEEK_SET
+PSI_memory_key csv_key_memory_Transparent_file;
+
Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE)
{
- buff= (uchar *) my_malloc(buff_size*sizeof(uchar), MYF(MY_WME));
+ buff= (uchar *) my_malloc(csv_key_memory_Transparent_file,
+ buff_size*sizeof(uchar), MYF(MY_WME));
}
Transparent_file::~Transparent_file()
diff --git a/storage/csv/transparent_file.h b/storage/csv/transparent_file.h
index 024fc0e3a38..545643d0f17 100644
--- a/storage/csv/transparent_file.h
+++ b/storage/csv/transparent_file.h
@@ -18,6 +18,7 @@
#include <sys/stat.h>
#include <my_dir.h>
+extern PSI_memory_key csv_key_memory_Transparent_file;
class Transparent_file
{
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index 2021e03bc62..8dc6c9e0698 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -497,7 +497,7 @@ int federated_db_init(void *p)
&federated_mutex, MY_MUTEX_INIT_FAST))
goto error;
if (!my_hash_init(&federated_open_tables, &my_charset_bin, 32, 0, 0,
- (my_hash_get_key) federated_get_key, 0, 0))
+ (my_hash_get_key) federated_get_key, 0, 0, PSI_INSTRUMENT_ME))
{
DBUG_RETURN(FALSE);
}
@@ -1516,7 +1516,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
*/
query.length(0);
- init_alloc_root(&mem_root, "federated_share", 256, 0, MYF(0));
+ init_alloc_root(PSI_INSTRUMENT_ME, &mem_root, 256, 0, MYF(0));
mysql_mutex_lock(&federated_mutex);
@@ -1642,7 +1642,7 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked)
ref_length= sizeof(MYSQL_RES *) + sizeof(MYSQL_ROW_OFFSET);
DBUG_PRINT("info", ("ref_length: %u", ref_length));
- my_init_dynamic_array(&results, sizeof(MYSQL_RES *), 4, 4, MYF(0));
+ my_init_dynamic_array(&results, PSI_INSTRUMENT_ME, sizeof(MYSQL_RES *), 4, 4, MYF(0));
reset();
DBUG_RETURN(0);
diff --git a/storage/federatedx/federatedx_io_mysql.cc b/storage/federatedx/federatedx_io_mysql.cc
index cc4d8ca7c70..4d4e8b11165 100644
--- a/storage/federatedx/federatedx_io_mysql.cc
+++ b/storage/federatedx/federatedx_io_mysql.cc
@@ -140,7 +140,7 @@ federatedx_io_mysql::federatedx_io_mysql(FEDERATEDX_SERVER *aserver)
bzero(&mysql, sizeof(MYSQL));
bzero(&savepoints, sizeof(DYNAMIC_ARRAY));
- my_init_dynamic_array(&savepoints, sizeof(SAVEPT), 16, 16, MYF(0));
+ my_init_dynamic_array(&savepoints, PSI_INSTRUMENT_ME, sizeof(SAVEPT), 16, 16, MYF(0));
DBUG_VOID_RETURN;
}
diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc
index eca580310ee..b042fa720dc 100644
--- a/storage/federatedx/ha_federatedx.cc
+++ b/storage/federatedx/ha_federatedx.cc
@@ -446,9 +446,9 @@ int federatedx_db_init(void *p)
&federatedx_mutex, MY_MUTEX_INIT_FAST))
goto error;
if (!my_hash_init(&federatedx_open_tables, &my_charset_bin, 32, 0, 0,
- (my_hash_get_key) federatedx_share_get_key, 0, 0) &&
+ (my_hash_get_key) federatedx_share_get_key, 0, 0, PSI_INSTRUMENT_ME) &&
!my_hash_init(&federatedx_open_servers, &my_charset_bin, 32, 0, 0,
- (my_hash_get_key) federatedx_server_get_key, 0, 0))
+ (my_hash_get_key) federatedx_server_get_key, 0, 0, PSI_INSTRUMENT_ME))
{
DBUG_RETURN(FALSE);
}
@@ -1540,7 +1540,7 @@ static FEDERATEDX_SERVER *get_server(FEDERATEDX_SHARE *share, TABLE *table)
mysql_mutex_assert_owner(&federatedx_mutex);
- init_alloc_root(&mem_root, "federated", 4096, 4096, MYF(0));
+ init_alloc_root(PSI_INSTRUMENT_ME, &mem_root, 4096, 4096, MYF(0));
fill_server(&mem_root, &tmp_server, share, table ? table->s->table_charset : 0);
@@ -1598,7 +1598,7 @@ static FEDERATEDX_SHARE *get_share(const char *table_name, TABLE *table)
query.length(0);
bzero(&tmp_share, sizeof(tmp_share));
- init_alloc_root(&mem_root, "federated", 256, 0, MYF(0));
+ init_alloc_root(PSI_INSTRUMENT_ME, &mem_root, 256, 0, MYF(0));
mysql_mutex_lock(&federatedx_mutex);
@@ -1802,7 +1802,7 @@ int ha_federatedx::open(const char *name, int mode, uint test_if_locked)
DBUG_PRINT("info", ("ref_length: %u", ref_length));
- my_init_dynamic_array(&results, sizeof(FEDERATEDX_IO_RESULT*), 4, 4, MYF(0));
+ my_init_dynamic_array(&results, PSI_INSTRUMENT_ME, sizeof(FEDERATEDX_IO_RESULT*), 4, 4, MYF(0));
reset();
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index e0e25442d71..ccfd6c69956 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -619,7 +619,8 @@ heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table,
for (key= parts= 0; key < keys; key++)
parts+= table_arg->key_info[key].user_defined_key_parts;
- if (!(keydef= (HP_KEYDEF*) my_malloc(keys * sizeof(HP_KEYDEF) +
+ if (!(keydef= (HP_KEYDEF*) my_malloc(hp_key_memory_HP_KEYDEF,
+ keys * sizeof(HP_KEYDEF) +
parts * sizeof(HA_KEYSEG),
MYF(MY_WME | MY_THREAD_SPECIFIC))))
return my_errno;
diff --git a/storage/heap/heapdef.h b/storage/heap/heapdef.h
index b3ceb617bd4..6136a90f0aa 100644
--- a/storage/heap/heapdef.h
+++ b/storage/heap/heapdef.h
@@ -103,8 +103,12 @@ extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
extern mysql_mutex_t THR_LOCK_heap;
+extern PSI_memory_key hp_key_memory_HP_SHARE;
+extern PSI_memory_key hp_key_memory_HP_INFO;
+extern PSI_memory_key hp_key_memory_HP_PTRS;
+extern PSI_memory_key hp_key_memory_HP_KEYDEF;
+
#ifdef HAVE_PSI_INTERFACE
-extern PSI_mutex_key hp_key_mutex_HP_SHARE_intern_lock;
void init_heap_psi_keys();
#endif /* HAVE_PSI_INTERFACE */
diff --git a/storage/heap/hp_block.c b/storage/heap/hp_block.c
index 395637db351..324efc8b4af 100644
--- a/storage/heap/hp_block.c
+++ b/storage/heap/hp_block.c
@@ -78,7 +78,7 @@ int hp_get_new_block(HP_SHARE *info, HP_BLOCK *block, size_t *alloc_length)
*/
*alloc_length= (sizeof(HP_PTRS) * ((i == block->levels) ? i : i - 1) +
(ulonglong)block->records_in_block * block->recbuffer);
- if (!(root=(HP_PTRS*) my_malloc(*alloc_length,
+ if (!(root=(HP_PTRS*) my_malloc(hp_key_memory_HP_PTRS, *alloc_length,
MYF(MY_WME |
(info->internal ?
MY_THREAD_SPECIFIC : 0)))))
diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c
index 8bd653f1b84..935c6f8d0fd 100644
--- a/storage/heap/hp_create.c
+++ b/storage/heap/hp_create.c
@@ -159,7 +159,8 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
keyinfo->get_key_length= hp_rb_key_length;
}
}
- if (!(share= (HP_SHARE*) my_malloc((uint) sizeof(HP_SHARE)+
+ if (!(share= (HP_SHARE*) my_malloc(hp_key_memory_HP_SHARE,
+ sizeof(HP_SHARE)+
keys*sizeof(HP_KEYDEF)+
key_segs*sizeof(HA_KEYSEG),
MYF(MY_ZEROFILL |
@@ -222,7 +223,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
share->create_time= (long) time((time_t*) 0);
share->internal= create_info->internal_table;
/* Must be allocated separately for rename to work */
- if (!(share->name= my_strdup(name,MYF(0))))
+ if (!(share->name= my_strdup(hp_key_memory_HP_SHARE, name, MYF(0))))
{
my_free(share);
goto err;
@@ -231,8 +232,6 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
if (!create_info->internal_table)
{
thr_lock_init(&share->lock);
- mysql_mutex_init(hp_key_mutex_HP_SHARE_intern_lock,
- &share->intern_lock, MY_MUTEX_INIT_FAST);
share->open_list.data= (void*) share;
heap_share_list= list_add(heap_share_list,&share->open_list);
}
@@ -361,7 +360,6 @@ void hp_free(HP_SHARE *share)
{
heap_share_list= list_delete(heap_share_list, &share->open_list);
thr_lock_delete(&share->lock);
- mysql_mutex_destroy(&share->intern_lock);
}
hp_clear(share); /* Remove blocks from memory */
my_free(share->name);
diff --git a/storage/heap/hp_open.c b/storage/heap/hp_open.c
index 65186d77e4f..272c4a3af23 100644
--- a/storage/heap/hp_open.c
+++ b/storage/heap/hp_open.c
@@ -30,8 +30,8 @@ HP_INFO *heap_open_from_share(HP_SHARE *share, int mode)
HP_INFO *info;
DBUG_ENTER("heap_open_from_share");
- if (!(info= (HP_INFO*) my_malloc(sizeof(HP_INFO) +
- 2 * share->max_key_length,
+ if (!(info= (HP_INFO*) my_malloc(hp_key_memory_HP_INFO,
+ sizeof(HP_INFO) + 2 * share->max_key_length,
MYF(MY_ZEROFILL +
(share->internal ?
MY_THREAD_SPECIFIC : 0)))))
diff --git a/storage/heap/hp_rename.c b/storage/heap/hp_rename.c
index 34e82bbc531..7343644b5d9 100644
--- a/storage/heap/hp_rename.c
+++ b/storage/heap/hp_rename.c
@@ -28,7 +28,8 @@ int heap_rename(const char *old_name, const char *new_name)
mysql_mutex_lock(&THR_LOCK_heap);
if ((info = hp_find_named_heap(old_name)))
{
- if (!(name_buff=(char*) my_strdup(new_name,MYF(MY_WME))))
+ if (!(name_buff=(char*) my_strdup(hp_key_memory_HP_SHARE,
+ new_name, MYF(MY_WME))))
{
mysql_mutex_unlock(&THR_LOCK_heap);
DBUG_RETURN(my_errno);
diff --git a/storage/heap/hp_static.c b/storage/heap/hp_static.c
index 9191e23b399..9a4410eead9 100644
--- a/storage/heap/hp_static.c
+++ b/storage/heap/hp_static.c
@@ -24,16 +24,19 @@
LIST *heap_open_list=0,*heap_share_list=0;
+PSI_memory_key hp_key_memory_HP_SHARE;
+PSI_memory_key hp_key_memory_HP_INFO;
+PSI_memory_key hp_key_memory_HP_PTRS;
+PSI_memory_key hp_key_memory_HP_KEYDEF;
+
#ifdef HAVE_PSI_INTERFACE
-PSI_mutex_key hp_key_mutex_HP_SHARE_intern_lock;
-static PSI_mutex_info all_heap_mutexes[]=
+static PSI_memory_info all_heap_memory[]=
{
- { & hp_key_mutex_HP_SHARE_intern_lock, "HP_SHARE::intern_lock", 0}
- /*
- Note:
- THR_LOCK_heap is part of mysys, not storage/heap.
- */
+ { & hp_key_memory_HP_SHARE, "HP_SHARE", 0},
+ { & hp_key_memory_HP_INFO, "HP_INFO", 0},
+ { & hp_key_memory_HP_PTRS, "HP_PTRS", 0},
+ { & hp_key_memory_HP_KEYDEF, "HP_KEYDEF", 0}
};
void init_heap_psi_keys()
@@ -44,8 +47,8 @@ void init_heap_psi_keys()
if (PSI_server == NULL)
return;
- count= array_elements(all_heap_mutexes);
- PSI_server->register_mutex(category, all_heap_mutexes, count);
+ count= array_elements(all_heap_memory);
+ mysql_memory_register(category, all_heap_memory, count);
}
#endif /* HAVE_PSI_INTERFACE */
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index be7de608d2b..c2094b23d3a 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -4554,7 +4554,7 @@ innobase_checkpoint_request(
/* Do the allocation outside of lock to reduce contention. The normal
case is that not everything is flushed, so we will need to enqueue. */
entry = static_cast<struct pending_checkpoint *>
- (my_malloc(sizeof(*entry), MYF(MY_WME)));
+ (my_malloc(PSI_INSTRUMENT_ME, sizeof(*entry), MYF(MY_WME)));
if (!entry) {
sql_print_error("Failed to allocate %u bytes."
" Commit checkpoint will be skipped.",
@@ -8540,7 +8540,7 @@ ha_innobase::update_row(
+ MAX_REF_PARTS * 3;
m_upd_buf = reinterpret_cast<uchar*>(
- my_malloc(//PSI_INSTRUMENT_ME,
+ my_malloc(PSI_INSTRUMENT_ME,
m_upd_buf_size,
MYF(MY_WME)));
@@ -9681,7 +9681,7 @@ ha_innobase::ft_init_ext(
/* Allocate FTS handler, and instantiate it before return */
fts_hdl = reinterpret_cast<NEW_FT_INFO*>(
- my_malloc(/*PSI_INSTRUMENT_ME,*/ sizeof(NEW_FT_INFO), MYF(0)));
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(NEW_FT_INFO), MYF(0)));
fts_hdl->please = const_cast<_ft_vft*>(&ft_vft_result);
fts_hdl->could_you = const_cast<_ft_vft_ext*>(&ft_vft_ext_result);
@@ -10964,7 +10964,7 @@ create_index(
ind_type |= DICT_UNIQUE;
}
- field_lengths = (ulint*) my_malloc(//PSI_INSTRUMENT_ME,
+ field_lengths = (ulint*) my_malloc(PSI_INSTRUMENT_ME,
key->user_defined_key_parts * sizeof *
field_lengths, MYF(MY_FAE));
@@ -13645,7 +13645,7 @@ innobase_drop_database(
}
ptr++;
- namebuf = (char*) my_malloc(/*PSI_INSTRUMENT_ME,*/ (uint) len + 2, MYF(0));
+ namebuf = (char*) my_malloc(PSI_INSTRUMENT_ME, (uint) len + 2, MYF(0));
memcpy(namebuf, ptr, len);
namebuf[len] = '/';
@@ -15249,7 +15249,7 @@ ha_innobase::update_table_comment(
flen = 64000 - 3 - length;
}
/* allocate buffer for the full string */
- str = (char*) my_malloc(length + flen + 3, MYF(0));
+ str = (char*) my_malloc(PSI_INSTRUMENT_ME, length + flen + 3, MYF(0));
if (str) {
char* pos = str + length;
if (length) {
@@ -15294,14 +15294,8 @@ ha_innobase::get_foreign_key_create_info(void)
m_prebuilt->trx->op_info = "";
/* Allocate buffer for the string */
- char* fk_str = (char*) my_malloc(str.length() + 1, MYF(0));
-
- /* JAN: TODO: MySQL 5.7
- fk_str = reinterpret_cast<char*>(
+ char *fk_str = reinterpret_cast<char*>(
my_malloc(PSI_INSTRUMENT_ME, str.length() + 1, MYF(0)));
- */
-
-
if (fk_str) {
memcpy(fk_str, str.c_str(), str.length());
@@ -16174,7 +16168,7 @@ innodb_show_status(
/* allocate buffer for the string, and
read the contents of the temporary file */
- if (!(str = (char*) my_malloc(//PSI_INSTRUMENT_ME,
+ if (!(str = (char*) my_malloc(PSI_INSTRUMENT_ME,
usable_len + 1, MYF(0)))) {
mutex_exit(&srv_monitor_file_mutex);
DBUG_RETURN(1);
@@ -18105,7 +18099,7 @@ innodb_monitor_validate(
by InnoDB, so we can access it in another callback
function innodb_monitor_update() and free it appropriately */
if (name) {
- monitor_name = my_strdup(//PSI_INSTRUMENT_ME,
+ monitor_name = my_strdup(PSI_INSTRUMENT_ME,
name, MYF(0));
} else {
return(1);
@@ -21635,7 +21629,7 @@ ib_push_warning(
char *buf;
va_start(args, format);
- buf = (char *)my_malloc(MAX_BUF_SIZE, MYF(MY_WME));
+ buf = (char *)my_malloc(PSI_INSTRUMENT_ME, MAX_BUF_SIZE, MYF(MY_WME));
vsprintf(buf,format, args);
push_warning_printf(
@@ -21666,7 +21660,7 @@ ib_push_warning(
if (thd) {
va_start(args, format);
- buf = (char *)my_malloc(MAX_BUF_SIZE, MYF(MY_WME));
+ buf = (char *)my_malloc(PSI_INSTRUMENT_ME, MAX_BUF_SIZE, MYF(MY_WME));
vsprintf(buf,format, args);
push_warning_printf(
@@ -21695,7 +21689,7 @@ ib_foreign_warn(trx_t* trx, /*!< in: trx */
char* buf;
static FILE* ef = dict_foreign_err_file;
static const size_t MAX_BUF_SIZE = 4 * 1024;
- buf = (char*)my_malloc(MAX_BUF_SIZE, MYF(MY_WME));
+ buf = (char*)my_malloc(PSI_INSTRUMENT_ME, MAX_BUF_SIZE, MYF(MY_WME));
if (!buf) {
return;
}
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index fc152099610..f026ab5dfa5 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -4620,12 +4620,8 @@ static int i_s_innodb_fill_buffer_lru(THD *thd, TABLE_LIST *tables, Item *)
lru_len = UT_LIST_GET_LEN(buf_pool->LRU);
/* Print error message if malloc fail */
- info_buffer = (buf_page_info_t*) my_malloc(
- lru_len * sizeof *info_buffer, MYF(MY_WME));
- /* JAN: TODO: MySQL 5.7 PSI
info_buffer = (buf_page_info_t*) my_malloc(PSI_INSTRUMENT_ME,
lru_len * sizeof *info_buffer, MYF(MY_WME));
- */
if (!info_buffer) {
status = 1;
diff --git a/storage/innobase/include/sync0rw.ic b/storage/innobase/include/sync0rw.ic
index a1bbf719b7d..4791c801424 100644
--- a/storage/innobase/include/sync0rw.ic
+++ b/storage/innobase/include/sync0rw.ic
@@ -541,8 +541,6 @@ pfs_rw_lock_x_lock_func(
/* Record the acquisition of a read-write lock in exclusive
mode in performance schema */
-/* MySQL 5.7 New PSI */
-#define PSI_RWLOCK_EXCLUSIVELOCK PSI_RWLOCK_WRITELOCK
locker = PSI_RWLOCK_CALL(start_rwlock_wrwait)(
&state, lock->pfs_psi, PSI_RWLOCK_EXCLUSIVELOCK,
@@ -582,7 +580,6 @@ pfs_rw_lock_x_lock_func_nowait(
/* Record the acquisition of a read-write trylock in exclusive
mode in performance schema */
-#define PSI_RWLOCK_TRYEXCLUSIVELOCK PSI_RWLOCK_TRYWRITELOCK
locker = PSI_RWLOCK_CALL(start_rwlock_wrwait)(
&state, lock->pfs_psi, PSI_RWLOCK_TRYEXCLUSIVELOCK,
file_name, static_cast<uint>(line));
@@ -636,7 +633,6 @@ pfs_rw_lock_s_lock_func(
PSI_rwlock_locker* locker;
PSI_rwlock_locker_state state;
-#define PSI_RWLOCK_SHAREDLOCK PSI_RWLOCK_READLOCK
/* Instrumented to inform we are aquiring a shared rwlock */
locker = PSI_RWLOCK_CALL(start_rwlock_rdwait)(
&state, lock->pfs_psi, PSI_RWLOCK_SHAREDLOCK,
@@ -671,7 +667,6 @@ pfs_rw_lock_sx_lock_func(
PSI_rwlock_locker* locker;
PSI_rwlock_locker_state state;
-#define PSI_RWLOCK_SHAREDEXCLUSIVELOCK PSI_RWLOCK_WRITELOCK
/* Instrumented to inform we are aquiring a shared rwlock */
locker = PSI_RWLOCK_CALL(start_rwlock_wrwait)(
&state, lock->pfs_psi, PSI_RWLOCK_SHAREDEXCLUSIVELOCK,
@@ -708,7 +703,6 @@ pfs_rw_lock_s_lock_low(
PSI_rwlock_locker* locker;
PSI_rwlock_locker_state state;
-#define PSI_RWLOCK_TRYSHAREDLOCK PSI_RWLOCK_TRYREADLOCK
/* Instrumented to inform we are aquiring a shared rwlock */
locker = PSI_RWLOCK_CALL(start_rwlock_rdwait)(
&state, lock->pfs_psi, PSI_RWLOCK_TRYSHAREDLOCK,
@@ -748,7 +742,6 @@ pfs_rw_lock_sx_lock_low(
PSI_rwlock_locker* locker;
PSI_rwlock_locker_state state;
-#define PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK PSI_RWLOCK_TRYWRITELOCK
/* Instrumented to inform we are aquiring a shared
exclusive rwlock */
locker = PSI_RWLOCK_CALL(start_rwlock_rdwait)(
diff --git a/storage/innobase/include/ut0new.h b/storage/innobase/include/ut0new.h
index a190b872549..0a2bfdd2530 100644
--- a/storage/innobase/include/ut0new.h
+++ b/storage/innobase/include/ut0new.h
@@ -232,38 +232,19 @@ struct ut_new_pfx_t {
#endif
};
-static inline void ut_allocate_trace_dontdump(void *ptr, size_t bytes,
- bool
-#if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DONTDUMP)
- dontdump
-#endif
- , ut_new_pfx_t* pfx,
- const char*
-#ifdef UNIV_PFS_MEMORY
- file
-#endif
-
- )
+#if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DODUMP)
+static inline void ut_dontdump(void *ptr, size_t m_size, bool dontdump)
{
ut_a(ptr != NULL);
-#if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DONTDUMP)
- if (dontdump && madvise(ptr, bytes, MADV_DONTDUMP)) {
+ if (dontdump && madvise(ptr, m_size, MADV_DONTDUMP)) {
ib::warn() << "Failed to set memory to " DONTDUMP_STR ": "
<< strerror(errno)
<< " ptr " << ptr
- << " size " << bytes;
- }
-#endif
- if (pfx != NULL) {
-#ifdef UNIV_PFS_MEMORY
- allocate_trace(bytes, file, pfx);
-#endif /* UNIV_PFS_MEMORY */
- pfx->m_size = bytes;
+ << " size " << m_size;
}
}
-#if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DODUMP)
static inline void ut_dodump(void* ptr, size_t m_size)
{
if (ptr && madvise(ptr, m_size, MADV_DODUMP)) {
@@ -274,6 +255,7 @@ static inline void ut_dodump(void* ptr, size_t m_size)
}
}
#else
+static inline void ut_dontdump(void *, size_t, bool) {}
static inline void ut_dodump(void*, size_t) {}
#endif
@@ -310,10 +292,14 @@ public:
other
#endif
)
+ {
#ifdef UNIV_PFS_MEMORY
- : m_key(other.m_key)
+ const PSI_memory_key other_key = other.get_mem_key(NULL);
+
+ m_key = (other_key != mem_key_std)
+ ? other_key
+ : PSI_NOT_INSTRUMENTED;
#endif /* UNIV_PFS_MEMORY */
- {
}
/** Return the maximum number of objects that can be allocated by
@@ -422,7 +408,7 @@ public:
/** Free a memory allocated by allocate() and trace the deallocation.
@param[in,out] ptr pointer to memory to free */
- void deallocate(pointer ptr, size_type)
+ void deallocate(pointer ptr, size_type n_elements = 0)
{
#ifdef UNIV_PFS_MEMORY
if (ptr == NULL) {
@@ -645,7 +631,14 @@ public:
return NULL;
}
- ut_allocate_trace_dontdump(ptr, n_bytes, dontdump, pfx, NULL);
+ ut_dontdump(ptr, n_bytes, dontdump);
+
+ if (pfx != NULL) {
+#ifdef UNIV_PFS_MEMORY
+ allocate_trace(n_bytes, NULL, pfx);
+#endif /* UNIV_PFS_MEMORY */
+ pfx->m_size = n_bytes;
+ }
return(ptr);
}
@@ -924,9 +917,9 @@ ut_delete_array(
ut_allocator<byte>(key).allocate( \
n_bytes, NULL, __FILE__, false, false))
-#define ut_malloc_dontdump(n_bytes) static_cast<void*>( \
- ut_allocator<byte>(PSI_NOT_INSTRUMENTED).allocate_large( \
- n_bytes, true))
+#define ut_malloc_dontdump(n_bytes, key) static_cast<void*>( \
+ ut_allocator<byte>(key).allocate_large( \
+ n_bytes, NULL, true))
#define ut_zalloc(n_bytes, key) static_cast<void*>( \
ut_allocator<byte>(key).allocate( \
@@ -951,9 +944,8 @@ ut_delete_array(
#define ut_free(ptr) ut_allocator<byte>(PSI_NOT_INSTRUMENTED).deallocate( \
reinterpret_cast<byte*>(ptr))
-#define ut_free_dodump(ptr, size) static_cast<void*>( \
- ut_allocator<byte>(PSI_NOT_INSTRUMENTED).deallocate_large( \
- ptr, NULL, size, true))
+#define ut_free_dodump(ptr, size) ut_allocator<byte>(PSI_NOT_INSTRUMENTED).deallocate_large_dodump( \
+ reinterpret_cast<byte*>(ptr), NULL, size)
#else /* UNIV_PFS_MEMORY */
@@ -977,11 +969,11 @@ ut_delete_array(
#define ut_malloc_nokey(n_bytes) ::malloc(n_bytes)
-static inline void *ut_malloc_dontdump(size_t n_bytes)
+static inline void *ut_malloc_dontdump(size_t n_bytes, ...)
{
void *ptr = os_mem_alloc_large(&n_bytes);
- ut_allocate_trace_dontdump(ptr, n_bytes, true, NULL, NULL);
+ ut_dontdump(ptr, n_bytes, true);
return ptr;
}
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index de6e51bd2ea..7e291c8d8df 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -127,7 +127,7 @@ void log_buffer_extend(ulong len)
{
const size_t new_buf_size = ut_calc_align(len, srv_page_size);
byte* new_buf = static_cast<byte*>(
- ut_malloc_dontdump(new_buf_size * 2));
+ ut_malloc_dontdump(new_buf_size * 2, PSI_INSTRUMENT_ME));
TRASH_ALLOC(new_buf, new_buf_size * 2);
log_mutex_enter();
@@ -508,7 +508,7 @@ void log_t::create()
ut_ad(srv_log_buffer_size >= 16 * OS_FILE_LOG_BLOCK_SIZE);
ut_ad(srv_log_buffer_size >= 4U << srv_page_size_shift);
- buf= static_cast<byte*>(ut_malloc_dontdump(srv_log_buffer_size * 2));
+ buf= static_cast<byte*>(ut_malloc_dontdump(srv_log_buffer_size * 2, PSI_INSTRUMENT_ME));
TRASH_ALLOC(buf, srv_log_buffer_size * 2);
first_in_use= true;
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index c6211acb5a5..9dd54c945b9 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -1008,7 +1008,7 @@ void recv_sys_t::create()
apply_batch_on = false;
max_log_blocks = buf_pool_get_n_pages() / 3;
- buf = static_cast<byte*>(ut_malloc_dontdump(RECV_PARSING_BUF_SIZE));
+ buf = static_cast<byte*>(ut_malloc_dontdump(RECV_PARSING_BUF_SIZE, PSI_INSTRUMENT_ME));
len = 0;
parse_start_lsn = 0;
scanned_lsn = 0;
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 5351f6ea673..0ccc651cc0e 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -527,7 +527,7 @@ static int table2maria(TABLE *table_arg, data_file_type row_type,
if (row_type == BLOCK_RECORD)
options|= HA_OPTION_PACK_RECORD;
- if (!(my_multi_malloc(MYF(MY_WME),
+ if (!(my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
recinfo_out, (share->fields * 2 + 2) * sizeof(MARIA_COLUMNDEF),
keydef_out, share->keys * sizeof(MARIA_KEYDEF),
&keyseg,
diff --git a/storage/maria/lockman.c b/storage/maria/lockman.c
index 590935967af..2eeb3c339bf 100644
--- a/storage/maria/lockman.c
+++ b/storage/maria/lockman.c
@@ -554,7 +554,7 @@ static void initialize_bucket(LOCKMAN *lm, LOCK * volatile *node,
{
int res;
uint parent= my_clear_highest_bit(bucket);
- LOCK *dummy= (LOCK *)my_malloc(sizeof(LOCK), MYF(MY_WME));
+ LOCK *dummy= (LOCK *)my_malloc(PSI_INSTRUMENT_ME, sizeof(LOCK), MYF(MY_WME));
LOCK **tmp= 0, *cur;
LOCK * volatile *el= lf_dynarray_lvalue(&lm->array, parent);
diff --git a/storage/maria/ma_backup.c b/storage/maria/ma_backup.c
index 79270425b38..83b521b1cad 100644
--- a/storage/maria/ma_backup.c
+++ b/storage/maria/ma_backup.c
@@ -59,7 +59,7 @@ int aria_get_capabilities(File kfile, ARIA_TABLE_CAPABILITIES *cap)
Allocate space for header information and for data that is too
big to keep on stack
*/
- if (!(disc_cache= my_malloc(info_length, MYF(MY_WME))))
+ if (!(disc_cache= my_malloc(PSI_NOT_INSTRUMENTED, info_length, MYF(MY_WME))))
DBUG_RETURN(ENOMEM);
if (my_pread(kfile, disc_cache, info_length, 0L, MYF(MY_NABP)))
diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c
index e9e07a56706..fd98adcaa1a 100644
--- a/storage/maria/ma_bitmap.c
+++ b/storage/maria/ma_bitmap.c
@@ -238,8 +238,8 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file,
size*= 2;
#endif
- if (((bitmap->map= (uchar*) my_malloc(size, MYF(MY_WME))) == NULL) ||
- my_init_dynamic_array(&bitmap->pinned_pages,
+ if (!((bitmap->map= (uchar*) my_malloc(PSI_INSTRUMENT_ME, size, MYF(MY_WME)))) ||
+ my_init_dynamic_array(&bitmap->pinned_pages, PSI_INSTRUMENT_ME,
sizeof(MARIA_PINNED_PAGE), 1, 1, MYF(0)))
return 1;
diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c
index be7634f7521..f827846298c 100644
--- a/storage/maria/ma_blockrec.c
+++ b/storage/maria/ma_blockrec.c
@@ -491,7 +491,7 @@ my_bool _ma_init_block_record(MARIA_HA *info)
uint default_extents;
DBUG_ENTER("_ma_init_block_record");
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&row->empty_bits, share->base.pack_bytes,
&row->field_lengths,
share->base.max_field_lengths + 2,
@@ -530,12 +530,13 @@ my_bool _ma_init_block_record(MARIA_HA *info)
FULL_PAGE_SIZE(share) /
BLOB_SEGMENT_MIN_SIZE));
- if (my_init_dynamic_array(&info->bitmap_blocks,
+ if (my_init_dynamic_array(&info->bitmap_blocks, PSI_INSTRUMENT_ME,
sizeof(MARIA_BITMAP_BLOCK), default_extents,
64, MYF(0)))
goto err;
info->cur_row.extents_buffer_length= default_extents * ROW_EXTENT_SIZE;
- if (!(info->cur_row.extents= my_malloc(info->cur_row.extents_buffer_length,
+ if (!(info->cur_row.extents= my_malloc(PSI_INSTRUMENT_ME,
+ info->cur_row.extents_buffer_length,
MYF(MY_WME))))
goto err;
@@ -3235,7 +3236,7 @@ static my_bool write_block_record(MARIA_HA *info,
}
else
{
- if (!my_multi_malloc(MY_WME, &log_array,
+ if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME), &log_array,
(uint) ((bitmap_blocks->count +
TRANSLOG_INTERNAL_PARTS + 2) *
sizeof(*log_array)),
@@ -5256,7 +5257,8 @@ my_bool _ma_scan_init_block_record(MARIA_HA *info)
*/
if (!(info->scan.bitmap_buff ||
((info->scan.bitmap_buff=
- (uchar *) my_malloc(share->block_size * 2, MYF(MY_WME))))))
+ (uchar *) my_malloc(PSI_INSTRUMENT_ME, share->block_size * 2,
+ MYF(MY_WME))))))
DBUG_RETURN(1);
info->scan.page_buff= info->scan.bitmap_buff + share->block_size;
info->scan.bitmap_end= info->scan.bitmap_buff + share->bitmap.max_total_size;
@@ -5311,7 +5313,8 @@ int _ma_scan_remember_block_record(MARIA_HA *info,
DBUG_ENTER("_ma_scan_remember_block_record");
if (!(info->scan_save))
{
- if (!(info->scan_save= my_malloc(ALIGN_SIZE(sizeof(*info->scan_save)) +
+ if (!(info->scan_save= my_malloc(PSI_INSTRUMENT_ME,
+ ALIGN_SIZE(sizeof(*info->scan_save)) +
info->s->block_size * 2,
MYF(MY_WME))))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -7129,7 +7132,8 @@ my_bool _ma_apply_undo_row_delete(MARIA_HA *info, LSN undo_lsn,
row.blob_length= ma_get_length(&header);
/* We need to build up a record (without blobs) in rec_buff */
- if (!(record= my_malloc(share->base.reclength, MYF(MY_WME))))
+ if (!(record= my_malloc(PSI_INSTRUMENT_ME, share->base.reclength,
+ MYF(MY_WME))))
DBUG_RETURN(1);
memcpy(record, null_bits, share->base.null_bytes);
@@ -7354,7 +7358,8 @@ my_bool _ma_apply_undo_row_update(MARIA_HA *info, LSN undo_lsn,
field_length_data_end= header;
/* Allocate buffer for current row & original row */
- if (!(current_record= my_malloc(share->base.reclength * 2, MYF(MY_WME))))
+ if (!(current_record= my_malloc(PSI_INSTRUMENT_ME, share->base.reclength * 2,
+ MYF(MY_WME))))
DBUG_RETURN(1);
orig_record= current_record+ share->base.reclength;
diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c
index 8b4e34816d5..6f202e2a406 100644
--- a/storage/maria/ma_check.c
+++ b/storage/maria/ma_check.c
@@ -2078,7 +2078,8 @@ int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info, my_bool extend)
puts("- check record links");
}
- if (!(record= (uchar*) my_malloc(share->base.default_rec_buff_size, MYF(0))))
+ if (!(record= (uchar*) my_malloc(PSI_INSTRUMENT_ME,
+ share->base.default_rec_buff_size, MYF(0))))
{
_ma_check_print_error(param,"Not enough memory for record");
DBUG_RETURN(-1);
@@ -2688,7 +2689,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
}
if (!(sort_param.record=
- (uchar *) my_malloc((uint)
+ (uchar *) my_malloc(PSI_INSTRUMENT_ME, (uint)
share->base.default_rec_buff_size, MYF(0))) ||
_ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size,
share->base.default_rec_buff_size))
@@ -3628,7 +3629,7 @@ int maria_filecopy(HA_CHECK *param, File to,File from,my_off_t start,
DBUG_ENTER("maria_filecopy");
buff_length=(ulong) MY_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
+ if (!(buff=my_malloc(PSI_INSTRUMENT_ME, buff_length, MYF(0))))
{
buff=tmp_buff; buff_length=IO_SIZE;
}
@@ -3772,7 +3773,8 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
}
if (!(sort_param.record=
- (uchar*) my_malloc((size_t) share->base.default_rec_buff_size,
+ (uchar*) my_malloc(PSI_INSTRUMENT_ME,
+ (size_t) share->base.default_rec_buff_size,
MYF(0))) ||
_ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size,
share->base.default_rec_buff_size))
@@ -3792,7 +3794,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
param->read_cache.end_of_file= sort_info.filelength;
sort_param.wordlist=NULL;
- init_alloc_root(&sort_param.wordroot, "sort", FTPARSER_MEMROOT_ALLOC_SIZE, 0,
+ init_alloc_root(PSI_INSTRUMENT_ME, &sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0,
MYF(param->malloc_flags));
sort_param.key_cmp=sort_key_cmp;
@@ -4356,7 +4358,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
del=share->state.state.del;
if (!(sort_param=(MARIA_SORT_PARAM *)
- my_malloc((uint) share->base.keys *
+ my_malloc(PSI_INSTRUMENT_ME, (uint) share->base.keys *
(sizeof(MARIA_SORT_PARAM) + share->base.pack_reclength),
MYF(MY_ZEROFILL))))
{
@@ -4440,8 +4442,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
(FT_MAX_WORD_LEN_FOR_SORT *
sort_param[i].keyinfo->seg->charset->mbmaxlen);
sort_param[i].key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
- init_alloc_root(&sort_param[i].wordroot, "sort",
- FTPARSER_MEMROOT_ALLOC_SIZE, 0,
+ init_alloc_root(PSI_INSTRUMENT_ME, &sort_param[i].wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0,
MYF(param->malloc_flags));
}
}
@@ -5423,7 +5424,7 @@ int _ma_sort_write_record(MARIA_SORT_PARAM *sort_param)
MARIA_DYN_DELETE_BLOCK_HEADER;
if (sort_info->buff_length < reclength)
{
- if (!(sort_info->buff=my_realloc(sort_info->buff, (uint) reclength,
+ if (!(sort_info->buff=my_realloc(PSI_INSTRUMENT_ME, sort_info->buff, (uint) reclength,
MYF(MY_FREE_ON_ERROR |
MY_ALLOW_ZERO_PTR))))
DBUG_RETURN(1);
@@ -5649,7 +5650,7 @@ static int sort_maria_ft_key_write(MARIA_SORT_PARAM *sort_param,
share->rec_reflength) &&
(share->options &
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)))
- ft_buf= (MA_SORT_FT_BUF *)my_malloc(sort_param->keyinfo->block_length +
+ ft_buf= (MA_SORT_FT_BUF *)my_malloc(PSI_INSTRUMENT_ME, sort_param->keyinfo->block_length +
sizeof(MA_SORT_FT_BUF), MYF(MY_WME));
if (!ft_buf)
@@ -5975,9 +5976,8 @@ static MA_SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks,
MA_SORT_KEY_BLOCKS *block;
DBUG_ENTER("alloc_key_blocks");
- if (!(block= (MA_SORT_KEY_BLOCKS*) my_malloc((sizeof(MA_SORT_KEY_BLOCKS)+
- buffer_length+IO_SIZE)*blocks,
- MYF(0))))
+ if (!(block= (MA_SORT_KEY_BLOCKS*) my_malloc(PSI_INSTRUMENT_ME,
+ (sizeof(MA_SORT_KEY_BLOCKS)+buffer_length+IO_SIZE)*blocks, MYF(0))))
{
_ma_check_print_error(param,"Not enough memory for sort-key-blocks");
return(0);
@@ -6309,7 +6309,7 @@ void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
We have to use an allocated buffer instead of info->rec_buff as
_ma_put_key_in_record() may use info->rec_buff
*/
- if (!(record= (uchar*) my_malloc((size_t) share->base.default_rec_buff_size,
+ if (!(record= (uchar*) my_malloc(PSI_INSTRUMENT_ME, (size_t) share->base.default_rec_buff_size,
MYF(0))))
{
_ma_check_print_error(param,"Not enough memory for extra record");
@@ -6972,7 +6972,7 @@ static void print_bitmap_description(MARIA_SHARE *share,
pgcache_page_no_t page,
uchar *bitmap_data)
{
- char *tmp= my_malloc(MAX_BITMAP_INFO_LENGTH, MYF(MY_WME));
+ char *tmp= my_malloc(PSI_INSTRUMENT_ME, MAX_BITMAP_INFO_LENGTH, MYF(MY_WME));
if (!tmp)
return;
_ma_get_bitmap_description(&share->bitmap, bitmap_data, page, tmp);
diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c
index e525602f7a1..caf6656c000 100644
--- a/storage/maria/ma_checkpoint.c
+++ b/storage/maria/ma_checkpoint.c
@@ -790,7 +790,7 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
}
}
if (unlikely((distinct_shares=
- (MARIA_SHARE **)my_malloc(nb * sizeof(MARIA_SHARE *),
+ (MARIA_SHARE **)my_malloc(PSI_INSTRUMENT_ME, nb * sizeof(MARIA_SHARE *),
MYF(MY_WME))) == NULL))
goto err;
for (total_names_length= 0, i= 0, pos= maria_open_list; pos; pos= pos->next)
@@ -823,7 +823,7 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
LSN_STORE_SIZE + /* first_log_write_at_lsn */
1 /* end-of-name 0 */
) * nb + total_names_length;
- if (unlikely((str->str= my_malloc(str->length, MYF(MY_WME))) == NULL))
+ if (unlikely((str->str= my_malloc(PSI_INSTRUMENT_ME, str->length, MYF(MY_WME))) == NULL))
goto err;
ptr= str->str;
@@ -853,12 +853,12 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
*/
#define STATE_COPIES 1024
state_copies= (struct st_state_copy *)
- my_malloc(STATE_COPIES * sizeof(struct st_state_copy), MYF(MY_WME));
- dfiles= (PAGECACHE_FILE *)my_realloc((uchar *)dfiles,
+ my_malloc(PSI_INSTRUMENT_ME, STATE_COPIES * sizeof(struct st_state_copy), MYF(MY_WME));
+ dfiles= (PAGECACHE_FILE *)my_realloc(PSI_INSTRUMENT_ME, (uchar *)dfiles,
/* avoid size of 0 for my_realloc */
MY_MAX(1, nb) * sizeof(PAGECACHE_FILE),
MYF(MY_WME | MY_ALLOW_ZERO_PTR));
- kfiles= (PAGECACHE_FILE *)my_realloc((uchar *)kfiles,
+ kfiles= (PAGECACHE_FILE *)my_realloc(PSI_INSTRUMENT_ME, (uchar *)kfiles,
/* avoid size of 0 for my_realloc */
MY_MAX(1, nb) * sizeof(PAGECACHE_FILE),
MYF(MY_WME | MY_ALLOW_ZERO_PTR));
diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c
index 27be555ab70..d66e3bda4de 100644
--- a/storage/maria/ma_close.c
+++ b/storage/maria/ma_close.c
@@ -213,7 +213,7 @@ int maria_close(register MARIA_HA *info)
wrong status information.
*/
if ((history= (MARIA_STATE_HISTORY_CLOSED *)
- my_malloc(sizeof(*history), MYF(MY_WME))))
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(*history), MYF(MY_WME))))
{
history->create_rename_lsn= share->state.create_rename_lsn;
history->state_history= share->state_history;
diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c
index 06139ed564d..a13190b0220 100644
--- a/storage/maria/ma_create.c
+++ b/storage/maria/ma_create.c
@@ -145,7 +145,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
}
if (!(rec_per_key_part=
- (double*) my_malloc((keys + uniques)*HA_MAX_KEY_SEG*sizeof(double) +
+ (double*) my_malloc(PSI_INSTRUMENT_ME,
+ (keys + uniques)*HA_MAX_KEY_SEG*sizeof(double) +
(keys + uniques)*HA_MAX_KEY_SEG*sizeof(ulong) +
sizeof(uint16) * columns,
MYF(MY_WME | MY_ZEROFILL))))
@@ -1028,7 +1029,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
{
/* Store columns in a more efficent order */
MARIA_COLUMNDEF **col_order, **pos;
- if (!(col_order= (MARIA_COLUMNDEF**) my_malloc(share.base.fields *
+ if (!(col_order= (MARIA_COLUMNDEF**) my_malloc(PSI_INSTRUMENT_ME,
+ share.base.fields *
sizeof(MARIA_COLUMNDEF*),
MYF(MY_WME))))
goto err;
@@ -1090,7 +1092,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
log_array[TRANSLOG_INTERNAL_PARTS + 1].length= 1 + 2 + 2 +
(uint) kfile_size_before_extension;
/* we are needing maybe 64 kB, so don't use the stack */
- log_data= my_malloc(log_array[TRANSLOG_INTERNAL_PARTS + 1].length, MYF(0));
+ log_data= my_malloc(PSI_INSTRUMENT_ME,
+ log_array[TRANSLOG_INTERNAL_PARTS + 1].length, MYF(0));
if ((log_data == NULL) ||
mysql_file_pread(file, 1 + 2 + 2 + log_data,
(size_t) kfile_size_before_extension, 0, MYF(MY_NABP)))
diff --git a/storage/maria/ma_crypt.c b/storage/maria/ma_crypt.c
index 95b84d38221..48861485012 100644
--- a/storage/maria/ma_crypt.c
+++ b/storage/maria/ma_crypt.c
@@ -101,7 +101,7 @@ int
ma_crypt_create(MARIA_SHARE* share)
{
MARIA_CRYPT_DATA *crypt_data=
- (MARIA_CRYPT_DATA*)my_malloc(sizeof(MARIA_CRYPT_DATA), MYF(MY_ZEROFILL));
+ (MARIA_CRYPT_DATA*)my_malloc(PSI_INSTRUMENT_ME, sizeof(MARIA_CRYPT_DATA), MYF(MY_ZEROFILL));
crypt_data->scheme.type= CRYPT_SCHEME_1;
crypt_data->scheme.locker= crypt_data_scheme_locker;
mysql_mutex_init(key_CRYPT_DATA_lock, &crypt_data->lock, MY_MUTEX_INIT_FAST);
@@ -165,7 +165,7 @@ ma_crypt_read(MARIA_SHARE* share, uchar *buff)
{
/* opening a table */
MARIA_CRYPT_DATA *crypt_data=
- (MARIA_CRYPT_DATA*)my_malloc(sizeof(MARIA_CRYPT_DATA), MYF(MY_ZEROFILL));
+ (MARIA_CRYPT_DATA*)my_malloc(PSI_INSTRUMENT_ME, sizeof(MARIA_CRYPT_DATA), MYF(MY_ZEROFILL));
crypt_data->scheme.type= type;
mysql_mutex_init(key_CRYPT_DATA_lock, &crypt_data->lock,
@@ -189,7 +189,7 @@ static int ma_decrypt(MARIA_SHARE *, MARIA_CRYPT_DATA *, const uchar *,
static my_bool ma_crypt_pre_read_hook(PAGECACHE_IO_HOOK_ARGS *args)
{
MARIA_SHARE *share= (MARIA_SHARE*) args->data;
- uchar *crypt_buf= my_malloc(share->block_size, MYF(0));
+ uchar *crypt_buf= my_malloc(PSI_INSTRUMENT_ME, share->block_size, MYF(0));
if (crypt_buf == NULL)
{
args->crypt_buf= NULL; /* for post-hook */
@@ -260,7 +260,7 @@ static my_bool ma_crypt_data_pre_write_hook(PAGECACHE_IO_HOOK_ARGS *args)
MARIA_SHARE *share= (MARIA_SHARE*) args->data;
const uint size= share->block_size;
uint key_version;
- uchar *crypt_buf= my_malloc(share->block_size, MYF(0));
+ uchar *crypt_buf= my_malloc(PSI_INSTRUMENT_ME, share->block_size, MYF(0));
if (crypt_buf == NULL)
{
@@ -385,7 +385,7 @@ static my_bool ma_crypt_index_pre_write_hook(PAGECACHE_IO_HOOK_ARGS *args)
const uint block_size= share->block_size;
const uint page_used= _ma_get_page_used(share, args->page);
uint key_version;
- uchar *crypt_buf= my_malloc(block_size, MYF(0));
+ uchar *crypt_buf= my_malloc(PSI_INSTRUMENT_ME, block_size, MYF(0));
if (crypt_buf == NULL)
{
args->crypt_buf= NULL; /* for post-hook */
diff --git a/storage/maria/ma_ft_boolean_search.c b/storage/maria/ma_ft_boolean_search.c
index 70ab6b2e3f6..596c50ee497 100644
--- a/storage/maria/ma_ft_boolean_search.c
+++ b/storage/maria/ma_ft_boolean_search.c
@@ -561,7 +561,7 @@ FT_INFO * maria_ft_init_boolean_search(MARIA_HA *info, uint keynr,
FTB_EXPR *ftbe;
FTB_WORD *ftbw;
- if (!(ftb=(FTB *)my_malloc(sizeof(FTB), MYF(MY_WME))))
+ if (!(ftb=(FTB *)my_malloc(PSI_INSTRUMENT_ME, sizeof(FTB), MYF(MY_WME))))
return 0;
ftb->please= (struct _ft_vft *) & _ma_ft_vft_boolean;
ftb->state=UNINITIALIZED;
@@ -574,7 +574,7 @@ FT_INFO * maria_ft_init_boolean_search(MARIA_HA *info, uint keynr,
bzero(& ftb->no_dupes, sizeof(TREE));
ftb->last_word= 0;
- init_alloc_root(&ftb->mem_root, "fulltext", 1024, 1024, 0);
+ init_alloc_root(PSI_INSTRUMENT_ME, &ftb->mem_root, 1024, 1024, 0);
ftb->queue.max_elements= 0;
if (!(ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR))))
goto err;
diff --git a/storage/maria/ma_ft_nlq_search.c b/storage/maria/ma_ft_nlq_search.c
index f7aa3afec9a..6c4e30bca83 100644
--- a/storage/maria/ma_ft_nlq_search.c
+++ b/storage/maria/ma_ft_nlq_search.c
@@ -291,7 +291,7 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, uchar *query,
If ndocs == 0, this will not allocate RAM for FT_INFO.doc[],
so if ndocs == 0, FT_INFO.doc[] must not be accessed.
*/
- dlist=(FT_INFO *)my_malloc(sizeof(FT_INFO)+
+ dlist=(FT_INFO *)my_malloc(PSI_INSTRUMENT_ME, sizeof(FT_INFO)+
sizeof(FT_DOC)*
(int)(aio.dtree.elements_in_tree-1),
MYF(0));
diff --git a/storage/maria/ma_ft_parser.c b/storage/maria/ma_ft_parser.c
index 2dfb4a77557..00532af0b47 100644
--- a/storage/maria/ma_ft_parser.c
+++ b/storage/maria/ma_ft_parser.c
@@ -347,9 +347,9 @@ MYSQL_FTPARSER_PARAM* maria_ftparser_alloc_param(MARIA_HA *info)
(ftb_check_phrase_internal, ftb_phrase_add_word). Thus MAX_PARAM_NR=2.
*/
info->ftparser_param= (MYSQL_FTPARSER_PARAM *)
- my_malloc(MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) *
+ my_malloc(PSI_INSTRUMENT_ME, MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) *
info->s->ftkeys, MYF(MY_WME | MY_ZEROFILL));
- init_alloc_root(&info->ft_memroot, "fulltext_parser",
+ init_alloc_root(PSI_INSTRUMENT_ME, &info->ft_memroot,
FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(0));
}
return info->ftparser_param;
diff --git a/storage/maria/ma_init.c b/storage/maria/ma_init.c
index 12d39db806a..76b6959629b 100644
--- a/storage/maria/ma_init.c
+++ b/storage/maria/ma_init.c
@@ -72,7 +72,8 @@ int maria_init(void)
maria_create_trn_hook= dummy_maria_create_trn_hook;
}
my_hash_init(&maria_stored_state, &my_charset_bin, 32,
- 0, sizeof(LSN), 0, (my_hash_free_key) history_state_free, 0);
+ 0, sizeof(LSN), 0, (my_hash_free_key) history_state_free, 0,
+ PSI_INSTRUMENT_ME);
DBUG_PRINT("info",("dummy_transaction_object: %p",
&dummy_transaction_object));
return 0;
diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
index a55026e3251..f1d0703de6c 100644
--- a/storage/maria/ma_loghandler.c
+++ b/storage/maria/ma_loghandler.c
@@ -1649,7 +1649,7 @@ static void translog_file_init(TRANSLOG_FILE *file, uint32 number,
static my_bool translog_create_new_file()
{
- TRANSLOG_FILE *file= (TRANSLOG_FILE*)my_malloc(sizeof(TRANSLOG_FILE),
+ TRANSLOG_FILE *file= (TRANSLOG_FILE*)my_malloc(PSI_INSTRUMENT_ME, sizeof(TRANSLOG_FILE),
MYF(0));
TRANSLOG_FILE *old= get_current_logfile();
@@ -3660,9 +3660,9 @@ my_bool translog_init_with_table(const char *directory,
&log_descriptor.new_goal_cond, 0) ||
mysql_rwlock_init(key_TRANSLOG_DESCRIPTOR_open_files_lock,
&log_descriptor.open_files_lock) ||
- my_init_dynamic_array(&log_descriptor.open_files,
+ my_init_dynamic_array(&log_descriptor.open_files, PSI_INSTRUMENT_ME,
sizeof(TRANSLOG_FILE*), 10, 10, MYF(0)) ||
- my_init_dynamic_array(&log_descriptor.unfinished_files,
+ my_init_dynamic_array(&log_descriptor.unfinished_files, PSI_INSTRUMENT_ME,
sizeof(struct st_file_counter),
10, 10, MYF(0)))
goto err;
@@ -3814,7 +3814,7 @@ my_bool translog_init_with_table(const char *directory,
We can't allocate all file together because they will be freed
one by one
*/
- TRANSLOG_FILE *file= (TRANSLOG_FILE *)my_malloc(sizeof(TRANSLOG_FILE),
+ TRANSLOG_FILE *file= (TRANSLOG_FILE *)my_malloc(PSI_INSTRUMENT_ME, sizeof(TRANSLOG_FILE),
MYF(0));
compile_time_assert(MY_FILEPOS_ERROR > 0xffffffffULL);
@@ -4016,8 +4016,8 @@ my_bool translog_init_with_table(const char *directory,
logs_found, old_log_was_recovered));
if (!logs_found)
{
- TRANSLOG_FILE *file= (TRANSLOG_FILE*)my_malloc(sizeof(TRANSLOG_FILE),
- MYF(MY_WME));
+ TRANSLOG_FILE *file= (TRANSLOG_FILE*)my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(TRANSLOG_FILE), MYF(MY_WME));
DBUG_PRINT("info", ("The log is not found => we will create new log"));
if (file == NULL)
goto err;
@@ -4084,7 +4084,7 @@ my_bool translog_init_with_table(const char *directory,
Log records will refer to a MARIA_SHARE by a unique 2-byte id; set up
structures for generating 2-byte ids:
*/
- id_to_share= (MARIA_SHARE **) my_malloc(SHARE_ID_MAX * sizeof(MARIA_SHARE*),
+ id_to_share= (MARIA_SHARE **) my_malloc(PSI_INSTRUMENT_ME, SHARE_ID_MAX * sizeof(MARIA_SHARE*),
MYF(MY_WME | MY_ZEROFILL));
if (unlikely(!id_to_share))
goto err;
@@ -5649,7 +5649,7 @@ translog_write_variable_record_mgroup(LSN *lsn,
used_buffs_init(&cursor.buffs);
chunk2_header[0]= TRANSLOG_CHUNK_NOHDR;
- if (my_init_dynamic_array(&groups,
+ if (my_init_dynamic_array(&groups, PSI_INSTRUMENT_ME,
sizeof(struct st_translog_group_descriptor),
10, 10, MYF(0)))
{
@@ -6994,7 +6994,7 @@ translog_variable_length_header(uchar *page, translog_size_t page_offset,
DBUG_PRINT("info", ("multi-group"));
grp_no= buff->groups_no= uint2korr(src + 2);
if (!(buff->groups=
- (TRANSLOG_GROUP*) my_malloc(sizeof(TRANSLOG_GROUP) * grp_no,
+ (TRANSLOG_GROUP*) my_malloc(PSI_INSTRUMENT_ME, sizeof(TRANSLOG_GROUP) * grp_no,
MYF(0))))
DBUG_RETURN(RECHEADER_READ_ERROR);
DBUG_PRINT("info", ("Groups: %u", (uint) grp_no));
diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c
index c7080daa265..08590b9b3f6 100644
--- a/storage/maria/ma_open.c
+++ b/storage/maria/ma_open.c
@@ -117,7 +117,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
errpos= 5;
/* alloc and set up private structure parts */
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&m_info,sizeof(MARIA_HA),
&info.blobs,sizeof(MARIA_BLOB)*share->base.blobs,
&info.buff,(share->base.max_key_block_length*2+
@@ -166,7 +166,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
goto err;
/* The following should be big enough for all pinning purposes */
- if (my_init_dynamic_array(&info.pinned_pages,
+ if (my_init_dynamic_array(&info.pinned_pages, PSI_INSTRUMENT_ME,
sizeof(MARIA_PINNED_PAGE),
MY_MAX(share->base.blobs*2 + 4,
MARIA_MAX_TREE_LEVELS*3), 16, MYF(0)))
@@ -465,7 +465,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
Allocate space for header information and for data that is too
big to keep on stack
*/
- if (!(disk_cache= my_malloc(info_length+128, MYF(MY_WME))))
+ if (!(disk_cache= my_malloc(PSI_INSTRUMENT_ME, info_length+128, MYF(MY_WME))))
{
my_errno=ENOMEM;
goto err;
@@ -648,7 +648,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
share->index_file_name.length= strlen(index_name);
share->data_file_name.length= strlen(data_name);
share->open_file_name.length= strlen(name);
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
&share,sizeof(*share),
&rec_per_key_part,
sizeof(double) * key_parts,
@@ -1043,7 +1043,8 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
{
/* Table is not part of any active transaction; Create new history */
if (!(share->state_history= (MARIA_STATE_HISTORY *)
- my_malloc(sizeof(*share->state_history), MYF(MY_WME))))
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(*share->state_history),
+ MYF(MY_WME))))
goto err;
share->state_history->trid= 0; /* Visible by all */
share->state_history->state= share->state.state;
@@ -1244,7 +1245,7 @@ my_bool _ma_alloc_buffer(uchar **old_addr, size_t *old_size,
if (*old_size < new_size)
{
uchar *addr;
- if (!(addr= (uchar*) my_realloc(*old_addr, new_size,
+ if (!(addr= (uchar*) my_realloc(PSI_INSTRUMENT_ME, *old_addr, new_size,
MYF(MY_ALLOW_ZERO_PTR))))
return 1;
*old_addr= addr;
@@ -1636,7 +1637,7 @@ static uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state)
/* Allocate memory for key parts if not already done */
if (!state->rec_per_key_part &&
- !my_multi_malloc(MY_WME,
+ !my_multi_malloc(PSI_INSTRUMENT_ME, MY_WME,
&state->rec_per_key_part,
sizeof(*state->rec_per_key_part) * key_parts,
&state->nulls_per_key_part,
diff --git a/storage/maria/ma_packrec.c b/storage/maria/ma_packrec.c
index 2e7add8f61d..b2cf7fb697a 100644
--- a/storage/maria/ma_packrec.c
+++ b/storage/maria/ma_packrec.c
@@ -228,7 +228,7 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file,
- Distinct column values
*/
if (!(share->decode_trees=(MARIA_DECODE_TREE*)
- my_malloc((uint) (trees*sizeof(MARIA_DECODE_TREE)+
+ my_malloc(PSI_INSTRUMENT_ME, (uint) (trees*sizeof(MARIA_DECODE_TREE)+
intervall_length*sizeof(uchar)),
MYF(MY_WME))))
goto err0;
@@ -244,7 +244,7 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file,
*/
length=(uint) (elements*2+trees*(1 << maria_quick_table_bits));
if (!(share->decode_tables=(uint16*)
- my_malloc((length+OFFSET_TABLE_SIZE)*sizeof(uint16)+
+ my_malloc(PSI_INSTRUMENT_ME, (length+OFFSET_TABLE_SIZE)*sizeof(uint16)+
(uint) (share->pack.header_length - sizeof(header)) +
share->base.extra_rec_buff_size,
MYF(MY_WME | MY_ZEROFILL))))
@@ -291,9 +291,9 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file,
goto err3;
/* Reallocate the decoding tables to the used size. */
decode_table=(uint16*)
- my_realloc((uchar*) share->decode_tables,
+ my_realloc(PSI_INSTRUMENT_ME, (uchar*) share->decode_tables,
(uint) ((uchar*) decode_table - (uchar*) share->decode_tables),
- MYF(MY_HOLD_ON_ERROR));
+ MYF(0));
/* Fix the table addresses in the tree heads. */
{
my_ptrdiff_t diff= PTR_BYTE_DIFF(decode_table,share->decode_tables);
diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c
index 13a2f18cc94..72ca4da98fb 100644
--- a/storage/maria/ma_pagecache.c
+++ b/storage/maria/ma_pagecache.c
@@ -792,7 +792,7 @@ size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem,
my_hash_init(&pagecache->files_in_flush, &my_charset_bin, 32,
offsetof(struct st_file_in_flush, file),
sizeof(((struct st_file_in_flush *)NULL)->file),
- NULL, NULL, 0))
+ NULL, NULL, 0, PSI_INSTRUMENT_ME))
goto err;
pagecache->inited= 1;
pagecache->in_init= 0;
@@ -853,7 +853,7 @@ size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem,
Allocate memory for blocks, hash_links and hash entries;
For each block 2 hash links are allocated
*/
- if (my_multi_malloc_large(MYF(MY_ZEROFILL),
+ if (my_multi_malloc_large(PSI_INSTRUMENT_ME, MYF(MY_ZEROFILL),
&pagecache->block_root,
(ulonglong) (blocks *
sizeof(PAGECACHE_BLOCK_LINK)),
@@ -2330,7 +2330,7 @@ static void add_pin(PAGECACHE_BLOCK_LINK *block)
#ifndef DBUG_OFF
{
PAGECACHE_PIN_INFO *info=
- (PAGECACHE_PIN_INFO *)my_malloc(sizeof(PAGECACHE_PIN_INFO), MYF(0));
+ (PAGECACHE_PIN_INFO *)my_malloc(PSI_INSTRUMENT_ME, sizeof(PAGECACHE_PIN_INFO), MYF(0));
info->thread= my_thread_var;
info_link(&block->pin_list, info);
}
@@ -2364,7 +2364,7 @@ static void remove_pin(PAGECACHE_BLOCK_LINK *block, my_bool any
static void info_add_lock(PAGECACHE_BLOCK_LINK *block, my_bool wl)
{
PAGECACHE_LOCK_INFO *info=
- (PAGECACHE_LOCK_INFO *)my_malloc(sizeof(PAGECACHE_LOCK_INFO), MYF(0));
+ (PAGECACHE_LOCK_INFO *)my_malloc(PSI_INSTRUMENT_ME, sizeof(PAGECACHE_LOCK_INFO), MYF(0));
info->thread= my_thread_var;
info->write_lock= wl;
info_link((PAGECACHE_PIN_INFO **)&block->lock_list,
@@ -4939,7 +4939,7 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
if (count > FLUSH_CACHE &&
!(cache=
(PAGECACHE_BLOCK_LINK**)
- my_malloc(sizeof(PAGECACHE_BLOCK_LINK*)*count, MYF(0))))
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(PAGECACHE_BLOCK_LINK*)*count, MYF(0))))
{
cache= cache_buff;
count= FLUSH_CACHE;
@@ -5295,7 +5295,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
5 + /* pageno */
LSN_STORE_SIZE /* rec_lsn */
) * stored_list_size;
- if (NULL == (str->str= my_malloc(str->length, MYF(MY_WME))))
+ if (NULL == (str->str= my_malloc(PSI_INSTRUMENT_ME, str->length, MYF(MY_WME))))
goto err;
ptr= str->str;
int8store(ptr, (ulonglong)stored_list_size);
diff --git a/storage/maria/ma_preload.c b/storage/maria/ma_preload.c
index eefc9777be6..60fd9b09bb3 100644
--- a/storage/maria/ma_preload.c
+++ b/storage/maria/ma_preload.c
@@ -56,7 +56,7 @@ int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves)
block_length= share->pagecache->block_size;
- if (!(buff= (uchar *) my_malloc(block_length, MYF(MY_WME))))
+ if (!(buff= (uchar *) my_malloc(PSI_INSTRUMENT_ME, block_length, MYF(MY_WME))))
DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM);
if (flush_pagecache_blocks(share->pagecache, &share->kfile, FLUSH_RELEASE))
diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c
index 6ce158dd468..4f48cf604ac 100644
--- a/storage/maria/ma_recovery.c
+++ b/storage/maria/ma_recovery.c
@@ -152,7 +152,7 @@ static void enlarge_buffer(const TRANSLOG_HEADER_BUFFER *rec)
if (log_record_buffer.length < rec->record_length)
{
log_record_buffer.length= rec->record_length;
- log_record_buffer.str= my_realloc(log_record_buffer.str,
+ log_record_buffer.str= my_realloc(PSI_INSTRUMENT_ME, log_record_buffer.str,
rec->record_length,
MYF(MY_WME | MY_ALLOW_ZERO_PTR));
}
@@ -296,10 +296,10 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn,
DBUG_ASSERT(should_run_undo_phase || !take_checkpoints);
DBUG_ASSERT(end_lsn == LSN_IMPOSSIBLE || should_run_undo_phase == 0);
all_active_trans= (struct st_trn_for_recovery *)
- my_malloc((SHORT_TRID_MAX + 1) * sizeof(struct st_trn_for_recovery),
+ my_malloc(PSI_INSTRUMENT_ME, (SHORT_TRID_MAX + 1) * sizeof(struct st_trn_for_recovery),
MYF(MY_ZEROFILL));
all_tables= (struct st_table_for_recovery *)
- my_malloc((SHARE_ID_MAX + 1) * sizeof(struct st_table_for_recovery),
+ my_malloc(PSI_INSTRUMENT_ME, (SHARE_ID_MAX + 1) * sizeof(struct st_table_for_recovery),
MYF(MY_ZEROFILL));
save_error_handler_hook= error_handler_hook;
@@ -3351,10 +3351,10 @@ static LSN parse_checkpoint_record(LSN lsn)
if (my_hash_init(&all_dirty_pages, &my_charset_bin, (ulong)nb_dirty_pages,
offsetof(struct st_dirty_page, file_and_page_id),
sizeof(((struct st_dirty_page *)NULL)->file_and_page_id),
- NULL, NULL, 0))
+ NULL, NULL, 0, PSI_INSTRUMENT_ME))
return LSN_ERROR;
dirty_pages_pool=
- (struct st_dirty_page *)my_malloc((size_t)nb_dirty_pages *
+ (struct st_dirty_page *)my_malloc(PSI_INSTRUMENT_ME, (size_t)nb_dirty_pages *
sizeof(struct st_dirty_page),
MYF(MY_WME));
if (unlikely(dirty_pages_pool == NULL))
diff --git a/storage/maria/ma_rt_index.c b/storage/maria/ma_rt_index.c
index b2efe298daa..6fddc8955c4 100644
--- a/storage/maria/ma_rt_index.c
+++ b/storage/maria/ma_rt_index.c
@@ -905,7 +905,7 @@ static my_bool maria_rtree_fill_reinsert_list(stPageList *ReinsertList,
if (ReinsertList->n_pages == ReinsertList->m_pages)
{
ReinsertList->m_pages += REINSERT_BUFFER_INC;
- if (!(ReinsertList->pages= (stPageLevel*)my_realloc((uchar*)ReinsertList->pages,
+ if (!(ReinsertList->pages= (stPageLevel*)my_realloc(PSI_INSTRUMENT_ME, (uchar*)ReinsertList->pages,
ReinsertList->m_pages * sizeof(stPageLevel), MYF(MY_ALLOW_ZERO_PTR))))
goto err;
}
diff --git a/storage/maria/ma_sort.c b/storage/maria/ma_sort.c
index 4dc6472bd15..43882c51adc 100644
--- a/storage/maria/ma_sort.c
+++ b/storage/maria/ma_sort.c
@@ -194,11 +194,11 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages,
}
if ((sort_keys= ((uchar**)
- my_malloc((size_t) (keys*(sort_length+sizeof(char*))+
+ my_malloc(PSI_INSTRUMENT_ME, (size_t) (keys*(sort_length+sizeof(char*))+
HA_FT_MAXBYTELEN),
MYF(0)))))
{
- if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer,
+ if (my_init_dynamic_array(&buffpek, PSI_INSTRUMENT_ME, sizeof(BUFFPEK), maxbuffer,
MY_MIN(maxbuffer/2, 1000), MYF(0)))
{
my_free(sort_keys);
@@ -428,11 +428,11 @@ static my_bool _ma_thr_find_all_keys_exec(MARIA_SORT_PARAM* sort_param)
while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org);
}
if ((sort_keys= (uchar **)
- my_malloc((size_t)(keys*(sort_length+sizeof(char*))+
+ my_malloc(PSI_INSTRUMENT_ME, (size_t)(keys*(sort_length+sizeof(char*))+
((sort_param->keyinfo->flag & HA_FULLTEXT) ?
HA_FT_MAXBYTELEN : 0)), MYF(0))))
{
- if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
+ if (my_init_dynamic_array(&sort_param->buffpek, PSI_INSTRUMENT_ME, sizeof(BUFFPEK),
maxbuffer, MY_MIN(maxbuffer / 2, 1000), MYF(0)))
{
my_free(sort_keys);
@@ -628,7 +628,7 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param)
length=(size_t)param->sort_buffer_length;
while (length >= MIN_SORT_MEMORY)
{
- if ((mergebuf= my_malloc((size_t) length, MYF(0))))
+ if ((mergebuf= my_malloc(PSI_INSTRUMENT_ME, (size_t) length, MYF(0))))
break;
length=length*3/4;
}
diff --git a/storage/maria/ma_state.c b/storage/maria/ma_state.c
index 2eff64ec7cd..9bf60c465b5 100644
--- a/storage/maria/ma_state.c
+++ b/storage/maria/ma_state.c
@@ -79,8 +79,8 @@ my_bool _ma_setup_live_state(MARIA_HA *info)
}
/* Table was not used before, create new table state entry */
- if (!(tables= (MARIA_USED_TABLES*) my_malloc(sizeof(*tables),
- MYF(MY_WME | MY_ZEROFILL))))
+ if (!(tables= (MARIA_USED_TABLES*) my_malloc(PSI_INSTRUMENT_ME,
+ sizeof(*tables), MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(1);
tables->next= trn->used_tables;
trn->used_tables= tables;
@@ -495,7 +495,8 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit,
ensures that all history items are stored in the list in
decresing trid order.
*/
- if (!(history= my_malloc(sizeof(*history), MYF(MY_WME))))
+ if (!(history= my_malloc(PSI_INSTRUMENT_ME, sizeof(*history),
+ MYF(MY_WME))))
{
/* purecov: begin inspected */
error= 1;
diff --git a/storage/maria/ma_test2.c b/storage/maria/ma_test2.c
index 7b7b31a7738..d739cc4a7f1 100644
--- a/storage/maria/ma_test2.c
+++ b/storage/maria/ma_test2.c
@@ -1215,7 +1215,7 @@ static void put_blob_in_record(uchar *blob_pos, char **blob_buffer,
if (use_blob)
{
if (! *blob_buffer &&
- !(*blob_buffer=my_malloc((uint) use_blob,MYF(MY_WME))))
+ !(*blob_buffer=my_malloc(PSI_NOT_INSTRUMENTED, (uint) use_blob,MYF(MY_WME))))
{
use_blob= 0;
return;
diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c
index 92d90d5c426..9f8c0771f0b 100644
--- a/storage/maria/ma_write.c
+++ b/storage/maria/ma_write.c
@@ -892,8 +892,9 @@ ChangeSet@1.2562, 2008-04-09 07:41:40+02:00, serg@janus.mylan +9 -0
{
/* Yup. converting */
info->ft1_to_ft2=(DYNAMIC_ARRAY *)
- my_malloc(sizeof(DYNAMIC_ARRAY), MYF(MY_WME));
- my_init_dynamic_array(info->ft1_to_ft2, ft2len, 300, 50, MYF(0));
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(DYNAMIC_ARRAY), MYF(MY_WME));
+ my_init_dynamic_array(info->ft1_to_ft2, PSI_INSTRUMENT_ME, ft2len, 300,
+ 50, MYF(0));
/*
Now, adding all keys from the page to dynarray
@@ -1768,7 +1769,7 @@ int maria_init_bulk_insert(MARIA_HA *info, size_t cache_size, ha_rows rows)
cache_size/=total_keylength*16;
info->bulk_insert=(TREE *)
- my_malloc((sizeof(TREE)*share->base.keys+
+ my_malloc(PSI_INSTRUMENT_ME, (sizeof(TREE)*share->base.keys+
sizeof(bulk_insert_param)*num_keys),MYF(0));
if (!info->bulk_insert)
diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c
index bd62859f66b..25ad7c5c86a 100644
--- a/storage/maria/maria_chk.c
+++ b/storage/maria/maria_chk.c
@@ -1900,8 +1900,8 @@ static int maria_sort_records(HA_CHECK *param,
goto err;
}
- if (!(sort_param.record=
- (uchar*) my_malloc((uint) share->base.default_rec_buff_size, MYF(0))))
+ if (!(sort_param.record= (uchar*) my_malloc(PSI_INSTRUMENT_ME,
+ (uint) share->base.default_rec_buff_size, MYF(0))))
{
_ma_check_print_error(param,"Not enough memory for record");
goto err;
diff --git a/storage/maria/maria_pack.c b/storage/maria/maria_pack.c
index 5bdeca327dd..fd8e6e5818c 100644
--- a/storage/maria/maria_pack.c
+++ b/storage/maria/maria_pack.c
@@ -441,7 +441,7 @@ static my_bool open_maria_files(PACK_MRG_INFO *mrg,char **names,uint count)
uint i,j;
mrg->count=0;
mrg->current=0;
- mrg->file=(MARIA_HA**) my_malloc(sizeof(MARIA_HA*)*count,MYF(MY_FAE));
+ mrg->file=(MARIA_HA**) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(MARIA_HA*)*count,MYF(MY_FAE));
mrg->free_file=1;
mrg->src_file_has_indexes_disabled= 0;
for (i=0; i < count ; i++)
@@ -528,7 +528,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
< 0)
goto err;
length=(uint) share->base.keystart;
- if (!(buff= (uchar*) my_malloc(length,MYF(MY_WME))))
+ if (!(buff= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, length, MYF(MY_WME))))
goto err;
if (my_pread(share->kfile.file, buff, length, 0L, MYF(MY_WME | MY_NABP)) ||
my_write(join_maria_file,buff,length,
@@ -775,9 +775,8 @@ static HUFF_COUNTS *init_huff_count(MARIA_HA *info,my_off_t records)
{
reg2 uint i;
reg1 HUFF_COUNTS *count;
- if ((count = (HUFF_COUNTS*) my_malloc(info->s->base.fields*
- sizeof(HUFF_COUNTS),
- MYF(MY_ZEROFILL | MY_WME))))
+ if ((count = (HUFF_COUNTS*) my_malloc(PSI_NOT_INSTRUMENTED,
+ info->s->base.fields*sizeof(HUFF_COUNTS), MYF(MY_ZEROFILL | MY_WME))))
{
for (i=0 ; i < info->s->base.fields ; i++)
{
@@ -804,7 +803,8 @@ static HUFF_COUNTS *init_huff_count(MARIA_HA *info,my_off_t records)
NULL, MYF(0));
if (records && type != FIELD_BLOB && type != FIELD_VARCHAR)
count[col_nr].tree_pos=count[col_nr].tree_buff =
- my_malloc(count[col_nr].field_length > 1 ? tree_buff_length : 2,
+ my_malloc(PSI_NOT_INSTRUMENTED,
+ count[col_nr].field_length > 1 ? tree_buff_length : 2,
MYF(MY_WME));
}
}
@@ -1448,8 +1448,8 @@ static HUFF_TREE* make_huff_trees(HUFF_COUNTS *huff_counts, uint trees)
HUFF_TREE *huff_tree;
DBUG_ENTER("make_huff_trees");
- if (!(huff_tree=(HUFF_TREE*) my_malloc(trees*sizeof(HUFF_TREE),
- MYF(MY_WME | MY_ZEROFILL))))
+ if (!(huff_tree=(HUFF_TREE*) my_malloc(PSI_NOT_INSTRUMENTED,
+ trees*sizeof(HUFF_TREE), MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(0);
for (tree=0 ; tree < trees ; tree++)
@@ -1526,16 +1526,15 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
if (!huff_tree->element_buffer)
{
if (!(huff_tree->element_buffer=
- (HUFF_ELEMENT*) my_malloc(found*2*sizeof(HUFF_ELEMENT),MYF(MY_WME))))
+ (HUFF_ELEMENT*) my_malloc(PSI_NOT_INSTRUMENTED,
+ found*2*sizeof(HUFF_ELEMENT),MYF(MY_WME))))
return 1;
}
else
{
HUFF_ELEMENT *temp;
- if (!(temp=
- (HUFF_ELEMENT*) my_realloc((uchar*) huff_tree->element_buffer,
- found*2*sizeof(HUFF_ELEMENT),
- MYF(MY_WME))))
+ if (!(temp= (HUFF_ELEMENT*) my_realloc(PSI_NOT_INSTRUMENTED,
+ (uchar*) huff_tree->element_buffer, found*2*sizeof(HUFF_ELEMENT), MYF(MY_WME))))
return 1;
huff_tree->element_buffer=temp;
}
@@ -1901,8 +1900,8 @@ static int make_huff_decode_table(HUFF_TREE *huff_tree, uint trees)
{
elements=huff_tree->counts->tree_buff ? huff_tree->elements : 256;
if (!(huff_tree->code =
- (ulonglong*) my_malloc(elements*
- (sizeof(ulonglong) + sizeof(uchar)),
+ (ulonglong*) my_malloc(PSI_NOT_INSTRUMENTED,
+ elements* (sizeof(ulonglong) + sizeof(uchar)),
MYF(MY_WME | MY_ZEROFILL))))
return 1;
huff_tree->code_len=(uchar*) (huff_tree->code+elements);
@@ -2803,8 +2802,8 @@ static char *make_old_name(char *new_name, char *old_name)
static void init_file_buffer(File file, pbool read_buffer)
{
file_buffer.file=file;
- file_buffer.buffer= (uchar*) my_malloc(ALIGN_SIZE(RECORD_CACHE_SIZE),
- MYF(MY_WME));
+ file_buffer.buffer= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED,
+ ALIGN_SIZE(RECORD_CACHE_SIZE), MYF(MY_WME));
file_buffer.end=file_buffer.buffer+ALIGN_SIZE(RECORD_CACHE_SIZE)-8;
file_buffer.pos_in_file=0;
error_on_write=0;
@@ -2860,7 +2859,8 @@ static int flush_buffer(ulong neaded_length)
{
uchar *tmp;
neaded_length+=256; /* some margin */
- tmp= (uchar*) my_realloc(file_buffer.buffer, neaded_length,MYF(MY_WME));
+ tmp= (uchar*) my_realloc(PSI_NOT_INSTRUMENTED, file_buffer.buffer,
+ neaded_length,MYF(MY_WME));
if (!tmp)
return 1;
file_buffer.pos= (tmp + (ulong) (file_buffer.pos - file_buffer.buffer));
diff --git a/storage/maria/maria_read_log.c b/storage/maria/maria_read_log.c
index f0dc331cf10..ad7aa5ceedc 100644
--- a/storage/maria/maria_read_log.c
+++ b/storage/maria/maria_read_log.c
@@ -318,7 +318,8 @@ get_one_option(const struct my_option *opt,
if (!my_hash_inited(&tables_to_redo))
{
my_hash_init2(&tables_to_redo, 16, &my_charset_bin,
- 16, 0, 0, my_hash_get_string, 0, 0, HASH_UNIQUE);
+ 16, 0, 0, my_hash_get_string, 0, 0, HASH_UNIQUE,
+ PSI_INSTRUMENT_ME);
}
do
{
diff --git a/storage/maria/test_ma_backup.c b/storage/maria/test_ma_backup.c
index 4d0599dfc46..ce43109a38b 100644
--- a/storage/maria/test_ma_backup.c
+++ b/storage/maria/test_ma_backup.c
@@ -113,7 +113,7 @@ static int copy_table(const char *table_name, int stage)
cap.online_backup_safe);
printf("- Copying index file\n");
- copy_buffer= my_malloc(cap.block_size, MYF(0));
+ copy_buffer= my_malloc(PSI_NOT_INSTRUMENTED, cap.block_size, MYF(0));
for (block= 0 ; ; block++)
{
if ((error= aria_read_index(org_file, &cap, block, copy_buffer) ==
diff --git a/storage/maria/trnman.c b/storage/maria/trnman.c
index 6bc83a9ba88..c018205f25e 100644
--- a/storage/maria/trnman.c
+++ b/storage/maria/trnman.c
@@ -149,7 +149,7 @@ int trnman_init(TrID initial_trid)
DBUG_ENTER("trnman_init");
DBUG_PRINT("enter", ("initial_trid: %lu", (ulong) initial_trid));
- short_trid_to_active_trn= (TRN **)my_malloc(SHORT_TRID_MAX*sizeof(TRN*),
+ short_trid_to_active_trn= (TRN **)my_malloc(PSI_INSTRUMENT_ME, SHORT_TRID_MAX*sizeof(TRN*),
MYF(MY_WME|MY_ZEROFILL));
if (unlikely(!short_trid_to_active_trn))
DBUG_RETURN(1);
@@ -312,7 +312,7 @@ TRN *trnman_new_trn(WT_THD *wt)
(Like redo_lns, which is assumed to be 0 at start of row handling
and reset to zero before end of row handling)
*/
- trn= (TRN *)my_malloc(sizeof(TRN), MYF(MY_WME | MY_ZEROFILL));
+ trn= (TRN *)my_malloc(PSI_INSTRUMENT_ME, sizeof(TRN), MYF(MY_WME | MY_ZEROFILL));
if (unlikely(!trn))
{
DBUG_PRINT("info", ("mysql_mutex_unlock LOCK_trn_list"));
@@ -700,8 +700,8 @@ my_bool trnman_collect_transactions(LEX_STRING *str_act, LEX_STRING *str_com,
#endif
LSN_STORE_SIZE /* first_undo_lsn */
) * trnman_committed_transactions;
- if ((NULL == (str_act->str= my_malloc(str_act->length, MYF(MY_WME)))) ||
- (NULL == (str_com->str= my_malloc(str_com->length, MYF(MY_WME)))))
+ if ((NULL == (str_act->str= my_malloc(PSI_INSTRUMENT_ME, str_act->length, MYF(MY_WME)))) ||
+ (NULL == (str_com->str= my_malloc(PSI_INSTRUMENT_ME, str_com->length, MYF(MY_WME)))))
goto err;
/* First, the active transactions */
ptr= str_act->str + 2 + LSN_STORE_SIZE;
diff --git a/storage/maria/unittest/ma_pagecache_single.c b/storage/maria/unittest/ma_pagecache_single.c
index 00e6efad0e6..4cd62c52d86 100644
--- a/storage/maria/unittest/ma_pagecache_single.c
+++ b/storage/maria/unittest/ma_pagecache_single.c
@@ -576,11 +576,11 @@ int simple_delete_flush_test()
int simple_big_test()
{
- unsigned char *buffw= (unsigned char *) my_malloc(TEST_PAGE_SIZE, MYF(MY_WME));
- unsigned char *buffr= (unsigned char *) my_malloc(TEST_PAGE_SIZE, MYF(MY_WME));
+ unsigned char *buffw= (unsigned char *) my_malloc(PSI_NOT_INSTRUMENTED, TEST_PAGE_SIZE, MYF(MY_WME));
+ unsigned char *buffr= (unsigned char *) my_malloc(PSI_NOT_INSTRUMENTED, TEST_PAGE_SIZE, MYF(MY_WME));
struct file_desc *desc= ((struct file_desc *)
- my_malloc((PCACHE_SIZE/(TEST_PAGE_SIZE/2) + 1) *
- sizeof(struct file_desc), MYF(MY_WME)));
+ my_malloc(PSI_NOT_INSTRUMENTED,
+ (PCACHE_SIZE/(TEST_PAGE_SIZE/2) + 1) * sizeof(struct file_desc), MYF(MY_WME)));
int res, i;
DBUG_ENTER("simple_big_test");
diff --git a/storage/maria/unittest/sequence_storage.c b/storage/maria/unittest/sequence_storage.c
index c6c8caefca1..a9719d03a5d 100644
--- a/storage/maria/unittest/sequence_storage.c
+++ b/storage/maria/unittest/sequence_storage.c
@@ -33,7 +33,7 @@ my_bool seq_storage_reader_init(SEQ_STORAGE *seq, const char *file)
seq->pos= 0;
if ((fd= my_fopen(file, O_RDONLY, MYF(MY_WME))) == NULL)
return 1;
- if (my_init_dynamic_array(&seq->seq, sizeof(ulong), 10, 10, MYF(0)))
+ if (my_init_dynamic_array(&seq->seq, PSI_NOT_INSTRUMENTED, sizeof(ulong), 10, 10, MYF(0)))
return 1;
for(;;)
diff --git a/storage/maria/unittest/test_file.c b/storage/maria/unittest/test_file.c
index 354f691aaa9..8c9a5f66a2f 100644
--- a/storage/maria/unittest/test_file.c
+++ b/storage/maria/unittest/test_file.c
@@ -38,7 +38,7 @@
int test_file(PAGECACHE_FILE file, char *file_name,
off_t size, size_t buff_size, struct file_desc *desc)
{
- unsigned char *buffr= my_malloc(buff_size, MYF(0));
+ unsigned char *buffr= my_malloc(PSI_NOT_INSTRUMENTED, buff_size, MYF(0));
off_t pos= 0;
size_t byte;
int step= 0;
diff --git a/storage/maria/unittest/trnman-t.c b/storage/maria/unittest/trnman-t.c
index 00e84cb2456..e16d41b5821 100644
--- a/storage/maria/unittest/trnman-t.c
+++ b/storage/maria/unittest/trnman-t.c
@@ -80,7 +80,7 @@ void run_test(const char *test, pthread_handler handler, int n, int m)
litmus= 0;
- threads= (pthread_t *)my_malloc(sizeof(void *)*n, MYF(0));
+ threads= (pthread_t *)my_malloc(PSI_NOT_INSTRUMENTED, sizeof(void *)*n, MYF(0));
if (!threads)
{
diag("Out of memory");
diff --git a/storage/mroonga/mrn_mysql_compat.h b/storage/mroonga/mrn_mysql_compat.h
index bdb15637e31..a90b1a169e9 100644
--- a/storage/mroonga/mrn_mysql_compat.h
+++ b/storage/mroonga/mrn_mysql_compat.h
@@ -60,19 +60,8 @@
# define KEY_N_KEY_PARTS(key) (key)->key_parts
#endif
-#if defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100213
# define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \
- init_alloc_root(PTR, "mroonga", SZ1, SZ2, FLAG)
-#elif defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100000
-# define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \
- init_alloc_root(PTR, SZ1, SZ2, FLAG)
-#elif MYSQL_VERSION_ID >= 50706
-# define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \
- init_alloc_root(mrn_memory_key, PTR, SZ1, SZ2)
-#else
-# define mrn_init_alloc_root(PTR, SZ1, SZ2, FLAG) \
- init_alloc_root(PTR, SZ1, SZ2)
-#endif
+ init_alloc_root(mrn_memory_key, PTR, SZ1, SZ2, FLAG)
#if MYSQL_VERSION_ID < 100002 || !defined(MRN_MARIADB_P)
# define GTS_TABLE 0
@@ -144,9 +133,7 @@
# define MRN_SEVERITY_WARNING Sql_condition::WARN_LEVEL_WARN
#endif
-#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
-# define MRN_HAVE_PSI_MEMORY_KEY
-#endif
+#define MRN_HAVE_PSI_MEMORY_KEY
#ifdef MRN_HAVE_PSI_MEMORY_KEY
# define mrn_my_malloc(size, flags) \
@@ -240,40 +227,11 @@
((select_lex)->options)
#endif
-#if defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100000
-# if MYSQL_VERSION_ID >= 100213
-# define mrn_init_sql_alloc(thd, mem_root) \
- init_sql_alloc(mem_root, "Mroonga", \
- TABLE_ALLOC_BLOCK_SIZE, \
- 0, \
- MYF(thd->slave_thread ? 0 : MY_THREAD_SPECIFIC))
-#elif MYSQL_VERSION_ID >= 100104
# define mrn_init_sql_alloc(thd, mem_root) \
- init_sql_alloc(mem_root, \
+ init_sql_alloc(mrn_memory_key, mem_root, \
TABLE_ALLOC_BLOCK_SIZE, \
0, \
MYF(thd->slave_thread ? 0 : MY_THREAD_SPECIFIC))
-# else
-# define mrn_init_sql_alloc(thd, mem_root) \
- init_sql_alloc(mem_root, \
- TABLE_ALLOC_BLOCK_SIZE, \
- 0, \
- MYF(0))
-# endif
-#else
-# if MYSQL_VERSION_ID >= 50709
-# define mrn_init_sql_alloc(thd, mem_root) \
- init_sql_alloc(mrn_memory_key, \
- mem_root, \
- TABLE_ALLOC_BLOCK_SIZE, \
- 0)
-# else
-# define mrn_init_sql_alloc(thd, mem_root) \
- init_sql_alloc(mem_root, \
- TABLE_ALLOC_BLOCK_SIZE, \
- 0)
-# endif
-#endif
#ifdef MRN_MARIADB_P
# define MRN_ABORT_ON_WARNING(thd) thd->abort_on_warning
@@ -288,7 +246,6 @@
#define MRN_ERROR_CODE_DATA_TRUNCATE(thd) \
(MRN_ABORT_ON_WARNING(thd) ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED)
-#if MYSQL_VERSION_ID >= 50709 && !defined(MRN_MARIADB_P)
# define mrn_my_hash_init(hash, \
charset, \
default_array_elements, \
@@ -306,24 +263,6 @@
free_element, \
flags, \
mrn_memory_key)
-#else
-# define mrn_my_hash_init(hash, \
- charset, \
- default_array_elements, \
- key_offset, \
- key_length, \
- get_key, \
- free_element, \
- flags) \
- my_hash_init(hash, \
- charset, \
- default_array_elements, \
- key_offset, \
- key_length, \
- get_key, \
- free_element, \
- flags)
-#endif
#if defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100000
# define mrn_strconvert(from_cs, \
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c
index 406a9bbc951..a91467c5b8d 100644
--- a/storage/myisam/ft_boolean_search.c
+++ b/storage/myisam/ft_boolean_search.c
@@ -566,7 +566,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query,
FTB_EXPR *ftbe;
FTB_WORD *ftbw;
- if (!(ftb=(FTB *)my_malloc(sizeof(FTB), MYF(MY_WME))))
+ if (!(ftb=(FTB *)my_malloc(mi_key_memory_FTB, sizeof(FTB), MYF(MY_WME))))
return 0;
ftb->please= (struct _ft_vft *) & _ft_vft_boolean;
ftb->state=UNINITIALIZED;
@@ -579,7 +579,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query,
bzero(& ftb->no_dupes, sizeof(TREE));
ftb->last_word= 0;
- init_alloc_root(&ftb->mem_root, "fulltext", 1024, 1024, MYF(0));
+ init_alloc_root(mi_key_memory_FTB, &ftb->mem_root, 1024, 1024, MYF(0));
ftb->queue.max_elements= 0;
if (!(ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR))))
goto err;
diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c
index 3e433b71761..eb95d1e0b94 100644
--- a/storage/myisam/ft_nlq_search.c
+++ b/storage/myisam/ft_nlq_search.c
@@ -287,7 +287,7 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query,
If ndocs == 0, this will not allocate RAM for FT_INFO.doc[],
so if ndocs == 0, FT_INFO.doc[] must not be accessed.
*/
- dlist=(FT_INFO *)my_malloc(sizeof(FT_INFO)+
+ dlist=(FT_INFO *)my_malloc(mi_key_memory_FT_INFO, sizeof(FT_INFO)+
sizeof(FT_DOC)*
(int)(aio.dtree.elements_in_tree-1),
MYF(0));
diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c
index 9f62250f760..4584dbd4b91 100644
--- a/storage/myisam/ft_parser.c
+++ b/storage/myisam/ft_parser.c
@@ -341,9 +341,10 @@ MYSQL_FTPARSER_PARAM* ftparser_alloc_param(MI_INFO *info)
(ftb_check_phrase_internal, ftb_phrase_add_word). Thus MAX_PARAM_NR=2.
*/
info->ftparser_param= (MYSQL_FTPARSER_PARAM *)
- my_malloc(MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) *
- info->s->ftkeys, MYF(MY_WME | MY_ZEROFILL));
- init_alloc_root(&info->ft_memroot, "fulltext_parser",
+ my_malloc(mi_key_memory_FTPARSER_PARAM,
+ MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) * info->s->ftkeys,
+ MYF(MY_WME | MY_ZEROFILL));
+ init_alloc_root(mi_key_memory_ft_memroot, &info->ft_memroot,
FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(0));
}
return info->ftparser_param;
diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c
index 3422a82a111..34c445cc163 100644
--- a/storage/myisam/ft_stopwords.c
+++ b/storage/myisam/ft_stopwords.c
@@ -59,7 +59,8 @@ int ft_init_stopwords()
DBUG_ENTER("ft_init_stopwords");
if (!stopwords3)
{
- if (!(stopwords3=(TREE *)my_malloc(sizeof(TREE),MYF(0))))
+ if (!(stopwords3=(TREE *)my_malloc(mi_key_memory_ft_stopwords,
+ sizeof(TREE), MYF(0))))
DBUG_RETURN(-1);
init_tree(stopwords3,0,0,sizeof(FT_STOPWORD),(qsort_cmp2)&FT_STOPWORD_cmp,
(ft_stopword_file ? (tree_element_free)&FT_STOPWORD_free : 0),
@@ -89,13 +90,15 @@ int ft_init_stopwords()
DBUG_RETURN(-1);
len=(size_t)my_seek(fd, 0L, MY_SEEK_END, MYF(0));
my_seek(fd, 0L, MY_SEEK_SET, MYF(0));
- if (!(start=buffer=my_malloc(len+1, MYF(MY_WME))))
+ if (!(start= buffer= my_malloc(mi_key_memory_ft_stopwords, len+1,
+ MYF(MY_WME))))
goto err0;
len=my_read(fd, buffer, len, MYF(MY_WME));
end=start+len;
while (ft_simple_get_word(ft_stopword_cs, &start, end, &w, TRUE))
{
- if (ft_add_stopword(my_strndup((char*) w.pos, w.len, MYF(0))))
+ if (ft_add_stopword(my_strndup(mi_key_memory_ft_stopwords,
+ (char*) w.pos, w.len, MYF(0))))
goto err1;
}
error=0;
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 38091dae0ba..1e9aadf038b 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -254,7 +254,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
TABLE_SHARE *share= table_arg->s;
uint options= share->db_options_in_use;
DBUG_ENTER("table2myisam");
- if (!(my_multi_malloc(MYF(MY_WME),
+ if (!(my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
recinfo_out, (share->fields * 2 + 2) * sizeof(MI_COLUMNDEF),
keydef_out, share->keys * sizeof(MI_KEYDEF),
&keyseg,
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index 3f3c60a4249..88c6a4837e4 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -2139,7 +2139,7 @@ int filecopy(HA_CHECK *param, File to,File from,my_off_t start,
DBUG_ENTER("filecopy");
buff_length=(ulong) MY_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
+ if (!(buff=my_malloc(mi_key_memory_filecopy, buff_length, MYF(0))))
{
buff=tmp_buff; buff_length=IO_SIZE;
}
@@ -2294,8 +2294,8 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
mysql_file_seek(param->read_cache.file, 0L, MY_SEEK_END, MYF(0));
sort_param.wordlist=NULL;
- init_alloc_root(&sort_param.wordroot, "sort", FTPARSER_MEMROOT_ALLOC_SIZE, 0,
- MYF(param->malloc_flags));
+ init_alloc_root(mi_key_memory_MI_SORT_PARAM_wordroot, &sort_param.wordroot,
+ FTPARSER_MEMROOT_ALLOC_SIZE, 0, MYF(param->malloc_flags));
if (share->data_file_type == DYNAMIC_RECORD)
length=MY_MAX(share->base.min_pack_length+1,share->base.min_block_length);
@@ -2789,7 +2789,7 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
if (share->options & HA_OPTION_COMPRESS_RECORD)
set_if_bigger(max_pack_reclength, share->max_pack_length);
if (!(sort_param=(MI_SORT_PARAM *)
- my_malloc((uint) share->base.keys *
+ my_malloc(mi_key_memory_MI_SORT_PARAM, (uint) share->base.keys *
(sizeof(MI_SORT_PARAM) + max_pack_reclength),
MYF(MY_ZEROFILL))))
{
@@ -2872,8 +2872,8 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
sort_param[i].keyinfo->seg->charset->mbmaxlen;
sort_param[i].key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
- init_alloc_root(&sort_param[i].wordroot, "sort",
- FTPARSER_MEMROOT_ALLOC_SIZE, 0,
+ init_alloc_root(mi_key_memory_MI_SORT_PARAM_wordroot,
+ &sort_param[i].wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0,
MYF(param->malloc_flags));
}
}
@@ -3717,7 +3717,8 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
MI_DYN_DELETE_BLOCK_HEADER;
if (sort_info->buff_length < reclength)
{
- if (!(sort_info->buff=my_realloc(sort_info->buff, (uint) reclength,
+ if (!(sort_info->buff=my_realloc(mi_key_memory_SORT_INFO_buffer,
+ sort_info->buff, (uint) reclength,
MYF(MY_FREE_ON_ERROR | MY_WME |
MY_ALLOW_ZERO_PTR))))
DBUG_RETURN(1);
@@ -3934,7 +3935,8 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a)
sort_info->info->s->rec_reflength) &&
(sort_info->info->s->options &
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)))
- ft_buf=(SORT_FT_BUF *)my_malloc(sort_param->keyinfo->block_length +
+ ft_buf=(SORT_FT_BUF *)my_malloc(mi_key_memory_SORT_FT_BUF,
+ sort_param->keyinfo->block_length +
sizeof(SORT_FT_BUF), MYF(MY_WME));
if (!ft_buf)
@@ -4205,7 +4207,8 @@ static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks,
SORT_KEY_BLOCKS *block;
DBUG_ENTER("alloc_key_blocks");
- if (!(block=(SORT_KEY_BLOCKS*) my_malloc((sizeof(SORT_KEY_BLOCKS)+
+ if (!(block=(SORT_KEY_BLOCKS*) my_malloc(mi_key_memory_SORT_KEY_BLOCKS,
+ (sizeof(SORT_KEY_BLOCKS)+
buffer_length+IO_SIZE)*blocks,
MYF(0))))
{
diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c
index c91c1af5f60..fcdb4569f4c 100644
--- a/storage/myisam/mi_create.c
+++ b/storage/myisam/mi_create.c
@@ -94,7 +94,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
ci->reloc_rows=ci->max_rows; /* Check if wrong parameter */
if (!(rec_per_key_part=
- (ulong*) my_malloc((keys + uniques)*HA_MAX_KEY_SEG*sizeof(long),
+ (ulong*) my_malloc(mi_key_memory_MYISAM_SHARE,
+ (keys + uniques) * HA_MAX_KEY_SEG * sizeof(long),
MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(my_errno);
diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c
index 69c13ab96cf..09c10040f9c 100644
--- a/storage/myisam/mi_dynrec.c
+++ b/storage/myisam/mi_dynrec.c
@@ -43,7 +43,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
/* Play it safe; We have a small stack when using threads */
#undef my_alloca
#undef my_afree
-#define my_alloca(A) my_malloc((A),MYF(0))
+#define my_alloca(A) my_malloc(PSI_NOT_INSTRUMENTED, (A),MYF(0))
#define my_afree(A) my_free((A))
/* Interface function from MI_INFO */
diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c
index 4d3c227dcc3..cca2afa0b03 100644
--- a/storage/myisam/mi_open.c
+++ b/storage/myisam/mi_open.c
@@ -310,7 +310,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
/* Add space for node pointer */
share->base.max_key_length+= share->base.key_reflength;
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(mi_key_memory_MYISAM_SHARE, MYF(MY_WME),
&share,sizeof(*share),
&share->state.rec_per_key_part,
sizeof(long)*base_key_parts,
@@ -599,7 +599,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
}
/* alloc and set up private structure parts */
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(mi_key_memory_MI_INFO, MYF(MY_WME),
&m_info,sizeof(MI_INFO),
&info.blobs,sizeof(MI_BLOB)*share->base.blobs,
&info.buff,(share->base.max_key_block_length*2+
@@ -759,7 +759,8 @@ uchar *mi_alloc_rec_buff(MI_INFO *info, ulong length, uchar **buf)
MI_REC_BUFF_OFFSET : 0);
if (extra && newptr)
newptr-= MI_REC_BUFF_OFFSET;
- if (!(newptr=(uchar*) my_realloc((uchar*)newptr, length+extra+8,
+ if (!(newptr=(uchar*) my_realloc(mi_key_memory_record_buffer,
+ (uchar*)newptr, length + extra + 8,
MYF(MY_ALLOW_ZERO_PTR))))
return NULL;
*((uint32 *) newptr)= (uint32) length;
@@ -1004,7 +1005,7 @@ uchar *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state)
if (!state->rec_per_key_part)
{
- if (!my_multi_malloc(MY_WME,
+ if (!my_multi_malloc(mi_key_memory_MYISAM_SHARE, MYF(MY_WME),
&state->rec_per_key_part,sizeof(long)*key_parts,
&state->key_root, keys*sizeof(my_off_t),
&state->key_del, key_blocks*sizeof(my_off_t),
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index b28eaf21090..637b1e69bfd 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -195,8 +195,8 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
- Distinct column values
*/
if (!(share->decode_trees=(MI_DECODE_TREE*)
- my_malloc((uint) (trees*sizeof(MI_DECODE_TREE)+
- intervall_length*sizeof(uchar)),
+ my_malloc(mi_key_memory_MI_DECODE_TREE,
+ trees*sizeof(MI_DECODE_TREE) + intervall_length*sizeof(uchar),
MYF(MY_WME))))
goto err0;
intervall_buff=(uchar*) (share->decode_trees+trees);
@@ -218,7 +218,8 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
data, we add (BITS_SAVED / 8) - 1 bytes to the buffer size.
*/
if (!(share->decode_tables=(uint16*)
- my_malloc((length + OFFSET_TABLE_SIZE) * sizeof(uint16) +
+ my_malloc(mi_key_memory_MYISAM_SHARE_decode_tables,
+ (length + OFFSET_TABLE_SIZE) * sizeof(uint16) +
(uint) (share->pack.header_length - sizeof(header) +
(BITS_SAVED / 8) - 1), MYF(MY_WME | MY_ZEROFILL))))
goto err1;
@@ -258,9 +259,10 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
goto err3;
/* Reallocate the decoding tables to the used size. */
decode_table=(uint16*)
- my_realloc((uchar*) share->decode_tables,
+ my_realloc(mi_key_memory_MYISAM_SHARE_decode_tables,
+ (uchar*) share->decode_tables,
(uint) ((uchar*) decode_table - (uchar*) share->decode_tables),
- MYF(MY_HOLD_ON_ERROR));
+ MYF(0));
/* Fix the table addresses in the tree heads. */
{
my_ptrdiff_t diff=PTR_BYTE_DIFF(decode_table,share->decode_tables);
diff --git a/storage/myisam/mi_preload.c b/storage/myisam/mi_preload.c
index d52a2ea46ea..5f9132abe14 100644
--- a/storage/myisam/mi_preload.c
+++ b/storage/myisam/mi_preload.c
@@ -73,7 +73,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
length= info->preload_buff_size/block_length * block_length;
set_if_bigger(length, block_length);
- if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME))))
+ if (!(buff= (uchar *) my_malloc(mi_key_memory_preload_buffer, length,
+ MYF(MY_WME))))
DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM);
if (flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map,
diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c
index 3679ea4a329..d0c3995d9de 100644
--- a/storage/myisam/mi_static.c
+++ b/storage/myisam/mi_static.c
@@ -61,6 +61,28 @@ uint myisam_readnext_vec[]=
SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_SMALLER
};
+PSI_memory_key mi_key_memory_MYISAM_SHARE;
+PSI_memory_key mi_key_memory_MI_INFO;
+PSI_memory_key mi_key_memory_MI_INFO_ft1_to_ft2;
+PSI_memory_key mi_key_memory_MI_INFO_bulk_insert;
+PSI_memory_key mi_key_memory_record_buffer;
+PSI_memory_key mi_key_memory_FTB;
+PSI_memory_key mi_key_memory_FT_INFO;
+PSI_memory_key mi_key_memory_FTPARSER_PARAM;
+PSI_memory_key mi_key_memory_ft_memroot;
+PSI_memory_key mi_key_memory_ft_stopwords;
+PSI_memory_key mi_key_memory_MI_SORT_PARAM;
+PSI_memory_key mi_key_memory_MI_SORT_PARAM_wordroot;
+PSI_memory_key mi_key_memory_SORT_FT_BUF;
+PSI_memory_key mi_key_memory_SORT_KEY_BLOCKS;
+PSI_memory_key mi_key_memory_filecopy;
+PSI_memory_key mi_key_memory_SORT_INFO_buffer;
+PSI_memory_key mi_key_memory_MI_DECODE_TREE;
+PSI_memory_key mi_key_memory_MYISAM_SHARE_decode_tables;
+PSI_memory_key mi_key_memory_preload_buffer;
+PSI_memory_key mi_key_memory_stPageList_pages;
+PSI_memory_key mi_key_memory_keycache_thread_var;
+
#ifdef HAVE_PSI_INTERFACE
PSI_mutex_key mi_key_mutex_MYISAM_SHARE_intern_lock,
mi_key_mutex_MI_SORT_INFO_mutex, mi_key_mutex_MI_CHECK_print_msg;
@@ -106,6 +128,31 @@ static PSI_thread_info all_myisam_threads[]=
{ &mi_key_thread_find_all_keys, "find_all_keys", 0},
};
+static PSI_memory_info all_myisam_memory[]=
+{
+ { &mi_key_memory_MYISAM_SHARE, "MYISAM_SHARE", 0},
+ { &mi_key_memory_MI_INFO, "MI_INFO", 0},
+ { &mi_key_memory_MI_INFO_ft1_to_ft2, "MI_INFO::ft1_to_ft2", 0},
+ { &mi_key_memory_MI_INFO_bulk_insert, "MI_INFO::bulk_insert", 0},
+ { &mi_key_memory_record_buffer, "record_buffer", 0},
+ { &mi_key_memory_FTB, "FTB", 0},
+ { &mi_key_memory_FT_INFO, "FT_INFO", 0},
+ { &mi_key_memory_FTPARSER_PARAM, "FTPARSER_PARAM", 0},
+ { &mi_key_memory_ft_memroot, "ft_memroot", 0},
+ { &mi_key_memory_ft_stopwords, "ft_stopwords", 0},
+ { &mi_key_memory_MI_SORT_PARAM, "MI_SORT_PARAM", 0},
+ { &mi_key_memory_MI_SORT_PARAM_wordroot, "MI_SORT_PARAM::wordroot", 0},
+ { &mi_key_memory_SORT_FT_BUF, "SORT_FT_BUF", 0},
+ { &mi_key_memory_SORT_KEY_BLOCKS, "SORT_KEY_BLOCKS", 0},
+ { &mi_key_memory_filecopy, "filecopy", 0},
+ { &mi_key_memory_SORT_INFO_buffer, "SORT_INFO::buffer", 0},
+ { &mi_key_memory_MI_DECODE_TREE, "MI_DECODE_TREE", 0},
+ { &mi_key_memory_MYISAM_SHARE_decode_tables, "MYISAM_SHARE::decode_tables", 0},
+ { &mi_key_memory_preload_buffer, "preload_buffer", 0},
+ { &mi_key_memory_stPageList_pages, "stPageList::pages", 0},
+ { &mi_key_memory_keycache_thread_var, "keycache_thread_var", 0}
+};
+
void init_myisam_psi_keys()
{
const char* category= "myisam";
@@ -125,6 +172,9 @@ void init_myisam_psi_keys()
count= array_elements(all_myisam_threads);
mysql_thread_register(category, all_myisam_threads, count);
+
+ count= array_elements(all_myisam_memory);
+ mysql_memory_register(category, all_myisam_memory, count);
}
#endif /* HAVE_PSI_INTERFACE */
diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c
index 48a091e80de..5a66e958139 100644
--- a/storage/myisam/mi_test2.c
+++ b/storage/myisam/mi_test2.c
@@ -1021,7 +1021,7 @@ static void put_blob_in_record(uchar *blob_pos, char **blob_buffer)
if (rnd(10) == 0)
{
if (! *blob_buffer &&
- !(*blob_buffer=my_malloc((uint) use_blob,MYF(MY_WME))))
+ !(*blob_buffer=my_malloc(PSI_NOT_INSTRUMENTED, use_blob,MYF(MY_WME))))
{
use_blob=0;
return;
diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c
index 7345ab1604d..512a2a11bf2 100644
--- a/storage/myisam/mi_write.c
+++ b/storage/myisam/mi_write.c
@@ -546,8 +546,10 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo,
{
/* yup. converting */
info->ft1_to_ft2=(DYNAMIC_ARRAY *)
- my_malloc(sizeof(DYNAMIC_ARRAY), MYF(MY_WME));
- my_init_dynamic_array(info->ft1_to_ft2, ft2len, 300, 50, MYF(0));
+ my_malloc(mi_key_memory_MI_INFO_ft1_to_ft2,
+ sizeof(DYNAMIC_ARRAY), MYF(MY_WME));
+ my_init_dynamic_array(info->ft1_to_ft2, mi_key_memory_MI_INFO_ft1_to_ft2,
+ ft2len, 300, 50, MYF(0));
/*
now, adding all keys from the page to dynarray
@@ -998,7 +1000,8 @@ int mi_init_bulk_insert(MI_INFO *info, size_t cache_size, ha_rows rows)
cache_size/=total_keylength*16;
info->bulk_insert=(TREE *)
- my_malloc((sizeof(TREE)*share->base.keys+
+ my_malloc(mi_key_memory_MI_INFO_bulk_insert,
+ (sizeof(TREE)*share->base.keys+
sizeof(bulk_insert_param)*num_keys),MYF(0));
if (!info->bulk_insert)
diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h
index b92c012e5f4..c5975f42315 100644
--- a/storage/myisam/myisamdef.h
+++ b/storage/myisam/myisamdef.h
@@ -777,4 +777,26 @@ extern PSI_thread_key mi_key_thread_find_all_keys;
void init_myisam_psi_keys();
#endif /* HAVE_PSI_INTERFACE */
+extern PSI_memory_key mi_key_memory_MYISAM_SHARE;
+extern PSI_memory_key mi_key_memory_MI_INFO;
+extern PSI_memory_key mi_key_memory_MI_INFO_ft1_to_ft2;
+extern PSI_memory_key mi_key_memory_MI_INFO_bulk_insert;
+extern PSI_memory_key mi_key_memory_record_buffer;
+extern PSI_memory_key mi_key_memory_FTB;
+extern PSI_memory_key mi_key_memory_FT_INFO;
+extern PSI_memory_key mi_key_memory_FTPARSER_PARAM;
+extern PSI_memory_key mi_key_memory_ft_memroot;
+extern PSI_memory_key mi_key_memory_ft_stopwords;
+extern PSI_memory_key mi_key_memory_MI_SORT_PARAM;
+extern PSI_memory_key mi_key_memory_MI_SORT_PARAM_wordroot;
+extern PSI_memory_key mi_key_memory_SORT_FT_BUF;
+extern PSI_memory_key mi_key_memory_SORT_KEY_BLOCKS;
+extern PSI_memory_key mi_key_memory_filecopy;
+extern PSI_memory_key mi_key_memory_SORT_INFO_buffer;
+extern PSI_memory_key mi_key_memory_MI_DECODE_TREE;
+extern PSI_memory_key mi_key_memory_MYISAM_SHARE_decode_tables;
+extern PSI_memory_key mi_key_memory_preload_buffer;
+extern PSI_memory_key mi_key_memory_stPageList_pages;
+extern PSI_memory_key mi_key_memory_keycache_thread_var;
+
C_MODE_END
diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c
index 9bef2be929f..40d473dc532 100644
--- a/storage/myisam/myisamlog.c
+++ b/storage/myisam/myisamlog.c
@@ -422,7 +422,7 @@ static int examine_log(char * file_name, char **table_names)
* The additional space is needed for the sprintf commands two lines
* below.
*/
- file_info.show_name=my_memdup(isam_file_name,
+ file_info.show_name=my_memdup(PSI_NOT_INSTRUMENTED, isam_file_name,
(uint) strlen(isam_file_name)+10,
MYF(MY_WME));
if (file_info.id > 1)
@@ -451,8 +451,8 @@ static int examine_log(char * file_name, char **table_names)
if (!(file_info.isam= mi_open(isam_file_name,O_RDWR,
HA_OPEN_WAIT_IF_LOCKED)))
goto com_err;
- if (!(file_info.record=my_malloc(file_info.isam->s->base.reclength,
- MYF(MY_WME))))
+ if (!(file_info.record=my_malloc(PSI_NOT_INSTRUMENTED,
+ file_info.isam->s->base.reclength, MYF(MY_WME))))
goto end;
files_open++;
file_info.closed=0;
@@ -683,7 +683,7 @@ static int read_string(IO_CACHE *file, register uchar* *to, register uint length
if (*to)
my_free(*to);
- if (!(*to= (uchar*) my_malloc(length+1,MYF(MY_WME))) ||
+ if (!(*to= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, length+1,MYF(MY_WME))) ||
my_b_read(file,(uchar*) *to,length))
{
if (*to)
diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c
index b2a2909ad73..1267ddc724d 100644
--- a/storage/myisam/myisampack.c
+++ b/storage/myisam/myisampack.c
@@ -439,7 +439,7 @@ static my_bool open_isam_files(PACK_MRG_INFO *mrg, char **names, uint count)
uint i,j;
mrg->count=0;
mrg->current=0;
- mrg->file=(MI_INFO**) my_malloc(sizeof(MI_INFO*)*count,MYF(MY_FAE));
+ mrg->file=(MI_INFO**) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(MI_INFO*)*count,MYF(MY_FAE));
mrg->free_file=1;
mrg->src_file_has_indexes_disabled= 0;
for (i=0; i < count ; i++)
@@ -518,7 +518,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
< 0)
goto err;
length=(uint) share->base.keystart;
- if (!(buff= (uchar*) my_malloc(length,MYF(MY_WME))))
+ if (!(buff= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, length,MYF(MY_WME))))
goto err;
if (my_pread(share->kfile,buff,length,0L,MYF(MY_WME | MY_NABP)) ||
my_write(join_isam_file,buff,length,
@@ -798,7 +798,7 @@ static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records)
{
reg2 uint i;
reg1 HUFF_COUNTS *count;
- if ((count = (HUFF_COUNTS*) my_malloc(info->s->base.fields*
+ if ((count = (HUFF_COUNTS*) my_malloc(PSI_NOT_INSTRUMENTED, info->s->base.fields*
sizeof(HUFF_COUNTS),
MYF(MY_ZEROFILL | MY_WME))))
{
@@ -825,7 +825,7 @@ static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records)
NULL, MYF(0));
if (records && type != FIELD_BLOB && type != FIELD_VARCHAR)
count[i].tree_pos=count[i].tree_buff =
- my_malloc(count[i].field_length > 1 ? tree_buff_length : 2,
+ my_malloc(PSI_NOT_INSTRUMENTED, count[i].field_length > 1 ? tree_buff_length : 2,
MYF(MY_WME));
}
}
@@ -1476,7 +1476,7 @@ static HUFF_TREE* make_huff_trees(HUFF_COUNTS *huff_counts, uint trees)
HUFF_TREE *huff_tree;
DBUG_ENTER("make_huff_trees");
- if (!(huff_tree=(HUFF_TREE*) my_malloc(trees*sizeof(HUFF_TREE),
+ if (!(huff_tree=(HUFF_TREE*) my_malloc(PSI_NOT_INSTRUMENTED, trees*sizeof(HUFF_TREE),
MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(0);
@@ -1554,14 +1554,14 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
if (!huff_tree->element_buffer)
{
if (!(huff_tree->element_buffer=
- (HUFF_ELEMENT*) my_malloc(found*2*sizeof(HUFF_ELEMENT),MYF(MY_WME))))
+ (HUFF_ELEMENT*) my_malloc(PSI_NOT_INSTRUMENTED, found*2*sizeof(HUFF_ELEMENT),MYF(MY_WME))))
return 1;
}
else
{
HUFF_ELEMENT *temp;
if (!(temp=
- (HUFF_ELEMENT*) my_realloc((uchar*) huff_tree->element_buffer,
+ (HUFF_ELEMENT*) my_realloc(PSI_NOT_INSTRUMENTED, (uchar*) huff_tree->element_buffer,
found*2*sizeof(HUFF_ELEMENT),
MYF(MY_WME))))
return 1;
@@ -1930,7 +1930,7 @@ static int make_huff_decode_table(HUFF_TREE *huff_tree, uint trees)
{
elements=huff_tree->counts->tree_buff ? huff_tree->elements : 256;
if (!(huff_tree->code =
- (ulonglong*) my_malloc(elements*
+ (ulonglong*) my_malloc(PSI_NOT_INSTRUMENTED, elements*
(sizeof(ulonglong) + sizeof(uchar)),
MYF(MY_WME | MY_ZEROFILL))))
return 1;
@@ -2823,7 +2823,7 @@ static char *make_old_name(char *new_name, char *old_name)
static void init_file_buffer(File file, pbool read_buffer)
{
file_buffer.file=file;
- file_buffer.buffer= (uchar*) my_malloc(ALIGN_SIZE(RECORD_CACHE_SIZE),
+ file_buffer.buffer= (uchar*) my_malloc(PSI_NOT_INSTRUMENTED, ALIGN_SIZE(RECORD_CACHE_SIZE),
MYF(MY_WME));
file_buffer.end=file_buffer.buffer+ALIGN_SIZE(RECORD_CACHE_SIZE)-8;
file_buffer.pos_in_file=0;
@@ -2880,7 +2880,7 @@ static int flush_buffer(ulong neaded_length)
{
char *tmp;
neaded_length+=256; /* some margin */
- tmp= my_realloc((char*) file_buffer.buffer, neaded_length,MYF(MY_WME));
+ tmp= my_realloc(PSI_NOT_INSTRUMENTED, (char*) file_buffer.buffer, neaded_length,MYF(MY_WME));
if (!tmp)
return 1;
file_buffer.pos= ((uchar*) tmp +
diff --git a/storage/myisam/rt_index.c b/storage/myisam/rt_index.c
index 08543ec2b22..651e2e79478 100644
--- a/storage/myisam/rt_index.c
+++ b/storage/myisam/rt_index.c
@@ -733,8 +733,11 @@ static int rtree_fill_reinsert_list(stPageList *ReinsertList, my_off_t page,
if (ReinsertList->n_pages == ReinsertList->m_pages)
{
ReinsertList->m_pages += REINSERT_BUFFER_INC;
- if (!(ReinsertList->pages = (stPageLevel*)my_realloc((uchar*)ReinsertList->pages,
- ReinsertList->m_pages * sizeof(stPageLevel), MYF(MY_ALLOW_ZERO_PTR))))
+ if (!(ReinsertList->pages = (stPageLevel*)
+ my_realloc(mi_key_memory_stPageList_pages,
+ (uchar*)ReinsertList->pages,
+ ReinsertList->m_pages * sizeof(stPageLevel),
+ MYF(MY_ALLOW_ZERO_PTR))))
goto err1;
}
/* save page to ReinsertList */
diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c
index e586543363b..910867b13a8 100644
--- a/storage/myisam/sort.c
+++ b/storage/myisam/sort.c
@@ -190,10 +190,12 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
}
if ((sort_keys= ((uchar **)
- my_malloc((size_t) (keys*(sort_length+sizeof(char*))+
+ my_malloc(PSI_INSTRUMENT_ME,
+ (size_t) (keys*(sort_length+sizeof(char*))+
HA_FT_MAXBYTELEN), MYF(0)))))
{
- if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer,
+ if (my_init_dynamic_array(&buffpek, PSI_INSTRUMENT_ME,
+ sizeof(BUFFPEK), maxbuffer,
MY_MIN(maxbuffer/2, 1000), MYF(0)))
{
my_free(sort_keys);
@@ -406,12 +408,14 @@ static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param)
}
while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org);
}
- if ((sort_keys= (uchar**) my_malloc((size_t)(keys * (sort_length + sizeof(char*)) +
+ if ((sort_keys= (uchar**) my_malloc(PSI_INSTRUMENT_ME,
+ (size_t)(keys * (sort_length + sizeof(char*)) +
((sort_param->keyinfo->flag & HA_FULLTEXT) ?
HA_FT_MAXBYTELEN : 0)), MYF(0))))
{
- if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
- maxbuffer, MY_MIN(maxbuffer / 2, 1000), MYF(0)))
+ if (my_init_dynamic_array(&sort_param->buffpek, PSI_INSTRUMENT_ME,
+ sizeof(BUFFPEK), maxbuffer,
+ MY_MIN(maxbuffer / 2, 1000), MYF(0)))
{
my_free(sort_keys);
sort_keys= NULL; /* Safety against double free on error. */
@@ -607,7 +611,8 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
length=param->sort_buffer_length;
while (length >= MIN_SORT_BUFFER)
{
- if ((mergebuf= my_malloc((size_t) length, MYF(0))))
+ if ((mergebuf= my_malloc(PSI_INSTRUMENT_ME,
+ (size_t) length, MYF(0))))
break;
length=length*3/4;
}
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 14036a31b8c..4fd63020c6a 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -120,7 +120,7 @@ static handler *myisammrg_create_handler(handlerton *hton,
ha_myisammrg::ha_myisammrg(handlerton *hton, TABLE_SHARE *table_arg)
:handler(hton, table_arg), file(0), is_cloned(0)
{
- init_sql_alloc(&children_mem_root, "ha_myisammrg",
+ init_sql_alloc(rg_key_memory_children, &children_mem_root,
FN_REFLEN + ALLOC_ROOT_MIN_BLOCK_SIZE, 0, MYF(0));
}
diff --git a/storage/myisammrg/myrg_def.h b/storage/myisammrg/myrg_def.h
index 9ef65f220be..8bb79a73127 100644
--- a/storage/myisammrg/myrg_def.h
+++ b/storage/myisammrg/myrg_def.h
@@ -32,12 +32,13 @@ extern "C"
#endif
void myrg_print_wrong_table(const char *table_name);
-#ifdef HAVE_PSI_INTERFACE
+/* Always defined */
+extern PSI_memory_key rg_key_memory_MYRG_INFO;
C_MODE_START
extern PSI_mutex_key rg_key_mutex_MYRG_INFO_mutex;
+extern PSI_memory_key rg_key_memory_children;
extern PSI_file_key rg_key_file_MRG;
void init_myisammrg_psi_keys();
C_MODE_END
-#endif /* HAVE_PSI_INTERFACE */
diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c
index 06c71dec14a..e19ce8f7cf3 100644
--- a/storage/myisammrg/myrg_open.c
+++ b/storage/myisammrg/myrg_open.c
@@ -108,7 +108,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
if (!m_info) /* First file */
{
key_parts=isam->s->base.key_parts;
- if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO) +
+ if (!(m_info= (MYRG_INFO*) my_malloc(rg_key_memory_MYRG_INFO,
+ sizeof(MYRG_INFO) +
files*sizeof(MYRG_TABLE) +
key_parts*sizeof(long),
MYF(MY_WME|MY_ZEROFILL))))
@@ -149,7 +150,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
if (bad_children)
goto bad_children;
- if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO),
+ if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(rg_key_memory_MYRG_INFO,
+ sizeof(MYRG_INFO),
MYF(MY_WME | MY_ZEROFILL))))
goto err;
/* Don't mark table readonly, for ALTER TABLE ... UNION=(...) to work */
@@ -285,7 +287,8 @@ MYRG_INFO *myrg_parent_open(const char *parent_name,
}
/* Allocate MERGE parent table structure. */
- if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO) +
+ if (!(m_info= (MYRG_INFO*) my_malloc(rg_key_memory_MYRG_INFO,
+ sizeof(MYRG_INFO) +
child_count * sizeof(MYRG_TABLE),
MYF(MY_WME | MY_ZEROFILL))))
goto err; /* purecov: inspected */
@@ -435,7 +438,8 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
if (!m_info->rec_per_key_part)
{
if(!(m_info->rec_per_key_part= (ulong*)
- my_malloc(key_parts * sizeof(long), MYF(MY_WME))))
+ my_malloc(rg_key_memory_MYRG_INFO,
+ key_parts * sizeof(long), MYF(MY_WME))))
goto err; /* purecov: inspected */
errpos= 1;
}
diff --git a/storage/myisammrg/myrg_static.c b/storage/myisammrg/myrg_static.c
index a2f5d074c9e..36ec25cb7d9 100644
--- a/storage/myisammrg/myrg_static.c
+++ b/storage/myisammrg/myrg_static.c
@@ -29,6 +29,9 @@ static const char *merge_insert_methods[] =
TYPELIB merge_insert_method= { array_elements(merge_insert_methods)-1,"",
merge_insert_methods, 0};
+PSI_memory_key rg_key_memory_MYRG_INFO;
+PSI_memory_key rg_key_memory_children;
+
#ifdef HAVE_PSI_INTERFACE
PSI_mutex_key rg_key_mutex_MYRG_INFO_mutex;
@@ -44,6 +47,12 @@ static PSI_file_info all_myisammrg_files[]=
{ &rg_key_file_MRG, "MRG", 0}
};
+static PSI_memory_info all_myisammrg_memory[]=
+{
+ { &rg_key_memory_MYRG_INFO, "MYRG_INFO", 0},
+ { &rg_key_memory_children, "children", 0}
+};
+
void init_myisammrg_psi_keys()
{
const char* category= "myisammrg";
@@ -54,6 +63,9 @@ void init_myisammrg_psi_keys()
count= array_elements(all_myisammrg_files);
mysql_file_register(category, all_myisammrg_files, count);
+
+ count= array_elements(all_myisammrg_memory);
+ mysql_memory_register(category, all_myisammrg_memory, count);
}
#endif /* HAVE_PSI_INTERFACE */
diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc
index 20ebd49bd5d..1857b66fdfd 100644
--- a/storage/oqgraph/ha_oqgraph.cc
+++ b/storage/oqgraph/ha_oqgraph.cc
@@ -562,7 +562,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
init_tmp_table_share( thd, share, table->s->db.str, table->s->db.length, options->table_name, "");
// because of that, we need to reinitialize the memroot (to reset MY_THREAD_SPECIFIC flag)
DBUG_ASSERT(share->mem_root.used == NULL); // it's still empty
- init_sql_alloc(&share->mem_root, "share", TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0));
+ init_sql_alloc(PSI_INSTRUMENT_ME, &share->mem_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0));
// What I think this code is doing:
// * Our OQGRAPH table is `database_blah/name`
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index 8488f9ee963..625624d228e 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -5970,6 +5970,7 @@ Rdb_table_handler *Rdb_open_tables_map::get_table_handler(
// Since we did not find it in the hash map, attempt to create and add it
// to the hash map.
if (!(table_handler = reinterpret_cast<Rdb_table_handler *>(my_multi_malloc(
+ PSI_INSTRUMENT_ME,
MYF(MY_WME | MY_ZEROFILL), &table_handler, sizeof(*table_handler),
&tmp_name, table_name_str.length() + 1, NullS)))) {
// Allocating a new Rdb_table_handler and a new table name failed.
@@ -6550,11 +6551,11 @@ int ha_rocksdb::alloc_key_buffers(const TABLE *const table_arg,
// move this into get_table_handler() ??
m_pk_descr->setup(table_arg, tbl_def_arg);
- m_pk_tuple = reinterpret_cast<uchar *>(my_malloc(key_len, MYF(0)));
+ m_pk_tuple = reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, key_len, MYF(0)));
pack_key_len = m_pk_descr->max_storage_fmt_length();
m_pk_packed_tuple =
- reinterpret_cast<uchar *>(my_malloc(pack_key_len, MYF(0)));
+ reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, pack_key_len, MYF(0)));
/* Sometimes, we may use m_sk_packed_tuple for storing packed PK */
max_packed_sk_len = pack_key_len;
@@ -6572,20 +6573,20 @@ int ha_rocksdb::alloc_key_buffers(const TABLE *const table_arg,
}
m_sk_packed_tuple =
- reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0)));
+ reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0)));
m_sk_match_prefix_buf =
- reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0)));
+ reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0)));
m_sk_packed_tuple_old =
- reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0)));
+ reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0)));
m_end_key_packed_tuple =
- reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0)));
+ reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0)));
m_pack_buffer =
- reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0)));
+ reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0)));
m_scan_it_lower_bound =
- reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0)));
+ reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0)));
m_scan_it_upper_bound =
- reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0)));
+ reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0)));
/*
If inplace alter is happening, allocate special buffers for unique
@@ -6593,9 +6594,9 @@ int ha_rocksdb::alloc_key_buffers(const TABLE *const table_arg,
*/
if (alloc_alter_buffers) {
m_dup_sk_packed_tuple =
- reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0)));
+ reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0)));
m_dup_sk_packed_tuple_old =
- reinterpret_cast<uchar *>(my_malloc(max_packed_sk_len, MYF(0)));
+ reinterpret_cast<uchar *>(my_malloc(PSI_INSTRUMENT_ME, max_packed_sk_len, MYF(0)));
}
if (m_pk_tuple == nullptr || m_pk_packed_tuple == nullptr ||
@@ -14131,7 +14132,7 @@ void rocksdb_set_collation_exception_list(THD *const thd,
rdb_set_collation_exception_list(val == nullptr ? "" : val);
//psergey-todo: what is the purpose of the below??
- const char *val_copy= val? my_strdup(val, MYF(0)): nullptr;
+ const char *val_copy= val? my_strdup(PSI_INSTRUMENT_ME, val, MYF(0)): nullptr;
my_free(*static_cast<char**>(var_ptr));
*static_cast<const char**>(var_ptr) = val_copy;
}
@@ -14344,7 +14345,7 @@ static int rocksdb_validate_update_cf_options(
// This can cause invalid memory access after validation is finished.
// To avoid this kind case, let's alway duplicate the str if str is not
// nullptr
- *(const char **)save = (str == nullptr) ? nullptr : my_strdup(str, MYF(0));
+ *(const char **)save = (str == nullptr) ? nullptr : my_strdup(PSI_INSTRUMENT_ME, str, MYF(0));
if (str == nullptr) {
return HA_EXIT_SUCCESS;
diff --git a/storage/rocksdb/rdb_converter.cc b/storage/rocksdb/rdb_converter.cc
index 677ff106753..e799d67f813 100644
--- a/storage/rocksdb/rdb_converter.cc
+++ b/storage/rocksdb/rdb_converter.cc
@@ -436,7 +436,7 @@ void Rdb_converter::setup_field_encoders() {
uchar cur_null_mask = 0x1;
m_encoder_arr = static_cast<Rdb_field_encoder *>(
- my_malloc(m_table->s->fields * sizeof(Rdb_field_encoder), MYF(0)));
+ my_malloc(PSI_INSTRUMENT_ME, m_table->s->fields * sizeof(Rdb_field_encoder), MYF(0)));
if (m_encoder_arr == nullptr) {
return;
}
diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc
index 00e6b95a748..3673a67bf22 100644
--- a/storage/rocksdb/rdb_datadic.cc
+++ b/storage/rocksdb/rdb_datadic.cc
@@ -368,14 +368,14 @@ Rdb_key_def::Rdb_key_def(const Rdb_key_def &k)
m_total_index_flags_length == 0);
if (k.m_pack_info) {
const size_t size = sizeof(Rdb_field_packing) * k.m_key_parts;
- void *pack_info= my_malloc(size, MYF(0));
+ void *pack_info= my_malloc(PSI_INSTRUMENT_ME, size, MYF(0));
memcpy(pack_info, k.m_pack_info, size);
m_pack_info = reinterpret_cast<Rdb_field_packing *>(pack_info);
}
if (k.m_pk_part_no) {
const size_t size = sizeof(uint) * m_key_parts;
- m_pk_part_no = reinterpret_cast<uint *>(my_malloc(size, MYF(0)));
+ m_pk_part_no = reinterpret_cast<uint *>(my_malloc(PSI_INSTRUMENT_ME, size, MYF(0)));
memcpy(m_pk_part_no, k.m_pk_part_no, size);
}
}
@@ -449,14 +449,14 @@ void Rdb_key_def::setup(const TABLE *const tbl,
if (secondary_key) {
m_pk_part_no = reinterpret_cast<uint *>(
- my_malloc(sizeof(uint) * m_key_parts, MYF(0)));
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(uint) * m_key_parts, MYF(0)));
} else {
m_pk_part_no = nullptr;
}
const size_t size = sizeof(Rdb_field_packing) * m_key_parts;
m_pack_info =
- reinterpret_cast<Rdb_field_packing *>(my_malloc(size, MYF(0)));
+ reinterpret_cast<Rdb_field_packing *>(my_malloc(PSI_INSTRUMENT_ME, size, MYF(0)));
/*
Guaranteed not to error here as checks have been made already during
diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc
index 2688b54725c..b1ef4826b59 100644
--- a/storage/sphinx/ha_sphinx.cc
+++ b/storage/sphinx/ha_sphinx.cc
@@ -596,6 +596,7 @@ private:
struct Override_t
{
+ Override_t() : m_dIds(PSI_INSTRUMENT_MEM), m_dValues(PSI_INSTRUMENT_MEM) {}
union Value_t
{
uint32 m_uValue;
@@ -738,7 +739,7 @@ static int sphinx_init_func ( void * p )
sphinx_init = 1;
void ( pthread_mutex_init ( &sphinx_mutex, MY_MUTEX_INIT_FAST ) );
sphinx_hash_init ( &sphinx_open_tables, system_charset_info, 32, 0, 0,
- sphinx_get_key, 0, 0 );
+ sphinx_get_key, 0, 0, PSI_NOT_INSTRUMENTED );
#if MYSQL_VERSION_ID > 50100
handlerton * hton = (handlerton*) p;
@@ -1303,6 +1304,7 @@ CSphSEQuery::CSphSEQuery ( const char * sQuery, int iLength, const char * sIndex
, m_fGeoLongitude ( 0.0f )
, m_sComment ( (char*) "" )
, m_sSelect ( (char*) "*" )
+ , m_dOverrides (PSI_INSTRUMENT_MEM)
, m_pBuf ( NULL )
, m_pCur ( NULL )
diff --git a/storage/spider/hs_client/config.cpp b/storage/spider/hs_client/config.cpp
index 97d479220e0..f735db6f586 100644
--- a/storage/spider/hs_client/config.cpp
+++ b/storage/spider/hs_client/config.cpp
@@ -36,7 +36,7 @@ conf_get_key(
config::config()
{
if (my_hash_init(&conf_hash, &my_charset_bin, 32, 0, 0,
- (my_hash_get_key) conf_get_key, 0, 0))
+ (my_hash_get_key) conf_get_key, 0, 0, PSI_INSTRUMENT_ME))
init = FALSE;
else
init = TRUE;
diff --git a/storage/spider/hs_client/hs_compat.h b/storage/spider/hs_client/hs_compat.h
index 8505d7978b7..6d40ff47475 100644
--- a/storage/spider/hs_client/hs_compat.h
+++ b/storage/spider/hs_client/hs_compat.h
@@ -16,7 +16,12 @@
#ifndef HS_COMPAT_H
#define HS_COMPAT_H
-#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100213
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100500
+#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \
+ my_init_dynamic_array2(A, PSI_INSTRUMENT_ME, B, C, D, E, F)
+#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \
+ init_alloc_root(PSI_INSTRUMENT_ME, A, B, C, D)
+#elif defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100213
#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \
my_init_dynamic_array2(A, B, C, D, E, F)
#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \
diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc
index 3ef8d4e0725..fe0ddd1d736 100644
--- a/storage/spider/spd_conn.cc
+++ b/storage/spider/spd_conn.cc
@@ -4534,7 +4534,8 @@ SPIDER_IP_PORT_CONN* spider_create_ipport_conn(SPIDER_CONN *conn)
DBUG_ENTER("spider_create_ipport_conn");
if (conn)
{
- SPIDER_IP_PORT_CONN *ret = (SPIDER_IP_PORT_CONN *) my_malloc(sizeof(*ret), MY_ZEROFILL | MY_WME);
+ SPIDER_IP_PORT_CONN *ret = (SPIDER_IP_PORT_CONN *)
+ my_malloc(PSI_INSTRUMENT_ME, sizeof(*ret), MY_ZEROFILL | MY_WME);
if (!ret)
{
goto err_return_direct;
@@ -4568,8 +4569,8 @@ SPIDER_IP_PORT_CONN* spider_create_ipport_conn(SPIDER_CONN *conn)
goto err_malloc_key;
}
- ret->key = (char *) my_malloc(ret->key_len + conn->tgt_host_length + 1,
- MY_ZEROFILL | MY_WME);
+ ret->key = (char *) my_malloc(PSI_INSTRUMENT_ME, ret->key_len +
+ conn->tgt_host_length + 1, MY_ZEROFILL | MY_WME);
if (!ret->key) {
pthread_cond_destroy(&ret->cond);
pthread_mutex_destroy(&ret->mutex);
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index ef405c68410..d3cf17679c3 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -1867,7 +1867,7 @@ int spider_db_mbase::init()
DBUG_PRINT("info",("spider this=%p", this));
if (
my_hash_init(&lock_table_hash, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_link_get_key, 0, 0)
+ (my_hash_get_key) spider_link_get_key, 0, 0, PSI_INSTRUMENT_ME)
) {
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
diff --git a/storage/spider/spd_malloc.cc b/storage/spider/spd_malloc.cc
index 40b37ff4377..9f4203ae33d 100644
--- a/storage/spider/spd_malloc.cc
+++ b/storage/spider/spd_malloc.cc
@@ -203,7 +203,7 @@ void *spider_alloc_mem(
uchar *ptr;
DBUG_ENTER("spider_alloc_mem");
size += ALIGN_SIZE(sizeof(uint)) + ALIGN_SIZE(sizeof(uint));
- if (!(ptr = (uchar *) my_malloc(size, my_flags)))
+ if (!(ptr = (uchar *) my_malloc(PSI_INSTRUMENT_ME, size, my_flags)))
DBUG_RETURN(NULL);
spider_alloc_mem_calc(trx, id, func_name, file_name, line_no, size);
@@ -233,7 +233,7 @@ void *spider_bulk_alloc_mem(
total_size += ALIGN_SIZE(va_arg(args, uint));
va_end(args);
- if (!(top_ptr = (uchar *) my_malloc(total_size, my_flags)))
+ if (!(top_ptr = (uchar *) my_malloc(PSI_INSTRUMENT_ME, total_size, my_flags)))
DBUG_RETURN(NULL);
spider_alloc_mem_calc(trx, id, func_name, file_name, line_no, total_size);
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index ee41d39df0f..e13c8d2b403 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -6139,7 +6139,8 @@ SPIDER_PARTITION_SHARE *spider_get_pt_share(
if(
my_hash_init(&partition_share->pt_handler_hash, spd_charset_utf8mb3_bin,
- 32, 0, 0, (my_hash_get_key) spider_pt_handler_share_get_key, 0, 0)
+ 32, 0, 0, (my_hash_get_key) spider_pt_handler_share_get_key, 0, 0,
+ PSI_INSTRUMENT_ME)
) {
*error_num = HA_ERR_OUT_OF_MEM;
goto error_init_pt_handler_hash;
@@ -7185,7 +7186,7 @@ int spider_db_init(
goto error_mem_calc_mutex_init;
if (my_hash_init(&spider_open_tables, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_tbl_get_key, 0, 0))
+ (my_hash_get_key) spider_tbl_get_key, 0, 0, PSI_INSTRUMENT_ME))
goto error_open_tables_hash_init;
spider_alloc_calc_mem_init(spider_open_tables, 143);
@@ -7194,7 +7195,7 @@ int spider_db_init(
spider_open_tables.array.max_element *
spider_open_tables.array.size_of_element);
if (my_hash_init(&spider_init_error_tables, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_tbl_get_key, 0, 0))
+ (my_hash_get_key) spider_tbl_get_key, 0, 0, PSI_INSTRUMENT_ME))
goto error_init_error_tables_hash_init;
spider_alloc_calc_mem_init(spider_init_error_tables, 144);
@@ -7204,7 +7205,7 @@ int spider_db_init(
spider_init_error_tables.array.size_of_element);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (my_hash_init(&spider_open_pt_share, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_pt_share_get_key, 0, 0))
+ (my_hash_get_key) spider_pt_share_get_key, 0, 0, PSI_INSTRUMENT_ME))
goto error_open_pt_share_hash_init;
spider_alloc_calc_mem_init(spider_open_pt_share, 145);
@@ -7216,7 +7217,7 @@ int spider_db_init(
if (my_hash_init(&spider_lgtm_tblhnd_share_hash, spd_charset_utf8mb3_bin,
32, 0, 0,
(my_hash_get_key) spider_lgtm_tblhnd_share_hash_get_key,
- 0, 0))
+ 0, 0, PSI_INSTRUMENT_ME))
goto error_lgtm_tblhnd_share_hash_init;
spider_alloc_calc_mem_init(spider_lgtm_tblhnd_share_hash, 245);
@@ -7225,12 +7226,12 @@ int spider_db_init(
spider_lgtm_tblhnd_share_hash.array.max_element *
spider_lgtm_tblhnd_share_hash.array.size_of_element);
if (my_hash_init(&spider_open_connections, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_conn_get_key, 0, 0))
+ (my_hash_get_key) spider_conn_get_key, 0, 0, PSI_INSTRUMENT_ME))
goto error_open_connections_hash_init;
if (my_hash_init(&spider_ipport_conns, spd_charset_utf8mb3_bin, 32, 0, 0,
(my_hash_get_key) spider_ipport_conn_get_key,
- spider_free_ipport_conn, 0))
+ spider_free_ipport_conn, 0, PSI_INSTRUMENT_ME))
goto error_ipport_conn__hash_init;
spider_alloc_calc_mem_init(spider_open_connections, 146);
@@ -7240,7 +7241,7 @@ int spider_db_init(
spider_open_connections.array.size_of_element);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (my_hash_init(&spider_hs_r_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_conn_get_key, 0, 0))
+ (my_hash_get_key) spider_conn_get_key, 0, 0, PSI_INSTRUMENT_ME))
goto error_hs_r_conn_hash_init;
spider_alloc_calc_mem_init(spider_hs_r_conn_hash, 147);
@@ -7249,7 +7250,7 @@ int spider_db_init(
spider_hs_r_conn_hash.array.max_element *
spider_hs_r_conn_hash.array.size_of_element);
if (my_hash_init(&spider_hs_w_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_conn_get_key, 0, 0))
+ (my_hash_get_key) spider_conn_get_key, 0, 0, PSI_INSTRUMENT_ME))
goto error_hs_w_conn_hash_init;
spider_alloc_calc_mem_init(spider_hs_w_conn_hash, 148);
@@ -7259,7 +7260,7 @@ int spider_db_init(
spider_hs_w_conn_hash.array.size_of_element);
#endif
if (my_hash_init(&spider_allocated_thds, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_allocated_thds_get_key, 0, 0))
+ (my_hash_get_key) spider_allocated_thds_get_key, 0, 0, PSI_INSTRUMENT_ME))
goto error_allocated_thds_hash_init;
spider_alloc_calc_mem_init(spider_allocated_thds, 149);
@@ -7321,7 +7322,7 @@ int spider_db_init(
{
if (my_hash_init(&spider_udf_table_mon_list_hash[roop_count],
spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_udf_tbl_mon_list_key, 0, 0))
+ (my_hash_get_key) spider_udf_tbl_mon_list_key, 0, 0, PSI_INSTRUMENT_ME))
goto error_init_udf_table_mon_list_hash;
spider_alloc_calc_mem_init(spider_udf_table_mon_list_hash, 150);
diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc
index ad2a35aac15..d3ff8424f9d 100644
--- a/storage/spider/spd_trx.cc
+++ b/storage/spider/spd_trx.cc
@@ -1238,7 +1238,7 @@ SPIDER_TRX *spider_get_trx(
if (
my_hash_init(&trx->trx_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_conn_get_key, 0, 0)
+ (my_hash_get_key) spider_conn_get_key, 0, 0, PSI_INSTRUMENT_ME)
)
goto error_init_hash;
spider_alloc_calc_mem_init(trx->trx_conn_hash, 151);
@@ -1250,7 +1250,7 @@ SPIDER_TRX *spider_get_trx(
if (
my_hash_init(&trx->trx_another_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_conn_get_key, 0, 0)
+ (my_hash_get_key) spider_conn_get_key, 0, 0, PSI_INSTRUMENT_ME)
)
goto error_init_another_hash;
spider_alloc_calc_mem_init(trx->trx_another_conn_hash, 152);
@@ -1314,7 +1314,7 @@ SPIDER_TRX *spider_get_trx(
if (
my_hash_init(&trx->trx_alter_table_hash, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_alter_tbl_get_key, 0, 0)
+ (my_hash_get_key) spider_alter_tbl_get_key, 0, 0, PSI_INSTRUMENT_ME)
)
goto error_init_alter_hash;
spider_alloc_calc_mem_init(trx->trx_alter_table_hash, 157);
@@ -1326,7 +1326,7 @@ SPIDER_TRX *spider_get_trx(
if (
my_hash_init(&trx->trx_ha_hash, spd_charset_utf8mb3_bin, 32, 0, 0,
- (my_hash_get_key) spider_trx_ha_get_key, 0, 0)
+ (my_hash_get_key) spider_trx_ha_get_key, 0, 0, PSI_INSTRUMENT_ME)
)
goto error_init_trx_ha_hash;
spider_alloc_calc_mem_init(trx->trx_ha_hash, 158);
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index a046bf352c4..6a351c05823 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -524,7 +524,7 @@ int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)),
tc1= buf;
if ((len1 + len2 +2) > (int) sizeof(buf))
- tc1= (uchar*) my_malloc(len1+len2+2, MYF(MY_FAE));
+ tc1= (uchar*) my_malloc(PSI_INSTRUMENT_ME, len1+len2+2, MYF(MY_FAE));
tc2= tc1 + len1+1;
memcpy((char*) tc1, (char*) s1, len1);
tc1[len1]= 0; /* if length(s1)> len1, need to put 'end of string' */
@@ -550,7 +550,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)),
a= buf;
if ((a_length + b_length +2) > (int) sizeof(buf))
- alloced= a= (uchar*) my_malloc(a_length+b_length+2, MYF(MY_FAE));
+ alloced= a= (uchar*) my_malloc(PSI_INSTRUMENT_ME, a_length+b_length+2, MYF(MY_FAE));
b= a + a_length+1;
memcpy((char*) a, (char*) a0, a_length);
diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c
index add0bd422e8..cf4a7eedabf 100644
--- a/strings/my_vsnprintf.c
+++ b/strings/my_vsnprintf.c
@@ -759,7 +759,7 @@ int my_vfprintf(FILE *stream, const char* format, va_list args)
if (new_len < cur_len)
return 0; /* Overflow */
cur_len= new_len;
- p= my_malloc(cur_len, MYF(MY_FAE));
+ p= my_malloc(PSI_INSTRUMENT_ME, cur_len, MYF(MY_FAE));
if (!p)
return 0;
}
diff --git a/strings/xml.c b/strings/xml.c
index 0178ea2574e..d16df34bf30 100644
--- a/strings/xml.c
+++ b/strings/xml.c
@@ -232,12 +232,12 @@ static int my_xml_attr_ensure_space(MY_XML_PARSER *st, size_t len)
if (!st->attr.buffer)
{
- st->attr.buffer= (char *) my_malloc(st->attr.buffer_size, MYF(0));
+ st->attr.buffer= (char *) my_malloc(PSI_INSTRUMENT_ME, st->attr.buffer_size, MYF(0));
if (st->attr.buffer)
memcpy(st->attr.buffer, st->attr.static_buffer, ofs + 1 /*term. zero */);
}
else
- st->attr.buffer= (char *) my_realloc(st->attr.buffer,
+ st->attr.buffer= (char *) my_realloc(PSI_INSTRUMENT_ME, st->attr.buffer,
st->attr.buffer_size, MYF(0));
st->attr.start= st->attr.buffer;
st->attr.end= st->attr.start + ofs;
diff --git a/tests/async_queries.c b/tests/async_queries.c
index 60b58685daa..e1b7061eaa9 100644
--- a/tests/async_queries.c
+++ b/tests/async_queries.c
@@ -314,8 +314,8 @@ add_query(const char *q)
char *q2;
size_t len;
- e= my_malloc(sizeof(*e), MYF(0));
- q2= my_strdup(q, MYF(0));
+ e= my_malloc(PSI_NOT_INSTRUMENTED, sizeof(*e), MYF(0));
+ q2= my_strdup(PSI_NOT_INSTRUMENTED, q, MYF(0));
if (!e || !q2)
fatal(NULL, "Out of memory");
@@ -394,7 +394,7 @@ main(int argc, char *argv[])
add_query(*argv++);
}
- sds= my_malloc(opt_connections * sizeof(*sds), MYF(0));
+ sds= my_malloc(PSI_NOT_INSTRUMENTED, opt_connections * sizeof(*sds), MYF(0));
if (!sds)
fatal(NULL, "Out of memory");
diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c
index cfcb6690f4a..aea0562672c 100644
--- a/tests/mysql_client_fw.c
+++ b/tests/mysql_client_fw.c
@@ -1288,7 +1288,7 @@ get_one_option(const struct my_option *opt, char *argument,
{
char *start=argument;
my_free(opt_password);
- opt_password= my_strdup(argument, MYF(MY_FAE));
+ opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0;
@@ -1319,7 +1319,7 @@ get_one_option(const struct my_option *opt, char *argument,
}
if (embedded_server_arg_count == MAX_SERVER_ARGS-1 ||
!(embedded_server_args[embedded_server_arg_count++]=
- my_strdup(argument, MYF(MY_FAE))))
+ my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE))))
{
DIE("Can't use server argument");
}
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 16bfa72985f..ce3deb7882d 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -19033,7 +19033,7 @@ static void test_bug56976()
rc= mysql_stmt_bind_param(stmt, bind);
check_execute(stmt, rc);
- long_buffer= (char*) my_malloc(packet_len, MYF(0));
+ long_buffer= (char*) my_malloc(PSI_NOT_INSTRUMENTED, packet_len, MYF(0));
DIE_UNLESS(long_buffer);
memset(long_buffer, 'a', packet_len);
@@ -19779,7 +19779,7 @@ static void test_big_packet()
myheader("test_big_packet");
- query= (char*) my_malloc(big_packet+1024, MYF(MY_WME));
+ query= (char*) my_malloc(PSI_NOT_INSTRUMENTED, big_packet+1024, MYF(MY_WME));
DIE_UNLESS(query);
if (!(mysql_local= mysql_client_init(NULL)))
diff --git a/unittest/mysys/my_malloc-t.c b/unittest/mysys/my_malloc-t.c
index d20ef052380..0ee6b2b9191 100644
--- a/unittest/mysys/my_malloc-t.c
+++ b/unittest/mysys/my_malloc-t.c
@@ -24,13 +24,13 @@ int main(int argc __attribute__((unused)),char *argv[])
plan(4);
- p= my_malloc(0, MYF(0));
+ p= my_malloc(PSI_NOT_INSTRUMENTED, 0, MYF(0));
ok(p != NULL, "Zero-sized block allocation.");
- p= my_realloc(p, 32, MYF(0));
+ p= my_realloc(PSI_NOT_INSTRUMENTED, p, 32, MYF(0));
ok(p != NULL, "Reallocated zero-sized block.");
- p= my_realloc(p, 16, MYF(0));
+ p= my_realloc(PSI_NOT_INSTRUMENTED, p, 16, MYF(0));
ok(p != NULL, "Trimmed block.");
my_free(p);
diff --git a/vio/vio.c b/vio/vio.c
index 3f92c1e6853..cabed39d94f 100644
--- a/vio/vio.c
+++ b/vio/vio.c
@@ -24,6 +24,28 @@
#include "vio_priv.h"
#include "ssl_compat.h"
+PSI_memory_key key_memory_vio_ssl_fd;
+PSI_memory_key key_memory_vio;
+PSI_memory_key key_memory_vio_read_buffer;
+
+#ifdef HAVE_PSI_INTERFACE
+static PSI_memory_info all_vio_memory[]=
+{
+ {&key_memory_vio_ssl_fd, "ssl_fd", 0},
+ {&key_memory_vio, "vio", 0},
+ {&key_memory_vio_read_buffer, "read_buffer", 0},
+};
+
+void init_vio_psi_keys()
+{
+ const char* category= "vio";
+ int count;
+
+ count= array_elements(all_vio_memory);
+ mysql_memory_register(category, all_vio_memory, count);
+}
+#endif
+
#ifdef _WIN32
/**
@@ -80,7 +102,8 @@ static void vio_init(Vio *vio, enum enum_vio_type type,
vio->localhost= flags & VIO_LOCALHOST;
vio->read_timeout= vio->write_timeout= -1;
if ((flags & VIO_BUFFERED_READ) &&
- !(vio->read_buffer= (char*)my_malloc(VIO_READ_BUFFER_SIZE, MYF(MY_WME))))
+ !(vio->read_buffer= (char*)my_malloc(key_memory_vio_read_buffer,
+ VIO_READ_BUFFER_SIZE, MYF(MY_WME))))
flags&= ~VIO_BUFFERED_READ;
#ifdef _WIN32
if (type == VIO_TYPE_NAMEDPIPE)
@@ -217,7 +240,7 @@ Vio *mysql_socket_vio_new(MYSQL_SOCKET mysql_socket, enum enum_vio_type type, ui
my_socket sd= mysql_socket_getfd(mysql_socket);
DBUG_ENTER("mysql_socket_vio_new");
DBUG_PRINT("enter", ("sd: %d", (int)sd));
- if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME))))
+ if ((vio = (Vio*) my_malloc(key_memory_vio, sizeof(*vio), MYF(MY_WME))))
{
vio_init(vio, type, sd, flags);
vio->desc= (vio->type == VIO_TYPE_SOCKET ? "socket" : "TCP/IP");
@@ -247,7 +270,7 @@ Vio *vio_new_win32pipe(HANDLE hPipe)
{
Vio *vio;
DBUG_ENTER("vio_new_handle");
- if ((vio = (Vio*) my_malloc(sizeof(Vio),MYF(MY_WME))))
+ if ((vio = (Vio*) my_malloc(PSI_INSTRUMENT_ME, sizeof(Vio),MYF(MY_WME))))
{
vio_init(vio, VIO_TYPE_NAMEDPIPE, 0, VIO_LOCALHOST);
vio->desc= "named pipe";
diff --git a/vio/vio_priv.h b/vio/vio_priv.h
index 9b68624a811..8dc38ab31e8 100644
--- a/vio/vio_priv.h
+++ b/vio/vio_priv.h
@@ -26,6 +26,10 @@
#include <m_string.h>
#include <violite.h>
+extern PSI_memory_key key_memory_vio;
+extern PSI_memory_key key_memory_vio_read_buffer;
+extern PSI_memory_key key_memory_vio_ssl_fd;
+
#ifdef _WIN32
size_t vio_read_pipe(Vio *vio, uchar * buf, size_t size);
size_t vio_write_pipe(Vio *vio, const uchar * buf, size_t size);
diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c
index edd40c2d60c..3783331e7df 100644
--- a/vio/viosslfactories.c
+++ b/vio/viosslfactories.c
@@ -246,7 +246,8 @@ new_VioSSLFd(const char *key_file, const char *cert_file,
check_ssl_init();
if (!(ssl_fd= ((struct st_VioSSLFd*)
- my_malloc(sizeof(struct st_VioSSLFd),MYF(0)))))
+ my_malloc(key_memory_vio_ssl_fd,
+ sizeof(struct st_VioSSLFd), MYF(0)))))
goto err0;
if (!(ssl_fd->ssl_context= SSL_CTX_new(is_client_method ?
SSLv23_client_method() :