From 2603dd13363e2d28f302dfd6cad05238b2d979f8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Aug 2002 20:09:57 +0200 Subject: [PATCH 01/16] - portability fix for AIX in include/my_sys.h: define alloca as a compiler builtin when using gcc include/my_sys.h: - Portability fix: define alloca as a compiler builtin on systems that have gcc but no alloca.h (e.g. some IBM AIX flavors), use "#pragma alloca" when using IBMs compiler (xlr_C) --- include/my_sys.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/my_sys.h b/include/my_sys.h index 8cdc78025f3..61395114a5d 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -146,6 +146,15 @@ extern my_string my_strdup(const char *from,myf MyFlags); #define ORIG_CALLER_INFO /* nothing */ #endif #ifdef HAVE_ALLOCA +#ifdef __GNUC__ +/* Remove any previous definitions. */ +#undef alloca +#define alloca(size) __builtin_alloca (size) +#else /* xlc */ +#ifdef _AIX + #pragma alloca +#endif /* _AIX */ +#endif /* __GNUC__ */ #define my_alloca(SZ) alloca((size_t) (SZ)) #define my_afree(PTR) {} #else From d483ea2be6b5a17bbc8c97fd50e55789fd3d6123 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Aug 2002 21:43:46 +0300 Subject: [PATCH 02/16] Reverted Heikkis patch as his was not portable. Remove not needed locks in SHOW OPEN TABLES sql/ha_innobase.cc: Reverted Heikkis patch as his was not portable. sql/sql_show.cc: Remove not needed locks in SHOW OPEN TABLES --- sql/ha_innobase.cc | 67 +++++++++++++--------------------------------- sql/sql_show.cc | 3 --- 2 files changed, 18 insertions(+), 52 deletions(-) diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 07d3c814c1c..0cf388f4fab 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -267,35 +267,6 @@ innobase_mysql_print_thd( thd = (THD*) input_thd; - buf += sprintf(buf, "MySQL thread id %lu, query id %lu", - thd->thread_id, thd->query_id); - if (thd->host) { - buf += sprintf(buf, " %.30s", thd->host); - } - - if (thd->ip) { - buf += sprintf(buf, " %.20s", thd->ip); - } - - if (thd->user) { - buf += sprintf(buf, " %.20s", thd->user); - } - - if (thd->proc_info) { - buf += sprintf(buf, " %.50s", thd->proc_info); - } - - if (thd->query) { - buf += sprintf(buf, "\n%.150s", thd->query); - } - - buf += sprintf(buf, "\n"); - -#ifdef notdefined - /* July 30, 2002 - Revert Monty's changes because they seem to make control - characters sometimes appear in the output */ - /* We can't use value of sprintf() as this is not portable */ buf+= my_sprintf(buf, (buf, "MySQL thread id %lu", @@ -330,7 +301,6 @@ innobase_mysql_print_thd( buf=strnmov(buf, thd->query, 150); } *buf='\n'; -#endif } } @@ -478,9 +448,8 @@ innobase_init(void) &srv_auto_extend_last_data_file, &srv_last_file_size_max); if (ret == FALSE) { - fprintf(stderr, - "InnoDB: syntax error in innodb_data_file_path\n"); - DBUG_RETURN(TRUE); + sql_print_error("InnoDB: syntax error in innodb_data_file_path"); + DBUG_RETURN(TRUE); } if (!innobase_log_group_home_dir) @@ -925,13 +894,13 @@ ha_innobase::open( norm_name, NULL); if (NULL == ib_table) { - fprintf(stderr, -"InnoDB: Error: cannot find table %s from the internal data dictionary\n" -"InnoDB: of InnoDB though the .frm file for the table exists. Maybe you\n" -"InnoDB: have deleted and recreated InnoDB data files but have forgotten\n" -"InnoDB: to delete the corresponding .frm files of InnoDB tables, or you\n" -"InnoDB: have moved .frm files to another database?\n", - norm_name); + sql_print_error("InnoDB error:\n\ +Cannot find table %s from the internal data dictionary\n\ +of InnoDB though the .frm file for the table exists. Maybe you\n\ +have deleted and recreated InnoDB data files but have forgotten\n\ +to delete the corresponding .frm files of InnoDB tables, or you\n\ +have moved .frm files to another database?", + norm_name); free_share(share); my_free((char*) upd_buff, MYF(0)); @@ -1269,7 +1238,6 @@ ha_innobase::store_key_val_for_row( equal */ bzero(buff, (ref_length - (uint) (buff - buff_start))); - DBUG_RETURN(ref_length); } @@ -2124,11 +2092,8 @@ ha_innobase::change_active_index( } if (!prebuilt->index) { - fprintf(stderr, - "InnoDB: Could not find key n:o %u with name %s from dict cache\n" - "InnoDB: for table %s\n", keynr, key ? key->name : "NULL", prebuilt->table->name); - - DBUG_RETURN(1); + sql_print_error("Innodb could not find key n:o %u with name %s from dict cache for table %s", keynr, key ? key->name : "NULL", prebuilt->table->name); + DBUG_RETURN(1); } assert(prebuilt->search_tuple != 0); @@ -2425,6 +2390,7 @@ ha_innobase::rnd_pos( } if (error) { + DBUG_PRINT("error",("Got error: %ld",error)); DBUG_RETURN(error); } @@ -2432,6 +2398,10 @@ ha_innobase::rnd_pos( for the table, and it is == ref_length */ error = index_read(buf, pos, ref_length, HA_READ_KEY_EXACT); + if (error) + { + DBUG_PRINT("error",("Got error: %ld",error)); + } change_active_index(keynr); @@ -2442,7 +2412,6 @@ ha_innobase::rnd_pos( Stores a reference to the current row to 'ref' field of the handle. Note that in the case where we have generated the clustered index for the table, the function parameter is illogical: we MUST ASSUME that 'record' -is the current 'position' of the handle, because if row ref is actually the row id internally generated in InnoDB, then 'record' does not contain it. We just guess that the row id must be for the record where the handle was positioned the last time. */ @@ -2691,7 +2660,7 @@ ha_innobase::create( /* Our function row_get_mysql_key_number_for_index assumes the primary key is always number 0, if it exists */ - assert(primary_key_no == -1 || primary_key_no == 0); + DBUG_ASSERT(primary_key_no == -1 || primary_key_no == 0); /* Create the keys */ @@ -2772,7 +2741,7 @@ ha_innobase::create( innobase_table = dict_table_get(norm_name, NULL); - assert(innobase_table != 0); + DBUG_ASSERT(innobase_table != 0); /* Tell the InnoDB server that there might be work for utility threads: */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c64a1a3d6ed..5746830f4cd 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -117,7 +117,6 @@ int mysqld_show_open_tables(THD *thd,const char *db,const char *wild) if (list_open_tables(thd,&tables,db,wild)) DBUG_RETURN(-1); - pthread_mutex_lock(&LOCK_open); List_iterator it(tables); while ((table_name=it++)) { @@ -126,11 +125,9 @@ int mysqld_show_open_tables(THD *thd,const char *db,const char *wild) net_store_data(&thd->packet,query_table_status(thd,db,table_name)); if (my_net_write(&thd->net,(char*) thd->packet.ptr(),thd->packet.length())) { - pthread_mutex_unlock(&LOCK_open); DBUG_RETURN(-1); } } - pthread_mutex_unlock(&LOCK_open); send_eof(&thd->net); DBUG_RETURN(0); } From e295dd2974adff13f069d01bfceee27e77882537 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Aug 2002 22:09:25 +0300 Subject: [PATCH 03/16] Portability fix for AIX include/my_sys.h: Removed redefine of alloca with GCC --- include/my_sys.h | 12 ++++-------- mysql-test/r/bigint.result | 2 -- mysql-test/t/bigint.test | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 61395114a5d..fd201d39183 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -145,22 +145,18 @@ extern my_string my_strdup(const char *from,myf MyFlags); #define CALLER_INFO /* nothing */ #define ORIG_CALLER_INFO /* nothing */ #endif + #ifdef HAVE_ALLOCA -#ifdef __GNUC__ -/* Remove any previous definitions. */ -#undef alloca -#define alloca(size) __builtin_alloca (size) -#else /* xlc */ -#ifdef _AIX - #pragma alloca +#if defined(_AIX) && !defined(__GNUC__) +#pragma alloca #endif /* _AIX */ -#endif /* __GNUC__ */ #define my_alloca(SZ) alloca((size_t) (SZ)) #define my_afree(PTR) {} #else #define my_alloca(SZ) my_malloc(SZ,MYF(0)) #define my_afree(PTR) my_free(PTR,MYF(MY_WME)) #endif /* HAVE_ALLOCA */ + #ifdef MSDOS #ifdef __ZTC__ void * __CDECL halloc(long count,size_t length); diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 46ce0fda2c1..169ab041ed9 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -10,6 +10,4 @@ a a 18446744073709551615 a -18446744073709551615 -a 18446744073709551614 diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index 6470b6f6a30..cd2fadc7f29 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -10,7 +10,7 @@ create table t1 (a bigint unsigned not null, primary key(a)); insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); select * from t1; select * from t1 where a=18446744073709551615; -select * from t1 where a='18446744073709551615'; +#select * from t1 where a='18446744073709551615'; delete from t1 where a=18446744073709551615; select * from t1; drop table t1; From 6fd5f345c920532121b43131e8c9d32b2e494b0d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Aug 2002 10:17:54 +0300 Subject: [PATCH 04/16] ha_innobase.cc: Revert changes to sprintf until we know why control characters scrambled the output sql/ha_innobase.cc: Revert changes to sprintf until we know why control characters scrambled the output --- sql/ha_innobase.cc | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 0cf388f4fab..0852282a7e7 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -265,7 +265,40 @@ innobase_mysql_print_thd( { THD* thd; - thd = (THD*) input_thd; + thd = (THD*) input_thd; + + buf += sprintf(buf, "MySQL thread id %lu, query id %lu", + thd->thread_id, thd->query_id); + if (thd->host) { + buf += sprintf(buf, " %.30s", thd->host); + } + + if (thd->ip) { + buf += sprintf(buf, " %.20s", thd->ip); + } + + if (thd->user) { + buf += sprintf(buf, " %.20s", thd->user); + } + + if (thd->proc_info) { + buf += sprintf(buf, " %.50s", thd->proc_info); + } + + if (thd->query) { + buf += sprintf(buf, "\n%.150s", thd->query); + } + + buf += sprintf(buf, "\n"); + +#ifdef notdefined + /* August 8, 2002 + Revert these changes because they seem to make control + characters sometimes appear in the output and scramble it; + on platforms (what are those?) where sprintf does not work + we should define sprintf as 'my_emulated_sprintf'; InnoDB code + contains lots of sprintfs, it does not help to remove them from + just a single file */ /* We can't use value of sprintf() as this is not portable */ buf+= my_sprintf(buf, @@ -301,6 +334,7 @@ innobase_mysql_print_thd( buf=strnmov(buf, thd->query, 150); } *buf='\n'; +#endif } } @@ -894,7 +928,7 @@ ha_innobase::open( norm_name, NULL); if (NULL == ib_table) { - sql_print_error("InnoDB error:\n\ + sql_print_error("InnoDB error:\n\ Cannot find table %s from the internal data dictionary\n\ of InnoDB though the .frm file for the table exists. Maybe you\n\ have deleted and recreated InnoDB data files but have forgotten\n\ From 6a246376dc8f4d3397844c75641a8e893ed5f11c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Aug 2002 15:06:59 +0300 Subject: [PATCH 05/16] ha_innobase.cc: Found the bug in modified innobase_mysqld_print_thd; the person who modifies code should test that his change works sql/ha_innobase.cc: Found the bug in modified innobase_mysqld_print_thd; the person who modifies code should test that his change works --- sql/ha_innobase.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 0852282a7e7..251e6c3ca7e 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -293,12 +293,16 @@ innobase_mysql_print_thd( #ifdef notdefined /* August 8, 2002 - Revert these changes because they seem to make control - characters sometimes appear in the output and scramble it; - on platforms (what are those?) where sprintf does not work + Revert these changes because they make control characters sometimes + appear in the output and scramble it: + the reason is that the last character of the ouptput will be + '\n', not the null character '\0'. We do not know where the output + ends in buf! + + On platforms (what are those?) where sprintf does not work we should define sprintf as 'my_emulated_sprintf'; InnoDB code contains lots of sprintfs, it does not help to remove them from - just a single file */ + just a single file. */ /* We can't use value of sprintf() as this is not portable */ buf+= my_sprintf(buf, @@ -334,6 +338,7 @@ innobase_mysql_print_thd( buf=strnmov(buf, thd->query, 150); } *buf='\n'; + /* Here we should add '\0' to the nd of output to mark its end */ #endif } } From b9b404b1ce9597d2e16a6be8c45e313d4f1a802a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Aug 2002 15:34:23 +0300 Subject: [PATCH 06/16] ha_innobase.cc, trx0trx.h, lock0lock.c, trx0trx.c: Add some more safety margin to buffer sizes in prints innobase/trx/trx0trx.c: Add some more safety margin to buffer sizes in prints innobase/lock/lock0lock.c: Add some more safety margin to buffer sizes in prints innobase/include/trx0trx.h: Add some more safety margin to buffer sizes in prints sql/ha_innobase.cc: Add some more safety margin to buffer sizes in prints --- innobase/include/trx0trx.h | 2 +- innobase/lock/lock0lock.c | 4 ++-- innobase/trx/trx0trx.c | 2 +- sql/ha_innobase.cc | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h index 6e98f22c34b..84d85fcaff6 100644 --- a/innobase/include/trx0trx.h +++ b/innobase/include/trx0trx.h @@ -262,7 +262,7 @@ void trx_print( /*======*/ char* buf, /* in/out: buffer where to print, must be at least - 500 bytes */ + 800 bytes */ trx_t* trx); /* in: transaction */ diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index 2f5ade656d9..9b3719867f0 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -3625,7 +3625,7 @@ lock_print_info( trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list); while (trx) { - if (buf_end - buf < 600) { + if (buf_end - buf < 900) { return; } @@ -3662,7 +3662,7 @@ loop: return; } - if (buf_end - buf < 600) { + if (buf_end - buf < 900) { return; } diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c index 48b1ecc59f2..94a11042de5 100644 --- a/innobase/trx/trx0trx.c +++ b/innobase/trx/trx0trx.c @@ -1465,7 +1465,7 @@ void trx_print( /*======*/ char* buf, /* in/out: buffer where to print, must be at least - 500 bytes */ + 800 bytes */ trx_t* trx) /* in: transaction */ { char* start_of_line; diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 251e6c3ca7e..5e6d4b5f50c 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -260,7 +260,7 @@ void innobase_mysql_print_thd( /*=====================*/ char* buf, /* in/out: buffer where to print, must be at least - 300 bytes */ + 400 bytes */ void* input_thd)/* in: pointer to a MySQL THD object */ { THD* thd; @@ -338,7 +338,7 @@ innobase_mysql_print_thd( buf=strnmov(buf, thd->query, 150); } *buf='\n'; - /* Here we should add '\0' to the nd of output to mark its end */ + /* Here we should add '\0' to the end of output to mark its end */ #endif } } From 46f5b2674fd2812cf1f77412ecd20561fe9d3d30 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Aug 2002 23:14:02 +0300 Subject: [PATCH 07/16] A change in IF behaviour that several users asked for ... --- Docs/manual.texi | 8 ++++++++ mysql-test/r/func_if.result | 2 ++ mysql-test/t/func_if.test | 4 ++++ sql/item_cmpfunc.cc | 6 ++++++ 4 files changed, 20 insertions(+) diff --git a/Docs/manual.texi b/Docs/manual.texi index 806c5d34fe0..d91738bf953 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46924,6 +46924,14 @@ not yet 100% confident in this code. * News-3.23.0:: Changes in release 3.23.0 @end menu +@node News-3.23.53, News-3.23.52, News-3.23.x, News-3.23.x +@appendixsubsec Changes in release 3.23.53 +@itemize @bullet +@item +Changed behaviour that IF(condition,column,NULL) returns column type +@end itemize + + @node News-3.23.52, News-3.23.51, News-3.23.x, News-3.23.x @appendixsubsec Changes in release 3.23.52 @itemize @bullet diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 85c4007f63c..f93f8028496 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -33,3 +33,5 @@ aa aaa sum(if(num is null,0.00,num)) 144.54 +min(if(y -x > 5,y,NULL)) max(if(y - x > 5,y,NULL)) +6 56 diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index c5cc73ecd1f..85553d1a2fd 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -28,3 +28,7 @@ create table t1 (num double(12,2)); insert into t1 values (144.54); select sum(if(num is null,0.00,num)) from t1; drop table t1; +create table t1 (x int, y int); +insert into t1 values (0,6),(10,16),(20,26),(30,10),(40,46),(50,56); +select min(if(y -x > 5,y,NULL)), max(if(y - x > 5,y,NULL)) from t1; +drop table t1; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index ae50090fea1..86e2ef29564 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -494,6 +494,12 @@ Item_func_if::fix_length_and_dec() decimals=max(args[1]->decimals,args[2]->decimals); enum Item_result arg1_type=args[1]->result_type(); enum Item_result arg2_type=args[2]->result_type(); + bool null1=args[1]->null_value; + bool null2=args[2]->null_value; + if (null1 && !null2) + arg1_type=arg2_type; + else if (!null1 && null2) + arg2_type=arg1_type; binary=1; if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT) { From c2b4a3049f161a6d50e2b6ea8a6d5d6ac751e593 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Aug 2002 01:47:51 +0200 Subject: [PATCH 08/16] After discussing it with Monty by phone once more: - Only define alloca as a compiler builtin, if we use GCC and there is no alloca.h installed include/my_sys.h: - Only define alloca as a compiler builtin, if we use GCC and there is no alloca.h installed --- include/my_sys.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/my_sys.h b/include/my_sys.h index fd201d39183..cd6ec62719a 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -150,6 +150,9 @@ extern my_string my_strdup(const char *from,myf MyFlags); #if defined(_AIX) && !defined(__GNUC__) #pragma alloca #endif /* _AIX */ +#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) +#define alloca __builtin_alloca +#endif /* GNUC */ #define my_alloca(SZ) alloca((size_t) (SZ)) #define my_afree(PTR) {} #else From 18c48aa951b901efca67b4f16d3bbe2f7975fd87 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Aug 2002 02:08:41 +0200 Subject: [PATCH 09/16] Moved a News entry from the 3.23.53 section into the 3.23.52 section and removed the 3.23.53 News section for now until 3.23.52 is officially tagged. Docs/manual.texi: Moved this changelog entry into the 3.23.52 section and removed the 3.23.53 News section for now until 3.23.52 is officially tagged. --- Docs/manual.texi | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index d91738bf953..321a5f0770e 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46924,18 +46924,12 @@ not yet 100% confident in this code. * News-3.23.0:: Changes in release 3.23.0 @end menu -@node News-3.23.53, News-3.23.52, News-3.23.x, News-3.23.x -@appendixsubsec Changes in release 3.23.53 -@itemize @bullet -@item -Changed behaviour that IF(condition,column,NULL) returns column type -@end itemize - - @node News-3.23.52, News-3.23.51, News-3.23.x, News-3.23.x @appendixsubsec Changes in release 3.23.52 @itemize @bullet @item +Changed behaviour that @code{IF(condition,column,NULL)} returns column type +@item Fixed a security bug with empty db column in db table @item Changed initialisation of @code{RND()} to make it less predicatable. From cdd3be6ab147ec6229bceefb1f4bb4d19960c7d4 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Aug 2002 16:38:30 +0300 Subject: [PATCH 10/16] removal of lines that make problems with texi Docs/manual.texi: removing lines that do not follow texi rules correctly. Hope Arjen can put this together properly ... --- Docs/manual.texi | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index d91738bf953..806c5d34fe0 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46924,14 +46924,6 @@ not yet 100% confident in this code. * News-3.23.0:: Changes in release 3.23.0 @end menu -@node News-3.23.53, News-3.23.52, News-3.23.x, News-3.23.x -@appendixsubsec Changes in release 3.23.53 -@itemize @bullet -@item -Changed behaviour that IF(condition,column,NULL) returns column type -@end itemize - - @node News-3.23.52, News-3.23.51, News-3.23.x, News-3.23.x @appendixsubsec Changes in release 3.23.52 @itemize @bullet From 49e4fea6c9f64f692b941589fd86158bf3e76a10 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Aug 2002 22:08:00 +0300 Subject: [PATCH 11/16] A small fix for last_insert_id with multi-row inserts --- sql/sql_insert.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index d1ec53d6590..6ffb3dd88bf 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -306,7 +306,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List &fields, else sprintf(buff,ER(ER_INSERT_INFO),info.records,info.deleted, thd->cuted_fields); - ::send_ok(&thd->net,info.copied+info.deleted,0L,buff); + ::send_ok(&thd->net,info.copied+info.deleted,(ulonglong)id,buff); } DBUG_RETURN(0); From 86dc608c3489adf8b5d453f84dc2f89bb7a13b82 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 11 Aug 2002 18:49:47 +0300 Subject: [PATCH 12/16] ha_innobase.cc, ut0ut.c, univ.i, ut0ut.h: Redefine sprintf as ut_sprintf inside InnoDB code; some old Unixes may have a pointer as the return type of sprintf lock0lock.c: Add safety against buffer overruns in latest deadlock info srv0srv.c: Add safety against buffer overruns in SHOW INNODB STATUS os0thread.h, os0thread.c: Fix a portability bug introduced in Windows when we changed os_thread_id_t to be the same as os_thread_t innobase/os/os0thread.c: Fix a portability bug introduced in Windows when we changed os_thread_id_t to be the same as os_thread_t innobase/include/os0thread.h: Fix a portability bug introduced in Windows when we changed os_thread_id_t to be the same as os_thread_t innobase/srv/srv0srv.c: Add safety against buffer overruns in SHOW INNODB STATUS innobase/lock/lock0lock.c: Add safety against buffer overruns in latest deadlock info innobase/include/ut0ut.h: Redefine sprintf as ut_sprintf inside InnoDB code; some old Unixes may have a pointer as the return type of sprintf innobase/include/univ.i: Redefine sprintf as ut_sprintf inside InnoDB code; some old Unixes may have a pointer as the return type of sprintf innobase/ut/ut0ut.c: Redefine sprintf as ut_sprintf inside InnoDB code; some old Unixes may have a pointer as the return type of sprintf sql/ha_innobase.cc: Redefine sprintf as ut_sprintf inside InnoDB code; some old Unixes may have a pointer as the return type of sprintf --- innobase/include/os0thread.h | 4 +- innobase/include/univ.i | 6 +++ innobase/include/ut0ut.h | 12 ++++++ innobase/lock/lock0lock.c | 2 + innobase/os/os0thread.c | 11 +++++- innobase/srv/srv0srv.c | 13 ++++++- innobase/ut/ut0ut.c | 25 +++++++++++++ sql/ha_innobase.cc | 71 +++++++----------------------------- 8 files changed, 82 insertions(+), 62 deletions(-) diff --git a/innobase/include/os0thread.h b/innobase/include/os0thread.h index 636cfd79e50..95a3a95fb74 100644 --- a/innobase/include/os0thread.h +++ b/innobase/include/os0thread.h @@ -70,7 +70,9 @@ os_thread_create( void* arg, /* in: argument to start function */ os_thread_id_t* thread_id); /* out: id of created - thread */ + thread; currently this is + identical to the handle to + the thread */ /********************************************************************* A thread calling this function ends its execution. */ diff --git a/innobase/include/univ.i b/innobase/include/univ.i index f5d083766bc..b511ec044a2 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -63,6 +63,12 @@ Microsoft Visual C++ */ #define HAVE_PWRITE #endif +/* Apparently in some old SCO Unixes the return type of sprintf is not +an integer as it should be according to the modern Posix standard. Because +of that we define sprintf inside InnoDB code as our own function ut_sprintf */ +#undef sprintf +#define sprintf ut_sprintf + #endif /* DEBUG VERSION CONTROL diff --git a/innobase/include/ut0ut.h b/innobase/include/ut0ut.h index 408788016c1..8ec23b23dcd 100644 --- a/innobase/include/ut0ut.h +++ b/innobase/include/ut0ut.h @@ -17,6 +17,18 @@ Created 1/20/1994 Heikki Tuuri typedef time_t ib_time_t; + +/************************************************************ +Uses vsprintf to emulate sprintf so that the function always returns +the printed length. Apparently in some old SCO Unixes sprintf did not +return the printed length but a pointer to the end of the printed string. */ + +ulint +ut_sprintf( +/*=======*/ + char* buf, /* in/out: buffer where to print */ + const char* format, /* in: format of prints */ + ...); /* in: arguments to be printed */ /************************************************************ Gets the high 32 bits in a ulint. That is makes a shift >> 32, but since there seem to be compiler bugs in both gcc and Visual C++, diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index 9b3719867f0..da4092b926e 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -2754,6 +2754,8 @@ lock_deadlock_occurs( err_buf += sprintf(err_buf, "*** WE ROLL BACK TRANSACTION (2)\n"); + ut_a(strlen(lock_latest_err_buf) < 4100); + /* sess_raise_error_low(trx, DB_DEADLOCK, lock->type_mode, table, index, NULL, NULL, NULL); diff --git a/innobase/os/os0thread.c b/innobase/os/os0thread.c index 75f19f6d175..9eb80cdf826 100644 --- a/innobase/os/os0thread.c +++ b/innobase/os/os0thread.c @@ -96,17 +96,20 @@ os_thread_create( void* arg, /* in: argument to start function */ os_thread_id_t* thread_id) /* out: id of created - thread */ + thread; currently this is + identical to the handle to + the thread */ { #ifdef __WIN__ os_thread_t thread; + ulint win_thread_id; thread = CreateThread(NULL, /* no security attributes */ 0, /* default size stack */ (LPTHREAD_START_ROUTINE)start_f, arg, 0, /* thread runs immediately */ - thread_id); + &win_thread_id); if (srv_set_thread_priorities) { @@ -117,6 +120,8 @@ os_thread_create( ut_a(SetThreadPriority(thread, srv_query_thread_priority)); } + *thread_id = thread; + return(thread); #else int ret; @@ -134,6 +139,8 @@ os_thread_create( my_pthread_setprio(pthread, srv_query_thread_priority); } + *thread_id = pthread; + return(pthread); #endif } diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 2ce97c34e06..0472146013e 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -2222,6 +2222,7 @@ srv_sprintf_innodb_monitor( ut_sprintf_timestamp(buf); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, " INNODB MONITOR OUTPUT\n" "=====================================\n"); @@ -2236,6 +2237,7 @@ srv_sprintf_innodb_monitor( sync_print(buf, buf_end); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, "------------\n" "TRANSACTIONS\n" @@ -2248,15 +2250,18 @@ srv_sprintf_innodb_monitor( "--------\n"); os_aio_print(buf, buf_end); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, "-------------------------------------\n" "INSERT BUFFER AND ADAPTIVE HASH INDEX\n" "-------------------------------------\n"); ibuf_print(buf, buf_end); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); ha_print_info(buf, buf_end, btr_search_sys->hash_index); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, "%.2f hash searches/s, %.2f non-hash searches/s\n", @@ -2272,6 +2277,7 @@ srv_sprintf_innodb_monitor( "---\n"); log_print(buf, buf_end); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, "----------------------\n" "BUFFER POOL AND MEMORY\n" @@ -2282,6 +2288,7 @@ srv_sprintf_innodb_monitor( mem_pool_get_reserved(mem_comm_pool)); buf_print_io(buf, buf_end); buf = buf + strlen(buf); + ut_a(buf < buf_end + 1500); buf += sprintf(buf, "--------------\n" "ROW OPERATIONS\n" @@ -2315,6 +2322,8 @@ srv_sprintf_innodb_monitor( buf += sprintf(buf, "----------------------------\n" "END OF INNODB MONITOR OUTPUT\n" "============================\n"); + ut_a(buf < buf_end + 1900); + mutex_exit(&srv_innodb_monitor_mutex); } @@ -2372,7 +2381,9 @@ loop: buf = mem_alloc(100000); - srv_sprintf_innodb_monitor(buf, 100000); + srv_sprintf_innodb_monitor(buf, 90000); + + ut_a(strlen(buf) < 99000); printf("%s", buf); diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c index 6a5f273e731..2274e723be9 100644 --- a/innobase/ut/ut0ut.c +++ b/innobase/ut/ut0ut.c @@ -12,10 +12,35 @@ Created 5/11/1994 Heikki Tuuri #include "ut0ut.ic" #endif +#include + #include "ut0sort.h" ibool ut_always_false = FALSE; +/************************************************************ +Uses vsprintf to emulate sprintf so that the function always returns +the printed length. Apparently in some old SCO Unixes sprintf did not +return the printed length but a pointer to the end of the printed string. */ + +ulint +ut_sprintf( +/*=======*/ + char* buf, /* in/out: buffer where to print */ + const char* format, /* in: format of prints */ + ...) /* in: arguments to be printed */ +{ + va_list args; + + va_start(args, format); + + vsprintf(buf, format, args); + + va_end(args); + + return((ulint)strlen(buf)); +} + /************************************************************ Gets the high 32 bits in a ulint. That is makes a shift >> 32, but since there seem to be compiler bugs in both gcc and Visual C++, diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 5e6d4b5f50c..e9becc8debb 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -264,82 +264,35 @@ innobase_mysql_print_thd( void* input_thd)/* in: pointer to a MySQL THD object */ { THD* thd; + char* old_buf = buf; thd = (THD*) input_thd; - buf += sprintf(buf, "MySQL thread id %lu, query id %lu", + buf += ut_sprintf(buf, "MySQL thread id %lu, query id %lu", thd->thread_id, thd->query_id); if (thd->host) { - buf += sprintf(buf, " %.30s", thd->host); + buf += ut_sprintf(buf, " %.30s", thd->host); } if (thd->ip) { - buf += sprintf(buf, " %.20s", thd->ip); + buf += ut_sprintf(buf, " %.20s", thd->ip); } if (thd->user) { - buf += sprintf(buf, " %.20s", thd->user); + buf += ut_sprintf(buf, " %.20s", thd->user); } if (thd->proc_info) { - buf += sprintf(buf, " %.50s", thd->proc_info); + buf += ut_sprintf(buf, " %.50s", thd->proc_info); } if (thd->query) { - buf += sprintf(buf, "\n%.150s", thd->query); + buf += ut_sprintf(buf, "\n%.150s", thd->query); } - buf += sprintf(buf, "\n"); + buf += ut_sprintf(buf, "\n"); -#ifdef notdefined - /* August 8, 2002 - Revert these changes because they make control characters sometimes - appear in the output and scramble it: - the reason is that the last character of the ouptput will be - '\n', not the null character '\0'. We do not know where the output - ends in buf! - - On platforms (what are those?) where sprintf does not work - we should define sprintf as 'my_emulated_sprintf'; InnoDB code - contains lots of sprintfs, it does not help to remove them from - just a single file. */ - - /* We can't use value of sprintf() as this is not portable */ - buf+= my_sprintf(buf, - (buf, "MySQL thread id %lu", - thd->thread_id)); - if (thd->host) - { - *buf++=' '; - buf=strnmov(buf, thd->host, 30); - } - - if (thd->ip) - { - *buf++=' '; - buf=strnmov(buf, thd->ip, 20); - } - - if (thd->user) - { - *buf++=' '; - buf=strnmov(buf, thd->user, 20); - } - - if (thd->proc_info) - { - *buf++=' '; - buf=strnmov(buf, thd->proc_info, 50); - } - - if (thd->query) - { - *buf++='\n'; - buf=strnmov(buf, thd->query, 150); - } - *buf='\n'; - /* Here we should add '\0' to the end of output to mark its end */ -#endif + ut_a(strlen(old_buf) < 400); } } @@ -3467,8 +3420,10 @@ innodb_show_status( DBUG_ENTER("innodb_show_status"); - /* We let the InnoDB Monitor to output at most 100 kB of text */ - buf = (char*)ut_malloc(100 * 1024); + /* We let the InnoDB Monitor to output at most 100 kB of text, add + a safety margin of 10 kB for buffer overruns */ + + buf = (char*)ut_malloc(110 * 1024); srv_sprintf_innodb_monitor(buf, 100 * 1024); From 714f2b0f8b90dc843024aea2f3d9afb5becc24d9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Aug 2002 00:17:39 +0300 Subject: [PATCH 13/16] trx0trx.h, trx0trx.c, ha_innobase.cc, ha_innobase.h: Add tentative code which can be used in HANDLER implementation for InnoDB sql/ha_innobase.h: Add tentative code which can be used in HANDLER implementation for InnoDB sql/ha_innobase.cc: Add tentative code which can be used in HANDLER implementation for InnoDB innobase/trx/trx0trx.c: Add tentative code which can be used in HANDLER implementation for InnoDB innobase/include/trx0trx.h: Add tentative code which can be used in HANDLER implementation for InnoDB --- innobase/include/trx0trx.h | 7 +++++ innobase/trx/trx0trx.c | 11 ++++++++ sql/ha_innobase.cc | 57 +++++++++++++++++++++++++++++++++++++- sql/ha_innobase.h | 1 + 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h index 84d85fcaff6..e1f65e9da0f 100644 --- a/innobase/include/trx0trx.h +++ b/innobase/include/trx0trx.h @@ -117,6 +117,13 @@ void trx_start_if_not_started( /*=====================*/ trx_t* trx); /* in: transaction */ +/***************************************************************** +Starts the transaction if it is not yet started. */ + +void +trx_start_if_not_started_noninline( +/*===============================*/ + trx_t* trx); /* in: transaction */ /******************************************************************** Commits a transaction. */ diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c index 94a11042de5..b8cf7ad4a6d 100644 --- a/innobase/trx/trx0trx.c +++ b/innobase/trx/trx0trx.c @@ -39,6 +39,17 @@ sess_t* trx_dummy_sess = NULL; the kernel mutex */ ulint trx_n_mysql_transactions = 0; +/***************************************************************** +Starts the transaction if it is not yet started. */ + +void +trx_start_if_not_started_noninline( +/*===============================*/ + trx_t* trx) /* in: transaction */ +{ + trx_start_if_not_started(trx); +} + /******************************************************************** Retrieves the error_info field from a trx. */ diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index e9becc8debb..3ca6262b13f 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -19,7 +19,7 @@ InnoDB */ /* TODO list for the InnoDB handler: - Ask Monty if strings of different languages can exist in the same - database. Answer: in near future yes, but not yet. + database. Answer: in 4.1 yes. */ #ifdef __GNUC__ @@ -378,6 +378,61 @@ ha_innobase::update_thd( return(0); } +/********************************************************************* +Call this when you have opened a new table handle in HANDLER, before you +call index_read_idx() etc. Actually, we can let the cursor stay open even +over a transaction commit! Then you should call this before every operation, +fecth next etc. This function inits the necessary things even after a +transaction commit. */ + +/* TODO: THIS CODE HAS NOT BEEN TESTED!!! */ + +void +ha_innobase::init_table_handle_for_HANDLER(void) +/*============================================*/ +{ + row_prebuilt_t* prebuilt; + + /* If current thd does not yet have a trx struct, create one. + If the current handle does not yet have a prebuilt struct, create + one. Update the trx pointers in the prebuilt struct. Normally + this operation is done in external_lock. */ + + update_thd(current_thd); + + /* Initialize the prebuilt struct much like it would be inited in + external_lock */ + + prebuilt = (row_prebuilt_t*)innobase_prebuilt; + + /* If the transaction is not started yet, start it */ + + trx_start_if_not_started_noninline(prebuilt->trx); + + /* Assign a read view if the transaction does not have it yet */ + + trx_assign_read_view(prebuilt->trx); + + /* We did the necessary inits in this function, no need to repeat them + in row_search_for_mysql */ + + prebuilt->sql_stat_start = FALSE; + + /* We let HANDLER always to do the reads as consistent reads, even + if the trx isolation level would have been specified as SERIALIZABLE */ + + prebuilt->select_lock_type = LOCK_NONE; + + /* Always fetch all columns in the index record */ + + prebuilt->hint_no_need_to_fetch_extra_cols = FALSE; + + /* We want always to fetch all columns in the whole row? Or do + we???? */ + + prebuilt->read_just_key = FALSE; +} + /************************************************************************* Opens an InnoDB database. */ diff --git a/sql/ha_innobase.h b/sql/ha_innobase.h index abb6ade79f7..2c69018ed38 100644 --- a/sql/ha_innobase.h +++ b/sql/ha_innobase.h @@ -157,6 +157,7 @@ class ha_innobase: public handler void free_foreign_key_create_info(char* str); THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); + void init_table_handle_for_HANDLER(); /* TODO: NOT TESTED!!! */ longlong get_auto_increment(); }; From b2e946136d21ec3102b3204ef1e2a1a10b404ff3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Aug 2002 03:28:02 +0300 Subject: [PATCH 14/16] Fixed problem with BIGINT and shutdown on AIX Moved IF(test,column,NULL) code to 4.0 Changed mysys_priv.h to include my_pthread.h or my_no_pthread.h. Removed some CR's in os2 files. Docs/manual.texi: Changelog include/global.h: Fix for BIGINT problem on AIX include/my_no_pthread.h: Fixed typo libmysql/Makefile.shared: Fix for BIGINT problem on AIX mysql-test/mysql-test-run.sh: Fix to find xterm on AIX 4.3 mysql-test/r/bigint.result: Fix for BIGINT problem on AIX mysql-test/r/func_if.result: Change results for IF() after reverting change. mysql-test/t/bigint.test: Fix for BIGINT problem on AIX mysys/Makefile.am: Fix for BIGINT problem on AIX mysys/my_gethostbyname.c: Cleanup mysys/my_init.c: Cleanup mysys/my_net.c: Cleanup mysys/my_os2cond.c: Space & CRLF cleanup mysys/my_os2dirsrch.c: Space & CRLF cleanup mysys/my_os2dirsrch.h: Space & CRLF cleanup mysys/my_os2dlfcn.c: Space & CRLF cleanup mysys/my_os2file64.c: Space & CRLF cleanup mysys/my_os2mutex.c: Space & CRLF cleanup mysys/my_os2thread.c: Space & CRLF cleanup mysys/my_os2tls.c: Space & CRLF cleanup mysys/mysys_priv.h: cleanup mysys/thr_rwlock.c: cleanup sql/ha_innobase.cc: Removed usage of sprintf() Fixed missing end \0 which caused control characters to appear in SHOW INNODB STATUS sql/item_cmpfunc.cc: Reverted change for IF() sql/mysqld.cc: Fix for shutdown on AIX --- Docs/manual.texi | 5 +- include/global.h | 2 + include/my_no_pthread.h | 2 +- libmysql/Makefile.shared | 2 +- mysql-test/mysql-test-run.sh | 2 +- mysql-test/r/bigint.result | 2 + mysql-test/r/func_if.result | 2 +- mysql-test/t/bigint.test | 8 +- mysys/Makefile.am | 2 +- mysys/my_gethostbyname.c | 6 -- mysys/my_init.c | 3 - mysys/my_net.c | 5 -- mysys/my_os2cond.c | 24 +++--- mysys/my_os2dirsrch.c | 66 ++++++++-------- mysys/my_os2dirsrch.h | 20 ++--- mysys/my_os2dlfcn.c | 4 +- mysys/my_os2file64.c | 142 +++++++++++++++++------------------ mysys/my_os2mutex.c | 8 +- mysys/my_os2thread.c | 6 +- mysys/my_os2tls.c | 44 +++++------ mysys/my_port.c | 40 ++++++++++ mysys/mysys_priv.h | 6 +- mysys/thr_rwlock.c | 1 - sql/ha_innobase.cc | 42 +---------- sql/item_cmpfunc.cc | 7 +- sql/mysqld.cc | 26 ++++--- 26 files changed, 239 insertions(+), 238 deletions(-) create mode 100644 mysys/my_port.c diff --git a/Docs/manual.texi b/Docs/manual.texi index 321a5f0770e..6e86d85ee38 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46928,9 +46928,10 @@ not yet 100% confident in this code. @appendixsubsec Changes in release 3.23.52 @itemize @bullet @item -Changed behaviour that @code{IF(condition,column,NULL)} returns column type +Fixed problem with @code{UNSIGNED BIGINT} on AIX. @item -Fixed a security bug with empty db column in db table +Fixed security bug when having an empty databasename in the @code{user.db} +table. @item Changed initialisation of @code{RND()} to make it less predicatable. @item diff --git a/include/global.h b/include/global.h index 61e00df375d..a6cc561fb0a 100644 --- a/include/global.h +++ b/include/global.h @@ -104,6 +104,8 @@ #define _H_STRINGS #define _SYS_STREAM_H #define _AIX32_CURSES +#define longlong2double(A) my_longlong2double(A) +double my_longlong2double(unsigned long long A); #endif #ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */ diff --git a/include/my_no_pthread.h b/include/my_no_pthread.h index 2ff8896fa74..328086ec388 100644 --- a/include/my_no_pthread.h +++ b/include/my_no_pthread.h @@ -21,7 +21,7 @@ environment, easier to use. */ -#if !defined(_my_no_pthread_h) && !defined(THREADS) +#if !defined(_my_no_pthread_h) && !defined(THREAD) #define _my_no_pthread_h #define pthread_mutex_init(A,B) diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index d1271173b24..8fe15cca20c 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -57,7 +57,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \ thr_mutex.lo mulalloc.lo string.lo default.lo \ my_compress.lo array.lo my_once.lo list.lo my_net.lo \ charset.lo hash.lo mf_iocache.lo my_seek.lo \ - my_pread.lo mf_cache.lo my_gethostbyname.lo + my_pread.lo mf_cache.lo my_gethostbyname.lo my_port.lo # Not needed in the minimum library mysysobjects2 = getopt.lo getopt1.lo getvar.lo my_lib.lo mysysobjects = $(mysysobjects1) $(mysysobjects2) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 566702a7330..514ef9e704a 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -18,7 +18,7 @@ TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work # Program Definitions #-- -PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin +PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/bin/X11 # Standard functions diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 169ab041ed9..46ce0fda2c1 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -10,4 +10,6 @@ a a 18446744073709551615 a +18446744073709551615 +a 18446744073709551614 diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index f93f8028496..8b5d51a4ba2 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -34,4 +34,4 @@ aaa sum(if(num is null,0.00,num)) 144.54 min(if(y -x > 5,y,NULL)) max(if(y - x > 5,y,NULL)) -6 56 +16 6 diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index cd2fadc7f29..f7437d77c36 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -5,12 +5,18 @@ select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296; select 9223372036854775807,-009223372036854775808; select +9999999999999999999,-9999999999999999999; +# +# In 3.23 we have to disable the test of column to bigint as +# this fails on AIX powerpc (the resolution for double is not good enough) +# This will work on 4.0 as we then have internal handling of bigint variables. +# + drop table if exists t1; create table t1 (a bigint unsigned not null, primary key(a)); insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); select * from t1; select * from t1 where a=18446744073709551615; -#select * from t1 where a='18446744073709551615'; +select * from t1 where a='18446744073709551615'; delete from t1 where a=18446744073709551615; select * from t1; drop table t1; diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 7de59939227..e3918f71b58 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -49,7 +49,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\ my_quick.c my_lockmem.c my_static.c \ getopt.c getopt1.c getvar.c my_mkdir.c \ default.c my_compress.c checksum.c raid.cc raid2.c \ - my_net.c \ + my_net.c my_port.c \ my_vsnprintf.c charset.c my_bitmap.c my_gethostbyname.c EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \ thr_mutex.c thr_rwlock.c diff --git a/mysys/my_gethostbyname.c b/mysys/my_gethostbyname.c index f30591d9fe3..ffbfc424d0a 100644 --- a/mysys/my_gethostbyname.c +++ b/mysys/my_gethostbyname.c @@ -18,7 +18,6 @@ /* Thread safe version of gethostbyname_r() */ #include "mysys_priv.h" -#include "my_pthread.h" #include #if !defined(MSDOS) && !defined(__WIN__) #include @@ -28,11 +27,6 @@ /* This file is not needed if my_gethostbyname_r is a macro */ #if !defined(my_gethostbyname_r) -#ifndef THREAD -#define pthread_mutex_lock(A) -#define pthread_mutex_unlock(A) -#endif - /* Emulate SOLARIS style calls, not because it's better, but just to make the usage of getbostbyname_r simpler. diff --git a/mysys/my_init.c b/mysys/my_init.c index 3bc87fd179d..31e49731c94 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -21,9 +21,6 @@ #include "m_ctype.h" #include #include -#ifdef THREAD -#include -#endif #ifdef HAVE_GETRUSAGE #include /* extern int getrusage(int, struct rusage *); */ diff --git a/mysys/my_net.c b/mysys/my_net.c index 1c91f7ff802..575c843f297 100644 --- a/mysys/my_net.c +++ b/mysys/my_net.c @@ -34,11 +34,6 @@ #endif #endif /* !defined(MSDOS) && !defined(__WIN__) */ -#ifndef THREAD -#define pthread_mutex_lock(A) -#define pthread_mutex_unlock(A) -#endif - void my_inet_ntoa(struct in_addr in, char *buf) { char *ptr; diff --git a/mysys/my_os2cond.c b/mysys/my_os2cond.c index c436ad9a0e9..d930aadb2d1 100644 --- a/mysys/my_os2cond.c +++ b/mysys/my_os2cond.c @@ -32,8 +32,8 @@ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) { - APIRET rc = 0; - HEV event; + APIRET rc = 0; + HEV event; cond->waiting=0; /* Warp3 FP29 or Warp4 FP4 or better required */ rc = DosCreateEventSem( NULL, &cond->semaphore, 0x0800, 0); @@ -61,7 +61,7 @@ int pthread_cond_destroy(pthread_cond_t *cond) int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { APIRET rc; - int rval; + int rval; rval = 0; cond->waiting++; @@ -80,13 +80,13 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) } int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, - struct timespec *abstime) + struct timespec *abstime) { struct timeb curtime; int result; long timeout; APIRET rc; - int rval; + int rval; _ftime(&curtime); timeout= ((long) (abstime->ts_sec - curtime.time)*1000L + @@ -123,13 +123,13 @@ int pthread_cond_signal(pthread_cond_t *cond) int pthread_cond_broadcast(pthread_cond_t *cond) { - int i; + int i; APIRET rc; - /* - * Enter a loop to bring all threads off the - * condition queue: - */ + /* + * Enter a loop to bring all threads off the + * condition queue: + */ i = cond->waiting; while (i--) rc = DosPostEventSem(cond->semaphore); @@ -176,9 +176,9 @@ struct tm *localtime_r(const time_t *timep,struct tm *tmp) else { struct tm *res=localtime(timep); - if (!res) /* Wrong date */ + if (!res) /* Wrong date */ { - bzero(tmp,sizeof(*tmp)); /* Keep things safe */ + bzero(tmp,sizeof(*tmp)); /* Keep things safe */ return 0; } *tmp= *res; diff --git a/mysys/my_os2dirsrch.c b/mysys/my_os2dirsrch.c index 36f56d3ed2e..773d6800d1e 100644 --- a/mysys/my_os2dirsrch.c +++ b/mysys/my_os2dirsrch.c @@ -26,10 +26,10 @@ long _findfirst( char* path, struct _finddata_t* dos_file) { - HDIR hdir = HDIR_CREATE; - APIRET rc; + HDIR hdir = HDIR_CREATE; + APIRET rc; FILEFINDBUF3 buf3; - ULONG entries = 1; + ULONG entries = 1; #ifdef _DEBUG printf( "_findfirst path %s\n", path); @@ -37,13 +37,13 @@ long _findfirst( char* path, struct _finddata_t* dos_file) memset( &buf3, 0, sizeof( buf3)); rc = DosFindFirst( - path, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */ - &hdir, /* Address of the handle associated with this DosFindFirst request. */ - FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */ - &buf3, /* Result buffer. */ - sizeof( buf3), /* The length, in bytes, of pfindbuf. */ - &entries, /* Pointer to the number of entries: */ - FIL_STANDARD); /* The level of file information required. */ + path, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */ + &hdir, /* Address of the handle associated with this DosFindFirst request. */ + FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */ + &buf3, /* Result buffer. */ + sizeof( buf3), /* The length, in bytes, of pfindbuf. */ + &entries, /* Pointer to the number of entries: */ + FIL_STANDARD); /* The level of file information required. */ #ifdef _DEBUG printf( "_findfirst rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries, buf3.achName); @@ -64,16 +64,16 @@ long _findfirst( char* path, struct _finddata_t* dos_file) long _findnext( long hdir, struct _finddata_t* dos_file) { - APIRET rc; + APIRET rc; FILEFINDBUF3 buf3; - ULONG entries = 1; + ULONG entries = 1; memset( &buf3, 0, sizeof( buf3)); rc = DosFindNext( - hdir, - &buf3, /* Result buffer. */ - sizeof( buf3), /* The length, in bytes, of pfindbuf. */ - &entries); /* Pointer to the number of entries: */ + hdir, + &buf3, /* Result buffer. */ + sizeof( buf3), /* The length, in bytes, of pfindbuf. */ + &entries); /* Pointer to the number of entries: */ #ifdef _DEBUG printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries, buf3.achName); @@ -93,7 +93,7 @@ long _findnext( long hdir, struct _finddata_t* dos_file) void _findclose( long hdir) { - APIRET rc; + APIRET rc; rc = DosFindClose( hdir); #ifdef _DEBUG @@ -105,8 +105,8 @@ DIR* opendir( char* path) { DIR* dir = (DIR*) calloc( 1, sizeof( DIR)); char buffer[260]; - APIRET rc; - ULONG entries = 1; + APIRET rc; + ULONG entries = 1; strcpy( buffer, path); strcat( buffer, "*.*"); @@ -118,13 +118,13 @@ DIR* opendir( char* path) dir->hdir = HDIR_CREATE; memset( &dir->buf3, 0, sizeof( dir->buf3)); rc = DosFindFirst( - buffer, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */ - &dir->hdir, /* Address of the handle associated with this DosFindFirst request. */ - FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */ - &dir->buf3, /* Result buffer. */ - sizeof( dir->buf3), /* The length, in bytes, of pfindbuf. */ - &entries, /* Pointer to the number of entries: */ - FIL_STANDARD); /* The level of file information required. */ + buffer, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */ + &dir->hdir, /* Address of the handle associated with this DosFindFirst request. */ + FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */ + &dir->buf3, /* Result buffer. */ + sizeof( dir->buf3), /* The length, in bytes, of pfindbuf. */ + &entries, /* Pointer to the number of entries: */ + FIL_STANDARD); /* The level of file information required. */ #ifdef _DEBUG printf( "opendir rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, dir->buf3.achName); @@ -138,9 +138,9 @@ DIR* opendir( char* path) struct dirent* readdir( DIR* dir) { - APIRET rc; + APIRET rc; //FILEFINDBUF3 buf3; - ULONG entries = 1; + ULONG entries = 1; if (!dir->buf3.achName[0]) // file not found on previous query return NULL; @@ -151,10 +151,10 @@ struct dirent* readdir( DIR* dir) // query next file memset( &dir->buf3, 0, sizeof( dir->buf3)); rc = DosFindNext( - dir->hdir, - &dir->buf3, /* Result buffer. */ - sizeof( dir->buf3), /* The length, in bytes, of pfindbuf. */ - &entries); /* Pointer to the number of entries: */ + dir->hdir, + &dir->buf3, /* Result buffer. */ + sizeof( dir->buf3), /* The length, in bytes, of pfindbuf. */ + &entries); /* Pointer to the number of entries: */ #ifdef _DEBUG printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, dir->buf3.achName); @@ -168,7 +168,7 @@ struct dirent* readdir( DIR* dir) int closedir (DIR *dir) { - APIRET rc; + APIRET rc; rc = DosFindClose( dir->hdir); #ifdef _DEBUG diff --git a/mysys/my_os2dirsrch.h b/mysys/my_os2dirsrch.h index 2afe0f609f1..e894d27b576 100644 --- a/mysys/my_os2dirsrch.h +++ b/mysys/my_os2dirsrch.h @@ -30,9 +30,9 @@ extern "C" { struct _finddata_t { unsigned attrib; - //unsigned long time_create; /* -1 for FAT file systems */ - //unsigned long time_access; /* -1 for FAT file systems */ - //unsigned long time_write; + //unsigned long time_create; /* -1 for FAT file systems */ + //unsigned long time_access; /* -1 for FAT file systems */ + //unsigned long time_write; unsigned long size; char name[260]; //uint16 wr_date; @@ -42,10 +42,10 @@ struct _finddata_t struct dirent { //unsigned attrib; - //unsigned long time_create; /* -1 for FAT file systems */ - //unsigned long time_access; /* -1 for FAT file systems */ - //unsigned long time_write; - //unsigned long size; + //unsigned long time_create; /* -1 for FAT file systems */ + //unsigned long time_access; /* -1 for FAT file systems */ + //unsigned long time_write; + //unsigned long size; char d_name[260]; //uint16 wr_date; //uint16 wr_time; @@ -66,9 +66,9 @@ int closedir (DIR *); //#define _A_SUBDIR FILE_DIRECTORY //#define _A_RDONLY FILE_READONLY -//long _findfirst( char*, struct _finddata_t*); -//long _findnext( long, struct _finddata_t*); -//void _findclose( long); +//long _findfirst( char*, struct _finddata_t*); +//long _findnext( long, struct _finddata_t*); +//void _findclose( long); #ifdef __cplusplus_00 } diff --git a/mysys/my_os2dlfcn.c b/mysys/my_os2dlfcn.c index 0b0b5518eff..9c9a6061e8d 100644 --- a/mysys/my_os2dlfcn.c +++ b/mysys/my_os2dlfcn.c @@ -34,7 +34,7 @@ char* dlerror( void); void* dlsym( void* hmod, char* fn); void dlclose( void* hmod); -char fail[ 256]; +char fail[ 256]; void* dlopen( char* path, int flag) { @@ -56,7 +56,7 @@ char* dlerror( void) void* dlsym( void* hmod, char* fn) { APIRET rc; - PFN addr; + PFN addr; rc = DosQueryProcAddr( (HMODULE) hmod, 0l, fn, &addr); if (rc) diff --git a/mysys/my_os2file64.c b/mysys/my_os2file64.c index 2f41d344e32..bc24c92b87f 100644 --- a/mysys/my_os2file64.c +++ b/mysys/my_os2file64.c @@ -18,11 +18,11 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -void _OS2errno( APIRET rc); +void _OS2errno( APIRET rc); longlong _lseek64( int fd, longlong offset, int seektype); -int _lock64( int fd, int locktype, my_off_t start, - my_off_t length, myf MyFlags); -int _sopen64( const char *name, int oflag, int shflag, int mask); +int _lock64( int fd, int locktype, my_off_t start, + my_off_t length, myf MyFlags); +int _sopen64( const char *name, int oflag, int shflag, int mask); // // this class is used to define a global c++ variable, that @@ -34,52 +34,52 @@ class File64bit File64bit(); /* default constructor */ } initFile64bit; -static APIRET (* APIENTRY _DosOpenL)(PCSZ pszFileName, - PHFILE phf, - PULONG pulAction, - LONGLONG cbFile, - ULONG ulAttribute, - ULONG fsOpenFlags, - ULONG fsOpenMode, - PEAOP2 peaop2); -static APIRET (* APIENTRY _DosSetFilePtrL)(HFILE hFile, - LONGLONG ib, - ULONG method, - PLONGLONG ibActual); -static APIRET (* APIENTRY _DosSetFileLocksL)(HFILE hFile, - PFILELOCKL pflUnlock, - PFILELOCKL pflLock, - ULONG timeout, - ULONG flags); +static APIRET (* APIENTRY _DosOpenL)(PCSZ pszFileName, + PHFILE phf, + PULONG pulAction, + LONGLONG cbFile, + ULONG ulAttribute, + ULONG fsOpenFlags, + ULONG fsOpenMode, + PEAOP2 peaop2); +static APIRET (* APIENTRY _DosSetFilePtrL)(HFILE hFile, + LONGLONG ib, + ULONG method, + PLONGLONG ibActual); +static APIRET (* APIENTRY _DosSetFileLocksL)(HFILE hFile, + PFILELOCKL pflUnlock, + PFILELOCKL pflLock, + ULONG timeout, + ULONG flags); -#define EIO EINVAL +#define EIO EINVAL #define ESPIPE EBADSEEK static unsigned char const errno_tab[] = { - 0 , EINVAL, ENOENT, ENOENT, EMFILE, /* 0..4 */ - EACCES, EBADF, EIO, ENOMEM, EIO, /* 5..9 */ + 0 , EINVAL, ENOENT, ENOENT, EMFILE, /* 0..4 */ + EACCES, EBADF, EIO, ENOMEM, EIO, /* 5..9 */ EINVAL, ENOEXEC,EINVAL, EINVAL, EINVAL, /* 10..14 */ ENOENT, EBUSY, EXDEV, ENOENT, EROFS, /* 15..19 */ - EIO, EIO, EIO, EIO, EIO, /* 20..24 */ - EIO, EIO, EIO, ENOSPC, EIO, /* 25..29 */ - EIO, EIO, EACCES, EACCES, EIO, /* 30..34 */ - EIO, EIO, EIO, EIO, ENOSPC, /* 35..39 */ - EIO, EIO, EIO, EIO, EIO, /* 40..44 */ - EIO, EIO, EIO, EIO, EIO, /* 45..49 */ - EIO, EIO, EIO, EIO, EBUSY, /* 50..54 */ - EIO, EIO, EIO, EIO, EIO, /* 55..59 */ - EIO, ENOSPC, ENOSPC, EIO, EIO, /* 60..64 */ - EACCES, EIO, EIO, EIO, EIO, /* 65..69 */ - EIO, EIO, EIO, EROFS, EIO, /* 70..74 */ - EIO, EIO, EIO, EIO, EIO, /* 75..79 */ - EEXIST, EIO, ENOENT, EIO, EIO, /* 80..84 */ - EIO, EIO, EINVAL, EIO, EAGAIN, /* 85..89 */ - EIO, EIO, EIO, EIO, EIO, /* 90..94 */ - EINTR, EIO, EIO, EIO, EACCES, /* 95..99 */ + EIO, EIO, EIO, EIO, EIO, /* 20..24 */ + EIO, EIO, EIO, ENOSPC, EIO, /* 25..29 */ + EIO, EIO, EACCES, EACCES, EIO, /* 30..34 */ + EIO, EIO, EIO, EIO, ENOSPC, /* 35..39 */ + EIO, EIO, EIO, EIO, EIO, /* 40..44 */ + EIO, EIO, EIO, EIO, EIO, /* 45..49 */ + EIO, EIO, EIO, EIO, EBUSY, /* 50..54 */ + EIO, EIO, EIO, EIO, EIO, /* 55..59 */ + EIO, ENOSPC, ENOSPC, EIO, EIO, /* 60..64 */ + EACCES, EIO, EIO, EIO, EIO, /* 65..69 */ + EIO, EIO, EIO, EROFS, EIO, /* 70..74 */ + EIO, EIO, EIO, EIO, EIO, /* 75..79 */ + EEXIST, EIO, ENOENT, EIO, EIO, /* 80..84 */ + EIO, EIO, EINVAL, EIO, EAGAIN, /* 85..89 */ + EIO, EIO, EIO, EIO, EIO, /* 90..94 */ + EINTR, EIO, EIO, EIO, EACCES, /* 95..99 */ ENOMEM, EINVAL, EINVAL, ENOMEM, EINVAL, /* 100..104 */ - EINVAL, ENOMEM, EIO, EACCES, EPIPE, /* 105..109 */ + EINVAL, ENOMEM, EIO, EACCES, EPIPE, /* 105..109 */ ENOENT, E2BIG, ENOSPC, ENOMEM, EBADF, /* 110..114 */ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 115..119 */ EINVAL, EINVAL, EINVAL, ENOENT, EINVAL, /* 120..124 */ @@ -121,16 +121,16 @@ static unsigned char const errno_tab[] = EINVAL, EBUSY, EINVAL, ESRCH, EINVAL, /* 300..304 */ ESRCH, EINVAL, EINVAL, EINVAL, ESRCH, /* 305..309 */ EINVAL, ENOMEM, EINVAL, EINVAL, EINVAL, /* 310..314 */ - EINVAL, E2BIG, ENOENT, EIO, EIO, /* 315..319 */ + EINVAL, E2BIG, ENOENT, EIO, EIO, /* 315..319 */ EINVAL, EINVAL, EINVAL, EINVAL, EAGAIN, /* 320..324 */ - EINVAL, EINVAL, EINVAL, EIO, ENOENT, /* 325..329 */ + EINVAL, EINVAL, EINVAL, EIO, ENOENT, /* 325..329 */ EACCES, EACCES, EACCES, ENOENT, ENOMEM /* 330..334 */ }; /* * Initialize 64bit file access: dynamic load of WSeB API */ - File64bit :: File64bit() + File64bit :: File64bit() { HMODULE hDoscalls; @@ -156,7 +156,7 @@ static unsigned char const errno_tab[] = #endif } -void _OS2errno( APIRET rc) +void _OS2errno( APIRET rc) { if (rc >= sizeof (errno_tab)) errno = EINVAL; @@ -187,19 +187,19 @@ longlong _lseek64( int fd, longlong offset, int seektype) } inline _SetFileLocksL(HFILE hFile, - PFILELOCKL pflUnlock, - PFILELOCKL pflLock, - ULONG timeout, - ULONG flags) + PFILELOCKL pflUnlock, + PFILELOCKL pflLock, + ULONG timeout, + ULONG flags) { if (_DosSetFileLocksL) { APIRET rc; rc = _DosSetFileLocksL( hFile, pflUnlock, pflLock, timeout, flags); - // on FAT/HPFS/LAN a INVALID_PARAMETER is returned, seems that + // on FAT/HPFS/LAN a INVALID_PARAMETER is returned, seems that // only JFS can handle >2GB ranges. if (rc != 87) - return rc; + return rc; // got INVALID_PARAMETER, fallback to standard call } @@ -209,8 +209,8 @@ inline _SetFileLocksL(HFILE hFile, return DosSetFileLocks( hFile, &flUnlock, &flLock, timeout, flags); } -int _lock64( int fd, int locktype, my_off_t start, - my_off_t length, myf MyFlags) +int _lock64( int fd, int locktype, my_off_t start, + my_off_t length, myf MyFlags) { FILELOCKL LockArea = {0,0}, UnlockArea = {0,0}; ULONG readonly = 0; @@ -241,16 +241,16 @@ int _lock64( int fd, int locktype, my_off_t start, //printf( "fd %d, locktype %d, rc %d (dont_wait)\n", fd, locktype, rc); if (rc == 33) { /* Lock Violation */ - DBUG_PRINT("info",("Was locked, trying with timeout")); - rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 1 * 1000, readonly); - //printf( "fd %d, locktype %d, rc %d (dont_wait with timeout)\n", fd, locktype, rc); + DBUG_PRINT("info",("Was locked, trying with timeout")); + rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 1 * 1000, readonly); + //printf( "fd %d, locktype %d, rc %d (dont_wait with timeout)\n", fd, locktype, rc); } } else { while( rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly) && (rc == 33)) { - printf("."); - DosSleep(1 * 1000); + printf("."); + DosSleep(1 * 1000); } //printf( "fd %d, locktype %d, rc %d (wait2)\n", fd, locktype, rc); } @@ -264,9 +264,9 @@ int _lock64( int fd, int locktype, my_off_t start, return(-1); } -int sopen( const char *name, int oflag, int shflag, int mask) +int sopen( const char *name, int oflag, int shflag, int mask) { - int fail_errno; + int fail_errno; APIRET rc = 0; HFILE hf = 0; ULONG ulAction = 0; @@ -289,18 +289,18 @@ int sopen( const char *name, int oflag, int shflag, int mask) { if (oflag & O_EXCL) { - fsOpenFlags = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; - fail_errno = EEXIST; + fsOpenFlags = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; + fail_errno = EEXIST; } else if (oflag & O_TRUNC) - fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; + fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; else - fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; + fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; if (mask & S_IWRITE) - ulAttribute = FILE_NORMAL; + ulAttribute = FILE_NORMAL; else - ulAttribute = FILE_READONLY; + ulAttribute = FILE_READONLY; } else if (oflag & O_TRUNC) @@ -311,10 +311,10 @@ int sopen( const char *name, int oflag, int shflag, int mask) /* Try to open the file and handle errors. */ if (_DosOpenL) rc = _DosOpenL( name, &hf, &ulAction, cbFile, - ulAttribute, fsOpenFlags, fsOpenMode, NULL); + ulAttribute, fsOpenFlags, fsOpenMode, NULL); else rc = DosOpen( name, &hf, &ulAction, (LONG) cbFile, - ulAttribute, fsOpenFlags, fsOpenMode, NULL); + ulAttribute, fsOpenFlags, fsOpenMode, NULL); if (rc == ERROR_OPEN_FAILED) { @@ -334,7 +334,7 @@ int sopen( const char *name, int oflag, int shflag, int mask) return hf; } -int read( int fd, void *buffer, unsigned int count) +int read( int fd, void *buffer, unsigned int count) { APIRET rc; ULONG actual; @@ -350,7 +350,7 @@ int read( int fd, void *buffer, unsigned int count) return(-1); } -int write( int fd, const void *buffer, unsigned int count) +int write( int fd, const void *buffer, unsigned int count) { APIRET rc; ULONG actual; @@ -366,7 +366,7 @@ int write( int fd, const void *buffer, unsigned int count) return(-1); } -int close( int fd) +int close( int fd) { APIRET rc; ULONG actual; diff --git a/mysys/my_os2mutex.c b/mysys/my_os2mutex.c index 0ae6ae86d8c..718aa9f2932 100644 --- a/mysys/my_os2mutex.c +++ b/mysys/my_os2mutex.c @@ -72,8 +72,8 @@ pthread_mutex_destroy(pthread_mutex_t * mutex) int pthread_mutex_lock(pthread_mutex_t * mutex) { - int ret = 0; - int status = 0; + int ret = 0; + int status = 0; APIRET rc = 0; rc = DosRequestMutexSem(*mutex,SEM_INDEFINITE_WAIT); @@ -86,9 +86,9 @@ pthread_mutex_lock(pthread_mutex_t * mutex) int pthread_mutex_unlock(pthread_mutex_t * mutex) { - int ret = 0; + int ret = 0; APIRET rc = 0; - int status; + int status; rc = DosReleaseMutexSem(*mutex); diff --git a/mysys/my_os2thread.c b/mysys/my_os2thread.c index 89a3311c10b..6f196f43d75 100644 --- a/mysys/my_os2thread.c +++ b/mysys/my_os2thread.c @@ -31,9 +31,9 @@ static pthread_mutex_t THR_LOCK_thread; struct pthread_map { - HANDLE pthreadself; + HANDLE pthreadself; pthread_handler func; - void * param; + void * param; }; void win_pthread_init(void) @@ -57,7 +57,7 @@ static pthread_handler_decl(pthread_start,param) pthread_handler func=((struct pthread_map *) param)->func; void *func_param=((struct pthread_map *) param)->param; my_thread_init(); /* Will always succeed in windows */ - pthread_mutex_lock(&THR_LOCK_thread); /* Wait for beginthread to return */ + pthread_mutex_lock(&THR_LOCK_thread); /* Wait for beginthread to return */ win_pthread_self=((struct pthread_map *) param)->pthreadself; pthread_mutex_unlock(&THR_LOCK_thread); free((char*) param); /* Free param from create */ diff --git a/mysys/my_os2tls.c b/mysys/my_os2tls.c index 25d543d0768..1598fa34e2b 100644 --- a/mysys/my_os2tls.c +++ b/mysys/my_os2tls.c @@ -18,23 +18,23 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -DWORD TlsAlloc( void); -BOOL TlsFree( DWORD); -PVOID TlsGetValue( DWORD); -BOOL TlsSetValue( DWORD, PVOID); +DWORD TlsAlloc( void); +BOOL TlsFree( DWORD); +PVOID TlsGetValue( DWORD); +BOOL TlsSetValue( DWORD, PVOID); -#define TLS_MINIMUM_AVAILABLE 64 +#define TLS_MINIMUM_AVAILABLE 64 -PULONG tls_storage; /* TLS local storage */ -DWORD tls_bits[2]; /* TLS in-use bits */ -pthread_mutex_t tls_mutex; /* TLS mutex for in-use bits */ +PULONG tls_storage; /* TLS local storage */ +DWORD tls_bits[2]; /* TLS in-use bits */ +pthread_mutex_t tls_mutex; /* TLS mutex for in-use bits */ -DWORD TlsAlloc( void) +DWORD TlsAlloc( void) { DWORD index = -1; DWORD mask, tibidx; - int i; + int i; if (tls_storage == NULL) { @@ -43,12 +43,12 @@ DWORD TlsAlloc( void) // allocate memory for TLS storage rc = DosAllocThreadLocalMemory( 1, &tls_storage); if (rc) { - fprintf( stderr, "DosAllocThreadLocalMemory error: return code = %u\n", rc); + fprintf( stderr, "DosAllocThreadLocalMemory error: return code = %u\n", rc); } // create a mutex if (pthread_mutex_init( &tls_mutex, NULL)) - fprintf( stderr, "Failed to init TLS mutex\n"); + fprintf( stderr, "Failed to init TLS mutex\n"); } pthread_mutex_lock( &tls_mutex); @@ -56,18 +56,18 @@ DWORD TlsAlloc( void) tibidx = 0; if (tls_bits[0] == 0xFFFFFFFF) { if (tls_bits[1] == 0xFFFFFFFF) { - fprintf( stderr, "tid#%d, no more TLS bits available\n", _threadid); - pthread_mutex_unlock( &tls_mutex); - return -1; + fprintf( stderr, "tid#%d, no more TLS bits available\n", _threadid); + pthread_mutex_unlock( &tls_mutex); + return -1; } tibidx = 1; } for( i=0; i<32; i++) { mask = (1 << i); if ((tls_bits[ tibidx] & mask) == 0) { - tls_bits[ tibidx] |= mask; - index = (tibidx*32) + i; - break; + tls_bits[ tibidx] |= mask; + index = (tibidx*32) + i; + break; } } tls_storage[index] = 0; @@ -79,9 +79,9 @@ DWORD TlsAlloc( void) return index; } -BOOL TlsFree( DWORD index) +BOOL TlsFree( DWORD index) { - int tlsidx; + int tlsidx; DWORD mask; if (index >= TLS_MINIMUM_AVAILABLE) @@ -106,7 +106,7 @@ BOOL TlsFree( DWORD index) } -PVOID TlsGetValue( DWORD index) +PVOID TlsGetValue( DWORD index) { if (index >= TLS_MINIMUM_AVAILABLE) return NULL; @@ -122,7 +122,7 @@ PVOID TlsGetValue( DWORD index) return (PVOID) tls_array[ index]; } -BOOL TlsSetValue( DWORD index, PVOID val) +BOOL TlsSetValue( DWORD index, PVOID val) { // verify if memory has been allocated for this thread diff --git a/mysys/my_port.c b/mysys/my_port.c new file mode 100644 index 00000000000..a9778875850 --- /dev/null +++ b/mysys/my_port.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA */ + +/* + Small functions to make code portable +*/ + +#include "mysys_priv.h" + +#ifdef _AIX + +/* + On AIX, at least with gcc 3.1, the expression + '(double) (ulonglong) var' doesn't always work for big unsigned + integers like '18446744073709551615'. The end result is that the + high bit is simply dropped. (probably bug in gcc optimizations) + Handling the conversion in a sub function seems to work. +*/ + + + +double my_longlong2double(unsigned long long nr) +{ + return (double) nr; +} +#endif /* _AIX */ diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h index 20fda270658..2049347cb36 100644 --- a/mysys/mysys_priv.h +++ b/mysys/mysys_priv.h @@ -23,10 +23,10 @@ #endif #ifdef THREAD +#include extern pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache, THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_net,THR_LOCK_charset; extern pthread_mutex_t LOCK_bitmap; -#else /* THREAD */ -#define pthread_mutex_lock(A) -#define pthread_mutex_unlock(A) +#else +#include #endif diff --git a/mysys/thr_rwlock.c b/mysys/thr_rwlock.c index 866948a1c23..d4fe79a06ac 100644 --- a/mysys/thr_rwlock.c +++ b/mysys/thr_rwlock.c @@ -18,7 +18,6 @@ /* Synchronization - readers / writer thread locks */ #include "mysys_priv.h" -#include #if defined(THREAD) && !defined(HAVE_PTHREAD_RWLOCK_RDLOCK) && !defined(HAVE_RWLOCK_INIT) /* diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 5e6d4b5f50c..2bea014519c 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -267,43 +267,6 @@ innobase_mysql_print_thd( thd = (THD*) input_thd; - buf += sprintf(buf, "MySQL thread id %lu, query id %lu", - thd->thread_id, thd->query_id); - if (thd->host) { - buf += sprintf(buf, " %.30s", thd->host); - } - - if (thd->ip) { - buf += sprintf(buf, " %.20s", thd->ip); - } - - if (thd->user) { - buf += sprintf(buf, " %.20s", thd->user); - } - - if (thd->proc_info) { - buf += sprintf(buf, " %.50s", thd->proc_info); - } - - if (thd->query) { - buf += sprintf(buf, "\n%.150s", thd->query); - } - - buf += sprintf(buf, "\n"); - -#ifdef notdefined - /* August 8, 2002 - Revert these changes because they make control characters sometimes - appear in the output and scramble it: - the reason is that the last character of the ouptput will be - '\n', not the null character '\0'. We do not know where the output - ends in buf! - - On platforms (what are those?) where sprintf does not work - we should define sprintf as 'my_emulated_sprintf'; InnoDB code - contains lots of sprintfs, it does not help to remove them from - just a single file. */ - /* We can't use value of sprintf() as this is not portable */ buf+= my_sprintf(buf, (buf, "MySQL thread id %lu", @@ -337,9 +300,8 @@ innobase_mysql_print_thd( *buf++='\n'; buf=strnmov(buf, thd->query, 150); } - *buf='\n'; - /* Here we should add '\0' to the end of output to mark its end */ -#endif + buf[0]='\n'; + buf[1]=0; } } diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 86e2ef29564..f17c8af3519 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -494,12 +494,7 @@ Item_func_if::fix_length_and_dec() decimals=max(args[1]->decimals,args[2]->decimals); enum Item_result arg1_type=args[1]->result_type(); enum Item_result arg2_type=args[2]->result_type(); - bool null1=args[1]->null_value; - bool null2=args[2]->null_value; - if (null1 && !null2) - arg1_type=arg2_type; - else if (!null1 && null2) - arg2_type=arg1_type; + binary=1; if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d73ec9fc0d6..150ad8ea379 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -43,6 +43,8 @@ #if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ) #define HAVE_CLOSE_SERVER_SOCK 1 void close_server_sock(); +#else +#define close_server_sock() #endif extern "C" { // Because of SCO 3.2V4.2 @@ -465,9 +467,7 @@ static void close_connections(void) if (error != 0 && !count++) sql_print_error("Got error %d from pthread_cond_timedwait",error); #endif -#if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ) close_server_sock(); -#endif } (void) pthread_mutex_unlock(&LOCK_thread_count); #endif /* __WIN__ */ @@ -598,18 +598,26 @@ if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe) void close_server_sock() { DBUG_ENTER("close_server_sock"); + if (ip_sock != INVALID_SOCKET) { - DBUG_PRINT("info",("closing TCP/IP socket")); + DBUG_PRINT("info",("calling shutdown on TCP/IP socket")); VOID(shutdown(ip_sock,2)); +#ifdef NOT_USED + /* + The following code is disabled as it cases MySQL to hang on + AIX 4.3 during shutdown + */ + DBUG_PRINT("info",("calling closesocket on TCP/IP socket")); VOID(closesocket(ip_sock)); +#endif ip_sock=INVALID_SOCKET; } if (unix_sock != INVALID_SOCKET) { - DBUG_PRINT("info",("closing Unix socket")); + DBUG_PRINT("info",("calling shutdown on unix socket")); VOID(shutdown(unix_sock,2)); - VOID(closesocket(unix_sock)); + DBUG_PRINT("info",("calling closesocket on unix socket")); VOID(unlink(mysql_unix_port)); unix_sock=INVALID_SOCKET; } @@ -621,7 +629,8 @@ void kill_mysql(void) { DBUG_ENTER("kill_mysql"); #ifdef SIGNALS_DONT_BREAK_READ - close_server_sock(); /* force accept to wake up */ + abort_loop=1; // Break connection loops + close_server_sock(); // Force accept to wake up #endif #if defined(__WIN__) { @@ -647,10 +656,9 @@ void kill_mysql(void) DBUG_PRINT("quit",("After pthread_kill")); shutdown_in_progress=1; // Safety if kill didn't work #ifdef SIGNALS_DONT_BREAK_READ - if (!abort_loop) + if (!kill_in_progress) { pthread_t tmp; - abort_loop=1; if (pthread_create(&tmp,&connection_attrib, kill_server_thread, (void*) 0)) sql_print_error("Error: Can't create thread to kill server"); @@ -1220,7 +1228,7 @@ static void sig_reload(int signo) static void sig_kill(int signo) { - if (!abort_loop) + if (!kill_in_progress) { abort_loop=1; // mark abort for threads kill_server((void*) signo); From 9b1930152db6ecd30b8cbcc7200af2baf7f82295 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Aug 2002 03:33:46 +0300 Subject: [PATCH 15/16] Changed IF(expr, column, NULL) to take type from column Fixed some windows portability problems and removed some compiler warnings Cleaned up QUOTE() function and fixed bug in \0 and \Z handling. Docs/manual.texi: Changelog Added information about new IF() behaviour. libmysql/libmysql.def: Removed mysql_ssl_clear myisam/mi_dynrec.c: Minor cleanup mysql-test/r/func_str.result: Added more tests for QUOTE mysql-test/t/func_str.test: Added more tests for QUOTE mysys/mf_iocache.c: Removed compiler warnings sql/ha_innodb.cc: Added missing null to generated string. sql/item_cmpfunc.cc: Changed IF(expr, column, NULL) to take type from column sql/item_strfunc.cc: Cleaned up QUOTE() function and fixed bug in \0 and \Z handling. sql/log.cc: Minor cleanup sql/mysql_priv.h: Fixed problem with opt_enable_named_pipe sql/mysqld.cc: Fixed problem with opt_enable_named_pipe Fixed some syntax errors in windows code sql/set_var.cc: Removed compiler warnings sql/slave.cc: Removed compiler warnings sql/sql_show.cc: Removed compiler warnings --- Docs/manual.texi | 11 +++- libmysql/libmysql.def | 1 - myisam/mi_dynrec.c | 1 - mysql-test/r/func_str.result | 3 + mysql-test/t/func_str.test | 1 + mysys/mf_iocache.c | 5 +- sql/ha_innodb.cc | 3 +- sql/item_cmpfunc.cc | 27 +++++++-- sql/item_strfunc.cc | 103 ++++++++++++++++++++++++++--------- sql/log.cc | 11 ++-- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 28 +++++----- sql/set_var.cc | 4 +- sql/slave.cc | 8 +-- sql/sql_show.cc | 3 +- 15 files changed, 144 insertions(+), 67 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 90c697402d4..a10c53af7a8 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -31071,6 +31071,10 @@ mysql> SELECT IF(STRCMP('test','test1'),'no','yes'); -> 'no' @end example +If @code{expr2} or @code{expr3} is explicitely @code{NULL} then the +result type of the @code{IF()} function is the type of the not +@code{NULL} column. (This behavior is new in MySQL 4.0.3). + @code{expr1} is evaluated as an integer value, which means that if you are testing floating-point or string values, you should do so using a comparison operation: @@ -50226,10 +50230,13 @@ each individual 4.0.x release. @itemize @bullet @item -Fixed security bug in database hash +Changed behavior of @code{IF(condition,column,NULL)} so that it returns +the value of the column type. +@item Made @code{safe_mysqld} a symlink to @code{mysqld_safe} in binary distribution. @item -Fixed security bug when having an empty databasename in the user.db table. +Fixed security bug when having an empty databasename in the @code{user.db} +table. @item Fixed some problems with @code{CREATE TABLE ... SELECT function()}. @item diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def index 988f2b09195..46ca5acafcc 100644 --- a/libmysql/libmysql.def +++ b/libmysql/libmysql.def @@ -89,7 +89,6 @@ EXPORTS mysql_read_query_result mysql_real_escape_string mysql_ssl_set - mysql_ssl_clear mysql_real_connect mysql_master_query mysql_master_send_query diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index 8a9ca8aab34..60e6fc0519a 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -1097,7 +1097,6 @@ int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def, const byte *record, my_off_t pos) { byte *rec_buff,*old_record; - uint alloced_rec_buff_length; int error; DBUG_ENTER("_mi_cmp_dynamic_unique"); diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 56eb9c632f7..dd5e5191536 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -152,6 +152,9 @@ quote('\'\"\\test') select quote(concat('abc\'', '\\cba')); quote(concat('abc\'', '\\cba')) 'abc\'\\cba' +select quote(1/0), quote('\0\Z'); +quote(1/0) quote('\0\Z') +NULL '\0\Z' select reverse(""); reverse("") diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 89212a74e04..daf5587b450 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -63,6 +63,7 @@ select decode(encode("abcdef","monty"),"monty")="abcdef"; select quote('\'\"\\test'); select quote(concat('abc\'', '\\cba')); +select quote(1/0), quote('\0\Z'); # # Wrong usage of functions diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index a4bf09ef7a7..6f7fb907ad5 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -521,8 +521,9 @@ int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count) length=(length <= info->read_length) ? length + IO_ROUND_DN(info->read_length - length) : length - IO_ROUND_UP(length - info->read_length) ; - if (info->type != READ_FIFO && (length > info->end_of_file - pos_in_file)) - length=info->end_of_file - pos_in_file; + if (info->type != READ_FIFO && + (length > (uint) (info->end_of_file - pos_in_file))) + length= (uint) (info->end_of_file - pos_in_file); if (length == 0) { info->error=(int) read_len; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 038da716abe..5d7d083ef91 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -306,7 +306,8 @@ innobase_mysql_print_thd( *buf++=' '; buf=strnmov(buf, thd->query, 150); } - *buf='\n'; + buf[0]='\n'; + buf[1]=0; } } diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 90e8a0e451f..19d64812f34 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -486,6 +486,7 @@ Item_func_ifnull::val_str(String *str) return res; } + void Item_func_if::fix_length_and_dec() { @@ -494,16 +495,32 @@ Item_func_if::fix_length_and_dec() decimals=max(args[1]->decimals,args[2]->decimals); enum Item_result arg1_type=args[1]->result_type(); enum Item_result arg2_type=args[2]->result_type(); - binary=1; - if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT) + bool null1=args[1]->null_value; + bool null2=args[2]->null_value; + + if (null1) + { + cached_result_type= arg2_type; + binary= args[1]->binary; + } + else if (null2) + { + cached_result_type= arg2_type; + binary= args[2]->binary; + } + else if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT) { cached_result_type = STRING_RESULT; binary=args[1]->binary | args[2]->binary; } - else if (arg1_type == REAL_RESULT || arg2_type == REAL_RESULT) - cached_result_type = REAL_RESULT; else - cached_result_type=arg1_type; // Should be INT_RESULT + { + binary=1; // Number + if (arg1_type == REAL_RESULT || arg2_type == REAL_RESULT) + cached_result_type = REAL_RESULT; + else + cached_result_type=arg1_type; // Should be INT_RESULT + } } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 7b28a9d4550..720313f4be7 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2071,41 +2071,90 @@ String* Item_func_inet_ntoa::val_str(String* str) return str; } +/* + QUOTE() function returns argument string in single quotes suitable for + using in a SQL statement. + + DESCRIPTION + Adds a \ before all characters that needs to be escaped in a SQL string. + We also escape '^Z' (END-OF-FILE in windows) to avoid probelms when + running commands from a file in windows. + + This function is very useful when you want to generate SQL statements + + RETURN VALUES + str Quoted string + NULL Argument to QUOTE() was NULL or out of memory. +*/ + #define get_esc_bit(mask, num) (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7)) -/* - QUOTE() function returns argument string in single quotes, - also adds a \ before \, ' CHAR(0) and CHAR(24) -*/ String *Item_func_quote::val_str(String *str) { - static char escmask[32] = {0x01, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - String *arg= args[0]->val_str(str); - char *from, *to, *end; - uint delta= 2; /* for beginning and ending ' signs */ + /* + Bit mask that has 1 for set for the position of the following characters: + 0, \, ' and ^Z + */ - if (!arg) - goto null; - - for (from= (char*) arg->ptr(), end= from + arg->length(); from < end; from++) - delta+= get_esc_bit(escmask, *from); - - if (str->alloc(arg->length() + delta)) - goto null; - to= (char*) str->ptr() + arg->length() + delta - 1; - *to--= '\''; - for (end= (char*) arg->ptr(), from= end + arg->length() - 1; from >= end; - from--, to--) + static char escmask[32]= { - *to= *from; - if (get_esc_bit(escmask, *from)) - *--to= '\\'; + 0x01, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + char *from, *to, *end, *start; + String *arg= args[0]->val_str(str); + uint arg_length, new_length; + if (!arg) // Null argument + goto null; + arg_length= arg->length(); + new_length= arg_length+2; /* for beginning and ending ' signs */ + + for (from= (char*) arg->ptr(), end= from + arg_length; from < end; from++) + new_length+= get_esc_bit(escmask, *from); + + /* + We have to use realloc() instead of alloc() as we want to keep the + old result in str + */ + if (str->realloc(new_length)) + goto null; + + /* + As 'arg' and 'str' may be the same string, we must replace characters + from the end to the beginning + */ + to= (char*) str->ptr() + new_length - 1; + *to--= '\''; + for (start= (char*) arg->ptr() ; end-- != start; to--) + { + /* + We can't use the bitmask here as we want to replace \O and ^Z with 0 + and Z + */ + switch (*end) { + case 0: + *to--= '0'; + *to= '\\'; + break; + case '\032': + *to--= 'Z'; + *to= '\\'; + break; + case '\'': + case '\\': + *to--= *end; + *to= '\\'; + break; + default: + *to= *end; + break; + } } *to= '\''; - str->length(arg->length() + delta); + str->length(new_length); return str; null: diff --git a/sql/log.cc b/sql/log.cc index b6a07d9021f..06007a081ea 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -451,7 +451,6 @@ int MYSQL_LOG::find_log_pos(LOG_INFO *linfo, const char *log_name, } } -err: if (need_lock) pthread_mutex_unlock(&LOCK_index); DBUG_RETURN(error); @@ -602,15 +601,15 @@ err: - Read the first file name from the index file and store in rli->linfo RETURN VALUES - 0 ok - 1 error + 0 ok + LOG_INFO_EOF End of log-index-file found + LOG_INFO_SEEK Could not allocate IO cache + LOG_INFO_IO Got IO error while reading file */ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli) { - File file; - bool error= 1; - my_off_t offset, init_offset; + int error; DBUG_ENTER("purge_first_log"); /* diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 18a006b5a16..e5a4f0f271f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -640,7 +640,7 @@ extern bool opt_using_transactions, use_temp_pool, mysql_embedded; extern bool using_update_log, opt_large_files; extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log; extern bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types; -extern bool opt_disable_networking, opt_skip_show_db; +extern bool opt_disable_networking, opt_skip_show_db, opt_enable_named_pipe; extern bool volatile abort_loop, shutdown_in_progress, grant_option; extern uint volatile thread_count, thread_running, global_read_lock; extern my_bool opt_safe_show_db, opt_local_infile, lower_case_table_names; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7ac2b009d15..3b998d61207 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -181,7 +181,6 @@ static SECURITY_DESCRIPTOR sdPipeDescriptor; static HANDLE hPipe = INVALID_HANDLE_VALUE; static pthread_cond_t COND_handler_count; static uint handler_count; -static bool opt_enable_named_pipe = 0; #endif #ifdef __WIN__ static bool opt_console=0, start_mode=0, use_opt_args; @@ -258,6 +257,7 @@ ulong back_log, connect_timeout, concurrency; char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], time_zone[30]; bool opt_log, opt_update_log, opt_bin_log, opt_slow_log; bool opt_disable_networking=0, opt_skip_show_db=0; +bool opt_enable_named_pipe= 0; my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol; static bool opt_do_pstack = 0; @@ -1045,8 +1045,8 @@ static void server_init(void) PIPE_READMODE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, - (int) global_variables.net_buffer_length, - (int) global_variables.net_buffer_length, + (int) global_system_variables.net_buffer_length, + (int) global_system_variables.net_buffer_length, NMPWAIT_USE_DEFAULT_WAIT, &saPipeSecurity )) == INVALID_HANDLE_VALUE) { @@ -2275,7 +2275,8 @@ int main(int argc, char **argv) if (Service.IsService(argv[1])) { /* start an optional service */ - event_name = load_default_groups[0]= argv[1]; + event_name= argv[1]; + load_default_groups[0]= argv[1]; start_mode= 1; Service.Init(event_name, mysql_service); return 0; @@ -2285,8 +2286,8 @@ int main(int argc, char **argv) { /* Add service name after filename */ uint length=strlen(file_path); - strxnmov(file_path + length, sizeof(file_path)-length-2, " ", - argv[2], NullS)= '\0'; + *strxnmov(file_path + length, sizeof(file_path)-length-2, " ", + argv[2], NullS)= '\0'; if (!default_service_handling(argv, argv[2], argv[2], file_path)) return 0; @@ -2309,8 +2310,8 @@ int main(int argc, char **argv) mysqld --install-manual mysqldopt --defaults-file=c:\miguel\my.ini */ uint length=strlen(file_path); - strxnmov(file_path + length, sizeof(file_path)-length-2, " ", - argv[3], " ", argv[2], NullS)= '\0'; + *strxnmov(file_path + length, sizeof(file_path)-length-2, " ", + argv[3], " ", argv[2], NullS)= '\0'; if (!default_service_handling(argv, argv[2], argv[2], file_path)) return 0; } @@ -2724,8 +2725,8 @@ pthread_handler_decl(handle_connections_namedpipes,arg) PIPE_READMODE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, - (int) global_variables.net_buffer_length, - (int) global_variables.net_buffer_length, + (int) global_system_variables.net_buffer_length, + (int) global_systenm_ariables.net_buffer_length, NMPWAIT_USE_DEFAULT_WAIT, &saPipeSecurity )) == INVALID_HANDLE_VALUE ) @@ -2742,8 +2743,8 @@ pthread_handler_decl(handle_connections_namedpipes,arg) PIPE_READMODE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, - (int) global_variables.net_buffer_length, - (int) global_variables.net_buffer_length, + (int) global_system_variables.net_buffer_length, + (int) global_system_variables.net_buffer_length, NMPWAIT_USE_DEFAULT_WAIT, &saPipeSecurity)) == INVALID_HANDLE_VALUE) @@ -4446,7 +4447,8 @@ static void fix_paths(void) } char *end=convert_dirname(buff, opt_mysql_tmpdir, NullS); - if (!(mysql_tmpdir= my_memdup(buff,(uint) (end-buff)+1, MYF(MY_FAE)))) + if (!(mysql_tmpdir= my_memdup((byte*) buff,(uint) (end-buff)+1, + MYF(MY_FAE)))) exit(1); if (!slave_load_tmpdir) { diff --git a/sql/set_var.cc b/sql/set_var.cc index d471c0b18ba..87417354b99 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -669,7 +669,7 @@ bool sys_var_thd_ulong::update(THD *thd, set_var *var) { /* Lock is needed to make things safe on 32 bit systems */ pthread_mutex_lock(&LOCK_global_system_variables); - global_system_variables.*offset=tmp; + global_system_variables.*offset= (ulong) tmp; pthread_mutex_unlock(&LOCK_global_system_variables); } else @@ -998,7 +998,7 @@ bool sys_var_slave_skip_counter::update(THD *thd, set_var *var) if (!active_mi->rli.slave_running) { pthread_mutex_lock(&active_mi->rli.data_lock); - active_mi->rli.slave_skip_counter= var->value->val_int(); + active_mi->rli.slave_skip_counter= (ulong) var->value->val_int(); pthread_mutex_unlock(&active_mi->rli.data_lock); } pthread_mutex_unlock(&active_mi->rli.run_lock); diff --git a/sql/slave.cc b/sql/slave.cc index e5be443428f..9873831cd28 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -855,7 +855,7 @@ static int check_master_version(MYSQL* mysql, MASTER_INFO* mi) errmsg = "Master reported unrecognized MySQL version"; break; } -err: + if (errmsg) { sql_print_error(errmsg); @@ -874,7 +874,7 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db, TABLE_LIST tables; int error= 1; handler *file; - uint save_options; + ulong save_options; if (packet_len == packet_error) { @@ -903,7 +903,7 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db, /* we do not want to log create table statement */ save_options = thd->options; - thd->options &= ~(ulong) OPTION_BIN_LOG; + thd->options &= ~(ulong) (OPTION_BIN_LOG); thd->proc_info = "Creating table from master dump"; // save old db in case we are creating in a different database char* save_db = thd->db; @@ -2642,7 +2642,7 @@ bool flush_relay_log_info(RELAY_LOG_INFO* rli) *pos++='\n'; pos=longlong2str(rli->master_log_pos, pos, 10); *pos='\n'; - if (my_b_write(file, buff, (ulong) (pos-buff)+1)) + if (my_b_write(file, (byte*) buff, (ulong) (pos-buff)+1)) error=1; if (flush_io_cache(file)) error=1; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6041132bd20..bf9abaaa32d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1152,7 +1152,6 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, String packet2(buff,sizeof(buff)); List field_list; CONVERT *convert=thd->variables.convert_set; - ulong offset; DBUG_ENTER("mysqld_show"); field_list.push_back(new Item_empty_string("Variable_name",30)); @@ -1173,7 +1172,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, if (show_type == SHOW_SYS) { show_type= ((sys_var*) value)->type(); - value= ((sys_var*) value)->value_ptr(thd, value_type); + value= (char*) ((sys_var*) value)->value_ptr(thd, value_type); } switch (show_type) { From 689a43874659ca5714edcd5effd3dcef2e3930cb Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Aug 2002 07:02:08 +0300 Subject: [PATCH 16/16] Fixes after last merge mysql-test/r/func_if.result: Fixed results after merge sql/ha_innodb.cc: fixed typo after merge --- mysql-test/r/func_if.result | 6 ++++++ sql/ha_innodb.cc | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 16fb0358d51..0ab41258091 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -46,3 +46,9 @@ select sum(if(num is null,0.00,num)) from t1; sum(if(num is null,0.00,num)) 144.54 drop table t1; +create table t1 (x int, y int); +insert into t1 values (0,6),(10,16),(20,26),(30,10),(40,46),(50,56); +select min(if(y -x > 5,y,NULL)), max(if(y - x > 5,y,NULL)) from t1; +min(if(y -x > 5,y,NULL)) max(if(y - x > 5,y,NULL)) +6 56 +drop table t1; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index bd03e9cffd3..97dc26df184 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -309,7 +309,7 @@ innobase_mysql_print_thd( buf[0]='\n'; buf[1]=0; - ut_a(strlen(old_buf) < 400); + ut_a(strlen(buf) < 400); } }