From 333bddb33ffa00989a98fdfa6157f5abff3e7cd6 Mon Sep 17 00:00:00 2001 From: "gluh@gluh.mysql.r18.ru" <> Date: Fri, 18 Jul 2003 14:11:01 +0500 Subject: [PATCH 01/12] SCRUM: Task 499 'init_connect, init_slave options' --- mysql-test/mysql-test-run.sh | 2 +- mysql-test/r/init_connect.result | 24 +++++++ mysql-test/r/rpl_init_slave.result | 23 +++++++ mysql-test/t/init_connect-master.opt | 1 + mysql-test/t/init_connect.test | 34 ++++++++++ mysql-test/t/rpl_init_slave-slave.opt | 1 + mysql-test/t/rpl_init_slave.test | 26 ++++++++ sql/mysql_priv.h | 2 +- sql/mysqld.cc | 29 ++++++++- sql/protocol.cc | 2 + sql/set_var.cc | 91 +++++++++++++++++++++++++++ sql/set_var.h | 3 + sql/slave.cc | 32 ++++++++++ sql/sql_class.cc | 1 + sql/sql_class.h | 1 + sql/sql_parse.cc | 50 ++++++++++++++- sql/sql_show.cc | 7 ++- 17 files changed, 319 insertions(+), 10 deletions(-) create mode 100644 mysql-test/r/init_connect.result create mode 100644 mysql-test/r/rpl_init_slave.result create mode 100644 mysql-test/t/init_connect-master.opt create mode 100644 mysql-test/t/init_connect.test create mode 100644 mysql-test/t/rpl_init_slave-slave.opt create mode 100644 mysql-test/t/rpl_init_slave.test diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 137e99f48b3..502644ad588 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -775,7 +775,7 @@ manager_launch() ident=$1 shift if [ $USE_MANAGER = 0 ] ; then - $@ >> $CUR_MYERR 2>&1 & + echo $@ | /bin/sh >> $CUR_MYERR 2>&1 & sleep 2 #hack return fi diff --git a/mysql-test/r/init_connect.result b/mysql-test/r/init_connect.result new file mode 100644 index 00000000000..3f8e726c775 --- /dev/null +++ b/mysql-test/r/init_connect.result @@ -0,0 +1,24 @@ +select hex(@a); +hex(@a) +NULL +select hex(@a); +hex(@a) +610063 +set global init_connect="set @a=2;set @b=3"; +select @a, @b; +@a @b +2 3 +set GLOBAL init_connect=DEFAULT; +select @a; +@a +NULL +set global init_connect="create table t1(a char(10));\ +insert into t1 values ('\0');insert into t1 values('abc')"; +select hex(a) from t1; +hex(a) +00 +616263 +set GLOBAL init_connect="adsfsdfsdfs"; +select @a; +ERROR HY000: Lost connection to MySQL server during query +drop table t1; diff --git a/mysql-test/r/rpl_init_slave.result b/mysql-test/r/rpl_init_slave.result new file mode 100644 index 00000000000..a91b2da85cd --- /dev/null +++ b/mysql-test/r/rpl_init_slave.result @@ -0,0 +1,23 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +reset master; +create table t1(n int); +insert into t1 values (@a), (@b); +select * from t1; +n +NULL +NULL +select * from t1; +n +1 +2 +set global init_connect="set @c=1"; +show variables like 'init_connect'; +Variable_name Value +init_connect set @c=1 +drop table t1; +stop slave; diff --git a/mysql-test/t/init_connect-master.opt b/mysql-test/t/init_connect-master.opt new file mode 100644 index 00000000000..e3316c2def5 --- /dev/null +++ b/mysql-test/t/init_connect-master.opt @@ -0,0 +1 @@ +--set-variable=init_connect="set @a='a\0c'" diff --git a/mysql-test/t/init_connect.test b/mysql-test/t/init_connect.test new file mode 100644 index 00000000000..563ec6178d0 --- /dev/null +++ b/mysql-test/t/init_connect.test @@ -0,0 +1,34 @@ +# +# Test of init_connect variable +# + +connect (con0,localhost,root,,); +connection con0; +select hex(@a); +connect (con1,localhost,user_1,,); +connection con1; +select hex(@a); +connection con0; +set global init_connect="set @a=2;set @b=3"; +connect (con2,localhost,user_1,,); +connection con2; +select @a, @b; +connection con0; +set GLOBAL init_connect=DEFAULT; +connect (con3,localhost,user_1,,); +connection con3; +select @a; +connection con0; +set global init_connect="create table t1(a char(10));\ +insert into t1 values ('\0');insert into t1 values('abc')"; +connect (con4,localhost,user_1,,); +connection con4; +select hex(a) from t1; +connection con0; +set GLOBAL init_connect="adsfsdfsdfs"; +connect (con5,localhost,user_1,,); +connection con5; +--error 2013 +select @a; +connection con0; +drop table t1; diff --git a/mysql-test/t/rpl_init_slave-slave.opt b/mysql-test/t/rpl_init_slave-slave.opt new file mode 100644 index 00000000000..6433dccf4aa --- /dev/null +++ b/mysql-test/t/rpl_init_slave-slave.opt @@ -0,0 +1 @@ +--init-slave="set @a=1;set @b=2" diff --git a/mysql-test/t/rpl_init_slave.test b/mysql-test/t/rpl_init_slave.test new file mode 100644 index 00000000000..67d35546225 --- /dev/null +++ b/mysql-test/t/rpl_init_slave.test @@ -0,0 +1,26 @@ +source include/master-slave.inc; + +# +# Test of init_slave variable +# + +save_master_pos; +connection slave; +sync_with_master; +reset master; +connection master; +create table t1(n int); +insert into t1 values (@a), (@b); +select * from t1; +save_master_pos; +connection slave; +sync_with_master; +select * from t1; +set global init_connect="set @c=1"; +show variables like 'init_connect'; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; +stop slave; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 65451ca40b5..5da81422298 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -769,7 +769,7 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_system_variables; -extern rw_lock_t LOCK_grant; +extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager; extern pthread_attr_t connection_attrib; extern I_List threads; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 709ba036f7e..df539776b19 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -300,7 +300,8 @@ char log_error_file[FN_REFLEN], glob_hostname[FN_REFLEN]; char* log_error_file_ptr= log_error_file; char mysql_real_data_home[FN_REFLEN], language[LIBLEN],reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN], - max_sort_char,*mysqld_user,*mysqld_chroot, *opt_init_file; + max_sort_char,*mysqld_user,*mysqld_chroot, *opt_init_file, + *opt_init_connect, *opt_init_slave; char *language_ptr, *default_collation_name, *default_character_set_name; char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home; char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION; @@ -344,7 +345,7 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count, LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received, LOCK_global_system_variables, LOCK_user_conn, LOCK_slave_list, LOCK_active_mi; -rw_lock_t LOCK_grant; +rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; pthread_cond_t COND_refresh,COND_thread_count, COND_slave_stopped, COND_slave_start; pthread_cond_t COND_thread_cache,COND_flush_thread_cache; @@ -883,6 +884,8 @@ void clean_up(bool print_message) #endif if (defaults_argv) free_defaults(defaults_argv); + my_free(sys_init_connect.value, MYF(MY_ALLOW_ZERO_PTR)); + my_free(sys_init_slave.value, MYF(MY_ALLOW_ZERO_PTR)); free_tmpdir(&mysql_tmpdir_list); #ifdef HAVE_REPLICATION my_free(slave_load_tmpdir,MYF(MY_ALLOW_ZERO_PTR)); @@ -949,6 +952,8 @@ static void clean_up_mutexes() (void) pthread_cond_destroy(&COND_rpl_status); #endif (void) pthread_mutex_destroy(&LOCK_active_mi); + (void) rwlock_destroy(&LOCK_sys_init_connect); + (void) rwlock_destroy(&LOCK_sys_init_slave); (void) pthread_mutex_destroy(&LOCK_global_system_variables); (void) pthread_cond_destroy(&COND_thread_count); (void) pthread_cond_destroy(&COND_refresh); @@ -2056,6 +2061,14 @@ static int init_common_variables(const char *conf_file_name, int argc, global_system_variables.character_set_client= default_charset_info; global_system_variables.collation_connection= default_charset_info; + sys_init_connect.value_length= 0; + if ((sys_init_connect.value= opt_init_connect)) + sys_init_connect.value_length= strlen(opt_init_connect); + + sys_init_slave.value_length= 0; + if ((sys_init_slave.value= opt_init_slave)) + sys_init_slave.value_length= strlen(opt_init_slave); + if (use_temp_pool && bitmap_init(&temp_pool,1024,1)) return 1; return 0; @@ -2081,6 +2094,8 @@ static int init_thread_environment() (void) pthread_mutex_init(&LOCK_user_conn, 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) my_rwlock_init(&LOCK_sys_init_connect, NULL); + (void) my_rwlock_init(&LOCK_sys_init_slave, NULL); (void) my_rwlock_init(&LOCK_grant, NULL); (void) pthread_cond_init(&COND_thread_count,NULL); (void) pthread_cond_init(&COND_refresh,NULL); @@ -3472,7 +3487,9 @@ enum options OPT_EXPIRE_LOGS_DAYS, OPT_DEFAULT_WEEK_FORMAT, OPT_GROUP_CONCAT_MAX_LEN, - OPT_DEFAULT_COLLATION + OPT_DEFAULT_COLLATION, + OPT_INIT_CONNECT, + OPT_INIT_SLAVE }; @@ -3638,6 +3655,12 @@ Disable with --skip-bdb (will save memory).", #endif /* End HAVE_INNOBASE_DB */ {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"init-connect", OPT_INIT_CONNECT, "Command what executes for all new connections", + (gptr*) &opt_init_connect, (gptr*) &opt_init_connect, 0, GET_STR_ALLOC, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, + {"init-slave", OPT_INIT_SLAVE, "Command what is executed when replication is starting", + (gptr*) &opt_init_slave, (gptr*) &opt_init_slave, 0, GET_STR_ALLOC, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, {"init-file", OPT_INIT_FILE, "Read SQL commands from this file at startup.", (gptr*) &opt_init_file, (gptr*) &opt_init_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/sql/protocol.cc b/sql/protocol.cc index 1b9256c7723..c2b1557ab39 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -92,6 +92,7 @@ void send_error(THD *thd, uint sql_errno, const char *err) /* In bootstrap it's ok to print on stderr */ fprintf(stderr,"ERROR: %d %s\n",sql_errno,err); } + thd->init_connect_error= 1; DBUG_VOID_RETURN; } @@ -210,6 +211,7 @@ net_printf(THD *thd, uint errcode, ...) fprintf(stderr,"ERROR: %d %s\n",errcode,text_pos); thd->fatal_error(); } + thd->init_connect_error= 1; DBUG_VOID_RETURN; } diff --git a/sql/set_var.cc b/sql/set_var.cc index cb6c875d513..29ca3dc951c 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -75,6 +75,10 @@ TYPELIB delay_key_write_typelib= static bool sys_check_charset(THD *thd, set_var *var); static bool sys_update_charset(THD *thd, set_var *var); static void sys_set_default_charset(THD *thd, enum_var_type type); +static bool sys_update_init_connect(THD*, set_var*); +static void sys_default_init_connect(THD*, enum_var_type type); +static bool sys_update_init_slave(THD*, set_var*); +static void sys_default_init_slave(THD*, enum_var_type type); static bool set_option_bit(THD *thd, set_var *var); static bool set_option_autocommit(THD *thd, set_var *var); static bool set_log_update(THD *thd, set_var *var); @@ -109,6 +113,12 @@ sys_var_str sys_charset_system("character_set_system", sys_check_charset, sys_update_charset, sys_set_default_charset); +sys_var_str sys_init_connect("init_connect", 0, + sys_update_init_connect, + sys_default_init_connect); +sys_var_str sys_init_slave("init_slave", 0, + sys_update_init_slave, + sys_default_init_slave); sys_var_character_set_database sys_character_set_database("character_set_database"); sys_var_character_set_client sys_character_set_client("character_set_client"); sys_var_character_set_connection sys_character_set_connection("character_set_connection"); @@ -386,6 +396,8 @@ sys_var *sys_variables[]= &sys_foreign_key_checks, &sys_group_concat_max_len, &sys_identity, + &sys_init_connect, + &sys_init_slave, &sys_insert_id, &sys_interactive_timeout, &sys_join_buffer_size, @@ -522,6 +534,8 @@ struct show_var_st init_vars[]= { {"have_openssl", (char*) &have_openssl, SHOW_HAVE}, {"have_query_cache", (char*) &have_query_cache, SHOW_HAVE}, {"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR}, + {"init_connect", (char*) &sys_init_connect, SHOW_SYS}, + {"init_slave", (char*) &sys_init_slave, SHOW_SYS}, #ifdef HAVE_INNOBASE_DB {"innodb_additional_mem_pool_size", (char*) &innobase_additional_mem_pool_size, SHOW_LONG }, {"innodb_buffer_pool_size", (char*) &innobase_buffer_pool_size, SHOW_LONG }, @@ -659,6 +673,83 @@ struct show_var_st init_vars[]= { Functions to check and update variables */ + +static bool sys_update_init_connect(THD *thd, set_var *var) +{ + char *res= 0, *old_value; + uint new_length; + /* If the string is "", delete old init command */ + if ((new_length= var->value->str_value.length())) + { + if (!(res= my_strdup_with_length(var->value->str_value.c_ptr(), + new_length, + MYF(0)))) + return 1; + } + /* + Replace the old value in such a way that the any thread using + the value will work. + */ + rw_wrlock(&LOCK_sys_init_connect); + old_value= sys_init_connect.value; + sys_init_connect.value= res; + sys_init_connect.value_length= new_length; + rw_unlock(&LOCK_sys_init_connect); + my_free(old_value, MYF(MY_ALLOW_ZERO_PTR)); + return 0; +} + + +static void sys_default_init_connect(THD* thd, enum_var_type type) +{ + char *old_value; + rw_wrlock(&LOCK_sys_init_connect); + old_value= sys_init_connect.value; + sys_init_connect.value= 0; + sys_init_connect.value_length= 0; + rw_unlock(&LOCK_sys_init_connect); + my_free(old_value, MYF(MY_ALLOW_ZERO_PTR)); +} + + +static bool sys_update_init_slave(THD *thd, set_var *var) +{ + char *res= 0, *old_value; + uint new_length; + /* If the string is "", delete old init command */ + if ((new_length= var->value->str_value.length())) + { + if (!(res= my_strdup_with_length(var->value->str_value.c_ptr(), + new_length, + MYF(0)))) + return 1; + } + /* + Replace the old value in such a way that the any thread using + the value will work. + */ + rw_wrlock(&LOCK_sys_init_slave); + old_value= sys_init_slave.value; + sys_init_slave.value= res; + sys_init_slave.value_length= new_length; + rw_unlock(&LOCK_sys_init_slave); + my_free(old_value, MYF(MY_ALLOW_ZERO_PTR)); + return 0; +} + + +static void sys_default_init_slave(THD* thd, enum_var_type type) +{ + char *old_value; + rw_wrlock(&LOCK_sys_init_slave); + old_value= sys_init_slave.value; + sys_init_slave.value= 0; + sys_init_slave.value_length= 0; + rw_unlock(&LOCK_sys_init_slave); + my_free(old_value, MYF(MY_ALLOW_ZERO_PTR)); +} + + /* The following 3 functions need to be changed in 4.1 when we allow one to change character sets diff --git a/sql/set_var.h b/sql/set_var.h index 978aba3384a..3b11528e7dc 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -137,6 +137,7 @@ class sys_var_str :public sys_var { public: char *value; // Pointer to allocated string + uint value_length; sys_check_func check_func; sys_update_func update_func; sys_set_default_func set_default_func; @@ -704,6 +705,8 @@ int sql_set_variables(THD *thd, List *var_list); void fix_delay_key_write(THD *thd, enum_var_type type); ulong fix_sql_mode(ulong sql_mode); extern sys_var_str sys_charset_system; +extern sys_var_str sys_init_connect; +extern sys_var_str sys_init_slave; CHARSET_INFO *get_old_charset_by_name(const char *old_name); gptr find_named(I_List *list, const char *name, uint length); void delete_elements(I_List *list, void (*free_element)(gptr)); diff --git a/sql/slave.cc b/sql/slave.cc index c45c11f8bef..b9da8c7eca6 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2448,6 +2448,24 @@ err: } +void init_slave_execute(THD *thd, sys_var_str *init_slave_var) +{ + Vio* save_vio; + ulong save_client_capabilities; + + thd->proc_info= "Execution of init_slave"; + thd->query= init_slave_var->value; + thd->query_length= init_slave_var->value_length; + save_client_capabilities= thd->client_capabilities; + thd->client_capabilities|= CLIENT_MULTI_QUERIES; + save_vio= thd->net.vio; + thd->net.vio= 0; + dispatch_command(COM_QUERY, thd, thd->query, thd->query_length+1); + thd->client_capabilities= save_client_capabilities; + thd->net.vio= save_vio; +} + + /* Slave SQL Thread entry point */ extern "C" pthread_handler_decl(handle_slave_sql,arg) @@ -2530,6 +2548,20 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, llstr(rli->group_master_log_pos,llbuff),rli->group_relay_log_name, llstr(rli->group_relay_log_pos,llbuff1)); + /* execute init_slave variable */ + if (sys_init_slave.value) + { + rw_wrlock(&LOCK_sys_init_slave); + init_slave_execute(thd, &sys_init_slave); + rw_unlock(&LOCK_sys_init_slave); + if (thd->query_error) + { + sql_print_error("\ +Slave SQL thread aborted. Can't execute init_slave query"); + goto err; + } + } + /* Read queries from the IO/THREAD until this thread is killed */ while (!sql_slave_killed(thd,rli)) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index c233ffd422a..8677c262437 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -121,6 +121,7 @@ THD::THD():user_time(0), is_fatal_error(0), system_thread=cleanup_done=0; peer_port= 0; // For SHOW PROCESSLIST transaction.changed_tables = 0; + init_connect_error= 0; #ifdef __WIN__ real_id = 0; #endif diff --git a/sql/sql_class.h b/sql/sql_class.h index f6336cb7dd9..900c17a8743 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -560,6 +560,7 @@ public: bool prepare_command; bool tmp_table_used; + bool init_connect_error; /* If we do a purge of binary logs, log index info of the threads that are currently reading it needs to be adjusted. To do that diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9e670a97e92..f2e268abcd2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -794,6 +794,24 @@ check_connections(THD *thd) } +void init_connect_execute(THD *thd, sys_var_str *init_connect_var) +{ + Vio* save_vio; + ulong save_client_capabilities; + + thd->proc_info= "Execution of init_connect"; + thd->query= init_connect_var->value; + thd->query_length= init_connect_var->value_length; + save_client_capabilities= thd->client_capabilities; + thd->client_capabilities|= CLIENT_MULTI_QUERIES; + save_vio= thd->net.vio; + thd->net.vio= 0; + dispatch_command(COM_QUERY, thd, thd->query, thd->query_length+1); + thd->client_capabilities= save_client_capabilities; + thd->net.vio= save_vio; +} + + pthread_handler_decl(handle_one_connection,arg) { THD *thd=(THD*) arg; @@ -866,9 +884,35 @@ pthread_handler_decl(handle_one_connection,arg) if (thd->client_capabilities & CLIENT_COMPRESS) net->compress=1; // Use compression - thd->proc_info=0; // Remove 'login' - thd->command=COM_SLEEP; - thd->version=refresh_version; + thd->version= refresh_version; + if (sys_init_connect.value && !(thd->master_access & SUPER_ACL)) + { + rw_wrlock(&LOCK_sys_init_connect); + init_connect_execute(thd, &sys_init_connect); + rw_unlock(&LOCK_sys_init_connect); + if (thd->init_connect_error) + { + if (thd->user_connect) + decrease_user_connections(thd->user_connect); + free_root(&thd->mem_root,MYF(0)); + if (!thd->killed && thd->variables.log_warnings) + { + sql_print_error(ER(ER_NEW_ABORTING_CONNECTION), + thd->thread_id,(thd->db ? thd->db : "unconnected"), + thd->user ? thd->user : "unauthenticated", + thd->host_or_ip, + "Can't execute init_connect query"); + statistic_increment(aborted_threads,&LOCK_status); + } + else if (thd->killed) + { + statistic_increment(aborted_threads,&LOCK_status); + } + goto end_thread; + } + } + + thd->proc_info=0; thd->set_time(); thd->init_for_queries(); while (!net->error && net->vio != 0 && !thd->killed) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index e8cb59e387e..42c89db9ca4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1587,9 +1587,12 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, break; } case SHOW_CHAR: - pos= value; - end= strend(pos); + { + if (!(pos= value)) + pos= ""; + end= strend(pos); break; + } case SHOW_STARTTIME: nr= (long) (thd->query_start() - start_time); end= int10_to_str(nr, buff, 10); From 9c7b1cf8ead8e00a8549445e377b4c6ab815fa8b Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Fri, 31 Oct 2003 16:24:55 -0400 Subject: [PATCH 02/12] fixed bug #1688 "CREATE TABLE ... SELECT with default()" --- mysql-test/r/create.result | 16 ++++++++++++++++ mysql-test/t/create.test | 7 +++++++ sql/sql_select.cc | 1 + 3 files changed, 24 insertions(+) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index d61614180b3..4e83f195ed2 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -411,6 +411,22 @@ a b c d e f g h dd 1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00 2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00 drop table t1, t2; +create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14'); +insert into t1 values ('','',0,0.0); +describe t1; +Field Type Null Key Default Extra +str varchar(10) YES def +strnull varchar(10) YES NULL +intg int(11) YES 10 +rel double YES 3.14 +create table t2 select default(str) as str, default(strnull) as strnull, default(intg) as intg, default(rel) as rel from t1; +describe t2; +Field Type Null Key Default Extra +str varchar(10) YES NULL +strnull varchar(10) YES NULL +intg int(11) YES NULL +rel double YES NULL +drop table t1, t2; drop database if exists test_$1; create database test_$1; use test_$1; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 059808161a3..826027b977d 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -318,6 +318,13 @@ select * from t2; drop table t1, t2; +create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14'); +insert into t1 values ('','',0,0.0); +describe t1; +create table t2 select default(str) as str, default(strnull) as strnull, default(intg) as intg, default(rel) as rel from t1; +describe t2; +drop table t1, t2; + # # Bug #1209 # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9bdb989b6a1..4fb3d70f941 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4473,6 +4473,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, return 0; // Error } case Item::FIELD_ITEM: + case Item::DEFAULT_VALUE_ITEM: { Field *org_field=((Item_field*) item)->field,*new_field; From b2e6b36487d6c0e1660263e50f7ad1d15b6ef02a Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Sat, 6 Dec 2003 19:05:26 +0100 Subject: [PATCH 03/12] fix for my_mbcharlen(charset, c) to return 1 for single-byte characters (isn't it obvious ?) --- mysys/charset.c | 2 +- sql/sql_load.cc | 5 ++--- strings/ctype-big5.c | 2 +- strings/ctype-euc_kr.c | 2 +- strings/ctype-gb2312.c | 2 +- strings/ctype-gbk.c | 2 +- strings/ctype-sjis.c | 2 +- strings/ctype-ujis.c | 2 +- 8 files changed, 9 insertions(+), 10 deletions(-) diff --git a/mysys/charset.c b/mysys/charset.c index e97ac0675d6..4111dd246cb 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -82,7 +82,7 @@ static void init_state_maps(CHARSET_INFO *cs) else if (my_isdigit(cs,i)) state_map[i]=(uchar) MY_LEX_NUMBER_IDENT; #if defined(USE_MB) && defined(USE_MB_IDENT) - else if (use_mb(cs) && (my_mbcharlen(cs, i)>1)) + else if (my_mbcharlen(cs, i)>1) state_map[i]=(uchar) MY_LEX_IDENT; #endif else if (!my_isgraph(cs,i)) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 0e7895689b5..0f39ab2663f 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -759,8 +759,7 @@ int READ_INFO::read_field() { chr = GET; #ifdef USE_MB - if (use_mb(read_charset) && - (my_mbcharlen(read_charset, chr) >1 )&& + if ((my_mbcharlen(read_charset, chr) > 1) && to+my_mbcharlen(read_charset, chr) <= end_of_buff) { uchar* p = (uchar*)to; @@ -946,7 +945,7 @@ int READ_INFO::next_line() { int chr = GET; #ifdef USE_MB - if (use_mb(read_charset) && (my_mbcharlen(read_charset, chr) >1 )) + if (my_mbcharlen(read_charset, chr) > 1) { for (int i=1; chr != my_b_EOF && i Date: Sat, 6 Dec 2003 23:21:09 +0100 Subject: [PATCH 04/12] QUERY_NO_GOOD_INDEX_USED and QUERY_NO_INDEX_USED moved from thd->lex.select_lex->options to thd->server_status --- include/mysql_com.h | 2 + mysql-test/r/union.result | 38 +++++++++++++++++++ mysql-test/t/union-master.opt | 1 + mysql-test/t/union.test | 26 +++++++++++-- sql/mysql_priv.h | 69 ++++++++++++++++------------------- sql/sql_delete.cc | 2 +- sql/sql_parse.cc | 8 ++-- sql/sql_select.cc | 8 ++-- sql/sql_update.cc | 2 +- 9 files changed, 107 insertions(+), 49 deletions(-) create mode 100644 mysql-test/t/union-master.opt diff --git a/include/mysql_com.h b/include/mysql_com.h index 39e9c48146d..2036b3d0ac2 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -124,6 +124,8 @@ enum enum_server_command #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ #define SERVER_STATUS_MORE_RESULTS 4 /* More results on server */ #define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */ +#define SERVER_QUERY_NO_GOOD_INDEX_USED 16 +#define SERVER_QUERY_NO_INDEX_USED 32 #define MYSQL_ERRMSG_SIZE 512 #define NET_READ_TIMEOUT 30 /* Timeout on read */ diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 241b9847c02..642c07904b5 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -823,3 +823,41 @@ count(*) 13 drop table t1,t2; set local tmp_table_size=default; +create table t1 (a int, index (a), b int); +insert t1 values (1,1),(2,2),(3,3),(4,4),(5,5); +insert t1 select a+1, a+b from t1; +insert t1 select a+1, a+b from t1; +insert t1 select a+1, a+b from t1; +insert t1 select a+1, a+b from t1; +insert t1 select a+1, a+b from t1; +FLUSH STATUS; +show status like 'Slow_queries'; +Variable_name Value +Slow_queries 0 +select count(*) from t1 where a=7; +count(*) +26 +show status like 'Slow_queries'; +Variable_name Value +Slow_queries 0 +select count(*) from t1 where b=13; +count(*) +10 +show status like 'Slow_queries'; +Variable_name Value +Slow_queries 1 +select count(*) from t1 where b=13 union select count(*) from t1 where a=7; +count(*) +0 +26 +show status like 'Slow_queries'; +Variable_name Value +Slow_queries 2 +select count(*) from t1 where a=7 union select count(*) from t1 where b=13; +count(*) +26 +10 +show status like 'Slow_queries'; +Variable_name Value +Slow_queries 3 +drop table t1; diff --git a/mysql-test/t/union-master.opt b/mysql-test/t/union-master.opt new file mode 100644 index 00000000000..3eb98fc3d6b --- /dev/null +++ b/mysql-test/t/union-master.opt @@ -0,0 +1 @@ +--log-slow-queries --log-long-format --log-queries-not-using-indexes diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index e302378e117..a5cb1ce6b6e 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -416,9 +416,6 @@ create table t1 select _latin2"test" union select _latin2"testt" ; show create table t1; drop table t1; -# -# conversion memory->disk table -# # # conversion memory->disk table # @@ -436,3 +433,26 @@ select count(*) from t1; select count(*) from t2; drop table t1,t2; set local tmp_table_size=default; + +# +# slow logging +# +create table t1 (a int, index (a), b int); +insert t1 values (1,1),(2,2),(3,3),(4,4),(5,5); +insert t1 select a+1, a+b from t1; +insert t1 select a+1, a+b from t1; +insert t1 select a+1, a+b from t1; +insert t1 select a+1, a+b from t1; +insert t1 select a+1, a+b from t1; +FLUSH STATUS; +show status like 'Slow_queries'; +select count(*) from t1 where a=7; +show status like 'Slow_queries'; +select count(*) from t1 where b=13; +show status like 'Slow_queries'; +select count(*) from t1 where b=13 union select count(*) from t1 where a=7; +show status like 'Slow_queries'; +select count(*) from t1 where a=7 union select count(*) from t1 where b=13; +show status like 'Slow_queries'; +drop table t1; + diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 4e2be96b9c7..62494da45d4 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -177,50 +177,45 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; #define TEST_SIGINT 1024 /* Allow sigint on threads */ /* options for select set by the yacc parser (stored in lex->options) */ -#define SELECT_DISTINCT 1 -#define SELECT_STRAIGHT_JOIN 2 -#define SELECT_DESCRIBE 4 -#define SELECT_SMALL_RESULT 8 -#define SELECT_BIG_RESULT 16 -#define OPTION_FOUND_ROWS 32 -#define OPTION_TO_QUERY_CACHE 64 -#define SELECT_NO_JOIN_CACHE 256 /* Intern */ - -#define OPTION_BIG_TABLES 512 /* for SQL OPTION */ -#define OPTION_BIG_SELECTS 1024 /* for SQL OPTION */ -#define OPTION_LOG_OFF 2048 -#define OPTION_UPDATE_LOG 4096 /* update log flag */ -#define TMP_TABLE_ALL_COLUMNS 8192 -#define OPTION_WARNINGS 16384 -#define OPTION_AUTO_IS_NULL 32768 -#define OPTION_FOUND_COMMENT 65536L -#define OPTION_SAFE_UPDATES OPTION_FOUND_COMMENT*2 -#define OPTION_BUFFER_RESULT OPTION_SAFE_UPDATES*2 -#define OPTION_BIN_LOG OPTION_BUFFER_RESULT*2 -#define OPTION_NOT_AUTOCOMMIT OPTION_BIN_LOG*2 -#define OPTION_BEGIN OPTION_NOT_AUTOCOMMIT*2 -#define OPTION_TABLE_LOCK OPTION_BEGIN*2 -#define OPTION_QUICK OPTION_TABLE_LOCK*2 -#define OPTION_QUOTE_SHOW_CREATE OPTION_QUICK*2 -#define OPTION_INTERNAL_SUBTRANSACTIONS OPTION_QUOTE_SHOW_CREATE*2 - -/* options for UNION set by the yacc parser (stored in unit->union_option) */ -#define UNION_ALL 1 +#define SELECT_DISTINCT (1L << 0) +#define SELECT_STRAIGHT_JOIN (1L << 1) +#define SELECT_DESCRIBE (1L << 2) +#define SELECT_SMALL_RESULT (1L << 3) +#define SELECT_BIG_RESULT (1L << 4) +#define OPTION_FOUND_ROWS (1L << 5) +#define OPTION_TO_QUERY_CACHE (1L << 6) +#define SELECT_NO_JOIN_CACHE (1L << 7) /* Intern */ +#define OPTION_BIG_TABLES (1L << 8) /* for SQL OPTION */ +#define OPTION_BIG_SELECTS (1L << 9) /* for SQL OPTION */ +#define OPTION_LOG_OFF (1L << 10) +#define OPTION_UPDATE_LOG (1L << 11) /* update log flag */ +#define TMP_TABLE_ALL_COLUMNS (1L << 12) +#define OPTION_WARNINGS (1L << 13) +#define OPTION_AUTO_IS_NULL (1L << 14) +#define OPTION_FOUND_COMMENT (1L << 15) +#define OPTION_SAFE_UPDATES (1L << 16) +#define OPTION_BUFFER_RESULT (1L << 17) +#define OPTION_BIN_LOG (1L << 18) +#define OPTION_NOT_AUTOCOMMIT (1L << 19) +#define OPTION_BEGIN (1L << 20) +#define OPTION_TABLE_LOCK (1L << 21) +#define OPTION_QUICK (1L << 22) +#define OPTION_QUOTE_SHOW_CREATE (1L << 23) +#define OPTION_INTERNAL_SUBTRANSACTIONS (1L << 24) /* Set if we are updating a non-transaction safe table */ -#define OPTION_STATUS_NO_TRANS_UPDATE OPTION_INTERNAL_SUBTRANSACTIONS*2 +#define OPTION_STATUS_NO_TRANS_UPDATE (1L << 25) -/* The following is set when parsing the query */ -#define QUERY_NO_INDEX_USED OPTION_STATUS_NO_TRANS_UPDATE*2 -#define QUERY_NO_GOOD_INDEX_USED QUERY_NO_INDEX_USED*2 /* The following can be set when importing tables in a 'wrong order' to suppress foreign key checks */ -#define OPTION_NO_FOREIGN_KEY_CHECKS QUERY_NO_GOOD_INDEX_USED*2 +#define OPTION_NO_FOREIGN_KEY_CHECKS (1L << 26) /* The following speeds up inserts to InnoDB tables by suppressing unique key checks in some cases */ -#define OPTION_RELAXED_UNIQUE_CHECKS OPTION_NO_FOREIGN_KEY_CHECKS*2 -#define SELECT_NO_UNLOCK ((ulong) OPTION_RELAXED_UNIQUE_CHECKS*2) -/* NOTE: we have now used up all 32 bits of the OPTION flag! */ +#define OPTION_RELAXED_UNIQUE_CHECKS (1L << 27) +#define SELECT_NO_UNLOCK (1L << 28) + +/* options for UNION set by the yacc parser (stored in unit->union_option) */ +#define UNION_ALL 1 /* Bits for different SQL modes modes (including ANSI mode) */ #define MODE_REAL_AS_FLOAT 1 diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 4bab7be255c..94ae1743fd9 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -104,7 +104,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, /* If running in safe sql mode, don't allow updates without keys */ if (table->quick_keys.is_clear_all()) { - thd->lex.select_lex.options|=QUERY_NO_INDEX_USED; + thd->server_status|=SERVER_QUERY_NO_INDEX_USED; if (safe_update && !using_limit) { delete select; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c50bfc43862..6442bbc1e1d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1203,7 +1203,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thread_running++; VOID(pthread_mutex_unlock(&LOCK_thread_count)); - thd->lex.select_lex.options=0; // We store status here + thd->server_status&= + ~(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED); switch (command) { case COM_INIT_DB: { @@ -1635,8 +1636,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if ((ulong) (thd->start_time - thd->time_after_lock) > thd->variables.long_query_time || - ((thd->lex.select_lex.options & - (QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED)) && + ((thd->server_status & + (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) && (specialflag & SPECIAL_LOG_QUERIES_NOT_USING_INDEXES))) { long_query_count++; @@ -3730,6 +3731,7 @@ mysql_init_query(THD *thd) lex->select_lex.prev= &lex->unit.slave; lex->select_lex.link_next= lex->select_lex.slave= lex->select_lex.next= 0; lex->select_lex.link_prev= (st_select_lex_node**)&(lex->all_selects_list); + lex->select_lex.options=0; lex->describe= 0; lex->derived_tables= FALSE; lex->lock_option= TL_READ; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 69e8ea8ccff..3d2a572c3a9 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3619,7 +3619,7 @@ make_join_readinfo(JOIN *join, uint options) /* These init changes read_record */ if (tab->use_quick == 2) { - select_lex->options|=QUERY_NO_GOOD_INDEX_USED; + join->thd->server_status|=SERVER_QUERY_NO_GOOD_INDEX_USED; tab->read_first_record= join_init_quick_read_record; statistic_increment(select_range_check_count, &LOCK_status); } @@ -3634,7 +3634,7 @@ make_join_readinfo(JOIN *join, uint options) } else { - select_lex->options|=QUERY_NO_INDEX_USED; + join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED; statistic_increment(select_scan_count, &LOCK_status); } } @@ -3646,7 +3646,7 @@ make_join_readinfo(JOIN *join, uint options) } else { - select_lex->options|=QUERY_NO_INDEX_USED; + join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED; statistic_increment(select_full_join_count, &LOCK_status); } } @@ -8926,7 +8926,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, (ulong)join->select_lex, join->select_lex->type, message ? message : "NULL")); /* Don't log this into the slow query log */ - select_lex->options&= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED); + thd->server_status&= ~(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED); join->unit->offset_limit_cnt= 0; if (message) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index d623ea66dfb..95dff107350 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -166,7 +166,7 @@ int mysql_update(THD *thd, /* If running in safe sql mode, don't allow updates without keys */ if (table->quick_keys.is_clear_all()) { - thd->lex.select_lex.options|=QUERY_NO_INDEX_USED; + thd->server_status|=SERVER_QUERY_NO_INDEX_USED; if (safe_update && !using_limit) { my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, From d7f0cd241d5ccb70f4b44b5065fe979fe9e90797 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Sun, 7 Dec 2003 20:36:45 +0100 Subject: [PATCH 05/12] let chk_index() understand 2-level fulltext index format --- myisam/mi_check.c | 70 +++++++++++++++++++++++++++++++++-------------- sql/sql_table.cc | 2 +- 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 6b2ad9744c4..f9e943fe42c 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -507,6 +507,36 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) DBUG_RETURN(result); } /* chk_key */ +static int chk_index_down(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, + my_off_t page, uchar *buff, ha_rows *keys, + ha_checksum *key_checksum, uint level) +{ + char llbuff[22],llbuff2[22]; + if (page > info->state->key_file_length || (page & (info->s->blocksize -1))) + { + my_off_t max_length=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0)); + mi_check_print_error(param,"Wrong pagepointer: %s at page: %s", + llstr(page,llbuff),llstr(page,llbuff2)); + + if (page+info->s->blocksize > max_length) + goto err; + info->state->key_file_length=(max_length & + ~ (my_off_t) (info->s->blocksize-1)); + } + if (!_mi_fetch_keypage(info,keyinfo,page, DFLT_INIT_HITS,buff,0)) + { + mi_check_print_error(param,"Can't read key from filepos: %s", + llstr(page,llbuff)); + goto err; + } + param->key_file_blocks+=keyinfo->block_length; + if (chk_index(param,info,keyinfo,page,buff,keys,key_checksum,level)) + goto err; + + return 0; +err: + return 1; +} /* Check if index is ok */ @@ -553,27 +583,8 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, if (nod_flag) { next_page=_mi_kpos(nod_flag,keypos); - if (next_page > info->state->key_file_length || - (nod_flag && (next_page & (info->s->blocksize -1)))) - { - my_off_t max_length=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0)); - mi_check_print_error(param,"Wrong pagepointer: %s at page: %s", - llstr(next_page,llbuff),llstr(page,llbuff2)); - - if (next_page+info->s->blocksize > max_length) - goto err; - info->state->key_file_length=(max_length & - ~ (my_off_t) (info->s->blocksize-1)); - } - if (!_mi_fetch_keypage(info,keyinfo,next_page, - DFLT_INIT_HITS,temp_buff,0)) - { - mi_check_print_error(param,"Can't read key from filepos: %s",llstr(next_page,llbuff)); - goto err; - } - param->key_file_blocks+=keyinfo->block_length; - if (chk_index(param,info,keyinfo,next_page,temp_buff,keys,key_checksum, - level+1)) + if (chk_index_down(param,info,keyinfo,next_page, + temp_buff,keys,key_checksum,level+1)) goto err; } old_keypos=keypos; @@ -615,6 +626,23 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, memcpy((char*) info->lastkey,(char*) key,key_length); info->lastkey_length=key_length; record= _mi_dpos(info,0,key+key_length); + if (keyinfo->flag & HA_FULLTEXT) /* special handling for ft2 */ + { + uint off; + int subkeys; + get_key_full_length_rdonly(off, key); + subkeys=ft_sintXkorr(key+off); + if (subkeys < 0) + { + ha_rows tmp_keys=0; + if (chk_index_down(param,info,&info->s->ft2_keyinfo,record, + temp_buff,&tmp_keys,key_checksum,1)) + goto err; + (*keys)+=tmp_keys-1; + continue; + } + /* fall through */ + } if (record >= info->state->data_file_length) { #ifndef DBUG_OFF diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dcb657bdce8..3a579986b6e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1539,7 +1539,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, case HA_ADMIN_CORRUPT: protocol->store("error", 5, system_charset_info); - protocol->store("Corrupt", 8, system_charset_info); + protocol->store("Corrupt", 7, system_charset_info); fatal_error=1; break; From b46d75f08b47d46190f038abed67f81fb078bf61 Mon Sep 17 00:00:00 2001 From: "gluh@gluh.mysql.r18.ru" <> Date: Mon, 8 Dec 2003 09:13:14 +0400 Subject: [PATCH 06/12] Task ID 499:Add a new settable string variable(init_connect, init_slave) to mysqld that is executed for all new connections. (Similar to the client command: mysql_options(... MYSQL_INIT_COMMAND ...). --- sql/mysql_priv.h | 2 ++ sql/mysqld.cc | 4 +-- sql/protocol.cc | 2 -- sql/set_var.cc | 71 ++++++++++++++++++------------------------------ sql/slave.cc | 22 +-------------- sql/sql_class.cc | 1 - sql/sql_class.h | 1 - sql/sql_parse.cc | 46 +++++++++++++------------------ sql/sql_show.cc | 8 +++--- 9 files changed, 55 insertions(+), 102 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5da81422298..a9c98ddca80 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -499,6 +499,8 @@ bool wait_for_tables(THD *thd); bool table_is_used(TABLE *table, bool wait_for_name_lock); bool drop_locked_tables(THD *thd,const char *db, const char *table_name); void abort_locked_tables(THD *thd,const char *db, const char *table_name); +void execute_init_command(THD *thd, sys_var_str *init_command_var, + rw_lock_t *var_mutex); extern const Field *not_found_field; Field *find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, TABLE_LIST **where, bool report_error); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index df539776b19..d3ba147dc76 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3655,10 +3655,10 @@ Disable with --skip-bdb (will save memory).", #endif /* End HAVE_INNOBASE_DB */ {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"init-connect", OPT_INIT_CONNECT, "Command what executes for all new connections", + {"init-connect", OPT_INIT_CONNECT, "Command(s) that are executed for each new connection", (gptr*) &opt_init_connect, (gptr*) &opt_init_connect, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"init-slave", OPT_INIT_SLAVE, "Command what is executed when replication is starting", + {"init-slave", OPT_INIT_SLAVE, "Command(s) that are executed when a slave connects to this master", (gptr*) &opt_init_slave, (gptr*) &opt_init_slave, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"init-file", OPT_INIT_FILE, "Read SQL commands from this file at startup.", diff --git a/sql/protocol.cc b/sql/protocol.cc index c2b1557ab39..1b9256c7723 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -92,7 +92,6 @@ void send_error(THD *thd, uint sql_errno, const char *err) /* In bootstrap it's ok to print on stderr */ fprintf(stderr,"ERROR: %d %s\n",sql_errno,err); } - thd->init_connect_error= 1; DBUG_VOID_RETURN; } @@ -211,7 +210,6 @@ net_printf(THD *thd, uint errcode, ...) fprintf(stderr,"ERROR: %d %s\n",errcode,text_pos); thd->fatal_error(); } - thd->init_connect_error= 1; DBUG_VOID_RETURN; } diff --git a/sql/set_var.cc b/sql/set_var.cc index 29ca3dc951c..012bc5ef6e4 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -674,14 +674,23 @@ struct show_var_st init_vars[]= { */ -static bool sys_update_init_connect(THD *thd, set_var *var) +/* + Update variables 'init_connect, init_slave'. + + In case of 'DEFAULT' value + (for example: 'set GLOBAL init_connect=DEFAULT') + 'var' parameter is NULL pointer. +*/ + +bool update_sys_var_str(sys_var_str *var_str, rw_lock_t *var_mutex, + set_var *var) { char *res= 0, *old_value; - uint new_length; + uint new_length= 0; /* If the string is "", delete old init command */ - if ((new_length= var->value->str_value.length())) + if (var && (new_length= var->value->str_value.length())) { - if (!(res= my_strdup_with_length(var->value->str_value.c_ptr(), + if (!(res= my_strdup_with_length(var->value->str_value.ptr(), new_length, MYF(0)))) return 1; @@ -690,63 +699,37 @@ static bool sys_update_init_connect(THD *thd, set_var *var) Replace the old value in such a way that the any thread using the value will work. */ - rw_wrlock(&LOCK_sys_init_connect); - old_value= sys_init_connect.value; - sys_init_connect.value= res; - sys_init_connect.value_length= new_length; - rw_unlock(&LOCK_sys_init_connect); + rw_wrlock(var_mutex); + old_value= var_str->value; + var_str->value= res; + var_str->value_length= new_length; + rw_unlock(var_mutex); my_free(old_value, MYF(MY_ALLOW_ZERO_PTR)); return 0; } +static bool sys_update_init_connect(THD *thd, set_var *var) +{ + return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var); +} + + static void sys_default_init_connect(THD* thd, enum_var_type type) { - char *old_value; - rw_wrlock(&LOCK_sys_init_connect); - old_value= sys_init_connect.value; - sys_init_connect.value= 0; - sys_init_connect.value_length= 0; - rw_unlock(&LOCK_sys_init_connect); - my_free(old_value, MYF(MY_ALLOW_ZERO_PTR)); + update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0); } static bool sys_update_init_slave(THD *thd, set_var *var) { - char *res= 0, *old_value; - uint new_length; - /* If the string is "", delete old init command */ - if ((new_length= var->value->str_value.length())) - { - if (!(res= my_strdup_with_length(var->value->str_value.c_ptr(), - new_length, - MYF(0)))) - return 1; - } - /* - Replace the old value in such a way that the any thread using - the value will work. - */ - rw_wrlock(&LOCK_sys_init_slave); - old_value= sys_init_slave.value; - sys_init_slave.value= res; - sys_init_slave.value_length= new_length; - rw_unlock(&LOCK_sys_init_slave); - my_free(old_value, MYF(MY_ALLOW_ZERO_PTR)); - return 0; + return update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, var); } static void sys_default_init_slave(THD* thd, enum_var_type type) { - char *old_value; - rw_wrlock(&LOCK_sys_init_slave); - old_value= sys_init_slave.value; - sys_init_slave.value= 0; - sys_init_slave.value_length= 0; - rw_unlock(&LOCK_sys_init_slave); - my_free(old_value, MYF(MY_ALLOW_ZERO_PTR)); + update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0); } diff --git a/sql/slave.cc b/sql/slave.cc index b9da8c7eca6..58eb214a319 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2448,24 +2448,6 @@ err: } -void init_slave_execute(THD *thd, sys_var_str *init_slave_var) -{ - Vio* save_vio; - ulong save_client_capabilities; - - thd->proc_info= "Execution of init_slave"; - thd->query= init_slave_var->value; - thd->query_length= init_slave_var->value_length; - save_client_capabilities= thd->client_capabilities; - thd->client_capabilities|= CLIENT_MULTI_QUERIES; - save_vio= thd->net.vio; - thd->net.vio= 0; - dispatch_command(COM_QUERY, thd, thd->query, thd->query_length+1); - thd->client_capabilities= save_client_capabilities; - thd->net.vio= save_vio; -} - - /* Slave SQL Thread entry point */ extern "C" pthread_handler_decl(handle_slave_sql,arg) @@ -2551,9 +2533,7 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, /* execute init_slave variable */ if (sys_init_slave.value) { - rw_wrlock(&LOCK_sys_init_slave); - init_slave_execute(thd, &sys_init_slave); - rw_unlock(&LOCK_sys_init_slave); + execute_init_command(thd, &sys_init_slave, &LOCK_sys_init_slave); if (thd->query_error) { sql_print_error("\ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 8677c262437..c233ffd422a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -121,7 +121,6 @@ THD::THD():user_time(0), is_fatal_error(0), system_thread=cleanup_done=0; peer_port= 0; // For SHOW PROCESSLIST transaction.changed_tables = 0; - init_connect_error= 0; #ifdef __WIN__ real_id = 0; #endif diff --git a/sql/sql_class.h b/sql/sql_class.h index 900c17a8743..f6336cb7dd9 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -560,7 +560,6 @@ public: bool prepare_command; bool tmp_table_used; - bool init_connect_error; /* If we do a purge of binary logs, log index info of the threads that are currently reading it needs to be adjusted. To do that diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f2e268abcd2..614cbaccf01 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -794,19 +794,31 @@ check_connections(THD *thd) } -void init_connect_execute(THD *thd, sys_var_str *init_connect_var) +void execute_init_command(THD *thd, sys_var_str *init_command_var, + rw_lock_t *var_mutex) { Vio* save_vio; ulong save_client_capabilities; - thd->proc_info= "Execution of init_connect"; - thd->query= init_connect_var->value; - thd->query_length= init_connect_var->value_length; + thd->proc_info= "Execution of init_command"; + /* + We need to lock init_command_var because + during execution of init_command_var query + values of init_command_var can't be changed + */ + rw_rdlock(var_mutex); + thd->query= init_command_var->value; + thd->query_length= init_command_var->value_length; save_client_capabilities= thd->client_capabilities; thd->client_capabilities|= CLIENT_MULTI_QUERIES; + /* + We don't need return result of execution to client side. + To forbid this we should set thd->net.vio to 0. + */ save_vio= thd->net.vio; thd->net.vio= 0; dispatch_command(COM_QUERY, thd, thd->query, thd->query_length+1); + rw_unlock(var_mutex); thd->client_capabilities= save_client_capabilities; thd->net.vio= save_vio; } @@ -887,29 +899,9 @@ pthread_handler_decl(handle_one_connection,arg) thd->version= refresh_version; if (sys_init_connect.value && !(thd->master_access & SUPER_ACL)) { - rw_wrlock(&LOCK_sys_init_connect); - init_connect_execute(thd, &sys_init_connect); - rw_unlock(&LOCK_sys_init_connect); - if (thd->init_connect_error) - { - if (thd->user_connect) - decrease_user_connections(thd->user_connect); - free_root(&thd->mem_root,MYF(0)); - if (!thd->killed && thd->variables.log_warnings) - { - sql_print_error(ER(ER_NEW_ABORTING_CONNECTION), - thd->thread_id,(thd->db ? thd->db : "unconnected"), - thd->user ? thd->user : "unauthenticated", - thd->host_or_ip, - "Can't execute init_connect query"); - statistic_increment(aborted_threads,&LOCK_status); - } - else if (thd->killed) - { - statistic_increment(aborted_threads,&LOCK_status); - } - goto end_thread; - } + execute_init_command(thd, &sys_init_connect, &LOCK_sys_init_connect); + if (thd->query_error) + thd->killed= 1; } thd->proc_info=0; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 42c89db9ca4..c80393715f6 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1618,10 +1618,10 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, break; case SHOW_CHAR_PTR: { - if (!(pos= *(char**) value)) - pos= ""; - end= strend(pos); - break; + if (!(pos= *(char**) value)) + pos= ""; + end= strend(pos); + break; } #ifdef HAVE_OPENSSL /* First group - functions relying on CTX */ From 38a4780fd13e0b2e3df1bcbdedade6575585ee0f Mon Sep 17 00:00:00 2001 From: "gluh@gluh.mysql.r18.ru" <> Date: Mon, 8 Dec 2003 12:10:30 +0400 Subject: [PATCH 07/12] Fixed test for 'init_slave' variable --- mysql-test/r/rpl_init_slave.result | 23 ++++++++++++----------- mysql-test/t/rpl_init_slave-slave.opt | 2 +- mysql-test/t/rpl_init_slave.test | 10 +++++----- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/rpl_init_slave.result b/mysql-test/r/rpl_init_slave.result index a91b2da85cd..83d0a3289a2 100644 --- a/mysql-test/r/rpl_init_slave.result +++ b/mysql-test/r/rpl_init_slave.result @@ -4,20 +4,21 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; +show variables like 'init_slave'; +Variable_name Value +init_slave set global max_connections=500 +show variables like 'max_connections'; +Variable_name Value +max_connections 500 reset master; -create table t1(n int); -insert into t1 values (@a), (@b); -select * from t1; -n -NULL -NULL -select * from t1; -n -1 -2 +show variables like 'init_slave'; +Variable_name Value +init_slave +show variables like 'max_connections'; +Variable_name Value +max_connections 100 set global init_connect="set @c=1"; show variables like 'init_connect'; Variable_name Value init_connect set @c=1 -drop table t1; stop slave; diff --git a/mysql-test/t/rpl_init_slave-slave.opt b/mysql-test/t/rpl_init_slave-slave.opt index 6433dccf4aa..337e8a60d97 100644 --- a/mysql-test/t/rpl_init_slave-slave.opt +++ b/mysql-test/t/rpl_init_slave-slave.opt @@ -1 +1 @@ ---init-slave="set @a=1;set @b=2" +--init-slave="set global max_connections=500" diff --git a/mysql-test/t/rpl_init_slave.test b/mysql-test/t/rpl_init_slave.test index 67d35546225..3ea04117ced 100644 --- a/mysql-test/t/rpl_init_slave.test +++ b/mysql-test/t/rpl_init_slave.test @@ -6,20 +6,20 @@ source include/master-slave.inc; save_master_pos; connection slave; +sleep 1; +show variables like 'init_slave'; +show variables like 'max_connections'; sync_with_master; reset master; connection master; -create table t1(n int); -insert into t1 values (@a), (@b); -select * from t1; +show variables like 'init_slave'; +show variables like 'max_connections'; save_master_pos; connection slave; sync_with_master; -select * from t1; set global init_connect="set @c=1"; show variables like 'init_connect'; connection master; -drop table t1; save_master_pos; connection slave; sync_with_master; From e8aef44349bc3441013dad0ed469bdb04f18d5b6 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Mon, 8 Dec 2003 12:25:37 +0200 Subject: [PATCH 08/12] Portability fixes for Windows --- VC++Files/client/mysqlclient.dsp | 12 +++++++++++ VC++Files/libmysql/libmysql.dsp | 12 +++++++++++ VC++Files/strings/strings.dsp | 4 ++++ libmysqld/lib_sql.cc | 30 ++++++++++++++++++---------- scripts/make_win_src_distribution.sh | 19 +++++++++--------- scripts/mysql_install_db.sh | 4 +++- sql/mysqld.cc | 1 - sql/set_var.cc | 9 +++++++-- sql/share/czech/errmsg.txt | 8 ++++---- sql/share/danish/errmsg.txt | 8 ++++---- sql/share/dutch/errmsg.txt | 8 ++++---- sql/share/english/errmsg.txt | 8 ++++---- sql/share/estonian/errmsg.txt | 8 ++++---- sql/share/french/errmsg.txt | 8 ++++---- sql/share/greek/errmsg.txt | 8 ++++---- sql/share/hungarian/errmsg.txt | 8 ++++---- sql/share/italian/errmsg.txt | 8 ++++---- sql/share/japanese/errmsg.txt | 8 ++++---- sql/share/korean/errmsg.txt | 8 ++++---- sql/share/norwegian-ny/errmsg.txt | 8 ++++---- sql/share/norwegian/errmsg.txt | 8 ++++---- sql/share/polish/errmsg.txt | 8 ++++---- sql/share/portuguese/errmsg.txt | 8 ++++---- sql/share/romanian/errmsg.txt | 8 ++++---- sql/share/russian/errmsg.txt | 8 ++++---- sql/share/serbian/errmsg.txt | 8 ++++---- sql/share/slovak/errmsg.txt | 8 ++++---- sql/share/spanish/errmsg.txt | 8 ++++---- sql/share/swedish/errmsg.txt | 8 ++++---- sql/share/ukrainian/errmsg.txt | 8 ++++---- sql/sql_acl.cc | 1 - strings/ctype-big5.c | 15 +++++++------- strings/ctype-euc_kr.c | 4 ++-- strings/ctype-gb2312.c | 15 +++++++------- strings/ctype-gbk.c | 4 ++-- strings/ctype-sjis.c | 16 ++++++++------- strings/ctype-ucs2.c | 6 +++--- strings/ctype-ujis.c | 14 ++++++------- 38 files changed, 193 insertions(+), 149 deletions(-) diff --git a/VC++Files/client/mysqlclient.dsp b/VC++Files/client/mysqlclient.dsp index 4a9d52232ca..2a1b52d54ee 100644 --- a/VC++Files/client/mysqlclient.dsp +++ b/VC++Files/client/mysqlclient.dsp @@ -160,10 +160,22 @@ SOURCE="..\strings\ctype-tis620.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-ucs2.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-ujis.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-utf8.c" +# End Source File +# Begin Source File + +SOURCE="..\strings\ctype-win1250ch.c" +# End Source File +# Begin Source File + SOURCE=..\strings\ctype.c # End Source File # Begin Source File diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp index 6b76a6147ff..0f94574b3cc 100644 --- a/VC++Files/libmysql/libmysql.dsp +++ b/VC++Files/libmysql/libmysql.dsp @@ -179,10 +179,22 @@ SOURCE="..\strings\ctype-tis620.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-ucs2.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-ujis.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-utf8.c" +# End Source File +# Begin Source File + +SOURCE="..\strings\ctype-win1250ch.c" +# End Source File +# Begin Source File + SOURCE=..\strings\ctype.c # End Source File # Begin Source File diff --git a/VC++Files/strings/strings.dsp b/VC++Files/strings/strings.dsp index 4e43cc875c8..030acdb7451 100644 --- a/VC++Files/strings/strings.dsp +++ b/VC++Files/strings/strings.dsp @@ -156,6 +156,10 @@ SOURCE=".\ctype-tis620.c" # End Source File # Begin Source File +SOURCE=".\ctype-ucs2.c" +# End Source File +# Begin Source File + SOURCE=".\ctype-ujis.c" # End Source File # Begin Source File diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index d4cb916a89c..2fd6927854f 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -45,7 +45,7 @@ C_MODE_START static my_bool org_my_init_done; my_bool server_inited; -static my_bool STDCALL +static my_bool emb_advanced_command(MYSQL *mysql, enum enum_server_command command, const char *header, ulong header_length, const char *arg, ulong arg_length, my_bool skip_check) @@ -103,7 +103,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, return result; } -static MYSQL_DATA * STDCALL +static MYSQL_DATA * emb_read_rows(MYSQL *mysql, MYSQL_FIELD *mysql_fields __attribute__((unused)), unsigned int fields __attribute__((unused))) { @@ -126,12 +126,12 @@ emb_read_rows(MYSQL *mysql, MYSQL_FIELD *mysql_fields __attribute__((unused)), return result; } -static MYSQL_FIELD * STDCALL emb_list_fields(MYSQL *mysql) +static MYSQL_FIELD *emb_list_fields(MYSQL *mysql) { return mysql->fields; } -static my_bool STDCALL emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) +static my_bool emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) { THD *thd= (THD*)mysql->thd; if (mysql->net.last_errno) @@ -159,7 +159,8 @@ static my_bool STDCALL emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) else the lengths are calculated from the offset between pointers. **************************************************************************/ -static void STDCALL emb_fetch_lengths(ulong *to, MYSQL_ROW column, unsigned int field_count) +static void emb_fetch_lengths(ulong *to, MYSQL_ROW column, + unsigned int field_count) { MYSQL_ROW end; @@ -167,7 +168,7 @@ static void STDCALL emb_fetch_lengths(ulong *to, MYSQL_ROW column, unsigned int *to= *column ? *(uint *)((*column) - sizeof(uint)) : 0; } -static my_bool STDCALL emb_mysql_read_query_result(MYSQL *mysql) +static my_bool emb_mysql_read_query_result(MYSQL *mysql) { if (mysql->net.last_errno) return -1; @@ -178,7 +179,7 @@ static my_bool STDCALL emb_mysql_read_query_result(MYSQL *mysql) return 0; } -static int STDCALL emb_stmt_execute(MYSQL_STMT *stmt) +static int emb_stmt_execute(MYSQL_STMT *stmt) { DBUG_ENTER("emb_stmt_execute"); THD *thd= (THD*)stmt->mysql->thd; @@ -205,7 +206,7 @@ MYSQL_DATA *emb_read_binary_rows(MYSQL_STMT *stmt) return emb_read_rows(stmt->mysql, 0, 0); } -int STDCALL emb_unbuffered_fetch(MYSQL *mysql, char **row) +int emb_unbuffered_fetch(MYSQL *mysql, char **row) { MYSQL_DATA *data= ((THD*)mysql->thd)->data; if (!data || !data->data) @@ -225,7 +226,7 @@ int STDCALL emb_unbuffered_fetch(MYSQL *mysql, char **row) return 0; } -static void STDCALL emb_free_embedded_thd(MYSQL *mysql) +static void emb_free_embedded_thd(MYSQL *mysql) { THD *thd= (THD*)mysql->thd; if (thd->data) @@ -234,18 +235,25 @@ static void STDCALL emb_free_embedded_thd(MYSQL *mysql) delete thd; } -static const char * STDCALL emb_read_statistic(MYSQL *mysql) +static const char * emb_read_statistic(MYSQL *mysql) { THD *thd= (THD*)mysql->thd; return thd->net.last_error; } + +static MYSQL_RES * emb_mysql_store_result(MYSQL *mysql) +{ + return mysql_store_result(mysql); +} + + MYSQL_METHODS embedded_methods= { emb_mysql_read_query_result, emb_advanced_command, emb_read_rows, - mysql_store_result, + emb_mysql_store_result, emb_fetch_lengths, emb_list_fields, emb_read_prepare_result, diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index d83548d0061..57612ac8edc 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -178,18 +178,8 @@ rm -r -f "$BASE/share/Makefile" rm -r -f "$BASE/share/Makefile.in" rm -r -f "$BASE/share/Makefile.am" -# -# Clean up if we did this from a bk tree -# - -if [ -d $BASE/SCCS ] -then - find $BASE/ -type d -name SCCS -printf " \"%p\"" | xargs rm -r -f -fi - mkdir $BASE/Docs $BASE/extra $BASE/include - # # Copy directory files # @@ -320,6 +310,15 @@ done unix_to_dos $BASE/README mv $BASE/README $BASE/README.txt +# +# Clean up if we did this from a bk tree +# + +if [ -d $BASE/SSL/SCCS ] +then + find $BASE -type d -name SCCS | xargs rm -r -f +fi + # # Initialize the initial data directory # diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index acf0f8aa2c8..fcb1f2a4ef1 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -119,11 +119,13 @@ fi mdata=$ldata/mysql mysqld=$execdir/mysqld mysqld_opt="" +scriptdir=$bindir if test "$windows" = 1 then mysqld="./sql/mysqld" mysqld_opt="--language=./sql/share/english" + scriptdir="./scripts" fi if test ! -x $mysqld @@ -199,7 +201,7 @@ then echo "Installing all prepared tables" fi if ( - $bindir/mysql_create_system_tables $create_option $mdata $hostname $windows + $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows if test -n "$fill_help_tables" then cat $fill_help_tables diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2a5f639a440..e9dee43155f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3327,7 +3327,6 @@ pthread_handler_decl(handle_connections_shared_memory,arg) HANDLE event_connect_answer= 0; ulong smem_buffer_length= shared_memory_buffer_length + 4; ulong connect_number= 1; - my_bool error_allow; char tmp[63]; char *suffix_pos; char connect_number_char[22], *p; diff --git a/sql/set_var.cc b/sql/set_var.cc index 5b956cd9c76..bd06652dc31 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2412,8 +2412,9 @@ int set_var_password::update(THD *thd) Functions to handle table_type ****************************************************************************/ +/* Based upon sys_var::check_enum() */ + bool sys_var_thd_table_type::check(THD *thd, set_var *var) - /* Based upon sys_var::check_enum() */ { char buff[80]; const char *value; @@ -2436,6 +2437,7 @@ err: return 1; } + byte *sys_var_thd_table_type::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { @@ -2443,9 +2445,10 @@ byte *sys_var_thd_table_type::value_ptr(THD *thd, enum_var_type type, val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : thd->variables.*offset); const char *table_type= ha_get_table_type((enum db_type)val); - return (byte *)table_type; + return (byte *) table_type; } + void sys_var_thd_table_type::set_default(THD *thd, enum_var_type type) { if (type == OPT_GLOBAL) @@ -2454,6 +2457,7 @@ void sys_var_thd_table_type::set_default(THD *thd, enum_var_type type) thd->variables.*offset= (ulong) (global_system_variables.*offset); } + bool sys_var_thd_table_type::update(THD *thd, set_var *var) { if (var->type == OPT_GLOBAL) @@ -2463,6 +2467,7 @@ bool sys_var_thd_table_type::update(THD *thd, set_var *var) return 0; } + /**************************************************************************** Functions to handle sql_mode ****************************************************************************/ diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 2e664d8b892..a77e6e4333b 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -272,10 +272,10 @@ character-set=latin2 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 59eef466ca3..1e04ef7340b 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -266,10 +266,10 @@ character-set=latin1 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 992effea88e..e9b0ac12e29 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -274,10 +274,10 @@ character-set=latin1 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index b57cb62814e..233f57cec28 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -263,10 +263,10 @@ character-set=latin1 "ZLIB: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "ZLIB: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index fd4c6d3e52e..fa6201f9097 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -268,10 +268,10 @@ character-set=latin7 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 1e2c6fa4178..dbc4cfeae5e 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -263,10 +263,10 @@ character-set=latin1 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index d3aebcba5d3..4d8a6d44099 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -263,10 +263,10 @@ character-set=greek "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index ed38956da44..3a6e309435c 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -265,10 +265,10 @@ character-set=latin2 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index e85a134614f..fcc3379e138 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -263,10 +263,10 @@ character-set=latin1 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 49efa03eef2..c4bd5dab028 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -265,10 +265,10 @@ character-set=ujis "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index b2be32402db..14112e5b6bd 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -263,10 +263,10 @@ character-set=euckr "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index c67ff6d8263..9b0274965a7 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -265,10 +265,10 @@ character-set=latin1 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index f412e4f8615..906e4702cab 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -265,10 +265,10 @@ character-set=latin1 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 715f17e3ccc..c9229d0c522 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -267,10 +267,10 @@ character-set=latin2 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index e98879508d6..9ff6325f935 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -264,10 +264,10 @@ character-set=latin1 "Z_BUF_ERROR: Não suficiente espaço no buffer emissor para zlib (provavelmente, o comprimento dos dados descomprimidos está corrupto)", "Z_DATA_ERROR: Dados de entrada está corrupto para zlib", "%d linha(s) foi(foram) cortada(s) por group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Usando engine de armazenamento %s para tabela '%s'", "Combinação ilegal de collations (%s,%s) e (%s,%s) para operação '%s'", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 46ece3bc9ce..34dd64daa2d 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -267,10 +267,10 @@ character-set=latin2 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 40e8c585eb3..6f22d1b87fd 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -265,10 +265,10 @@ character-set=koi8r "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index 4002ffe926c..98308190587 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -258,10 +258,10 @@ character-set=cp1250 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 7324906fca1..5decce35dfd 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -271,10 +271,10 @@ character-set=latin2 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 0db613ae4c7..00f31d351df 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -265,10 +265,10 @@ character-set=latin1 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 96e124207ed..a53b6e4df3a 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -263,10 +263,10 @@ character-set=latin1 "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d rad(er) kapades av group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Använder handler %s för tabell '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 587e599c01e..e3a496831a2 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -268,10 +268,10 @@ character-set=koi8u "Z_BUF_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)", "Z_DATA_ERROR: Input data was corrupted for zlib", "%d line(s) was(were) cut by group_concat()", -"Record count is fewer than the column count at row %ld"; -"Record count is more than the column count at row %ld"; -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld"; -"Data truncated, out of range for column '%s' at row %ld"; +"Record count is fewer than the column count at row %ld", +"Record count is more than the column count at row %ld", +"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", +"Data truncated, out of range for column '%s' at row %ld", "Data truncated for column '%s' at row %ld", "Using storage engine %s for table '%s'", "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index ac517014108..5364357a24b 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2548,7 +2548,6 @@ my_bool grant_init(THD *org_thd) { if (hostname_requires_resolving(mem_check->host)) { - char buff[MAX_FIELD_WIDTH]; sql_print_error("Warning: 'tables_priv' entry '%s %s@%s' " "ignored in --skip-name-resolve mode.", mem_check->tname, mem_check->user, diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 878493bc31f..d70b06217c0 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6183,16 +6183,16 @@ my_wc_mb_big5(CHARSET_INFO *cs __attribute__((unused)), if (s >= e) return MY_CS_TOOSMALL; - if(wc<0x80) + if ((int) wc < 0x80) { - s[0]=wc; + s[0]= (uchar) wc; return 1; } - if(!(code=func_uni_big5_onechar(wc))) + if (!(code=func_uni_big5_onechar(wc))) return MY_CS_ILUNI; - if(s+2>e) + if (s+2>e) return MY_CS_TOOSMALL; s[0]=code>>8; @@ -6201,6 +6201,7 @@ my_wc_mb_big5(CHARSET_INFO *cs __attribute__((unused)), return 2; } + static int my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc,const uchar *s,const uchar *e) @@ -6211,16 +6212,16 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)), if (s >= e) return MY_CS_TOOFEW(0); - if(hi<0x80) + if (hi<0x80) { pwc[0]=hi; return 1; } - if(s+2>e) + if (s+2>e) return MY_CS_TOOFEW(0); - if(!(pwc[0]=func_big5_uni_onechar((hi<<8)+s[1]))) + if (!(pwc[0]=func_big5_uni_onechar((hi<<8)+s[1]))) return MY_CS_ILSEQ; return 2; diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index d47c4268642..5b04d9fa53b 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8591,9 +8591,9 @@ my_wc_mb_euc_kr(CHARSET_INFO *cs __attribute__((unused)), if (s >= e) return MY_CS_TOOSMALL; - if (wc<0x80) + if ((uint) wc < 0x80) { - s[0]=wc; + s[0]= (uchar) wc; return 1; } diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index d429fa34eea..afc418e01bd 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5641,16 +5641,16 @@ my_wc_mb_gb2312(CHARSET_INFO *cs __attribute__((unused)), if (s >= e) return MY_CS_TOOSMALL; - if (wc<0x80) + if ((uint) wc < 0x80) { - s[0]=wc; + s[0]= (uchar) wc; return 1; } if (!(code=func_uni_gb2312_onechar(wc))) return MY_CS_ILUNI; - if(s+2>e) + if (s+2>e) return MY_CS_TOOSMALL; code|=0x8080; @@ -5659,26 +5659,27 @@ my_wc_mb_gb2312(CHARSET_INFO *cs __attribute__((unused)), return 2; } + static int my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc, const uchar *s, const uchar *e){ int hi; - hi=s[0]; + hi=(int) s[0]; if (s >= e) return MY_CS_TOOFEW(0); - if(hi<0x80) + if (hi<0x80) { pwc[0]=hi; return 1; } - if(s+2>e) + if (s+2>e) return MY_CS_TOOFEW(0); - if(!(pwc[0]=func_gb2312_uni_onechar(((hi<<8)+s[1])&0x7F7F))) + if (!(pwc[0]=func_gb2312_uni_onechar(((hi<<8)+s[1])&0x7F7F))) return MY_CS_ILSEQ; return 2; diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index fa7aa175103..db500644674 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9837,9 +9837,9 @@ my_wc_mb_gbk(CHARSET_INFO *cs __attribute__((unused)), if (s >= e) return MY_CS_TOOSMALL; - if (wc<0x80) + if ((uint) wc < 0x80) { - s[0]=wc; + s[0]= (uchar) wc; return 1; } diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index f302e678b9f..f08f8d4f0c2 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4428,16 +4428,16 @@ my_wc_mb_sjis(CHARSET_INFO *cs __attribute__((unused)), if (s >= e) return MY_CS_TOOSMALL; - if(wc<0x80) + if ((int) wc < 0x80) { - s[0]=wc; + s[0]= (uchar) wc; return 1; } - if(!(code=func_uni_sjis_onechar(wc))) + if (!(code=func_uni_sjis_onechar(wc))) return MY_CS_ILUNI; - if(s+2>e) + if (s+2>e) return MY_CS_TOOSMALL; s[0]=code>>8; @@ -4445,6 +4445,7 @@ my_wc_mb_sjis(CHARSET_INFO *cs __attribute__((unused)), return 2; } + static int my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc, const uchar *s, const uchar *e){ @@ -4453,16 +4454,16 @@ my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)), if (s >= e) return MY_CS_TOOFEW(0); - if(hi<0x80) + if (hi<0x80) { pwc[0]=hi; return 1; } - if(s+2>e) + if (s+2>e) return MY_CS_TOOFEW(0); - if(!(pwc[0]=func_sjis_uni_onechar((hi<<8)+s[1]))) + if (!(pwc[0]=func_sjis_uni_onechar((hi<<8)+s[1]))) return MY_CS_ILSEQ; return 2; @@ -4481,6 +4482,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_hash_sort_simple, }; + static MY_CHARSET_HANDLER my_charset_handler= { ismbchar_sjis, diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index cdcd91b2916..beb803a69f2 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -106,8 +106,8 @@ static int my_uni_ucs2 (CHARSET_INFO *cs __attribute__((unused)) , if ( r+2 > e ) return MY_CS_TOOSMALL; - r[0]=wc >> 8; - r[1]=wc & 0xFF; + r[0]= (uchar) (wc >> 8); + r[1]= (uchar) (wc & 0xFF); return 2; } @@ -862,7 +862,7 @@ double my_strntod_ucs2(CHARSET_INFO *cs __attribute__((unused)), s+=cnv; if (wc > (int) (uchar) 'e' || !wc) break; /* Can't be part of double */ - *b++=wc; + *b++= (char) wc; } *b= 0; diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 29375aca727..a6f8ac65771 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -252,25 +252,25 @@ my_wc_mb_jisx0201(CHARSET_INFO *cs __attribute__((unused)), uchar *e __attribute__((unused))) { - if (wc <= 0x7D) + if ((int) wc <= 0x7D) { - *s = wc; + *s = (uchar) wc; return (wc == 0x5C) ? MY_CS_ILUNI : 1; } if (wc >= 0xFF61 && wc <= 0xFF9F) { - *s = (wc - 0xFEC0); + *s = (uchar) (wc - 0xFEC0); return 1; } - if (wc==0x00A5) + if (wc == 0x00A5) { *s = 0x5C; return 1; } - if (wc==0x203E) + if (wc == 0x203E) { *s = 0x7E; return 1; @@ -8349,12 +8349,12 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e) if (s >= e) return MY_CS_TOOSMALL; - if (wc<0x80) + if ((int) wc < 0x80) { if (s>e) return MY_CS_TOOSMALL; - *s=wc; + *s= (uchar) wc; return 1; } From 54f76e2c930c7c71351c7001e46426f285c25aac Mon Sep 17 00:00:00 2001 From: "konstantin@oak.local" <> Date: Mon, 8 Dec 2003 13:30:14 +0300 Subject: [PATCH 09/12] commented why valgrind barks at the bug #1500 --- tests/client_test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/client_test.c b/tests/client_test.c index 048935d2efb..464d5b632ae 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -7955,7 +7955,12 @@ static void test_ts() /* Test for bug #1500. + XXX: despite that this bug is fixed, it spots mysqld code which is not + working correctly yet: to fix all things properly we need to implement + Item::cleanup() method for all items (as described in bugs #1663 and + #1749). So don't be surprised in case valgrind barks on it. */ + static void test_bug1500() { MYSQL_STMT *stmt; From 9aa12e25f1eb05f2bc18bf29e098a79297aeef8a Mon Sep 17 00:00:00 2001 From: "lenz@kallisto.local" <> Date: Mon, 8 Dec 2003 14:38:29 +0100 Subject: [PATCH 10/12] Fixed two packaging bugs: - postinstall of the Mac OS X PKG failed as a parameter for mysql_install_db was changed for MySQL 4.1 - postinstall of the Server RPM failed as mysql_create_system_tables was missing from the file list --- support-files/MacOSX/postinstall.sh | 2 +- support-files/mysql.spec.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/support-files/MacOSX/postinstall.sh b/support-files/MacOSX/postinstall.sh index f46f4480e3e..ff921d3fee9 100644 --- a/support-files/MacOSX/postinstall.sh +++ b/support-files/MacOSX/postinstall.sh @@ -10,7 +10,7 @@ if cd @prefix@ ; then if [ ! -f data/mysql/db.frm ] ; then - ./scripts/mysql_install_db -IN-RPM + ./scripts/mysql_install_db --rpm fi if [ -d data ] ; then diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 59006a187d0..0eb642650d7 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -470,6 +470,7 @@ fi %attr(755, root, root) %{_bindir}/myisamlog %attr(755, root, root) %{_bindir}/myisampack %attr(755, root, root) %{_bindir}/mysql_convert_table_format +%attr(755, root, root) %{_bindir}/mysql_create_system_tables %attr(755, root, root) %{_bindir}/mysql_explain_log %attr(755, root, root) %{_bindir}/mysql_fix_extensions %attr(755, root, root) %{_bindir}/mysql_fix_privilege_tables @@ -568,6 +569,10 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Fri Dec 05 2003 Lenz Grimmer + +- added missing file mysql_create_system_tables to the server subpackage + * Fri Nov 21 2003 Lenz Grimmer - removed dependency on MySQL-client from the MySQL-devel subpackage From 4d1f521f21ed94d5e2aa67251efba958c1b571d5 Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Tue, 9 Dec 2003 15:28:58 +0400 Subject: [PATCH 11/12] Fix for the bug #1994: mysqldump does not correctly dump UCS2 data. --- client/mysqldump.c | 7 ++++++- mysql-test/r/mysqldump.result | 39 +++++++++++++++++++++++++++++++++++ mysql-test/t/mysqldump.test | 9 ++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 31305c93e6c..cdb0a62d4cc 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -89,7 +89,11 @@ static char insert_pat[12 * 1024],*opt_password=0,*current_user=0, *where=0, *opt_compatible_mode_str= 0, *err_ptr= 0; +#ifdef HAVE_CHARSET_utf8 +static char *default_charset= (char*) "utf8"; +#else static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; +#endif static ulong opt_compatible_mode= 0; static uint opt_mysql_port= 0, err_len= 0; static my_string opt_mysql_unix_port=0; @@ -351,7 +355,7 @@ static void write_header(FILE *sql_file, char *db_name) fprintf(sql_file, "-- Server version\t%s\n", mysql_get_server_info(&mysql_connection)); if (!opt_set_names) - fprintf(sql_file,"\n/*!40101 SET NAMES %s*/;\n",default_charset); + fprintf(sql_file,"\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=%s */;\n",default_charset); fprintf(md_result_file,"\ /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n\ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n\ @@ -372,6 +376,7 @@ static void write_footer(FILE *sql_file) /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;\n\ /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;\n\ /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n\ +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n\ "); } fputs("\n", sql_file); diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 4025a01bc93..f5d98143f9e 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -62,3 +62,42 @@ INSERT INTO t1 VALUES ("1\""), ("\"2"); DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET ucs2; +INSERT INTO t1 VALUES (_ucs2 x'05D005D505DC05D9'); +-- MySQL dump 10.2 +-- +-- Host: localhost Database: test +-- ------------------------------------------------------ +-- Server version 4.1.2-alpha-debug-log + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */; + +-- +-- Table structure for table `t1` +-- + +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( + a varchar(255) default NULL +) TYPE=MyISAM DEFAULT CHARSET=ucs2; + +-- +-- Dumping data for table `t1` +-- + + +/*!40000 ALTER TABLE t1 DISABLE KEYS */; +LOCK TABLES t1 WRITE; +INSERT INTO t1 VALUES ('×ולי'); +UNLOCK TABLES; +/*!40000 ALTER TABLE t1 ENABLE KEYS */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; + +DROP TABLE t1; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 954fdcb925a..2004d5122f1 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -22,3 +22,12 @@ CREATE TABLE t1 (`a"b"` char(2)); INSERT INTO t1 VALUES ("1\""), ("\"2"); --exec $MYSQL_DUMP --skip-all -X test t1 DROP TABLE t1; + +# +# Bug #1994 +# + +CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET ucs2; +INSERT INTO t1 VALUES (_ucs2 x'05D005D505DC05D9'); +--exec $MYSQL_DUMP test t1 +DROP TABLE t1; From 2c3065c9cbac9a8b8ad4d053d0c95f2c7e53714a Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Tue, 9 Dec 2003 19:05:41 +0100 Subject: [PATCH 12/12] Post-merge fixes. --- mysql-test/r/mysqldump.result | 2 +- sql/sql_parse.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index f5d98143f9e..8efda4b110c 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -68,7 +68,7 @@ INSERT INTO t1 VALUES (_ucs2 x'05D005D505DC05D9'); -- -- Host: localhost Database: test -- ------------------------------------------------------ --- Server version 4.1.2-alpha-debug-log +-- Server version 5.0.0-alpha-debug-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fa94296cb0a..c8d5ebe0743 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -980,7 +980,7 @@ pthread_handler_decl(handle_one_connection,arg) { execute_init_command(thd, &sys_init_connect, &LOCK_sys_init_connect); if (thd->query_error) - thd->killed= 1; + thd->killed= THD::KILL_CONNECTION; } thd->proc_info=0;