From a13d1b2faf81d8dc46b16bad0c63112343e61506 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Fri, 29 Nov 2002 17:36:36 +0100 Subject: [PATCH 1/8] - removed unused variable $defaults - parse mysql.server section in my.cnf as well --- support-files/mysql.server.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 6c3fa9f1127..f438899b3bf 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -79,7 +79,8 @@ parse_arguments() { done } -# Get arguments from the my.cnf file, groups [mysqld] and [mysql_server] +# Get arguments from the my.cnf file, +# groups [mysqld] [mysql_server] and [mysql.server] if test -x ./bin/my_print_defaults then print_defaults="./bin/my_print_defaults" @@ -117,7 +118,7 @@ else test -z "$print_defaults" && print_defaults="my_print_defaults" fi -parse_arguments `$print_defaults $defaults mysqld mysql_server` +parse_arguments `$print_defaults mysqld mysql_server mysql.server` # Safeguard (relative paths, core dumps..) cd $basedir From 2c7c19769a989f2161754538aa6ae232420ac80e Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Mon, 2 Dec 2002 15:12:56 +0200 Subject: [PATCH 2/8] moving fix elsewhere ... --- sql/sql_show.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 028d6b055ff..a8567112fe9 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1145,7 +1145,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables) switch (variables[i].type){ case SHOW_LONG: case SHOW_LONG_CONST: - net_store_data(&packet2,(longlong) *(ulong*) variables[i].value); + net_store_data(&packet2,(int32) *(ulong*) variables[i].value); break; case SHOW_BOOL: net_store_data(&packet2,(ulong) *(bool*) variables[i].value ? From 9b331dc3544d03e2d1613b4fb059335527b46cb5 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Mon, 2 Dec 2002 15:33:16 +0200 Subject: [PATCH 3/8] Proper fix for SHOW VARS on 64-bit systems --- sql/mysqld.cc | 2 +- sql/sql_show.cc | 5 ++++- sql/structs.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f67fa8afd8c..6aa41f9f800 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3110,7 +3110,7 @@ struct show_var_st init_vars[]= { #endif {"interactive_timeout", (char*) &net_interactive_timeout, SHOW_LONG}, {"join_buffer_size", (char*) &join_buff_size, SHOW_LONG}, - {"key_buffer_size", (char*) &keybuff_size, SHOW_LONG}, + {"key_buffer_size", (char*) &keybuff_size, SHOW_LONG_AS_LONGLONG}, {"language", language, SHOW_CHAR}, {"large_files_support", (char*) &opt_large_files, SHOW_BOOL}, #ifdef HAVE_MLOCKALL diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a8567112fe9..12979f77e56 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1145,7 +1145,10 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables) switch (variables[i].type){ case SHOW_LONG: case SHOW_LONG_CONST: - net_store_data(&packet2,(int32) *(ulong*) variables[i].value); + net_store_data(&packet2,(uint32) *(ulong*) variables[i].value); + break; + case SHOW_LONG_AS_LONGLONG: + net_store_data(&packet2,(longlong) *(ulong*) variables[i].value); break; case SHOW_BOOL: net_store_data(&packet2,(ulong) *(bool*) variables[i].value ? diff --git a/sql/structs.h b/sql/structs.h index 36f503312c0..90924b842d6 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -125,7 +125,7 @@ typedef struct { enum SHOW_TYPE { SHOW_LONG,SHOW_CHAR,SHOW_INT,SHOW_CHAR_PTR,SHOW_BOOL, SHOW_MY_BOOL,SHOW_OPENTABLES,SHOW_STARTTIME,SHOW_QUESTION, - SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE}; + SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_LONG_AS_LONGLONG}; enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED}; From 1935183975ff5be14cfb3a2c0454fbb09cf384bf Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 4 Dec 2002 16:16:06 +0100 Subject: [PATCH 4/8] - Portability fixes for HP compiler on HPUX11 (backport from 4.0 tree) - sql_analyse.cc: Fixed bug in decimal handling --- configure.in | 6 ++++++ libmysql/password.c | 2 +- mysys/hash.c | 15 ++++++++++----- mysys/my_static.c | 2 +- mysys/my_static.h | 2 +- mysys/my_tempnam.c | 6 ++++++ sql/sql_analyse.cc | 2 +- 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/configure.in b/configure.in index 3fb495281a0..3a5c1a56408 100644 --- a/configure.in +++ b/configure.in @@ -893,6 +893,12 @@ case $SYSTEM_TYPE in echo "Using --with-named-thread=-lpthread" with_named_thread="-lpthread" fi + # Fixes for HPUX 11.0 compiler + if test "$ac_cv_prog_gcc" = "no" + then + CFLAGS="$CFLAGS +DD64 -DHAVE_BROKEN_INLINE" + CXXFLAGS="$CXXFLAGS +DD64 +O2" + fi ;; *rhapsody*) if test "$ac_cv_prog_gcc" = "yes" diff --git a/libmysql/password.c b/libmysql/password.c index 0fd5861873a..71ed68c6b2c 100644 --- a/libmysql/password.c +++ b/libmysql/password.c @@ -92,7 +92,7 @@ void make_scrambled_password(char *to,const char *password) sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]); } -static inline uint char_val(char X) +static inline unsigned int char_val(char X) { return (uint) (X >= '0' && X <= '9' ? X-'0' : X >= 'A' && X <= 'Z' ? X-'A'+10 : diff --git a/mysys/hash.c b/mysys/hash.c index eb74b1f30dd..602823e6d43 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -83,7 +83,12 @@ void hash_free(HASH *hash) /* some helper functions */ -inline byte* +/* + This function is char* instead of byte* as HPUX11 compiler can't + handle inline functions that are not defined as native types +*/ + +inline char* hash_key(HASH *hash,const byte *record,uint *length,my_bool first) { if (hash->get_key) @@ -104,7 +109,7 @@ static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax, uint maxlength) { uint length; - byte *key=hash_key(hash,pos->data,&length,0); + byte *key= (byte*) hash_key(hash,pos->data,&length,0); return hash_mask((*hash->calc_hashnr)(key,length),buffmax,maxlength); } @@ -183,10 +188,10 @@ uint calc_hashnr_caseup(const byte *key, uint len) #ifndef __SUNPRO_C /* SUNPRO can't handle this */ inline #endif -uint rec_hashnr(HASH *hash,const byte *record) +unsigned int rec_hashnr(HASH *hash,const byte *record) { uint length; - byte *key=hash_key(hash,record,&length,0); + byte *key= (byte*) hash_key(hash,record,&length,0); return (*hash->calc_hashnr)(key,length); } @@ -273,7 +278,7 @@ static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink) static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length) { uint rec_keylength; - byte *rec_key=hash_key(hash,pos->data,&rec_keylength,1); + byte *rec_key= (byte*) hash_key(hash,pos->data,&rec_keylength,1); return (length && length != rec_keylength) || (hash->flags & HASH_CASE_INSENSITIVE ? my_casecmp(rec_key,key,rec_keylength) : diff --git a/mysys/my_static.c b/mysys/my_static.c index 00061893cdc..72bf7207efa 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -61,7 +61,7 @@ USED_MEM* my_once_root_block=0; /* pointer to first block */ uint my_once_extra=ONCE_ALLOC_INIT; /* Memory to alloc / block */ /* from my_tempnam */ -#ifndef HAVE_TEMPNAM +#if !defined(HAVE_TEMPNAM) || defined(HPUX11) int _my_tempnam_used=0; #endif diff --git a/mysys/my_static.h b/mysys/my_static.h index e9d1a30b786..e139b0ec127 100644 --- a/mysys/my_static.h +++ b/mysys/my_static.h @@ -57,7 +57,7 @@ extern const char *soundex_map; extern USED_MEM* my_once_root_block; extern uint my_once_extra; -#ifndef HAVE_TEMPNAM +#if !defined(HAVE_TEMPNAM) || defined(HPUX11) extern int _my_tempnam_used; #endif diff --git a/mysys/my_tempnam.c b/mysys/my_tempnam.c index fdaf018af0d..d4979fcaa6e 100644 --- a/mysys/my_tempnam.c +++ b/mysys/my_tempnam.c @@ -24,6 +24,12 @@ #include "mysys_priv.h" #include + +/* HPUX 11.0 doesn't allow us to change the environ pointer */ +#ifdef HPUX11 +#undef HAVE_TEMPNAM +#endif + #include "my_static.h" #include "mysys_err.h" diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index de367e8c052..457356d4253 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -641,7 +641,7 @@ bool analyse::end_of_records() case FIELD_TYPE_DECIMAL: ans.append("DECIMAL", 7); // if item is FIELD_ITEM, it _must_be_ Field_num in this case - if (((Field_num*) (*f)->item)->zerofill) + if (((Field_num*) ((Item_field*) (*f)->item)->field)->zerofill) ans.append(" ZEROFILL"); break; default: From 0db5f142dd8deeb22ef047a08963d4e66c9f83fb Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 4 Dec 2002 19:16:45 +0100 Subject: [PATCH 5/8] - portability patch to work around bugs in the HP compiler's "inline" handling (backport from 4.0 tree) --- include/global.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/global.h b/include/global.h index 4ab7cbbeee6..988797b330c 100644 --- a/include/global.h +++ b/include/global.h @@ -122,6 +122,10 @@ double my_ulonglong2double(unsigned long long A); #undef HAVE_PREAD #undef HAVE_PWRITE #endif +#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus) +#undef inline +#define inline +#endif #ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */ #undef HAVE_GETHOSTBYNAME_R From d527bfbd5974261b42192e1a07e86177113c9229 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Wed, 4 Dec 2002 20:51:18 +0200 Subject: [PATCH 6/8] A fix for double free'd pointer bug ... --- .bzrignore | 2 ++ sql/sql_table.cc | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index 4a707ae05df..5b35d1f6611 100644 --- a/.bzrignore +++ b/.bzrignore @@ -331,3 +331,5 @@ bdb/dist/autom4te.cache/traces.0 innobase/autom4te.cache/output.0 innobase/autom4te.cache/requests innobase/autom4te.cache/traces.0 +innobase/stamp-h1 +stamp-h1 diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0a09b6232e8..ec866b927e6 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1528,8 +1528,14 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, /* We changed a temporary table */ if (error) { + /* + * The following function call will also free a + * new_table pointer. + * Therefore, here new_table pointer is not free'd as it is + * free'd in close_temporary() which is called by by the + * close_temporary_table() function. + */ close_temporary_table(thd,new_db,tmp_name); - my_free((gptr) new_table,MYF(0)); goto err; } /* Close lock if this is a transactional table */ From 5331a7ef8ed9db2fcf9fbd749543f9d504ddcf86 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Wed, 4 Dec 2002 21:39:15 +0200 Subject: [PATCH 7/8] some code cleanup --- sql/sql_table.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ec866b927e6..e2fa8bc00d5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1848,7 +1848,6 @@ copy_data_between_tables(TABLE *from,TABLE *to, if (to->file->external_lock(thd,F_UNLCK)) error=1; err: - tmp_error = ha_recovery_logging(thd,TRUE); free_io_cache(from); *copied= found_count; *deleted=delete_count; From 82a9669267e5e84e93104a739ce628bb0cd33d36 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Wed, 4 Dec 2002 21:50:59 +0200 Subject: [PATCH 8/8] a test case for double free'ing of pointer in alter table ... --- mysql-test/t/temp_table.test | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index 3cf18bae9fe..0eba893fe60 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -60,3 +60,8 @@ insert into t2 values (1,1),(2,1),(3,1),(4,2); # do a query using ELT, a join and an ORDER BY. select one.id, two.val, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id; drop table t1,t2; +create temporary table t1 (a int not null); +insert into t1 values (1),(1); +-- error 1062 +alter table t1 add primary key (a); +drop table t1;