mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao. The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC. Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc(). There are plenty of new asserts to ensure that for a debug server the counting is correct. Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS. - The later is there mainly to show how query is progressing. The following changes in interfaces was needed to get this to work: - init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC - One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root() - my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC - my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC - Added flag for hash_init() so that one can mark hash table to be thread specific. - Added flags to init_tree() so that one can mark tree to be thread specific. - Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG. - Added flag to Warning_info::Warning_info() if the structure should be fully initialized. - String elements can now be marked as thread specific. - Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC. - Changed type of myf from int to ulong, as this is always a set of bit flags. Other things: - Removed calls to net_end() and thd->cleanup() as these are now done in ~THD() - We now also show EXAMINED_ROWS in SHOW PROCESSLIST - Added new variable 'memory_used' - Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory. - Removed calls to the obsoleted function init_dynamic_array() - Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...) client/completion_hash.cc: Updated call to init_alloc_root() client/mysql.cc: Updated call to init_alloc_root() client/mysqlbinlog.cc: init_dynamic_array() -> my_init_dynamic_array() Updated call to init_alloc_root() client/mysqlcheck.c: Updated call to my_init_dynamic_array() client/mysqldump.c: Updated call to init_alloc_root() client/mysqltest.cc: Updated call to init_alloc_root() Updated call to my_init_dynamic_array() Fixed compiler warnings extra/comp_err.c: Updated call to my_init_dynamic_array() extra/resolve_stack_dump.c: Updated call to my_init_dynamic_array() include/hash.h: Added HASH_THREAD_SPECIFIC include/heap.h: Added flag is internal temporary table. include/my_dir.h: Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags include/my_global.h: Changed type of myf from int to ulong, as this is always a set of bit flags. include/my_sys.h: Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE Added malloc_flags to DYNAMIC_ARRAY Added extra mysys flag argument to my_init_dynamic_array() Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci Updated paramaters for init_alloc_root() include/my_tree.h: Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables. Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG Updated parameters to init_tree() include/myisamchk.h: Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks. include/mysql.h: Added MYSQL_THREAD_SPECIFIC_MALLOC Used 'unused1' to mark memory as thread specific. include/mysql.h.pp: Updated file include/mysql_com.h: Used 'unused1' to mark memory as thread specific. Updated parameters for my_net_init() libmysql/libmysql.c: Updated call to init_alloc_root() to mark memory thread specific. libmysqld/emb_qcache.cc: Updated call to init_alloc_root() libmysqld/lib_sql.cc: Updated call to init_alloc_root() mysql-test/r/create.result: Updated results mysql-test/r/user_var.result: Updated results mysql-test/suite/funcs_1/datadict/processlist_priv.inc: Update to handle new format of SHOW PROCESSLIST mysql-test/suite/funcs_1/datadict/processlist_val.inc: Update to handle new format of SHOW PROCESSLIST mysql-test/suite/funcs_1/r/is_columns_is.result: Update to handle new format of SHOW PROCESSLIST mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result: Updated results mysql-test/suite/funcs_1/r/processlist_val_no_prot.result: Updated results mysql-test/t/show_explain.test: Fixed usage of debug variable so that one can run test with --debug mysql-test/t/user_var.test: Added test of memory_usage variable. mysys/array.c: Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC All allocated memory is marked with the given my_flags. Removed obsolete function init_dynamic_array() mysys/default.c: Updated call to init_alloc_root() Updated call to my_init_dynamic_array() mysys/hash.c: Updated call to my_init_dynamic_array_ci(). Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used. mysys/ma_dyncol.c: init_dynamic_array() -> my_init_dynamic_array() Added #if to get rid of compiler warnings mysys/mf_tempdir.c: Updated call to my_init_dynamic_array() mysys/my_alloc.c: Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC Extend MEM_ROOT with a flag if memory is thread specific. This is stored in block_size, to keep the size of the MEM_ROOT object identical as before. Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root() mysys/my_chmod.c: Updated DBUG_PRINT because of change of myf type mysys/my_chsize.c: Updated DBUG_PRINT because of change of myf type mysys/my_copy.c: Updated DBUG_PRINT because of change of myf type mysys/my_create.c: Updated DBUG_PRINT because of change of myf type mysys/my_delete.c: Updated DBUG_PRINT because of change of myf type mysys/my_error.c: Updated DBUG_PRINT because of change of myf type mysys/my_fopen.c: Updated DBUG_PRINT because of change of myf type mysys/my_fstream.c: Updated DBUG_PRINT because of change of myf type mysys/my_getwd.c: Updated DBUG_PRINT because of change of myf type mysys/my_lib.c: Updated call to init_alloc_root() Updated call to my_init_dynamic_array() Updated DBUG_PRINT because of change of myf type mysys/my_lock.c: Updated DBUG_PRINT because of change of myf type mysys/my_malloc.c: Store at start of each allocated memory block the size of the block and if the block is thread specific. Call malloc_size_cb_func, if set, with the memory allocated/freed. Updated DBUG_PRINT because of change of myf type mysys/my_open.c: Updated DBUG_PRINT because of change of myf type mysys/my_pread.c: Updated DBUG_PRINT because of change of myf type mysys/my_read.c: Updated DBUG_PRINT because of change of myf type mysys/my_redel.c: Updated DBUG_PRINT because of change of myf type mysys/my_rename.c: Updated DBUG_PRINT because of change of myf type mysys/my_seek.c: Updated DBUG_PRINT because of change of myf type mysys/my_sync.c: Updated DBUG_PRINT because of change of myf type mysys/my_thr_init.c: Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized. mysys/my_write.c: Updated DBUG_PRINT because of change of myf type mysys/mysys_priv.h: Updated parameters to sf_malloc and sf_realloc() mysys/safemalloc.c: Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory. Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory. Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC. Added sf_report_leaked_memory() to get list of memory not freed by a thread. mysys/tree.c: Added flags to init_tree() so that one can mark tree to be thread specific. Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG. Updated call to init_alloc_root() All allocated memory is marked with the given malloc flags mysys/waiting_threads.c: Updated call to my_init_dynamic_array() sql-common/client.c: Updated call to init_alloc_root() and my_net_init() to mark memory thread specific. Updated call to my_init_dynamic_array(). Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC. sql-common/client_plugin.c: Updated call to init_alloc_root() sql/debug_sync.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/event_scheduler.cc: Removed calls to net_end() as this is now done in ~THD() Call set_current_thd() to ensure that memory is assigned to right thread. sql/events.cc: my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() sql/filesort.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/filesort_utils.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/ha_ndbcluster.cc: Updated call to init_alloc_root() Updated call to my_net_init() Removed calls to net_end() and thd->cleanup() as these are now done in ~THD() sql/ha_ndbcluster_binlog.cc: Updated call to my_net_init() Updated call to init_sql_alloc() Removed calls to net_end() and thd->cleanup() as these are now done in ~THD() sql/ha_partition.cc: Updated call to init_alloc_root() sql/handler.cc: Added MY_THREAD_SPECIFIC to allocated memory. Added missing call to my_dir_end() sql/item_func.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/item_subselect.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/item_sum.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/log.cc: More DBUG Updated call to init_alloc_root() sql/mdl.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/mysqld.cc: Added total_memory_used Updated call to init_alloc_root() Move mysql_cond_broadcast() before my_thread_end() Added mariadb_dbug_id() to count memory per THD instead of per thread. Added my_malloc_size_cb_func() callback function for my_malloc() to count memory. Move initialization of mysqld_server_started and mysqld_server_initialized earlier. Updated call to my_init_dynamic_array(). Updated call to my_net_init(). Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread. Added status variable 'memory_used'. Updated call to init_alloc_root() my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() sql/mysqld.h: Added set_current_thd() sql/net_serv.cc: Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC. Store in net->thread_specific_malloc if memory is thread specific. Mark memory to be thread specific if requested. sql/opt_range.cc: Updated call to my_init_dynamic_array() Updated call to init_sql_alloc() Added MY_THREAD_SPECIFIC to allocated memory. sql/opt_subselect.cc: Updated call to init_sql_alloc() to mark memory thread specific. sql/protocol.cc: Fixed compiler warning sql/records.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/rpl_filter.cc: Updated call to my_init_dynamic_array() sql/rpl_handler.cc: Updated call to my_init_dynamic_array2() sql/rpl_handler.h: Updated call to init_sql_alloc() sql/rpl_mi.cc: Updated call to my_init_dynamic_array() sql/rpl_tblmap.cc: Updated call to init_alloc_root() sql/rpl_utility.cc: Updated call to my_init_dynamic_array() sql/slave.cc: Initialize things properly before calling functions that allocate memory. Removed calls to net_end() as this is now done in ~THD() sql/sp_head.cc: Updated call to init_sql_alloc() Updated call to my_init_dynamic_array() Added parameter to warning_info() that it should be fully initialized. sql/sp_pcontext.cc: Updated call to my_init_dynamic_array() sql/sql_acl.cc: Updated call to init_sql_alloc() Updated call to my_init_dynamic_array() my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() sql/sql_admin.cc: Added parameter to warning_info() that it should be fully initialized. sql/sql_analyse.h: Updated call to init_tree() to mark memory thread specific. sql/sql_array.h: Updated call to my_init_dynamic_array() to mark memory thread specific. sql/sql_audit.cc: Updated call to my_init_dynamic_array() sql/sql_base.cc: Updated call to init_sql_alloc() my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() sql/sql_cache.cc: Updated comment sql/sql_class.cc: Added parameter to warning_info() that not initialize it until THD is fully created. Updated call to init_sql_alloc() Mark THD::user_vars has to be thread specific. Updated call to my_init_dynamic_array() Ensure that memory allocated by THD is assigned to the THD. More DBUG Always acll net_end() in ~THD() Assert that all memory signed to this THD is really deleted at ~THD. Fixed set_status_var_init() to not reset memory_used. my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() sql/sql_class.h: Added MY_THREAD_SPECIFIC to allocated memory. Added malloc_size to THD to record allocated memory per THD. sql/sql_delete.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/sql_error.cc: Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures. This is used by THD::THD() to not allocate memory until THD is ready. Added Warning_info::free_memory() sql/sql_error.h: Updated Warning_info() class. sql/sql_handler.cc: Updated call to init_alloc_root() to mark memory thread specific. sql/sql_insert.cc: More DBUG sql/sql_join_cache.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/sql_lex.cc: Updated call to my_init_dynamic_array() sql/sql_lex.h: Updated call to my_init_dynamic_array() sql/sql_load.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/sql_parse.cc: Removed calls to net_end() and thd->cleanup() as these are now done in ~THD() Ensure that examined_row_count() is reset before query. Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory. my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() Don't restore thd->status_var.memory_used when restoring thd->status_var sql/sql_plugin.cc: Updated call to init_alloc_root() Updated call to my_init_dynamic_array() Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting. my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() sql/sql_prepare.cc: Added parameter to warning_info() that it should be fully initialized. Updated call to init_sql_alloc() to mark memory thread specific. sql/sql_reload.cc: my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() sql/sql_select.cc: Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific. Added MY_THREAD_SPECIFIC to allocated memory. More DBUG sql/sql_servers.cc: Updated call to init_sql_alloc() to mark memory some memory thread specific. my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() sql/sql_show.cc: Updated call to my_init_dynamic_array() Mark my_dir() memory thread specific. Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread. More DBUG. Added malloc_size and examined_row_count to SHOW PROCESSLIST. Added MY_THREAD_SPECIFIC to allocated memory. Updated call to init_sql_alloc() Added parameter to warning_info() that it should be fully initialized. sql/sql_statistics.cc: Fixed compiler warning sql/sql_string.cc: String elements can now be marked as thread specific. sql/sql_string.h: String elements can now be marked as thread specific. sql/sql_table.cc: Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() Fixed compiler warning sql/sql_test.cc: Updated call to my_init_dynamic_array() to mark memory thread specific. sql/sql_trigger.cc: Updated call to init_sql_alloc() sql/sql_udf.cc: Updated call to init_sql_alloc() my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() sql/sql_update.cc: Added MY_THREAD_SPECIFIC to allocated memory. sql/table.cc: Updated call to init_sql_alloc(). Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC Updated call to init_sql_alloc() sql/thr_malloc.cc: Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC. sql/thr_malloc.h: Updated prototype for init_sql_alloc() sql/tztime.cc: Updated call to init_sql_alloc() Updated call to init_alloc_root() to mark memory thread specific. my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd() sql/uniques.cc: Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific. sql/unireg.cc: Added MY_THREAD_SPECIFIC to allocated memory. storage/csv/ha_tina.cc: Updated call to init_alloc_root() storage/federated/ha_federated.cc: Updated call to init_alloc_root() Updated call to my_init_dynamic_array() Ensure that memory allocated by fedarated is registered for the system, not for the thread. storage/federatedx/federatedx_io_mysql.cc: Updated call to my_init_dynamic_array() storage/federatedx/ha_federatedx.cc: Updated call to init_alloc_root() Updated call to my_init_dynamic_array() storage/heap/ha_heap.cc: Added MY_THREAD_SPECIFIC to allocated memory. storage/heap/heapdef.h: Added parameter to hp_get_new_block() to be able to do thread specific memory tagging. storage/heap/hp_block.c: Added parameter to hp_get_new_block() to be able to do thread specific memory tagging. storage/heap/hp_create.c: - Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC. - Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'. storage/heap/hp_open.c: Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC. storage/heap/hp_write.c: Added new parameter to hp_get_new_block() storage/maria/ma_bitmap.c: Updated call to my_init_dynamic_array() storage/maria/ma_blockrec.c: Updated call to my_init_dynamic_array() storage/maria/ma_check.c: Updated call to init_alloc_root() storage/maria/ma_ft_boolean_search.c: Updated calls to init_tree() and init_alloc_root() storage/maria/ma_ft_nlq_search.c: Updated call to init_tree() storage/maria/ma_ft_parser.c: Updated call to init_tree() Updated call to init_alloc_root() storage/maria/ma_loghandler.c: Updated call to my_init_dynamic_array() storage/maria/ma_open.c: Updated call to my_init_dynamic_array() storage/maria/ma_sort.c: Updated call to my_init_dynamic_array() storage/maria/ma_write.c: Updated calls to my_init_dynamic_array() and init_tree() storage/maria/maria_pack.c: Updated call to init_tree() storage/maria/unittest/sequence_storage.c: Updated call to my_init_dynamic_array() storage/myisam/ft_boolean_search.c: Updated call to init_tree() Updated call to init_alloc_root() storage/myisam/ft_nlq_search.c: Updated call to init_tree() storage/myisam/ft_parser.c: Updated call to init_tree() Updated call to init_alloc_root() storage/myisam/ft_stopwords.c: Updated call to init_tree() storage/myisam/mi_check.c: Updated call to init_alloc_root() storage/myisam/mi_write.c: Updated call to my_init_dynamic_array() Updated call to init_tree() storage/myisam/myisamlog.c: Updated call to init_tree() storage/myisam/myisampack.c: Updated call to init_tree() storage/myisam/sort.c: Updated call to my_init_dynamic_array() storage/myisammrg/ha_myisammrg.cc: Updated call to init_sql_alloc() storage/perfschema/pfs_check.cc: Rest current_thd storage/perfschema/pfs_instr.cc: Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems. support-files/compiler_warnings.supp: Disable compiler warning from offsetof macro.
This commit is contained in:
parent
09665bfd0e
commit
a260b15554
173 changed files with 1331 additions and 773 deletions
|
@ -49,7 +49,7 @@ int completion_hash_init(HashTable *ht, uint nSize)
|
|||
ht->initialized = 0;
|
||||
return FAILURE;
|
||||
}
|
||||
init_alloc_root(&ht->mem_root, 8192, 0);
|
||||
init_alloc_root(&ht->mem_root, 8192, 0, 0);
|
||||
ht->pHashFunction = hashpjw;
|
||||
ht->nTableSize = nSize;
|
||||
ht->initialized = 1;
|
||||
|
|
|
@ -1157,7 +1157,7 @@ int main(int argc,char *argv[])
|
|||
}
|
||||
glob_buffer.realloc(512);
|
||||
completion_hash_init(&ht, 128);
|
||||
init_alloc_root(&hash_mem_root, 16384, 0);
|
||||
init_alloc_root(&hash_mem_root, 16384, 0, 0);
|
||||
bzero((char*) &mysql, sizeof(mysql));
|
||||
if (sql_connect(current_host,current_db,current_user,opt_password,
|
||||
opt_silent))
|
||||
|
|
|
@ -278,8 +278,8 @@ public:
|
|||
|
||||
int init()
|
||||
{
|
||||
return init_dynamic_array(&file_names, sizeof(File_name_record),
|
||||
100, 100);
|
||||
return my_init_dynamic_array(&file_names, sizeof(File_name_record),
|
||||
100, 100, 0);
|
||||
}
|
||||
|
||||
void init_by_dir_name(const char *dir)
|
||||
|
@ -2393,7 +2393,7 @@ int main(int argc, char** argv)
|
|||
|
||||
my_init_time(); // for time functions
|
||||
|
||||
init_alloc_root(&s_mem_root, 16384, 0);
|
||||
init_alloc_root(&s_mem_root, 16384, 0, 0);
|
||||
if (load_defaults("my", load_groups, &argc, &argv))
|
||||
exit(1);
|
||||
|
||||
|
|
|
@ -994,8 +994,10 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (opt_auto_repair &&
|
||||
(my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16,64) ||
|
||||
my_init_dynamic_array(&tables4rebuild, sizeof(char)*(NAME_LEN*2+2),16,64)))
|
||||
(my_init_dynamic_array(&tables4repair, sizeof(char)*(NAME_LEN*2+2),16,
|
||||
64, 0) ||
|
||||
my_init_dynamic_array(&tables4rebuild, sizeof(char)*(NAME_LEN*2+2),16,
|
||||
64, 0)))
|
||||
goto end;
|
||||
|
||||
if (opt_alldbs)
|
||||
|
|
|
@ -4583,7 +4583,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(&root, 8192, 0);
|
||||
init_alloc_root(&root, 8192, 0, 0);
|
||||
if (!(dump_tables= pos= (char**) alloc_root(&root, tables * sizeof(char *))))
|
||||
die(EX_EOM, "alloc_root failure.");
|
||||
|
||||
|
|
|
@ -5174,7 +5174,7 @@ typedef struct
|
|||
|
||||
static st_error global_error_names[] =
|
||||
{
|
||||
{ "<No error>", -1U, "" },
|
||||
{ "<No error>", ~0U, "" },
|
||||
#include <mysqld_ername.h>
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
@ -7286,7 +7286,7 @@ void init_win_path_patterns()
|
|||
|
||||
DBUG_ENTER("init_win_path_patterns");
|
||||
|
||||
my_init_dynamic_array(&patterns, sizeof(const char*), 16, 16);
|
||||
my_init_dynamic_array(&patterns, sizeof(const char*), 16, 16, MYF(0));
|
||||
|
||||
/* Loop through all paths in the array */
|
||||
for (i= 0; i < num_paths; i++)
|
||||
|
@ -8899,7 +8899,7 @@ 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);
|
||||
my_init_dynamic_array(&q_lines, sizeof(struct st_command*), 1024, 1024, 0);
|
||||
|
||||
if (my_hash_init2(&var_hash, 64, charset_info,
|
||||
128, 0, 0, get_var_key, var_free, MYF(0)))
|
||||
|
@ -8929,7 +8929,7 @@ int main(int argc, char **argv)
|
|||
#endif
|
||||
|
||||
init_dynamic_string(&ds_res, "", 2048, 2048);
|
||||
init_alloc_root(&require_file_root, 1024, 1024);
|
||||
init_alloc_root(&require_file_root, 1024, 1024, 0);
|
||||
|
||||
parse_args(argc, argv);
|
||||
|
||||
|
@ -9873,7 +9873,7 @@ struct st_replace_regex* init_replace_regex(char* expr)
|
|||
/* my_malloc() will die on fail with MY_FAE */
|
||||
res=(struct st_replace_regex*)my_malloc(
|
||||
sizeof(*res)+expr_len ,MYF(MY_FAE+MY_WME));
|
||||
my_init_dynamic_array(&res->regex_arr,sizeof(struct st_regex),128,128);
|
||||
my_init_dynamic_array(&res->regex_arr,sizeof(struct st_regex), 128, 128, 0);
|
||||
|
||||
buf= (char*)res + sizeof(*res);
|
||||
expr_end= expr + expr_len;
|
||||
|
@ -10928,7 +10928,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);
|
||||
my_init_dynamic_array(&lines, sizeof(const char*), 32, 32, 0);
|
||||
|
||||
if (keep_header)
|
||||
{
|
||||
|
|
|
@ -894,7 +894,7 @@ static struct errors *generate_empty_message(uint d_code)
|
|||
if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error),
|
||||
MYF(MY_WME))))
|
||||
return(0);
|
||||
if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 1))
|
||||
if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 1, 0))
|
||||
return(0); /* OOM: Fatal error */
|
||||
|
||||
new_error->er_name= NULL;
|
||||
|
@ -928,7 +928,7 @@ static struct errors *parse_error_string(char *str, int er_count)
|
|||
MYF(MY_WME))))
|
||||
DBUG_RETURN(0);
|
||||
|
||||
if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 0))
|
||||
if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 0, 0))
|
||||
DBUG_RETURN(0); /* OOM: Fatal error */
|
||||
|
||||
/* getting the error name */
|
||||
|
|
|
@ -265,7 +265,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
|
|||
if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD),
|
||||
MYF(MY_WME))))
|
||||
{
|
||||
my_free(pa->typelib.type_names);
|
||||
my_free((char*) pa->typelib.type_names);
|
||||
DBUG_RETURN (-1);
|
||||
}
|
||||
pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+
|
||||
|
@ -327,7 +327,7 @@ static void free_pointer_array(reg1 POINTER_ARRAY *pa)
|
|||
if (pa->typelib.count)
|
||||
{
|
||||
pa->typelib.count=0;
|
||||
my_free(pa->typelib.type_names);
|
||||
my_free((char*) pa->typelib.type_names);
|
||||
pa->typelib.type_names=0;
|
||||
my_free(pa->str);
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ static void init_sym_table()
|
|||
{
|
||||
char buf[512];
|
||||
if (my_init_dynamic_array(&sym_table, sizeof(SYM_ENTRY), INIT_SYM_TABLE,
|
||||
INC_SYM_TABLE))
|
||||
INC_SYM_TABLE, 0))
|
||||
die("Failed in my_init_dynamic_array() -- looks like out of memory problem");
|
||||
|
||||
while (fgets(buf, sizeof(buf), fp_sym))
|
||||
|
|
|
@ -39,6 +39,7 @@ extern "C" {
|
|||
|
||||
/* flags for hash_init */
|
||||
#define HASH_UNIQUE 1 /* hash_insert fails on duplicate key */
|
||||
#define HASH_THREAD_SPECIFIC 2 /* Mark allocated memory THREAD_SPECIFIC */
|
||||
|
||||
typedef uint my_hash_value_type;
|
||||
typedef uchar *(*my_hash_get_key)(const uchar *,size_t*,my_bool);
|
||||
|
|
|
@ -153,6 +153,7 @@ typedef struct st_heap_share
|
|||
THR_LOCK lock;
|
||||
mysql_mutex_t intern_lock; /* Locking for use with _locking */
|
||||
my_bool delete_on_close;
|
||||
my_bool internal; /* Internal temporary table */
|
||||
LIST open_list;
|
||||
uint auto_key;
|
||||
uint auto_key_type; /* real type of the auto key segment */
|
||||
|
|
|
@ -45,8 +45,9 @@ extern "C" {
|
|||
#define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG)
|
||||
#define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO)
|
||||
|
||||
#define MY_DONT_SORT 512 /* my_lib; Don't sort files */
|
||||
#define MY_WANT_STAT 1024 /* my_lib; stat files */
|
||||
/* Ensure these dosn't clash with anything in my_sys.h */
|
||||
#define MY_DONT_SORT 8192 /* my_lib; Don't sort files */
|
||||
#define MY_WANT_STAT 16384 /* my_lib; stat files */
|
||||
|
||||
/* typedefs for my_dir & my_stat */
|
||||
|
||||
|
|
|
@ -1003,7 +1003,7 @@ typedef struct st_mysql_lex_string LEX_STRING;
|
|||
#define SOCKET_EMFILE EMFILE
|
||||
#endif
|
||||
|
||||
typedef int myf; /* Type of MyFlags in my_funcs */
|
||||
typedef ulong myf; /* Type of MyFlags in my_funcs */
|
||||
typedef char my_bool; /* Small bool */
|
||||
|
||||
/* Macros for converting *constants* to the right type */
|
||||
|
|
|
@ -86,6 +86,10 @@ typedef struct my_aio_result {
|
|||
#define MY_SYNC 4096 /* my_copy(): sync dst file */
|
||||
#define MY_SYNC_DIR 32768 /* my_create/delete/rename: sync directory */
|
||||
#define MY_SYNC_FILESIZE 65536 /* my_sync(): safe sync when file is extended */
|
||||
#define MY_THREAD_SPECIFIC 0x10000 /* my_malloc(): thread specific */
|
||||
#define MY_THREAD_MOVE 0x20000 /* realloc(); Memory can move */
|
||||
/* Tree that should delete things automaticly */
|
||||
#define MY_TREE_WITH_DELETE 0x40000
|
||||
|
||||
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
|
||||
#define MY_GIVE_INFO 2 /* Give time info about process*/
|
||||
|
@ -148,6 +152,18 @@ typedef struct my_aio_result {
|
|||
/* Extra length needed for filename if one calls my_create_backup_name */
|
||||
#define MY_BACKUP_NAME_EXTRA_LENGTH 17
|
||||
|
||||
/* If we have our own safemalloc (for debugging) */
|
||||
#if defined(SAFEMALLOC)
|
||||
void sf_report_leaked_memory(my_thread_id id);
|
||||
extern my_thread_id (*sf_malloc_dbug_id)(void);
|
||||
#define SAFEMALLOC_REPORT_MEMORY(X) sf_report_leaked_memory(X)
|
||||
#else
|
||||
#define SAFEMALLOC_REPORT_MEMORY(X) do {} while(0)
|
||||
#endif
|
||||
|
||||
typedef void (*MALLOC_SIZE_CB) (long long size, myf my_flags);
|
||||
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, ...);
|
||||
|
@ -323,6 +339,7 @@ typedef struct st_dynamic_array
|
|||
uint elements,max_element;
|
||||
uint alloc_increment;
|
||||
uint size_of_element;
|
||||
myf malloc_flags;
|
||||
} DYNAMIC_ARRAY;
|
||||
|
||||
typedef struct st_my_tmpdir
|
||||
|
@ -768,16 +785,11 @@ 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) init_dynamic_array2(A,B,NULL,C,D)
|
||||
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
|
||||
#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
|
||||
#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
|
||||
#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);
|
||||
/* init_dynamic_array() function is deprecated */
|
||||
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
|
||||
uint init_alloc, uint alloc_increment);
|
||||
uint alloc_increment, myf my_flags);
|
||||
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const uchar * element);
|
||||
extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array);
|
||||
extern uchar *pop_dynamic(DYNAMIC_ARRAY*);
|
||||
|
@ -829,7 +841,7 @@ extern void my_free_lock(void *ptr);
|
|||
#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, size_t block_size,
|
||||
size_t pre_alloc_size);
|
||||
size_t pre_alloc_size, myf my_flags);
|
||||
extern void *alloc_root(MEM_ROOT *mem_root, size_t Size);
|
||||
extern void *multi_alloc_root(MEM_ROOT *mem_root, ...);
|
||||
extern void free_root(MEM_ROOT *root, myf MyFLAGS);
|
||||
|
|
|
@ -68,13 +68,15 @@ typedef struct st_tree {
|
|||
MEM_ROOT mem_root;
|
||||
my_bool with_delete;
|
||||
tree_element_free free;
|
||||
myf my_flags;
|
||||
uint flag;
|
||||
} TREE;
|
||||
|
||||
/* Functions on whole tree */
|
||||
void init_tree(TREE *tree, size_t default_alloc_size, size_t memory_limit,
|
||||
int size, qsort_cmp2 compare, my_bool with_delete,
|
||||
tree_element_free free_element, void *custom_arg);
|
||||
int size, qsort_cmp2 compare,
|
||||
tree_element_free free_element, void *custom_arg,
|
||||
myf my_flags);
|
||||
void delete_tree(TREE*);
|
||||
void reset_tree(TREE*);
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ typedef struct st_handler_check_param
|
|||
|
||||
mysql_mutex_t print_msg_mutex;
|
||||
my_bool need_print_msg_lock;
|
||||
myf malloc_flags;
|
||||
} HA_CHECK;
|
||||
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ enum mysql_option
|
|||
MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
|
||||
MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
|
||||
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
|
||||
MYSQL_PROGRESS_CALLBACK,
|
||||
MYSQL_PROGRESS_CALLBACK, MYSQL_THREAD_SPECIFIC_MALLOC,
|
||||
/* MariaDB options */
|
||||
MYSQL_OPT_NONBLOCK=6000
|
||||
};
|
||||
|
@ -194,7 +194,7 @@ struct st_mysql_options {
|
|||
unsigned long max_allowed_packet;
|
||||
my_bool use_ssl; /* if to use SSL or not */
|
||||
my_bool compress,named_pipe;
|
||||
my_bool unused1;
|
||||
my_bool thread_specific_malloc;
|
||||
my_bool unused2;
|
||||
my_bool unused3;
|
||||
my_bool unused4;
|
||||
|
|
|
@ -28,7 +28,7 @@ typedef struct st_net {
|
|||
unsigned char reading_or_writing;
|
||||
char save_char;
|
||||
char net_skip_rest_factor;
|
||||
my_bool unused1;
|
||||
my_bool thread_specific_malloc;
|
||||
my_bool compress;
|
||||
my_bool unused3;
|
||||
unsigned char *unused;
|
||||
|
@ -80,7 +80,7 @@ enum enum_mysql_set_option
|
|||
MYSQL_OPTION_MULTI_STATEMENTS_ON,
|
||||
MYSQL_OPTION_MULTI_STATEMENTS_OFF
|
||||
};
|
||||
my_bool my_net_init(NET *net, Vio* vio);
|
||||
my_bool my_net_init(NET *net, Vio* vio, unsigned int my_flags);
|
||||
void my_net_local_init(NET *net);
|
||||
void net_end(NET *net);
|
||||
void net_clear(NET *net, my_bool clear_buffer);
|
||||
|
@ -262,7 +262,7 @@ enum mysql_option
|
|||
MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
|
||||
MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
|
||||
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
|
||||
MYSQL_PROGRESS_CALLBACK,
|
||||
MYSQL_PROGRESS_CALLBACK, MYSQL_THREAD_SPECIFIC_MALLOC,
|
||||
MYSQL_OPT_NONBLOCK=6000
|
||||
};
|
||||
struct st_mysql_options_extention;
|
||||
|
@ -282,7 +282,7 @@ struct st_mysql_options {
|
|||
unsigned long max_allowed_packet;
|
||||
my_bool use_ssl;
|
||||
my_bool compress,named_pipe;
|
||||
my_bool unused1;
|
||||
my_bool thread_specific_malloc;
|
||||
my_bool unused2;
|
||||
my_bool unused3;
|
||||
my_bool unused4;
|
||||
|
|
|
@ -330,7 +330,7 @@ typedef struct st_net {
|
|||
unsigned char reading_or_writing;
|
||||
char save_char;
|
||||
char net_skip_rest_factor;
|
||||
my_bool unused1; /* Please remove with the next incompatible ABI change */
|
||||
my_bool thread_specific_malloc;
|
||||
my_bool compress;
|
||||
my_bool unused3; /* Please remove with the next incompatible ABI change. */
|
||||
/*
|
||||
|
@ -465,10 +465,10 @@ enum enum_mysql_set_option
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
my_bool my_net_init(NET *net, Vio* vio);
|
||||
my_bool my_net_init(NET *net, Vio* vio, unsigned int my_flags);
|
||||
void my_net_local_init(NET *net);
|
||||
void net_end(NET *net);
|
||||
void net_clear(NET *net, my_bool clear_buffer);
|
||||
void net_clear(NET *net, my_bool clear_buffer);
|
||||
my_bool net_realloc(NET *net, size_t length);
|
||||
my_bool net_flush(NET *net);
|
||||
my_bool my_net_write(NET *net,const unsigned char *packet, size_t len);
|
||||
|
|
|
@ -1520,8 +1520,8 @@ mysql_stmt_init(MYSQL *mysql)
|
|||
DBUG_RETURN(NULL);
|
||||
}
|
||||
|
||||
init_alloc_root(&stmt->mem_root, 2048, 2048);
|
||||
init_alloc_root(&stmt->result.alloc, 4096, 4096);
|
||||
init_alloc_root(&stmt->mem_root, 2048, 2048, MY_THREAD_SPECIFIC);
|
||||
init_alloc_root(&stmt->result.alloc, 4096, 4096, MY_THREAD_SPECIFIC);
|
||||
stmt->result.alloc.min_malloc= sizeof(MYSQL_ROWS);
|
||||
mysql->stmts= list_add(mysql->stmts, &stmt->list);
|
||||
stmt->list.data= stmt;
|
||||
|
@ -1532,7 +1532,8 @@ 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, 2048, 0);
|
||||
init_alloc_root(&stmt->extension->fields_mem_root, 2048, 0,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
|
||||
DBUG_RETURN(stmt);
|
||||
}
|
||||
|
|
|
@ -415,7 +415,7 @@ int emb_load_querycache_result(THD *thd, Querycache_stream *src)
|
|||
|
||||
if (!data)
|
||||
goto err;
|
||||
init_alloc_root(&data->alloc, 8192,0);
|
||||
init_alloc_root(&data->alloc, 8192,0,0);
|
||||
f_alloc= &data->alloc;
|
||||
|
||||
data->fields= src->load_int();
|
||||
|
|
|
@ -634,7 +634,7 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag)
|
|||
mysql->server_version= server_version;
|
||||
mysql->client_flag= client_flag;
|
||||
//mysql->server_capabilities= client_flag;
|
||||
init_alloc_root(&mysql->field_alloc, 8192, 0);
|
||||
init_alloc_root(&mysql->field_alloc, 8192, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -906,8 +906,9 @@ int Protocol::begin_dataset()
|
|||
if (!data)
|
||||
return 1;
|
||||
alloc= &data->alloc;
|
||||
init_alloc_root(alloc,8192,0); /* Assume rowlength < 8192 */
|
||||
alloc->min_malloc=sizeof(MYSQL_ROWS);
|
||||
/* Assume rowlength < 8192 */
|
||||
init_alloc_root(alloc, 8192, 0, MYF(MY_THREAD_SPECIFIC));
|
||||
alloc->min_malloc= sizeof(MYSQL_ROWS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -3591,9 +3591,10 @@ sub mysql_install_db {
|
|||
verbose => $opt_verbose,
|
||||
) != 0)
|
||||
{
|
||||
my $data= mtr_grab_file($path_bootstrap_log);
|
||||
mtr_error("Error executing mysqld --bootstrap\n" .
|
||||
"Could not install system database from $bootstrap_sql_file\n" .
|
||||
"see $path_bootstrap_log for errors");
|
||||
"The $path_bootstrap_log file contains:\n$data\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1762,7 +1762,9 @@ t1 CREATE TABLE `t1` (
|
|||
`TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000',
|
||||
`STAGE` tinyint(2) NOT NULL DEFAULT '0',
|
||||
`MAX_STAGE` tinyint(2) NOT NULL DEFAULT '0',
|
||||
`PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000'
|
||||
`PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000',
|
||||
`MEMORY_USED` int(7) NOT NULL DEFAULT '0',
|
||||
`EXAMINED_ROWS` int(7) NOT NULL DEFAULT '0'
|
||||
) DEFAULT CHARSET=utf8
|
||||
drop table t1;
|
||||
create temporary table t1 like information_schema.processlist;
|
||||
|
@ -1780,7 +1782,9 @@ t1 CREATE TEMPORARY TABLE `t1` (
|
|||
`TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000',
|
||||
`STAGE` tinyint(2) NOT NULL DEFAULT '0',
|
||||
`MAX_STAGE` tinyint(2) NOT NULL DEFAULT '0',
|
||||
`PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000'
|
||||
`PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000',
|
||||
`MEMORY_USED` int(7) NOT NULL DEFAULT '0',
|
||||
`EXAMINED_ROWS` int(7) NOT NULL DEFAULT '0'
|
||||
) DEFAULT CHARSET=utf8
|
||||
drop table t1;
|
||||
create table t1 like information_schema.character_sets;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
drop table if exists t0, t1, t2, t3, t4;
|
||||
drop view if exists v1;
|
||||
SET @old_debug= @@session.debug;
|
||||
set debug_sync='RESET';
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
@ -12,12 +13,13 @@ show explain for 2000000000;
|
|||
ERROR HY000: Unknown thread id: 2000000000
|
||||
show explain for (select max(a) from t0);
|
||||
ERROR HY000: You may only use constant expressions in this statement
|
||||
SET @old_debug= @@session.debug;
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
show explain for $thr1;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select count(*) from t1 where a < 100000;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -46,9 +48,10 @@ Note 1003 explain select max(c) from t1 where a < 10
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 10 Using index condition; Rowid-ordered scan
|
||||
set optimizer_switch= @show_expl_tmp;
|
||||
set debug_dbug=@old_debug;
|
||||
# UNION, first branch
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
explain select a from t0 A union select a+1 from t0 B;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -61,9 +64,10 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 PRIMARY A ALL NULL NULL NULL NULL 10
|
||||
2 UNION B ALL NULL NULL NULL NULL 10
|
||||
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
|
||||
set debug_dbug=@old_debug;
|
||||
# UNION, second branch
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
explain select a from t0 A union select a+1 from t0 B;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -76,9 +80,10 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 PRIMARY A ALL NULL NULL NULL NULL 10
|
||||
2 UNION B ALL NULL NULL NULL NULL 10
|
||||
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
|
||||
set debug_dbug=@old_debug;
|
||||
# Uncorrelated subquery, select
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select a, (select max(a) from t0 B) from t0 A where a<1;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -88,9 +93,10 @@ Warnings:
|
|||
Note 1003 select a, (select max(a) from t0 B) from t0 A where a<1
|
||||
a (select max(a) from t0 B)
|
||||
0 9
|
||||
set debug_dbug=@old_debug;
|
||||
# Uncorrelated subquery, explain
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
explain select a, (select max(a) from t0 B) from t0 A where a<1;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -101,9 +107,10 @@ Note 1003 explain select a, (select max(a) from t0 B) from t0 A where a<1
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using where
|
||||
2 SUBQUERY B ALL NULL NULL NULL NULL 10
|
||||
set debug_dbug=@old_debug;
|
||||
# correlated subquery, select
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -113,9 +120,10 @@ Warnings:
|
|||
Note 1003 select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1
|
||||
a (select max(a) from t0 b where b.a+a.a<10)
|
||||
0 9
|
||||
set debug_dbug=@old_debug;
|
||||
# correlated subquery, explain
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -125,9 +133,10 @@ Warnings:
|
|||
Note 1003 select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1
|
||||
a (select max(a) from t0 b where b.a+a.a<10)
|
||||
0 9
|
||||
set debug_dbug=@old_debug;
|
||||
# correlated subquery, select, while inside the subquery
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -137,9 +146,10 @@ Warnings:
|
|||
Note 1003 select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1
|
||||
a (select max(a) from t0 b where b.a+a.a<10)
|
||||
0 9
|
||||
set debug_dbug=@old_debug;
|
||||
# correlated subquery, explain, while inside the subquery
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -149,52 +159,57 @@ Warnings:
|
|||
Note 1003 select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1
|
||||
a (select max(a) from t0 b where b.a+a.a<10)
|
||||
0 9
|
||||
set debug_dbug=@old_debug;
|
||||
# correlated subquery, explain, while inside the subquery
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
a (select max(a) from t0 b where b.a+a.a<10)
|
||||
0 9
|
||||
set debug_dbug=@old_debug;
|
||||
# Try to do SHOW EXPLAIN for a query that runs a SET command:
|
||||
# I've found experimentally that select_id==2 here...
|
||||
#
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
set @foo= (select max(a) from t0 where sin(a) >0);
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
set debug_dbug=@old_debug;
|
||||
#
|
||||
# Attempt SHOW EXPLAIN for an UPDATE
|
||||
#
|
||||
create table t2 as select a as a, a as dummy from t0 limit 2;
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
update t2 set dummy=0 where (select max(a) from t0 where t2.a + t0.a <3) >3 ;
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
drop table t2;
|
||||
set debug_dbug=@old_debug;
|
||||
#
|
||||
# Attempt SHOW EXPLAIN for a DELETE
|
||||
#
|
||||
create table t2 as select a as a, a as dummy from t0 limit 2;
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
delete from t2 where (select max(a) from t0 where t2.a + t0.a <3) >3 ;
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
drop table t2;
|
||||
set debug_dbug=@old_debug;
|
||||
#
|
||||
# Multiple SHOW EXPLAIN calls for one select
|
||||
#
|
||||
create table t2 as select a as a, a as dummy from t0 limit 3;
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select t2.a, ((select max(a) from t0 where t2.a + t0.a <3) >3) as SUBQ from t2;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -219,13 +234,14 @@ a SUBQ
|
|||
1 0
|
||||
2 0
|
||||
drop table t2;
|
||||
set debug_dbug=@old_debug;
|
||||
#
|
||||
# SHOW EXPLAIN for SELECT ... ORDER BY with "Using filesort"
|
||||
#
|
||||
explain select * from t0 order by a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using filesort
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
set @show_explain_probe_select_id=1;
|
||||
select * from t0 order by a;
|
||||
show explain for $thr2;
|
||||
|
@ -244,13 +260,14 @@ a
|
|||
7
|
||||
8
|
||||
9
|
||||
set debug_dbug=@old_debug;
|
||||
#
|
||||
# SHOW EXPLAIN for SELECT ... with "Using temporary"
|
||||
#
|
||||
explain select distinct a from t0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using temporary
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
set @show_explain_probe_select_id=1;
|
||||
select distinct a from t0;
|
||||
show explain for $thr2;
|
||||
|
@ -269,13 +286,14 @@ a
|
|||
7
|
||||
8
|
||||
9
|
||||
set debug_dbug=@old_debug;
|
||||
#
|
||||
# SHOW EXPLAIN for SELECT ... with "Using temporary; Using filesort"
|
||||
#
|
||||
explain select distinct a from t0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using temporary
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
set @show_explain_probe_select_id=1;
|
||||
select distinct a from t0;
|
||||
show explain for $thr2;
|
||||
|
@ -294,7 +312,7 @@ a
|
|||
7
|
||||
8
|
||||
9
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
#
|
||||
# MDEV-238: SHOW EXPLAIN: Server crashes in JOIN::print_explain with FROM subquery and GROUP BY
|
||||
#
|
||||
|
@ -304,7 +322,7 @@ explain SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
set debug_dbug='d,show_explain_in_find_all_keys';
|
||||
set debug_dbug='+d,show_explain_in_find_all_keys';
|
||||
SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a;
|
||||
# FIXED by "conservative assumptions about when QEP is available" fix:
|
||||
# NOTE: current code will not show "Using join buffer":
|
||||
|
@ -314,7 +332,7 @@ a
|
|||
1
|
||||
2
|
||||
4
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t2;
|
||||
#
|
||||
# MDEV-239: Assertion `field_types == 0 ... ' failed in Protocol_text::store(double, uint32, String*) with
|
||||
|
@ -329,7 +347,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` join `test`.`t2` group by `test`.`t2`.`a`
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
EXPLAIN EXTENDED SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a ;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -342,7 +360,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` join `test`.`t2` group by `test`.`t2`.`a`
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t2;
|
||||
#
|
||||
# MDEV-240: SHOW EXPLAIN: Assertion `this->optimized == 2' failed in
|
||||
|
@ -359,7 +377,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 PRIMARY t2 ALL NULL NULL NULL NULL 6
|
||||
2 DERIVED t3 system NULL NULL NULL NULL 1
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
SELECT * FROM v1, t2;
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
|
@ -370,14 +388,14 @@ a b
|
|||
8 7
|
||||
8 8
|
||||
8 9
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t2, t3;
|
||||
#
|
||||
# MDEV-267: SHOW EXPLAIN: Server crashes in JOIN::print_explain on most of queries
|
||||
#
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
select sleep(1);
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -386,29 +404,29 @@ Warnings:
|
|||
Note 1003 select sleep(1)
|
||||
sleep(1)
|
||||
0
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
#
|
||||
# Same as above, but try another reason for JOIN to be degenerate
|
||||
#
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
select * from t0 where 1>10;
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
a
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
#
|
||||
# Same as above, but try another reason for JOIN to be degenerate (2)
|
||||
#
|
||||
create table t3(a int primary key);
|
||||
insert into t3 select a from t0;
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
select * from t0,t3 where t3.a=112233;
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
a a
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t3;
|
||||
#
|
||||
# MDEV-270: SHOW EXPLAIN: server crashes in JOIN::print_explain on a query with
|
||||
|
@ -427,7 +445,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
2 SUBQUERY t2 const PRIMARY PRIMARY 4 const 1 Using where
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_do_select';
|
||||
set debug_dbug='+d,show_explain_probe_do_select';
|
||||
SELECT * FROM t2 WHERE a =
|
||||
(SELECT MAX(a) FROM t2
|
||||
WHERE pk= (SELECT MAX(pk) FROM t2 WHERE pk = 3)
|
||||
|
@ -447,7 +465,7 @@ pk a
|
|||
6 7
|
||||
7 7
|
||||
9 7
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t2;
|
||||
#
|
||||
# MDEV-273: SHOW EXPLAIN: server crashes in JOIN::print_explain on a query with impossible WHERE
|
||||
|
@ -479,7 +497,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 PRIMARY t3 ALL NULL NULL NULL NULL 87 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_do_select';
|
||||
set debug_dbug='+d,show_explain_probe_do_select';
|
||||
SELECT count(*) FROM t2, t3
|
||||
WHERE a1 < ALL (
|
||||
SELECT a1 FROM t2
|
||||
|
@ -498,7 +516,7 @@ WHERE a1 IN ( SELECT a1 FROM t2, t4 )
|
|||
)
|
||||
count(*)
|
||||
1740
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t2, t3, t4;
|
||||
#
|
||||
# MDEV-275: SHOW EXPLAIN: server crashes in JOIN::print_explain with IN subquery and aggregate function
|
||||
|
@ -508,12 +526,12 @@ INSERT INTO t2 VALUES
|
|||
(1,5),(2,4),(3,6),(4,9),(5,2),(6,8),(7,4),(8,8),(9,0),(10,43),
|
||||
(11,23),(12,3),(13,45),(14,16),(15,2),(16,33),(17,2),(18,5),(19,9),(20,2);
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
SELECT * FROM t2 WHERE (5, 78) IN (SELECT `a1`, MAX(`a1`) FROM t2 GROUP BY `a1`);
|
||||
show explain for $thr2;
|
||||
ERROR HY000: Target is not running an EXPLAINable command
|
||||
pk a1
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -522,7 +540,7 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1(a INT, KEY(a));
|
||||
INSERT INTO t1 VALUES (3),(1),(5),(1);
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
SELECT 'test' FROM t1 WHERE a=1;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -532,7 +550,7 @@ Note 1003 SELECT 'test' FROM t1 WHERE a=1
|
|||
test
|
||||
test
|
||||
test
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-299: SHOW EXPLAIN: Plan produced by SHOW EXPLAIN changes back and forth during query execution
|
||||
|
@ -550,7 +568,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE A ALL NULL NULL NULL NULL 100 Using where
|
||||
1 SIMPLE B ALL key1 NULL NULL NULL 100 Range checked for each record (index map: 0x1)
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_test_if_quick_select';
|
||||
set debug_dbug='+d,show_explain_probe_test_if_quick_select';
|
||||
select count(*) from t1 A, t1 B where B.key1 < A.col2 and A.col1=3 AND B.col2 + 1 < 100;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -578,7 +596,7 @@ Warnings:
|
|||
Note 1003 select count(*) from t1 A, t1 B where B.key1 < A.col2 and A.col1=3 AND B.col2 + 1 < 100
|
||||
count(*)
|
||||
212
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-297: SHOW EXPLAIN: Server gets stuck until timeout occurs while
|
||||
|
@ -587,7 +605,7 @@ drop table t1;
|
|||
CREATE TABLE t1(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c));
|
||||
INSERT INTO t1 (a) VALUES (3),(1),(5),(1);
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
SHOW INDEX FROM t1;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -598,7 +616,7 @@ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_par
|
|||
t1 1 a 1 a A NULL NULL NULL YES BTREE
|
||||
t1 1 b 1 b A NULL NULL NULL YES BTREE
|
||||
t1 1 c 1 c A NULL NULL NULL YES BTREE
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-324: SHOW EXPLAIN: Plan produced by SHOW EXPLAIN for a query with TEMPTABLE view
|
||||
|
@ -611,7 +629,7 @@ EXPLAIN SELECT a + 1 FROM v1;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 2
|
||||
set debug_dbug='d,show_explain_probe_join_tab_preread';
|
||||
set debug_dbug='+d,show_explain_probe_join_tab_preread';
|
||||
set @show_explain_probe_select_id=1;
|
||||
SELECT a + 1 FROM v1;
|
||||
show explain for $thr2;
|
||||
|
@ -623,7 +641,7 @@ Note 1003 SELECT a + 1 FROM v1
|
|||
a + 1
|
||||
2
|
||||
3
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -639,7 +657,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
set debug_dbug='d,show_explain_probe_union_read';
|
||||
set debug_dbug='+d,show_explain_probe_union_read';
|
||||
SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 );
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -658,7 +676,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
|||
Warnings:
|
||||
Note 1003 SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 )
|
||||
a
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-327: SHOW EXPLAIN: Different select_type in plans produced by SHOW EXPLAIN
|
||||
|
@ -681,7 +699,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 20
|
||||
3 SUBQUERY t2 ALL NULL NULL NULL NULL 20 Using where
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
SELECT * FROM t1, ( SELECT * FROM t2 ) AS alias
|
||||
WHERE a < ALL ( SELECT b FROM t1, t2 WHERE a = b );
|
||||
show explain for $thr2;
|
||||
|
@ -694,7 +712,7 @@ Warnings:
|
|||
Note 1003 SELECT * FROM t1, ( SELECT * FROM t2 ) AS alias
|
||||
WHERE a < ALL ( SELECT b FROM t1, t2 WHERE a = b )
|
||||
a b
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# Test that SHOW EXPLAIN will print 'Distinct'.
|
||||
|
@ -716,7 +734,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary
|
||||
1 SIMPLE t3 ref a a 5 test.t1.a 7 Using index; Distinct
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select distinct t1.a from t1,t3 where t1.a=t3.a;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -727,7 +745,7 @@ Note 1003 select distinct t1.a from t1,t3 where t1.a=t3.a
|
|||
a
|
||||
1
|
||||
2
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t1,t3,t4;
|
||||
#
|
||||
# ---------- SHOW EXPLAIN and permissions -----------------
|
||||
|
@ -738,7 +756,7 @@ grant super on *.* to test2@localhost;
|
|||
# First, make sure that user 'test2' cannot do SHOW EXPLAIN on us
|
||||
#
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select * from t0 where a < 3;
|
||||
show explain for $thr2;
|
||||
ERROR 42000: Access denied; you need (at least one of) the PROCESS privilege(s) for this operation
|
||||
|
@ -751,12 +769,12 @@ a
|
|||
0
|
||||
1
|
||||
2
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
#
|
||||
# Check that user test2 can do SHOW EXPLAIN on its own queries
|
||||
#
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select * from t0 where a < 3;
|
||||
show explain for $thr_con2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -771,8 +789,9 @@ a
|
|||
# Now, grant test2 a PROCESSLIST permission, and see that he's able to observe us
|
||||
#
|
||||
grant process on *.* to test2@localhost;
|
||||
set debug_dbug=@old_debug;
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select * from t0 where a < 3;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -783,7 +802,7 @@ a
|
|||
0
|
||||
1
|
||||
2
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
revoke all privileges on test.* from test2@localhost;
|
||||
drop user test2@localhost;
|
||||
#
|
||||
|
@ -848,7 +867,7 @@ ORDER BY b;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 8 Using sort_union(a,b); Using where; Using filesort
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
SELECT a+SLEEP(0.01) FROM t1
|
||||
WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129
|
||||
ORDER BY b;
|
||||
|
@ -867,8 +886,9 @@ a+SLEEP(0.01)
|
|||
0
|
||||
0
|
||||
0
|
||||
set debug_dbug=@old_debug;
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_do_select';
|
||||
set debug_dbug='+d,show_explain_probe_do_select';
|
||||
SELECT a+SLEEP(0.01) FROM t1
|
||||
WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129
|
||||
ORDER BY b;
|
||||
|
@ -887,7 +907,7 @@ a+SLEEP(0.01)
|
|||
0
|
||||
0
|
||||
0
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-298: SHOW EXPLAIN: Plan returned by SHOW EXPLAIN only contains
|
||||
|
@ -901,7 +921,7 @@ EXPLAIN SELECT a FROM t1 GROUP BY a;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4112 Using temporary; Using filesort
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
SELECT a FROM t1 GROUP BY a;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -925,7 +945,7 @@ a
|
|||
14
|
||||
15
|
||||
16
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-408: SHOW EXPLAIN: Some values are chopped off in SHOW EXPLAIN output
|
||||
|
@ -939,7 +959,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 index_subquery PRIMARY,c c 5 func 1 Using index; Using where
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
SELECT SUM(a + SLEEP(0.1)) FROM t1 WHERE a IN ( SELECT c FROM t2 WHERE d < b ) OR b < 's';
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -949,7 +969,7 @@ Warnings:
|
|||
Note 1003 SELECT SUM(a + SLEEP(0.1)) FROM t1 WHERE a IN ( SELECT c FROM t2 WHERE d < b ) OR b < 's'
|
||||
SUM(a + SLEEP(0.1))
|
||||
7862
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t1, t2;
|
||||
#
|
||||
# MDEV-412: SHOW EXPLAIN: Server crashes in JOIN::print_explain on a query with inner join and ORDER BY the same column twice
|
||||
|
@ -987,7 +1007,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t1 index b b 6 NULL 107 Using where; Using index
|
||||
1 SIMPLE t3 ref PRIMARY PRIMARY 5 test.t1.b 1 Using index
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_do_select';
|
||||
set debug_dbug='+d,show_explain_probe_do_select';
|
||||
SELECT b AS field1, b AS field2 FROM t1, t2, t3 WHERE d = b ORDER BY field1, field2;
|
||||
show explain for $thr2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -997,7 +1017,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
Warnings:
|
||||
Note 1003 SELECT b AS field1, b AS field2 FROM t1, t2, t3 WHERE d = b ORDER BY field1, field2
|
||||
field1 field2
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-423: SHOW EXPLAIN: 'Using where' for a subquery is shown in EXPLAIN, but not in SHOW EXPLAIN output
|
||||
|
@ -1018,7 +1038,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 PRIMARY t2 ALL NULL NULL NULL NULL 20
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 20 Using where
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
SELECT max(a+b+c) FROM t1 AS alias1, ( SELECT * FROM t2 ) AS alias
|
||||
WHERE EXISTS ( SELECT * FROM t3 WHERE b = c ) OR a <= 10;
|
||||
show explain for $thr2;
|
||||
|
@ -1031,7 +1051,7 @@ Note 1003 SELECT max(a+b+c) FROM t1 AS alias1, ( SELECT * FROM t2 ) AS alias
|
|||
WHERE EXISTS ( SELECT * FROM t3 WHERE b = c ) OR a <= 10
|
||||
max(a+b+c)
|
||||
279
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-416: Server crashes in SQL_SELECT::cleanup on EXPLAIN with SUM ( DISTINCT ) in a non-correlated subquery (5.5-show-explain tree)
|
||||
|
@ -1057,7 +1077,7 @@ select hex('
|
|||
hex('ãû')
|
||||
E3FB
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
select * from t0 where length('ãû') = a;
|
||||
set names utf8;
|
||||
show explain for $thr2;
|
||||
|
@ -1068,7 +1088,7 @@ Note 1003 select * from t0 where length('гы') = a
|
|||
set names default;
|
||||
a
|
||||
2
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
set names default;
|
||||
#
|
||||
# MDEV-462: SHOW EXPLAIN: Assertion `table_list->table' fails in find_field_in_table_ref if FOR contains a non-numeric value
|
||||
|
|
|
@ -530,4 +530,9 @@ SELECT @a;
|
|||
@a
|
||||
1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Check that used memory extends if we set a variable
|
||||
#
|
||||
set @var= repeat('a',20000);
|
||||
1
|
||||
End of 5.5 tests
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
let $table= processlist;
|
||||
#
|
||||
# columns of the information_schema table e.g. to use in a select.
|
||||
let $columns= ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS;
|
||||
let $columns= ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS;
|
||||
#
|
||||
# Where clause for an update.
|
||||
let $update_where= WHERE id=1 ;
|
||||
|
@ -159,9 +159,9 @@ WHERE DB = 'information_schema' AND COMMAND = 'Sleep' AND USER = 'ddicttestuser1
|
|||
eval SHOW CREATE TABLE $table;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
eval SHOW $table;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
eval SELECT * FROM $table $select_where ORDER BY id;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
eval SELECT $columns FROM $table $select_where ORDER BY id;
|
||||
--source suite/funcs_1/datadict/datadict_priv.inc
|
||||
--real_sleep 0.3
|
||||
|
@ -179,9 +179,9 @@ connection con100;
|
|||
eval SHOW CREATE TABLE $table;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
eval SHOW $table;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
eval SELECT * FROM $table $select_where ORDER BY id;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
eval SELECT $columns FROM $table $select_where ORDER BY id;
|
||||
--source suite/funcs_1/datadict/datadict_priv.inc
|
||||
--real_sleep 0.3
|
||||
|
@ -205,7 +205,7 @@ connection con100;
|
|||
SHOW GRANTS;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
@ -217,7 +217,7 @@ connect (con101,localhost,ddicttestuser1,ddictpass,information_schema);
|
|||
SHOW GRANTS;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
@ -239,7 +239,7 @@ connect (anonymous1,localhost,"''",,information_schema);
|
|||
SHOW GRANTS;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
@ -261,7 +261,7 @@ connect (con102,localhost,ddicttestuser1,ddictpass,information_schema);
|
|||
SHOW GRANTS;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
@ -287,7 +287,7 @@ if ($fixed_bug_30395)
|
|||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
}
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
@ -308,7 +308,7 @@ connect (con103,localhost,ddicttestuser1,ddictpass,information_schema);
|
|||
SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
@ -330,7 +330,7 @@ connect (con104,localhost,ddicttestuser1,ddictpass,information_schema);
|
|||
SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
@ -377,7 +377,7 @@ connect (con200,localhost,ddicttestuser2,ddictpass,information_schema);
|
|||
SHOW GRANTS FOR 'ddicttestuser2'@'localhost';
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
@ -398,7 +398,7 @@ connect (con201,localhost,ddicttestuser2,ddictpass,information_schema);
|
|||
SHOW GRANTS;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
@ -421,7 +421,7 @@ SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
|
|||
GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost';
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
@ -445,7 +445,7 @@ connect (con108,localhost,ddicttestuser1,ddictpass,information_schema);
|
|||
SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
SHOW processlist;
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
|
||||
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
--real_sleep 0.3
|
||||
|
||||
|
|
|
@ -93,9 +93,9 @@ echo
|
|||
# - INFO must contain the corresponding SHOW/SELECT PROCESSLIST
|
||||
#
|
||||
# 1. Just dump what we get
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS>
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS>
|
||||
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS>
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS>
|
||||
SHOW FULL PROCESSLIST;
|
||||
#
|
||||
# Determine the connection id of the current connection (default)
|
||||
|
@ -166,7 +166,7 @@ let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
|
|||
WHERE COMMAND = 'Sleep' AND USER = 'test_user';
|
||||
--source include/wait_condition.inc
|
||||
# 1. Just dump what we get
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS>
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS>
|
||||
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
|
||||
SHOW FULL PROCESSLIST;
|
||||
|
@ -211,7 +211,7 @@ echo
|
|||
# ----- switch to connection con1 (user = test_user) -----
|
||||
;
|
||||
connection con1;
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS>
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS>
|
||||
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
|
||||
SHOW FULL PROCESSLIST;
|
||||
|
@ -245,7 +245,7 @@ echo
|
|||
;
|
||||
connection con2;
|
||||
# Just dump what we get
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS>
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS>
|
||||
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
|
||||
SHOW FULL PROCESSLIST;
|
||||
|
@ -305,7 +305,7 @@ WHERE ID = @test_user_con2_id AND Command IN('Query','Execute')
|
|||
AND State = 'User sleep' AND INFO IS NOT NULL ;
|
||||
--source include/wait_condition.inc
|
||||
# 1. Just dump what we get
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS>
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS>
|
||||
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
|
||||
SHOW FULL PROCESSLIST;
|
||||
|
@ -376,7 +376,7 @@ let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST
|
|||
#
|
||||
# Expect to see the state 'Waiting for table metadata lock' for the third
|
||||
# connection because the SELECT collides with the WRITE TABLE LOCK.
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS>
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS>
|
||||
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
|
||||
UNLOCK TABLES;
|
||||
#
|
||||
|
@ -435,7 +435,7 @@ echo
|
|||
# SHOW FULL PROCESSLIST Complete statement
|
||||
# SHOW PROCESSLIST statement truncated after 100 char
|
||||
;
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> 9 <TIME_MS>
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS>
|
||||
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
|
||||
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE>
|
||||
SHOW FULL PROCESSLIST;
|
||||
|
|
|
@ -221,10 +221,12 @@ def information_schema PLUGINS PLUGIN_TYPE_VERSION 5 NO varchar 20 60 NULL NULL
|
|||
def information_schema PLUGINS PLUGIN_VERSION 2 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20) select
|
||||
def information_schema PROCESSLIST COMMAND 5 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16) select
|
||||
def information_schema PROCESSLIST DB 4 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
|
||||
def information_schema PROCESSLIST EXAMINED_ROWS 14 0 NO int NULL NULL 10 0 NULL NULL NULL int(7) select
|
||||
def information_schema PROCESSLIST HOST 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
|
||||
def information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
|
||||
def information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
|
||||
def information_schema PROCESSLIST MAX_STAGE 11 0 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(2) select
|
||||
def information_schema PROCESSLIST MEMORY_USED 13 0 NO int NULL NULL 10 0 NULL NULL NULL int(7) select
|
||||
def information_schema PROCESSLIST PROGRESS 12 0.000 NO decimal NULL NULL 7 3 NULL NULL NULL decimal(7,3) select
|
||||
def information_schema PROCESSLIST STAGE 10 0 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(2) select
|
||||
def information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
|
||||
|
@ -699,6 +701,8 @@ NULL information_schema PROCESSLIST TIME_MS decimal NULL NULL NULL NULL decimal(
|
|||
NULL information_schema PROCESSLIST STAGE tinyint NULL NULL NULL NULL tinyint(2)
|
||||
NULL information_schema PROCESSLIST MAX_STAGE tinyint NULL NULL NULL NULL tinyint(2)
|
||||
NULL information_schema PROCESSLIST PROGRESS decimal NULL NULL NULL NULL decimal(7,3)
|
||||
NULL information_schema PROCESSLIST MEMORY_USED int NULL NULL NULL NULL int(7)
|
||||
NULL information_schema PROCESSLIST EXAMINED_ROWS int NULL NULL NULL NULL int(7)
|
||||
3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
|
||||
3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64)
|
||||
3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
|
||||
|
|
|
@ -33,28 +33,30 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` (
|
|||
`TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000',
|
||||
`STAGE` tinyint(2) NOT NULL DEFAULT '0',
|
||||
`MAX_STAGE` tinyint(2) NOT NULL DEFAULT '0',
|
||||
`PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000'
|
||||
`PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000',
|
||||
`MEMORY_USED` int(7) NOT NULL DEFAULT '0',
|
||||
`EXAMINED_ROWS` int(7) NOT NULL DEFAULT '0'
|
||||
) DEFAULT CHARSET=utf8
|
||||
SHOW processlist;
|
||||
Id User Host db Command Time State Info Progress
|
||||
ID root HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
||||
SELECT * FROM processlist ORDER BY id;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID root HOST_NAME information_schema Query TIME executing SELECT * FROM processlist ORDER BY id TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS FROM processlist ORDER BY id;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID root HOST_NAME information_schema Query TIME executing SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS FROM processlist ORDER BY id TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID root HOST_NAME information_schema Query TIME executing SELECT * FROM processlist ORDER BY id TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS FROM processlist ORDER BY id;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID root HOST_NAME information_schema Query TIME executing SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS FROM processlist ORDER BY id TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
CREATE TEMPORARY TABLE test.t_processlist AS SELECT * FROM processlist;
|
||||
UPDATE test.t_processlist SET user='horst' WHERE id=1 ;
|
||||
INSERT INTO processlist SELECT * FROM test.t_processlist;
|
||||
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
|
||||
DROP TABLE test.t_processlist;
|
||||
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS) AS SELECT * FROM processlist WITH CHECK OPTION;
|
||||
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS) AS SELECT * FROM processlist WITH CHECK OPTION;
|
||||
ERROR HY000: CHECK OPTION on non-updatable view 'test.v_processlist'
|
||||
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS) AS SELECT * FROM processlist;
|
||||
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS) AS SELECT * FROM processlist;
|
||||
DROP VIEW test.v_processlist;
|
||||
UPDATE processlist SET user='any_user' WHERE id=1 ;
|
||||
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
|
||||
|
@ -106,25 +108,27 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` (
|
|||
`TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000',
|
||||
`STAGE` tinyint(2) NOT NULL DEFAULT '0',
|
||||
`MAX_STAGE` tinyint(2) NOT NULL DEFAULT '0',
|
||||
`PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000'
|
||||
`PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000',
|
||||
`MEMORY_USED` int(7) NOT NULL DEFAULT '0',
|
||||
`EXAMINED_ROWS` int(7) NOT NULL DEFAULT '0'
|
||||
) DEFAULT CHARSET=utf8
|
||||
SHOW processlist;
|
||||
Id User Host db Command Time State Info Progress
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM processlist ORDER BY id;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM processlist ORDER BY id TIME_MS 0 0 0.000
|
||||
SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS FROM processlist ORDER BY id;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS FROM processlist ORDER BY id TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM processlist ORDER BY id TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS FROM processlist ORDER BY id;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS FROM processlist ORDER BY id TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
CREATE TEMPORARY TABLE test.t_processlist AS SELECT * FROM processlist;
|
||||
UPDATE test.t_processlist SET user='horst' WHERE id=1 ;
|
||||
INSERT INTO processlist SELECT * FROM test.t_processlist;
|
||||
ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema'
|
||||
DROP TABLE test.t_processlist;
|
||||
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS) AS SELECT * FROM processlist WITH CHECK OPTION;
|
||||
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS) AS SELECT * FROM processlist WITH CHECK OPTION;
|
||||
ERROR HY000: CHECK OPTION on non-updatable view 'test.v_processlist'
|
||||
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS) AS SELECT * FROM processlist;
|
||||
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS) AS SELECT * FROM processlist;
|
||||
DROP VIEW test.v_processlist;
|
||||
UPDATE processlist SET user='any_user' WHERE id=1 ;
|
||||
ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema'
|
||||
|
@ -175,8 +179,8 @@ SHOW processlist;
|
|||
Id User Host db Command Time State Info Progress
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
4.2 New connection con101 (ddicttestuser1 with PROCESS privilege)
|
||||
SHOW/SELECT shows all processes/threads.
|
||||
|
@ -190,10 +194,10 @@ ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
|||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
5 Grant PROCESS privilege to anonymous user.
|
||||
connection default (user=root)
|
||||
|
@ -214,11 +218,11 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
|||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
||||
ID HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
6 Revoke PROCESS privilege from ddicttestuser1
|
||||
connection default (user=root)
|
||||
|
@ -238,10 +242,10 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
|||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
7 Revoke PROCESS privilege from anonymous user
|
||||
connection default (user=root)
|
||||
|
@ -256,9 +260,9 @@ SHOW GRANTS FOR ''@'localhost';
|
|||
Grants for @localhost
|
||||
GRANT USAGE ON *.* TO ''@'localhost'
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
8 Grant SUPER (does not imply PROCESS) privilege to ddicttestuser1
|
||||
connection default (user=root)
|
||||
|
@ -278,11 +282,11 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
|||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
9 Revoke SUPER privilege from user ddicttestuser1
|
||||
connection default (user=root)
|
||||
|
@ -304,12 +308,12 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
|||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
10 Grant SUPER privilege with grant option to user ddicttestuser1.
|
||||
connection default (user=root)
|
||||
|
@ -358,18 +362,18 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
|||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
||||
ID ddicttestuser2 HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser2 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser2 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID root HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
11 User ddicttestuser1 revokes PROCESS privilege from user ddicttestuser2
|
||||
connection ddicttestuser1;
|
||||
|
@ -387,9 +391,9 @@ Id User Host db Command Time State Info Progress
|
|||
ID ddicttestuser2 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
||||
ID ddicttestuser2 HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser2 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID ddicttestuser2 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser2 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser2 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
11.2 Revoke SUPER,PROCESS,GRANT OPTION privilege from user ddicttestuser1
|
||||
connection default (user=root)
|
||||
|
@ -416,15 +420,15 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
|||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
12 Revoke the SELECT privilege from user ddicttestuser1
|
||||
connection default (user=root)
|
||||
|
@ -452,16 +456,16 @@ ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
|||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME NULL SHOW processlist TIME_MS
|
||||
SELECT * FROM information_schema.processlist;
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000
|
||||
ID USER HOST DB COMMAND TIME STATE INFO TIME_MS STAGE MAX_STAGE PROGRESS MEMORY_USED EXAMINED_ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Query TIME executing SELECT * FROM information_schema.processlist TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
ID ddicttestuser1 HOST_NAME information_schema Sleep TIME NULL TIME_MS 0 0 0.000 MEMORY ROWS
|
||||
####################################################################################
|
||||
12.2 Revoke only the SELECT privilege on the information_schema from ddicttestuser1.
|
||||
connection default (user=root)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,7 @@
|
|||
# The test would allocate and initialize 5GB of memory
|
||||
# if compiled with debug. It can take a lot of time
|
||||
# of for paging/swapping.
|
||||
--source include/not_debug.inc
|
||||
#--source include/not_debug.inc
|
||||
|
||||
#
|
||||
# Bug#27322 failure to allocate transaction_prealloc_size causes crash
|
||||
|
|
|
@ -42,8 +42,8 @@ if ($dir_bin eq '/usr/') {
|
|||
$dir_docs = "$dir_docs/Docs"; # development tree
|
||||
}
|
||||
}
|
||||
$found_version = "No line 'MySQL source #.#.#'";
|
||||
$found_revision = "No line 'revision-id: .....'";
|
||||
$found_version = "No line 'MySQL source #.#.#' in $dir_docs/INFO_SRC";
|
||||
$found_revision = "No line 'revision-id: .....' in $dir_docs/INFO_SRC";
|
||||
open(I_SRC,"<","$dir_docs/INFO_SRC") or print "Cannot open 'INFO_SRC' in '$dir_docs' (starting from bindir '$dir_bin')\n";
|
||||
while(defined ($line = <I_SRC>)) {
|
||||
if ($line =~ m|^MySQL source \d+\.\d\.\d+|) {$found_version = "Found MySQL version number";}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
drop table if exists t0, t1, t2, t3, t4;
|
||||
drop view if exists v1;
|
||||
--enable_warnings
|
||||
SET @old_debug= @@session.debug;
|
||||
|
||||
#
|
||||
# Testcases in this file do not work with embedded server. The reason for this
|
||||
|
@ -56,6 +57,7 @@ let $thr1=`select connection_id()`;
|
|||
connect (con1, localhost, root,,);
|
||||
connection con1;
|
||||
let $thr2=`select connection_id()`;
|
||||
SET @old_debug= @@session.debug;
|
||||
connection default;
|
||||
|
||||
# SHOW EXPLAIN FOR <idle thread>
|
||||
|
@ -73,7 +75,7 @@ let $wait_condition= select State='show_explain_trap' from information_schema.pr
|
|||
#
|
||||
connection con1;
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send select count(*) from t1 where a < 100000;
|
||||
|
||||
connection default;
|
||||
|
@ -101,95 +103,102 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
set optimizer_switch= @show_expl_tmp;
|
||||
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo # UNION, first branch
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send explain select a from t0 A union select a+1 from t0 B;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
|
||||
--echo # UNION, second branch
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send explain select a from t0 A union select a+1 from t0 B;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
|
||||
--echo # Uncorrelated subquery, select
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send select a, (select max(a) from t0 B) from t0 A where a<1;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
|
||||
--echo # Uncorrelated subquery, explain
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send explain select a, (select max(a) from t0 B) from t0 A where a<1;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo # correlated subquery, select
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo # correlated subquery, explain
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo # correlated subquery, select, while inside the subquery
|
||||
set @show_explain_probe_select_id=2; # <---
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo # correlated subquery, explain, while inside the subquery
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo # correlated subquery, explain, while inside the subquery
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
send select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
|
@ -197,6 +206,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
# TODO: explain in the parent subuqery when the un-correlated child has been
|
||||
# run (and have done irreversible cleanups)
|
||||
|
@ -209,7 +219,7 @@ reap;
|
|||
--echo # I've found experimentally that select_id==2 here...
|
||||
--echo #
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send set @foo= (select max(a) from t0 where sin(a) >0);
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
|
@ -217,13 +227,14 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo #
|
||||
--echo # Attempt SHOW EXPLAIN for an UPDATE
|
||||
--echo #
|
||||
create table t2 as select a as a, a as dummy from t0 limit 2;
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send update t2 set dummy=0 where (select max(a) from t0 where t2.a + t0.a <3) >3 ;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
|
@ -234,13 +245,14 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
drop table t2;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo #
|
||||
--echo # Attempt SHOW EXPLAIN for a DELETE
|
||||
--echo #
|
||||
create table t2 as select a as a, a as dummy from t0 limit 2;
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send delete from t2 where (select max(a) from t0 where t2.a + t0.a <3) >3 ;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
|
@ -251,14 +263,14 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
drop table t2;
|
||||
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo #
|
||||
--echo # Multiple SHOW EXPLAIN calls for one select
|
||||
--echo #
|
||||
create table t2 as select a as a, a as dummy from t0 limit 3;
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send select t2.a, ((select max(a) from t0 where t2.a + t0.a <3) >3) as SUBQ from t2;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
|
@ -268,13 +280,14 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
drop table t2;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo #
|
||||
--echo # SHOW EXPLAIN for SELECT ... ORDER BY with "Using filesort"
|
||||
--echo #
|
||||
explain select * from t0 order by a;
|
||||
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
set @show_explain_probe_select_id=1;
|
||||
send select * from t0 order by a;
|
||||
connection default;
|
||||
|
@ -282,6 +295,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo #
|
||||
--echo # SHOW EXPLAIN for SELECT ... with "Using temporary"
|
||||
|
@ -290,7 +304,7 @@ connection default;
|
|||
explain select distinct a from t0;
|
||||
connection con1;
|
||||
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
set @show_explain_probe_select_id=1;
|
||||
send select distinct a from t0;
|
||||
connection default;
|
||||
|
@ -298,6 +312,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo #
|
||||
--echo # SHOW EXPLAIN for SELECT ... with "Using temporary; Using filesort"
|
||||
|
@ -306,7 +321,7 @@ connection default;
|
|||
explain select distinct a from t0;
|
||||
connection con1;
|
||||
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
set @show_explain_probe_select_id=1;
|
||||
send select distinct a from t0;
|
||||
connection default;
|
||||
|
@ -314,7 +329,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-238: SHOW EXPLAIN: Server crashes in JOIN::print_explain with FROM subquery and GROUP BY
|
||||
|
@ -323,7 +338,7 @@ CREATE TABLE t2 ( a INT );
|
|||
INSERT INTO t2 VALUES (1),(2),(1),(4),(2);
|
||||
explain SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a;
|
||||
|
||||
set debug_dbug='d,show_explain_in_find_all_keys';
|
||||
set debug_dbug='+d,show_explain_in_find_all_keys';
|
||||
send SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a;
|
||||
|
||||
connection default;
|
||||
|
@ -334,7 +349,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t2;
|
||||
|
||||
|
||||
|
@ -350,7 +365,7 @@ INSERT INTO t2 VALUES (1),(2),(1),(4),(2);
|
|||
EXPLAIN EXTENDED SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a ;
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
send EXPLAIN EXTENDED SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a ;
|
||||
|
||||
connection default;
|
||||
|
@ -358,7 +373,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t2;
|
||||
|
||||
|
||||
|
@ -374,7 +389,7 @@ INSERT INTO t2 VALUES (4),(5),(6),(7),(8),(9);
|
|||
explain SELECT * FROM v1, t2;
|
||||
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
send SELECT * FROM v1, t2;
|
||||
|
||||
connection default;
|
||||
|
@ -383,7 +398,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t2, t3;
|
||||
|
||||
|
@ -391,21 +406,21 @@ DROP TABLE t2, t3;
|
|||
--echo # MDEV-267: SHOW EXPLAIN: Server crashes in JOIN::print_explain on most of queries
|
||||
--echo #
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
send select sleep(1);
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Same as above, but try another reason for JOIN to be degenerate
|
||||
--echo #
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
send select * from t0 where 1>10;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
|
@ -413,7 +428,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo #
|
||||
--echo # Same as above, but try another reason for JOIN to be degenerate (2)
|
||||
|
@ -421,7 +436,7 @@ set debug_dbug='';
|
|||
create table t3(a int primary key);
|
||||
insert into t3 select a from t0;
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
send select * from t0,t3 where t3.a=112233;
|
||||
connection default;
|
||||
--source include/wait_condition.inc
|
||||
|
@ -429,7 +444,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t3;
|
||||
|
||||
--echo #
|
||||
|
@ -448,7 +463,7 @@ explain SELECT * FROM t2 WHERE a =
|
|||
);
|
||||
|
||||
set @show_explain_probe_select_id=2;
|
||||
set debug_dbug='d,show_explain_probe_do_select';
|
||||
set debug_dbug='+d,show_explain_probe_do_select';
|
||||
send SELECT * FROM t2 WHERE a =
|
||||
(SELECT MAX(a) FROM t2
|
||||
WHERE pk= (SELECT MAX(pk) FROM t2 WHERE pk = 3)
|
||||
|
@ -458,7 +473,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t2;
|
||||
|
||||
|
||||
|
@ -491,7 +506,7 @@ WHERE a1 < ALL (
|
|||
);
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_do_select';
|
||||
set debug_dbug='+d,show_explain_probe_do_select';
|
||||
send
|
||||
SELECT count(*) FROM t2, t3
|
||||
WHERE a1 < ALL (
|
||||
|
@ -504,7 +519,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t2, t3, t4;
|
||||
|
||||
--echo #
|
||||
|
@ -516,7 +531,7 @@ INSERT INTO t2 VALUES
|
|||
(11,23),(12,3),(13,45),(14,16),(15,2),(16,33),(17,2),(18,5),(19,9),(20,2);
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_end';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_end';
|
||||
send
|
||||
SELECT * FROM t2 WHERE (5, 78) IN (SELECT `a1`, MAX(`a1`) FROM t2 GROUP BY `a1`);
|
||||
connection default;
|
||||
|
@ -525,10 +540,9 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
DROP TABLE t2;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
|
@ -538,7 +552,7 @@ CREATE TABLE t1(a INT, KEY(a));
|
|||
INSERT INTO t1 VALUES (3),(1),(5),(1);
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
|
||||
send SELECT 'test' FROM t1 WHERE a=1;
|
||||
connection default;
|
||||
|
@ -546,7 +560,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
@ -570,7 +584,7 @@ set join_cache_level=0;
|
|||
explain select count(*) from t1 A, t1 B where B.key1 < A.col2 and A.col1=3 AND B.col2 + 1 < 100;
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_test_if_quick_select';
|
||||
set debug_dbug='+d,show_explain_probe_test_if_quick_select';
|
||||
|
||||
send
|
||||
select count(*) from t1 A, t1 B where B.key1 < A.col2 and A.col1=3 AND B.col2 + 1 < 100;
|
||||
|
@ -587,7 +601,7 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
|
@ -598,7 +612,7 @@ CREATE TABLE t1(a INT, b INT, c INT, KEY(a), KEY(b), KEY(c));
|
|||
INSERT INTO t1 (a) VALUES (3),(1),(5),(1);
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
|
||||
send SHOW INDEX FROM t1;
|
||||
connection default;
|
||||
|
@ -606,7 +620,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
@ -620,7 +634,7 @@ CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
|
|||
|
||||
EXPLAIN SELECT a + 1 FROM v1;
|
||||
|
||||
set debug_dbug='d,show_explain_probe_join_tab_preread';
|
||||
set debug_dbug='+d,show_explain_probe_join_tab_preread';
|
||||
set @show_explain_probe_select_id=1;
|
||||
|
||||
send
|
||||
|
@ -630,7 +644,7 @@ connection default;
|
|||
evalp show explain for $thr2;
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
@ -646,7 +660,7 @@ INSERT INTO t1 VALUES (4),(6);
|
|||
EXPLAIN
|
||||
SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 );
|
||||
|
||||
set debug_dbug='d,show_explain_probe_union_read';
|
||||
set debug_dbug='+d,show_explain_probe_union_read';
|
||||
send
|
||||
SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 );
|
||||
|
||||
|
@ -660,8 +674,7 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
|
||||
set debug_dbug='';
|
||||
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
|
@ -683,7 +696,7 @@ SELECT * FROM t1, ( SELECT * FROM t2 ) AS alias
|
|||
WHERE a < ALL ( SELECT b FROM t1, t2 WHERE a = b );
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
--send
|
||||
SELECT * FROM t1, ( SELECT * FROM t2 ) AS alias
|
||||
WHERE a < ALL ( SELECT b FROM t1, t2 WHERE a = b );
|
||||
|
@ -694,7 +707,7 @@ evalp show explain for $thr2;
|
|||
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo #
|
||||
|
@ -717,7 +730,7 @@ insert into t3 select * from t4;
|
|||
explain select distinct t1.a from t1,t3 where t1.a=t3.a;
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
--send
|
||||
select distinct t1.a from t1,t3 where t1.a=t3.a;
|
||||
connection default;
|
||||
|
@ -726,7 +739,7 @@ evalp show explain for $thr2;
|
|||
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
drop table t1,t3,t4;
|
||||
|
||||
|
@ -744,7 +757,7 @@ connection con1;
|
|||
--echo # First, make sure that user 'test2' cannot do SHOW EXPLAIN on us
|
||||
--echo #
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send
|
||||
select * from t0 where a < 3;
|
||||
|
||||
|
@ -760,7 +773,7 @@ evalp show explain for $thr2;
|
|||
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
--echo #
|
||||
--echo # Check that user test2 can do SHOW EXPLAIN on its own queries
|
||||
|
@ -770,7 +783,7 @@ connect (con3, localhost, test2,,);
|
|||
connection con2;
|
||||
let $thr_con2=`select connection_id()`;
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send
|
||||
select * from t0 where a < 3;
|
||||
|
||||
|
@ -796,9 +809,10 @@ disconnect con2;
|
|||
grant process on *.* to test2@localhost;
|
||||
connect (con2, localhost, test2,,);
|
||||
connection con1;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
send
|
||||
select * from t0 where a < 3;
|
||||
|
||||
|
@ -810,7 +824,7 @@ evalp show explain for $thr2;
|
|||
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
revoke all privileges on test.* from test2@localhost;
|
||||
drop user test2@localhost;
|
||||
|
@ -890,7 +904,7 @@ WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129
|
|||
ORDER BY b;
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
--send
|
||||
SELECT a+SLEEP(0.01) FROM t1
|
||||
WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129
|
||||
|
@ -902,9 +916,10 @@ evalp show explain for $thr2;
|
|||
|
||||
connection con1;
|
||||
reap;
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_do_select';
|
||||
set debug_dbug='+d,show_explain_probe_do_select';
|
||||
--send
|
||||
SELECT a+SLEEP(0.01) FROM t1
|
||||
WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129
|
||||
|
@ -917,7 +932,7 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
@ -933,7 +948,7 @@ INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12, t1 t13;
|
|||
EXPLAIN SELECT a FROM t1 GROUP BY a;
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
--send
|
||||
SELECT a FROM t1 GROUP BY a;
|
||||
|
||||
|
@ -944,7 +959,7 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
@ -960,7 +975,7 @@ INSERT INTO t2 VALUES (86,'English'),(87,'Russian');
|
|||
explain SELECT SUM(a + SLEEP(0.1)) FROM t1 WHERE a IN ( SELECT c FROM t2 WHERE d < b ) OR b < 's';
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
--send
|
||||
SELECT SUM(a + SLEEP(0.1)) FROM t1 WHERE a IN ( SELECT c FROM t2 WHERE d < b ) OR b < 's';
|
||||
|
||||
|
@ -971,8 +986,7 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
|
||||
set debug_dbug='';
|
||||
|
||||
set debug_dbug=@old_debug;
|
||||
drop table t1, t2;
|
||||
|
||||
--echo #
|
||||
|
@ -1011,7 +1025,7 @@ explain
|
|||
SELECT b AS field1, b AS field2 FROM t1, t2, t3 WHERE d = b ORDER BY field1, field2;
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_do_select';
|
||||
set debug_dbug='+d,show_explain_probe_do_select';
|
||||
|
||||
send
|
||||
SELECT b AS field1, b AS field2 FROM t1, t2, t3 WHERE d = b ORDER BY field1, field2;
|
||||
|
@ -1023,7 +1037,7 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
|
@ -1047,7 +1061,7 @@ SELECT max(a+b+c) FROM t1 AS alias1, ( SELECT * FROM t2 ) AS alias
|
|||
WHERE EXISTS ( SELECT * FROM t3 WHERE b = c ) OR a <= 10;
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
|
||||
send
|
||||
SELECT max(a+b+c) FROM t1 AS alias1, ( SELECT * FROM t2 ) AS alias
|
||||
|
@ -1060,8 +1074,7 @@ evalp show explain for $thr2;
|
|||
connection con1;
|
||||
reap;
|
||||
|
||||
set debug_dbug='';
|
||||
|
||||
set debug_dbug=@old_debug;
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
|
@ -1088,7 +1101,7 @@ select charset('
|
|||
select hex('ãû');
|
||||
|
||||
set @show_explain_probe_select_id=1;
|
||||
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||
set debug_dbug='+d,show_explain_probe_join_exec_start';
|
||||
|
||||
send
|
||||
select * from t0 where length('ãû') = a;
|
||||
|
@ -1103,7 +1116,7 @@ connection con1;
|
|||
# The constant should be two letters, the last looking like 'bl'
|
||||
reap;
|
||||
|
||||
set debug_dbug='';
|
||||
set debug_dbug=@old_debug;
|
||||
set names default;
|
||||
|
||||
--echo #
|
||||
|
|
|
@ -452,4 +452,19 @@ SELECT DISTINCT POW(COUNT(distinct a), @a:=(SELECT 1 FROM t1 LEFT JOIN t1 AS t2
|
|||
SELECT @a;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Check that used memory extends if we set a variable
|
||||
--echo #
|
||||
|
||||
# Execute twice so number stablizes a bit
|
||||
let $tmp= `select memory_used from information_schema.processlist`;
|
||||
let $tmp= `select memory_used from information_schema.processlist`;
|
||||
set @var= repeat('a',20000);
|
||||
let $tmp2= `select memory_used from information_schema.processlist`;
|
||||
--disable_query_log
|
||||
--disable_column_names
|
||||
eval select $tmp < $tmp2;
|
||||
--enable_column_names
|
||||
--enable_query_log
|
||||
|
||||
--echo End of 5.5 tests
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
init_buffer Initial buffer pointer
|
||||
init_alloc Number of initial elements
|
||||
alloc_increment Increment for adding new elements
|
||||
my_flags Flags to my_malloc
|
||||
|
||||
DESCRIPTION
|
||||
init_dynamic_array() initiates array and allocate space for
|
||||
|
@ -42,7 +43,7 @@
|
|||
|
||||
my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
|
||||
void *init_buffer, uint init_alloc,
|
||||
uint alloc_increment)
|
||||
uint alloc_increment, myf my_flags)
|
||||
{
|
||||
DBUG_ENTER("init_dynamic_array2");
|
||||
if (!alloc_increment)
|
||||
|
@ -55,6 +56,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->malloc_flags= my_flags;
|
||||
if ((array->buffer= init_buffer))
|
||||
DBUG_RETURN(FALSE);
|
||||
/*
|
||||
|
@ -62,18 +64,12 @@ 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, MYF(0))))
|
||||
!(array->buffer= (uchar*) my_malloc(element_size*init_alloc,
|
||||
MYF(my_flags))))
|
||||
array->max_element=0;
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
|
||||
uint init_alloc, uint alloc_increment)
|
||||
{
|
||||
/* placeholder to preserve ABI */
|
||||
return my_init_dynamic_array_ci(array, element_size, init_alloc,
|
||||
alloc_increment);
|
||||
}
|
||||
/*
|
||||
Insert element at the end of array. Allocate memory if needed.
|
||||
|
||||
|
@ -137,7 +133,7 @@ uchar *alloc_dynamic(DYNAMIC_ARRAY *array)
|
|||
if (!(new_ptr= (char *) my_malloc((array->max_element+
|
||||
array->alloc_increment) *
|
||||
array->size_of_element,
|
||||
MYF(MY_WME))))
|
||||
MYF(array->malloc_flags | MY_WME))))
|
||||
DBUG_RETURN(0);
|
||||
memcpy(new_ptr, array->buffer,
|
||||
array->elements * array->size_of_element);
|
||||
|
@ -146,7 +142,8 @@ uchar *alloc_dynamic(DYNAMIC_ARRAY *array)
|
|||
my_realloc(array->buffer,(array->max_element+
|
||||
array->alloc_increment)*
|
||||
array->size_of_element,
|
||||
MYF(MY_WME | MY_ALLOW_ZERO_PTR))))
|
||||
MYF(MY_WME | MY_ALLOW_ZERO_PTR |
|
||||
array->malloc_flags))))
|
||||
DBUG_RETURN(0);
|
||||
array->buffer= (uchar*) new_ptr;
|
||||
array->max_element+=array->alloc_increment;
|
||||
|
@ -242,14 +239,15 @@ my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements)
|
|||
*/
|
||||
if (!(new_ptr= (uchar *) my_malloc(size *
|
||||
array->size_of_element,
|
||||
MYF(MY_WME))))
|
||||
MYF(array->malloc_flags | MY_WME))))
|
||||
DBUG_RETURN(0);
|
||||
memcpy(new_ptr, array->buffer,
|
||||
array->elements * array->size_of_element);
|
||||
}
|
||||
else if (!(new_ptr= (uchar*) my_realloc(array->buffer,size*
|
||||
array->size_of_element,
|
||||
MYF(MY_WME | MY_ALLOW_ZERO_PTR))))
|
||||
MYF(MY_WME | MY_ALLOW_ZERO_PTR |
|
||||
array->malloc_flags))))
|
||||
DBUG_RETURN(TRUE);
|
||||
array->buffer= new_ptr;
|
||||
array->max_element= size;
|
||||
|
@ -347,7 +345,7 @@ void freeze_size(DYNAMIC_ARRAY *array)
|
|||
{
|
||||
array->buffer=(uchar*) my_realloc(array->buffer,
|
||||
elements*array->size_of_element,
|
||||
MYF(MY_WME));
|
||||
MYF(MY_WME | array->malloc_flags));
|
||||
array->max_element=elements;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -520,7 +520,7 @@ int my_load_defaults(const char *conf_file, const char **groups,
|
|||
uint args_sep= my_getopt_use_args_separator ? 1 : 0;
|
||||
DBUG_ENTER("load_defaults");
|
||||
|
||||
init_alloc_root(&alloc,512,0);
|
||||
init_alloc_root(&alloc, 512, 0, 0);
|
||||
if ((dirs= init_default_directories(&alloc)) == NULL)
|
||||
goto err;
|
||||
/*
|
||||
|
@ -566,7 +566,7 @@ int my_load_defaults(const char *conf_file, const char **groups,
|
|||
for (; *groups ; groups++)
|
||||
group.count++;
|
||||
|
||||
if (my_init_dynamic_array(&args, sizeof(char*),*argc, 32))
|
||||
if (my_init_dynamic_array(&args, sizeof(char*),*argc, 32, 0))
|
||||
goto err;
|
||||
|
||||
ctx.alloc= &alloc;
|
||||
|
@ -1043,7 +1043,7 @@ void my_print_default_files(const char *conf_file)
|
|||
{
|
||||
const char **dirs;
|
||||
MEM_ROOT alloc;
|
||||
init_alloc_root(&alloc,512,0);
|
||||
init_alloc_root(&alloc, 512, 0, 0);
|
||||
|
||||
if ((dirs= init_default_directories(&alloc)) == NULL)
|
||||
{
|
||||
|
|
|
@ -89,8 +89,10 @@ _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
|
|||
hash->free=free_element;
|
||||
hash->flags=flags;
|
||||
hash->charset=charset;
|
||||
res= my_init_dynamic_array_ci(&hash->array,
|
||||
sizeof(HASH_LINK), size, growth_size);
|
||||
res= my_init_dynamic_array2(&hash->array,
|
||||
sizeof(HASH_LINK), NULL, size, growth_size,
|
||||
MYF((flags & HASH_THREAD_SPECIFIC ?
|
||||
MY_THREAD_SPECIFIC : 0)));
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
|
|
|
@ -342,8 +342,10 @@ static my_bool type_and_offset_store_num(uchar *place, size_t offset_size,
|
|||
int3store(place, val);
|
||||
break;
|
||||
case 4:
|
||||
#if SIZEOF_SIZE_T > 4
|
||||
if (offset >= 0x1fffffff) /* all 1 value is reserved */
|
||||
return TRUE;
|
||||
#endif
|
||||
int4store(place, val);
|
||||
break;
|
||||
default:
|
||||
|
@ -381,8 +383,10 @@ static my_bool type_and_offset_store_named(uchar *place, size_t offset_size,
|
|||
int4store(place, val);
|
||||
break;
|
||||
case 5:
|
||||
#if SIZEOF_SIZE_T > 4
|
||||
if (offset >= 0xfffffffffull) /* all 1 value is reserved */
|
||||
return TRUE;
|
||||
#endif
|
||||
int5store(place, val);
|
||||
break;
|
||||
case 1:
|
||||
|
@ -482,8 +486,10 @@ static size_t dynamic_column_offset_bytes_named(size_t data_length)
|
|||
return 3;
|
||||
if (data_length < 0xfffffff) /* all 1 value is reserved */
|
||||
return 4;
|
||||
#if SIZEOF_SIZE_T > 4
|
||||
if (data_length < 0xfffffffffull) /* all 1 value is reserved */
|
||||
return 5;
|
||||
#endif
|
||||
return MAX_OFFSET_LENGTH_NM + 1; /* For an error generation */
|
||||
}
|
||||
|
||||
|
@ -2403,7 +2409,8 @@ dynamic_column_list(DYNAMIC_COLUMN *str, DYNAMIC_ARRAY *array_of_uint)
|
|||
str->length)
|
||||
return ER_DYNCOL_FORMAT;
|
||||
|
||||
if (init_dynamic_array(array_of_uint, sizeof(uint), header.column_count, 0))
|
||||
if (my_init_dynamic_array(array_of_uint, sizeof(uint), header.column_count,
|
||||
0, 0))
|
||||
return ER_DYNCOL_RESOURCE;
|
||||
|
||||
for (i= 0, read= header.header;
|
||||
|
|
|
@ -30,7 +30,7 @@ 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))
|
||||
if (my_init_dynamic_array(&tmpdir->full_list, sizeof(char*), 1, 5, 0))
|
||||
goto err;
|
||||
if (!pathlist || !pathlist[0])
|
||||
{
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
#undef EXTRA_DEBUG
|
||||
#define EXTRA_DEBUG
|
||||
|
||||
/* data packed in MEM_ROOT -> min_malloc */
|
||||
|
||||
#define MALLOC_FLAG(A) ((A & 1) ? MY_THREAD_SPECIFIC : 0)
|
||||
|
||||
/*
|
||||
Initialize memory root
|
||||
|
||||
|
@ -34,6 +38,7 @@
|
|||
should be no less than ALLOC_ROOT_MIN_BLOCK_SIZE)
|
||||
pre_alloc_size - if non-0, then size of block that should be
|
||||
pre-allocated during memory root initialization.
|
||||
my_flags MY_THREAD_SPECIFIC flag for my_malloc
|
||||
|
||||
DESCRIPTION
|
||||
This function prepares memory root for further use, sets initial size of
|
||||
|
@ -41,17 +46,24 @@
|
|||
Altough error can happen during execution of this function if
|
||||
pre_alloc_size is non-0 it won't be reported. Instead it will be
|
||||
reported as error in first alloc_root() on this memory root.
|
||||
|
||||
We don't want to change the structure size for MEM_ROOT.
|
||||
Because of this, we store in MY_THREAD_SPECIFIC as bit 1 in block_size
|
||||
*/
|
||||
|
||||
void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
|
||||
size_t pre_alloc_size __attribute__((unused)))
|
||||
size_t pre_alloc_size __attribute__((unused)),
|
||||
myf my_flags)
|
||||
{
|
||||
DBUG_ENTER("init_alloc_root");
|
||||
DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root));
|
||||
|
||||
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;
|
||||
mem_root->block_size= (block_size - ALLOC_ROOT_MIN_BLOCK_SIZE) & ~1;
|
||||
if (test(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;
|
||||
|
@ -61,7 +73,7 @@ void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
|
|||
{
|
||||
if ((mem_root->free= mem_root->pre_alloc=
|
||||
(USED_MEM*) my_malloc(pre_alloc_size+ ALIGN_SIZE(sizeof(USED_MEM)),
|
||||
MYF(0))))
|
||||
MYF(my_flags))))
|
||||
{
|
||||
mem_root->free->size= pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM));
|
||||
mem_root->free->left= pre_alloc_size;
|
||||
|
@ -72,7 +84,6 @@ void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
|
|||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
SYNOPSIS
|
||||
reset_root_defaults()
|
||||
|
@ -95,7 +106,8 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
|
|||
{
|
||||
DBUG_ASSERT(alloc_root_inited(mem_root));
|
||||
|
||||
mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE;
|
||||
mem_root->block_size= (((block_size - ALLOC_ROOT_MIN_BLOCK_SIZE) & ~1) |
|
||||
(mem_root->block_size & 1));
|
||||
#if !(defined(HAVE_valgrind) && defined(EXTRA_DEBUG))
|
||||
if (pre_alloc_size)
|
||||
{
|
||||
|
@ -126,7 +138,9 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
|
|||
prev= &mem->next;
|
||||
}
|
||||
/* Allocate new prealloc block and add it to the end of free list */
|
||||
if ((mem= (USED_MEM *) my_malloc(size, MYF(0))))
|
||||
if ((mem= (USED_MEM *) my_malloc(size,
|
||||
MYF(MALLOC_FLAG(mem_root->
|
||||
block_size)))))
|
||||
{
|
||||
mem->size= size;
|
||||
mem->left= pre_alloc_size;
|
||||
|
@ -163,7 +177,9 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
|
|||
});
|
||||
|
||||
length+=ALIGN_SIZE(sizeof(USED_MEM));
|
||||
if (!(next = (USED_MEM*) my_malloc(length,MYF(MY_WME | ME_FATALERROR))))
|
||||
if (!(next = (USED_MEM*) my_malloc(length,
|
||||
MYF(MY_WME | ME_FATALERROR |
|
||||
MALLOC_FLAG(mem_root->block_size)))))
|
||||
{
|
||||
if (mem_root->error_handler)
|
||||
(*mem_root->error_handler)();
|
||||
|
@ -210,11 +226,14 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
|
|||
}
|
||||
if (! next)
|
||||
{ /* Time to alloc new block */
|
||||
block_size= mem_root->block_size * (mem_root->block_num >> 2);
|
||||
block_size= (mem_root->block_size & ~1) * (mem_root->block_num >> 2);
|
||||
get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
|
||||
get_size= max(get_size, block_size);
|
||||
|
||||
if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME | ME_FATALERROR))))
|
||||
if (!(next = (USED_MEM*) my_malloc(get_size,
|
||||
MYF(MY_WME | ME_FATALERROR |
|
||||
MALLOC_FLAG(mem_root->
|
||||
block_size)))))
|
||||
{
|
||||
if (mem_root->error_handler)
|
||||
(*mem_root->error_handler)();
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
int my_chmod(const char *name, mode_t mode, myf my_flags)
|
||||
{
|
||||
DBUG_ENTER("my_chmod");
|
||||
DBUG_PRINT("my",("name: %s mode: %lu flags: %d", name, (ulong) mode,
|
||||
DBUG_PRINT("my",("name: %s mode: %lu flags: %lu", name, (ulong) mode,
|
||||
my_flags));
|
||||
|
||||
if (chmod(name, mode))
|
||||
|
|
|
@ -43,7 +43,7 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
|
|||
my_off_t oldsize;
|
||||
uchar buff[IO_SIZE];
|
||||
DBUG_ENTER("my_chsize");
|
||||
DBUG_PRINT("my",("fd: %d length: %lu MyFlags: %d",fd,(ulong) newlength,
|
||||
DBUG_PRINT("my",("fd: %d length: %lu MyFlags: %lu",fd,(ulong) newlength,
|
||||
MyFlags));
|
||||
|
||||
if ((oldsize= my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME+MY_FAE))) == newlength)
|
||||
|
|
|
@ -61,7 +61,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
|
|||
MY_STAT stat_buff,new_stat_buff;
|
||||
my_bool file_created= 0;
|
||||
DBUG_ENTER("my_copy");
|
||||
DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
|
||||
DBUG_PRINT("my",("from %s to %s MyFlags %lu", from, to, MyFlags));
|
||||
|
||||
from_file=to_file= -1;
|
||||
DBUG_ASSERT(!(MyFlags & (MY_FNABP | MY_NABP))); /* for my_read/my_write */
|
||||
|
|
|
@ -38,7 +38,7 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
|
|||
{
|
||||
int fd, rc;
|
||||
DBUG_ENTER("my_create");
|
||||
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d",
|
||||
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %lu",
|
||||
FileName, CreateFlags, access_flags, MyFlags));
|
||||
#if defined(_WIN32)
|
||||
fd= my_win_open(FileName, access_flags | O_CREAT);
|
||||
|
|
|
@ -21,7 +21,7 @@ int my_delete(const char *name, myf MyFlags)
|
|||
{
|
||||
int err;
|
||||
DBUG_ENTER("my_delete");
|
||||
DBUG_PRINT("my",("name %s MyFlags %d", name, MyFlags));
|
||||
DBUG_PRINT("my",("name %s MyFlags %lu", name, MyFlags));
|
||||
|
||||
if ((err = unlink(name)) == -1)
|
||||
{
|
||||
|
|
|
@ -75,7 +75,7 @@ void my_error(int nr, myf MyFlags, ...)
|
|||
va_list args;
|
||||
char ebuff[ERRMSGSIZE];
|
||||
DBUG_ENTER("my_error");
|
||||
DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d", nr, MyFlags, errno));
|
||||
DBUG_PRINT("my", ("nr: %d MyFlags: %lu errno: %d", nr, MyFlags, errno));
|
||||
|
||||
/* Search for the error messages array, which could contain the message. */
|
||||
for (meh_p= my_errmsgs_list; meh_p; meh_p= meh_p->meh_next)
|
||||
|
@ -114,7 +114,7 @@ void my_printf_error(uint error, const char *format, myf MyFlags, ...)
|
|||
va_list args;
|
||||
char ebuff[ERRMSGSIZE];
|
||||
DBUG_ENTER("my_printf_error");
|
||||
DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d format: %s",
|
||||
DBUG_PRINT("my", ("nr: %d MyFlags: %lu errno: %d format: %s",
|
||||
error, MyFlags, errno, format));
|
||||
|
||||
va_start(args,MyFlags);
|
||||
|
@ -140,7 +140,7 @@ void my_printv_error(uint error, const char *format, myf MyFlags, va_list ap)
|
|||
{
|
||||
char ebuff[ERRMSGSIZE];
|
||||
DBUG_ENTER("my_printv_error");
|
||||
DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d format: %s",
|
||||
DBUG_PRINT("my", ("nr: %d MyFlags: %lu errno: %d format: %s",
|
||||
error, MyFlags, errno, format));
|
||||
|
||||
(void) my_vsnprintf(ebuff, sizeof(ebuff), format, ap);
|
||||
|
|
|
@ -44,7 +44,7 @@ FILE *my_fopen(const char *filename, int flags, myf MyFlags)
|
|||
FILE *fd;
|
||||
char type[5];
|
||||
DBUG_ENTER("my_fopen");
|
||||
DBUG_PRINT("my",("Name: '%s' flags: %d MyFlags: %d",
|
||||
DBUG_PRINT("my",("Name: '%s' flags: %d MyFlags: %lu",
|
||||
filename, flags, MyFlags));
|
||||
|
||||
make_ftype(type,flags);
|
||||
|
@ -229,7 +229,7 @@ int my_fclose(FILE *fd, myf MyFlags)
|
|||
{
|
||||
int err,file;
|
||||
DBUG_ENTER("my_fclose");
|
||||
DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d", (long) fd, MyFlags));
|
||||
DBUG_PRINT("my",("stream: 0x%lx MyFlags: %lu", (long) fd, MyFlags));
|
||||
|
||||
mysql_mutex_lock(&THR_LOCK_open);
|
||||
file= my_fileno(fd);
|
||||
|
@ -265,7 +265,7 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
|
|||
FILE *fd;
|
||||
char type[5];
|
||||
DBUG_ENTER("my_fdopen");
|
||||
DBUG_PRINT("my",("fd: %d Flags: %d MyFlags: %d",
|
||||
DBUG_PRINT("my",("fd: %d Flags: %d MyFlags: %lu",
|
||||
Filedes, Flags, MyFlags));
|
||||
|
||||
make_ftype(type,Flags);
|
||||
|
|
|
@ -46,7 +46,7 @@ size_t my_fread(FILE *stream, uchar *Buffer, size_t Count, myf MyFlags)
|
|||
{
|
||||
size_t readbytes;
|
||||
DBUG_ENTER("my_fread");
|
||||
DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d",
|
||||
DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %lu",
|
||||
(long) stream, (long) Buffer, (uint) Count, MyFlags));
|
||||
|
||||
if ((readbytes= fread(Buffer, sizeof(char), Count, stream)) != Count)
|
||||
|
@ -94,7 +94,7 @@ size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags)
|
|||
uint errors;
|
||||
#endif
|
||||
DBUG_ENTER("my_fwrite");
|
||||
DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d",
|
||||
DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %lu",
|
||||
(long) stream, (long) Buffer, (uint) Count, MyFlags));
|
||||
|
||||
#if !defined(NO_BACKGROUND) && defined(USE_MY_STREAM)
|
||||
|
@ -163,7 +163,7 @@ my_off_t my_fseek(FILE *stream, my_off_t pos, int whence,
|
|||
myf MyFlags __attribute__((unused)))
|
||||
{
|
||||
DBUG_ENTER("my_fseek");
|
||||
DBUG_PRINT("my",("stream: 0x%lx pos: %lu whence: %d MyFlags: %d",
|
||||
DBUG_PRINT("my",("stream: 0x%lx pos: %lu whence: %d MyFlags: %lu",
|
||||
(long) stream, (long) pos, whence, MyFlags));
|
||||
DBUG_RETURN(fseek(stream, (off_t) pos, whence) ?
|
||||
MY_FILEPOS_ERROR : (my_off_t) ftell(stream));
|
||||
|
@ -176,7 +176,7 @@ my_off_t my_ftell(FILE *stream, myf MyFlags __attribute__((unused)))
|
|||
{
|
||||
off_t pos;
|
||||
DBUG_ENTER("my_ftell");
|
||||
DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d", (long) stream, MyFlags));
|
||||
DBUG_PRINT("my",("stream: 0x%lx MyFlags: %lu", (long) stream, MyFlags));
|
||||
pos=ftell(stream);
|
||||
DBUG_PRINT("exit",("ftell: %lu",(ulong) pos));
|
||||
DBUG_RETURN((my_off_t) pos);
|
||||
|
|
|
@ -48,7 +48,7 @@ int my_getwd(char * buf, size_t size, myf MyFlags)
|
|||
{
|
||||
char * pos;
|
||||
DBUG_ENTER("my_getwd");
|
||||
DBUG_PRINT("my",("buf: 0x%lx size: %u MyFlags %d",
|
||||
DBUG_PRINT("my",("buf: 0x%lx size: %u MyFlags %lu",
|
||||
(long) buf, (uint) size, MyFlags));
|
||||
|
||||
if (size < 1)
|
||||
|
@ -95,7 +95,7 @@ int my_setwd(const char *dir, myf MyFlags)
|
|||
size_t length;
|
||||
char *start, *pos;
|
||||
DBUG_ENTER("my_setwd");
|
||||
DBUG_PRINT("my",("dir: '%s' MyFlags %d", dir, MyFlags));
|
||||
DBUG_PRINT("my",("dir: '%s' MyFlags %lu", dir, MyFlags));
|
||||
|
||||
start=(char *) dir;
|
||||
if (! dir[0] || (dir[0] == FN_LIBCHAR && dir[1] == 0))
|
||||
|
|
|
@ -100,7 +100,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
|
|||
char dirent_tmp[sizeof(struct dirent)+_POSIX_PATH_MAX+1];
|
||||
|
||||
DBUG_ENTER("my_dir");
|
||||
DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,MyFlags));
|
||||
DBUG_PRINT("my",("path: '%s' MyFlags: %lu",path,MyFlags));
|
||||
|
||||
#if !defined(HAVE_READDIR_R)
|
||||
mysql_mutex_lock(&THR_LOCK_open);
|
||||
|
@ -122,12 +122,14 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
|
|||
ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)));
|
||||
|
||||
if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
|
||||
ENTRIES_START_SIZE, ENTRIES_INCREMENT))
|
||||
ENTRIES_START_SIZE, ENTRIES_INCREMENT,
|
||||
MyFlags))
|
||||
{
|
||||
my_free(buffer);
|
||||
goto error;
|
||||
}
|
||||
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
|
||||
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE,
|
||||
MyFlags);
|
||||
|
||||
/* MY_DIR structure is allocated and completly initialized at this point */
|
||||
result= (MY_DIR*)buffer;
|
||||
|
@ -263,12 +265,13 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
|
|||
ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)));
|
||||
|
||||
if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
|
||||
ENTRIES_START_SIZE, ENTRIES_INCREMENT))
|
||||
ENTRIES_START_SIZE, ENTRIES_INCREMENT,
|
||||
MyFlags))
|
||||
{
|
||||
my_free(buffer);
|
||||
goto error;
|
||||
}
|
||||
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
|
||||
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE, MyFlags);
|
||||
|
||||
/* MY_DIR structure is allocated and completly initialized at this point */
|
||||
result= (MY_DIR*)buffer;
|
||||
|
@ -383,7 +386,7 @@ int my_fstat(File Filedes, MY_STAT *stat_area,
|
|||
myf MyFlags __attribute__((unused)))
|
||||
{
|
||||
DBUG_ENTER("my_fstat");
|
||||
DBUG_PRINT("my",("fd: %d MyFlags: %d", Filedes, MyFlags));
|
||||
DBUG_PRINT("my",("fd: %d MyFlags: %lu", Filedes, MyFlags));
|
||||
#ifdef _WIN32
|
||||
DBUG_RETURN(my_win_fstat(Filedes, stat_area));
|
||||
#else
|
||||
|
@ -396,7 +399,7 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
|
|||
{
|
||||
int m_used;
|
||||
DBUG_ENTER("my_stat");
|
||||
DBUG_PRINT("my", ("path: '%s' stat_area: 0x%lx MyFlags: %d", path,
|
||||
DBUG_PRINT("my", ("path: '%s' stat_area: 0x%lx MyFlags: %lu", path,
|
||||
(long) stat_area, my_flags));
|
||||
|
||||
if ((m_used= (stat_area == NULL)))
|
||||
|
|
|
@ -144,7 +144,7 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
|
|||
#endif
|
||||
|
||||
DBUG_ENTER("my_lock");
|
||||
DBUG_PRINT("my",("fd: %d Op: %d start: %ld Length: %ld MyFlags: %d",
|
||||
DBUG_PRINT("my",("fd: %d Op: %d start: %ld Length: %ld MyFlags: %lu",
|
||||
fd,locktype,(long) start,(long) length,MyFlags));
|
||||
if (my_disable_locking && ! (MyFlags & MY_FORCE_LOCK))
|
||||
DBUG_RETURN(0);
|
||||
|
|
|
@ -18,6 +18,60 @@
|
|||
#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, myf *flags)
|
||||
{
|
||||
size_t size= MALLOC_SIZE(p);
|
||||
*flags= (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 */
|
||||
|
||||
static MALLOC_SIZE_CB malloc_size_cb_func= NULL;
|
||||
|
||||
/**
|
||||
Inform application that memory usage has changed
|
||||
|
||||
@param size Size of memory segment allocated or freed
|
||||
@param flag 1 if thread specific (allocated by MY_THREAD_SPECIFIC),
|
||||
0 if system specific.
|
||||
|
||||
The type os size is long long, to be able to handle negative numbers to
|
||||
decrement the memory usage
|
||||
*/
|
||||
|
||||
static void update_malloc_size(long long size, myf my_flags)
|
||||
{
|
||||
if (malloc_size_cb_func)
|
||||
malloc_size_cb_func(size, my_flags);
|
||||
}
|
||||
|
||||
void set_malloc_size_cb(MALLOC_SIZE_CB func)
|
||||
{
|
||||
malloc_size_cb_func= func;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Allocate a sized block of memory.
|
||||
|
||||
|
@ -30,7 +84,9 @@ void *my_malloc(size_t size, myf my_flags)
|
|||
{
|
||||
void* point;
|
||||
DBUG_ENTER("my_malloc");
|
||||
DBUG_PRINT("my",("size: %lu my_flags: %d", (ulong) size, my_flags));
|
||||
DBUG_PRINT("my",("size: %lu my_flags: %lu", (ulong) size, my_flags));
|
||||
compile_time_assert(sizeof(size_t) <= sizeof(double));
|
||||
|
||||
if (!(my_flags & (MY_WME | MY_FAE)))
|
||||
my_flags|= my_global_flags;
|
||||
|
||||
|
@ -38,12 +94,9 @@ void *my_malloc(size_t size, myf my_flags)
|
|||
if (!size)
|
||||
size=1;
|
||||
|
||||
point= sf_malloc(size);
|
||||
DBUG_EXECUTE_IF("simulate_out_of_memory",
|
||||
{
|
||||
my_free(point);
|
||||
point= NULL;
|
||||
});
|
||||
/* We have to align size to be able to store markers in it */
|
||||
size= ALIGN_SIZE(size);
|
||||
point= sf_malloc(size + MALLOC_PREFIX_SIZE, my_flags);
|
||||
|
||||
if (point == NULL)
|
||||
{
|
||||
|
@ -59,8 +112,20 @@ void *my_malloc(size_t size, myf my_flags)
|
|||
if (my_flags & MY_FAE)
|
||||
exit(1);
|
||||
}
|
||||
else if (my_flags & MY_ZEROFILL)
|
||||
bzero(point, size);
|
||||
else
|
||||
{
|
||||
MALLOC_STORE_SIZE(point, void*, size, test(my_flags & MY_THREAD_SPECIFIC));
|
||||
update_malloc_size(size + MALLOC_PREFIX_SIZE,
|
||||
test(my_flags & MY_THREAD_SPECIFIC));
|
||||
DBUG_EXECUTE_IF("simulate_out_of_memory",
|
||||
{
|
||||
/* my_free() handles memory accounting */
|
||||
my_free(point);
|
||||
point= NULL;
|
||||
});
|
||||
if (my_flags & MY_ZEROFILL)
|
||||
bzero(point, size);
|
||||
}
|
||||
DBUG_PRINT("exit",("ptr: %p", point));
|
||||
DBUG_RETURN(point);
|
||||
}
|
||||
|
@ -79,23 +144,53 @@ void *my_malloc(size_t size, myf my_flags)
|
|||
void *my_realloc(void *oldpoint, size_t size, myf my_flags)
|
||||
{
|
||||
void *point;
|
||||
size_t old_size;
|
||||
myf old_flags;
|
||||
DBUG_ENTER("my_realloc");
|
||||
DBUG_PRINT("my",("ptr: %p size: %lu my_flags: %d", oldpoint,
|
||||
DBUG_PRINT("my",("ptr: %p size: %lu my_flags: %lu", oldpoint,
|
||||
(ulong) size, my_flags));
|
||||
|
||||
DBUG_ASSERT(size > 0);
|
||||
if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
|
||||
DBUG_RETURN(my_malloc(size, my_flags));
|
||||
if ((point= sf_realloc(oldpoint, size)) == NULL)
|
||||
|
||||
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((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)
|
||||
{
|
||||
if (my_flags & MY_FREE_ON_ERROR)
|
||||
{
|
||||
/* my_free will take care of size accounting */
|
||||
my_free(oldpoint);
|
||||
oldpoint= 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_WAITTANG), size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MALLOC_STORE_SIZE(point, void*, size, test(my_flags & MY_THREAD_SPECIFIC));
|
||||
if (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_flags & MY_THREAD_SPECIFIC);
|
||||
}
|
||||
else
|
||||
update_malloc_size((longlong) (size - old_size), old_flags);
|
||||
}
|
||||
|
||||
DBUG_PRINT("exit",("ptr: %p", point));
|
||||
DBUG_RETURN(point);
|
||||
}
|
||||
|
@ -112,7 +207,14 @@ void my_free(void *ptr)
|
|||
{
|
||||
DBUG_ENTER("my_free");
|
||||
DBUG_PRINT("my",("ptr: %p", ptr));
|
||||
sf_free(ptr);
|
||||
if (ptr)
|
||||
{
|
||||
size_t old_size;
|
||||
myf old_flags;
|
||||
old_size= MALLOC_SIZE_AND_FLAG(ptr, &old_flags);
|
||||
update_malloc_size(- (longlong) old_size - MALLOC_PREFIX_SIZE, old_flags);
|
||||
sf_free(MALLOC_FIX_POINTER_FOR_FREE(ptr));
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ File my_open(const char *FileName, int Flags, myf MyFlags)
|
|||
{
|
||||
File fd;
|
||||
DBUG_ENTER("my_open");
|
||||
DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d",
|
||||
DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %lu",
|
||||
FileName, Flags, MyFlags));
|
||||
if (!(MyFlags & (MY_WME | MY_FAE | MY_FFNF)))
|
||||
MyFlags|= my_global_flags;
|
||||
|
@ -71,7 +71,7 @@ int my_close(File fd, myf MyFlags)
|
|||
{
|
||||
int err;
|
||||
DBUG_ENTER("my_close");
|
||||
DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags));
|
||||
DBUG_PRINT("my",("fd: %d MyFlags: %lu",fd, MyFlags));
|
||||
if (!(MyFlags & (MY_WME | MY_FAE)))
|
||||
MyFlags|= my_global_flags;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
|
|||
|
||||
DBUG_ENTER("my_pread");
|
||||
|
||||
DBUG_PRINT("my",("fd: %d Seek: %llu Buffer: %p Count: %lu MyFlags: %d",
|
||||
DBUG_PRINT("my",("fd: %d Seek: %llu Buffer: %p Count: %lu MyFlags: %lu",
|
||||
Filedes, (ulonglong)offset, Buffer, (ulong)Count, MyFlags));
|
||||
|
||||
if (!(MyFlags & (MY_WME | MY_FAE | MY_FNABP)))
|
||||
|
@ -130,7 +130,7 @@ size_t my_pwrite(int Filedes, const uchar *Buffer, size_t Count,
|
|||
size_t writtenbytes, written;
|
||||
uint errors;
|
||||
DBUG_ENTER("my_pwrite");
|
||||
DBUG_PRINT("my",("fd: %d Seek: %llu Buffer: %p Count: %lu MyFlags: %d",
|
||||
DBUG_PRINT("my",("fd: %d Seek: %llu Buffer: %p Count: %lu MyFlags: %lu",
|
||||
Filedes, (ulonglong)offset, Buffer, (ulong)Count, MyFlags));
|
||||
errors= 0;
|
||||
written= 0;
|
||||
|
|
|
@ -37,7 +37,7 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
|
|||
{
|
||||
size_t readbytes, save_count;
|
||||
DBUG_ENTER("my_read");
|
||||
DBUG_PRINT("my",("fd: %d Buffer: %p Count: %lu MyFlags: %d",
|
||||
DBUG_PRINT("my",("fd: %d Buffer: %p Count: %lu MyFlags: %lu",
|
||||
Filedes, Buffer, (ulong) Count, MyFlags));
|
||||
save_count= Count;
|
||||
if (!(MyFlags & (MY_WME | MY_FAE | MY_FNABP)))
|
||||
|
|
|
@ -46,7 +46,7 @@ int my_redel(const char *org_name, const char *tmp_name,
|
|||
{
|
||||
int error=1;
|
||||
DBUG_ENTER("my_redel");
|
||||
DBUG_PRINT("my",("org_name: '%s' tmp_name: '%s' MyFlags: %d",
|
||||
DBUG_PRINT("my",("org_name: '%s' tmp_name: '%s' MyFlags: %lu",
|
||||
org_name,tmp_name,MyFlags));
|
||||
|
||||
if (my_copystat(org_name,tmp_name,MyFlags) < 0)
|
||||
|
|
|
@ -25,7 +25,7 @@ int my_rename(const char *from, const char *to, myf MyFlags)
|
|||
{
|
||||
int error = 0;
|
||||
DBUG_ENTER("my_rename");
|
||||
DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
|
||||
DBUG_PRINT("my",("from %s to %s MyFlags %lu", from, to, MyFlags));
|
||||
|
||||
#if defined(HAVE_RENAME)
|
||||
#if defined(__WIN__)
|
||||
|
|
|
@ -48,7 +48,7 @@ my_off_t my_seek(File fd, my_off_t pos, int whence, myf MyFlags)
|
|||
{
|
||||
os_off_t newpos= -1;
|
||||
DBUG_ENTER("my_seek");
|
||||
DBUG_PRINT("my",("fd: %d Pos: %llu Whence: %d MyFlags: %d",
|
||||
DBUG_PRINT("my",("fd: %d Pos: %llu Whence: %d MyFlags: %lu",
|
||||
fd, (ulonglong) pos, whence, MyFlags));
|
||||
DBUG_ASSERT(pos != MY_FILEPOS_ERROR); /* safety check */
|
||||
|
||||
|
@ -84,7 +84,7 @@ my_off_t my_tell(File fd, myf MyFlags)
|
|||
{
|
||||
os_off_t pos;
|
||||
DBUG_ENTER("my_tell");
|
||||
DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags));
|
||||
DBUG_PRINT("my",("fd: %d MyFlags: %lu",fd, MyFlags));
|
||||
DBUG_ASSERT(fd >= 0);
|
||||
#if defined (HAVE_TELL) && !defined (_WIN32)
|
||||
pos= tell(fd);
|
||||
|
|
|
@ -65,16 +65,13 @@ int my_sync(File fd, myf my_flags)
|
|||
{
|
||||
int res;
|
||||
DBUG_ENTER("my_sync");
|
||||
|
||||
DBUG_PRINT("my",("fd: %d my_flags: %d", fd, my_flags));
|
||||
DBUG_PRINT("my",("fd: %d my_flags: %lu", fd, my_flags));
|
||||
|
||||
if (my_disable_sync)
|
||||
DBUG_RETURN(0);
|
||||
|
||||
statistic_increment(my_sync_count,&THR_LOCK_open);
|
||||
|
||||
DBUG_PRINT("my",("Fd: %d my_flags: %d", fd, my_flags));
|
||||
|
||||
if (before_sync_wait)
|
||||
(*before_sync_wait)();
|
||||
|
||||
|
@ -158,7 +155,7 @@ int my_sync_dir(const char *dir_name __attribute__((unused)),
|
|||
int res= 0;
|
||||
const char *correct_dir_name;
|
||||
DBUG_ENTER("my_sync_dir");
|
||||
DBUG_PRINT("my",("Dir: '%s' my_flags: %d", dir_name, my_flags));
|
||||
DBUG_PRINT("my",("Dir: '%s' my_flags: %lu", dir_name, my_flags));
|
||||
/* Sometimes the path does not contain an explicit directory */
|
||||
correct_dir_name= (dir_name[0] == 0) ? cur_dir_name : dir_name;
|
||||
/*
|
||||
|
|
|
@ -427,7 +427,12 @@ struct st_my_thread_var *_my_thread_var(void)
|
|||
|
||||
my_thread_id my_thread_dbug_id()
|
||||
{
|
||||
return my_thread_var->id;
|
||||
/*
|
||||
We need to do this test as some system thread may not yet have called
|
||||
my_thread_init().
|
||||
*/
|
||||
struct st_my_thread_var *tmp= my_thread_var;
|
||||
return tmp ? tmp->id : 0;
|
||||
}
|
||||
|
||||
#ifdef DBUG_OFF
|
||||
|
|
|
@ -25,7 +25,7 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
|
|||
size_t writtenbytes, written;
|
||||
uint errors;
|
||||
DBUG_ENTER("my_write");
|
||||
DBUG_PRINT("my",("fd: %d Buffer: %p Count: %lu MyFlags: %d",
|
||||
DBUG_PRINT("my",("fd: %d Buffer: %p Count: %lu MyFlags: %lu",
|
||||
Filedes, Buffer, (ulong) Count, MyFlags));
|
||||
errors= 0; written= 0;
|
||||
if (!(MyFlags & (MY_WME | MY_FAE | MY_FNABP)))
|
||||
|
|
|
@ -70,12 +70,13 @@ extern PSI_file_key key_file_charset, key_file_cnf;
|
|||
#endif /* HAVE_PSI_INTERFACE */
|
||||
|
||||
#ifdef SAFEMALLOC
|
||||
void *sf_malloc(size_t size);
|
||||
void *sf_realloc(void *ptr, size_t size);
|
||||
void *sf_malloc(size_t size, myf my_flags);
|
||||
void *sf_realloc(void *ptr, size_t size, myf my_flags);
|
||||
void sf_free(void *ptr);
|
||||
size_t sf_malloc_usable_size(void *ptr, myf *my_flags);
|
||||
#else
|
||||
#define sf_malloc(X) malloc(X)
|
||||
#define sf_realloc(X,Y) realloc(X,Y)
|
||||
#define sf_malloc(X,Y) malloc(X)
|
||||
#define sf_realloc(X,Y,Z) realloc(X,Y)
|
||||
#define sf_free(X) free(X)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -58,6 +58,8 @@ struct st_irem
|
|||
#ifdef HAVE_BACKTRACE
|
||||
void *frame[SF_REMEMBER_FRAMES]; /* call stack */
|
||||
#endif
|
||||
uint32 flags; /* Flags passed to malloc */
|
||||
my_thread_id thread_id; /* Which thread did the allocation */
|
||||
uint32 marker; /* Underrun marker value */
|
||||
};
|
||||
|
||||
|
@ -79,11 +81,21 @@ static int bad_ptr(const char *where, void *ptr);
|
|||
static void free_memory(void *ptr);
|
||||
static void sf_terminate();
|
||||
|
||||
/* Setup default call to get a thread id for the memory */
|
||||
|
||||
my_thread_id default_sf_malloc_dbug_id(void)
|
||||
{
|
||||
return my_thread_dbug_id();
|
||||
}
|
||||
|
||||
my_thread_id (*sf_malloc_dbug_id)(void)= default_sf_malloc_dbug_id;
|
||||
|
||||
|
||||
/**
|
||||
allocates memory
|
||||
*/
|
||||
|
||||
void *sf_malloc(size_t size)
|
||||
void *sf_malloc(size_t size, myf my_flags)
|
||||
{
|
||||
struct st_irem *irem;
|
||||
uchar *data;
|
||||
|
@ -114,7 +126,9 @@ void *sf_malloc(size_t size)
|
|||
data= (uchar*) (irem + 1);
|
||||
irem->datasize= size;
|
||||
irem->prev= 0;
|
||||
irem->flags= my_flags;
|
||||
irem->marker= MAGICSTART;
|
||||
irem->thread_id= sf_malloc_dbug_id();
|
||||
data[size + 0]= MAGICEND0;
|
||||
data[size + 1]= MAGICEND1;
|
||||
data[size + 2]= MAGICEND2;
|
||||
|
@ -154,17 +168,17 @@ void *sf_malloc(size_t size)
|
|||
return data;
|
||||
}
|
||||
|
||||
void *sf_realloc(void *ptr, size_t size)
|
||||
void *sf_realloc(void *ptr, size_t size, myf my_flags)
|
||||
{
|
||||
char *data;
|
||||
|
||||
if (!ptr)
|
||||
return sf_malloc(size);
|
||||
return sf_malloc(size, my_flags);
|
||||
|
||||
if (bad_ptr("Reallocating", ptr))
|
||||
return 0;
|
||||
|
||||
if ((data= sf_malloc(size)))
|
||||
if ((data= sf_malloc(size, my_flags)))
|
||||
{
|
||||
struct st_irem *irem= (struct st_irem *)ptr - 1;
|
||||
set_if_smaller(size, irem->datasize);
|
||||
|
@ -182,10 +196,38 @@ void sf_free(void *ptr)
|
|||
free_memory(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
Return size of memory block and if block is thread specific
|
||||
|
||||
sf_malloc_usable_size()
|
||||
@param ptr Pointer to malloced block
|
||||
@param flags We will store 1 here if block is marked as MY_THREAD_SPECIFIC
|
||||
otherwise 0
|
||||
|
||||
@return Size of block
|
||||
*/
|
||||
|
||||
size_t sf_malloc_usable_size(void *ptr, myf *flags)
|
||||
{
|
||||
struct st_irem *irem= (struct st_irem *)ptr - 1;
|
||||
DBUG_ENTER("sf_malloc_usable_size");
|
||||
*flags= test(irem->flags & MY_THREAD_SPECIFIC);
|
||||
DBUG_PRINT("exit", ("size: %lu flags: %lu", (ulong) irem->datasize,
|
||||
*flags));
|
||||
DBUG_RETURN(irem->datasize);
|
||||
}
|
||||
|
||||
static void free_memory(void *ptr)
|
||||
{
|
||||
struct st_irem *irem= (struct st_irem *)ptr - 1;
|
||||
|
||||
if ((irem->flags & MY_THREAD_SPECIFIC) &&
|
||||
irem->thread_id != sf_malloc_dbug_id())
|
||||
{
|
||||
DBUG_PRINT("warning",
|
||||
("Memory: %p was allocated by thread %lu and freed by thread %lu", ptr, (ulong) irem->thread_id, (ulong) sf_malloc_dbug_id()));
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&sf_mutex);
|
||||
/* Remove this structure from the linked list */
|
||||
if (irem->prev)
|
||||
|
@ -312,9 +354,11 @@ static int sf_sanity()
|
|||
|
||||
/**
|
||||
report on all the memory pieces that have not been free'd
|
||||
|
||||
@param id Id of thread to report. 0 if all
|
||||
*/
|
||||
|
||||
static void sf_terminate()
|
||||
void sf_report_leaked_memory(my_thread_id id)
|
||||
{
|
||||
size_t total= 0;
|
||||
struct st_irem *irem;
|
||||
|
@ -322,21 +366,29 @@ static void sf_terminate()
|
|||
sf_sanity();
|
||||
|
||||
/* Report on all the memory that was allocated but not free'd */
|
||||
if (!sf_leaking_memory && sf_malloc_root)
|
||||
|
||||
for (irem= sf_malloc_root; irem; irem= irem->next)
|
||||
{
|
||||
for (irem= sf_malloc_root; irem; irem= irem->next)
|
||||
if (!id || (irem->thread_id == id && irem->flags & MY_THREAD_SPECIFIC))
|
||||
{
|
||||
fprintf(stderr, "Warning: %4lu bytes lost, allocated at ",
|
||||
(ulong) irem->datasize);
|
||||
print_stack(irem->frame);
|
||||
total+= irem->datasize;
|
||||
}
|
||||
}
|
||||
if (total)
|
||||
fprintf(stderr, "Memory lost: %lu bytes in %d chunks\n",
|
||||
(ulong) total, sf_malloc_count);
|
||||
}
|
||||
|
||||
pthread_mutex_destroy(&sf_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
static void sf_terminate()
|
||||
{
|
||||
if (!sf_leaking_memory)
|
||||
sf_report_leaked_memory(0);
|
||||
|
||||
pthread_mutex_destroy(&sf_mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
16
mysys/tree.c
16
mysys/tree.c
|
@ -84,8 +84,9 @@ static int test_rb_tree(TREE_ELEMENT *element);
|
|||
#endif
|
||||
|
||||
void init_tree(TREE *tree, size_t default_alloc_size, size_t memory_limit,
|
||||
int size, qsort_cmp2 compare, my_bool with_delete,
|
||||
tree_element_free free_element, void *custom_arg)
|
||||
int size, qsort_cmp2 compare,
|
||||
tree_element_free free_element, void *custom_arg,
|
||||
myf my_flags)
|
||||
{
|
||||
DBUG_ENTER("init_tree");
|
||||
DBUG_PRINT("enter",("tree: 0x%lx size: %d", (long) tree, size));
|
||||
|
@ -104,6 +105,7 @@ void init_tree(TREE *tree, size_t default_alloc_size, size_t memory_limit,
|
|||
tree->custom_arg = custom_arg;
|
||||
tree->null_element.colour=BLACK;
|
||||
tree->null_element.left=tree->null_element.right=0;
|
||||
tree->my_flags= my_flags;
|
||||
tree->flag= 0;
|
||||
if (!free_element && size >= 0 &&
|
||||
((uint) size <= sizeof(void*) || ((uint) size & (sizeof(void*)-1))))
|
||||
|
@ -125,10 +127,11 @@ void init_tree(TREE *tree, size_t default_alloc_size, size_t memory_limit,
|
|||
tree->offset_to_key=0; /* use key through pointer */
|
||||
tree->size_of_element+=sizeof(void*);
|
||||
}
|
||||
if (!(tree->with_delete=with_delete))
|
||||
if (!(tree->with_delete= test(my_flags & MY_TREE_WITH_DELETE)))
|
||||
{
|
||||
init_alloc_root(&tree->mem_root, default_alloc_size, 0);
|
||||
tree->mem_root.min_malloc=(sizeof(TREE_ELEMENT)+tree->size_of_element);
|
||||
init_alloc_root(&tree->mem_root, default_alloc_size, 0,
|
||||
my_flags);
|
||||
tree->mem_root.min_malloc= sizeof(TREE_ELEMENT)+tree->size_of_element;
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -236,7 +239,8 @@ 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, MYF(MY_WME));
|
||||
element=(TREE_ELEMENT *) my_malloc(alloc_size,
|
||||
MYF(tree->my_flags | MY_WME));
|
||||
else
|
||||
element=(TREE_ELEMENT *) alloc_root(&tree->mem_root,alloc_size);
|
||||
if (!element)
|
||||
|
|
|
@ -403,7 +403,7 @@ static void wt_resource_init(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);
|
||||
my_init_dynamic_array(&rc->owners, sizeof(WT_THD *), 0, 5, 0);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -509,7 +509,7 @@ 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);
|
||||
my_init_dynamic_array(&thd->my_resources, sizeof(WT_RESOURCE *), 0, 5, 0);
|
||||
#ifndef DBUG_OFF
|
||||
thd->name= my_thread_name();
|
||||
#endif
|
||||
|
|
|
@ -891,7 +891,8 @@ void free_old_query(MYSQL *mysql)
|
|||
DBUG_ENTER("free_old_query");
|
||||
if (mysql->fields)
|
||||
free_root(&mysql->field_alloc,MYF(0));
|
||||
init_alloc_root(&mysql->field_alloc,8192,0); /* Assume rowlength < 8192 */
|
||||
/* Assume rowlength < 8192 */
|
||||
init_alloc_root(&mysql->field_alloc, 8192, 0, MYF(MY_THREAD_SPECIFIC));
|
||||
mysql->fields= 0;
|
||||
mysql->field_count= 0; /* For API */
|
||||
mysql->warning_count= 0;
|
||||
|
@ -1169,7 +1170,7 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
|
|||
{
|
||||
options->init_commands= (DYNAMIC_ARRAY*)my_malloc(sizeof(DYNAMIC_ARRAY),
|
||||
MYF(MY_WME));
|
||||
init_dynamic_array(options->init_commands,sizeof(char*),5,5);
|
||||
my_init_dynamic_array(options->init_commands,sizeof(char*),5, 5, 0);
|
||||
}
|
||||
|
||||
if (!(tmp= my_strdup(cmd,MYF(MY_WME))) ||
|
||||
|
@ -1576,7 +1577,8 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
|
|||
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
init_alloc_root(&result->alloc,8192,0); /* Assume rowlength < 8192 */
|
||||
/* Assume rowlength < 8192 */
|
||||
init_alloc_root(&result->alloc, 8192, 0, MYF(MY_THREAD_SPECIFIC));
|
||||
result->alloc.min_malloc=sizeof(MYSQL_ROWS);
|
||||
prev_ptr= &result->data;
|
||||
result->rows=0;
|
||||
|
@ -3290,7 +3292,9 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
|
|||
if (mysql->options.extension && mysql->options.extension->async_context)
|
||||
net->vio->async_context= mysql->options.extension->async_context;
|
||||
|
||||
if (my_net_init(net, net->vio))
|
||||
if (my_net_init(net, net->vio,
|
||||
MYF(mysql->options.thread_specific_malloc ?
|
||||
MY_THREAD_SPECIFIC : 0)))
|
||||
{
|
||||
vio_delete(net->vio);
|
||||
net->vio = 0;
|
||||
|
@ -4218,6 +4222,9 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
|
|||
mysql->options.extension->report_progress=
|
||||
(void (*)(const MYSQL *, uint, uint, double, const char *, uint)) arg;
|
||||
break;
|
||||
case MYSQL_THREAD_SPECIFIC_MALLOC:
|
||||
mysql->options.thread_specific_malloc= *(uint*) arg;
|
||||
break;
|
||||
case MYSQL_OPT_NONBLOCK:
|
||||
if (mysql->options.extension &&
|
||||
(ctxt = mysql->options.extension->async_context) != 0)
|
||||
|
|
|
@ -251,7 +251,7 @@ int mysql_client_plugin_init()
|
|||
bzero(&mysql, sizeof(mysql)); /* dummy mysql for set_mysql_extended_error */
|
||||
|
||||
pthread_mutex_init(&LOCK_load_client_plugin, MY_MUTEX_INIT_SLOW);
|
||||
init_alloc_root(&mem_root, 128, 128);
|
||||
init_alloc_root(&mem_root, 128, 128, 0);
|
||||
|
||||
bzero(&plugin_list, sizeof(plugin_list));
|
||||
|
||||
|
|
|
@ -239,7 +239,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), MYF(MY_WME | MY_ZEROFILL));
|
||||
my_malloc(sizeof(st_debug_sync_control),
|
||||
MYF(MY_WME | MY_ZEROFILL | MY_THREAD_SPECIFIC));
|
||||
if (!thd->debug_sync_control)
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -209,7 +209,7 @@ Event_basic::Event_basic()
|
|||
{
|
||||
DBUG_ENTER("Event_basic::Event_basic");
|
||||
/* init memory root */
|
||||
init_sql_alloc(&mem_root, 256, 512);
|
||||
init_sql_alloc(&mem_root, 256, 512, 0);
|
||||
dbname.str= name.str= NULL;
|
||||
dbname.length= name.length= 0;
|
||||
time_zone= NULL;
|
||||
|
|
|
@ -153,8 +153,6 @@ void
|
|||
deinit_event_thread(THD *thd)
|
||||
{
|
||||
thd->proc_info= "Clearing";
|
||||
DBUG_ASSERT(thd->net.buff != 0);
|
||||
net_end(&thd->net);
|
||||
DBUG_PRINT("exit", ("Event thread finishing"));
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
thread_count--;
|
||||
|
@ -182,12 +180,15 @@ deinit_event_thread(THD *thd)
|
|||
void
|
||||
pre_init_event_thread(THD* thd)
|
||||
{
|
||||
THD *orig_thd= current_thd;
|
||||
DBUG_ENTER("pre_init_event_thread");
|
||||
|
||||
set_current_thd(thd);
|
||||
thd->client_capabilities= 0;
|
||||
thd->security_ctx->master_access= 0;
|
||||
thd->security_ctx->db_access= 0;
|
||||
thd->security_ctx->host_or_ip= (char*)my_localhost;
|
||||
my_net_init(&thd->net, NULL);
|
||||
my_net_init(&thd->net, NULL, MYF(MY_THREAD_SPECIFIC));
|
||||
thd->security_ctx->set_user((char*)"event_scheduler");
|
||||
thd->net.read_timeout= slave_net_timeout;
|
||||
thd->variables.option_bits|= OPTION_AUTO_IS_NULL;
|
||||
|
@ -207,6 +208,7 @@ pre_init_event_thread(THD* thd)
|
|||
/* Do not use user-supplied timeout value for system threads. */
|
||||
thd->variables.lock_wait_timeout= LONG_TIMEOUT;
|
||||
|
||||
set_current_thd(orig_thd);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -402,6 +404,7 @@ Event_scheduler::start()
|
|||
ret= TRUE;
|
||||
goto end;
|
||||
}
|
||||
|
||||
pre_init_event_thread(new_thd);
|
||||
new_thd->system_thread= SYSTEM_THREAD_EVENT_SCHEDULER;
|
||||
new_thd->command= COM_DAEMON;
|
||||
|
@ -413,6 +416,7 @@ Event_scheduler::start()
|
|||
*/
|
||||
new_thd->security_ctx->master_access |= SUPER_ACL;
|
||||
|
||||
/* This should not be marked with MY_THREAD_SPECIFIC */
|
||||
scheduler_param_value=
|
||||
(struct scheduler_param *)my_malloc(sizeof(struct scheduler_param), MYF(0));
|
||||
scheduler_param_value->thd= new_thd;
|
||||
|
@ -432,8 +436,6 @@ Event_scheduler::start()
|
|||
ret= TRUE;
|
||||
|
||||
new_thd->proc_info= "Clearing";
|
||||
DBUG_ASSERT(new_thd->net.buff != 0);
|
||||
net_end(&new_thd->net);
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
thread_count--;
|
||||
dec_thread_running();
|
||||
|
@ -533,6 +535,7 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
|
|||
pthread_t th;
|
||||
int res= 0;
|
||||
DBUG_ENTER("Event_scheduler::execute_top");
|
||||
|
||||
if (!(new_thd= new THD()))
|
||||
goto error;
|
||||
|
||||
|
@ -567,8 +570,6 @@ error:
|
|||
if (new_thd)
|
||||
{
|
||||
new_thd->proc_info= "Clearing";
|
||||
DBUG_ASSERT(new_thd->net.buff != 0);
|
||||
net_end(&new_thd->net);
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
thread_count--;
|
||||
dec_thread_running();
|
||||
|
|
|
@ -879,7 +879,7 @@ end:
|
|||
}
|
||||
delete thd;
|
||||
/* Remember that we don't have a THD */
|
||||
my_pthread_setspecific_ptr(THR_THD, NULL);
|
||||
set_current_thd(0);
|
||||
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
|
|
@ -200,7 +200,8 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
|||
table_sort.unpack= unpack_addon_fields;
|
||||
if (param.addon_field &&
|
||||
!(table_sort.addon_buf=
|
||||
(uchar *) my_malloc(param.addon_length, MYF(MY_WME))))
|
||||
(uchar *) my_malloc(param.addon_length, MYF(MY_WME |
|
||||
MY_THREAD_SPECIFIC))))
|
||||
goto err;
|
||||
|
||||
if (select && select->quick)
|
||||
|
@ -213,7 +214,8 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
|||
num_rows= table->file->estimate_rows_upper_bound();
|
||||
|
||||
if (multi_byte_charset &&
|
||||
!(param.tmp_buffer= (char*) my_malloc(param.sort_length,MYF(MY_WME))))
|
||||
!(param.tmp_buffer= (char*) my_malloc(param.sort_length,
|
||||
MYF(MY_WME | MY_THREAD_SPECIFIC))))
|
||||
goto err;
|
||||
|
||||
if (check_if_pq_applicable(¶m, &table_sort,
|
||||
|
@ -453,7 +455,7 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count,
|
|||
if (count > UINT_MAX/sizeof(BUFFPEK))
|
||||
return 0; /* sizeof(BUFFPEK)*count will overflow */
|
||||
if (!tmp)
|
||||
tmp= (uchar *)my_malloc(length, MYF(MY_WME));
|
||||
tmp= (uchar *)my_malloc(length, MYF(MY_WME | MY_THREAD_SPECIFIC));
|
||||
if (tmp)
|
||||
{
|
||||
if (reinit_io_cache(buffpek_pointers,READ_CACHE,0L,0,0) ||
|
||||
|
@ -1155,7 +1157,8 @@ static bool save_index(Sort_param *param, uint count, Filesort_info *table_sort)
|
|||
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))))
|
||||
(uchar*) my_malloc(res_length*count,
|
||||
MYF(MY_WME | MY_THREAD_SPECIFIC))))
|
||||
DBUG_RETURN(1); /* purecov: inspected */
|
||||
uchar **sort_keys= table_sort->get_sort_keys();
|
||||
for (uchar **end= sort_keys+count ; sort_keys != end ; sort_keys++)
|
||||
|
@ -1897,7 +1900,9 @@ get_addon_fields(ulong max_length_for_sort_data,
|
|||
|
||||
if (length+sortlength > max_length_for_sort_data ||
|
||||
!(addonf= (SORT_ADDON_FIELD *) my_malloc(sizeof(SORT_ADDON_FIELD)*
|
||||
(fields+1), MYF(MY_WME))))
|
||||
(fields+1),
|
||||
MYF(MY_WME |
|
||||
MY_THREAD_SPECIFIC))))
|
||||
return 0;
|
||||
|
||||
*plength= length;
|
||||
|
|
|
@ -99,7 +99,7 @@ uchar **Filesort_buffer::alloc_sort_buffer(uint num_records, uint record_length)
|
|||
sort_buff_sz= num_records * (record_length + sizeof(uchar*));
|
||||
set_if_bigger(sort_buff_sz, record_length * MERGEBUFF2);
|
||||
uchar **sort_keys=
|
||||
(uchar**) my_malloc(sort_buff_sz, MYF(0));
|
||||
(uchar**) my_malloc(sort_buff_sz, MYF(MY_THREAD_SPECIFIC));
|
||||
m_idx_array= Idx_array(sort_keys, num_records);
|
||||
m_record_length= record_length;
|
||||
uchar **start_of_data= m_idx_array.array() + m_idx_array.size();
|
||||
|
@ -130,7 +130,8 @@ void Filesort_buffer::sort_buffer(const Sort_param *param, uint count)
|
|||
uchar **keys= get_sort_keys();
|
||||
uchar **buffer= NULL;
|
||||
if (radixsort_is_appliccable(count, param->sort_length) &&
|
||||
(buffer= (uchar**) my_malloc(count*sizeof(char*), MYF(0))))
|
||||
(buffer= (uchar**) my_malloc(count*sizeof(char*),
|
||||
MYF(MY_THREAD_SPECIFIC))))
|
||||
{
|
||||
radixsort_for_str_ptr(keys, count, param->sort_length, buffer);
|
||||
my_free(buffer);
|
||||
|
@ -140,4 +141,3 @@ void Filesort_buffer::sort_buffer(const Sort_param *param, uint count)
|
|||
size_t size= param->sort_length;
|
||||
my_qsort2(keys, count, sizeof(uchar*), get_ptr_compare(size), &size);
|
||||
}
|
||||
|
||||
|
|
|
@ -8649,7 +8649,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
|
|||
MEM_ROOT **root_ptr=
|
||||
my_pthread_getspecific_ptr(MEM_ROOT**, THR_MALLOC);
|
||||
MEM_ROOT *old_root= *root_ptr;
|
||||
init_sql_alloc(&share->mem_root, 1024, 0);
|
||||
init_sql_alloc(&share->mem_root, 1024, 0, 0);
|
||||
*root_ptr= &share->mem_root; // remember to reset before return
|
||||
share->state= NSS_INITIAL;
|
||||
/* enough space for key, db, and table_name */
|
||||
|
@ -9493,7 +9493,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
|
|||
thd->init_for_queries();
|
||||
thd->main_security_ctx.host_or_ip= "";
|
||||
thd->client_capabilities = 0;
|
||||
my_net_init(&thd->net, 0);
|
||||
my_net_init(&thd->net, 0, MYF(MY_THREAD_SPECIFIC));
|
||||
thd->main_security_ctx.master_access= ~0;
|
||||
thd->main_security_ctx.priv_user[0] = 0;
|
||||
/* Do not use user-supplied timeout value for system threads. */
|
||||
|
@ -9730,11 +9730,9 @@ next:
|
|||
mysql_mutex_lock(&LOCK_ndb_util_thread);
|
||||
|
||||
ndb_util_thread_end:
|
||||
net_end(&thd->net);
|
||||
ndb_util_thread_fail:
|
||||
if (share_list)
|
||||
delete [] share_list;
|
||||
thd->cleanup();
|
||||
delete thd;
|
||||
|
||||
/* signal termination */
|
||||
|
|
|
@ -3665,7 +3665,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg)
|
|||
thd->system_thread= SYSTEM_THREAD_NDBCLUSTER_BINLOG;
|
||||
thd->main_security_ctx.host_or_ip= "";
|
||||
thd->client_capabilities= 0;
|
||||
my_net_init(&thd->net, 0);
|
||||
my_net_init(&thd->net, 0, MYF(MY_THREAD_SPECIFIC));
|
||||
thd->main_security_ctx.master_access= ~0;
|
||||
thd->main_security_ctx.priv_user[0]= 0;
|
||||
/* Do not use user-supplied timeout value for system threads. */
|
||||
|
@ -3964,7 +3964,7 @@ restart:
|
|||
my_pthread_getspecific_ptr(MEM_ROOT**, THR_MALLOC);
|
||||
MEM_ROOT *old_root= *root_ptr;
|
||||
MEM_ROOT mem_root;
|
||||
init_sql_alloc(&mem_root, 4096, 0);
|
||||
init_sql_alloc(&mem_root, 4096, 0, 0);
|
||||
List<Cluster_schema> post_epoch_log_list;
|
||||
List<Cluster_schema> post_epoch_unlock_list;
|
||||
*root_ptr= &mem_root;
|
||||
|
@ -4364,8 +4364,6 @@ err:
|
|||
|
||||
my_hash_free(&ndb_schema_objects);
|
||||
|
||||
net_end(&thd->net);
|
||||
thd->cleanup();
|
||||
delete thd;
|
||||
|
||||
ndb_binlog_thread_running= -1;
|
||||
|
|
|
@ -168,7 +168,7 @@ ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share)
|
|||
:handler(hton, share)
|
||||
{
|
||||
DBUG_ENTER("ha_partition::ha_partition(table)");
|
||||
init_alloc_root(&m_mem_root, 512, 512);
|
||||
init_alloc_root(&m_mem_root, 512, 512, 0);
|
||||
init_handler_variables();
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ ha_partition::ha_partition(handlerton *hton, partition_info *part_info)
|
|||
{
|
||||
DBUG_ENTER("ha_partition::ha_partition(part_info)");
|
||||
DBUG_ASSERT(part_info);
|
||||
init_alloc_root(&m_mem_root, 512, 512);
|
||||
init_alloc_root(&m_mem_root, 512, 512, 0);
|
||||
init_handler_variables();
|
||||
m_part_info= part_info;
|
||||
m_create_handler= TRUE;
|
||||
|
@ -217,7 +217,7 @@ ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share,
|
|||
:handler(hton, share)
|
||||
{
|
||||
DBUG_ENTER("ha_partition::ha_partition(clone)");
|
||||
init_alloc_root(&m_mem_root, 512, 512);
|
||||
init_alloc_root(&m_mem_root, 512, 512, 0);
|
||||
init_handler_variables();
|
||||
m_part_info= part_info_arg;
|
||||
m_create_handler= TRUE;
|
||||
|
|
|
@ -5352,7 +5352,7 @@ fl_log_iterator_buffer_init(struct handler_iterator *iterator)
|
|||
/* to be able to make my_free without crash in case of error */
|
||||
iterator->buffer= 0;
|
||||
|
||||
if (!(dirp = my_dir(fl_dir, MYF(0))))
|
||||
if (!(dirp = my_dir(fl_dir, MYF(MY_THREAD_SPECIFIC))))
|
||||
{
|
||||
return HA_ITERATOR_ERROR;
|
||||
}
|
||||
|
@ -5361,7 +5361,7 @@ fl_log_iterator_buffer_init(struct handler_iterator *iterator)
|
|||
sizeof(enum log_status) +
|
||||
+ FN_REFLEN + 1) *
|
||||
(uint) dirp->number_off_files),
|
||||
MYF(0))) == 0)
|
||||
MYF(MY_THREAD_SPECIFIC))) == 0)
|
||||
{
|
||||
return HA_ITERATOR_ERROR;
|
||||
}
|
||||
|
@ -5395,6 +5395,7 @@ fl_log_iterator_buffer_init(struct handler_iterator *iterator)
|
|||
iterator->buffer= buff;
|
||||
iterator->next= &fl_log_iterator_next;
|
||||
iterator->destroy= &fl_log_iterator_destroy;
|
||||
my_dirend(dirp);
|
||||
return HA_ITERATOR_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -4343,7 +4343,9 @@ user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
|
|||
uint 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,MYF(MY_WME | ME_FATALERROR))))
|
||||
if (!(entry = (user_var_entry*) my_malloc(size,
|
||||
MYF(MY_WME | ME_FATALERROR |
|
||||
MY_THREAD_SPECIFIC))))
|
||||
return 0;
|
||||
entry->name.str=(char*) entry+ ALIGN_SIZE(sizeof(user_var_entry))+
|
||||
extra_size;
|
||||
|
@ -4571,7 +4573,8 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
|
|||
entry->value=0;
|
||||
entry->value= (char*) my_realloc(entry->value, length,
|
||||
MYF(MY_ALLOW_ZERO_PTR | MY_WME |
|
||||
ME_FATALERROR));
|
||||
ME_FATALERROR |
|
||||
MY_THREAD_SPECIFIC));
|
||||
if (!entry->value)
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -5053,7 +5053,7 @@ 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))))
|
||||
sizeof(rownum_t)), MYF(MY_WME | MY_THREAD_SPECIFIC))))
|
||||
return TRUE;
|
||||
|
||||
/*
|
||||
|
@ -5480,7 +5480,7 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts,
|
|||
!(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))))
|
||||
MYF(MY_WME | MY_THREAD_SPECIFIC))))
|
||||
return TRUE;
|
||||
|
||||
/* Create the only non-NULL key if there is any. */
|
||||
|
|
|
@ -3485,7 +3485,8 @@ bool Item_func_group_concat::setup(THD *thd)
|
|||
init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
|
||||
thd->variables.sortbuff_size/16), 0,
|
||||
tree_key_length,
|
||||
group_concat_key_cmp_with_order , 0, NULL, (void*) this);
|
||||
group_concat_key_cmp_with_order, NULL, (void*) this,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
}
|
||||
|
||||
if (distinct)
|
||||
|
|
|
@ -8194,8 +8194,9 @@ binlog_background_thread(void *arg __attribute__((unused)))
|
|||
bool stop;
|
||||
MYSQL_BIN_LOG::xid_count_per_binlog *queue, *next;
|
||||
THD *thd;
|
||||
|
||||
my_thread_init();
|
||||
DBUG_ENTER("binlog_background_thread");
|
||||
|
||||
thd= new THD;
|
||||
thd->system_thread= SYSTEM_THREAD_BINLOG_BACKGROUND;
|
||||
thd->thread_stack= (char*) &thd; /* Set approximate stack start */
|
||||
|
@ -8259,7 +8260,7 @@ binlog_background_thread(void *arg __attribute__((unused)))
|
|||
mysql_cond_signal(&mysql_bin_log.COND_binlog_background_thread_end);
|
||||
mysql_mutex_unlock(&mysql_bin_log.LOCK_binlog_background_thread);
|
||||
|
||||
return 0;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PSI_INTERFACE
|
||||
|
@ -8310,7 +8311,7 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name,
|
|||
sizeof(my_xid), 0, 0, MYF(0)))
|
||||
goto err1;
|
||||
|
||||
init_alloc_root(&mem_root, TC_LOG_PAGE_SIZE, TC_LOG_PAGE_SIZE);
|
||||
init_alloc_root(&mem_root, TC_LOG_PAGE_SIZE, TC_LOG_PAGE_SIZE, 0);
|
||||
|
||||
fdle->flags&= ~LOG_EVENT_BINLOG_IN_USE_F; // abort on the first error
|
||||
|
||||
|
|
|
@ -2200,7 +2200,8 @@ bool MDL_context::acquire_locks(MDL_request_list *mdl_requests,
|
|||
/* Sort requests according to MDL_key. */
|
||||
if (! (sort_buf= (MDL_request **)my_malloc(req_count *
|
||||
sizeof(MDL_request*),
|
||||
MYF(MY_WME))))
|
||||
MYF(MY_WME |
|
||||
MY_THREAD_SPECIFIC))))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
for (p_req= sort_buf; p_req < sort_buf + req_count; p_req++)
|
||||
|
|
119
sql/mysqld.cc
119
sql/mysqld.cc
|
@ -1121,7 +1121,7 @@ private:
|
|||
|
||||
void Buffered_logs::init()
|
||||
{
|
||||
init_alloc_root(&m_root, 1024, 0);
|
||||
init_alloc_root(&m_root, 1024, 0, 0);
|
||||
}
|
||||
|
||||
void Buffered_logs::cleanup()
|
||||
|
@ -1765,6 +1765,7 @@ extern "C" void unireg_abort(int exit_code)
|
|||
|
||||
static void mysqld_exit(int exit_code)
|
||||
{
|
||||
DBUG_ENTER("mysqld_exit");
|
||||
/*
|
||||
Important note: we wait for the signal thread to end,
|
||||
but if a kill -15 signal was sent, the signal thread did
|
||||
|
@ -1776,6 +1777,7 @@ static void mysqld_exit(int exit_code)
|
|||
clean_up_error_log_mutex();
|
||||
my_end((opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0));
|
||||
shutdown_performance_schema(); // we do it as late as possible
|
||||
DBUG_LEAVE;
|
||||
exit(exit_code); /* purecov: inspected */
|
||||
}
|
||||
|
||||
|
@ -2485,9 +2487,13 @@ void unlink_thd(THD *thd)
|
|||
sync feature has been shut down at this point.
|
||||
*/
|
||||
DBUG_EXECUTE_IF("sleep_after_lock_thread_count_before_delete_thd", sleep(5););
|
||||
/*
|
||||
We must delete thd inside the lock to ensure that we don't start cleanup
|
||||
before THD is deleted
|
||||
*/
|
||||
delete thd;
|
||||
mysql_mutex_unlock(&LOCK_thread_count);
|
||||
|
||||
delete thd;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -2594,7 +2600,7 @@ bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
|
|||
DBUG_ENTER("one_thread_per_connection_end");
|
||||
unlink_thd(thd);
|
||||
/* Mark that current_thd is not valid anymore */
|
||||
my_pthread_setspecific_ptr(THR_THD, 0);
|
||||
set_current_thd(0);
|
||||
if (put_in_cache)
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
|
@ -2606,9 +2612,10 @@ bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
|
|||
|
||||
/* It's safe to broadcast outside a lock (COND... is not deleted here) */
|
||||
DBUG_PRINT("signal", ("Broadcasting COND_thread_count"));
|
||||
mysql_cond_broadcast(&COND_thread_count);
|
||||
|
||||
DBUG_LEAVE; // Must match DBUG_ENTER()
|
||||
my_thread_end();
|
||||
mysql_cond_broadcast(&COND_thread_count);
|
||||
|
||||
pthread_exit(0);
|
||||
return 0; // Avoid compiler warnings
|
||||
|
@ -3142,9 +3149,9 @@ void my_message_sql(uint error, const char *str, myf MyFlags)
|
|||
THD *thd= current_thd;
|
||||
MYSQL_ERROR::enum_warning_level level;
|
||||
sql_print_message_func func;
|
||||
|
||||
DBUG_ENTER("my_message_sql");
|
||||
DBUG_PRINT("error", ("error: %u message: '%s' Flag: %d", error, str, MyFlags));
|
||||
DBUG_PRINT("error", ("error: %u message: '%s' Flag: %lu", error, str,
|
||||
MyFlags));
|
||||
|
||||
DBUG_ASSERT(str != NULL);
|
||||
DBUG_ASSERT(error != 0);
|
||||
|
@ -3430,6 +3437,28 @@ SHOW_VAR com_status_vars[]= {
|
|||
{NullS, NullS, SHOW_LONG}
|
||||
};
|
||||
|
||||
#ifdef SAFEMALLOC
|
||||
/*
|
||||
Return the id for the current THD, to allow safemalloc to associate
|
||||
the memory with the right id.
|
||||
*/
|
||||
|
||||
extern "C" my_thread_id mariadb_dbug_id()
|
||||
{
|
||||
THD *thd;
|
||||
if ((thd= current_thd))
|
||||
{
|
||||
return thd->thread_id;
|
||||
}
|
||||
return my_thread_dbug_id();
|
||||
}
|
||||
#endif /* SAFEMALLOC */
|
||||
|
||||
|
||||
/*
|
||||
Init common variables
|
||||
*/
|
||||
|
||||
static int init_common_variables()
|
||||
{
|
||||
umask(((~my_umask) & 0666));
|
||||
|
@ -3438,6 +3467,9 @@ static int init_common_variables()
|
|||
tzset(); // Set tzname
|
||||
|
||||
sf_leaking_memory= 0; // no memory leaks from now on
|
||||
#ifdef SAFEMALLOC
|
||||
sf_malloc_dbug_id= mariadb_dbug_id;
|
||||
#endif
|
||||
|
||||
max_system_variables.pseudo_thread_id= (ulong)~0;
|
||||
server_start_time= flush_status_time= my_time(0);
|
||||
|
@ -3897,6 +3929,7 @@ You should consider changing lower_case_table_names to 1 or 2",
|
|||
|
||||
static int init_thread_environment()
|
||||
{
|
||||
DBUG_ENTER("init_thread_environment");
|
||||
mysql_mutex_init(key_LOCK_thread_count, &LOCK_thread_count, MY_MUTEX_INIT_FAST);
|
||||
mysql_mutex_init(key_LOCK_status, &LOCK_status, MY_MUTEX_INIT_FAST);
|
||||
mysql_mutex_init(key_LOCK_delayed_insert,
|
||||
|
@ -3975,9 +4008,9 @@ static int init_thread_environment()
|
|||
pthread_key_create(&THR_MALLOC,NULL))
|
||||
{
|
||||
sql_print_error("Can't create thread-keys");
|
||||
return 1;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
return 0;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -4641,6 +4674,37 @@ static void test_lc_time_sz()
|
|||
}
|
||||
#endif//DBUG_OFF
|
||||
|
||||
|
||||
/* Thread Mem Usage By P.Linux */
|
||||
extern "C"
|
||||
void my_malloc_size_cb_func(long long size, myf my_flags)
|
||||
{
|
||||
/* If thread specific memory */
|
||||
if (my_flags)
|
||||
{
|
||||
THD *thd= current_thd;
|
||||
if (mysqld_server_initialized || thd)
|
||||
{
|
||||
/*
|
||||
THD may not be set if we are called from my_net_init() before THD
|
||||
thread has started.
|
||||
However, this should never happen, so better to assert and
|
||||
fix this.
|
||||
*/
|
||||
DBUG_ASSERT(thd);
|
||||
if (thd)
|
||||
{
|
||||
DBUG_PRINT("info", ("memory_used: %lld size: %lld",
|
||||
(longlong) thd->status_var.memory_used, size));
|
||||
thd->status_var.memory_used+= size;
|
||||
DBUG_ASSERT((longlong) thd->status_var.memory_used >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
my_atomic_add64(&global_status_var.memory_used, size);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __WIN__
|
||||
int win_main(int argc, char **argv)
|
||||
#else
|
||||
|
@ -4653,6 +4717,9 @@ int mysqld_main(int argc, char **argv)
|
|||
*/
|
||||
my_progname= argv[0];
|
||||
sf_leaking_memory= 1; // no safemalloc memory leak reports if we exit early
|
||||
set_malloc_size_cb(my_malloc_size_cb_func);
|
||||
mysqld_server_started= mysqld_server_initialized= 0;
|
||||
|
||||
#ifdef HAVE_NPTL
|
||||
ld_assume_kernel_is_set= (getenv("LD_ASSUME_KERNEL") != 0);
|
||||
#endif
|
||||
|
@ -4665,7 +4732,6 @@ int mysqld_main(int argc, char **argv)
|
|||
}
|
||||
#endif
|
||||
|
||||
mysqld_server_started= mysqld_server_initialized= 0;
|
||||
orig_argc= argc;
|
||||
orig_argv= argv;
|
||||
my_getopt_use_args_separator= TRUE;
|
||||
|
@ -4695,7 +4761,7 @@ int mysqld_main(int argc, char **argv)
|
|||
my_getopt_skip_unknown= TRUE;
|
||||
|
||||
/* prepare all_early_options array */
|
||||
my_init_dynamic_array(&all_early_options, sizeof(my_option), 100, 25);
|
||||
my_init_dynamic_array(&all_early_options, sizeof(my_option), 100, 25, 0);
|
||||
sys_var_add_options(&all_early_options, sys_var::PARSE_EARLY);
|
||||
add_terminator(&all_early_options);
|
||||
|
||||
|
@ -4956,8 +5022,6 @@ int mysqld_main(int argc, char **argv)
|
|||
if (Events::init(opt_noacl || opt_bootstrap))
|
||||
unireg_abort(1);
|
||||
|
||||
mysqld_server_initialized= 1;
|
||||
|
||||
if (opt_bootstrap)
|
||||
{
|
||||
select_thread_in_use= 0; // Allow 'kill' to work
|
||||
|
@ -4971,6 +5035,9 @@ int mysqld_main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
/* It's now safe to use thread specific memory */
|
||||
mysqld_server_initialized= 1;
|
||||
|
||||
create_shutdown_thread();
|
||||
start_handle_manager();
|
||||
|
||||
|
@ -5000,7 +5067,6 @@ int mysqld_main(int argc, char **argv)
|
|||
Service.SetRunning();
|
||||
#endif
|
||||
|
||||
|
||||
/* Signal threads waiting for server to be started */
|
||||
mysql_mutex_lock(&LOCK_server_started);
|
||||
mysqld_server_started= 1;
|
||||
|
@ -5180,6 +5246,7 @@ int mysqld_main(int argc, char **argv)
|
|||
|
||||
/* Must be initialized early for comparison of service name */
|
||||
system_charset_info= &my_charset_utf8_general_ci;
|
||||
set_malloc_size_cb(my_malloc_size_cb_func);
|
||||
|
||||
if (my_init())
|
||||
{
|
||||
|
@ -5288,7 +5355,7 @@ static void bootstrap(MYSQL_FILE *file)
|
|||
|
||||
THD *thd= new THD;
|
||||
thd->bootstrap=1;
|
||||
my_net_init(&thd->net,(st_vio*) 0);
|
||||
my_net_init(&thd->net,(st_vio*) 0, 0);
|
||||
thd->max_client_packet_length= thd->net.max_packet;
|
||||
thd->security_ctx->master_access= ~(ulong)0;
|
||||
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
|
||||
|
@ -5705,17 +5772,20 @@ void handle_connections_sockets()
|
|||
** Don't allow too many connections
|
||||
*/
|
||||
|
||||
DBUG_PRINT("info", ("Creating THD for new connection"));
|
||||
if (!(thd= new THD))
|
||||
{
|
||||
(void) mysql_socket_shutdown(new_sock, SHUT_RDWR);
|
||||
(void) closesocket(new_sock);
|
||||
continue;
|
||||
}
|
||||
/* Set to get io buffers to be part of THD */
|
||||
set_current_thd(thd);
|
||||
if (!(vio_tmp=vio_new(new_sock,
|
||||
sock == unix_sock ? VIO_TYPE_SOCKET :
|
||||
VIO_TYPE_TCPIP,
|
||||
sock == unix_sock ? VIO_LOCALHOST: 0)) ||
|
||||
my_net_init(&thd->net,vio_tmp))
|
||||
my_net_init(&thd->net, vio_tmp, MYF(MY_THREAD_SPECIFIC)))
|
||||
{
|
||||
/*
|
||||
Only delete the temporary vio if we didn't already attach it to the
|
||||
|
@ -5730,6 +5800,7 @@ void handle_connections_sockets()
|
|||
(void) closesocket(new_sock);
|
||||
}
|
||||
delete thd;
|
||||
set_current_thd(0);
|
||||
continue;
|
||||
}
|
||||
if (sock == unix_sock)
|
||||
|
@ -5741,6 +5812,7 @@ void handle_connections_sockets()
|
|||
thd->scheduler= extra_thread_scheduler;
|
||||
}
|
||||
create_new_thread(thd);
|
||||
set_current_thd(0);
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -5834,16 +5906,19 @@ pthread_handler_t handle_connections_namedpipes(void *arg)
|
|||
CloseHandle(hConnectedPipe);
|
||||
continue;
|
||||
}
|
||||
set_current_thd(thd);
|
||||
if (!(thd->net.vio= vio_new_win32pipe(hConnectedPipe)) ||
|
||||
my_net_init(&thd->net, thd->net.vio))
|
||||
my_net_init(&thd->net, thd->net.vio, MYF(MY_THREAD_SPECIFIC)))
|
||||
{
|
||||
close_connection(thd, ER_OUT_OF_RESOURCES);
|
||||
delete thd;
|
||||
set_current_thd(0);
|
||||
continue;
|
||||
}
|
||||
/* Host is unknown */
|
||||
thd->security_ctx->host= my_strdup(my_localhost, MYF(0));
|
||||
create_new_thread(thd);
|
||||
set_current_thd(0);
|
||||
}
|
||||
CloseHandle(connectOverlapped.hEvent);
|
||||
DBUG_LEAVE;
|
||||
|
@ -6023,6 +6098,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg)
|
|||
errmsg= "Could not set client to read mode";
|
||||
goto errorconn;
|
||||
}
|
||||
set_current_thd(thd);
|
||||
if (!(thd->net.vio= vio_new_win32shared_memory(handle_client_file_map,
|
||||
handle_client_map,
|
||||
event_client_wrote,
|
||||
|
@ -6030,7 +6106,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg)
|
|||
event_server_wrote,
|
||||
event_server_read,
|
||||
event_conn_closed)) ||
|
||||
my_net_init(&thd->net, thd->net.vio))
|
||||
my_net_init(&thd->net, thd->net.vio, MYF(MY_THREAD_SPECIFIC)))
|
||||
{
|
||||
close_connection(thd, ER_OUT_OF_RESOURCES);
|
||||
errmsg= 0;
|
||||
|
@ -6039,6 +6115,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg)
|
|||
thd->security_ctx->host= my_strdup(my_localhost, MYF(0)); /* Host is unknown */
|
||||
create_new_thread(thd);
|
||||
connect_number++;
|
||||
set_current_thd(thd);
|
||||
continue;
|
||||
|
||||
errorconn:
|
||||
|
@ -6066,6 +6143,7 @@ errorconn:
|
|||
CloseHandle(event_conn_closed);
|
||||
delete thd;
|
||||
}
|
||||
set_current_thd(0);
|
||||
|
||||
/* End shared memory handling */
|
||||
error:
|
||||
|
@ -7024,6 +7102,7 @@ SHOW_VAR status_vars[]= {
|
|||
{"Key", (char*) &show_default_keycache, SHOW_FUNC},
|
||||
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
|
||||
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
|
||||
{"Memory_used", (char*) offsetof(STATUS_VAR, memory_used), SHOW_LONGLONG_STATUS},
|
||||
{"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH},
|
||||
{"Open_files", (char*) &my_file_opened, SHOW_LONG_NOFLUSH},
|
||||
{"Open_streams", (char*) &my_stream_opened, SHOW_LONG_NOFLUSH},
|
||||
|
@ -7170,7 +7249,7 @@ static int option_cmp(my_option *a, my_option *b)
|
|||
static void print_help()
|
||||
{
|
||||
MEM_ROOT mem_root;
|
||||
init_alloc_root(&mem_root, 4096, 4096);
|
||||
init_alloc_root(&mem_root, 4096, 4096, 0);
|
||||
|
||||
pop_dynamic(&all_options);
|
||||
sys_var_add_options(&all_options, sys_var::PARSE_EARLY);
|
||||
|
@ -7862,7 +7941,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
|
|||
/* prepare all_options array */
|
||||
my_init_dynamic_array(&all_options, sizeof(my_option),
|
||||
array_elements(my_long_options),
|
||||
array_elements(my_long_options)/4);
|
||||
array_elements(my_long_options)/4, 0);
|
||||
for (my_option *opt= my_long_options;
|
||||
opt < my_long_options + array_elements(my_long_options) - 1;
|
||||
opt++)
|
||||
|
@ -8364,7 +8443,7 @@ void refresh_status(THD *thd)
|
|||
add_to_status(&global_status_var, &thd->status_var);
|
||||
|
||||
/* Reset thread's status variables */
|
||||
bzero((uchar*) &thd->status_var, sizeof(thd->status_var));
|
||||
thd->set_status_var_init();
|
||||
bzero((uchar*) &thd->org_status_var, sizeof(thd->org_status_var));
|
||||
thd->start_bytes_received= 0;
|
||||
|
||||
|
|
|
@ -534,6 +534,7 @@ inline THD *_current_thd(void)
|
|||
}
|
||||
#endif
|
||||
#define current_thd _current_thd()
|
||||
#define set_current_thd(X) my_pthread_setspecific_ptr(THR_THD, (X))
|
||||
|
||||
/*
|
||||
@todo remove, make it static in ha_maria.cc
|
||||
|
|
|
@ -120,14 +120,15 @@ static my_bool net_write_buff(NET *net,const uchar *packet,ulong len);
|
|||
|
||||
/** Init with packet info. */
|
||||
|
||||
my_bool my_net_init(NET *net, Vio* vio)
|
||||
my_bool my_net_init(NET *net, Vio* vio, uint my_flags)
|
||||
{
|
||||
DBUG_ENTER("my_net_init");
|
||||
DBUG_PRINT("enter", ("my_flags: %u", my_flags));
|
||||
net->vio = vio;
|
||||
my_net_local_init(net); /* Set some limits */
|
||||
if (!(net->buff=(uchar*) my_malloc((size_t) net->max_packet+
|
||||
NET_HEADER_SIZE + COMP_HEADER_SIZE +1,
|
||||
MYF(MY_WME))))
|
||||
MYF(MY_WME | my_flags))))
|
||||
DBUG_RETURN(1);
|
||||
net->buff_end=net->buff+net->max_packet;
|
||||
net->error=0; net->return_status=0;
|
||||
|
@ -139,6 +140,7 @@ my_bool my_net_init(NET *net, Vio* vio)
|
|||
net->net_skip_rest_factor= 0;
|
||||
net->last_errno=0;
|
||||
net->unused= 0;
|
||||
net->thread_specific_malloc= test(my_flags & MY_THREAD_SPECIFIC);
|
||||
|
||||
if (vio != 0) /* If real connection */
|
||||
{
|
||||
|
@ -193,7 +195,9 @@ my_bool net_realloc(NET *net, size_t length)
|
|||
*/
|
||||
if (!(buff= (uchar*) my_realloc((char*) net->buff, pkt_length +
|
||||
NET_HEADER_SIZE + COMP_HEADER_SIZE + 1,
|
||||
MYF(MY_WME))))
|
||||
MYF(MY_WME |
|
||||
(net->thread_specific_malloc ?
|
||||
MY_THREAD_SPECIFIC : 0)))))
|
||||
{
|
||||
/* @todo: 1 and 2 codes are identical. */
|
||||
net->error= 1;
|
||||
|
@ -603,7 +607,10 @@ net_real_write(NET *net,const uchar *packet, size_t len)
|
|||
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))))
|
||||
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;
|
||||
|
|
|
@ -1772,7 +1772,8 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
|
|||
index= key_nr;
|
||||
head= table;
|
||||
key_part_info= head->key_info[index].key_part;
|
||||
my_init_dynamic_array(&ranges, sizeof(QUICK_RANGE*), 16, 16);
|
||||
my_init_dynamic_array(&ranges, sizeof(QUICK_RANGE*), 16, 16,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
|
||||
/* 'thd' is not accessible in QUICK_RANGE_SELECT::reset(). */
|
||||
mrr_buf_size= thd->variables.mrr_buff_size;
|
||||
|
@ -1781,7 +1782,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, thd->variables.range_alloc_block_size, 0);
|
||||
init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
thd->mem_root= &alloc;
|
||||
}
|
||||
else
|
||||
|
@ -1793,7 +1795,7 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
|
|||
|
||||
/* Allocate a bitmap for used columns (Q: why not on MEM_ROOT?) */
|
||||
if (!(bitmap= (my_bitmap_map*) my_malloc(head->s->column_bitmap_size,
|
||||
MYF(MY_WME))))
|
||||
MYF(MY_WME | MY_THREAD_SPECIFIC))))
|
||||
{
|
||||
column_bitmap.bitmap= 0;
|
||||
*create_error= 1;
|
||||
|
@ -1879,7 +1881,8 @@ QUICK_INDEX_SORT_SELECT::QUICK_INDEX_SORT_SELECT(THD *thd_param,
|
|||
index= MAX_KEY;
|
||||
head= table;
|
||||
bzero(&read_record, sizeof(read_record));
|
||||
init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0);
|
||||
init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -1949,7 +1952,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, thd->variables.range_alloc_block_size, 0);
|
||||
init_sql_alloc(&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,
|
||||
|
@ -2232,7 +2236,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, thd->variables.range_alloc_block_size, 0);
|
||||
init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
thd_param->mem_root= &alloc;
|
||||
}
|
||||
|
||||
|
@ -2966,7 +2971,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
|
|||
param.force_default_mrr= ordered_output;
|
||||
|
||||
thd->no_errors=1; // Don't warn about NULL
|
||||
init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0);
|
||||
init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
if (!(param.key_parts=
|
||||
(KEY_PART*) alloc_root(&alloc,
|
||||
sizeof(KEY_PART) *
|
||||
|
@ -3411,7 +3417,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, thd->variables.range_alloc_block_size, 0);
|
||||
init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
range_par->mem_root= &alloc;
|
||||
range_par->old_root= thd->mem_root;
|
||||
|
||||
|
@ -12859,7 +12866,8 @@ 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, join->thd->variables.range_alloc_block_size, 0);
|
||||
init_sql_alloc(&alloc, join->thd->variables.range_alloc_block_size, 0,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
join->thd->mem_root= &alloc;
|
||||
}
|
||||
else
|
||||
|
@ -12914,7 +12922,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))
|
||||
if (my_init_dynamic_array(&min_max_ranges, sizeof(QUICK_RANGE*), 16, 16,
|
||||
MYF(MY_THREAD_SPECIFIC)))
|
||||
return 1;
|
||||
|
||||
if (have_min)
|
||||
|
|
|
@ -3872,7 +3872,7 @@ 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, TABLE_ALLOC_BLOCK_SIZE, 0);
|
||||
init_sql_alloc(&own_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(MY_THREAD_SPECIFIC));
|
||||
if (!multi_alloc_root(&own_root,
|
||||
&table, sizeof(*table),
|
||||
&share, sizeof(*share),
|
||||
|
|
|
@ -776,7 +776,7 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
|
|||
pos= (char*) local_packet->ptr()+local_packet->length();
|
||||
*pos++= 12; // Length of packed fields
|
||||
/* inject a NULL to test the client */
|
||||
DBUG_EXECUTE_IF("poison_rs_fields", pos[-1]= 0xfb;);
|
||||
DBUG_EXECUTE_IF("poison_rs_fields", pos[-1]= (char) 0xfb;);
|
||||
if (item->charset_for_protocol() == &my_charset_bin || thd_charset == NULL)
|
||||
{
|
||||
/* No conversion */
|
||||
|
|
|
@ -588,7 +588,7 @@ static int init_rr_cache(THD *thd, READ_RECORD *info)
|
|||
if (info->cache_records <= 2 ||
|
||||
!(info->cache=(uchar*) my_malloc_lock(rec_cache_size+info->cache_records*
|
||||
info->struct_length+1,
|
||||
MYF(0))))
|
||||
MYF(MY_THREAD_SPECIFIC))))
|
||||
DBUG_RETURN(1);
|
||||
#ifdef HAVE_valgrind
|
||||
// Avoid warnings in qsort
|
||||
|
|
|
@ -573,7 +573,7 @@ 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);
|
||||
TABLE_RULE_ARR_SIZE, 0);
|
||||
*a_inited = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ void delegates_destroy()
|
|||
DYNAMIC_ARRAY *plugins= &s.plugins; \
|
||||
plugin_ref *plugins_buffer= s.plugins_buffer; \
|
||||
my_init_dynamic_array2(plugins, sizeof(plugin_ref), \
|
||||
plugins_buffer, 8, 8); \
|
||||
plugins_buffer, 8, 8, 0); \
|
||||
read_lock(); \
|
||||
Observer_info_iterator iter= observer_info_iter(); \
|
||||
Observer_info *info= iter++; \
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
inited= FALSE;
|
||||
if (my_rwlock_init(&lock, NULL))
|
||||
return;
|
||||
init_sql_alloc(&memroot, 1024, 0);
|
||||
init_sql_alloc(&memroot, 1024, 0, 0);
|
||||
inited= TRUE;
|
||||
}
|
||||
~Delegate()
|
||||
|
|
|
@ -61,7 +61,7 @@ Master_info::Master_info(LEX_STRING *connection_name_arg,
|
|||
my_casedn_str(system_charset_info, cmp_connection_name.str);
|
||||
}
|
||||
|
||||
my_init_dynamic_array(&ignore_server_ids, sizeof(::server_id), 16, 16);
|
||||
my_init_dynamic_array(&ignore_server_ids, sizeof(::server_id), 16, 16, 0);
|
||||
bzero((char*) &file, sizeof(file));
|
||||
mysql_mutex_init(key_master_info_run_lock, &run_lock, MY_MUTEX_INIT_FAST);
|
||||
mysql_mutex_init(key_master_info_data_lock, &data_lock, MY_MUTEX_INIT_FAST);
|
||||
|
|
|
@ -46,7 +46,7 @@ table_mapping::table_mapping()
|
|||
offsetof(entry,table_id),sizeof(ulong),
|
||||
0,0,0);
|
||||
/* We don't preallocate any block, this is consistent with m_free=0 above */
|
||||
init_alloc_root(&m_mem_root, TABLE_ID_HASH_SIZE*sizeof(entry), 0);
|
||||
init_alloc_root(&m_mem_root, TABLE_ID_HASH_SIZE*sizeof(entry), 0, 0);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
|
|
@ -1117,7 +1117,7 @@ bool event_checksum_test(uchar *event_buf, ulong event_len, uint8 alg)
|
|||
|
||||
Deferred_log_events::Deferred_log_events(Relay_log_info *rli) : last_added(NULL)
|
||||
{
|
||||
my_init_dynamic_array(&array, sizeof(Log_event *), 32, 16);
|
||||
my_init_dynamic_array(&array, sizeof(Log_event *), 32, 16, 0);
|
||||
}
|
||||
|
||||
Deferred_log_events::~Deferred_log_events()
|
||||
|
|
31
sql/slave.cc
31
sql/slave.cc
|
@ -1779,7 +1779,9 @@ past_checksum:
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifndef DBUG_OFF
|
||||
after_set_capability:
|
||||
#endif
|
||||
|
||||
err:
|
||||
if (errmsg)
|
||||
|
@ -2426,10 +2428,22 @@ static int init_slave_thread(THD* thd, Master_info *mi,
|
|||
#if !defined(DBUG_OFF)
|
||||
int simulate_error= 0;
|
||||
#endif
|
||||
DBUG_EXECUTE_IF("simulate_io_slave_error_on_init",
|
||||
simulate_error|= (1 << SLAVE_THD_IO););
|
||||
DBUG_EXECUTE_IF("simulate_sql_slave_error_on_init",
|
||||
simulate_error|= (1 << SLAVE_THD_SQL););
|
||||
/* We must call store_globals() before doing my_net_init() */
|
||||
if (init_thr_lock() || thd->store_globals() ||
|
||||
my_net_init(&thd->net, 0, MYF(MY_THREAD_SPECIFIC)) ||
|
||||
IF_DBUG(simulate_error & (1<< thd_type), 0))
|
||||
{
|
||||
thd->cleanup();
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
thd->system_thread = (thd_type == SLAVE_THD_SQL) ?
|
||||
SYSTEM_THREAD_SLAVE_SQL : SYSTEM_THREAD_SLAVE_IO;
|
||||
thd->security_ctx->skip_grants();
|
||||
my_net_init(&thd->net, 0);
|
||||
/*
|
||||
Adding MAX_LOG_EVENT_HEADER_LEN to the max_allowed_packet on all
|
||||
slave threads, since a replication event can become this much larger
|
||||
|
@ -2446,17 +2460,6 @@ static int init_slave_thread(THD* thd, Master_info *mi,
|
|||
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
|
||||
mysql_mutex_unlock(&LOCK_thread_count);
|
||||
|
||||
DBUG_EXECUTE_IF("simulate_io_slave_error_on_init",
|
||||
simulate_error|= (1 << SLAVE_THD_IO););
|
||||
DBUG_EXECUTE_IF("simulate_sql_slave_error_on_init",
|
||||
simulate_error|= (1 << SLAVE_THD_SQL););
|
||||
if (init_thr_lock() || thd->store_globals() ||
|
||||
IF_DBUG(simulate_error & (1<< thd_type), 0))
|
||||
{
|
||||
thd->cleanup();
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
if (thd_type == SLAVE_THD_SQL)
|
||||
thd_proc_info(thd, "Waiting for the next event in relay log");
|
||||
else
|
||||
|
@ -3494,8 +3497,6 @@ err_during_init:
|
|||
mi->rli.relay_log.description_event_for_queue= 0;
|
||||
// TODO: make rpl_status part of Master_info
|
||||
change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
|
||||
DBUG_ASSERT(thd->net.buff != 0);
|
||||
net_end(&thd->net); // destructor will not free it, because net.vio is 0
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
THD_CHECK_SENTRY(thd);
|
||||
delete thd;
|
||||
|
@ -3901,8 +3902,6 @@ err_during_init:
|
|||
to avoid unneeded position re-init
|
||||
*/
|
||||
thd->temporary_tables = 0; // remove tempation from destructor to close them
|
||||
DBUG_ASSERT(thd->net.buff != 0);
|
||||
net_end(&thd->net); // destructor will not free it, because we are weird
|
||||
DBUG_ASSERT(rli->sql_thd == thd);
|
||||
THD_CHECK_SENTRY(thd);
|
||||
rli->sql_thd= 0;
|
||||
|
|
|
@ -510,7 +510,7 @@ sp_head::operator new(size_t size) throw()
|
|||
MEM_ROOT own_root;
|
||||
sp_head *sp;
|
||||
|
||||
init_sql_alloc(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC);
|
||||
init_sql_alloc(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC, 0);
|
||||
sp= (sp_head *) alloc_root(&own_root, size);
|
||||
if (sp == NULL)
|
||||
DBUG_RETURN(NULL);
|
||||
|
@ -594,7 +594,7 @@ sp_head::init(LEX *lex)
|
|||
types of stored procedures to simplify reset_lex()/restore_lex() code.
|
||||
*/
|
||||
lex->trg_table_fields.empty();
|
||||
my_init_dynamic_array(&m_instr, sizeof(sp_instr *), 16, 8);
|
||||
my_init_dynamic_array(&m_instr, sizeof(sp_instr *), 16, 8, 0);
|
||||
|
||||
m_param_begin= NULL;
|
||||
m_param_end= NULL;
|
||||
|
@ -1224,7 +1224,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
|
|||
Reprepare_observer *save_reprepare_observer= thd->m_reprepare_observer;
|
||||
Object_creation_ctx *saved_creation_ctx;
|
||||
Warning_info *saved_warning_info;
|
||||
Warning_info warning_info(thd->warning_info->warn_id(), false);
|
||||
Warning_info warning_info(thd->warning_info->warn_id(), false, true);
|
||||
|
||||
/*
|
||||
Just reporting a stack overrun error
|
||||
|
@ -1254,7 +1254,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
|
|||
DBUG_RETURN(TRUE);
|
||||
|
||||
/* init per-instruction memroot */
|
||||
init_sql_alloc(&execute_mem_root, MEM_ROOT_BLOCK_SIZE, 0);
|
||||
init_sql_alloc(&execute_mem_root, MEM_ROOT_BLOCK_SIZE, 0, 0);
|
||||
|
||||
DBUG_ASSERT(!(m_flags & IS_INVOKED));
|
||||
m_flags|= IS_INVOKED;
|
||||
|
@ -1711,7 +1711,7 @@ 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, MEM_ROOT_BLOCK_SIZE, 0);
|
||||
init_sql_alloc(&call_mem_root, MEM_ROOT_BLOCK_SIZE, 0, 0);
|
||||
thd->set_n_backup_active_arena(&call_arena, &backup_arena);
|
||||
|
||||
if (!(nctx= new sp_rcontext(m_pcont, 0, octx)) ||
|
||||
|
@ -1828,7 +1828,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount,
|
|||
TODO: we should create sp_rcontext once per command and reuse
|
||||
it on subsequent executions of a function/trigger.
|
||||
*/
|
||||
init_sql_alloc(&call_mem_root, MEM_ROOT_BLOCK_SIZE, 0);
|
||||
init_sql_alloc(&call_mem_root, MEM_ROOT_BLOCK_SIZE, 0, 0);
|
||||
thd->set_n_backup_active_arena(&call_arena, &backup_arena);
|
||||
|
||||
if (!(nctx= new sp_rcontext(m_pcont, return_value_fld, octx)) ||
|
||||
|
|
|
@ -61,20 +61,20 @@ sp_pcontext::sp_pcontext()
|
|||
m_label_scope(LABEL_DEFAULT_SCOPE)
|
||||
{
|
||||
(void) my_init_dynamic_array(&m_vars, sizeof(sp_variable_t *),
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC);
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC, 0);
|
||||
(void) my_init_dynamic_array(&m_case_expr_id_lst, sizeof(int),
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC);
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC, 0);
|
||||
(void) my_init_dynamic_array(&m_conds, sizeof(sp_cond_type_t *),
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC);
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC, 0);
|
||||
(void) my_init_dynamic_array(&m_cursors, sizeof(LEX_STRING),
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC);
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC, 0);
|
||||
(void) my_init_dynamic_array(&m_handlers, sizeof(sp_cond_type_t *),
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC);
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC, 0);
|
||||
m_label.empty();
|
||||
m_children.empty();
|
||||
|
||||
|
@ -89,20 +89,20 @@ sp_pcontext::sp_pcontext(sp_pcontext *prev, label_scope_type label_scope)
|
|||
m_label_scope(label_scope)
|
||||
{
|
||||
(void) my_init_dynamic_array(&m_vars, sizeof(sp_variable_t *),
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC);
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC, 0);
|
||||
(void) my_init_dynamic_array(&m_case_expr_id_lst, sizeof(int),
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC);
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC, 0);
|
||||
(void) my_init_dynamic_array(&m_conds, sizeof(sp_cond_type_t *),
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC);
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC, 0);
|
||||
(void) my_init_dynamic_array(&m_cursors, sizeof(LEX_STRING),
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC);
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC, 0);
|
||||
(void) my_init_dynamic_array(&m_handlers, sizeof(sp_cond_type_t *),
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC);
|
||||
PCONTEXT_ARRAY_INIT_ALLOC,
|
||||
PCONTEXT_ARRAY_INCREMENT_ALLOC, 0);
|
||||
m_label.empty();
|
||||
m_children.empty();
|
||||
|
||||
|
|
|
@ -688,7 +688,7 @@ my_bool acl_init(bool dont_read_acl_tables)
|
|||
return_val= acl_reload(thd);
|
||||
delete thd;
|
||||
/* Remember that we don't have a THD */
|
||||
my_pthread_setspecific_ptr(THR_THD, 0);
|
||||
set_current_thd(0);
|
||||
DBUG_RETURN(return_val);
|
||||
}
|
||||
|
||||
|
@ -749,13 +749,13 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
|
|||
|
||||
acl_cache->clear(1); // Clear locked hostname cache
|
||||
|
||||
init_sql_alloc(&mem, ACL_ALLOC_BLOCK_SIZE, 0);
|
||||
init_sql_alloc(&mem, ACL_ALLOC_BLOCK_SIZE, 0, 0);
|
||||
if (init_read_record(&read_record_info,thd,table= tables[0].table,NULL,1,0,
|
||||
FALSE))
|
||||
goto end;
|
||||
|
||||
table->use_all_columns();
|
||||
(void) my_init_dynamic_array(&acl_hosts,sizeof(ACL_HOST),20,50);
|
||||
(void) my_init_dynamic_array(&acl_hosts,sizeof(ACL_HOST), 20, 50, 0);
|
||||
while (!(read_record_info.read_record(&read_record_info)))
|
||||
{
|
||||
ACL_HOST host;
|
||||
|
@ -807,7 +807,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
|
|||
goto end;
|
||||
|
||||
table->use_all_columns();
|
||||
(void) my_init_dynamic_array(&acl_users,sizeof(ACL_USER),50,100);
|
||||
(void) my_init_dynamic_array(&acl_users,sizeof(ACL_USER), 50, 100, 0);
|
||||
password_length= table->field[2]->field_length /
|
||||
table->field[2]->charset()->mbmaxlen;
|
||||
if (password_length < SCRAMBLED_PASSWORD_CHAR_LENGTH_323)
|
||||
|
@ -1009,7 +1009,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
|
|||
goto end;
|
||||
|
||||
table->use_all_columns();
|
||||
(void) my_init_dynamic_array(&acl_dbs,sizeof(ACL_DB),50,100);
|
||||
(void) my_init_dynamic_array(&acl_dbs,sizeof(ACL_DB), 50, 100, 0);
|
||||
while (!(read_record_info.read_record(&read_record_info)))
|
||||
{
|
||||
ACL_DB db;
|
||||
|
@ -1067,7 +1067,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
|
|||
freeze_size(&acl_dbs);
|
||||
|
||||
(void) my_init_dynamic_array(&acl_proxy_users, sizeof(ACL_PROXY_USER),
|
||||
50, 100);
|
||||
50, 100, 0);
|
||||
if (tables[3].table)
|
||||
{
|
||||
init_read_record(&read_record_info, thd, table= tables[3].table, NULL, 1,
|
||||
|
@ -1722,7 +1722,7 @@ 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),
|
||||
acl_users.elements,1);
|
||||
acl_users.elements, 1, 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);
|
||||
|
@ -4121,7 +4121,7 @@ my_bool grant_init()
|
|||
return_val= grant_reload(thd);
|
||||
delete thd;
|
||||
/* Remember that we don't have a THD */
|
||||
my_pthread_setspecific_ptr(THR_THD, 0);
|
||||
set_current_thd(0);
|
||||
DBUG_RETURN(return_val);
|
||||
}
|
||||
|
||||
|
@ -4412,7 +4412,7 @@ my_bool grant_reload(THD *thd)
|
|||
opertion possible in case of failure.
|
||||
*/
|
||||
old_mem= memex;
|
||||
init_sql_alloc(&memex, ACL_ALLOC_BLOCK_SIZE, 0);
|
||||
init_sql_alloc(&memex, ACL_ALLOC_BLOCK_SIZE, 0, 0);
|
||||
|
||||
if ((return_val= grant_load(thd, tables)))
|
||||
{ // Error. Revert to old hash
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue