From b088e1bf1f47d2c2e928ca174de62bbc230f6114 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Wed, 29 May 2002 14:04:19 +0300 Subject: [PATCH 1/5] ha_innobase.cc: Fix an assertion failure in ha_innobase.cc about line 302 when a user has used user level locks and closes a connection; this was reported by Jeremy Zawodny --- sql/ha_innobase.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index a741ffefbb5..5ce7869e3f8 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -649,6 +649,7 @@ innobase_close_connection( (thd->transaction.all.innobase_tid)); trx_free_for_mysql((trx_t*) (thd->transaction.all.innobase_tid)); + thd->transaction.all.innobase_tid = NULL; } return(0); From 429aa7459f9890531ad8679ad184d1fc4d1d5dca Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Thu, 30 May 2002 15:49:32 +0300 Subject: [PATCH 2/5] A small fix for HP-UX when used --with-debug --- include/my_pthread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/my_pthread.h b/include/my_pthread.h index 24e73707288..bcad292ecc9 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -349,7 +349,7 @@ extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority); #undef HAVE_GETHOSTBYADDR_R /* No definition */ #endif -#if defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT) +#if defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT) && !defined(SAFE_MUTEX) extern int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, struct timespec *abstime); From a2ec51cec16205154aa2c7f5ecf6ec3c98a978e8 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Fri, 31 May 2002 13:35:20 +0300 Subject: [PATCH 3/5] Fixed a problem with --skip-networking. This fix should be merged into 4.0 and 4.1 --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9ac6ea6fff8..08d0f381534 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1121,7 +1121,7 @@ void end_thread(THD *thd, bool put_in_cache) inline void kill_broken_server() { /* hack to get around signals ignored in syscalls for problem OS's */ - if (unix_sock == INVALID_SOCKET || ip_sock ==INVALID_SOCKET) + if (unix_sock == INVALID_SOCKET || (!opt_disable_networking && ip_sock ==INVALID_SOCKET)) { select_thread_in_use = 0; kill_server((void*)MYSQL_KILL_SIGNAL); /* never returns */ From e2a116411e7b293b5d0d920c8a94794dd75dd334 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Fri, 31 May 2002 15:22:38 +0300 Subject: [PATCH 4/5] Portability fixes for SCO and HPUX Change TRUNCATE(number) to truncate towards zero for negative numbers Fix NULL handling for DESCRIBE table_name --- Docs/manual.texi | 16 ++++++++++++++++ configure.in | 8 ++++---- extra/resolveip.c | 2 +- include/my_net.h | 2 +- libmysql/libmysql.c | 5 +++++ mysql-test/r/func_math.result | 4 ++-- mysql-test/t/func_math.test | 2 +- mysys/my_gethostbyname.c | 2 +- sql/item_func.cc | 7 ++++++- sql/sql_show.cc | 4 +++- 10 files changed, 40 insertions(+), 12 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 431b6911393..d8b63c71726 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -31150,6 +31150,17 @@ mysql> select TRUNCATE(1.999,1); -> 1.9 mysql> select TRUNCATE(1.999,0); -> 1 +mysql> select TRUNCATE(-1,999,1); + -> -1.9 +@end example + +Starting from MySQL 3.23.51 all numbers are rounded towards zero. + +If @code{D} is negative, then the whole part of the number is zeroed out: + +@example +mysql> select truncate(122,-2); + -> 100 @end example Note that as decimal numbers are normally not stored as exact numbers in @@ -46916,6 +46927,11 @@ not yet 100% confident in this code. @appendixsubsec Changes in release 3.23.51 @itemize @bullet @item +Cleaned up @code{NULL} handling for default values in @code{DESCRIBE +table_name}. +@item +Fixed @code{truncate()} to round up negative values to the nearest integer. +@item Remove end space from @code{enum} values. (This fixed a problem with @code{SHOW CREATE TABLE}). @item diff --git a/configure.in b/configure.in index 183de44fdf2..00c986c4006 100644 --- a/configure.in +++ b/configure.in @@ -1552,7 +1552,7 @@ then fi AC_TRY_COMPILE( [#undef inline -#if !defined(SCO) && !defined(__osf__) +#if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT) #define _REENTRANT #endif #include @@ -1585,7 +1585,7 @@ then fi AC_TRY_COMPILE( [#undef inline -#if !defined(SCO) && !defined(__osf__) +#if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT) #define _REENTRANT #endif #include @@ -1617,7 +1617,7 @@ then fi AC_TRY_COMPILE( [#undef inline -#if !defined(SCO) && !defined(__osf__) +#if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT) #define _REENTRANT #endif #include @@ -1643,7 +1643,7 @@ then # Check definition of pthread_getspecific AC_CACHE_CHECK("args to pthread_getspecific", mysql_cv_getspecific_args, AC_TRY_COMPILE( -[#if !defined(SCO) && !defined(__osf__) +[#if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT) #define _REENTRANT #endif #define _POSIX_PTHREAD_SEMANTICS diff --git a/extra/resolveip.c b/extra/resolveip.c index 9bab5846c03..ba2db0a4d65 100644 --- a/extra/resolveip.c +++ b/extra/resolveip.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -30,6 +29,7 @@ #endif #include #include +#include #include #if !defined(_AIX) && !defined(HAVE_UNIXWARE7_THREADS) && !defined(HAVE_UNIXWARE7_POSIX) && !defined(h_errno) diff --git a/include/my_net.h b/include/my_net.h index 6a6e2aecc27..a4910d8af1d 100644 --- a/include/my_net.h +++ b/include/my_net.h @@ -53,7 +53,7 @@ struct hostent *my_gethostbyname_r(const char *name, struct hostent *result, char *buffer, int buflen, int *h_errnop); #define my_gethostbyname_r_free() -#if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) +#if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX) #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data) #endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */ diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 4190a4c37f4..bab6d304094 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -180,8 +180,13 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, { tv.tv_sec = (long) timeout; tv.tv_usec = 0; +#if defined(HPUX) && defined(THREAD) + if ((res = select(s+1, NULL, (int*) &sfds, NULL, &tv)) >= 0) + break; +#else if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0) break; +#endif now_time=time(NULL); timeout-= (uint) (now_time - start_time); if (errno != EINTR || (int) timeout <= 0) diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index cee67a3e25c..e2723311682 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -2,8 +2,8 @@ floor(5.5) floor(-5.5) 5 -6 ceiling(5.5) ceiling(-5.5) 6 -5 -truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) -52.6 52.64 50 0 +truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1) +52.6 52.64 50 0 -52.6 -50 round(5.5) round(-5.5) 6 -6 round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2) diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index ab7990eea79..5299897d0f0 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -4,7 +4,7 @@ select floor(5.5),floor(-5.5); select ceiling(5.5),ceiling(-5.5); -select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2); +select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1); select round(5.5),round(-5.5); select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2); select abs(-10), sign(-5), sign(5), sign(0); diff --git a/mysys/my_gethostbyname.c b/mysys/my_gethostbyname.c index 19381734e83..f30591d9fe3 100644 --- a/mysys/my_gethostbyname.c +++ b/mysys/my_gethostbyname.c @@ -20,10 +20,10 @@ #include "mysys_priv.h" #include "my_pthread.h" #include -#include #if !defined(MSDOS) && !defined(__WIN__) #include #endif +#include /* This file is not needed if my_gethostbyname_r is a macro */ #if !defined(my_gethostbyname_r) diff --git a/sql/item_func.cc b/sql/item_func.cc index 9180cccabcf..b73436afbcf 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -601,7 +601,12 @@ double Item_func_round::val() log_10[abs_dec] : pow(10.0,(double) abs_dec)); if (truncate) - return dec < 0 ? floor(value/tmp)*tmp : floor(value*tmp)/tmp; + { + if (value >= 0) + return dec < 0 ? floor(value/tmp)*tmp : floor(value*tmp)/tmp; + else + return dec < 0 ? ceil(value/tmp)*tmp : ceil(value*tmp)/tmp; + } return dec < 0 ? rint(value/tmp)*tmp : rint(value*tmp)/tmp; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8cfac1675b0..5db2df85fbf 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -431,6 +431,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, TABLE *table; handler *file; char tmp[MAX_FIELD_WIDTH]; + Item *item; DBUG_ENTER("mysqld_show_fields"); DBUG_PRINT("enter",("db: %s table: %s",table_list->db, table_list->real_name)); @@ -449,7 +450,8 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, field_list.push_back(new Item_empty_string("Type",40)); field_list.push_back(new Item_empty_string("Null",1)); field_list.push_back(new Item_empty_string("Key",3)); - field_list.push_back(new Item_empty_string("Default",NAME_LEN)); + field_list.push_back(item=new Item_empty_string("Default",NAME_LEN)); + item->maybe_null=1; field_list.push_back(new Item_empty_string("Extra",20)); if (verbose) field_list.push_back(new Item_empty_string("Privileges",80)); From fc52e079d07b7fdf9d5768303b58b63275c1475d Mon Sep 17 00:00:00 2001 From: "nick@nick.leippe.com" <> Date: Fri, 31 May 2002 16:56:02 -0700 Subject: [PATCH 5/5] fixed 'load table from master' hang when host is empty added respective test case --- mysql-test/r/rpl_empty_master_crash.result | 2 ++ mysql-test/t/rpl_empty_master_crash.test | 8 ++++++++ sql/slave.cc | 6 ++++++ 3 files changed, 16 insertions(+) create mode 100644 mysql-test/r/rpl_empty_master_crash.result create mode 100644 mysql-test/t/rpl_empty_master_crash.test diff --git a/mysql-test/r/rpl_empty_master_crash.result b/mysql-test/r/rpl_empty_master_crash.result new file mode 100644 index 00000000000..e9111fdb401 --- /dev/null +++ b/mysql-test/r/rpl_empty_master_crash.result @@ -0,0 +1,2 @@ +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter + 0 0 0 No 0 0 diff --git a/mysql-test/t/rpl_empty_master_crash.test b/mysql-test/t/rpl_empty_master_crash.test new file mode 100644 index 00000000000..7c4437a3657 --- /dev/null +++ b/mysql-test/t/rpl_empty_master_crash.test @@ -0,0 +1,8 @@ +source include/master-slave.inc; +connection master; +use test; +drop table if exists t1; +show slave status; +#--error 1218 # for mysql-4.0 +--error 1042 +load table t1 from master; diff --git a/sql/slave.cc b/sql/slave.cc index 946cf483e4b..c7a048e8452 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -451,6 +451,12 @@ int fetch_nx_table(THD* thd, MASTER_INFO* mi) goto err; } + if (!mi->host || !*mi->host) + { + nx_errno = ER_BAD_HOST_ERROR; + goto err; + } + safe_connect(thd, mysql, mi); if (slave_killed(thd)) goto err;