diff options
author | unknown <serg@serg.mylan> | 2004-08-18 19:57:55 +0200 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-08-18 19:57:55 +0200 |
commit | 945625ebaa21468fdf0b2a3c1786fca50bdd5aa2 (patch) | |
tree | 8ac7985dc9b6caddd1c2402ef8606e4a4cd85ada /sql | |
parent | 992ff0a27274c0c95da2f4ea1496bb9356201f89 (diff) | |
parent | 0c6b96658e96cc604c9c5fedb41a5e43bad4f74b (diff) | |
download | mariadb-git-945625ebaa21468fdf0b2a3c1786fca50bdd5aa2.tar.gz |
manually merged
BitKeeper/etc/logging_ok:
auto-union
BitKeeper/deleted/.del-mytest-old.c~5237697b30cf59e4:
Auto merged
Build-tools/Bootstrap:
Auto merged
Build-tools/mysql-copyright:
Auto merged
configure.in:
Auto merged
BitKeeper/deleted/.del-mysql_fix_privilege_tables.sql:
Auto merged
VC++Files/innobase/innobase.dsp:
Auto merged
client/mysql.cc:
Auto merged
include/my_global.h:
Auto merged
innobase/dict/dict0crea.c:
Auto merged
innobase/dict/dict0dict.c:
Auto merged
innobase/include/mtr0log.h:
Auto merged
innobase/include/mtr0log.ic:
Auto merged
innobase/include/srv0srv.h:
Auto merged
innobase/include/ut0dbg.h:
Auto merged
innobase/lock/lock0lock.c:
Auto merged
innobase/os/os0file.c:
Auto merged
innobase/row/row0mysql.c:
Auto merged
innobase/row/row0sel.c:
Auto merged
innobase/srv/srv0srv.c:
Auto merged
innobase/ut/ut0dbg.c:
Auto merged
innobase/ut/ut0mem.c:
Auto merged
libmysql/Makefile.am:
Auto merged
libmysql/Makefile.shared:
Auto merged
libmysql/conf_to_src.c:
Auto merged
libmysql/dll.c:
Auto merged
libmysql/errmsg.c:
Auto merged
libmysql/manager.c:
Auto merged
libmysql_r/Makefile.am:
Auto merged
myisam/mi_key.c:
Auto merged
mysql-test/Makefile.am:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
mysql-test/r/having.result:
Auto merged
mysql-test/r/heap.result:
Auto merged
mysql-test/r/type_date.result:
Auto merged
mysql-test/r/type_float.result:
Auto merged
mysql-test/t/having.test:
Auto merged
mysql-test/t/heap.test:
Auto merged
mysql-test/t/type_date.test:
Auto merged
mysql-test/t/type_float.test:
Auto merged
mysql-test/t/type_uint.test:
Auto merged
scripts/make_binary_distribution.sh:
Auto merged
scripts/make_win_src_distribution.sh:
Auto merged
sql/Makefile.am:
Auto merged
sql/field.h:
Auto merged
sql/ha_heap.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/item_sum.h:
Auto merged
sql/lock.cc:
Auto merged
sql/log.cc:
Auto merged
sql/protocol.cc:
Auto merged
sql/repl_failsafe.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_analyse.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/share/czech/errmsg.txt:
Auto merged
sql/share/danish/errmsg.txt:
Auto merged
sql/share/dutch/errmsg.txt:
Auto merged
sql/share/english/errmsg.txt:
Auto merged
sql/share/estonian/errmsg.txt:
Auto merged
sql/share/french/errmsg.txt:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/share/greek/errmsg.txt:
Auto merged
sql/share/hungarian/errmsg.txt:
Auto merged
sql/share/japanese/errmsg.txt:
Auto merged
sql/share/korean/errmsg.txt:
Auto merged
sql/share/norwegian-ny/errmsg.txt:
Auto merged
sql/share/norwegian/errmsg.txt:
Auto merged
sql/share/polish/errmsg.txt:
Auto merged
sql/share/portuguese/errmsg.txt:
Auto merged
sql/share/romanian/errmsg.txt:
Auto merged
sql/share/russian/errmsg.txt:
Auto merged
sql/share/slovak/errmsg.txt:
Auto merged
sql/share/spanish/errmsg.txt:
Auto merged
sql/share/swedish/errmsg.txt:
Auto merged
sql/share/ukrainian/errmsg.txt:
Auto merged
Diffstat (limited to 'sql')
44 files changed, 274 insertions, 93 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am index 3f8a228b94b..d1dfbfb390e 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -154,8 +154,8 @@ sql_lex.o: lex_hash.h udf_example.so: udf_example.cc $(CXXCOMPILE) -shared -o $@ $< -#distclean: -# rm -f lex_hash.h +distclean: + rm -f lex_hash.h # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/sql/field.cc b/sql/field.cc index af9ad110f0e..4458c14160d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -46,6 +46,8 @@ template class List_iterator<create_field>; uchar Field_null::null[1]={1}; const char field_separator=','; +#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE 320 + /***************************************************************************** Static help functions *****************************************************************************/ @@ -876,7 +878,7 @@ int Field_decimal::store(double nr) reg4 uint i,length; char fyllchar,*to; - char buff[320]; + char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; fyllchar = zerofill ? (char) '0' : (char) ' '; #ifdef HAVE_SNPRINTF @@ -1751,13 +1753,14 @@ void Field_medium::sql_type(String &res) const int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) { long tmp; - int error= 0; + int error= 0, cuted_fields= 0; char *end; tmp= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES); len-= tmp; from+= tmp; my_errno=0; + if (unsigned_flag) { if (!len || *from == '-') @@ -1774,6 +1777,34 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) if (error || (from+len != end && table->in_use->count_cuted_fields && !test_if_int(from,len,end,cs))) + error= 1; +#if SIZEOF_LONG > 4 + if (unsigned_flag) + { + if (tmp > UINT_MAX32) + { + tmp= UINT_MAX32; + error= 1; + my_errno=ERANGE; + } + } + else + { + if (tmp > INT_MAX32) + { + tmp= INT_MAX32; + error= 1; + my_errno=ERANGE; + } + else if (tmp < INT_MIN32) + { + tmp= INT_MIN32; + error= 1; + my_errno=ERANGE; + } + } +#endif + if (error) { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); error= 1; @@ -2695,7 +2726,7 @@ String *Field_double::val_str(String *val_buffer, #endif doubleget(nr,ptr); - uint to_length=max(field_length,320); + uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE); val_buffer->alloc(to_length); char *to=(char*) val_buffer->ptr(); @@ -2707,7 +2738,8 @@ String *Field_double::val_str(String *val_buffer, else { #ifdef HAVE_FCONVERT - char buff[320],*pos=buff; + char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE], + char *pos= buff; int decpt,sign,tmp_dec=dec; VOID(fconvert(nr,tmp_dec,&decpt,&sign,buff)); @@ -4232,13 +4264,50 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) } -int Field_string::store(double nr) +/* + Store double value in Field_string or Field_varstring. + + SYNOPSIS + store_double_in_string_field() + field field to store value in + field_length number of characters in the field + nr number + + DESCRIPTION + Pretty prints double number into field_length characters buffer. +*/ + +static int store_double_in_string_field(Field_str *field, uint32 field_length, + double nr) { - char buff[MAX_FIELD_WIDTH],*end; - int width=min(field_length,DBL_DIG+5); - sprintf(buff,"%-*.*g",width,max(width-5,0),nr); - end=strcend(buff,' '); - return Field_string::store(buff,(uint) (end - buff), &my_charset_bin); + bool use_scientific_notation=TRUE; + char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; + int length; + if (field_length < 32 && nr > 1) + { + if (field->ceiling == 0) + { + static double e[]= {1e1, 1e2, 1e4, 1e8, 1e16 }; + double p= 1; + for (int i= sizeof(e)/sizeof(e[0]), j= 1<<i ; j; i--, j>>= 1 ) + { + if (field_length & j) + p*= e[i]; + } + field->ceiling= p-1; + } + use_scientific_notation= (field->ceiling < nr); + } + length= sprintf(buff, "%-.*g", + use_scientific_notation ? max(0,field_length-5) : field_length, + nr); + DBUG_ASSERT(length <= field_length); + return field->store(buff, (uint) length); +} + +int Field_string::store(double nr) + { + return store_double_in_string_field(this, field_length, nr); } @@ -4412,11 +4481,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) int Field_varstring::store(double nr) { - char buff[MAX_FIELD_WIDTH],*end; - int width=min(field_length,DBL_DIG+5); - sprintf(buff,"%-*.*g",width,max(width-5,0),nr); - end=strcend(buff,' '); - return Field_varstring::store(buff,(uint) (end - buff), &my_charset_bin); + return store_double_in_string_field(this, field_length, nr); } diff --git a/sql/field.h b/sql/field.h index 7f35b006c03..694d1efa285 100644 --- a/sql/field.h +++ b/sql/field.h @@ -337,12 +337,13 @@ class Field_str :public Field { protected: CHARSET_INFO *field_charset; public: + double ceiling; // for ::store(double nr) Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, struct st_table *table_arg,CHARSET_INFO *charset) :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, table_arg) + unireg_check_arg, field_name_arg, table_arg), ceiling(0.0) { field_charset=charset; if (charset->state & MY_CS_BINSORT) diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index cc828b6e6b2..a7f6cc45831 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -360,7 +360,8 @@ THR_LOCK_DATA **ha_heap::store_lock(THD *thd, int ha_heap::delete_table(const char *name) { - int error=heap_delete_table(name); + char buff[FN_REFLEN]; + int error= heap_delete_table(fn_format(buff,name,"","",4+2)); return error == ENOENT ? 0 : error; } diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index a8309d4f32c..b1e5a16bc32 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -118,6 +118,7 @@ my_bool innobase_use_native_aio = FALSE; my_bool innobase_fast_shutdown = TRUE; my_bool innobase_file_per_table = FALSE; my_bool innobase_locks_unsafe_for_binlog = FALSE; +my_bool innobase_create_status_file = FALSE; static char *internal_innobase_data_file_path = NULL; @@ -135,6 +136,10 @@ char innodb_dummy_stmt_trx_handle = 'D'; static HASH innobase_open_tables; +#ifdef __NETWARE__ /* some special cleanup for NetWare */ +bool nw_panic = FALSE; +#endif + static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length, my_bool not_used __attribute__((unused))); static INNOBASE_SHARE *get_share(const char *table_name); @@ -420,6 +425,30 @@ innobase_mysql_print_thd( } /************************************************************************* +Creates a temporary file. */ +extern "C" +int +innobase_mysql_tmpfile(void) +/*========================*/ + /* out: temporary file descriptor, or < 0 on error */ +{ + char filename[FN_REFLEN]; + File fd = create_temp_file(filename, NullS, "ib", +#ifdef __WIN__ + O_BINARY | O_TRUNC | O_SEQUENTIAL | + O_TEMPORARY | O_SHORT_LIVED | +#endif /* __WIN__ */ + O_CREAT | O_EXCL | O_RDWR, + MYF(MY_WME)); +#ifndef __WIN__ + if (fd >= 0) { + unlink(filename); + } +#endif /* !__WIN__ */ + return(fd); +} + +/************************************************************************* Gets the InnoDB transaction handle for a MySQL handler object, creates an InnoDB transaction struct if the corresponding MySQL thread struct still lacks one. */ @@ -912,6 +941,7 @@ innobase_init(void) srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog; srv_max_n_open_files = (ulint) innobase_open_files; + srv_innodb_status = (ibool) innobase_create_status_file; srv_print_verbose_log = mysql_embedded ? 0 : 1; @@ -982,6 +1012,11 @@ innobase_end(void) DBUG_ENTER("innobase_end"); +#ifdef __NETWARE__ /* some special cleanup for NetWare */ + if (nw_panic) { + set_panic_flag_for_netware(); + } +#endif if (innodb_inited) { innodb_inited= 0; @@ -4403,7 +4438,7 @@ ha_innobase::update_table_comment( trx_search_latch_release_if_reserved(prebuilt->trx); str = NULL; - if (FILE* file = tmpfile()) { + if (FILE* file = os_file_create_tmpfile()) { long flen; /* output the data to a temporary file */ @@ -4465,7 +4500,7 @@ ha_innobase::get_foreign_key_create_info(void) update_thd(current_thd); - if (FILE* file = tmpfile()) { + if (FILE* file = os_file_create_tmpfile()) { long flen; prebuilt->trx->op_info = (char*)"getting info on foreign keys"; diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index 6815bdd632d..6556931fa1a 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -189,7 +189,8 @@ extern char *innobase_unix_file_flush_method; /* The following variables have to be my_bool for SHOW VARIABLES to work */ extern my_bool innobase_log_archive, innobase_use_native_aio, innobase_fast_shutdown, - innobase_file_per_table, innobase_locks_unsafe_for_binlog; + innobase_file_per_table, innobase_locks_unsafe_for_binlog, + innobase_create_status_file; extern "C" { extern ulong srv_max_buf_pool_modified_pct; } diff --git a/sql/item_func.cc b/sql/item_func.cc index e3874d8e4fa..c90a70a6bb6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -969,7 +969,7 @@ void Item_func_round::fix_length_and_dec() if (tmp < 0) decimals=0; else - decimals=tmp; + decimals=min(tmp,NOT_FIXED_DEC); } } @@ -1639,7 +1639,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, func->max_length=min(initid.max_length,MAX_BLOB_WIDTH); func->maybe_null=initid.maybe_null; const_item_cache=initid.const_item; - func->decimals=min(initid.decimals,31); + func->decimals=min(initid.decimals,NOT_FIXED_DEC); } initialized=1; if (error) diff --git a/sql/item_func.h b/sql/item_func.h index c05c1b01259..eaa0a044fd6 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -335,7 +335,7 @@ class Item_dec_func :public Item_real_func Item_dec_func(Item *a,Item *b) :Item_real_func(a,b) {} void fix_length_and_dec() { - decimals=6; max_length=float_length(decimals); + decimals=NOT_FIXED_DEC; max_length=float_length(decimals); maybe_null=1; } inline double fix_result(double value) diff --git a/sql/item_sum.h b/sql/item_sum.h index 507a36194de..fcace9e322a 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -282,7 +282,11 @@ public: class Item_sum_avg :public Item_sum_num { - void fix_length_and_dec() { decimals+=4; maybe_null=1; } + void fix_length_and_dec() + { + decimals=min(decimals+4, NOT_FIXED_DEC); + maybe_null=1; + } double sum; ulonglong count; @@ -337,7 +341,11 @@ class Item_sum_variance : public Item_sum_num { double sum, sum_sqr; ulonglong count; - void fix_length_and_dec() { decimals+=4; maybe_null=1; } + void fix_length_and_dec() + { + decimals=min(decimals+4, NOT_FIXED_DEC); + maybe_null=1; + } public: Item_sum_variance(Item *item_par) :Item_sum_num(item_par),count(0) {} diff --git a/sql/lock.cc b/sql/lock.cc index ac689495ca3..0917c143a8a 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -732,15 +732,14 @@ bool lock_global_read_lock(THD *thd) while (protect_against_global_read_lock && !thd->killed) pthread_cond_wait(&COND_refresh, &LOCK_open); waiting_for_read_lock--; - thd->exit_cond(old_message); if (thd->killed) { - (void) pthread_mutex_unlock(&LOCK_open); + thd->exit_cond(old_message); DBUG_RETURN(1); } thd->global_read_lock=1; global_read_lock++; - (void) pthread_mutex_unlock(&LOCK_open); + thd->exit_cond(old_message); } DBUG_RETURN(0); } @@ -761,11 +760,12 @@ void unlock_global_read_lock(THD *thd) bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh) { const char *old_message; - bool result=0; + bool result= 0, need_exit_cond; DBUG_ENTER("wait_if_global_read_lock"); + LINT_INIT(old_message); (void) pthread_mutex_lock(&LOCK_open); - if (global_read_lock) + if (need_exit_cond= (bool)global_read_lock) { if (thd->global_read_lock) // This thread had the read locks { @@ -780,11 +780,13 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh) (void) pthread_cond_wait(&COND_refresh,&LOCK_open); if (thd->killed) result=1; - thd->exit_cond(old_message); } if (!abort_on_refresh && !result) protect_against_global_read_lock++; - pthread_mutex_unlock(&LOCK_open); + if (unlikely(need_exit_cond)) // global read locks are rare + thd->exit_cond(old_message); + else + pthread_mutex_unlock(&LOCK_open); DBUG_RETURN(result); } diff --git a/sql/log.cc b/sql/log.cc index afba530ce49..ac412f2de9a 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1782,17 +1782,12 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length, NOTES One must have a lock on LOCK_log before calling this function. - This lock will be freed before return! - - The reason for the above is that for enter_cond() / exit_cond() to - work the mutex must be got before enter_cond() but releases before - exit_cond(). - If you don't do it this way, you will get a deadlock in THD::awake() + This lock will be freed before return! That's required by + THD::enter_cond() (see NOTES in sql_class.h). */ void MYSQL_LOG:: wait_for_update(THD* thd, bool master_or_slave) { - safe_mutex_assert_owner(&LOCK_log); const char* old_msg = thd->enter_cond(&update_cond, &LOCK_log, master_or_slave ? "Has read all relay log; waiting for \ @@ -1800,7 +1795,6 @@ the slave I/O thread to update it" : "Has sent all binlog to slave; \ waiting for binlog to be updated"); pthread_cond_wait(&update_cond, &LOCK_log); - pthread_mutex_unlock(&LOCK_log); // See NOTES thd->exit_cond(old_msg); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index be3d9f01a8b..2c85fb004d8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1590,6 +1590,8 @@ static void registerwithneb() ulong neb_event_callback(struct EventBlock *eblock) { EventChangeVolStateEnter_s *voldata; + extern bool nw_panic; + voldata= (EventChangeVolStateEnter_s *)eblock->EBEventData; /* Deactivation of a volume */ @@ -1602,6 +1604,7 @@ ulong neb_event_callback(struct EventBlock *eblock) if (!memcmp(&voldata->volID, &datavolid, sizeof(VolumeID_t))) { consoleprintf("MySQL data volume is deactivated, shutting down MySQL Server \n"); + nw_panic = TRUE; kill_server(0); } } @@ -1879,9 +1882,11 @@ static void init_signals(void) sigaddset(&set,SIGPIPE); #endif sigaddset(&set,SIGINT); +#ifndef IGNORE_SIGHUP_SIGQUIT sigaddset(&set,SIGQUIT); - sigaddset(&set,SIGTERM); sigaddset(&set,SIGHUP); +#endif + sigaddset(&set,SIGTERM); /* Fix signals if blocked by parents (can happen on Mac OS X) */ sigemptyset(&sa.sa_mask); @@ -1965,11 +1970,13 @@ extern "C" void *signal_hand(void *arg __attribute__((unused))) #ifdef USE_ONE_SIGNAL_HAND (void) sigaddset(&set,THR_SERVER_ALARM); // For alarms #endif +#ifndef IGNORE_SIGHUP_SIGQUIT (void) sigaddset(&set,SIGQUIT); - (void) sigaddset(&set,SIGTERM); #if THR_CLIENT_ALARM != SIGHUP (void) sigaddset(&set,SIGHUP); #endif +#endif + (void) sigaddset(&set,SIGTERM); (void) sigaddset(&set,SIGTSTP); /* Save pid to this process (or thread on Linux) */ @@ -2925,6 +2932,9 @@ we force server id to 2, but this MySQL server will not act as a slave."); printf(ER(ER_READY),my_progname,server_version, ((unix_sock == INVALID_SOCKET) ? (char*) "" : mysqld_unix_port), mysqld_port); + if (MYSQL_COMPILATION_COMMENT[0] != '\0') + fputs(" " MYSQL_COMPILATION_COMMENT, stdout); + putchar('\n'); fflush(stdout); #if defined(__NT__) || defined(HAVE_SMEM) @@ -3942,6 +3952,7 @@ enum options_mysqld OPT_INNODB_LOCK_WAIT_TIMEOUT, OPT_INNODB_THREAD_CONCURRENCY, OPT_INNODB_FORCE_RECOVERY, + OPT_INNODB_STATUS_FILE, OPT_INNODB_MAX_DIRTY_PAGES_PCT, OPT_INNODB_OPEN_FILES, OPT_BDB_CACHE_SIZE, @@ -4171,6 +4182,10 @@ Disable with --skip-innodb (will save memory).", {"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT, "Percentage of dirty pages allowed in bufferpool.", (gptr*) &srv_max_buf_pool_modified_pct, (gptr*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0, 0, 0}, + {"innodb_status_file", OPT_INNODB_STATUS_FILE, + "Enable SHOW INNODB STATUS output in the innodb_status.<pid> file", + (gptr*) &innobase_create_status_file, (gptr*) &innobase_create_status_file, + 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif /* End HAVE_INNOBASE_DB */ {"isam", OPT_ISAM, "Enable ISAM (if this version of MySQL supports it). \ Disable with --skip-isam.", diff --git a/sql/protocol.cc b/sql/protocol.cc index 7738349c742..2812a92497f 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -201,7 +201,9 @@ net_printf(THD *thd, uint errcode, ...) #ifndef EMBEDDED_LIBRARY text_pos=(char*) net->buff + head_length + offset + 1; #endif - (void) vsprintf(my_const_cast(char*) (text_pos),format,args); + (void) my_vsnprintf(my_const_cast(char*) (text_pos), + (char*)net->buff_end-text_pos, + format,args); length=(uint) strlen((char*) text_pos); if (length >= sizeof(net->last_error)) length=sizeof(net->last_error)-1; /* purecov: inspected */ diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 4feb24f06b2..d7b70fe122c 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -589,6 +589,8 @@ pthread_handler_decl(handle_failsafe_rpl,arg) THD *thd = new THD; thd->thread_stack = (char*)&thd; MYSQL* recovery_captain = 0; + const char* msg; + pthread_detach_this_thread(); if (init_failsafe_rpl_thread(thd) || !(recovery_captain=mysql_init(0))) { @@ -596,11 +598,11 @@ pthread_handler_decl(handle_failsafe_rpl,arg) goto err; } pthread_mutex_lock(&LOCK_rpl_status); + msg= thd->enter_cond(&COND_rpl_status, + &LOCK_rpl_status, "Waiting for request"); while (!thd->killed && !abort_loop) { bool break_req_chain = 0; - const char* msg = thd->enter_cond(&COND_rpl_status, - &LOCK_rpl_status, "Waiting for request"); pthread_cond_wait(&COND_rpl_status, &LOCK_rpl_status); thd->proc_info="Processing request"; while (!break_req_chain) @@ -618,9 +620,8 @@ pthread_handler_decl(handle_failsafe_rpl,arg) break; } } - thd->exit_cond(msg); } - pthread_mutex_unlock(&LOCK_rpl_status); + thd->exit_cond(msg); err: if (recovery_captain) mysql_close(recovery_captain); diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index b62911b8090..772e3e387d6 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -88,7 +88,7 @@ character-set=latin2 "Blob sloupec '%-.64s' nem-Bù¾e být pou¾it jako klíè", "P-Bøíli¹ velká délka sloupce '%-.64s' (nejvíce %d). Pou¾ijte BLOB", "M-Bù¾ete mít pouze jedno AUTO pole a to musí být definováno jako klíè", -"%s: p-Bøipraven na spojení\n", +"%s: p-Bøipraven na spojení", "%s: norm-Bální ukonèení\n", "%s: p-Bøijat signal %d, konèím\n", "%s: ukon-Bèení práce hotovo\n", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 07c6c422465..91fdb82fe59 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -82,7 +82,7 @@ character-set=latin1 "BLOB feltet '%-.64s' kan ikke bruges ved specifikation af indeks", "For stor feltlængde for kolonne '%-.64s' (maks = %d). Brug BLOB i stedet", "Der kan kun specificeres eet AUTO_INCREMENT-felt, og det skal være indekseret", -"%s: klar til tilslutninger\n", +"%s: klar til tilslutninger", "%s: Normal nedlukning\n", "%s: Fangede signal %d. Afslutter!!\n", "%s: Server lukket\n", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 1b133ba6cf5..41678ae67aa 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -90,7 +90,7 @@ character-set=latin1 "BLOB kolom '%-.64s' kan niet gebruikt worden bij zoeksleutel specificatie", "Te grote kolomlengte voor '%-.64s' (max = %d). Maak hiervoor gebruik van het type BLOB", "Er kan slechts 1 autofield zijn en deze moet als zoeksleutel worden gedefinieerd.", -"%s: klaar voor verbindingen\n", +"%s: klaar voor verbindingen", "%s: Normaal afgesloten \n", "%s: Signaal %d. Systeem breekt af!\n", "%s: Afsluiten afgerond\n", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 40024bada59..c34bf1c0403 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -79,7 +79,7 @@ character-set=latin1 "BLOB column '%-.64s' can't be used in key specification with the used table type", "Column length too big for column '%-.64s' (max = %d); use BLOB instead", "Incorrect table definition; there can be only one auto column and it must be defined as a key", -"%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d\n", +"%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d", "%s: Normal shutdown\n", "%s: Got signal %d. Aborting!\n", "%s: Shutdown complete\n", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 9c983d261bd..d3bb306f00a 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -84,7 +84,7 @@ character-set=latin7 "BLOB-tüüpi tulpa '%-.64s' ei saa kasutada võtmena", "Tulba '%-.64s' pikkus on liiga pikk (maksimaalne pikkus: %d). Kasuta BLOB väljatüüpi", "Vigane tabelikirjeldus; Tabelis tohib olla üks auto_increment tüüpi tulp ning see peab olema defineeritud võtmena", -"%s: ootab ühendusi\n", +"%s: ootab ühendusi", "%s: MySQL lõpetas\n", "%s: sain signaali %d. Lõpetan!\n", "%s: Lõpp\n", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 3d770eaff71..49a1065a5ca 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -79,7 +79,7 @@ character-set=latin1 "Champ BLOB '%-.64s' ne peut être utilisé dans une clé", "Champ '%-.64s' trop long (max = %d). Utilisez un BLOB", "Un seul champ automatique est permis et il doit être indexé", -"%s: Prêt pour des connections\n", +"%s: Prêt pour des connections", "%s: Arrêt normal du serveur\n", "%s: Reçu le signal %d. Abandonne!\n", "%s: Arrêt du serveur terminé\n", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 63afe6f6e5d..56e6454ab29 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -91,7 +91,7 @@ character-set=latin1 "BLOB-Feld '%-.64s' kann beim verwendeten Tabellentyp nicht als Schlüssel verwendet werden", "Feldlänge für Feld '%-.64s' zu groß (maximal %d). BLOB-Feld verwenden!", "Falsche Tabellendefinition. Es darf nur ein Auto-Feld geben und dieses muss als Schlüssel definiert werden", -"%-.64s: Bereit für Verbindungen\n", +"%-.64s: Bereit für Verbindungen", "%-.64s: Normal heruntergefahren\n", "%-.64s: Signal %d erhalten. Abbruch!\n", "%-.64s: Heruntergefahren (shutdown)\n", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 58587a4ff38..dd83db9907c 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -79,7 +79,7 @@ character-set=greek "Ðåäßï ôýðïõ Blob '%-.64s' äåí ìðïñåß íá ÷ñçóéìïðïéçèåß óôïí ïñéóìü åíüò êëåéäéïý (key specification)", "Ðïëý ìåãÜëï ìÞêïò ãéá ôï ðåäßï '%-.64s' (max = %d). Ðáñáêáëþ ÷ñçóéìïðïéåßóôå ôïí ôýðï BLOB", "Ìðïñåß íá õðÜñ÷åé ìüíï Ýíá auto field êáé ðñÝðåé íá Ý÷åé ïñéóèåß óáí key", -"%s: óå áíáìïíÞ óõíäÝóåùí\n", +"%s: óå áíáìïíÞ óõíäÝóåùí", "%s: ÖõóéïëïãéêÞ äéáäéêáóßá shutdown\n", "%s: ÅëÞöèç ôï ìÞíõìá %d. Ç äéáäéêáóßá åãêáôáëåßðåôáé!\n", "%s: Ç äéáäéêáóßá Shutdown ïëïêëçñþèçêå\n", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 3d5284dfa1a..23c6cffbcb8 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -81,7 +81,7 @@ character-set=latin2 "Blob objektum '%-.64s' nem hasznalhato kulcskent", "A(z) '%-.64s' oszlop tul hosszu. (maximum = %d). Hasznaljon BLOB tipust inkabb.", "Csak egy auto mezo lehetseges, es azt kulcskent kell definialni.", -"%s: kapcsolatra kesz\n", +"%s: kapcsolatra kesz", "%s: Normal leallitas\n", "%s: %d jelzes. Megszakitva!\n", "%s: A leallitas kesz\n", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 012f6693e6f..fbdd63f1ede 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -81,7 +81,7 @@ character-set=ujis "BLOB column '%-.64s' can't be used in key specification with the used table type", "column '%-.64s' ¤Ï,³ÎÊݤ¹¤ë column ¤ÎÂ礤µ¤¬Â¿¤¹¤®¤Þ¤¹. (ºÇÂç %d ¤Þ¤Ç). BLOB ¤ò¤«¤ï¤ê¤Ë»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤.", "¥Æ¡¼¥Ö¥ë¤ÎÄêµÁ¤¬°ã¤¤¤Þ¤¹; there can be only one auto column and it must be defined as a key", -"%s: ½àÈ÷´°Î»\n", +"%s: ½àÈ÷´°Î»", "%s: Normal shutdown\n", "%s: Got signal %d. ÃæÃÇ!\n", "%s: Shutdown ´°Î»\n", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 65146fb6578..6e98cd61541 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -79,7 +79,7 @@ character-set=euckr "BLOB Ä®·³ '%-.64s'´Â Å° Á¤ÀÇ¿¡¼ »ç¿ëµÉ ¼ö ¾ø½À´Ï´Ù.", "Ä®·³ '%-.64s'ÀÇ Ä®·³ ±æÀÌ°¡ ³Ê¹« ±é´Ï´Ù (ÃÖ´ë = %d). ´ë½Å¿¡ BLOB¸¦ »ç¿ëÇϼ¼¿ä.", "ºÎÁ¤È®ÇÑ Å×À̺í Á¤ÀÇ; Å×À̺íÀº ÇϳªÀÇ auto Ä®·³ÀÌ Á¸ÀçÇÏ°í Å°·Î Á¤ÀǵǾîÁ®¾ß ÇÕ´Ï´Ù.", -"%s: ¿¬°á ÁغñÁßÀÔ´Ï´Ù.\n", +"%s: ¿¬°á ÁغñÁßÀÔ´Ï´Ù", "%s: Á¤»óÀûÀÎ shutdown\n", "%s: %d ½ÅÈ£°¡ µé¾î¿ÔÀ½. ÁßÁö!\n", "%s: Shutdown ÀÌ ¿Ï·áµÊ!\n", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 3825b0c84a7..517c041a355 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -81,7 +81,7 @@ character-set=latin1 "Blob kolonne '%-.64s' kan ikkje brukast ved spesifikasjon av nyklar", "For stor nykkellengde for felt '%-.64s' (maks = %d). Bruk BLOB istadenfor", "Bare eitt auto felt kan være definert som nøkkel.", -"%s: klar for tilkoblingar\n", +"%s: klar for tilkoblingar", "%s: Normal nedkopling\n", "%s: Oppdaga signal %d. Avsluttar!\n", "%s: Nedkopling komplett\n", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index dd0f0a4c6cb..b5cf4a7df19 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -81,7 +81,7 @@ character-set=latin1 "Blob felt '%-.64s' kan ikke brukes ved spesifikasjon av nøkler", "For stor nøkkellengde for kolonne '%-.64s' (maks = %d). Bruk BLOB istedenfor", "Bare ett auto felt kan være definert som nøkkel.", -"%s: klar for tilkoblinger\n", +"%s: klar for tilkoblinger", "%s: Normal avslutning\n", "%s: Oppdaget signal %d. Avslutter!\n", "%s: Avslutning komplett\n", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 9d61a0efed5..be152eed9b2 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -83,7 +83,7 @@ character-set=latin2 "Kolumna typu Blob '%-.64s' nie mo¿e byæ u¿yta w specyfikacji klucza", "Zbyt du¿a d³ugo?æ kolumny '%-.64s' (maks. = %d). W zamian u¿yj typu BLOB", "W tabeli mo¿e byæ tylko jedno pole auto i musi ono byæ zdefiniowane jako klucz", -"%s: gotowe do po³?czenia\n", +"%s: gotowe do po³?czenia", "%s: Standardowe zakoñczenie dzia³ania\n", "%s: Otrzymano sygna³ %d. Koñczenie dzia³ania!\n", "%s: Zakoñczenie dzia³ania wykonane\n", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 68784bc7be8..729883c7a79 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -80,7 +80,7 @@ character-set=latin1 "Coluna BLOB '%-.64s' não pode ser utilizada na especificação de chave para o tipo de tabela usado", "Comprimento da coluna '%-.64s' grande demais (max = %d); use BLOB em seu lugar", "Definição incorreta de tabela. Somente é permitido um único campo auto-incrementado e ele tem que ser definido como chave", -"%s: Pronto para conexões\n", +"%s: Pronto para conexões", "%s: 'Shutdown' normal\n", "%s: Obteve sinal %d. Abortando!\n", "%s: 'Shutdown' completo\n", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 8272ada205b..c1f3abc9c3d 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -83,7 +83,7 @@ character-set=latin2 "Coloana de tip BLOB '%-.64s' nu poate fi folosita in specificarea cheii cu tipul de tabla folosit", "Lungimea coloanei '%-.64s' este prea lunga (maximum = %d). Foloseste BLOB mai bine", "Definitia tabelei este incorecta; Nu pot fi mai mult de o singura coloana de tip auto si aceasta trebuie definita ca cheie", -"%s: sint gata pentru conectii\n", +"%s: sint gata pentru conectii", "%s: Terminare normala\n", "%s: Semnal %d obtinut. Aborting!\n", "%s: Terminare completa\n", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 3f567f88c46..ecc8fc6e408 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -81,7 +81,7 @@ character-set=koi8r "óÔÏÌÂÅà ÔÉÐÁ BLOB '%-.64s' ÎÅ ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎ ËÁË ÚÎÁÞÅÎÉÅ ËÌÀÞÁ × ÔÁÂÌÉÃÅ ÔÁËÏÇÏ ÔÉÐÁ", "óÌÉÛËÏÍ ÂÏÌØÛÁÑ ÄÌÉÎÁ ÓÔÏÌÂÃÁ '%-.64s' (ÍÁËÓÉÍÕÍ = %d). éÓÐÏÌØÚÕÊÔÅ ÔÉÐ BLOB ×ÍÅÓÔÏ ÔÅËÕÝÅÇÏ", "îÅËÏÒÒÅËÔÎÏÅ ÏÐÒÅÄÅÌÅÎÉÅ ÔÁÂÌÉÃÙ: ÍÏÖÅÔ ÓÕÝÅÓÔ×Ï×ÁÔØ ÔÏÌØËÏ ÏÄÉÎ Á×ÔÏÉÎËÒÅÍÅÎÔÎÙÊ ÓÔÏÌÂÅÃ, É ÏÎ ÄÏÌÖÅÎ ÂÙÔØ ÏÐÒÅÄÅÌÅÎ ËÁË ËÌÀÞ", -"%s: çÏÔÏ× ÐÒÉÎÉÍÁÔØ ÓÏÅÄÉÎÅÎÉÑ.\n÷ÅÒÓÉÑ: '%s' ÓÏËÅÔ: '%s' ÐÏÒÔ: %d\n", +"%s: çÏÔÏ× ÐÒÉÎÉÍÁÔØ ÓÏÅÄÉÎÅÎÉÑ.\n÷ÅÒÓÉÑ: '%s' ÓÏËÅÔ: '%s' ÐÏÒÔ: %d", "%s: ëÏÒÒÅËÔÎÁÑ ÏÓÔÁÎÏ×ËÁ\n", "%s: ðÏÌÕÞÅÎ ÓÉÇÎÁÌ %d. ðÒÅËÒÁÝÁÅÍ!\n", "%s: ïÓÔÁÎÏ×ËÁ ÚÁ×ÅÒÛÅÎÁ\n", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index fbcaeab526f..b616db6235c 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -87,7 +87,7 @@ character-set=latin2 "Blob pole '%-.64s' nemô¾e by» pou¾ité ako kµúè", "Príli¹ veµká då¾ka pre pole '%-.64s' (maximum = %d). Pou¾ite BLOB", "Mô¾ete ma» iba jedno AUTO pole a to musí by» definované ako kµúè", -"%s: pripravený na spojenie\n", +"%s: pripravený na spojenie", "%s: normálne ukonèenie\n", "%s: prijatý signál %d, ukonèenie (Abort)!\n", "%s: práca ukonèená\n", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index ebdfeba1be2..0231e83fbec 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -81,7 +81,7 @@ character-set=latin1 "La columna Blob '%-.64s' no puede ser usada en una declaracion de clave", "Longitud de columna demasiado grande para la columna '%-.64s' (maximo = %d).Usar BLOB en su lugar", "Puede ser solamente un campo automatico y este debe ser definido como una clave", -"%s: preparado para conexiones\n", +"%s: preparado para conexiones", "%s: Apagado normal\n", "%s: Recibiendo signal %d. Abortando!\n", "%s: Apagado completado\n", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 53abfb238c3..a227de3b991 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -79,7 +79,7 @@ character-set=latin1 "En BLOB '%-.64s' kan inte vara nyckel med den använda tabelltypen", "För stor kolumnlängd angiven för '%-.64s' (max= %d). Använd en BLOB instället", "Det får finnas endast ett AUTO_INCREMENT-fält och detta måste vara en nyckel", -"%s: klar att ta emot klienter\n", +"%s: klar att ta emot klienter", "%s: Normal avslutning\n", "%s: Fick signal %d. Avslutar!\n", "%s: Avslutning klar\n", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 2267b497673..f68e709471c 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -84,7 +84,7 @@ character-set=koi8u "BLOB ÓÔÏ×ÂÅÃØ '%-.64s' ÎÅ ÍÏÖÅ ÂÕÔÉ ×ÉËÏÒÉÓÔÁÎÉÊ Õ ×ÉÚÎÁÞÅÎΦ ËÌÀÞÁ × ÃØÏÍÕ ÔÉЦ ÔÁÂÌÉæ", "úÁÄÏ×ÇÁ ÄÏ×ÖÉÎÁ ÓÔÏ×ÂÃÑ '%-.64s' (max = %d). ÷ÉËÏÒÉÓÔÁÊÔÅ ÔÉÐ BLOB", "îÅצÒÎÅ ×ÉÚÎÁÞÅÎÎÑ ÔÁÂÌÉæ; íÏÖÅ ÂÕÔÉ ÌÉÛÅ ÏÄÉÎ Á×ÔÏÍÁÔÉÞÎÉÊ ÓÔÏ×ÂÅÃØ, ÝÏ ÐÏ×ÉÎÅÎ ÂÕÔÉ ×ÉÚÎÁÞÅÎÉÊ ÑË ËÌÀÞ", -"%s: çÏÔÏ×ÉÊ ÄÌÑ Ú'¤ÄÎÁÎØ!\n", +"%s: çÏÔÏ×ÉÊ ÄÌÑ Ú'¤ÄÎÁÎØ!", "%s: îÏÒÍÁÌØÎÅ ÚÁ×ÅÒÛÅÎÎÑ\n", "%s: ïÔÒÉÍÁÎÏ ÓÉÇÎÁÌ %d. ðÅÒÅÒÉ×ÁÀÓØ!\n", "%s: òÏÂÏÔÕ ÚÁ×ÅÒÛÅÎÏ\n", diff --git a/sql/slave.cc b/sql/slave.cc index 0fe525d766f..7fb7fbdade4 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -623,7 +623,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, pthread_mutex_unlock(start_lock); DBUG_RETURN(ER_SLAVE_THREAD); } - if (start_cond && cond_lock) + if (start_cond && cond_lock) // caller has cond_lock { THD* thd = current_thd; while (start_id == *slave_run_id) @@ -633,11 +633,9 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, "Waiting for slave thread to start"); pthread_cond_wait(start_cond,cond_lock); thd->exit_cond(old_msg); + pthread_mutex_lock(cond_lock); // re-acquire it as exit_cond() released if (thd->killed) - { - pthread_mutex_unlock(cond_lock); DBUG_RETURN(ER_SERVER_SHUTDOWN); - } } } if (start_lock) @@ -1705,7 +1703,6 @@ Waiting for the slave SQL thread to free enough relay log space"); !rli->ignore_log_space_limit) pthread_cond_wait(&rli->log_space_cond, &rli->log_space_lock); thd->exit_cond(save_proc_info); - pthread_mutex_unlock(&rli->log_space_lock); DBUG_RETURN(slave_killed); } @@ -2381,6 +2378,9 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, (long) timeout)); pthread_mutex_lock(&data_lock); + const char *msg= thd->enter_cond(&data_cond, &data_lock, + "Waiting for the slave SQL thread to " + "advance position"); /* This function will abort when it notices that some CHANGE MASTER or RESET MASTER has changed the master info. @@ -2482,9 +2482,6 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, //wait for master update, with optional timeout. DBUG_PRINT("info",("Waiting for master update")); - const char* msg = thd->enter_cond(&data_cond, &data_lock, - "Waiting for the slave SQL thread to \ -advance position"); /* We are going to pthread_cond_(timed)wait(); if the SQL thread stops it will wake us up. @@ -2506,8 +2503,7 @@ advance position"); } else pthread_cond_wait(&data_cond, &data_lock); - DBUG_PRINT("info",("Got signal of master update")); - thd->exit_cond(msg); + DBUG_PRINT("info",("Got signal of master update or timed out")); if (error == ETIMEDOUT || error == ETIME) { error= -1; @@ -2519,7 +2515,7 @@ advance position"); } err: - pthread_mutex_unlock(&data_lock); + thd->exit_cond(msg); DBUG_PRINT("exit",("killed: %d abort: %d slave_running: %d \ improper_arguments: %d timed_out: %d", (int) thd->killed, diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 44fd5e9e94f..f60897bf62b 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -542,22 +542,30 @@ static ulong get_sort(uint count,...) va_start(args,count); ulong sort=0; + /* Should not use this function with more than 4 arguments for compare. */ + DBUG_ASSERT(count <= 4); + while (count--) { - char *str=va_arg(args,char*); - uint chars=0,wild=0; + char *start, *str= va_arg(args,char*); + uint chars= 0; + uint wild_pos= 0; /* first wildcard position */ - if (str) + if (start= str) { for (; *str ; str++) { if (*str == wild_many || *str == wild_one || *str == wild_prefix) - wild++; + { + wild_pos= str - start + 1; + break; + } else chars++; } } - sort= (sort << 8) + (wild ? 1 : chars ? 2 : 0); + sort= (sort << 8) + (wild_pos ? (wild_pos > 127 ? 127 : wild_pos) : + (chars ? 128 : 0)); } va_end(args); return sort; diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 68f7d45e81c..3f75dadb6f0 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -34,9 +34,6 @@ #define MAX_TREEMEM 8192 #define MAX_TREE_ELEMENTS 256 -#define UINT_MAX16 0xffff -#define UINT_MAX24 0xffffff -#define UINT_MAX32 0xffffffff int sortcmp2(void* cmp_arg __attribute__((unused)), const String *a,const String *b) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index ad4eb9f6801..73a180078cf 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -434,8 +434,18 @@ void THD::awake(bool prepare_to_die) exits the cond in the time between read and broadcast, but that is ok since all we want to do is to make the victim thread get out of waiting on current_cond. + If we see a non-zero current_cond: it cannot be an old value (because + then exit_cond() should have run and it can't because we have mutex); so + it is the true value but maybe current_mutex is not yet non-zero (we're + in the middle of enter_cond() and there is a "memory order + inversion"). So we test the mutex too to not lock 0. + Note that there is a small chance we fail to kill. If victim has locked + current_mutex, and hasn't entered enter_cond(), then we don't know it's + going to wait on cond. Then victim goes into its cond "forever" (until + we issue a second KILL). True we have set its thd->killed but it may not + see it immediately and so may have time to reach the cond_wait(). */ - if (mysys_var->current_cond) + if (mysys_var->current_cond && mysys_var->current_mutex) { pthread_mutex_lock(mysys_var->current_mutex); pthread_cond_broadcast(mysys_var->current_cond); diff --git a/sql/sql_class.h b/sql/sql_class.h index 64fed055c80..59ac8ff0483 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -885,6 +885,12 @@ public: void close_active_vio(); #endif void awake(bool prepare_to_die); + /* + For enter_cond() / exit_cond() to work the mutex must be got before + enter_cond() (in 4.1 an assertion will soon ensure this); this mutex is + then released by exit_cond(). Use must be: + lock mutex; enter_cond(); your code; exit_cond(). + */ inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex, const char* msg) { @@ -896,6 +902,13 @@ public: } inline void exit_cond(const char* old_msg) { + /* + Putting the mutex unlock in exit_cond() ensures that + mysys_var->current_mutex is always unlocked _before_ mysys_var->mutex is + locked (if that would not be the case, you'll get a deadlock if someone + does a THD::awake() on you). + */ + pthread_mutex_unlock(mysys_var->current_mutex); pthread_mutex_lock(&mysys_var->mutex); mysys_var->current_mutex = 0; mysys_var->current_cond = 0; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 77ac730b6dc..57e4022719e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4319,8 +4319,12 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, case FIELD_TYPE_TIMESTAMP: if (!length) new_field->length= 14; // Full date YYYYMMDDHHMMSS - else + else if (new_field->length != 19) { + /* + We support only even TIMESTAMP lengths less or equal than 14 + and 19 as length of 4.1 compatible representation. + */ new_field->length=((new_field->length+1)/2)*2; /* purecov: inspected */ new_field->length= min(new_field->length,14); /* purecov: inspected */ } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f8bc6210a2f..c56645e06b9 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5527,6 +5527,20 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, new_table.no_rows=1; } +#ifdef TO_BE_DONE_LATER_IN_4_1 + /* + To use start_bulk_insert() (which is new in 4.1) we need to find + all places where a corresponding end_bulk_insert() should be put. + */ + table->file->info(HA_STATUS_VARIABLE); /* update table->file->records */ + new_table.file->start_bulk_insert(table->file->records); +#else + /* + HA_EXTRA_WRITE_CACHE can stay until close, no need to disable it explicitly. + */ + new_table.file->extra(HA_EXTRA_WRITE_CACHE); +#endif + /* copy all old rows */ while (!table->file->rnd_next(new_table.record[1])) { @@ -8447,7 +8461,16 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, { if (!(pos= new Item_copy_string(pos))) goto err; - if (param->copy_funcs.push_back(pos)) + /* + Item_copy_string::copy for function can call + Item_copy_string::val_int for blob via Item_ref. + But if Item_copy_string::copy for blob isn't called before, + it's value will be wrong + so let's insert Item_copy_string for blobs in the beginning of + copy_funcs + (to see full test case look at having.test, BUG #4358) + */ + if (param->copy_funcs.push_front(pos)) goto err; } else diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 37e959d38a1..c82bff05412 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1816,7 +1816,6 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, dropping_tables--; } thd->exit_cond(old_message); - pthread_mutex_unlock(&LOCK_open); if (thd->killed) goto err; open_for_modify=0; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 8e3fb0884a9..be3ac10c398 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1933,6 +1933,12 @@ alter_list_item: LEX *lex=Lex; lex->select_lex.db=$3->db.str; lex->name= $3->table.str; + if (check_table_name($3->table.str,$3->table.length) || + $3->db.str && check_db_name($3->db.str)) + { + net_printf(&lex->thd->net,ER_WRONG_TABLE_NAME,$3->table.str); + YYABORT; + } lex->alter_info.flags|= ALTER_RENAME; } | CONVERT_SYM TO_SYM charset charset_name_or_default opt_collate |