Commit 4b1f9b1a authored by unknown's avatar unknown

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

into rhols221.adsl.netsonic.fi:/home/my/bk/mysql-4.0-new


mysys/my_getopt.c:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
parents 2bdf7fba 039c6b1b
...@@ -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];
......
This diff is collapsed.
...@@ -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