Commit b3d57979 authored by jani@rhols221.adsl.netsonic.fi's avatar jani@rhols221.adsl.netsonic.fi

Merge work:/home/bk/mysql-4.0/

into rhols221.adsl.netsonic.fi:/home/my/bk/mysql-4.0-new
parents daaf9b1a 7cad1f93
...@@ -164,9 +164,6 @@ enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY, ...@@ -164,9 +164,6 @@ enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
extern "C" { extern "C" {
#endif #endif
extern unsigned long max_allowed_packet;
extern unsigned long net_buffer_length;
int my_net_init(NET *net, Vio* vio); int my_net_init(NET *net, Vio* vio);
void net_end(NET *net); void net_end(NET *net);
void net_clear(NET *net); void net_clear(NET *net);
...@@ -225,6 +222,9 @@ typedef struct st_udf_init ...@@ -225,6 +222,9 @@ typedef struct st_udf_init
extern "C" { extern "C" {
#endif #endif
extern unsigned long max_allowed_packet;
extern unsigned long net_buffer_length;
void randominit(struct rand_struct *,unsigned long seed1, void randominit(struct rand_struct *,unsigned long seed1,
unsigned long seed2); unsigned long seed2);
double rnd(struct rand_struct *); double rnd(struct rand_struct *);
......
...@@ -220,7 +220,7 @@ check_connections2(THD * thd) ...@@ -220,7 +220,7 @@ check_connections2(THD * thd)
if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB) if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB)
db=strend(passwd)+1; db=strend(passwd)+1;
if (thd->client_capabilities & CLIENT_INTERACTIVE) if (thd->client_capabilities & CLIENT_INTERACTIVE)
thd->inactive_timeout=net_interactive_timeout; thd->inactive_timeout= thd->variables.net_interactive_timeout;
if (thd->client_capabilities & CLIENT_TRANSACTIONS) if (thd->client_capabilities & CLIENT_TRANSACTIONS)
thd->net.return_status= &thd->server_status; thd->net.return_status= &thd->server_status;
net->timeout=net_read_timeout; net->timeout=net_read_timeout;
......
...@@ -620,32 +620,32 @@ static void init_variables(const struct my_option *options) ...@@ -620,32 +620,32 @@ static void init_variables(const struct my_option *options)
{ {
switch (options->var_type) { switch (options->var_type) {
case GET_BOOL: case GET_BOOL:
*((my_bool*) options->u_max_value)= *((my_bool*) options->value)= *((my_bool*) options->u_max_value)= (my_bool) options->max_value;
(my_bool) options->def_value; *((my_bool*) options->value)= (my_bool) options->def_value;
break; break;
case GET_INT: case GET_INT:
*((int*) options->u_max_value)= *((int*) options->value)= *((int*) options->u_max_value)= (int) options->max_value;
(int) options->def_value; *((int*) options->value)= (int) options->def_value;
break; break;
case GET_UINT: case GET_UINT:
*((uint*) options->u_max_value)= *((uint*) options->value)= *((uint*) options->u_max_value)= (uint) options->max_value;
(uint) options->def_value; *((uint*) options->value)= (uint) options->def_value;
break; break;
case GET_LONG: case GET_LONG:
*((long*) options->u_max_value)= *((long*) options->value)= *((long*) options->u_max_value)= (long) options->max_value;
(long) options->def_value; *((long*) options->value)= (long) options->def_value;
break; break;
case GET_ULONG: case GET_ULONG:
*((ulong*) options->u_max_value)= *((ulong*) options->value)= *((ulong*) options->u_max_value)= (ulong) options->max_value;
(ulong) options->def_value; *((ulong*) options->value)= (ulong) options->def_value;
break; break;
case GET_LL: case GET_LL:
*((longlong*) options->u_max_value)= *((longlong*) options->value)= *((longlong*) options->u_max_value)= (longlong) options->max_value;
(longlong) options->def_value; *((longlong*) options->value)= (longlong) options->def_value;
break; break;
case GET_ULL: case GET_ULL:
*((ulonglong*) options->u_max_value)= *((ulonglong*) options->value)= *((ulonglong*) options->u_max_value)= (ulonglong) options->max_value;
(ulonglong) options->def_value; *((ulonglong*) options->value)= (ulonglong) options->def_value;
break; break;
default: /* dummy default to avoid compiler warnings */ default: /* dummy default to avoid compiler warnings */
break; break;
......
...@@ -75,6 +75,8 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length, ...@@ -75,6 +75,8 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
uchar **sort_keys; uchar **sort_keys;
IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile; IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile;
SORTPARAM param; SORTPARAM param;
THD *thd= current_thd;
DBUG_ENTER("filesort"); DBUG_ENTER("filesort");
DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length,special);); DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length,special););
#ifdef SKIP_DBUG_IN_FILESORT #ifdef SKIP_DBUG_IN_FILESORT
...@@ -134,7 +136,7 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length, ...@@ -134,7 +136,7 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
goto err; goto err;
#endif #endif
memavl=sortbuff_size; memavl= thd->variables.sortbuff_size;
while (memavl >= MIN_SORT_MEMORY) while (memavl >= MIN_SORT_MEMORY)
{ {
ulong old_memavl; ulong old_memavl;
...@@ -149,7 +151,8 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length, ...@@ -149,7 +151,8 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
} }
if (memavl < MIN_SORT_MEMORY) if (memavl < MIN_SORT_MEMORY)
{ {
my_error(ER_OUTOFMEMORY,MYF(ME_ERROR+ME_WAITTANG),sortbuff_size); my_error(ER_OUTOFMEMORY,MYF(ME_ERROR+ME_WAITTANG),
thd->variables.sortbuff_size);
goto err; goto err;
} }
if (open_cached_file(&buffpek_pointers,mysql_tmpdir,TEMP_PREFIX, if (open_cached_file(&buffpek_pointers,mysql_tmpdir,TEMP_PREFIX,
...@@ -909,6 +912,7 @@ static uint ...@@ -909,6 +912,7 @@ static uint
sortlength(SORT_FIELD *sortorder, uint s_length) sortlength(SORT_FIELD *sortorder, uint s_length)
{ {
reg2 uint length; reg2 uint length;
THD *thd= current_thd;
length=0; length=0;
for (; s_length-- ; sortorder++) for (; s_length-- ; sortorder++)
...@@ -916,7 +920,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length) ...@@ -916,7 +920,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
if (sortorder->field) if (sortorder->field)
{ {
if (sortorder->field->type() == FIELD_TYPE_BLOB) if (sortorder->field->type() == FIELD_TYPE_BLOB)
sortorder->length=max_item_sort_length; sortorder->length= thd->variables.max_item_sort_length;
else else
{ {
sortorder->length=sortorder->field->pack_length(); sortorder->length=sortorder->field->pack_length();
...@@ -952,7 +956,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length) ...@@ -952,7 +956,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
if (sortorder->item->maybe_null) if (sortorder->item->maybe_null)
length++; // Place for NULL marker length++; // Place for NULL marker
} }
set_if_smaller(sortorder->length,max_item_sort_length); set_if_smaller(sortorder->length, thd->variables.max_item_sort_length);
length+=sortorder->length; length+=sortorder->length;
} }
sortorder->field= (Field*) 0; // end marker sortorder->field= (Field*) 0; // end marker
......
...@@ -37,6 +37,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked) ...@@ -37,6 +37,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
ulong max_rows; ulong max_rows;
HP_KEYDEF *keydef; HP_KEYDEF *keydef;
HP_KEYSEG *seg; HP_KEYSEG *seg;
THD *thd= current_thd;
for (key=parts=0 ; key < table->keys ; key++) for (key=parts=0 ; key < table->keys ; key++)
parts+=table->key_info[key].key_parts; parts+=table->key_info[key].key_parts;
...@@ -83,7 +84,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked) ...@@ -83,7 +84,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
} }
} }
mem_per_row += MY_ALIGN(table->reclength+1, sizeof(char*)); mem_per_row += MY_ALIGN(table->reclength+1, sizeof(char*));
max_rows = (ulong) (max_heap_table_size / mem_per_row); max_rows = (ulong) (thd->variables.max_heap_table_size / mem_per_row);
file=heap_open(name,mode, file=heap_open(name,mode,
table->keys,keydef, table->keys,keydef,
table->reclength, table->reclength,
......
...@@ -1040,7 +1040,8 @@ bool Item_sum_count_distinct::setup(THD *thd) ...@@ -1040,7 +1040,8 @@ bool Item_sum_count_distinct::setup(THD *thd)
} }
} }
init_tree(&tree, min(max_heap_table_size, sortbuff_size/16), 0, init_tree(&tree, min(thd->variables.max_heap_table_size,
thd->variables.sortbuff_size/16), 0,
key_length, compare_key, 0, NULL, cmp_arg); key_length, compare_key, 0, NULL, cmp_arg);
use_tree = 1; use_tree = 1;
...@@ -1050,8 +1051,8 @@ bool Item_sum_count_distinct::setup(THD *thd) ...@@ -1050,8 +1051,8 @@ bool Item_sum_count_distinct::setup(THD *thd)
but this has to be handled - otherwise someone can crash but this has to be handled - otherwise someone can crash
the server with a DoS attack the server with a DoS attack
*/ */
max_elements_in_tree = ((key_length) ? max_heap_table_size/key_length : max_elements_in_tree = ((key_length) ?
1); thd->variables.max_heap_table_size/key_length : 1);
} }
return 0; return 0;
} }
......
...@@ -468,7 +468,8 @@ int mysqld_show_create(THD *thd, TABLE_LIST *table_list); ...@@ -468,7 +468,8 @@ int mysqld_show_create(THD *thd, TABLE_LIST *table_list);
void mysqld_list_processes(THD *thd,const char *user,bool verbose); void mysqld_list_processes(THD *thd,const char *user,bool verbose);
int mysqld_show_status(THD *thd); int mysqld_show_status(THD *thd);
int mysqld_show_variables(THD *thd,const char *wild); int mysqld_show_variables(THD *thd,const char *wild);
int mysqld_show(THD *thd, const char *wild, show_var_st *variables); int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
struct system_variables *variable_values);
/* sql_handler.cc */ /* sql_handler.cc */
int mysql_ha_open(THD *thd, TABLE_LIST *tables); int mysql_ha_open(THD *thd, TABLE_LIST *tables);
...@@ -550,8 +551,6 @@ int write_record(TABLE *table,COPY_INFO *info); ...@@ -550,8 +551,6 @@ int write_record(TABLE *table,COPY_INFO *info);
extern ulong volatile manager_status; extern ulong volatile manager_status;
extern bool volatile manager_thread_in_use, mqh_used; extern bool volatile manager_thread_in_use, mqh_used;
extern pthread_t manager_thread; extern pthread_t manager_thread;
extern pthread_mutex_t LOCK_manager;
extern pthread_cond_t COND_manager;
pthread_handler_decl(handle_manager, arg); pthread_handler_decl(handle_manager, arg);
/* sql_test.cc */ /* sql_test.cc */
...@@ -611,12 +610,13 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, ...@@ -611,12 +610,13 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open,
LOCK_thread_count,LOCK_mapped_file,LOCK_user_locks, LOCK_status, LOCK_thread_count,LOCK_mapped_file,LOCK_user_locks, LOCK_status,
LOCK_grant, LOCK_error_log, LOCK_delayed_insert, LOCK_grant, LOCK_error_log, LOCK_delayed_insert,
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
LOCK_server_id, LOCK_slave_list, LOCK_active_mi; LOCK_server_id, LOCK_slave_list, LOCK_active_mi, LOCK_manager,
extern pthread_cond_t COND_refresh,COND_thread_count; LOCK_global_system_variables;
extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
extern pthread_attr_t connection_attrib; extern pthread_attr_t connection_attrib;
extern bool opt_endinfo, using_udf_functions, locked_in_memory, extern bool opt_endinfo, using_udf_functions, locked_in_memory,
opt_using_transactions, use_temp_pool, mysql_embedded; opt_using_transactions, use_temp_pool, mysql_embedded;
extern my_bool opt_local_infile;
extern char f_fyllchar; extern char f_fyllchar;
extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count, extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
ha_read_key_count, ha_read_next_count, ha_read_prev_count, ha_read_key_count, ha_read_next_count, ha_read_prev_count,
...@@ -628,20 +628,19 @@ extern uchar *days_in_month; ...@@ -628,20 +628,19 @@ extern uchar *days_in_month;
extern DATE_FORMAT dayord; extern DATE_FORMAT dayord;
extern double log_10[32]; extern double log_10[32];
extern uint protocol_version,dropping_tables; extern uint protocol_version,dropping_tables;
extern ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size, extern ulong keybuff_size,table_cache_size,
max_join_size,join_buff_size,tmp_table_size, max_connections,max_connect_errors,
max_connections,max_connect_errors,long_query_time,
max_insert_delayed_threads, max_user_connections, max_insert_delayed_threads, max_user_connections,
long_query_count,net_wait_timeout,net_interactive_timeout, long_query_count,
net_read_timeout,net_write_timeout, net_read_timeout,net_write_timeout,
what_to_log,flush_time,opt_sql_mode, what_to_log,flush_time,opt_sql_mode,
max_tmp_tables,max_heap_table_size,query_buff_size, query_buff_size, lower_case_table_names,
lower_case_table_names,thread_stack,thread_stack_min, thread_stack,thread_stack_min,
binlog_cache_size, max_binlog_cache_size, record_rnd_cache_size; binlog_cache_size, max_binlog_cache_size;
extern ulong com_stat[(uint) SQLCOM_END], com_other; extern ulong com_stat[(uint) SQLCOM_END], com_other;
extern ulong specialflag, current_pid; extern ulong specialflag, current_pid;
extern bool low_priority_updates, using_update_log; extern bool low_priority_updates, using_update_log;
extern bool opt_sql_bin_update, opt_safe_show_db, opt_warnings, extern bool opt_sql_bin_update, opt_safe_show_db,
opt_safe_user_create, opt_no_mix_types; opt_safe_user_create, opt_no_mix_types;
extern char language[LIBLEN],reg_ext[FN_EXTLEN],blob_newline; extern char language[LIBLEN],reg_ext[FN_EXTLEN],blob_newline;
extern const char **errmesg; /* Error messages */ extern const char **errmesg; /* Error messages */
...@@ -649,6 +648,7 @@ extern const char *default_tx_isolation_name; ...@@ -649,6 +648,7 @@ extern const char *default_tx_isolation_name;
extern String empty_string; extern String empty_string;
extern struct show_var_st init_vars[]; extern struct show_var_st init_vars[];
extern struct show_var_st status_vars[]; extern struct show_var_st status_vars[];
extern struct system_variables global_system_variables;
extern enum db_type default_table_type; extern enum db_type default_table_type;
extern enum enum_tx_isolation default_tx_isolation; extern enum enum_tx_isolation default_tx_isolation;
extern char glob_hostname[FN_REFLEN]; extern char glob_hostname[FN_REFLEN];
......
...@@ -299,13 +299,15 @@ uint volatile thread_count=0, thread_running=0, kill_cached_threads=0, ...@@ -299,13 +299,15 @@ uint volatile thread_count=0, thread_running=0, kill_cached_threads=0,
ulong thd_startup_options=(OPTION_UPDATE_LOG | OPTION_AUTO_IS_NULL | ulong thd_startup_options=(OPTION_UPDATE_LOG | OPTION_AUTO_IS_NULL |
OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE ); OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE );
uint protocol_version=PROTOCOL_VERSION; uint protocol_version=PROTOCOL_VERSION;
ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size, struct system_variables global_system_variables;
max_join_size,join_buff_size,tmp_table_size,thread_stack, struct system_variables max_system_variables;
thread_stack_min,net_wait_timeout,what_to_log= ~ (1L << (uint) COM_TIME), ulong keybuff_size,table_cache_size,
thread_stack,
thread_stack_min,what_to_log= ~ (1L << (uint) COM_TIME),
query_buff_size, lower_case_table_names, mysqld_net_retry_count, query_buff_size, lower_case_table_names, mysqld_net_retry_count,
net_interactive_timeout, slow_launch_time = 2L, slow_launch_time = 2L,
net_read_timeout,net_write_timeout,slave_open_temp_tables=0, net_read_timeout,net_write_timeout,slave_open_temp_tables=0,
open_files_limit=0, max_binlog_size, record_rnd_cache_size; open_files_limit=0, max_binlog_size;
ulong com_stat[(uint) SQLCOM_END], com_other; ulong com_stat[(uint) SQLCOM_END], com_other;
ulong slave_net_timeout; ulong slave_net_timeout;
ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0; ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
...@@ -330,16 +332,15 @@ uint master_port = MYSQL_PORT, master_connect_retry = 60; ...@@ -330,16 +332,15 @@ uint master_port = MYSQL_PORT, master_connect_retry = 60;
uint report_port = MYSQL_PORT; uint report_port = MYSQL_PORT;
bool master_ssl = 0; bool master_ssl = 0;
ulong max_tmp_tables,max_heap_table_size,master_retry_count=0; ulong master_retry_count=0;
ulong bytes_sent = 0L, bytes_received = 0L; ulong bytes_sent = 0L, bytes_received = 0L;
bool opt_endinfo,using_udf_functions,low_priority_updates, locked_in_memory; bool opt_endinfo,using_udf_functions,low_priority_updates, locked_in_memory;
bool opt_using_transactions, using_update_log, opt_warnings=0; bool opt_using_transactions, using_update_log;
my_bool opt_local_infile=1;
bool volatile abort_loop,select_thread_in_use,grant_option; bool volatile abort_loop,select_thread_in_use,grant_option;
bool volatile ready_to_exit,shutdown_in_progress; bool volatile ready_to_exit,shutdown_in_progress;
ulong refresh_version=1L,flush_version=1L; /* Increments on each reload */ ulong refresh_version=1L,flush_version=1L; /* Increments on each reload */
ulong query_id=1L,long_query_count,long_query_time,aborted_threads, ulong query_id=1L,long_query_count,aborted_threads,
aborted_connects,delayed_insert_timeout,delayed_insert_limit, aborted_connects,delayed_insert_timeout,delayed_insert_limit,
delayed_queue_size,delayed_insert_threads,delayed_insert_writes, delayed_queue_size,delayed_insert_threads,delayed_insert_writes,
delayed_rows_in_use,delayed_insert_errors,flush_time, thread_created; delayed_rows_in_use,delayed_insert_errors,flush_time, thread_created;
...@@ -353,7 +354,6 @@ ulong max_connections,max_insert_delayed_threads,max_used_connections, ...@@ -353,7 +354,6 @@ ulong max_connections,max_insert_delayed_threads,max_used_connections,
max_connect_errors, max_user_connections = 0; max_connect_errors, max_user_connections = 0;
ulong thread_id=1L,current_pid; ulong thread_id=1L,current_pid;
ulong slow_launch_threads = 0; ulong slow_launch_threads = 0;
ulong myisam_max_sort_file_size, myisam_max_extra_sort_file_size;
char mysql_real_data_home[FN_REFLEN], char mysql_real_data_home[FN_REFLEN],
language[LIBLEN],reg_ext[FN_EXTLEN], language[LIBLEN],reg_ext[FN_EXTLEN],
...@@ -407,7 +407,7 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count, ...@@ -407,7 +407,7 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count,
LOCK_error_log, LOCK_error_log,
LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create, LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create,
LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received, LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
LOCK_server_id, LOCK_server_id, LOCK_global_system_variables,
LOCK_user_conn, LOCK_slave_list, LOCK_active_mi; LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
pthread_cond_t COND_refresh,COND_thread_count,COND_binlog_update, pthread_cond_t COND_refresh,COND_thread_count,COND_binlog_update,
...@@ -762,7 +762,7 @@ static pthread_handler_decl(kill_server_thread,arg __attribute__((unused))) ...@@ -762,7 +762,7 @@ static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
static sig_handler print_signal_warning(int sig) static sig_handler print_signal_warning(int sig)
{ {
if (opt_warnings) if (current_thd->variables.opt_warnings)
sql_print_error("Warning: Got signal %d from thread %d", sql_print_error("Warning: Got signal %d from thread %d",
sig,my_thread_id()); sig,my_thread_id());
#ifdef DONT_REMEMBER_SIGNAL #ifdef DONT_REMEMBER_SIGNAL
...@@ -1331,14 +1331,15 @@ the problem, but since we have already crashed, something is definitely wrong\n\ ...@@ -1331,14 +1331,15 @@ the problem, but since we have already crashed, something is definitely wrong\n\
and this may fail.\n\n"); and this may fail.\n\n");
fprintf(stderr, "key_buffer_size=%ld\n", keybuff_size); fprintf(stderr, "key_buffer_size=%ld\n", keybuff_size);
fprintf(stderr, "record_buffer=%ld\n", my_default_record_cache_size); fprintf(stderr, "record_buffer=%ld\n", my_default_record_cache_size);
fprintf(stderr, "sort_buffer=%ld\n", sortbuff_size); fprintf(stderr, "sort_buffer=%ld\n", thd->variables.sortbuff_size);
fprintf(stderr, "max_used_connections=%ld\n", max_used_connections); fprintf(stderr, "max_used_connections=%ld\n", max_used_connections);
fprintf(stderr, "max_connections=%ld\n", max_connections); fprintf(stderr, "max_connections=%ld\n", max_connections);
fprintf(stderr, "threads_connected=%d\n", thread_count); fprintf(stderr, "threads_connected=%d\n", thread_count);
fprintf(stderr, "It is possible that mysqld could use up to \n\ fprintf(stderr, "It is possible that mysqld could use up to \n\
key_buffer_size + (record_buffer + sort_buffer)*max_connections = %ld K\n\ key_buffer_size + (record_buffer + sort_buffer)*max_connections = %ld K\n\
bytes of memory\n", (keybuff_size + (my_default_record_cache_size + bytes of memory\n", (keybuff_size + (my_default_record_cache_size +
sortbuff_size) * max_connections)/ 1024); thd->variables.sortbuff_size) *
max_connections)/ 1024);
fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n"); fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n");
#if defined(HAVE_LINUXTHREADS) #if defined(HAVE_LINUXTHREADS)
...@@ -1827,6 +1828,7 @@ int main(int argc, char **argv) ...@@ -1827,6 +1828,7 @@ int main(int argc, char **argv)
(void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
(void) pthread_cond_init(&COND_thread_count,NULL); (void) pthread_cond_init(&COND_thread_count,NULL);
(void) pthread_cond_init(&COND_refresh,NULL); (void) pthread_cond_init(&COND_refresh,NULL);
(void) pthread_cond_init(&COND_thread_cache,NULL); (void) pthread_cond_init(&COND_thread_cache,NULL);
...@@ -2974,7 +2976,8 @@ static struct my_option my_long_options[] = ...@@ -2974,7 +2976,8 @@ static struct my_option my_long_options[] =
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"local-infile", OPT_LOCAL_INFILE, {"local-infile", OPT_LOCAL_INFILE,
"Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0)", "Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0)",
(gptr*) &opt_local_infile, (gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG, (gptr*) &global_system_variables.opt_local_infile,
(gptr*) &max_system_variables.opt_local_infile, 0, GET_BOOL, OPT_ARG,
1, 0, 0, 0, 0, 0}, 1, 0, 0, 0, 0, 0},
{"log-bin", OPT_BIN_LOG, {"log-bin", OPT_BIN_LOG,
"Log queries in new binary format (for replication)", "Log queries in new binary format (for replication)",
...@@ -3250,7 +3253,8 @@ static struct my_option my_long_options[] = ...@@ -3250,7 +3253,8 @@ static struct my_option my_long_options[] =
{"version", 'v', "Synonym for option -v", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, {"version", 'v', "Synonym for option -v", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"warnings", 'W', "Log some not critical warnings to the log file", {"warnings", 'W', "Log some not critical warnings to the log file",
(gptr*) &opt_warnings, (gptr*) &opt_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0, (gptr*) &global_system_variables.opt_warnings,
(gptr*) &max_system_variables.opt_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{ "back_log", OPT_BACK_LOG, { "back_log", OPT_BACK_LOG,
"The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.", (gptr*) &back_log, (gptr*) &back_log, 0, GET_ULONG, "The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.", (gptr*) &back_log, (gptr*) &back_log, 0, GET_ULONG,
...@@ -3355,11 +3359,13 @@ static struct my_option my_long_options[] = ...@@ -3355,11 +3359,13 @@ static struct my_option my_long_options[] =
#endif /* HAVE_INNOBASE_DB */ #endif /* HAVE_INNOBASE_DB */
{"interactive_timeout", OPT_INTERACTIVE_TIMEOUT, {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
"The number of seconds the server waits for activity on an interactive connection before closing it.", "The number of seconds the server waits for activity on an interactive connection before closing it.",
(gptr*) &net_interactive_timeout, (gptr*) &net_interactive_timeout, 0, (gptr*) &global_system_variables.net_interactive_timeout,
(gptr*) &max_system_variables.net_interactive_timeout, 0,
GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
{"join_buffer_size", OPT_JOIN_BUFF_SIZE, {"join_buffer_size", OPT_JOIN_BUFF_SIZE,
"The size of the buffer that is used for full joins.", "The size of the buffer that is used for full joins.",
(gptr*) &join_buff_size, (gptr*) &join_buff_size, 0, GET_ULONG, (gptr*) &global_system_variables.join_buff_size,
(gptr*) &max_system_variables.join_buff_size, 0, GET_ULONG,
REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD,
IO_SIZE, 0}, IO_SIZE, 0},
{"key_buffer_size", OPT_KEY_BUFFER_SIZE, {"key_buffer_size", OPT_KEY_BUFFER_SIZE,
...@@ -3368,15 +3374,18 @@ static struct my_option my_long_options[] = ...@@ -3368,15 +3374,18 @@ static struct my_option my_long_options[] =
KEY_CACHE_SIZE, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE, 0}, KEY_CACHE_SIZE, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE, 0},
{"long_query_time", OPT_LONG_QUERY_TIME, {"long_query_time", OPT_LONG_QUERY_TIME,
"Log all queries that have taken more than long_query_time seconds to execute to file.", "Log all queries that have taken more than long_query_time seconds to execute to file.",
(gptr*) &long_query_time, (gptr*) &long_query_time, 0, GET_ULONG, (gptr*) &global_system_variables.long_query_time,
(gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0}, REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
{"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES, {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
"If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive.", "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive.",
(gptr*) &lower_case_table_names, (gptr*) &lower_case_table_names, 0, (gptr*) &lower_case_table_names,
(gptr*) &lower_case_table_names, 0,
GET_ULONG, REQUIRED_ARG, IF_WIN(1,0), 0, 1, 0, 1, 0}, GET_ULONG, REQUIRED_ARG, IF_WIN(1,0), 0, 1, 0, 1, 0},
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
"Max packetlength to send/receive from to server.", "Max packetlength to send/receive from to server.",
(gptr*) &max_allowed_packet, (gptr*) &max_allowed_packet, 0, GET_ULONG, (gptr*) &max_allowed_packet,
(gptr*) &max_allowed_packet, 0, GET_ULONG,
REQUIRED_ARG, 1024*1024L, 80, 64*1024*1024L, MALLOC_OVERHEAD, 1024, 0}, REQUIRED_ARG, 1024*1024L, 80, 64*1024*1024L, MALLOC_OVERHEAD, 1024, 0},
{"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE, {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE,
"Can be used to restrict the total size used to cache a multi-transaction query.", "Can be used to restrict the total size used to cache a multi-transaction query.",
...@@ -3400,19 +3409,23 @@ static struct my_option my_long_options[] = ...@@ -3400,19 +3409,23 @@ static struct my_option my_long_options[] =
0, GET_ULONG, REQUIRED_ARG, 20, 1, 16384, 0, 1, 0}, 0, GET_ULONG, REQUIRED_ARG, 20, 1, 16384, 0, 1, 0},
{"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE, {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
"Don't allow creation of heap tables bigger than this.", "Don't allow creation of heap tables bigger than this.",
(gptr*) &max_heap_table_size, (gptr*) &max_heap_table_size, 0, GET_ULONG, (gptr*) &global_system_variables.max_heap_table_size,
(gptr*) &max_system_variables.max_heap_table_size, 0, GET_ULONG,
REQUIRED_ARG, 16*1024*1024L, 16384, ~0L, MALLOC_OVERHEAD, 1024, 0}, REQUIRED_ARG, 16*1024*1024L, 16384, ~0L, MALLOC_OVERHEAD, 1024, 0},
{"max_join_size", OPT_MAX_JOIN_SIZE, {"max_join_size", OPT_MAX_JOIN_SIZE,
"Joins that are probably going to read more than max_join_size records return an error.", "Joins that are probably going to read more than max_join_size records return an error.",
(gptr*) &max_join_size, (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &global_system_variables.max_join_size,
(gptr*) &max_system_variables.max_join_size, 0, GET_ULONG, REQUIRED_ARG,
~0L, 1, ~0L, 0, 1, 0}, ~0L, 1, ~0L, 0, 1, 0},
{"max_sort_length", OPT_MAX_SORT_LENGTH, {"max_sort_length", OPT_MAX_SORT_LENGTH,
"The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored).", "The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored).",
(gptr*) &max_item_sort_length, (gptr*) &max_item_sort_length, 0, GET_ULONG, (gptr*) &global_system_variables.max_item_sort_length,
(gptr*) &max_system_variables.max_item_sort_length, 0, GET_ULONG,
REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0}, REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
{"max_tmp_tables", OPT_MAX_TMP_TABLES, {"max_tmp_tables", OPT_MAX_TMP_TABLES,
"Maximum number of temporary tables a client can keep open at a time.", "Maximum number of temporary tables a client can keep open at a time.",
(gptr*) &max_tmp_tables, (gptr*) &max_tmp_tables, 0, GET_ULONG, (gptr*) &global_system_variables.max_tmp_tables,
(gptr*) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0}, REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0},
{"max_user_connections", OPT_MAX_USER_CONNECTIONS, {"max_user_connections", OPT_MAX_USER_CONNECTIONS,
"The maximum number of active connections for a single user (0 = no limit).", "The maximum number of active connections for a single user (0 = no limit).",
...@@ -3425,8 +3438,8 @@ static struct my_option my_long_options[] = ...@@ -3425,8 +3438,8 @@ static struct my_option my_long_options[] =
{"myisam_bulk_insert_tree_size", OPT_MYISAM_BULK_INSERT_TREE_SIZE, {"myisam_bulk_insert_tree_size", OPT_MYISAM_BULK_INSERT_TREE_SIZE,
"Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread!", "Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread!",
(gptr*) &myisam_bulk_insert_tree_size, (gptr*) &myisam_bulk_insert_tree_size,
(gptr*) &myisam_bulk_insert_tree_size, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &myisam_bulk_insert_tree_size,
8192*1024, 0, ~0L, 0, 1, 0}, 0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ~0L, 0, 1, 0},
{"myisam_block_size", OPT_MYISAM_BLOCK_SIZE, {"myisam_block_size", OPT_MYISAM_BLOCK_SIZE,
"Undocumented", (gptr*) &opt_myisam_block_size, "Undocumented", (gptr*) &opt_myisam_block_size,
(gptr*) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG,
...@@ -3434,32 +3447,37 @@ static struct my_option my_long_options[] = ...@@ -3434,32 +3447,37 @@ static struct my_option my_long_options[] =
0, MI_MIN_KEY_BLOCK_LENGTH, 0}, 0, MI_MIN_KEY_BLOCK_LENGTH, 0},
{"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE, {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
"Used to help MySQL to decide when to use the slow but safe key cache index create method. Note that this parameter is given in megabytes!", "Used to help MySQL to decide when to use the slow but safe key cache index create method. Note that this parameter is given in megabytes!",
(gptr*) &myisam_max_extra_sort_file_size, (gptr*) &global_system_variables.myisam_max_extra_sort_file_size,
(gptr*) &myisam_max_extra_sort_file_size, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &max_system_variables.myisam_max_extra_sort_file_size,
(long) (MI_MAX_TEMP_LENGTH/(1024L*1024L)), 0, ~0L, 0, 1, 0}, 0, GET_ULONG, REQUIRED_ARG, (long) (MI_MAX_TEMP_LENGTH/(1024L*1024L)),
0, ~0L, 0, 1, 0},
{"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE, {"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE,
"Don't use the fast sort index method to created index if the temporary file would get bigger than this. Note that this paramter is given in megabytes!", "Don't use the fast sort index method to created index if the temporary file would get bigger than this. Note that this paramter is given in megabytes!",
(gptr*) &myisam_max_sort_file_size, (gptr*) &myisam_max_sort_file_size, 0, (gptr*) &global_system_variables.myisam_max_sort_file_size,
(gptr*) &max_system_variables.myisam_max_sort_file_size, 0,
GET_ULONG, REQUIRED_ARG, (long) (LONG_MAX/(1024L*1024L)), 0, ~0L, 0, 1, 0}, GET_ULONG, REQUIRED_ARG, (long) (LONG_MAX/(1024L*1024L)), 0, ~0L, 0, 1, 0},
{"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE, {"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE,
"The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.", "The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.",
(gptr*) &myisam_sort_buffer_size, (gptr*) &myisam_sort_buffer_size, 0, (gptr*) &myisam_sort_buffer_size, (gptr*) &myisam_sort_buffer_size, 0,
GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0}, GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, {"net_buffer_length", OPT_NET_BUFFER_LENGTH,
"Buffer for TCP/IP and socket communication.", (gptr*) &net_buffer_length, "Buffer for TCP/IP and socket communication.",
(gptr*) &net_buffer_length, 0, GET_ULONG, REQUIRED_ARG, 16384, 1024, (gptr*) &net_buffer_length,
1024*1024L, MALLOC_OVERHEAD, 1024, 0}, (gptr*) &net_buffer_length, 0, GET_ULONG,
REQUIRED_ARG, 16384, 1024, 1024*1024L, MALLOC_OVERHEAD, 1024, 0},
{"net_retry_count", OPT_NET_RETRY_COUNT, {"net_retry_count", OPT_NET_RETRY_COUNT,
"If a read on a communication port is interrupted, retry this many times before giving up.", "If a read on a communication port is interrupted, retry this many times before giving up.",
(gptr*) &mysqld_net_retry_count, (gptr*) &mysqld_net_retry_count, 0, (gptr*) &mysqld_net_retry_count, (gptr*) &mysqld_net_retry_count, 0,
GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ~0L, 0, 1, 0}, GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ~0L, 0, 1, 0},
{"net_read_timeout", OPT_NET_READ_TIMEOUT, {"net_read_timeout", OPT_NET_READ_TIMEOUT,
"Number of seconds to wait for more data from a connection before aborting the read.", "Number of seconds to wait for more data from a connection before aborting the read.",
(gptr*) &net_read_timeout, (gptr*) &net_read_timeout, 0, GET_ULONG, (gptr*) &net_read_timeout,
(gptr*) &net_read_timeout, 0, GET_ULONG,
REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
{"net_write_timeout", OPT_NET_WRITE_TIMEOUT, {"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
"Number of seconds to wait for a block to be written to a connection before aborting the write.", "Number of seconds to wait for a block to be written to a connection before aborting the write.",
(gptr*) &net_write_timeout, (gptr*) &net_write_timeout, 0, GET_ULONG, (gptr*) &net_write_timeout,
(gptr*) &net_write_timeout, 0, GET_ULONG,
REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
{"open_files_limit", OPT_OPEN_FILES_LIMIT, {"open_files_limit", OPT_OPEN_FILES_LIMIT,
"If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of files.", "If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of files.",
...@@ -3492,7 +3510,8 @@ static struct my_option my_long_options[] = ...@@ -3492,7 +3510,8 @@ static struct my_option my_long_options[] =
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0}, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0},
{"record_rnd_buffer", OPT_RECORD_RND_BUFFER, {"record_rnd_buffer", OPT_RECORD_RND_BUFFER,
"When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks. If not set, then it's set to the value of record_buffer.", "When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks. If not set, then it's set to the value of record_buffer.",
(gptr*) &record_rnd_cache_size, (gptr*) &record_rnd_cache_size, 0, (gptr*) &global_system_variables.record_rnd_cache_size,
(gptr*) &max_system_variables.record_rnd_cache_size, 0,
GET_ULONG, REQUIRED_ARG, 0, IO_SIZE*2+MALLOC_OVERHEAD, GET_ULONG, REQUIRED_ARG, 0, IO_SIZE*2+MALLOC_OVERHEAD,
~0L, MALLOC_OVERHEAD, IO_SIZE, 0}, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0},
{"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT, {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT,
...@@ -3509,7 +3528,8 @@ static struct my_option my_long_options[] = ...@@ -3509,7 +3528,8 @@ static struct my_option my_long_options[] =
REQUIRED_ARG, 2L, 0L, LONG_TIMEOUT, 0, 1, 0}, REQUIRED_ARG, 2L, 0L, LONG_TIMEOUT, 0, 1, 0},
{"sort_buffer", OPT_SORT_BUFFER, {"sort_buffer", OPT_SORT_BUFFER,
"Each thread that needs to do a sort allocates a buffer of this size.", "Each thread that needs to do a sort allocates a buffer of this size.",
(gptr*) &sortbuff_size, (gptr*) &sortbuff_size, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &global_system_variables.sortbuff_size,
(gptr*) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ~0L, MALLOC_OVERHEAD, MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ~0L, MALLOC_OVERHEAD,
1, 0}, 1, 0},
{"table_cache", OPT_TABLE_CACHE, {"table_cache", OPT_TABLE_CACHE,
...@@ -3526,7 +3546,8 @@ static struct my_option my_long_options[] = ...@@ -3526,7 +3546,8 @@ static struct my_option my_long_options[] =
REQUIRED_ARG, 0, 0, 16384, 0, 1, 0}, REQUIRED_ARG, 0, 0, 16384, 0, 1, 0},
{"tmp_table_size", OPT_TMP_TABLE_SIZE, {"tmp_table_size", OPT_TMP_TABLE_SIZE,
"If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.", "If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.",
(gptr*) &tmp_table_size, (gptr*) &tmp_table_size, 0, GET_ULONG, (gptr*) &global_system_variables.tmp_table_size,
(gptr*) &max_system_variables.tmp_table_size, 0, GET_ULONG,
REQUIRED_ARG, 32*1024*1024L, 1024, ~0L, 0, 1, 0}, REQUIRED_ARG, 32*1024*1024L, 1024, ~0L, 0, 1, 0},
{"thread_stack", OPT_THREAD_STACK, {"thread_stack", OPT_THREAD_STACK,
"The stack size for each thread.", (gptr*) &thread_stack, "The stack size for each thread.", (gptr*) &thread_stack,
...@@ -3534,7 +3555,8 @@ static struct my_option my_long_options[] = ...@@ -3534,7 +3555,8 @@ static struct my_option my_long_options[] =
1024*32, ~0L, 0, 1024, 0}, 1024*32, ~0L, 0, 1024, 0},
{"wait_timeout", OPT_WAIT_TIMEOUT, {"wait_timeout", OPT_WAIT_TIMEOUT,
"The number of seconds the server waits for activity on a connection before closing it", "The number of seconds the server waits for activity on a connection before closing it",
(gptr*) &net_wait_timeout, (gptr*) &net_wait_timeout, 0, GET_ULONG, (gptr*) &global_system_variables.net_wait_timeout,
(gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
...@@ -3596,11 +3618,18 @@ struct show_var_st init_vars[]= { ...@@ -3596,11 +3618,18 @@ struct show_var_st init_vars[]= {
{"innodb_log_group_home_dir", (char*) &innobase_log_group_home_dir, SHOW_CHAR_PTR}, {"innodb_log_group_home_dir", (char*) &innobase_log_group_home_dir, SHOW_CHAR_PTR},
{"innodb_mirrored_log_groups", (char*) &innobase_mirrored_log_groups, SHOW_LONG}, {"innodb_mirrored_log_groups", (char*) &innobase_mirrored_log_groups, SHOW_LONG},
#endif #endif
{"interactive_timeout", (char*) &net_interactive_timeout, SHOW_LONG}, {"interactive_timeout",
{"join_buffer_size", (char*) &join_buff_size, SHOW_LONG}, (char*) offsetof(struct system_variables, net_interactive_timeout),
SHOW_LONG_OFFSET},
{"join_buffer_size",
(char*) offsetof(struct system_variables, join_buff_size),
SHOW_LONG_OFFSET},
{"key_buffer_size", (char*) &keybuff_size, SHOW_LONG}, {"key_buffer_size", (char*) &keybuff_size, SHOW_LONG},
{"language", language, SHOW_CHAR}, {"language", language, SHOW_CHAR},
{"large_files_support", (char*) &opt_large_files, SHOW_BOOL}, {"large_files_support", (char*) &opt_large_files, SHOW_BOOL},
{"local_infile",
(char*) offsetof(struct system_variables, opt_local_infile),
SHOW_MY_BOOL_OFFSET},
#ifdef HAVE_MLOCKALL #ifdef HAVE_MLOCKALL
{"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL}, {"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL},
#endif #endif
...@@ -3609,7 +3638,9 @@ struct show_var_st init_vars[]= { ...@@ -3609,7 +3638,9 @@ struct show_var_st init_vars[]= {
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL}, {"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
{"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_BOOL}, {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_BOOL},
{"log_slow_queries", (char*) &opt_slow_log, SHOW_BOOL}, {"log_slow_queries", (char*) &opt_slow_log, SHOW_BOOL},
{"long_query_time", (char*) &long_query_time, SHOW_LONG}, {"long_query_time",
(char*) offsetof(struct system_variables, long_query_time),
SHOW_LONG_OFFSET},
{"low_priority_updates", (char*) &low_priority_updates, SHOW_BOOL}, {"low_priority_updates", (char*) &low_priority_updates, SHOW_BOOL},
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_LONG}, {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_LONG},
{"max_allowed_packet", (char*) &max_allowed_packet, SHOW_LONG}, {"max_allowed_packet", (char*) &max_allowed_packet, SHOW_LONG},
...@@ -3618,16 +3649,28 @@ struct show_var_st init_vars[]= { ...@@ -3618,16 +3649,28 @@ struct show_var_st init_vars[]= {
{"max_connections", (char*) &max_connections, SHOW_LONG}, {"max_connections", (char*) &max_connections, SHOW_LONG},
{"max_connect_errors", (char*) &max_connect_errors, SHOW_LONG}, {"max_connect_errors", (char*) &max_connect_errors, SHOW_LONG},
{"max_delayed_threads", (char*) &max_insert_delayed_threads, SHOW_LONG}, {"max_delayed_threads", (char*) &max_insert_delayed_threads, SHOW_LONG},
{"max_heap_table_size", (char*) &max_heap_table_size, SHOW_LONG}, {"max_heap_table_size",
{"max_join_size", (char*) &max_join_size, SHOW_LONG}, (char*) offsetof(struct system_variables, max_heap_table_size),
{"max_sort_length", (char*) &max_item_sort_length, SHOW_LONG}, SHOW_LONG_OFFSET},
{"max_join_size",
(char*) offsetof(struct system_variables, max_join_size),
SHOW_LONG_OFFSET},
{"max_sort_length",
(char*) offsetof(struct system_variables, max_item_sort_length),
SHOW_LONG_OFFSET},
{"max_user_connections", (char*) &max_user_connections, SHOW_LONG}, {"max_user_connections", (char*) &max_user_connections, SHOW_LONG},
{"max_tmp_tables", (char*) &max_tmp_tables, SHOW_LONG}, {"max_tmp_tables",
(char*) offsetof(struct system_variables, max_tmp_tables),
SHOW_LONG_OFFSET},
{"max_write_lock_count", (char*) &max_write_lock_count, SHOW_LONG}, {"max_write_lock_count", (char*) &max_write_lock_count, SHOW_LONG},
{"myisam_bulk_insert_tree_size", (char*) &myisam_bulk_insert_tree_size, SHOW_INT}, {"myisam_bulk_insert_tree_size", (char*) &myisam_bulk_insert_tree_size, SHOW_INT},
{"myisam_max_extra_sort_file_size", (char*) &myisam_max_extra_sort_file_size, {"myisam_max_extra_sort_file_size",
SHOW_LONG}, (char*) offsetof(struct system_variables,
{"myisam_max_sort_file_size",(char*) &myisam_max_sort_file_size, SHOW_LONG}, myisam_max_extra_sort_file_size),
SHOW_LONG_OFFSET},
{"myisam_max_sort_file_size",
(char*) offsetof(struct system_variables, myisam_max_sort_file_size),
SHOW_LONG_OFFSET},
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR}, {"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
{"myisam_sort_buffer_size", (char*) &myisam_sort_buffer_size, SHOW_LONG}, {"myisam_sort_buffer_size", (char*) &myisam_sort_buffer_size, SHOW_LONG},
#ifdef __NT__ #ifdef __NT__
...@@ -3642,7 +3685,9 @@ struct show_var_st init_vars[]= { ...@@ -3642,7 +3685,9 @@ struct show_var_st init_vars[]= {
{"port", (char*) &mysql_port, SHOW_INT}, {"port", (char*) &mysql_port, SHOW_INT},
{"protocol_version", (char*) &protocol_version, SHOW_INT}, {"protocol_version", (char*) &protocol_version, SHOW_INT},
{"record_buffer", (char*) &my_default_record_cache_size,SHOW_LONG}, {"record_buffer", (char*) &my_default_record_cache_size,SHOW_LONG},
{"record_rnd_buffer", (char*) &record_rnd_cache_size, SHOW_LONG}, {"record_rnd_buffer",
(char*) offsetof(struct system_variables, record_rnd_cache_size),
SHOW_LONG_OFFSET},
{"rpl_recovery_rank", (char*) &rpl_recovery_rank, SHOW_LONG}, {"rpl_recovery_rank", (char*) &rpl_recovery_rank, SHOW_LONG},
{"query_buffer_size", (char*) &query_buff_size, SHOW_LONG}, {"query_buffer_size", (char*) &query_buff_size, SHOW_LONG},
#ifdef HAVE_QUERY_CACHE #ifdef HAVE_QUERY_CACHE
...@@ -3658,7 +3703,9 @@ struct show_var_st init_vars[]= { ...@@ -3658,7 +3703,9 @@ struct show_var_st init_vars[]= {
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL}, {"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
{"slow_launch_time", (char*) &slow_launch_time, SHOW_LONG}, {"slow_launch_time", (char*) &slow_launch_time, SHOW_LONG},
{"socket", (char*) &mysql_unix_port, SHOW_CHAR_PTR}, {"socket", (char*) &mysql_unix_port, SHOW_CHAR_PTR},
{"sort_buffer", (char*) &sortbuff_size, SHOW_LONG}, {"sort_buffer",
(char*) offsetof(struct system_variables, sortbuff_size),
SHOW_LONG_OFFSET},
{"sql_mode", (char*) &opt_sql_mode, SHOW_LONG}, {"sql_mode", (char*) &opt_sql_mode, SHOW_LONG},
{"table_cache", (char*) &table_cache_size, SHOW_LONG}, {"table_cache", (char*) &table_cache_size, SHOW_LONG},
{"table_type", (char*) &default_table_type_name, SHOW_CHAR_PTR}, {"table_type", (char*) &default_table_type_name, SHOW_CHAR_PTR},
...@@ -3671,10 +3718,17 @@ struct show_var_st init_vars[]= { ...@@ -3671,10 +3718,17 @@ struct show_var_st init_vars[]= {
#ifdef HAVE_TZNAME #ifdef HAVE_TZNAME
{"timezone", time_zone, SHOW_CHAR}, {"timezone", time_zone, SHOW_CHAR},
#endif #endif
{"tmp_table_size", (char*) &tmp_table_size, SHOW_LONG}, {"tmp_table_size",
(char*) offsetof(struct system_variables, tmp_table_size),
SHOW_LONG_OFFSET},
{"tmpdir", (char*) &mysql_tmpdir, SHOW_CHAR_PTR}, {"tmpdir", (char*) &mysql_tmpdir, SHOW_CHAR_PTR},
{"version", server_version, SHOW_CHAR}, {"version", server_version, SHOW_CHAR},
{"wait_timeout", (char*) &net_wait_timeout, SHOW_LONG}, {"wait_timeout",
(char*) offsetof(struct system_variables, net_wait_timeout),
SHOW_LONG_OFFSET},
{"warnings",
(char*) offsetof(struct system_variables, opt_warnings),
SHOW_MY_BOOL_OFFSET},
{NullS, NullS, SHOW_LONG} {NullS, NullS, SHOW_LONG}
}; };
...@@ -4414,6 +4468,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -4414,6 +4468,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
static void get_options(int argc,char **argv) static void get_options(int argc,char **argv)
{ {
int ho_error; int ho_error;
THD *thd= current_thd;
myisam_delay_key_write=1; // Allow use of this myisam_delay_key_write=1; // Allow use of this
#ifndef HAVE_purify #ifndef HAVE_purify
...@@ -4434,12 +4489,18 @@ static void get_options(int argc,char **argv) ...@@ -4434,12 +4489,18 @@ static void get_options(int argc,char **argv)
default_table_type_name=ha_table_typelib.type_names[default_table_type-1]; default_table_type_name=ha_table_typelib.type_names[default_table_type-1];
default_tx_isolation_name=tx_isolation_typelib.type_names[default_tx_isolation]; default_tx_isolation_name=tx_isolation_typelib.type_names[default_tx_isolation];
/* To be deleted in MySQL 4.0 */ /* To be deleted in MySQL 4.0 */
if (!record_rnd_cache_size) if (!thd->variables.record_rnd_cache_size)
record_rnd_cache_size=my_default_record_cache_size; thd->variables.record_rnd_cache_size= my_default_record_cache_size;
/* Fix variables that are base 1024*1024 */ /* Fix variables that are base 1024*1024 */
myisam_max_temp_length= (my_off_t) min(((ulonglong) myisam_max_sort_file_size)*1024*1024, (ulonglong) MAX_FILE_SIZE); myisam_max_temp_length=
myisam_max_extra_temp_length= (my_off_t) min(((ulonglong) myisam_max_extra_sort_file_size)*1024*1024, (ulonglong) MAX_FILE_SIZE); (my_off_t) min(((ulonglong)
thd->variables.myisam_max_sort_file_size)*1024 * 1024,
(ulonglong) MAX_FILE_SIZE);
myisam_max_extra_temp_length=
(my_off_t) min(((ulonglong)
thd->variables.myisam_max_extra_sort_file_size)*1024*1024,
(ulonglong) MAX_FILE_SIZE);
myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size); myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
} }
......
...@@ -61,7 +61,7 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table, ...@@ -61,7 +61,7 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
table->file->rnd_init(0); table->file->rnd_init(0);
if (! (specialflag & SPECIAL_SAFE_MODE) && if (! (specialflag & SPECIAL_SAFE_MODE) &&
record_rnd_cache_size && thd->variables.record_rnd_cache_size &&
!table->file->fast_key_read() && !table->file->fast_key_read() &&
(table->db_stat & HA_READ_ONLY || (table->db_stat & HA_READ_ONLY ||
table->reginfo.lock_type <= TL_READ_NO_INSERT) && table->reginfo.lock_type <= TL_READ_NO_INSERT) &&
...@@ -229,6 +229,8 @@ static int rr_from_pointers(READ_RECORD *info) ...@@ -229,6 +229,8 @@ static int rr_from_pointers(READ_RECORD *info)
static int init_rr_cache(READ_RECORD *info) static int init_rr_cache(READ_RECORD *info)
{ {
uint rec_cache_size; uint rec_cache_size;
THD *thd= current_thd;
DBUG_ENTER("init_rr_cache"); DBUG_ENTER("init_rr_cache");
info->struct_length=3+MAX_REFLENGTH; info->struct_length=3+MAX_REFLENGTH;
...@@ -237,7 +239,7 @@ static int init_rr_cache(READ_RECORD *info) ...@@ -237,7 +239,7 @@ static int init_rr_cache(READ_RECORD *info)
info->reclength=ALIGN_SIZE(info->struct_length); info->reclength=ALIGN_SIZE(info->struct_length);
info->error_offset=info->table->reclength; info->error_offset=info->table->reclength;
info->cache_records=record_rnd_cache_size/ info->cache_records= thd->variables.record_rnd_cache_size /
(info->reclength+info->struct_length); (info->reclength+info->struct_length);
rec_cache_size=info->cache_records*info->reclength; rec_cache_size=info->cache_records*info->reclength;
info->rec_cache_size=info->cache_records*info->ref_length; info->rec_cache_size=info->cache_records*info->ref_length;
......
...@@ -779,6 +779,7 @@ ulong acl_get(const char *host, const char *ip, const char *bin_ip, ...@@ -779,6 +779,7 @@ ulong acl_get(const char *host, const char *ip, const char *bin_ip,
db_access=0; host_access= ~0; db_access=0; host_access= ~0;
char key[ACL_KEY_LENGTH],*tmp_db,*end; char key[ACL_KEY_LENGTH],*tmp_db,*end;
acl_entry *entry; acl_entry *entry;
THD *thd= current_thd;
VOID(pthread_mutex_lock(&acl_cache->lock)); VOID(pthread_mutex_lock(&acl_cache->lock));
memcpy_fixed(&key,bin_ip,sizeof(struct in_addr)); memcpy_fixed(&key,bin_ip,sizeof(struct in_addr));
......
...@@ -87,6 +87,9 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), ...@@ -87,6 +87,9 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
host_or_ip="unknown ip"; host_or_ip="unknown ip";
locked=killed=count_cuted_fields=some_tables_deleted=no_errors=password= locked=killed=count_cuted_fields=some_tables_deleted=no_errors=password=
query_start_used=safe_to_cache_query=0; query_start_used=safe_to_cache_query=0;
pthread_mutex_lock(&LOCK_global_system_variables);
variables= global_system_variables;
pthread_mutex_unlock(&LOCK_global_system_variables);
db_length=query_length=col_access=0; db_length=query_length=col_access=0;
query_error=0; query_error=0;
next_insert_id=last_insert_id=0; next_insert_id=last_insert_id=0;
...@@ -134,13 +137,14 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), ...@@ -134,13 +137,14 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
query_cache_type= 0; //Safety query_cache_type= 0; //Safety
#endif #endif
sql_mode=(uint) opt_sql_mode; sql_mode=(uint) opt_sql_mode;
inactive_timeout=net_wait_timeout; inactive_timeout= variables.net_wait_timeout;
open_options=ha_open_options; open_options=ha_open_options;
tx_isolation=session_tx_isolation=default_tx_isolation; tx_isolation=session_tx_isolation=default_tx_isolation;
command=COM_CONNECT; command=COM_CONNECT;
set_query_id=1; set_query_id=1;
default_select_limit= HA_POS_ERROR; default_select_limit= HA_POS_ERROR;
max_join_size= ((::max_join_size != ~ (ulong) 0L) ? ::max_join_size : max_join_size= ((variables.max_join_size != ~ (ulong) 0L) ?
variables.max_join_size :
HA_POS_ERROR); HA_POS_ERROR);
db_access=NO_ACCESS; db_access=NO_ACCESS;
......
...@@ -280,6 +280,26 @@ class delayed_insert; ...@@ -280,6 +280,26 @@ class delayed_insert;
#define THD_CHECK_SENTRY(thd) DBUG_ASSERT(thd->dbug_sentry == THD_SENTRY_MAGIC) #define THD_CHECK_SENTRY(thd) DBUG_ASSERT(thd->dbug_sentry == THD_SENTRY_MAGIC)
struct system_variables
{
my_bool opt_local_infile;
my_bool opt_warnings;
ulong join_buff_size;
ulong long_query_time;
ulong max_heap_table_size;
ulong max_item_sort_length;
ulong max_join_size;
ulong max_tmp_tables;
ulong myisam_max_extra_sort_file_size;
ulong myisam_max_sort_file_size;
ulong net_interactive_timeout;
ulong net_wait_timeout;
ulong record_rnd_cache_size;
ulong sortbuff_size;
ulong tmp_table_size;
}; /* system variables */
/* For each client connection we create a separate thread with THD serving as /* For each client connection we create a separate thread with THD serving as
a thread/connection descriptor */ a thread/connection descriptor */
...@@ -292,6 +312,7 @@ class THD :public ilink { ...@@ -292,6 +312,7 @@ class THD :public ilink {
String packet; // dynamic string buffer used for network I/O String packet; // dynamic string buffer used for network I/O
struct sockaddr_in remote; // client socket address struct sockaddr_in remote; // client socket address
struct rand_struct rand; // used for authentication struct rand_struct rand; // used for authentication
struct system_variables variables;
/* query points to the current query, /* query points to the current query,
thread_stack is a pointer to the stack frame of handle_one_connection(), thread_stack is a pointer to the stack frame of handle_one_connection(),
......
...@@ -201,7 +201,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, ...@@ -201,7 +201,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
Delete multiple tables from join Delete multiple tables from join
***************************************************************************/ ***************************************************************************/
#define MEM_STRIP_BUF_SIZE sortbuff_size #define MEM_STRIP_BUF_SIZE current_thd->variables.sortbuff_size
int refposcmp2(void* arg, const void *a,const void *b) int refposcmp2(void* arg, const void *a,const void *b)
{ {
......
...@@ -151,6 +151,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length) ...@@ -151,6 +151,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length)
lex->yacc_yyss=lex->yacc_yyvs=0; lex->yacc_yyss=lex->yacc_yyvs=0;
lex->ignore_space=test(thd->sql_mode & MODE_IGNORE_SPACE); lex->ignore_space=test(thd->sql_mode & MODE_IGNORE_SPACE);
lex->slave_thd_opt=0; lex->slave_thd_opt=0;
lex->sql_command=SQLCOM_END;
bzero(&lex->mi,sizeof(lex->mi)); bzero(&lex->mi,sizeof(lex->mi));
return lex; return lex;
} }
......
...@@ -162,6 +162,7 @@ typedef struct st_lex ...@@ -162,6 +162,7 @@ typedef struct st_lex
LEX_USER *grant_user; LEX_USER *grant_user;
gptr yacc_yyss,yacc_yyvs; gptr yacc_yyss,yacc_yyvs;
THD *thd; THD *thd;
struct system_variables *variable_values;
udf_func udf; udf_func udf;
HA_CHECK_OPT check_opt; // check/repair options HA_CHECK_OPT check_opt; // check/repair options
HA_CREATE_INFO create_info; HA_CREATE_INFO create_info;
......
...@@ -559,7 +559,7 @@ check_connections(THD *thd) ...@@ -559,7 +559,7 @@ check_connections(THD *thd)
if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB) if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB)
db=strend(passwd)+1; db=strend(passwd)+1;
if (thd->client_capabilities & CLIENT_INTERACTIVE) if (thd->client_capabilities & CLIENT_INTERACTIVE)
thd->inactive_timeout=net_interactive_timeout; thd->inactive_timeout= thd->variables.net_interactive_timeout;
if ((thd->client_capabilities & CLIENT_TRANSACTIONS) && if ((thd->client_capabilities & CLIENT_TRANSACTIONS) &&
opt_using_transactions) opt_using_transactions)
thd->net.return_status= &thd->server_status; thd->net.return_status= &thd->server_status;
...@@ -661,7 +661,7 @@ pthread_handler_decl(handle_one_connection,arg) ...@@ -661,7 +661,7 @@ pthread_handler_decl(handle_one_connection,arg)
free_root(&thd->mem_root,MYF(0)); free_root(&thd->mem_root,MYF(0));
if (net->error && net->vio != 0) if (net->error && net->vio != 0)
{ {
if (!thd->killed && opt_warnings) if (!thd->killed && thd->variables.opt_warnings)
sql_print_error(ER(ER_NEW_ABORTING_CONNECTION), sql_print_error(ER(ER_NEW_ABORTING_CONNECTION),
thd->thread_id,(thd->db ? thd->db : "unconnected"), thd->thread_id,(thd->db ? thd->db : "unconnected"),
thd->user ? thd->user : "unauthenticated", thd->user ? thd->user : "unauthenticated",
...@@ -1196,7 +1196,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1196,7 +1196,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
{ {
thd->proc_info="logging slow query"; thd->proc_info="logging slow query";
if ((ulong) (thd->start_time - thd->time_after_lock) > long_query_time || if ((ulong) (thd->start_time - thd->time_after_lock) >
thd->variables.long_query_time ||
((thd->lex.select_lex.options & ((thd->lex.select_lex.options &
(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED)) && (QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED)) &&
(specialflag & SPECIAL_LONG_LOG_FORMAT))) (specialflag & SPECIAL_LONG_LOG_FORMAT)))
...@@ -2040,11 +2041,12 @@ mysql_execute_command(void) ...@@ -2040,11 +2041,12 @@ mysql_execute_command(void)
thd->priv_user,lex->verbose); thd->priv_user,lex->verbose);
break; break;
case SQLCOM_SHOW_STATUS: case SQLCOM_SHOW_STATUS:
res= mysqld_show(thd,(lex->wild ? lex->wild->ptr() : NullS),status_vars); res= mysqld_show(thd,(lex->wild ? lex->wild->ptr() : NullS),status_vars,
(struct system_variables*) 0);
break; break;
case SQLCOM_SHOW_VARIABLES: case SQLCOM_SHOW_VARIABLES:
res= mysqld_show(thd, (lex->wild ? lex->wild->ptr() : NullS), res= mysqld_show(thd, (lex->wild ? lex->wild->ptr() : NullS),
init_vars); init_vars, lex->variable_values);
break; break;
case SQLCOM_SHOW_LOGS: case SQLCOM_SHOW_LOGS:
{ {
...@@ -2151,7 +2153,7 @@ mysql_execute_command(void) ...@@ -2151,7 +2153,7 @@ mysql_execute_command(void)
else else
{ {
if (!(thd->client_capabilities & CLIENT_LOCAL_FILES) || if (!(thd->client_capabilities & CLIENT_LOCAL_FILES) ||
! opt_local_infile) ! thd->variables.opt_local_infile)
{ {
send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); send_error(&thd->net,ER_NOT_ALLOWED_COMMAND);
goto error; goto error;
......
...@@ -1711,6 +1711,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, ...@@ -1711,6 +1711,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
{ {
ulong rec; ulong rec;
double tmp; double tmp;
THD *thd= current_thd;
if (!rest_tables) if (!rest_tables)
{ {
...@@ -1977,7 +1978,8 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, ...@@ -1977,7 +1978,8 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
tmp=(double) s->read_time; tmp=(double) s->read_time;
/* Calculate time to read through cache */ /* Calculate time to read through cache */
tmp*=(1.0+floor((double) cache_record_length(join,idx)* tmp*=(1.0+floor((double) cache_record_length(join,idx)*
record_count/(double) join_buff_size)); record_count /
(double) thd->variables.join_buff_size));
} }
if (best == DBL_MAX || if (best == DBL_MAX ||
(tmp + record_count/(double) TIME_FOR_COMPARE*s->found_records < (tmp + record_count/(double) TIME_FOR_COMPARE*s->found_records <
...@@ -3769,12 +3771,13 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -3769,12 +3771,13 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
param->recinfo=recinfo; param->recinfo=recinfo;
store_record(table,2); // Make empty default record store_record(table,2); // Make empty default record
if (tmp_table_size == ~(ulong) 0) // No limit if (thd->variables.tmp_table_size == ~(ulong) 0) // No limit
table->max_rows= ~(ha_rows) 0; table->max_rows= ~(ha_rows) 0;
else else
table->max_rows=(((table->db_type == DB_TYPE_HEAP) ? table->max_rows=(((table->db_type == DB_TYPE_HEAP) ?
min(tmp_table_size, max_heap_table_size) : min(thd->variables.tmp_table_size,
tmp_table_size)/ table->reclength); thd->variables.max_heap_table_size) :
thd->variables.tmp_table_size)/ table->reclength);
set_if_bigger(table->max_rows,1); // For dummy start options set_if_bigger(table->max_rows,1); // For dummy start options
keyinfo=param->keyinfo; keyinfo=param->keyinfo;
...@@ -5755,6 +5758,8 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having) ...@@ -5755,6 +5758,8 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
int error; int error;
ulong reclength,offset; ulong reclength,offset;
uint field_count; uint field_count;
THD *thd= current_thd;
DBUG_ENTER("remove_duplicates"); DBUG_ENTER("remove_duplicates");
entry->reginfo.lock_type=TL_WRITE; entry->reginfo.lock_type=TL_WRITE;
...@@ -5783,7 +5788,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having) ...@@ -5783,7 +5788,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
if (entry->db_type == DB_TYPE_HEAP || if (entry->db_type == DB_TYPE_HEAP ||
(!entry->blob_fields && (!entry->blob_fields &&
((ALIGN_SIZE(reclength) +sizeof(HASH_LINK)) * entry->file->records < ((ALIGN_SIZE(reclength) +sizeof(HASH_LINK)) * entry->file->records <
sortbuff_size))) thd->variables.sortbuff_size)))
error=remove_dup_with_hash_index(join->thd, entry, error=remove_dup_with_hash_index(join->thd, entry,
field_count, first_field, field_count, first_field,
reclength, having); reclength, having);
...@@ -6104,7 +6109,7 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) ...@@ -6104,7 +6109,7 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count)
cache->length=length+blobs*sizeof(char*); cache->length=length+blobs*sizeof(char*);
cache->blobs=blobs; cache->blobs=blobs;
*blob_ptr=0; /* End sequentel */ *blob_ptr=0; /* End sequentel */
size=max(join_buff_size,cache->length); size=max(thd->variables.join_buff_size, cache->length);
if (!(cache->buff=(uchar*) my_malloc(size,MYF(0)))) if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */ DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
cache->end=cache->buff+size; cache->end=cache->buff+size;
......
...@@ -1142,13 +1142,16 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) ...@@ -1142,13 +1142,16 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
*****************************************************************************/ *****************************************************************************/
int mysqld_show(THD *thd, const char *wild, show_var_st *variables) int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
struct system_variables *values)
{ {
uint i; uint i;
char buff[8192]; char buff[8192];
String packet2(buff,sizeof(buff)); String packet2(buff,sizeof(buff));
List<Item> field_list; List<Item> field_list;
CONVERT *convert=thd->convert_set; CONVERT *convert=thd->convert_set;
ulong offset;
DBUG_ENTER("mysqld_show"); DBUG_ENTER("mysqld_show");
field_list.push_back(new Item_empty_string("Variable_name",30)); field_list.push_back(new Item_empty_string("Variable_name",30));
field_list.push_back(new Item_empty_string("Value",256)); field_list.push_back(new Item_empty_string("Value",256));
...@@ -1168,6 +1171,11 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables) ...@@ -1168,6 +1171,11 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables)
case SHOW_LONG_CONST: case SHOW_LONG_CONST:
net_store_data(&packet2,(uint32) *(ulong*) variables[i].value); net_store_data(&packet2,(uint32) *(ulong*) variables[i].value);
break; break;
case SHOW_LONG_OFFSET:
offset= (ulong) variables[i].value;
net_store_data(&packet2,
(uint32) *(ulong*) (((char*) values) + offset));
break;
case SHOW_BOOL: case SHOW_BOOL:
net_store_data(&packet2,(ulong) *(bool*) variables[i].value ? net_store_data(&packet2,(ulong) *(bool*) variables[i].value ?
"ON" : "OFF"); "ON" : "OFF");
...@@ -1176,10 +1184,21 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables) ...@@ -1176,10 +1184,21 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables)
net_store_data(&packet2,(ulong) *(my_bool*) variables[i].value ? net_store_data(&packet2,(ulong) *(my_bool*) variables[i].value ?
"ON" : "OFF"); "ON" : "OFF");
break; break;
case SHOW_MY_BOOL_OFFSET:
offset= (ulong) variables[i].value;
net_store_data(&packet2,
((ulong) *(my_bool*) (((char*) values) + offset)) ?
"ON" : "OFF");
break;
case SHOW_INT_CONST: case SHOW_INT_CONST:
case SHOW_INT: case SHOW_INT:
net_store_data(&packet2,(uint32) *(int*) variables[i].value); net_store_data(&packet2,(uint32) *(int*) variables[i].value);
break; break;
case SHOW_INT_OFFSET:
offset= (ulong) variables[i].value;
net_store_data(&packet2,
(uint32) *(int*) (((char*) values) + offset));
break;
case SHOW_HAVE: case SHOW_HAVE:
{ {
SHOW_COMP_OPTION tmp= *(SHOW_COMP_OPTION*) variables[i].value; SHOW_COMP_OPTION tmp= *(SHOW_COMP_OPTION*) variables[i].value;
......
...@@ -522,7 +522,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -522,7 +522,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%type <num> %type <num>
type int_type real_type order_dir opt_field_spec set_option lock_option type int_type real_type order_dir opt_field_spec set_option lock_option
udf_type if_exists opt_local opt_table_options table_options udf_type if_exists opt_local opt_table_options table_options
table_option opt_if_not_exists table_option opt_if_not_exists opt_var_type
%type <ulong_num> %type <ulong_num>
ULONG_NUM raid_types merge_insert_types ULONG_NUM raid_types merge_insert_types
...@@ -2630,8 +2630,15 @@ show_param: ...@@ -2630,8 +2630,15 @@ show_param:
{ Lex->sql_command= SQLCOM_SHOW_STATUS; } { Lex->sql_command= SQLCOM_SHOW_STATUS; }
| opt_full PROCESSLIST_SYM | opt_full PROCESSLIST_SYM
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;} { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
| VARIABLES wild | opt_var_type VARIABLES wild
{ Lex->sql_command= SQLCOM_SHOW_VARIABLES; } {
THD *thd= current_thd;
thd->lex.sql_command= SQLCOM_SHOW_VARIABLES;
if ($1)
thd->lex.variable_values= &thd->variables;
else
thd->lex.variable_values= &global_system_variables;
}
| LOGS_SYM | LOGS_SYM
{ Lex->sql_command= SQLCOM_SHOW_LOGS; } { Lex->sql_command= SQLCOM_SHOW_LOGS; }
| GRANTS FOR_SYM user | GRANTS FOR_SYM user
...@@ -2668,6 +2675,12 @@ opt_full: ...@@ -2668,6 +2675,12 @@ opt_full:
/* empty */ { Lex->verbose=0; } /* empty */ { Lex->verbose=0; }
| FULL { Lex->verbose=1; }; | FULL { Lex->verbose=1; };
opt_var_type:
/* empty */ { $$=1; /* local variable */ }
| LOCAL_SYM { $$=1; }
| GLOBAL_SYM { $$=0; }
;
from_or_in: from_or_in:
FROM FROM
| IN_SYM; | IN_SYM;
......
...@@ -126,7 +126,8 @@ typedef struct { ...@@ -126,7 +126,8 @@ typedef struct {
enum SHOW_TYPE { SHOW_LONG,SHOW_CHAR,SHOW_INT,SHOW_CHAR_PTR,SHOW_BOOL, enum SHOW_TYPE { SHOW_LONG,SHOW_CHAR,SHOW_INT,SHOW_CHAR_PTR,SHOW_BOOL,
SHOW_MY_BOOL,SHOW_OPENTABLES,SHOW_STARTTIME,SHOW_QUESTION, SHOW_MY_BOOL,SHOW_OPENTABLES,SHOW_STARTTIME,SHOW_QUESTION,
SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE,
SHOW_LONG_OFFSET, SHOW_INT_OFFSET, SHOW_MY_BOOL_OFFSET
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
,SHOW_SSL_CTX_SESS_ACCEPT, SHOW_SSL_CTX_SESS_ACCEPT_GOOD ,SHOW_SSL_CTX_SESS_ACCEPT, SHOW_SSL_CTX_SESS_ACCEPT_GOOD
,SHOW_SSL_GET_VERSION, SHOW_SSL_CTX_GET_SESSION_CACHE_MODE ,SHOW_SSL_GET_VERSION, SHOW_SSL_CTX_GET_SESSION_CACHE_MODE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment