From 666342d312f16e22117a5d1e5a9106ad81d0850a Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 8 Aug 2002 20:09:57 +0200 Subject: - portability fix for AIX in include/my_sys.h: define alloca as a compiler builtin when using gcc --- 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 -- cgit v1.2.1 From 1a264ceb3442c02f64a6a8f071ad5f3f69c2b484 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Thu, 8 Aug 2002 21:43:46 +0300 Subject: Reverted Heikkis patch as his was not portable. 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); } -- cgit v1.2.1 From ea3fe233e3597d506c7f0c2e50f598afc99e3570 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Thu, 8 Aug 2002 22:09:25 +0300 Subject: Portability fix for AIX --- 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; -- cgit v1.2.1 From 6e87dc118c470ffe61497d0f85488f6e0d96c45d Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 9 Aug 2002 10:17:54 +0300 Subject: 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\ -- cgit v1.2.1 From 933417c1fed0b0d8ff9eb27ba7ce3d9086a470a7 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 9 Aug 2002 15:06:59 +0300 Subject: 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 } } -- cgit v1.2.1 From edf3929cd589d150adccefc754a979ce7e5d7e36 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 9 Aug 2002 15:34:23 +0300 Subject: ha_innobase.cc, trx0trx.h, lock0lock.c, trx0trx.c: 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 } } -- cgit v1.2.1 From a80d185e403720d060aa5c61a09e962e0abfb1f8 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Fri, 9 Aug 2002 23:14:02 +0300 Subject: 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) { -- cgit v1.2.1 From 7d33814c1bfb33e5699ab7b77a3386a735139377 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Sat, 10 Aug 2002 01:47:51 +0200 Subject: 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 | 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 -- cgit v1.2.1 From 50958d6237e52f6683bf2ac4d7abe889dbc71540 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Sat, 10 Aug 2002 02:08:41 +0200 Subject: 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 | 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. -- cgit v1.2.1 From 2ff90322442d23ba11142e256c16b0000ed3c981 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Sat, 10 Aug 2002 16:38:30 +0300 Subject: removal of lines that make problems with texi --- 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 -- cgit v1.2.1 From 0005f28b4ec6fdc73c83ea430f53f74103b26239 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Sat, 10 Aug 2002 22:08:00 +0300 Subject: 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); -- cgit v1.2.1 From bee3f072e40dbdd40b45de1988309fb4bb9f6546 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Sun, 11 Aug 2002 18:49:47 +0300 Subject: 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/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"); - -#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); - } + buf += ut_sprintf(buf, "\n"); - 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); -- cgit v1.2.1 From 1239863b64521d15bf22e96b60eace193c35ab08 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Mon, 12 Aug 2002 00:17:39 +0300 Subject: trx0trx.h, trx0trx.c, ha_innobase.cc, ha_innobase.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(); }; -- cgit v1.2.1 From b779b63862990857c2dd0456196529364ff02d1a Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Mon, 12 Aug 2002 03:28:02 +0300 Subject: 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 | 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 | 144 +++++++++++++++++++++---------------------- 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, 240 insertions(+), 239 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); - -#define EIO EINVAL +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 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); -- cgit v1.2.1