From 7ae87a945d811c1b1f10ca31bd623481af3ff4d4 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 20 Jul 2004 18:24:36 +0200 Subject: [PATCH 01/63] - added mysqlman.1.in to the source distribution (generic fallback man page that can be used as a default man page for programs that do not have their own man page) --- man/Makefile.am | 2 +- man/mysqlman.1.in | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 man/mysqlman.1.in diff --git a/man/Makefile.am b/man/Makefile.am index 37eb8a13f4e..539c43dfed6 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -23,7 +23,7 @@ man_MANS = mysql.1 isamchk.1 isamlog.1 mysql_zap.1 mysqlaccess.1 \ EXTRA_DIST = mysql.1.in isamchk.1.in isamlog.1.in mysql_zap.1.in \ mysqlaccess.1.in mysqladmin.1.in mysqld.1.in mysqld_multi.1.in \ - mysqldump.1.in mysqlshow.1.in perror.1.in replace.1.in \ + mysqldump.1.in mysqlshow.1.in perror.1.in replace.1.in mysqlman.1.in \ mysqld_safe.1.in mysql_fix_privilege_tables.1.in CLEANFILES = $(man_MANS) diff --git a/man/mysqlman.1.in b/man/mysqlman.1.in new file mode 100644 index 00000000000..610a64da198 --- /dev/null +++ b/man/mysqlman.1.in @@ -0,0 +1,15 @@ +.TH mysqlman 1 "20 July 2004" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" +.SH NAME +mysqlman \- default man page for mysql +.SH "DESCRIPTION" +Certain executables distributed with the MySQL database management system do +not have specific man pages. +.SH "SEE ALSO" +In most cases, you can run the executable from the command line with a "--help" +argument to display a brief summary of the executable's arguments and function. +For more information about MySQL, please refer to the MySQL reference manual, +which may already be installed locally and which is also available online at +http://dev.mysql.com/doc/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. +.\" end of man page From 2a71cc26aa2095ad27da7d385d0c30f7df023390 Mon Sep 17 00:00:00 2001 From: "hf@deer.(none)" <> Date: Wed, 21 Jul 2004 18:23:13 +0500 Subject: [PATCH 02/63] Fix for bug #4531(64bit embedded server crashes) There is some 'ulong'<->'uint' mess in libmysqld.c --- libmysqld/libmysqld.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index 6f60e4c4fbc..9c79536b2e0 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -412,8 +412,8 @@ mysql_free_result(MYSQL_RES *result) DBUG_PRINT("warning",("Not all rows in set were read; Ignoring rows")); for (;;) { - uint pkt_len; - if ((pkt_len=(uint) net_safe_read(result->handle)) == packet_error) + ulong pkt_len; + if ((pkt_len=net_safe_read(result->handle)) == packet_error) break; if (pkt_len == 1 && result->handle->net.read_pos[0] == 254) break; /* End of data */ @@ -611,7 +611,8 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, uint fields) { - uint field,pkt_len; + uint field; + ulong pkt_len; ulong len; uchar *cp; char *to; @@ -620,7 +621,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, NET *net = &mysql->net; DBUG_ENTER("read_rows"); - if ((pkt_len=(uint) net_safe_read(mysql)) == packet_error) + if ((pkt_len= net_safe_read(mysql)) == packet_error) DBUG_RETURN(0); if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA), MYF(MY_WME | MY_ZEROFILL)))) @@ -805,7 +806,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, uint port, const char *unix_socket,uint client_flag) { char buff[100],charset_name_buff[16],*end,*host_info, *charset_name; - uint pkt_length; + ulong pkt_length; ulong max_allowed_packet; NET *net= &mysql->net; DBUG_ENTER("mysql_real_connect"); @@ -1153,7 +1154,7 @@ mysql_read_query_result(MYSQL *mysql) uchar *pos; ulong field_count; MYSQL_DATA *fields; - uint length; + ulong length; DBUG_ENTER("mysql_read_query_result"); if ((length=net_safe_read(mysql)) == packet_error) From 35ac63439d9c2e152348f08ad2c79e01652018c2 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Thu, 22 Jul 2004 19:28:11 +0200 Subject: [PATCH 03/63] distclean: rm -f lex_hash.h BUG#4583 --- sql/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/Makefile.am b/sql/Makefile.am index f3751eabd25..0a664a120a5 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -125,8 +125,8 @@ sql_lex.o: lex_hash.h udf_example.so: udf_example.cc $(CXXCOMPILE) -shared -o $@ $< -#distclean: -# rm -f lex_hash.h +distclean: + rm -f lex_hash.h # Don't update the files from bitkeeper %::SCCS/s.% From a54f6398fe9649e1b84b25235e6c60c0ae8d86ba Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Fri, 23 Jul 2004 12:27:28 +0200 Subject: [PATCH 04/63] - Use the same compile options for the upcoming darwin8 OS in configure.in (thanks to Al Begley from Apple for the hint) --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 516b521034b..2444cdbc7ce 100644 --- a/configure.in +++ b/configure.in @@ -1037,7 +1037,7 @@ case $SYSTEM_TYPE in MAX_C_OPTIMIZE="-O" fi ;; - *darwin7*) + *darwin[7-8]*) if test "$ac_cv_prog_gcc" = "yes" then FLAGS="-DHAVE_DARWIN_THREADS -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ" From 0b8fd9d66dcc2285d96de5c1400d871752523ca5 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Fri, 23 Jul 2004 12:44:09 +0200 Subject: [PATCH 05/63] - match shared library file name suffixes on Mac OS X (.dylib) and HP-UX (.sl) for creating "mysql-shared" packages there --- scripts/make_sharedlib_distribution.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/make_sharedlib_distribution.sh b/scripts/make_sharedlib_distribution.sh index 4104a315296..fbc945e445a 100644 --- a/scripts/make_sharedlib_distribution.sh +++ b/scripts/make_sharedlib_distribution.sh @@ -45,8 +45,10 @@ fi mkdir -p $BASE/lib for i in \ - libmysql/.libs/libmysqlclient.so* \ - libmysql_r/.libs/libmysqlclient_r.so* + libmysql/.libs/libmysqlclient.s{l,o}* \ + libmysql/.libs/libmysqlclient*.dylib \ + libmysql_r/.libs/libmysqlclient_r.s{l,o}* \ + libmysql_r/.libs/libmysqlclient_r*.dylib do if [ -f $i ] then From a4ae8c3c8db648be6e43b702ada998a2493f248e Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 23 Jul 2004 19:12:20 +0200 Subject: [PATCH 06/63] workaround for Sun Forte / x86 BUG#4681 --- configure.in | 17 ++++++ mytest-old.c | 169 --------------------------------------------------- 2 files changed, 17 insertions(+), 169 deletions(-) delete mode 100644 mytest-old.c diff --git a/configure.in b/configure.in index 516b521034b..a6d1dbbf589 100644 --- a/configure.in +++ b/configure.in @@ -936,6 +936,18 @@ esac MAX_C_OPTIMIZE="-O3" MAX_CXX_OPTIMIZE="-O3" +fix_for_forte_x86 () +{ + case $MACHINE_TYPE-$ac_cv_prog_gcc in + i?86-no) + # workaround for Sun Forte/x86 see BUG#4681 + CFLAGS="$CFLAGS -DBIG_FILES" + CXXFLAGS="$CXXFLAGS -DBIG_FILES" + ;; + *) ;; + esac +} + case $SYSTEM_TYPE in *solaris2.7*) # Solaris 2.7 has a broken /usr/include/widec.h @@ -950,6 +962,7 @@ case $SYSTEM_TYPE in sed -e "s|^#if[ ]*!defined(lint) && !defined(__lint)|#if !defined\(lint\) \&\& !defined\(__lint\) \&\& !defined\(getwc\)|" < /usr/include/widec.h > include/widec.h CFLAGS="$CFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T" CXXFLAGS="$CXXFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T" + fix_for_forte_x86 ;; *solaris2.8*) # Solaris 2.8 has a broken /usr/include/widec.h @@ -964,19 +977,23 @@ case $SYSTEM_TYPE in sed -e "s|^#if[ ]*!defined(__lint)|#if !defined\(__lint\) \&\& !defined\(getwc\)|" < /usr/include/widec.h > include/widec.h CFLAGS="$CFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T" CXXFLAGS="$CXXFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T" + fix_for_forte_x86 ;; *solaris2.5.1*) echo "Enabling getpass() workaround for Solaris 2.5.1" CFLAGS="$CFLAGS -DHAVE_BROKEN_GETPASS -DSOLARIS -DHAVE_RWLOCK_T"; CXXFLAGS="$CXXFLAGS -DHAVE_RWLOCK_T -DSOLARIS" + fix_for_forte_x86 ;; *solaris*) CFLAGS="$CFLAGS -DHAVE_RWLOCK_T" CXXFLAGS="$CXXFLAGS -DHAVE_RWLOCK_T" + fix_for_forte_x86 ;; *SunOS*) echo "Enabling getpass() workaround for SunOS" CFLAGS="$CFLAGS -DHAVE_BROKEN_GETPASS -DSOLARIS"; + fix_for_forte_x86 ;; *hpux10.20*) echo "Enabling workarounds for hpux 10.20" diff --git a/mytest-old.c b/mytest-old.c deleted file mode 100644 index 8b4029f5e1e..00000000000 --- a/mytest-old.c +++ /dev/null @@ -1,169 +0,0 @@ -/*C4*/ -/****************************************************************/ -/* Author: Jethro Wright, III TS : 3/ 4/1998 9:15 */ -/* Date: 02/18/1998 */ -/* mytest.c : do some testing of the libmySQL.DLL.... */ -/* */ -/* History: */ -/* 02/18/1998 jw3 also sprach zarathustra.... */ -/****************************************************************/ - - -#include -#include -#include - -#include - -#define DEFALT_SQL_STMT "SELECT * FROM db" -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - - -/******************************************************** -** -** main :- -** -********************************************************/ - -int -main( int argc, char * argv[] ) -{ - - char szSQL[ 200 ], aszFlds[ 25 ][ 25 ], * pszT, szDB[ 50 ] ; - int i, j, k, l, x ; - MYSQL * myData ; - MYSQL_RES * res ; - MYSQL_FIELD * fd ; - MYSQL_ROW row ; - - //....just curious.... - printf( "sizeof( MYSQL ) == %d\n", sizeof( MYSQL ) ) ; - if ( argc == 2 ) - { - strcpy( szDB, argv[ 1 ] ) ; - strcpy( szSQL, DEFALT_SQL_STMT ) ; - if (!strcmp(szDB,"--debug")) - { - strcpy( szDB, "mysql" ) ; - printf("Some mysql struct information (size and offset):\n"); - printf("net:\t%3d %3d\n",sizeof(myData->net),offsetof(MYSQL,net)); - printf("host:\t%3d %3d\n",sizeof(myData->host),offsetof(MYSQL,host)); - printf("port:\t%3d %3d\n",sizeof(myData->port),offsetof(MYSQL,port)); - printf("protocol_version:\t%3d %3d\n",sizeof(myData->protocol_version), - offsetof(MYSQL,protocol_version)); - printf("thread_id:\t%3d %3d\n",sizeof(myData->thread_id), - offsetof(MYSQL,thread_id)); - printf("affected_rows:\t%3d %3d\n",sizeof(myData->affected_rows), - offsetof(MYSQL,affected_rows)); - printf("packet_length:\t%3d %3d\n",sizeof(myData->packet_length), - offsetof(MYSQL,packet_length)); - printf("status:\t%3d %3d\n",sizeof(myData->status), - offsetof(MYSQL,status)); - printf("fields:\t%3d %3d\n",sizeof(myData->fields), - offsetof(MYSQL,fields)); - printf("field_alloc:\t%3d %3d\n",sizeof(myData->field_alloc), - offsetof(MYSQL,field_alloc)); - printf("free_me:\t%3d %3d\n",sizeof(myData->free_me), - offsetof(MYSQL,free_me)); - printf("options:\t%3d %3d\n",sizeof(myData->options), - offsetof(MYSQL,options)); - puts(""); - } - } - else if ( argc > 2 ) { - strcpy( szDB, argv[ 1 ] ) ; - strcpy( szSQL, argv[ 2 ] ) ; - } - else { - strcpy( szDB, "mysql" ) ; - strcpy( szSQL, DEFALT_SQL_STMT ) ; - } - //.... - - if ( (myData = mysql_init((MYSQL*) 0)) && - mysql_real_connect( myData, NULL, NULL, NULL, NULL, MYSQL_PORT, - NULL, 0 ) ) - { - if ( mysql_select_db( myData, szDB ) < 0 ) { - printf( "Can't select the %s database !\n", szDB ) ; - mysql_close( myData ) ; - return 2 ; - } - } - else { - printf( "Can't connect to the mysql server on port %d !\n", - MYSQL_PORT ) ; - mysql_close( myData ) ; - return 1 ; - } - //.... - if ( ! mysql_query( myData, szSQL ) ) { - res = mysql_store_result( myData ) ; - i = (int) mysql_num_rows( res ) ; l = 1 ; - printf( "Query: %s\nNumber of records found: %ld\n", szSQL, i ) ; - //....we can get the field-specific characteristics here.... - for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ ) - strcpy( aszFlds[ x ], fd->name ) ; - //.... - while ( row = mysql_fetch_row( res ) ) { - j = mysql_num_fields( res ) ; - printf( "Record #%ld:-\n", l++ ) ; - for ( k = 0 ; k < j ; k++ ) - printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ], - (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ; - puts( "==============================\n" ) ; - } - mysql_free_result( res ) ; - } - else printf( "Couldn't execute %s on the server !\n", szSQL ) ; - //.... - puts( "==== Diagnostic info ====" ) ; - pszT = mysql_get_client_info() ; - printf( "Client info: %s\n", pszT ) ; - //.... - pszT = mysql_get_host_info( myData ) ; - printf( "Host info: %s\n", pszT ) ; - //.... - pszT = mysql_get_server_info( myData ) ; - printf( "Server info: %s\n", pszT ) ; - //.... - res = mysql_list_processes( myData ) ; l = 1 ; - if (res) - { - for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ ) - strcpy( aszFlds[ x ], fd->name ) ; - while ( row = mysql_fetch_row( res ) ) { - j = mysql_num_fields( res ) ; - printf( "Process #%ld:-\n", l++ ) ; - for ( k = 0 ; k < j ; k++ ) - printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ], - (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ; - puts( "==============================\n" ) ; - } - } - else - { - printf("Got error %s when retreiving processlist\n",mysql_error(myData)); - } - //.... - res = mysql_list_tables( myData, "%" ) ; l = 1 ; - for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ ) - strcpy( aszFlds[ x ], fd->name ) ; - while ( row = mysql_fetch_row( res ) ) { - j = mysql_num_fields( res ) ; - printf( "Table #%ld:-\n", l++ ) ; - for ( k = 0 ; k < j ; k++ ) - printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ], - (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ; - puts( "==============================\n" ) ; - } - //.... - pszT = mysql_stat( myData ) ; - puts( pszT ) ; - //.... - mysql_close( myData ) ; - return 0 ; - -} From b9512a55aa2ff17559886447a4b372179002568f Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Mon, 26 Jul 2004 10:52:40 +0200 Subject: [PATCH 07/63] BUG#4717 - check for valid table names in ALTER TABLE ... RENAME --- mysql-test/r/alter_table.result | 6 ++++++ mysql-test/t/alter_table.test | 11 +++++++++++ sql/sql_yacc.yy | 8 +++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index c2fd5161353..e7a8d2c7cdf 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -380,3 +380,9 @@ t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE t1 0 PRIMARY 2 User A 0 NULL NULL BTREE t1 1 Host 1 Host A NULL NULL NULL BTREE disabled DROP TABLE t1; +create table t1 (a int); +alter table t1 rename to `t1\\`; +Incorrect table name 't1\\' +rename table t1 to `t1\\`; +Incorrect table name 't1\\' +drop table t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 9a29ab3c2d7..11290134a71 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -243,3 +243,14 @@ LOCK TABLES t1 WRITE; ALTER TABLE t1 DISABLE KEYS; SHOW INDEX FROM t1; DROP TABLE t1; + +# +# BUG#4717 - check for valid table names +# +create table t1 (a int); +--error 1103 +alter table t1 rename to `t1\\`; +--error 1103 +rename table t1 to `t1\\`; +drop table t1; + diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a50e37e54f5..2199a0c8be5 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1316,10 +1316,16 @@ alter_list_item: lex->simple_alter=0; } | RENAME opt_to table_ident - { + { LEX *lex=Lex; lex->select->db=$3->db.str; lex->name= $3->table.str; + if (check_table_name($3->table.str,$3->table.length) || + $3->db.str && check_db_name($3->db.str)) + { + net_printf(&lex->thd->net,ER_WRONG_TABLE_NAME,$3->table.str); + YYABORT; + } } | create_table_options { Lex->simple_alter=0; } | order_clause { Lex->simple_alter=0; }; From d2c8d8d6095ed226e670681b533dd7e879bbfbf8 Mon Sep 17 00:00:00 2001 From: "ingo@mysql.com" <> Date: Mon, 26 Jul 2004 13:58:08 +0200 Subject: [PATCH 08/63] Fixed a probable typo. Unfortunately we will not be able to test this ;-) --- myisam/mi_search.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myisam/mi_search.c b/myisam/mi_search.c index b98ee351195..ce228c5ba5d 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -540,7 +540,7 @@ my_off_t _mi_dpos(MI_INFO *info, uint nod_flag, uchar *after_key) after_key-=(nod_flag + info->s->rec_reflength); switch (info->s->rec_reflength) { #if SIZEOF_OFF_T > 4 - case 8: pos= (my_off_t) mi_uint5korr(after_key); break; + case 8: pos= (my_off_t) mi_uint8korr(after_key); break; case 7: pos= (my_off_t) mi_uint7korr(after_key); break; case 6: pos= (my_off_t) mi_uint6korr(after_key); break; case 5: pos= (my_off_t) mi_uint5korr(after_key); break; From 4b42225c553cfd8f986563e118a7115624fa2f92 Mon Sep 17 00:00:00 2001 From: "ingo@mysql.com" <> Date: Mon, 26 Jul 2004 15:32:52 +0200 Subject: [PATCH 09/63] Fixed some DBUG_PRINT format problems. --- myisam/mi_search.c | 53 ++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/myisam/mi_search.c b/myisam/mi_search.c index ce228c5ba5d..cfc1c5cc3c0 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -63,8 +63,8 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *keypos,*maxpos; uchar lastkey[MI_MAX_KEY_BUFF],*buff; DBUG_ENTER("_mi_search"); - DBUG_PRINT("enter",("pos: %ld nextflag: %d lastpos: %ld", - pos,nextflag,info->lastpos)); + DBUG_PRINT("enter",("pos: %lu nextflag: %u lastpos: %lu", + (ulong) pos, nextflag, (ulong) info->lastpos)); DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg,key,key_len);); if (pos == HA_OFFSET_ERROR) @@ -235,15 +235,15 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, if (length == 0 || page > end) { my_errno=HA_ERR_CRASHED; - DBUG_PRINT("error",("Found wrong key: length: %d page: %lx end: %lx", - length,page,end)); + DBUG_PRINT("error",("Found wrong key: length: %u page: %p end: %p", + length, page, end)); DBUG_RETURN(MI_FOUND_WRONG_KEY); } if ((flag=_mi_key_cmp(keyinfo->seg,t_buff,key,key_len,comp_flag, ¬_used)) >= 0) break; #ifdef EXTRA_DEBUG - DBUG_PRINT("loop",("page: %lx key: '%s' flag: %d",page,t_buff,flag)); + DBUG_PRINT("loop",("page: %p key: '%s' flag: %d", page, t_buff, flag)); #endif memcpy(buff,t_buff,length); *ret_pos=page; @@ -251,7 +251,7 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, if (flag == 0) memcpy(buff,t_buff,length); /* Result is first key */ *last_key= page == end; - DBUG_PRINT("exit",("flag: %d ret_pos: %lx",flag,*ret_pos)); + DBUG_PRINT("exit",("flag: %d ret_pos: %p", flag, *ret_pos)); DBUG_RETURN(flag); } /* _mi_seq_search */ @@ -350,7 +350,8 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, saved_vseg=vseg; saved_prefix_len=prefix_len; - DBUG_PRINT("loop",("page: '%.*s%.*s'",prefix_len,t_buff+seg_len_pack,suffix_len,vseg)); + DBUG_PRINT("loop",("page: '%.*s%.*s'", prefix_len, t_buff + seg_len_pack, + suffix_len, vseg)); { uchar *from=vseg+suffix_len; MI_KEYSEG *keyseg; @@ -381,8 +382,8 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, if (page > end) { my_errno=HA_ERR_CRASHED; - DBUG_PRINT("error",("Found wrong key: length: %d page: %lx end: %lx", - length,page,end)); + DBUG_PRINT("error",("Found wrong key: length: %u page: %p end: %p", + length, page, end)); DBUG_RETURN(MI_FOUND_WRONG_KEY); } @@ -463,7 +464,7 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, *last_key= page == end; - DBUG_PRINT("exit",("flag: %d ret_pos: %lx",flag,*ret_pos)); + DBUG_PRINT("exit",("flag: %d ret_pos: %p", flag, *ret_pos)); DBUG_RETURN(flag); } /* _mi_prefix_search */ @@ -1134,8 +1135,9 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, key+= length; /* Same diff_key as prev */ if (length > keyseg->length) { - DBUG_PRINT("error",("Found too long null packed key: %d of %d at %lx", - length, keyseg->length, *page_pos)); + DBUG_PRINT("error", + ("Found too long null packed key: %u of %u at %p", + length, keyseg->length, *page_pos)); DBUG_DUMP("key",(char*) *page_pos,16); my_errno=HA_ERR_CRASHED; return 0; @@ -1190,7 +1192,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, } if (length > (uint) keyseg->length) { - DBUG_PRINT("error",("Found too long packed key: %d of %d at %lx", + DBUG_PRINT("error",("Found too long packed key: %u of %u at %p", length, keyseg->length, *page_pos)); DBUG_DUMP("key",(char*) *page_pos,16); my_errno=HA_ERR_CRASHED; @@ -1245,7 +1247,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, { if (length > keyinfo->maxlength) { - DBUG_PRINT("error",("Found too long binary packed key: %d of %d at %lx", + DBUG_PRINT("error",("Found too long binary packed key: %u of %u at %p", length, keyinfo->maxlength, *page_pos)); DBUG_DUMP("key",(char*) *page_pos,16); my_errno=HA_ERR_CRASHED; @@ -1292,7 +1294,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, length-=tmp; from=page; from_end=page_end; } - DBUG_PRINT("info",("key: %lx from: %lx length: %u", + DBUG_PRINT("info",("key: %p from: %p length: %u", key, from, length)); memcpy_overlap((byte*) key, (byte*) from, (size_t) length); key+=length; @@ -1348,7 +1350,7 @@ uchar *_mi_get_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, } } } - DBUG_PRINT("exit",("page: %lx length: %d",page,*return_key_length)); + DBUG_PRINT("exit",("page: %p length: %u", page, *return_key_length)); DBUG_RETURN(page); } /* _mi_get_key */ @@ -1399,7 +1401,7 @@ uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uint nod_flag; uchar *lastpos; DBUG_ENTER("_mi_get_last_key"); - DBUG_PRINT("enter",("page: %lx endpos: %lx",page,endpos)); + DBUG_PRINT("enter",("page: %p endpos: %p", page, endpos)); nod_flag=mi_test_if_nod(page); if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY))) @@ -1419,13 +1421,13 @@ uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, *return_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,lastkey); if (*return_key_length == 0) { - DBUG_PRINT("error",("Couldn't find last key: page: %lx",page)); + DBUG_PRINT("error",("Couldn't find last key: page: %p", page)); my_errno=HA_ERR_CRASHED; DBUG_RETURN(0); } } } - DBUG_PRINT("exit",("lastpos: %lx length: %d",lastpos,*return_key_length)); + DBUG_PRINT("exit",("lastpos: %p length: %u", lastpos, *return_key_length)); DBUG_RETURN(lastpos); } /* _mi_get_last_key */ @@ -1510,8 +1512,9 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo, uint nod_flag; uchar lastkey[MI_MAX_KEY_BUFF]; DBUG_ENTER("_mi_search_next"); - DBUG_PRINT("enter",("nextflag: %d lastpos: %ld int_keypos: %lx", - nextflag,(long) info->lastpos,info->int_keypos)); + DBUG_PRINT("enter",("nextflag: %u lastpos: %lu int_keypos: %lu", + nextflag, (ulong) info->lastpos, + (ulong) info->int_keypos)); DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg,key,key_length);); /* Force full read if we are at last key or if we are not on a leaf @@ -1618,7 +1621,7 @@ int _mi_search_first(register MI_INFO *info, register MI_KEYDEF *keyinfo, info->page_changed=info->buff_used=0; info->lastpos=_mi_dpos(info,0,info->lastkey+info->lastkey_length); - DBUG_PRINT("exit",("found key at %ld",(ulong) info->lastpos)); + DBUG_PRINT("exit",("found key at %lu", (ulong) info->lastpos)); DBUG_RETURN(0); } /* _mi_search_first */ @@ -1852,8 +1855,8 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key, } s_temp->totlength=(uint) length; s_temp->prev_length=0; - DBUG_PRINT("test",("tot_length: %d length: %d uniq_key_length: %d", - key_length,length,s_temp->key_length)); + DBUG_PRINT("test",("tot_length: %u length: %d uniq_key_length: %u", + key_length, length, s_temp->key_length)); /* If something after that hasn't length=0, test if we can combine */ if ((s_temp->next_key_pos=next_key)) @@ -1959,7 +1962,7 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key, ref_length=0; next_length_pack=0; } - DBUG_PRINT("test",("length: %d next_key: %lx",length,next_key)); + DBUG_PRINT("test",("length: %d next_key: %p", length, next_key)); { uint tmp_length; From 1b7334c4c0c35ed7b253810534d3d10ae32aa917 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Tue, 27 Jul 2004 09:00:17 +0300 Subject: [PATCH 10/63] row0sel.c, page0page.ic: Add diagnostic code to print hex dumps and track corruption of next record offsets in an index page --- innobase/include/page0page.ic | 10 +++++++++- innobase/row/row0sel.c | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/innobase/include/page0page.ic b/innobase/include/page0page.ic index e7c0f8ee07c..27f43d5c63d 100644 --- a/innobase/include/page0page.ic +++ b/innobase/include/page0page.ic @@ -479,7 +479,15 @@ page_rec_get_next( offs = rec_get_next_offs(rec); - ut_a(offs < UNIV_PAGE_SIZE); + if (offs >= UNIV_PAGE_SIZE) { + fprintf(stderr, +"InnoDB: Next record offset is nonsensical %lu in record at offset %lu\n", + (ulong)offs, (ulong)(rec - page)); + + buf_page_print(page); + + ut_a(0); + } if (offs == 0) { diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index e0bf4684214..42d1f260757 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -3088,6 +3088,7 @@ rec_loop: if (srv_force_recovery == 0 || moves_up == FALSE) { ut_print_timestamp(stderr); + buf_page_print(buf_frame_align(rec)); fprintf(stderr, " InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n" "InnoDB: ", From 13ecd6946984e5825f771f82f34c862911c5ea53 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 27 Jul 2004 09:12:20 +0200 Subject: [PATCH 11/63] avoid functions in configure --- configure.in | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/configure.in b/configure.in index 31a82b55183..be3269d50d6 100644 --- a/configure.in +++ b/configure.in @@ -936,17 +936,15 @@ esac MAX_C_OPTIMIZE="-O3" MAX_CXX_OPTIMIZE="-O3" -fix_for_forte_x86 () -{ - case $MACHINE_TYPE-$ac_cv_prog_gcc in - i?86-no) - # workaround for Sun Forte/x86 see BUG#4681 - CFLAGS="$CFLAGS -DBIG_FILES" - CXXFLAGS="$CXXFLAGS -DBIG_FILES" - ;; - *) ;; - esac -} +# workaround for Sun Forte/x86 see BUG#4681 +case $SYSTEM_TYPE-$MACHINE_TYPE-$ac_cv_prog_gcc in + *solaris*-i?86-no) + CFLAGS="$CFLAGS -DBIG_FILES" + CXXFLAGS="$CXXFLAGS -DBIG_FILES" + ;; + *) ;; +esac + case $SYSTEM_TYPE in *solaris2.7*) @@ -962,7 +960,6 @@ case $SYSTEM_TYPE in sed -e "s|^#if[ ]*!defined(lint) && !defined(__lint)|#if !defined\(lint\) \&\& !defined\(__lint\) \&\& !defined\(getwc\)|" < /usr/include/widec.h > include/widec.h CFLAGS="$CFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T" CXXFLAGS="$CXXFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T" - fix_for_forte_x86 ;; *solaris2.8*) # Solaris 2.8 has a broken /usr/include/widec.h @@ -977,23 +974,19 @@ case $SYSTEM_TYPE in sed -e "s|^#if[ ]*!defined(__lint)|#if !defined\(__lint\) \&\& !defined\(getwc\)|" < /usr/include/widec.h > include/widec.h CFLAGS="$CFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T" CXXFLAGS="$CXXFLAGS -DHAVE_CURSES_H -I$builddir/include -DHAVE_RWLOCK_T" - fix_for_forte_x86 ;; *solaris2.5.1*) echo "Enabling getpass() workaround for Solaris 2.5.1" CFLAGS="$CFLAGS -DHAVE_BROKEN_GETPASS -DSOLARIS -DHAVE_RWLOCK_T"; CXXFLAGS="$CXXFLAGS -DHAVE_RWLOCK_T -DSOLARIS" - fix_for_forte_x86 ;; *solaris*) CFLAGS="$CFLAGS -DHAVE_RWLOCK_T" CXXFLAGS="$CXXFLAGS -DHAVE_RWLOCK_T" - fix_for_forte_x86 ;; *SunOS*) echo "Enabling getpass() workaround for SunOS" CFLAGS="$CFLAGS -DHAVE_BROKEN_GETPASS -DSOLARIS"; - fix_for_forte_x86 ;; *hpux10.20*) echo "Enabling workarounds for hpux 10.20" From fb0b02415c77298a05530400bf1d191d8ffd3107 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Tue, 27 Jul 2004 19:14:50 +0300 Subject: [PATCH 12/63] buf0flu.c, os0file.c: Add more diagnostic code to determine when an lsn field gets corrupt; tracks a crash reported from one Itanium computer --- innobase/buf/buf0flu.c | 54 ++++++++++++++++++++++++++++++++++++++++++ innobase/os/os0file.c | 3 +++ 2 files changed, 57 insertions(+) diff --git a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c index 7456e5d6f61..9eb8076732d 100644 --- a/innobase/buf/buf0flu.c +++ b/innobase/buf/buf0flu.c @@ -213,7 +213,9 @@ buf_flush_buffered_writes(void) /*===========================*/ { buf_block_t* block; + byte* write_buf; ulint len; + ulint len2; ulint i; if (trx_doublewrite == NULL) { @@ -240,6 +242,16 @@ buf_flush_buffered_writes(void) block = trx_doublewrite->buf_block_arr[i]; ut_a(block->state == BUF_BLOCK_FILE_PAGE); + if (mach_read_from_4(block->frame + FIL_PAGE_LSN + 4) + != mach_read_from_4(block->frame + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { + ut_print_timestamp(stderr); + fprintf(stderr, +" InnoDB: ERROR: The page to be written seems corrupt!\n" +"InnoDB: The lsn fields do not match! Noticed in the buffer pool\n" +"InnoDB: before posting to the doublewrite buffer.\n"); + } + if (block->check_index_page_at_flush && !page_simple_validate(block->frame)) { @@ -268,6 +280,19 @@ buf_flush_buffered_writes(void) trx_doublewrite->block1, 0, len, (void*)trx_doublewrite->write_buf, NULL); + write_buf = trx_doublewrite->write_buf; + + for (len2 = 0; len2 + UNIV_PAGE_SIZE <= len; len2 += UNIV_PAGE_SIZE) { + if (mach_read_from_4(write_buf + len2 + FIL_PAGE_LSN + 4) + != mach_read_from_4(write_buf + len2 + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { + ut_print_timestamp(stderr); + fprintf(stderr, +" InnoDB: ERROR: The page to be written seems corrupt!\n" +"InnoDB: The lsn fields do not match! Noticed in the doublewrite block1.\n"); + } + } + if (trx_doublewrite->first_free > TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { len = (trx_doublewrite->first_free - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) * UNIV_PAGE_SIZE; @@ -278,6 +303,22 @@ buf_flush_buffered_writes(void) (void*)(trx_doublewrite->write_buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE), NULL); + + write_buf = trx_doublewrite->write_buf + + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE; + for (len2 = 0; len2 + UNIV_PAGE_SIZE <= len; + len2 += UNIV_PAGE_SIZE) { + if (mach_read_from_4(write_buf + len2 + + FIL_PAGE_LSN + 4) + != mach_read_from_4(write_buf + len2 + + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { + ut_print_timestamp(stderr); + fprintf(stderr, +" InnoDB: ERROR: The page to be written seems corrupt!\n" +"InnoDB: The lsn fields do not match! Noticed in the doublewrite block2.\n"); + } + } } /* Now flush the doublewrite buffer data to disk */ @@ -291,6 +332,19 @@ buf_flush_buffered_writes(void) for (i = 0; i < trx_doublewrite->first_free; i++) { block = trx_doublewrite->buf_block_arr[i]; + if (mach_read_from_4(block->frame + FIL_PAGE_LSN + 4) + != mach_read_from_4(block->frame + UNIV_PAGE_SIZE + - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { + ut_print_timestamp(stderr); + fprintf(stderr, +" InnoDB: ERROR: The page to be written seems corrupt!\n" +"InnoDB: The lsn fields do not match! Noticed in the buffer pool\n" +"InnoDB: after posting and flushing the doublewrite buffer.\n" +"InnoDB: Page buf fix count %lu, io fix %lu, state %lu\n", + (ulong)block->buf_fix_count, (ulong)block->io_fix, + (ulong)block->state); + } + fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER, FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE, (void*)block->frame, (void*)block); diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 8cb2b171328..a70333ba6ab 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -2736,6 +2736,9 @@ consecutive_loop: ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: ERROR: The page to be written seems corrupt!\n"); + fprintf(stderr, +"InnoDB: Writing a block of %lu bytes, currently writing at offset %lu\n", + (ulong)total_len, (ulong)len2); buf_page_print(combined_buf + len2); fprintf(stderr, "InnoDB: ERROR: The page to be written seems corrupt!\n"); From f76b84979de6db9f6a79e79bc34f8dff9c982a92 Mon Sep 17 00:00:00 2001 From: "jani@rhols221.adsl.netsonic.fi" <> Date: Wed, 28 Jul 2004 16:37:56 +0300 Subject: [PATCH 13/63] Changed log() to mtr_log(), because of a redefination when compiled with metroworks compiler for Netware. --- netware/mysql_test_run.c | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/netware/mysql_test_run.c b/netware/mysql_test_run.c index 5e5f49da73f..0b86e67fc68 100644 --- a/netware/mysql_test_run.c +++ b/netware/mysql_test_run.c @@ -143,7 +143,7 @@ int read_option(char *, char *); void run_test(char *); void setup(char *); void vlog(char *, va_list); -void log(char *, ...); +void mtr_log(char *, ...); void log_info(char *, ...); void log_error(char *, ...); void log_errno(char *, ...); @@ -160,21 +160,21 @@ void report_stats() { if (total_fail == 0) { - log("\nAll %d test(s) were successful.\n", total_test); + mtr_log("\nAll %d test(s) were successful.\n", total_test); } else { double percent = ((double)total_pass / total_test) * 100; - log("\nFailed %u/%u test(s), %.02f%% successful.\n", + mtr_log("\nFailed %u/%u test(s), %.02f%% successful.\n", total_fail, total_test, percent); - log("\nThe .out and .err files in %s may give you some\n", result_dir); - log("hint of what when wrong.\n"); - log("\nIf you want to report this error, please first read the documentation\n"); - log("at: http://www.mysql.com/doc/M/y/MySQL_test_suite.html\n"); + mtr_log("\nThe .out and .err files in %s may give you some\n", result_dir); + mtr_log("hint of what when wrong.\n"); + mtr_log("\nIf you want to report this error, please first read the documentation\n"); + mtr_log("at: http://www.mysql.com/doc/M/y/MySQL_test_suite.html\n"); } - log("\n%.02f total minutes elapsed in the test cases\n\n", total_time / 60); + mtr_log("\n%.02f total minutes elapsed in the test cases\n\n", total_time / 60); } /****************************************************************************** @@ -794,7 +794,7 @@ void run_test(char *test) if(ignore) { // show test - log("%-46s ", test); + mtr_log("%-46s ", test); // ignore rstr = TEST_IGNORE; @@ -876,7 +876,7 @@ void run_test(char *test) sleep(1); // show test - log("%-46s ", test); + mtr_log("%-46s ", test); // args init_args(&al); @@ -948,7 +948,7 @@ void run_test(char *test) else // early skips { // show test - log("%-46s ", test); + mtr_log("%-46s ", test); // skip rstr = TEST_SKIP; @@ -956,7 +956,7 @@ void run_test(char *test) } // result - log("%10.06f %-14s\n", elapsed, rstr); + mtr_log("%10.06f %-14s\n", elapsed, rstr); } /****************************************************************************** @@ -985,7 +985,7 @@ void vlog(char *format, va_list ap) Log the message. ******************************************************************************/ -void log(char *format, ...) +void mtr_log(char *format, ...) { va_list ap; @@ -1009,9 +1009,9 @@ void log_info(char *format, ...) va_start(ap, format); - log("-- INFO : "); + mtr_log("-- INFO : "); vlog(format, ap); - log("\n"); + mtr_log("\n"); va_end(ap); } @@ -1029,9 +1029,9 @@ void log_error(char *format, ...) va_start(ap, format); - log("-- ERROR: "); + mtr_log("-- ERROR: "); vlog(format, ap); - log("\n"); + mtr_log("\n"); va_end(ap); } @@ -1049,9 +1049,9 @@ void log_errno(char *format, ...) va_start(ap, format); - log("-- ERROR: (%003u) ", errno); + mtr_log("-- ERROR: (%003u) ", errno); vlog(format, ap); - log("\n"); + mtr_log("\n"); va_end(ap); } @@ -1184,18 +1184,18 @@ int main(int argc, char **argv) is_ignore_list = 1; } // header - log("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE); + mtr_log("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE); - log("Initializing Tests...\n"); + mtr_log("Initializing Tests...\n"); // install test databases mysql_install_db(); - log("Starting Tests...\n"); + mtr_log("Starting Tests...\n"); - log("\n"); - log(HEADER); - log(DASH); + mtr_log("\n"); + mtr_log(HEADER); + mtr_log(DASH); if ( argc > 1 + is_ignore_list ) { @@ -1250,10 +1250,10 @@ int main(int argc, char **argv) // stop server mysql_stop(); - log(DASH); - log("\n"); + mtr_log(DASH); + mtr_log("\n"); - log("Ending Tests...\n"); + mtr_log("Ending Tests...\n"); // report stats report_stats(); From 0d0a50ce6a2743a1ec5806e8535d5b4e0b4efe99 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Thu, 29 Jul 2004 23:33:23 +0200 Subject: [PATCH 14/63] language fix --- scripts/mysql_install_db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 7ab312baa5c..f9f3160d220 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -143,7 +143,7 @@ then resolved=`$bindir/resolveip localhost 2>&1` if [ $? -ne 0 ] then - echo "Neither host '$hostname' and 'localhost' could not be looked up with" + echo "Neither host '$hostname' nor 'localhost' could not be looked up with" echo "$bindir/resolveip" echo "Please configure the 'hostname' command to return a correct hostname." echo "If you want to solve this at a later stage, restart this script with" From 0f20e2fece0eda1ff6dc58c8cf76d431d419fadc Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Fri, 30 Jul 2004 00:53:25 +0200 Subject: [PATCH 15/63] Avoiding a theoretically possible crash (pthread_mutex_lock(0)) which could (at least in POSIX Threads books) happen on SMP machines, when a thread is going to wait on a condition and it is KILLed at the same time. Cleaning code a bit by adding a test in enter_cond() that we have the mutex (was already the case in all places where it's called except one which is fixed here). --- sql/log.cc | 1 - sql/slave.cc | 1 + sql/sql_class.cc | 12 +++++++++++- sql/sql_class.h | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 559d30f28ba..a0e2196cc59 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1544,7 +1544,6 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length, void MYSQL_LOG:: wait_for_update(THD* thd, bool master_or_slave) { - safe_mutex_assert_owner(&LOCK_log); const char* old_msg = thd->enter_cond(&update_cond, &LOCK_log, master_or_slave ? "Has read all relay log; waiting for \ diff --git a/sql/slave.cc b/sql/slave.cc index 2269fc8d8cf..9e9e3045ad2 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -588,6 +588,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, while (start_id == *slave_run_id) { DBUG_PRINT("sleep",("Waiting for slave thread to start")); + pthread_mutex_lock(cond_lock); const char* old_msg = thd->enter_cond(start_cond,cond_lock, "Waiting for slave thread to start"); pthread_cond_wait(start_cond,cond_lock); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 44faa3d6963..eb6e74a58c4 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -299,8 +299,18 @@ void THD::awake(bool prepare_to_die) exits the cond in the time between read and broadcast, but that is ok since all we want to do is to make the victim thread get out of waiting on current_cond. + If we see a non-zero current_cond: it cannot be an old value (because + then exit_cond() should have run and it can't because we have mutex); so + it is the true value but maybe current_mutex is not yet non-zero (we're + in the middle of enter_cond() and there is a "memory order + inversion"). So we test the mutex too to not lock 0. + Note that there is a small chance we fail to kill. If victim has locked + current_mutex, and hasn't entered enter_cond(), then we don't know it's + going to wait on cond. Then victim goes into its cond "forever" (until + we issue a second KILL). True we have set its thd->killed but it may not + see it immediately and so may have time to reach the cond_wait(). */ - if (mysys_var->current_cond) + if (mysys_var->current_cond && mysys_var->current_mutex) { pthread_mutex_lock(mysys_var->current_mutex); pthread_cond_broadcast(mysys_var->current_cond); diff --git a/sql/sql_class.h b/sql/sql_class.h index 484a442af20..e045c70517e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -539,6 +539,7 @@ public: const char* msg) { const char* old_msg = proc_info; + safe_mutex_assert_owner(mutex); mysys_var->current_mutex = mutex; mysys_var->current_cond = cond; proc_info = msg; From 9275a701044269addbcd4b33c4737da56dfb7fe7 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Fri, 30 Jul 2004 01:00:52 +0200 Subject: [PATCH 16/63] Reverting a line I had just added to slave.cc (mutex is already locked when we come at this place). --- sql/slave.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/slave.cc b/sql/slave.cc index 9e9e3045ad2..2269fc8d8cf 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -588,7 +588,6 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, while (start_id == *slave_run_id) { DBUG_PRINT("sleep",("Waiting for slave thread to start")); - pthread_mutex_lock(cond_lock); const char* old_msg = thd->enter_cond(start_cond,cond_lock, "Waiting for slave thread to start"); pthread_cond_wait(start_cond,cond_lock); From 6e321db3d58635b00ab6c63162816298d828cd3d Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Fri, 30 Jul 2004 10:20:52 +0200 Subject: [PATCH 17/63] sql_class.h: removing safe_mutex_assert_owner, as it would require an include, and Konstantin already has cleaned up things with assert.h in 4.1; so I'll put the safe_mutex_assert_owner in 4.1 instead. From 55dce7b2c69372a6ea494f0f8ccee91ee1f4edee Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Fri, 30 Jul 2004 14:04:52 +0200 Subject: [PATCH 18/63] - make sure the Windows "-classic" server binaries actually include "-classic" in the version string --- VC++Files/sql/mysqld.dsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index 454b79abe43..1332b74235f 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -187,7 +187,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "USE_SYMDIR" /D "HAVE_DLOPEN" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D LICENSE=Commercial /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "HAVE_DLOPEN" /D "DBUG_OFF" /D "_MBCS" /D "NDEBUG" /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D LICENSE=Commercial /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "HAVE_DLOPEN" /D "DBUG_OFF" /D "_MBCS" /D "NDEBUG" /FD /D MYSQL_SERVER_SUFFIX=-classic /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -243,7 +243,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "USE_SYMDIR" /D "HAVE_DLOPEN" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "__NT__" /D "DBUG_OFF" /D "NDEBUG" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /D LICENSE=Commercial /D MYSQL_SERVER_SUFFIX=-nt /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "__NT__" /D "DBUG_OFF" /D "NDEBUG" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /D LICENSE=Commercial /D MYSQL_SERVER_SUFFIX=-classic-nt /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" From c4ee1bcc103b5aa760c40e19899649f06990eddf Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Fri, 30 Jul 2004 16:58:25 +0300 Subject: [PATCH 19/63] dict0crea.c: Restore accidentally deleted comment to dict_create_sys_tables_tuple() --- innobase/dict/dict0crea.c | 1 + 1 file changed, 1 insertion(+) diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c index 6ebefc98a24..31a601e68b0 100644 --- a/innobase/dict/dict0crea.c +++ b/innobase/dict/dict0crea.c @@ -32,6 +32,7 @@ static dtuple_t* dict_create_sys_tables_tuple( /*=========================*/ + /* out: the tuple which should be inserted */ dict_table_t* table, /* in: table */ mem_heap_t* heap) /* in: memory heap from which the memory for the built tuple is allocated */ From fe784f4962748c22d265a9c5446c1c37cb63c2f6 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 30 Jul 2004 17:02:26 +0300 Subject: [PATCH 20/63] row0sel.c, page0page.ic: Add still more diagnostic code to track buffer pool corruption in one AMD64/Linux computer --- innobase/include/page0page.ic | 7 ++++++- innobase/row/row0sel.c | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/innobase/include/page0page.ic b/innobase/include/page0page.ic index 27f43d5c63d..3d2bf3b090e 100644 --- a/innobase/include/page0page.ic +++ b/innobase/include/page0page.ic @@ -483,7 +483,12 @@ page_rec_get_next( fprintf(stderr, "InnoDB: Next record offset is nonsensical %lu in record at offset %lu\n", (ulong)offs, (ulong)(rec - page)); - + fprintf(stderr, +"\nInnoDB: rec address %lx, first buffer frame %lx\n" +"InnoDB: buffer pool high end %lx, buf fix count %lu\n", + (ulong)rec, (ulong)buf_pool->frame_zero, + (ulong)buf_pool->high_end, + (ulong)buf_block_align(rec)->buf_fix_count); buf_page_print(page); ut_a(0); diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 42d1f260757..6c62fed974c 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -3090,7 +3090,13 @@ rec_loop: ut_print_timestamp(stderr); buf_page_print(buf_frame_align(rec)); fprintf(stderr, -" InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n" +"\nInnoDB: rec address %lx, first buffer frame %lx\n" +"InnoDB: buffer pool high end %lx, buf block fix count %lu\n", + (ulong)rec, (ulong)buf_pool->frame_zero, + (ulong)buf_pool->high_end, + (ulong)buf_block_align(rec)->buf_fix_count); + fprintf(stderr, +"InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n" "InnoDB: ", (ulint)(rec - buf_frame_align(rec)), next_offs, buf_frame_get_page_no(rec)); From 6e4c560592b242869c48f71225f994b6106701a5 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 30 Jul 2004 18:53:54 +0200 Subject: [PATCH 21/63] install-sh: copy not move like any reasonably modern install does --- install-sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-sh b/install-sh index e9de23842dc..c1666c37407 100755 --- a/install-sh +++ b/install-sh @@ -43,7 +43,7 @@ mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" -instcmd="$mvprog" +instcmd="$cpprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" From 2532adf49baa90a801bf55a7bce5fb71df081b2d Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Sat, 31 Jul 2004 09:49:32 +0200 Subject: [PATCH 22/63] removing assertion (will be moved to 4.1) for non-debug to compile --- sql/sql_class.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index e045c70517e..df246b42337 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -535,11 +535,19 @@ public: void close_active_vio(); #endif void awake(bool prepare_to_die); + /* + For enter_cond() / exit_cond() to work the mutex must be got before + enter_cond() but released before exit_cond() (in 4.1, assertions will soon + ensure this). Use must be: + lock mutex; enter_cond(); ...; unlock mutex; exit_cond(). + If you don't do it this way, you will get a deadlock if another thread is + doing a THD::awake() on you. + + */ inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex, const char* msg) { const char* old_msg = proc_info; - safe_mutex_assert_owner(mutex); mysys_var->current_mutex = mutex; mysys_var->current_cond = cond; proc_info = msg; From dd023bc878104485e4c8cdc248c85b9c1daff34d Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Sat, 31 Jul 2004 22:33:20 +0200 Subject: [PATCH 23/63] Fix for: Bug #4810 "deadlock with KILL when the victim was in a wait state" (I included mutex unlock into exit_cond() for future safety) and BUG#4827 "KILL while START SLAVE may lead to replication slave crash" --- sql/lock.cc | 16 +++++++++------- sql/log.cc | 9 ++------- sql/repl_failsafe.cc | 9 +++++---- sql/slave.cc | 18 +++++++----------- sql/sql_class.h | 16 ++++++++++------ sql/sql_table.cc | 1 - 6 files changed, 33 insertions(+), 36 deletions(-) diff --git a/sql/lock.cc b/sql/lock.cc index 5010d115a6c..9ea1ce96175 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -692,15 +692,14 @@ bool lock_global_read_lock(THD *thd) while (protect_against_global_read_lock && !thd->killed) pthread_cond_wait(&COND_refresh, &LOCK_open); waiting_for_read_lock--; - thd->exit_cond(old_message); if (thd->killed) { - (void) pthread_mutex_unlock(&LOCK_open); + thd->exit_cond(old_message); DBUG_RETURN(1); } thd->global_read_lock=1; global_read_lock++; - (void) pthread_mutex_unlock(&LOCK_open); + thd->exit_cond(old_message); } DBUG_RETURN(0); } @@ -721,11 +720,12 @@ void unlock_global_read_lock(THD *thd) bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh) { const char *old_message; - bool result=0; + bool result= 0, need_exit_cond; DBUG_ENTER("wait_if_global_read_lock"); + LINT_INIT(old_message); (void) pthread_mutex_lock(&LOCK_open); - if (global_read_lock) + if (need_exit_cond= (bool)global_read_lock) { if (thd->global_read_lock) // This thread had the read locks { @@ -740,11 +740,13 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh) (void) pthread_cond_wait(&COND_refresh,&LOCK_open); if (thd->killed) result=1; - thd->exit_cond(old_message); } if (!abort_on_refresh && !result) protect_against_global_read_lock++; - pthread_mutex_unlock(&LOCK_open); + if (unlikely(need_exit_cond)) // global read locks are rare + thd->exit_cond(old_message); + else + pthread_mutex_unlock(&LOCK_open); DBUG_RETURN(result); } diff --git a/sql/log.cc b/sql/log.cc index a0e2196cc59..e031656cc6e 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1533,12 +1533,8 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length, NOTES One must have a lock on LOCK_log before calling this function. - This lock will be freed before return! - - The reason for the above is that for enter_cond() / exit_cond() to - work the mutex must be got before enter_cond() but releases before - exit_cond(). - If you don't do it this way, you will get a deadlock in THD::awake() + This lock will be freed before return! That's required by + THD::enter_cond() (see NOTES in sql_class.h). */ @@ -1551,7 +1547,6 @@ the I/O slave thread to update it" : "Has sent all binlog to slave; \ waiting for binlog to be updated"); pthread_cond_wait(&update_cond, &LOCK_log); - pthread_mutex_unlock(&LOCK_log); // See NOTES thd->exit_cond(old_msg); } diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 1edf452d5f6..604938a8ed0 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -584,6 +584,8 @@ pthread_handler_decl(handle_failsafe_rpl,arg) THD *thd = new THD; thd->thread_stack = (char*)&thd; MYSQL* recovery_captain = 0; + const char* msg; + pthread_detach_this_thread(); if (init_failsafe_rpl_thread(thd) || !(recovery_captain=mc_mysql_init(0))) { @@ -591,11 +593,11 @@ pthread_handler_decl(handle_failsafe_rpl,arg) goto err; } pthread_mutex_lock(&LOCK_rpl_status); + msg= thd->enter_cond(&COND_rpl_status, + &LOCK_rpl_status, "Waiting for request"); while (!thd->killed && !abort_loop) { bool break_req_chain = 0; - const char* msg = thd->enter_cond(&COND_rpl_status, - &LOCK_rpl_status, "Waiting for request"); pthread_cond_wait(&COND_rpl_status, &LOCK_rpl_status); thd->proc_info="Processing request"; while (!break_req_chain) @@ -613,9 +615,8 @@ pthread_handler_decl(handle_failsafe_rpl,arg) break; } } - thd->exit_cond(msg); } - pthread_mutex_unlock(&LOCK_rpl_status); + thd->exit_cond(msg); err: if (recovery_captain) mc_mysql_close(recovery_captain); diff --git a/sql/slave.cc b/sql/slave.cc index 2269fc8d8cf..4416a2544ef 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -582,7 +582,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, pthread_mutex_unlock(start_lock); DBUG_RETURN(ER_SLAVE_THREAD); } - if (start_cond && cond_lock) + if (start_cond && cond_lock) // caller has cond_lock { THD* thd = current_thd; while (start_id == *slave_run_id) @@ -592,11 +592,9 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, "Waiting for slave thread to start"); pthread_cond_wait(start_cond,cond_lock); thd->exit_cond(old_msg); + pthread_mutex_lock(cond_lock); // re-acquire it as exit_cond() released if (thd->killed) - { - pthread_mutex_unlock(cond_lock); DBUG_RETURN(ER_SERVER_SHUTDOWN); - } } } if (start_lock) @@ -1561,7 +1559,6 @@ thread to free enough relay log space"); !rli->ignore_log_space_limit) pthread_cond_wait(&rli->log_space_cond, &rli->log_space_lock); thd->exit_cond(save_proc_info); - pthread_mutex_unlock(&rli->log_space_lock); DBUG_RETURN(slave_killed); } @@ -1965,6 +1962,9 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, (long) timeout)); pthread_mutex_lock(&data_lock); + const char *msg= thd->enter_cond(&data_cond, &data_lock, + "Waiting for the SQL slave thread to " + "advance position"); /* This function will abort when it notices that some CHANGE MASTER or RESET MASTER has changed the master info. @@ -2063,9 +2063,6 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, //wait for master update, with optional timeout. DBUG_PRINT("info",("Waiting for master update")); - const char* msg = thd->enter_cond(&data_cond, &data_lock, - "Waiting for the SQL slave thread to \ -advance position"); /* We are going to pthread_cond_(timed)wait(); if the SQL thread stops it will wake us up. @@ -2087,8 +2084,7 @@ advance position"); } else pthread_cond_wait(&data_cond, &data_lock); - DBUG_PRINT("info",("Got signal of master update")); - thd->exit_cond(msg); + DBUG_PRINT("info",("Got signal of master update or timed out")); if (error == ETIMEDOUT || error == ETIME) { error= -1; @@ -2100,7 +2096,7 @@ advance position"); } err: - pthread_mutex_unlock(&data_lock); + thd->exit_cond(msg); DBUG_PRINT("exit",("killed: %d abort: %d slave_running: %d \ improper_arguments: %d timed_out: %d", (int) thd->killed, diff --git a/sql/sql_class.h b/sql/sql_class.h index df246b42337..e646d33fe5d 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -537,12 +537,9 @@ public: void awake(bool prepare_to_die); /* For enter_cond() / exit_cond() to work the mutex must be got before - enter_cond() but released before exit_cond() (in 4.1, assertions will soon - ensure this). Use must be: - lock mutex; enter_cond(); ...; unlock mutex; exit_cond(). - If you don't do it this way, you will get a deadlock if another thread is - doing a THD::awake() on you. - + enter_cond() (in 4.1 an assertion will soon ensure this); this mutex is + then released by exit_cond(). Use must be: + lock mutex; enter_cond(); your code; exit_cond(). */ inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex, const char* msg) @@ -555,6 +552,13 @@ public: } inline void exit_cond(const char* old_msg) { + /* + Putting the mutex unlock in exit_cond() ensures that + mysys_var->current_mutex is always unlocked _before_ mysys_var->mutex is + locked (if that would not be the case, you'll get a deadlock if someone + does a THD::awake() on you). + */ + pthread_mutex_unlock(mysys_var->current_mutex); pthread_mutex_lock(&mysys_var->mutex); mysys_var->current_mutex = 0; mysys_var->current_cond = 0; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9ab4859bc13..7f4a8583b78 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1301,7 +1301,6 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, dropping_tables--; } thd->exit_cond(old_message); - pthread_mutex_unlock(&LOCK_open); if (thd->killed) goto err; open_for_modify=0; From 22ca5582d005754d3907ce6bc088ba2d9710d1eb Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Sat, 31 Jul 2004 22:39:10 +0200 Subject: [PATCH 24/63] BUG#4393, BUG#4356 - incorrect decimals in fix_length_and_dec() in some functions --- mysql-test/mysql-test-run.sh | 2 ++ mysql-test/r/func_math.result | 24 ++++++++++++------------ mysql-test/r/type_float.result | 11 +++++++---- mysql-test/t/type_float.test | 9 +++++++-- sql/item_func.cc | 4 ++-- sql/item_func.h | 2 +- sql/item_sum.h | 12 ++++++++++-- 7 files changed, 41 insertions(+), 23 deletions(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 449b7015188..cd6c331687f 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -589,6 +589,8 @@ show_failed_diff () echo "Please follow the instructions outlined at" echo "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html" echo "to find the reason to this problem and how to report this." + echo "" + echo "Test $1 failed!" fi } diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 46ad7a14e25..d90071e0b56 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -18,44 +18,44 @@ abs(-10) sign(-5) sign(5) sign(0) 10 -1 1 0 select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2); log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2) -10.000000 10.000000 NULL NULL NULL 2.000000 NULL NULL +10 10 NULL NULL NULL 2 NULL NULL select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL); ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL) -10.000000 10.000000 NULL NULL NULL +10 10 NULL NULL NULL select log2(8),log2(15),log2(-2),log2(0),log2(NULL); log2(8) log2(15) log2(-2) log2(0) log2(NULL) -3.000000 3.906891 NULL NULL NULL +3 3.9068905956085 NULL NULL NULL select log10(100),log10(18),log10(-4),log10(0),log10(NULL); log10(100) log10(18) log10(-4) log10(0) log10(NULL) -2.000000 1.255273 NULL NULL NULL +2 1.2552725051033 NULL NULL NULL select pow(10,log10(10)),power(2,4); pow(10,log10(10)) power(2,4) -10.000000 16.000000 +10 16 set @@rand_seed1=10000000,@@rand_seed2=1000000; select rand(999999),rand(); rand(999999) rand() 0.014231365187309 0.028870999839968 select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1); pi() sin(pi()/2) cos(pi()/2) abs(tan(pi())) cot(1) asin(1) acos(0) atan(1) -3.141593 1.000000 0.000000 0.000000 0.64209262 1.570796 1.570796 0.785398 +3.141593 1 6.1230317691119e-17 1.2246063538224e-16 0.64209261593433 1.5707963267949 1.5707963267949 0.78539816339745 select degrees(pi()),radians(360); degrees(pi()) radians(360) 180 6.2831853071796 SELECT ACOS(1.0); ACOS(1.0) -0.000000 +0 SELECT ASIN(1.0); ASIN(1.0) -1.570796 +1.5707963267949 SELECT ACOS(0.2*5.0); ACOS(0.2*5.0) -0.000000 +0 SELECT ACOS(0.5*2.0); ACOS(0.5*2.0) -0.000000 +0 SELECT ASIN(0.8+0.2); ASIN(0.8+0.2) -1.570796 +1.5707963267949 SELECT ASIN(1.2-0.2); ASIN(1.2-0.2) -1.570796 +1.5707963267949 diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index c9996e9c9f3..61b90c8cf2e 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -72,14 +72,17 @@ insert t1 values (121,"16"); select c1 + c1 * (c2 / 100) as col from t1; col 140.36 -create table t2 select c1 + c1 * (c2 / 100) as col from t1; +create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1; select * from t2; -col -140.36 +col1 col2 col3 col4 +140.36 121.00000 121 3.47850542618522e-07 show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `col` double default NULL + `col1` double default NULL, + `col2` double(22,5) default NULL, + `col3` double default NULL, + `col4` double default NULL ) TYPE=MyISAM drop table t1,t2; create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6)); diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 65d594387b9..bd6448616dc 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -28,10 +28,14 @@ select a from t1 order by a; select min(a) from t1; drop table t1; +# +# BUG#3612, BUG#4393, BUG#4356, BUG#4394 +# + create table t1 (c1 double, c2 varchar(20)); insert t1 values (121,"16"); select c1 + c1 * (c2 / 100) as col from t1; -create table t2 select c1 + c1 * (c2 / 100) as col from t1; +create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1; select * from t2; show create table t2; drop table t1,t2; @@ -52,6 +56,7 @@ drop table t1; # Errors -!$1063 create table t1 (f float(54)); # Should give an error +--error 1063 +create table t1 (f float(54)); # Should give an error drop table if exists t1; diff --git a/sql/item_func.cc b/sql/item_func.cc index 368c14cc8df..237db890abb 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -684,7 +684,7 @@ void Item_func_round::fix_length_and_dec() if (tmp < 0) decimals=0; else - decimals=tmp; + decimals=min(tmp,NOT_FIXED_DEC); } } @@ -1286,7 +1286,7 @@ udf_handler::fix_fields(THD *thd,TABLE_LIST *tables,Item_result_field *func, func->max_length=min(initid.max_length,MAX_BLOB_WIDTH); func->maybe_null=initid.maybe_null; const_item_cache=initid.const_item; - func->decimals=min(initid.decimals,31); + func->decimals=min(initid.decimals,NOT_FIXED_DEC); } initialized=1; if (error) diff --git a/sql/item_func.h b/sql/item_func.h index 4d171cda490..8a013f42c05 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -295,7 +295,7 @@ class Item_dec_func :public Item_real_func Item_dec_func(Item *a,Item *b) :Item_real_func(a,b) {} void fix_length_and_dec() { - decimals=6; max_length=float_length(decimals); + decimals=NOT_FIXED_DEC; max_length=float_length(decimals); maybe_null=1; } inline double fix_result(double value) diff --git a/sql/item_sum.h b/sql/item_sum.h index 6835b1e8fae..802e3f1ba45 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -234,7 +234,11 @@ public: class Item_sum_avg :public Item_sum_num { - void fix_length_and_dec() { decimals+=4; maybe_null=1; } + void fix_length_and_dec() + { + decimals=min(decimals+4, NOT_FIXED_DEC); + maybe_null=1; + } double sum; ulonglong count; @@ -276,7 +280,11 @@ class Item_sum_std :public Item_sum_num double sum; double sum_sqr; ulonglong count; - void fix_length_and_dec() { decimals+=4; maybe_null=1; } + void fix_length_and_dec() + { + decimals=min(decimals+4, NOT_FIXED_DEC); + maybe_null=1; + } public: Item_sum_std(Item *item_par) :Item_sum_num(item_par),count(0) {} From f4244cd00e0a97b1e92f78fef4da3cfdad2664ca Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Sun, 1 Aug 2004 13:26:01 +0200 Subject: [PATCH 25/63] bug#4816. index search for NULL in blob --- myisam/mi_key.c | 2 ++ mysql-test/r/myisam.result | 9 +++++++++ mysql-test/t/myisam.test | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 766ecf334b6..1688ab74823 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -177,6 +177,8 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, if (!(*key++= (char) 1-*old++)) /* Copy null marker */ { k_length-=length; + if (keyseg->flag & (HA_VAR_LENGTH | HA_BLOB_PART)) + k_length-=2; /* Skip length */ continue; /* Found NULL */ } } diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 1fd64377f12..c55bacdd371 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -453,3 +453,12 @@ table type possible_keys key key_len ref rows Extra t1 system NULL NULL NULL NULL 1 Using temporary t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct drop table t1,t2; +create table t1 ( a tinytext, b char(1), index idx (a(1),b) ); +insert into t1 values (null,''), (null,''); +explain select count(*) from t1 where a is null; +table type possible_keys key key_len ref rows Extra +t1 ref idx idx 4 const 1 Using where +select count(*) from t1 where a is null; +count(*) +2 +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 59b86309d77..57b64e30bac 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -436,3 +436,13 @@ select sql_big_result distinct t1.a from t1,t2; explain select sql_big_result distinct t1.a from t1,t2 order by t2.a; explain select distinct t1.a from t1,t2 order by t2.a; drop table t1,t2; + +# +# index search for NULL in blob. Bug #4816 +# +create table t1 ( a tinytext, b char(1), index idx (a(1),b) ); +insert into t1 values (null,''), (null,''); +explain select count(*) from t1 where a is null; +select count(*) from t1 where a is null; +drop table t1; + From 2f3e628649f350df22c4c06b3dc798b4a1467935 Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Mon, 2 Aug 2004 13:02:34 +0300 Subject: [PATCH 26/63] dyn0dyn.h: dyn_array_open(): mention the size limit mtr0log.ic, mtr0log.h: mlog_open(): mention the size limit --- innobase/include/dyn0dyn.h | 3 ++- innobase/include/mtr0log.h | 3 ++- innobase/include/mtr0log.ic | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/innobase/include/dyn0dyn.h b/innobase/include/dyn0dyn.h index 501fde05e90..abee62300e3 100644 --- a/innobase/include/dyn0dyn.h +++ b/innobase/include/dyn0dyn.h @@ -47,7 +47,8 @@ dyn_array_open( /*===========*/ /* out: pointer to the buffer */ dyn_array_t* arr, /* in: dynamic array */ - ulint size); /* in: size in bytes of the buffer */ + ulint size); /* in: size in bytes of the buffer; MUST be + smaller than DYN_ARRAY_DATA_SIZE! */ /************************************************************************* Closes the buffer returned by dyn_array_open. */ UNIV_INLINE diff --git a/innobase/include/mtr0log.h b/innobase/include/mtr0log.h index 785985dea16..be671e119e3 100644 --- a/innobase/include/mtr0log.h +++ b/innobase/include/mtr0log.h @@ -98,7 +98,8 @@ mlog_open( /*======*/ /* out: buffer, NULL if log mode MTR_LOG_NONE */ mtr_t* mtr, /* in: mtr */ - ulint size); /* in: buffer size in bytes */ + ulint size); /* in: buffer size in bytes; MUST be + smaller than DYN_ARRAY_DATA_SIZE! */ /************************************************************ Closes a buffer opened to mlog. */ UNIV_INLINE diff --git a/innobase/include/mtr0log.ic b/innobase/include/mtr0log.ic index b0392e214f1..e544a38330f 100644 --- a/innobase/include/mtr0log.ic +++ b/innobase/include/mtr0log.ic @@ -18,7 +18,8 @@ mlog_open( /*======*/ /* out: buffer, NULL if log mode MTR_LOG_NONE */ mtr_t* mtr, /* in: mtr */ - ulint size) /* in: buffer size in bytes */ + ulint size) /* in: buffer size in bytes; MUST be + smaller than DYN_ARRAY_DATA_SIZE! */ { dyn_array_t* mlog; From 6ce0b07a998d69792bef975e28c6dd64af07a4bc Mon Sep 17 00:00:00 2001 From: "tim@sand.box" <> Date: Wed, 4 Aug 2004 10:12:57 -0600 Subject: [PATCH 27/63] Print MYSQL_COMPILATION_COMMENT after ER_READY on server startup --- sql/mysqld.cc | 3 +++ sql/share/czech/errmsg.txt | 2 +- sql/share/danish/errmsg.txt | 2 +- sql/share/dutch/errmsg.txt | 2 +- sql/share/english/errmsg.txt | 2 +- sql/share/estonian/errmsg.txt | 2 +- sql/share/french/errmsg.txt | 2 +- sql/share/german/errmsg.txt | 2 +- sql/share/greek/errmsg.txt | 2 +- sql/share/hungarian/errmsg.txt | 2 +- sql/share/japanese/errmsg.txt | 2 +- sql/share/korean/errmsg.txt | 2 +- sql/share/norwegian-ny/errmsg.txt | 2 +- sql/share/norwegian/errmsg.txt | 2 +- sql/share/polish/errmsg.txt | 2 +- sql/share/portuguese/errmsg.txt | 2 +- sql/share/romanian/errmsg.txt | 2 +- sql/share/russian/errmsg.txt | 2 +- sql/share/slovak/errmsg.txt | 2 +- sql/share/spanish/errmsg.txt | 2 +- sql/share/swedish/errmsg.txt | 2 +- sql/share/ukrainian/errmsg.txt | 2 +- 22 files changed, 24 insertions(+), 21 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 80e9292a873..55f58e9970e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2614,6 +2614,9 @@ server."); printf(ER(ER_READY),my_progname,server_version, ((unix_sock == INVALID_SOCKET) ? (char*) "" : mysql_unix_port), mysql_port); + if (MYSQL_COMPILATION_COMMENT[0] != '\0') + fputs(" " MYSQL_COMPILATION_COMMENT, stdout); + putchar('\n'); fflush(stdout); #ifdef __NT__ diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index e36475d7803..b6737df91e1 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -86,7 +86,7 @@ "Blob sloupec '%-.64s' nem-Bù¾e být pou¾it jako klíè", "P-Bøíli¹ velká délka sloupce '%-.64s' (nejvíce %d). Pou¾ijte BLOB", "M-Bù¾ete mít pouze jedno AUTO pole a to musí být definováno jako klíè", -"%s: p-Bøipraven na spojení\n", +"%s: p-Bøipraven na spojení", "%s: norm-Bální ukonèení\n", "%s: p-Bøijat signal %d, konèím\n", "%s: ukon-Bèení práce hotovo\n", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 4e612c599ec..ba50c78e92c 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -80,7 +80,7 @@ "BLOB feltet '%-.64s' kan ikke bruges ved specifikation af indeks", "For stor feltlængde for kolonne '%-.64s' (maks = %d). Brug BLOB i stedet", "Der kan kun specificeres eet AUTO_INCREMENT-felt, og det skal være indekseret", -"%s: klar til tilslutninger\n", +"%s: klar til tilslutninger", "%s: Normal nedlukning\n", "%s: Fangede signal %d. Afslutter!!\n", "%s: Server lukket\n", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 4aafa51e856..1b9c1025e69 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -88,7 +88,7 @@ "BLOB kolom '%-.64s' kan niet gebruikt worden bij zoeksleutel specificatie", "Te grote kolomlengte voor '%-.64s' (max = %d). Maak hiervoor gebruik van het type BLOB", "Er kan slechts 1 autofield zijn en deze moet als zoeksleutel worden gedefinieerd.", -"%s: klaar voor verbindingen\n", +"%s: klaar voor verbindingen", "%s: Normaal afgesloten \n", "%s: Signaal %d. Systeem breekt af!\n", "%s: Afsluiten afgerond\n", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index dca9311b277..edbf2357ff8 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -77,7 +77,7 @@ "BLOB column '%-.64s' can't be used in key specification with the used table type", "Too big column length for column '%-.64s' (max = %d). Use BLOB instead", "Incorrect table definition; There can only be one auto column and it must be defined as a key", -"%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d\n", +"%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d", "%s: Normal shutdown\n", "%s: Got signal %d. Aborting!\n", "%s: Shutdown Complete\n", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index f583568193f..8ec5d4b29f0 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -82,7 +82,7 @@ "BLOB-tüüpi tulpa '%-.64s' ei saa kasutada võtmena", "Tulba '%-.64s' pikkus on liiga pikk (maksimaalne pikkus: %d). Kasuta BLOB väljatüüpi", "Vigane tabelikirjeldus; Tabelis tohib olla üks auto_increment tüüpi tulp ning see peab olema defineeritud võtmena", -"%s: ootab ühendusi\n", +"%s: ootab ühendusi", "%s: MySQL lõpetas\n", "%s: sain signaali %d. Lõpetan!\n", "%s: Lõpp\n", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index cabb22a6494..3c5c827aa62 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -77,7 +77,7 @@ "Champ BLOB '%-.64s' ne peut être utilisé dans une clé", "Champ '%-.64s' trop long (max = %d). Utilisez un BLOB", "Un seul champ automatique est permis et il doit être indexé", -"%s: Prêt pour des connections\n", +"%s: Prêt pour des connections", "%s: Arrêt normal du serveur\n", "%s: Reçu le signal %d. Abandonne!\n", "%s: Arrêt du serveur terminé\n", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 518cb507466..3960dcc2122 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -80,7 +80,7 @@ "BLOB-Feld '%-.64s' kann nicht als Schlüssel verwendet werden.", "Feldlänge für Feld '%-.64s' zu groß (max = %d). BLOB-Feld verwenden!", "Nur ein Auto-Feld möglich, welches als Schlüssel definiert werden muß.", -"%-.64s: Warten auf Verbindungen.\n", +"%-.64s: Warten auf Verbindungen", "%-.64s: Normal beendet.\n", "%-.64s: Signal %d erhalten. Abbruch!\n", "%-.64s: Shutdown ausgeführt.\n", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index d993d80dcc1..3e9a68f2b4b 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -77,7 +77,7 @@ "Ðåäßï ôýðïõ Blob '%-.64s' äåí ìðïñåß íá ÷ñçóéìïðïéçèåß óôïí ïñéóìü åíüò êëåéäéïý (key specification)", "Ðïëý ìåãÜëï ìÞêïò ãéá ôï ðåäßï '%-.64s' (max = %d). Ðáñáêáëþ ÷ñçóéìïðïéåßóôå ôïí ôýðï BLOB", "Ìðïñåß íá õðÜñ÷åé ìüíï Ýíá auto field êáé ðñÝðåé íá Ý÷åé ïñéóèåß óáí key", -"%s: óå áíáìïíÞ óõíäÝóåùí\n", +"%s: óå áíáìïíÞ óõíäÝóåùí", "%s: ÖõóéïëïãéêÞ äéáäéêáóßá shutdown\n", "%s: ÅëÞöèç ôï ìÞíõìá %d. Ç äéáäéêáóßá åãêáôáëåßðåôáé!\n", "%s: Ç äéáäéêáóßá Shutdown ïëïêëçñþèçêå\n", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 4a65e735ef9..9da878981b0 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -79,7 +79,7 @@ "Blob objektum '%-.64s' nem hasznalhato kulcskent", "A(z) '%-.64s' oszlop tul hosszu. (maximum = %d). Hasznaljon BLOB tipust inkabb.", "Csak egy auto mezo lehetseges, es azt kulcskent kell definialni.", -"%s: kapcsolatra kesz\n", +"%s: kapcsolatra kesz", "%s: Normal leallitas\n", "%s: %d jelzes. Megszakitva!\n", "%s: A leallitas kesz\n", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index c384c4bded4..7e267261a2e 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -79,7 +79,7 @@ "BLOB column '%-.64s' can't be used in key specification with the used table type", "column '%-.64s' ¤Ï,³ÎÊݤ¹¤ë column ¤ÎÂ礭¤µ¤¬Â¿¤¹¤®¤Þ¤¹. (ºÇÂç %d ¤Þ¤Ç). BLOB ¤ò¤«¤ï¤ê¤Ë»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤.", "¥Æ¡¼¥Ö¥ë¤ÎÄêµÁ¤¬°ã¤¤¤Þ¤¹; There can only be one auto column and it must be defined as a key", -"%s: ½àÈ÷´°Î»\n", +"%s: ½àÈ÷´°Î»", "%s: Normal shutdown\n", "%s: Got signal %d. ÃæÃÇ!\n", "%s: Shutdown ´°Î»\n", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index b706069b495..1ad5432f4db 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -77,7 +77,7 @@ "BLOB Ä®·³ '%-.64s'´Â Ű Á¤ÀÇ¿¡¼­ »ç¿ëµÉ ¼ö ¾ø½À´Ï´Ù.", "Ä®·³ '%-.64s'ÀÇ Ä®·³ ±æÀ̰¡ ³Ê¹« ±é´Ï´Ù (ÃÖ´ë = %d). ´ë½Å¿¡ BLOB¸¦ »ç¿ëÇϼ¼¿ä.", "ºÎÁ¤È®ÇÑ Å×À̺í Á¤ÀÇ; Å×À̺íÀº ÇϳªÀÇ auto Ä®·³ÀÌ Á¸ÀçÇϰí Ű·Î Á¤ÀǵǾîÁ®¾ß ÇÕ´Ï´Ù.", -"%s: ¿¬°á ÁغñÁßÀÔ´Ï´Ù.\n", +"%s: ¿¬°á ÁغñÁßÀÔ´Ï´Ù", "%s: Á¤»óÀûÀÎ shutdown\n", "%s: %d ½ÅÈ£°¡ µé¾î¿ÔÀ½. ÁßÁö!\n", "%s: Shutdown ÀÌ ¿Ï·áµÊ!\n", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 2c1deead312..234a53b53fb 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -79,7 +79,7 @@ "Blob kolonne '%-.64s' kan ikkje brukast ved spesifikasjon av nyklar", "For stor nykkellengde for felt '%-.64s' (maks = %d). Bruk BLOB istadenfor", "Bare eitt auto felt kan være definert som nøkkel.", -"%s: klar for tilkoblingar\n", +"%s: klar for tilkoblingar", "%s: Normal nedkopling\n", "%s: Oppdaga signal %d. Avsluttar!\n", "%s: Nedkopling komplett\n", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 42b35c18cfc..e582786dc6e 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -79,7 +79,7 @@ "Blob felt '%-.64s' kan ikke brukes ved spesifikasjon av nøkler", "For stor nøkkellengde for kolonne '%-.64s' (maks = %d). Bruk BLOB istedenfor", "Bare ett auto felt kan være definert som nøkkel.", -"%s: klar for tilkoblinger\n", +"%s: klar for tilkoblinger", "%s: Normal avslutning\n", "%s: Oppdaget signal %d. Avslutter!\n", "%s: Avslutning komplett\n", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index d8e84b08a9a..a4d11046ea4 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -81,7 +81,7 @@ "Kolumna typu Blob '%-.64s' nie mo¿e byæ u¿yta w specyfikacji klucza", "Zbyt du¿a d³ugo?æ kolumny '%-.64s' (maks. = %d). W zamian u¿yj typu BLOB", "W tabeli mo¿e byæ tylko jedno pole auto i musi ono byæ zdefiniowane jako klucz", -"%s: gotowe do po³?czenia\n", +"%s: gotowe do po³?czenia", "%s: Standardowe zakoñczenie dzia³ania\n", "%s: Otrzymano sygna³ %d. Koñczenie dzia³ania!\n", "%s: Zakoñczenie dzia³ania wykonane\n", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index a1b5e87a52d..14c14270dc0 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -77,7 +77,7 @@ "Coluna BLOB '%-.64s' não pode ser utilizada na especificação de chave para o tipo de tabela usado", "Comprimento da coluna '%-.64s' grande demais (max = %d). Use BLOB em seu lugar", "Definição incorreta de tabela. Somente é permitido um único campo auto-incrementado e ele tem que ser definido como chave", -"%s: Pronto para conexões\n", +"%s: Pronto para conexões", "%s: 'Shutdown' normal\n", "%s: Obteve sinal %d. Abortando!\n", "%s: 'Shutdown' completo\n", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 44e8b9fa8de..8d2decdf23f 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -81,7 +81,7 @@ "Coloana de tip BLOB '%-.64s' nu poate fi folosita in specificarea cheii cu tipul de tabla folosit", "Lungimea coloanei '%-.64s' este prea lunga (maximum = %d). Foloseste BLOB mai bine", "Definitia tabelei este incorecta; Nu pot fi mai mult de o singura coloana de tip auto si aceasta trebuie definita ca cheie", -"%s: sint gata pentru conectii\n", +"%s: sint gata pentru conectii", "%s: Terminare normala\n", "%s: Semnal %d obtinut. Aborting!\n", "%s: Terminare completa\n", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 472031c6300..42845b57d76 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -79,7 +79,7 @@ "óÔÏÌÂÅà ÔÉÐÁ BLOB '%-.64s' ÎÅ ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎ ËÁË ÚÎÁÞÅÎÉÅ ËÌÀÞÁ × ÔÁÂÌÉÃÅ ÔÁËÏÇÏ ÔÉÐÁ", "óÌÉÛËÏÍ ÂÏÌØÛÁÑ ÄÌÉÎÁ ÓÔÏÌÂÃÁ '%-.64s' (ÍÁËÓÉÍÕÍ = %d). éÓÐÏÌØÚÕÊÔÅ ÔÉÐ BLOB ×ÍÅÓÔÏ ÔÅËÕÝÅÇÏ", "îÅËÏÒÒÅËÔÎÏÅ ÏÐÒÅÄÅÌÅÎÉÅ ÔÁÂÌÉÃÙ: ÍÏÖÅÔ ÓÕÝÅÓÔ×Ï×ÁÔØ ÔÏÌØËÏ ÏÄÉÎ Á×ÔÏÉÎËÒÅÍÅÎÔÎÙÊ ÓÔÏÌÂÅÃ, É ÏÎ ÄÏÌÖÅÎ ÂÙÔØ ÏÐÒÅÄÅÌÅÎ ËÁË ËÌÀÞ", -"%s: çÏÔÏ× ÐÒÉÎÉÍÁÔØ ÓÏÅÄÉÎÅÎÉÑ.\n÷ÅÒÓÉÑ: '%s' ÓÏËÅÔ: '%s' ÐÏÒÔ: %d\n", +"%s: çÏÔÏ× ÐÒÉÎÉÍÁÔØ ÓÏÅÄÉÎÅÎÉÑ.\n÷ÅÒÓÉÑ: '%s' ÓÏËÅÔ: '%s' ÐÏÒÔ: %d", "%s: ëÏÒÒÅËÔÎÁÑ ÏÓÔÁÎÏ×ËÁ\n", "%s: ðÏÌÕÞÅÎ ÓÉÇÎÁÌ %d. ðÒÅËÒÁÝÁÅÍ!\n", "%s: ïÓÔÁÎÏ×ËÁ ÚÁ×ÅÒÛÅÎÁ\n", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 411f93b97da..52ed69a238d 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -85,7 +85,7 @@ "Blob pole '%-.64s' nemô¾e by» pou¾ité ako kµúè", "Príli¹ veµká då¾ka pre pole '%-.64s' (maximum = %d). Pou¾ite BLOB", "Mô¾ete ma» iba jedno AUTO pole a to musí by» definované ako kµúè", -"%s: pripravený na spojenie\n", +"%s: pripravený na spojenie", "%s: normálne ukonèenie\n", "%s: prijatý signál %d, ukonèenie (Abort)!\n", "%s: práca ukonèená\n", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 0010769aa4f..2ed3c19b68e 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -78,7 +78,7 @@ "La columna Blob '%-.64s' no puede ser usada en una declaracion de clave", "Longitud de columna demasiado grande para la columna '%-.64s' (maximo = %d).Usar BLOB en su lugar", "Puede ser solamente un campo automatico y este debe ser definido como una clave", -"%s: preparado para conexiones\n", +"%s: preparado para conexiones", "%s: Apagado normal\n", "%s: Recibiendo signal %d. Abortando!\n", "%s: Apagado completado\n", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 508737dde2f..4fd05875b43 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -77,7 +77,7 @@ "En BLOB '%-.64s' kan inte vara nyckel med den använda tabelltypen", "För stor kolumnlängd angiven för '%-.64s' (max= %d). Använd en BLOB instället", "Det får finnas endast ett AUTO_INCREMENT-fält och detta måste vara en nyckel", -"%s: klar att ta emot klienter\n", +"%s: klar att ta emot klienter", "%s: Normal avslutning\n", "%s: Fick signal %d. Avslutar!\n", "%s: Avslutning klar\n", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 372cfa78dff..6036f4be2d5 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -82,7 +82,7 @@ "BLOB ÓÔÏ×ÂÅÃØ '%-.64s' ÎÅ ÍÏÖÅ ÂÕÔÉ ×ÉËÏÒÉÓÔÁÎÉÊ Õ ×ÉÚÎÁÞÅÎΦ ËÌÀÞÁ × ÃØÏÍÕ ÔÉЦ ÔÁÂÌÉæ", "úÁÄÏ×ÇÁ ÄÏ×ÖÉÎÁ ÓÔÏ×ÂÃÑ '%-.64s' (max = %d). ÷ÉËÏÒÉÓÔÁÊÔÅ ÔÉÐ BLOB", "îÅצÒÎÅ ×ÉÚÎÁÞÅÎÎÑ ÔÁÂÌÉæ; íÏÖÅ ÂÕÔÉ ÌÉÛÅ ÏÄÉÎ Á×ÔÏÍÁÔÉÞÎÉÊ ÓÔÏ×ÂÅÃØ, ÝÏ ÐÏ×ÉÎÅÎ ÂÕÔÉ ×ÉÚÎÁÞÅÎÉÊ ÑË ËÌÀÞ", -"%s: çÏÔÏ×ÉÊ ÄÌÑ Ú'¤ÄÎÁÎØ!\n", +"%s: çÏÔÏ×ÉÊ ÄÌÑ Ú'¤ÄÎÁÎØ!", "%s: îÏÒÍÁÌØÎÅ ÚÁ×ÅÒÛÅÎÎÑ\n", "%s: ïÔÒÉÍÁÎÏ ÓÉÇÎÁÌ %d. ðÅÒÅÒÉ×ÁÀÓØ!\n", "%s: òÏÂÏÔÕ ÚÁ×ÅÒÛÅÎÏ\n", From e5cb60dcaad6a17a6368321e7a02ed9299c8c5ac Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 5 Aug 2004 01:54:04 +0200 Subject: [PATCH 28/63] - applied the required changes to create the FOSS License exception file "EXCEPTIONS" and include it in the source and binary distributions --- Build-tools/mysql-copyright | 1 + Docs/Makefile.am | 7 +++++-- scripts/make_binary_distribution.sh | 2 +- support-files/mysql.spec.sh | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Build-tools/mysql-copyright b/Build-tools/mysql-copyright index f3a2a2960ea..231482806ee 100755 --- a/Build-tools/mysql-copyright +++ b/Build-tools/mysql-copyright @@ -101,6 +101,7 @@ sub main # on the toplevel of the directory instead. file 'PUBLIC' shouldn't # exist in the new mysql distributions, but let's be sure.. unlink("$destdir/PUBLIC", "$destdir/README"); + unlink("$destdir/COPYING", "$destdir/EXCEPTIONS"); copy("$WD/Docs/MySQLEULA.txt", "$destdir"); # remove readline subdir and update configure accordingly diff --git a/Docs/Makefile.am b/Docs/Makefile.am index 9a77202a91b..fe203a4d0bf 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -26,7 +26,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) $(BUILT_SOURCES) mysqld_error.txt \ all: $(targets) txt_files -txt_files: ../INSTALL-SOURCE ../COPYING \ +txt_files: ../INSTALL-SOURCE ../COPYING ../EXCEPTIONS \ INSTALL-BINARY ../support-files/MacOSX/ReadMe.txt CLEAN_FILES: $(BUILD_SOURCES) @@ -202,7 +202,10 @@ INSTALL-BINARY: mysql.info $(GT) perl -w $(GT) mysql.info "Installing binary" "Installing source" > $@ ../COPYING: mysql.info $(GT) - perl -w $(GT) mysql.info "GPL license" "Function Index" > $@ + perl -w $(GT) mysql.info "GPL license" "MySQL FOSS License Exception" > $@ + +../EXCEPTIONS: mysql.info $(GT) + perl -w $(GT) mysql.info "MySQL FOSS License Exception" "Function Index" > $@ ../support-files/MacOSX/ReadMe.txt: mysql.info $(GT) perl -w $(GT) mysql.info "Mac OS X installation" "NetWare installation" > $@ diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index ea64f5ccfbd..d78a7ee28b9 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -86,7 +86,7 @@ do done for i in COPYING COPYING.LIB README Docs/INSTALL-BINARY \ - MySQLEULA.txt LICENSE.doc README.NW + EXCEPTIONS MySQLEULA.txt LICENSE.doc README.NW do if [ -f $i ] then diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 5ddc19580f3..9670ccf569d 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -446,7 +446,7 @@ fi %files server %defattr(-,root,root,0755) -%doc COPYING README +%doc COPYING EXCEPTIONS README %doc Docs/manual.{html,ps,texi,txt} %doc Docs/manual_toc.html %doc support-files/my-*.cnf From 26f0fdd5e8c8ddf745105f823cd2dfadc9e02a70 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 5 Aug 2004 11:22:02 +0200 Subject: [PATCH 29/63] - More changes to include the FLOSS License Exception in the various distributions --- Docs/Makefile.am | 4 ++-- Makefile.am | 2 +- scripts/make_win_src_distribution.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Docs/Makefile.am b/Docs/Makefile.am index fe203a4d0bf..06e4b4cfd6a 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -202,10 +202,10 @@ INSTALL-BINARY: mysql.info $(GT) perl -w $(GT) mysql.info "Installing binary" "Installing source" > $@ ../COPYING: mysql.info $(GT) - perl -w $(GT) mysql.info "GPL license" "MySQL FOSS License Exception" > $@ + perl -w $(GT) mysql.info "GPL license" "MySQL FLOSS License Exception" > $@ ../EXCEPTIONS: mysql.info $(GT) - perl -w $(GT) mysql.info "MySQL FOSS License Exception" "Function Index" > $@ + perl -w $(GT) mysql.info "MySQL FLOSS License Exception" "Function Index" > $@ ../support-files/MacOSX/ReadMe.txt: mysql.info $(GT) perl -w $(GT) mysql.info "Mac OS X installation" "NetWare installation" > $@ diff --git a/Makefile.am b/Makefile.am index 8a5df17c2cb..8e524871d7a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,7 @@ AUTOMAKE_OPTIONS = foreign # These are built from source in the Docs directory -EXTRA_DIST = INSTALL-SOURCE README COPYING +EXTRA_DIST = INSTALL-SOURCE README COPYING EXCEPTIONS SUBDIRS = . include @docs_dirs@ @readline_dir@ \ @thread_dirs@ pstack @sql_client_dirs@ \ @sql_server_dirs@ scripts man tests \ diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 135c2a38f87..8837628a1a5 100644 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -272,7 +272,7 @@ touch $BASE/innobase/ib_config.h # cd $SOURCE -for i in COPYING ChangeLog README \ +for i in COPYING ChangeLog README EXCEPTIONS\ INSTALL-SOURCE INSTALL-WIN \ INSTALL-WIN-SOURCE \ Docs/manual_toc.html Docs/manual.html \ From b6c0b67cf6df7a7245083a801e8f308da7c89c04 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 5 Aug 2004 11:59:17 +0200 Subject: [PATCH 30/63] - Fixed libmysql license texts: added reference to the FLOSS EXCEPTIONS file and amended the GPL text as requested by Zak --- libmysql/Makefile.am | 15 +++++++++------ libmysql/Makefile.shared | 39 +++++++++++++++++++++------------------ libmysql/conf_to_src.c | 9 ++++++--- libmysql/dll.c | 9 ++++++--- libmysql/errmsg.c | 9 ++++++--- libmysql/get_password.c | 9 ++++++--- libmysql/libmysql.c | 9 ++++++--- libmysql/manager.c | 9 ++++++--- libmysql_r/Makefile.am | 17 ++++++++++------- 9 files changed, 76 insertions(+), 49 deletions(-) diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index 686f7807949..1d80aae8e5c 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -1,9 +1,12 @@ -# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +# Copyright (C) 2000-2004 MySQL 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 program is free software; you can redistribute it and/or modify +# it under the terms of version 2 GNU General Public License as +# published by the Free Software Foundation. +# +# There are special exceptions to the terms and conditions of the GPL as it +# is applied to this software. View the full text of the exception in file +# EXCEPTIONS in the directory of this software distribution. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,7 +17,7 @@ # License along with this library; if not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA - +# # This file is public domain and comes with NO WARRANTY of any kind target = libmysqlclient.la diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index 764983506d1..9e97e6b00eb 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -1,21 +1,24 @@ -## 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 -## -## This file is public domain and comes with NO WARRANTY of any kind +# Copyright (C) 2000-2004 MySQL AB +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 GNU General Public License as +# published by the Free Software Foundation. +# +# There are special exceptions to the terms and conditions of the GPL as it +# is applied to this software. View the full text of the exception in file +# EXCEPTIONS in the directory of this software distribution. +# +# 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 +# +# This file is public domain and comes with NO WARRANTY of any kind MYSQLDATAdir = $(localstatedir) MYSQLSHAREdir = $(pkgdatadir) diff --git a/libmysql/conf_to_src.c b/libmysql/conf_to_src.c index 95ffcf1cb2b..8c9b5ede7bd 100644 --- a/libmysql/conf_to_src.c +++ b/libmysql/conf_to_src.c @@ -1,9 +1,12 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (C) 2000-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation. + + There are special exceptions to the terms and conditions of the GPL as it + is applied to this software. View the full text of the exception in file + EXCEPTIONS in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/dll.c b/libmysql/dll.c index 92aa611000b..f983f4b4409 100644 --- a/libmysql/dll.c +++ b/libmysql/dll.c @@ -1,9 +1,12 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (C) 2000-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation. + + There are special exceptions to the terms and conditions of the GPL as it + is applied to this software. View the full text of the exception in file + EXCEPTIONS in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index 06d21cf36c3..cb0e8e79cf8 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -1,9 +1,12 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (C) 2000-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation. + + There are special exceptions to the terms and conditions of the GPL as it + is applied to this software. View the full text of the exception in file + EXCEPTIONS in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/get_password.c b/libmysql/get_password.c index 0e3b2dcb0ae..350207e0aee 100644 --- a/libmysql/get_password.c +++ b/libmysql/get_password.c @@ -1,9 +1,12 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (C) 2000-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation. + + There are special exceptions to the terms and conditions of the GPL as it + is applied to this software. View the full text of the exception in file + EXCEPTIONS in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index bac72064e1b..cabdd5fca95 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1,9 +1,12 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (C) 2000-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation. + + There are special exceptions to the terms and conditions of the GPL as it + is applied to this software. View the full text of the exception in file + EXCEPTIONS in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/manager.c b/libmysql/manager.c index 5d432848f7b..46a56f155e9 100644 --- a/libmysql/manager.c +++ b/libmysql/manager.c @@ -1,9 +1,12 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (C) 2000-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation. + + There are special exceptions to the terms and conditions of the GPL as it + is applied to this software. View the full text of the exception in file + EXCEPTIONS in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index 04b6f3b6c6c..55ae906ee96 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -1,9 +1,12 @@ -# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +# Copyright (C) 2000-2004 MySQL 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 program is free software; you can redistribute it and/or modify +# it under the terms of version 2 GNU General Public License as +# published by the Free Software Foundation. +# +# There are special exceptions to the terms and conditions of the GPL as it +# is applied to this software. View the full text of the exception in file +# EXCEPTIONS in the directory of this software distribution. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,8 +17,8 @@ # License along with this library; if not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA - - +# +# This file is public domain and comes with NO WARRANTY of any kind target = libmysqlclient_r.la target_defs = -DDONT_USE_RAID -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@ From ed277f8ccf88191e6b52f515425a6b421e31e937 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 5 Aug 2004 16:50:03 +0200 Subject: [PATCH 31/63] - Windows compile fix: added srv/srv0que.c to the innobase project file --- VC++Files/innobase/innobase.dsp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/VC++Files/innobase/innobase.dsp b/VC++Files/innobase/innobase.dsp index ea0aaeb3b83..25e9d5d75b8 100644 --- a/VC++Files/innobase/innobase.dsp +++ b/VC++Files/innobase/innobase.dsp @@ -368,6 +368,10 @@ SOURCE=.\row\row0vers.c # End Source File # Begin Source File +SOURCE=.\srv\srv0que.c +# End Source File +# Begin Source File + SOURCE=.\srv\srv0srv.c # End Source File # Begin Source File From 1097805cf2bdf833f7d07886c7a35b9af54ba068 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 5 Aug 2004 17:05:11 +0200 Subject: [PATCH 32/63] - rename: EXCEPTIONS->EXCEPTIONS-CLIENT --- Build-tools/mysql-copyright | 2 +- Docs/Makefile.am | 4 ++-- Makefile.am | 2 +- libmysql/Makefile.am | 2 +- libmysql/Makefile.shared | 2 +- libmysql/conf_to_src.c | 2 +- libmysql/dll.c | 2 +- libmysql/errmsg.c | 2 +- libmysql/get_password.c | 2 +- libmysql/libmysql.c | 2 +- libmysql/manager.c | 2 +- libmysql_r/Makefile.am | 2 +- scripts/make_binary_distribution.sh | 2 +- scripts/make_win_src_distribution.sh | 2 +- support-files/mysql.spec.sh | 2 +- 15 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Build-tools/mysql-copyright b/Build-tools/mysql-copyright index 231482806ee..84e13d6041e 100755 --- a/Build-tools/mysql-copyright +++ b/Build-tools/mysql-copyright @@ -101,7 +101,7 @@ sub main # on the toplevel of the directory instead. file 'PUBLIC' shouldn't # exist in the new mysql distributions, but let's be sure.. unlink("$destdir/PUBLIC", "$destdir/README"); - unlink("$destdir/COPYING", "$destdir/EXCEPTIONS"); + unlink("$destdir/COPYING", "$destdir/EXCEPTIONS-CLIENT"); copy("$WD/Docs/MySQLEULA.txt", "$destdir"); # remove readline subdir and update configure accordingly diff --git a/Docs/Makefile.am b/Docs/Makefile.am index 06e4b4cfd6a..a4e8e14a38d 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -26,7 +26,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) $(BUILT_SOURCES) mysqld_error.txt \ all: $(targets) txt_files -txt_files: ../INSTALL-SOURCE ../COPYING ../EXCEPTIONS \ +txt_files: ../INSTALL-SOURCE ../COPYING ../EXCEPTIONS-CLIENT \ INSTALL-BINARY ../support-files/MacOSX/ReadMe.txt CLEAN_FILES: $(BUILD_SOURCES) @@ -204,7 +204,7 @@ INSTALL-BINARY: mysql.info $(GT) ../COPYING: mysql.info $(GT) perl -w $(GT) mysql.info "GPL license" "MySQL FLOSS License Exception" > $@ -../EXCEPTIONS: mysql.info $(GT) +../EXCEPTIONS-CLIENT: mysql.info $(GT) perl -w $(GT) mysql.info "MySQL FLOSS License Exception" "Function Index" > $@ ../support-files/MacOSX/ReadMe.txt: mysql.info $(GT) diff --git a/Makefile.am b/Makefile.am index 8e524871d7a..fb0735b562c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,7 @@ AUTOMAKE_OPTIONS = foreign # These are built from source in the Docs directory -EXTRA_DIST = INSTALL-SOURCE README COPYING EXCEPTIONS +EXTRA_DIST = INSTALL-SOURCE README COPYING EXCEPTIONS-CLIENT SUBDIRS = . include @docs_dirs@ @readline_dir@ \ @thread_dirs@ pstack @sql_client_dirs@ \ @sql_server_dirs@ scripts man tests \ diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index 1d80aae8e5c..fefed7f079c 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -6,7 +6,7 @@ # # There are special exceptions to the terms and conditions of the GPL as it # is applied to this software. View the full text of the exception in file -# EXCEPTIONS in the directory of this software distribution. +# EXCEPTIONS-CLIENT in the directory of this software distribution. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index 9e97e6b00eb..06d5c14f602 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -6,7 +6,7 @@ # # There are special exceptions to the terms and conditions of the GPL as it # is applied to this software. View the full text of the exception in file -# EXCEPTIONS in the directory of this software distribution. +# EXCEPTIONS-CLIENT in the directory of this software distribution. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/conf_to_src.c b/libmysql/conf_to_src.c index 8c9b5ede7bd..e9084afae41 100644 --- a/libmysql/conf_to_src.c +++ b/libmysql/conf_to_src.c @@ -6,7 +6,7 @@ There are special exceptions to the terms and conditions of the GPL as it is applied to this software. View the full text of the exception in file - EXCEPTIONS in the directory of this software distribution. + EXCEPTIONS-CLIENT in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/dll.c b/libmysql/dll.c index f983f4b4409..90731ee209e 100644 --- a/libmysql/dll.c +++ b/libmysql/dll.c @@ -6,7 +6,7 @@ There are special exceptions to the terms and conditions of the GPL as it is applied to this software. View the full text of the exception in file - EXCEPTIONS in the directory of this software distribution. + EXCEPTIONS-CLIENT in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index cb0e8e79cf8..e43864bfd33 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -6,7 +6,7 @@ There are special exceptions to the terms and conditions of the GPL as it is applied to this software. View the full text of the exception in file - EXCEPTIONS in the directory of this software distribution. + EXCEPTIONS-CLIENT in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/get_password.c b/libmysql/get_password.c index 350207e0aee..e55e77320f0 100644 --- a/libmysql/get_password.c +++ b/libmysql/get_password.c @@ -6,7 +6,7 @@ There are special exceptions to the terms and conditions of the GPL as it is applied to this software. View the full text of the exception in file - EXCEPTIONS in the directory of this software distribution. + EXCEPTIONS-CLIENT in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index cabdd5fca95..cbe6bb3959f 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -6,7 +6,7 @@ There are special exceptions to the terms and conditions of the GPL as it is applied to this software. View the full text of the exception in file - EXCEPTIONS in the directory of this software distribution. + EXCEPTIONS-CLIENT in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql/manager.c b/libmysql/manager.c index 46a56f155e9..8e0f56326ac 100644 --- a/libmysql/manager.c +++ b/libmysql/manager.c @@ -6,7 +6,7 @@ There are special exceptions to the terms and conditions of the GPL as it is applied to this software. View the full text of the exception in file - EXCEPTIONS in the directory of this software distribution. + EXCEPTIONS-CLIENT in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index 55ae906ee96..8ed4a64d309 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -6,7 +6,7 @@ # # There are special exceptions to the terms and conditions of the GPL as it # is applied to this software. View the full text of the exception in file -# EXCEPTIONS in the directory of this software distribution. +# EXCEPTIONS-CLIENT in the directory of this software distribution. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index d78a7ee28b9..8ea9a16f56b 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -86,7 +86,7 @@ do done for i in COPYING COPYING.LIB README Docs/INSTALL-BINARY \ - EXCEPTIONS MySQLEULA.txt LICENSE.doc README.NW + EXCEPTIONS-CLIENT MySQLEULA.txt LICENSE.doc README.NW do if [ -f $i ] then diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 8837628a1a5..9aca62527e6 100644 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -272,7 +272,7 @@ touch $BASE/innobase/ib_config.h # cd $SOURCE -for i in COPYING ChangeLog README EXCEPTIONS\ +for i in COPYING ChangeLog README EXCEPTIONS-CLIENT\ INSTALL-SOURCE INSTALL-WIN \ INSTALL-WIN-SOURCE \ Docs/manual_toc.html Docs/manual.html \ diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 9670ccf569d..8a74543d053 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -446,7 +446,7 @@ fi %files server %defattr(-,root,root,0755) -%doc COPYING EXCEPTIONS README +%doc COPYING EXCEPTIONS-CLIENT README %doc Docs/manual.{html,ps,texi,txt} %doc Docs/manual_toc.html %doc support-files/my-*.cnf From f325a92b0a893969e865f4552425625bb30aca26 Mon Sep 17 00:00:00 2001 From: "dlenev@brandersnatch.localdomain" <> Date: Fri, 6 Aug 2004 12:15:40 +0400 Subject: [PATCH 33/63] Fix for bug #4491 "timestamp(19) doesn't work". We should allow 19 as length of newly created TIMESTAMP fields. --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/type_timestamp.result | 12 ++++++++++++ mysql-test/t/type_timestamp.test | 11 +++++++++++ sql/sql_parse.cc | 6 +++++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 7a3063c3884..3ffbead8d68 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -20,6 +20,7 @@ bell@sanja.is.com.ua bk@admin.bk carsten@tsort.bitbybit.dk davida@isil.mysql.com +dlenev@brandersnatch.localdomain dlenev@build.mysql.com dlenev@mysql.com gerberb@ou800.zenez.com diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index cd45bcf911d..752a5045eb0 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -167,3 +167,15 @@ ts1 ts2 2001-09-09 04:46:40 0000-00-00 00:00:00 2001-09-09 04:46:40 0000-00-00 00:00:00 drop table t1; +create table t1 (ts timestamp(19)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ts` timestamp(19) NOT NULL +) TYPE=MyISAM +set TIMESTAMP=1000000000; +insert into t1 values (); +select * from t1; +ts +2001-09-09 04:46:40 +drop table t1; diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index 3483227376e..92bd20e846e 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -105,3 +105,14 @@ insert into t1 values (); insert into t1 values (DEFAULT, DEFAULT); select * from t1; drop table t1; + +# +# Test for bug #4491, TIMESTAMP(19) should be possible to create and not +# only read in 4.0 +# +create table t1 (ts timestamp(19)); +show create table t1; +set TIMESTAMP=1000000000; +insert into t1 values (); +select * from t1; +drop table t1; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1f0af05a460..39c1a78b081 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3231,8 +3231,12 @@ bool add_field_to_list(char *field_name, enum_field_types type, case FIELD_TYPE_TIMESTAMP: if (!length) new_field->length= 14; // Full date YYYYMMDDHHMMSS - else + else if (new_field->length != 19) { + /* + We support only even TIMESTAMP lengths less or equal than 14 + and 19 as length of 4.1 compatible representation. + */ new_field->length=((new_field->length+1)/2)*2; /* purecov: inspected */ new_field->length= min(new_field->length,14); /* purecov: inspected */ } From 3cb09c98176c794328e209996a26f13f6bc2010e Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Fri, 6 Aug 2004 15:55:50 +0300 Subject: [PATCH 34/63] InnoDB: Add option for disabling innodb_status. files. InnoDB: Implement tmpfile() differently on Windows (Bug #3998) --- innobase/dict/dict0dict.c | 1 + innobase/include/os0file.h | 2 +- innobase/include/srv0srv.h | 2 ++ innobase/lock/lock0lock.c | 1 + innobase/os/os0file.c | 25 +++++++++++++++++++++---- innobase/srv/srv0srv.c | 3 +++ innobase/srv/srv0start.c | 34 ++++++++++++++++++++++------------ sql/ha_innodb.cc | 6 ++++-- sql/ha_innodb.h | 3 ++- sql/mysqld.cc | 5 +++++ 10 files changed, 62 insertions(+), 20 deletions(-) diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index e2c2043db74..ccaa5720c20 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -643,6 +643,7 @@ dict_init(void) rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION); dict_foreign_err_file = os_file_create_tmpfile(); + ut_a(dict_foreign_err_file); mutex_create(&dict_foreign_err_mutex); mutex_set_level(&dict_foreign_err_mutex, SYNC_ANY_LATCH); } diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index 43741f79855..4a8b9623eeb 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -139,7 +139,7 @@ Creates a temporary file. In case of error, causes abnormal termination. */ FILE* os_file_create_tmpfile(void); /*========================*/ - /* out: temporary file handle (never NULL) */ + /* out: temporary file handle, or NULL */ /******************************************************************** A simple function to open or create a file. */ diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h index 0be13528fd7..57ca1f84f26 100644 --- a/innobase/include/srv0srv.h +++ b/innobase/include/srv0srv.h @@ -92,6 +92,8 @@ extern lint srv_conc_n_threads; extern ibool srv_fast_shutdown; +extern ibool srv_innodb_status; + extern ibool srv_use_doublewrite_buf; extern ibool srv_set_thread_priorities; diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index 68dd2aa18c1..1c9b1263130 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -509,6 +509,7 @@ lock_sys_create( /* hash_create_mutexes(lock_sys->rec_hash, 2, SYNC_REC_LOCK); */ lock_latest_err_file = os_file_create_tmpfile(); + ut_a(lock_latest_err_file); } /************************************************************************* diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index a70333ba6ab..c33066b1476 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -377,16 +377,33 @@ Creates a temporary file. In case of error, causes abnormal termination. */ FILE* os_file_create_tmpfile(void) /*========================*/ - /* out: temporary file handle (never NULL) */ + /* out: temporary file handle, or NULL */ { - FILE* file = tmpfile(); + FILE* file; +#ifdef __WIN__ + int fd = -1; + char* name; + file = NULL; + if (NULL == (name = tempnam(fil_path_to_mysql_datadir, "ib")) + || -1 == (fd = _open(name, _O_CREAT | _O_EXCL | _O_RDWR + | _O_SEQUENTIAL | _O_SHORT_LIVED | _O_TEMPORARY)) + || NULL == (file = fdopen(fd, "w+b"))) { + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: Error: unable to create" + " temporary file %s\n", name ? name : "name"); + if (fd != -1) { + _close(fd); + } + } + free(name); +#else /* __WIN__ */ + file = tmpfile(); if (file == NULL) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: unable to create temporary file\n", stderr); - os_file_handle_error(NULL, "tmpfile"); - ut_error; } +#endif /* __WIN__ */ return(file); } diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 174214f9efe..d799ada1e20 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -223,6 +223,9 @@ merge to completion before shutdown */ ibool srv_fast_shutdown = FALSE; +/* Generate a innodb_status. file */ +ibool srv_innodb_status = FALSE; + ibool srv_use_doublewrite_buf = TRUE; ibool srv_set_thread_priorities = TRUE; diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 3223854652f..30c9982068e 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -1023,16 +1023,24 @@ NetWare. */ mutex_create(&srv_monitor_file_mutex); mutex_set_level(&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK); - srv_monitor_file_name = mem_alloc( - strlen(fil_path_to_mysql_datadir) + - 20 + sizeof "/innodb_status."); - sprintf(srv_monitor_file_name, "%s/innodb_status.%lu", - fil_path_to_mysql_datadir, os_proc_get_number()); - srv_monitor_file = fopen(srv_monitor_file_name, "w+"); - if (!srv_monitor_file) { - fprintf(stderr, "InnoDB: unable to create %s: %s\n", - srv_monitor_file_name, strerror(errno)); - return(DB_ERROR); + if (srv_innodb_status) { + srv_monitor_file_name = mem_alloc( + strlen(fil_path_to_mysql_datadir) + + 20 + sizeof "/innodb_status."); + sprintf(srv_monitor_file_name, "%s/innodb_status.%lu", + fil_path_to_mysql_datadir, os_proc_get_number()); + srv_monitor_file = fopen(srv_monitor_file_name, "w+"); + if (!srv_monitor_file) { + fprintf(stderr, "InnoDB: unable to create %s: %s\n", + srv_monitor_file_name, strerror(errno)); + return(DB_ERROR); + } + } else { + srv_monitor_file_name = NULL; + srv_monitor_file = os_file_create_tmpfile(); + if (!srv_monitor_file) { + return(DB_ERROR); + } } /* Restrict the maximum number of file i/o threads */ @@ -1527,8 +1535,10 @@ innobase_shutdown_for_mysql(void) if (srv_monitor_file) { fclose(srv_monitor_file); srv_monitor_file = 0; - unlink(srv_monitor_file_name); - mem_free(srv_monitor_file_name); + if (srv_monitor_file_name) { + unlink(srv_monitor_file_name); + mem_free(srv_monitor_file_name); + } } mutex_free(&srv_monitor_file_mutex); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 21dd7f748c2..6319c1494d3 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -103,6 +103,7 @@ uint innobase_flush_log_at_trx_commit = 1; my_bool innobase_log_archive = FALSE; my_bool innobase_use_native_aio = FALSE; my_bool innobase_fast_shutdown = TRUE; +my_bool innobase_create_status_file = FALSE; static char *internal_innobase_data_file_path = NULL; @@ -861,6 +862,7 @@ innobase_init(void) srv_force_recovery = (ulint) innobase_force_recovery; srv_fast_shutdown = (ibool) innobase_fast_shutdown; + srv_innodb_status = (ibool) innobase_create_status_file; srv_print_verbose_log = mysql_embedded ? 0 : 1; @@ -4270,7 +4272,7 @@ ha_innobase::update_table_comment( trx_search_latch_release_if_reserved(prebuilt->trx); str = NULL; - if (FILE* file = tmpfile()) { + if (FILE* file = os_file_create_tmpfile()) { long flen; /* output the data to a temporary file */ @@ -4330,7 +4332,7 @@ ha_innobase::get_foreign_key_create_info(void) update_thd(current_thd); - if (FILE* file = tmpfile()) { + if (FILE* file = os_file_create_tmpfile()) { long flen; prebuilt->trx->op_info = (char*)"getting info on foreign keys"; diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index 384b3dec949..5736f70c65c 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -203,7 +203,8 @@ extern char *innobase_log_group_home_dir, *innobase_log_arch_dir; extern char *innobase_unix_file_flush_method; /* The following variables have to be my_bool for SHOW VARIABLES to work */ extern my_bool innobase_log_archive, - innobase_use_native_aio, innobase_fast_shutdown; + innobase_use_native_aio, innobase_fast_shutdown, + innobase_create_status_file; extern "C" { extern ulong srv_max_buf_pool_modified_pct; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 55f58e9970e..3f7c187ccdd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3458,6 +3458,7 @@ enum options_mysqld { OPT_INNODB_LOCK_WAIT_TIMEOUT, OPT_INNODB_THREAD_CONCURRENCY, OPT_INNODB_FORCE_RECOVERY, + OPT_INNODB_STATUS_FILE, OPT_INNODB_MAX_DIRTY_PAGES_PCT, OPT_BDB_CACHE_SIZE, OPT_BDB_LOG_BUFFER_SIZE, @@ -3625,6 +3626,10 @@ struct my_option my_long_options[] = {"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN, "Speeds up server shutdown process", (gptr*) &innobase_fast_shutdown, (gptr*) &innobase_fast_shutdown, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, + {"innodb_status_file", OPT_INNODB_STATUS_FILE, + "Enable SHOW INNODB STATUS output in the innodb_status. file", + (gptr*) &innobase_create_status_file, (gptr*) &innobase_create_status_file, + 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT, "Percentage of dirty pages allowed in bufferpool", (gptr*) &srv_max_buf_pool_modified_pct, (gptr*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0, 0, 0}, From b88a47db3e045843324e890a9006a0040a98fe42 Mon Sep 17 00:00:00 2001 From: "ingo@mysql.com" <> Date: Mon, 9 Aug 2004 11:39:26 +0200 Subject: [PATCH 35/63] bug#4497 - Serious regression if disk based TMP table is used. Solved performance problems by enabling write buffer. --- sql/sql_select.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 096b73c482f..7b688041acc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4533,6 +4533,20 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, new_table.no_rows=1; } +#ifdef TO_BE_DONE_LATER_IN_4_1 + /* + To use start_bulk_insert() (which is new in 4.1) we need to find + all places where a corresponding end_bulk_insert() should be put. + */ + table->file->info(HA_STATUS_VARIABLE); /* update table->file->records */ + new_table.file->start_bulk_insert(table->file->records); +#else + /* + HA_EXTRA_WRITE_CACHE can stay until close, no need to disable it explicitly. + */ + new_table.file->extra(HA_EXTRA_WRITE_CACHE); +#endif + /* copy all old rows */ while (!table->file->rnd_next(new_table.record[1])) { From 0709513d4ba73d77575adf0788f26019eef76d94 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Mon, 9 Aug 2004 14:36:59 +0200 Subject: [PATCH 36/63] - added EXCEPTIONS-CLIENT to the "devel" RPM subpackage and added a note to the RPM ChangeLog about it --- support-files/mysql.spec.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 8a74543d053..366af1929f1 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -446,7 +446,7 @@ fi %files server %defattr(-,root,root,0755) -%doc COPYING EXCEPTIONS-CLIENT README +%doc COPYING README %doc Docs/manual.{html,ps,texi,txt} %doc Docs/manual_toc.html %doc support-files/my-*.cnf @@ -531,6 +531,7 @@ fi %files devel %defattr(-, root, root, 0755) +%doc EXCEPTIONS-CLIENT %attr(755, root, root) %{_bindir}/comp_err %attr(755, root, root) %{_bindir}/mysql_config %dir %attr(755, root, root) %{_includedir}/mysql @@ -575,6 +576,10 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Mon Aug 09 2004 Lenz Grimmer + +- Added EXCEPTIONS-CLIENT to the "devel" package + * Mon Apr 05 2004 Lenz Grimmer - added ncurses-devel to the build prerequisites (BUG 3377) From cd6292d21952e7087b2271801a5207dc63d20e9a Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Tue, 10 Aug 2004 14:17:32 +0300 Subject: [PATCH 37/63] InnoDB: Use create_temp_file() when available --- innobase/include/os0file.h | 4 +-- innobase/os/os0file.c | 72 +++++++++++++++++++++++++++----------- sql/ha_innodb.cc | 24 +++++++++++++ 3 files changed, 78 insertions(+), 22 deletions(-) diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index 4a8b9623eeb..9727c2b8243 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -134,12 +134,12 @@ void os_io_init_simple(void); /*===================*/ /*************************************************************************** -Creates a temporary file. In case of error, causes abnormal termination. */ +Creates a temporary file. */ FILE* os_file_create_tmpfile(void); /*========================*/ - /* out: temporary file handle, or NULL */ + /* out: temporary file handle, or NULL on error */ /******************************************************************** A simple function to open or create a file. */ diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index c33066b1476..63a86d8ab68 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -371,39 +371,71 @@ os_io_init_simple(void) } } +#ifndef UNIV_HOTBACKUP +/************************************************************************* +Creates a temporary file. This function is defined in ha_innodb.cc. */ + +int +innobase_mysql_tmpfile(void); +/*========================*/ + /* out: temporary file descriptor, or < 0 on error */ +#endif /* !UNIV_HOTBACKUP */ + /*************************************************************************** -Creates a temporary file. In case of error, causes abnormal termination. */ +Creates a temporary file. */ FILE* os_file_create_tmpfile(void) /*========================*/ - /* out: temporary file handle, or NULL */ + /* out: temporary file handle, or NULL on error */ { - FILE* file; -#ifdef __WIN__ + FILE* file = NULL; int fd = -1; - char* name; - file = NULL; - if (NULL == (name = tempnam(fil_path_to_mysql_datadir, "ib")) - || -1 == (fd = _open(name, _O_CREAT | _O_EXCL | _O_RDWR - | _O_SEQUENTIAL | _O_SHORT_LIVED | _O_TEMPORARY)) - || NULL == (file = fdopen(fd, "w+b"))) { - ut_print_timestamp(stderr); - fprintf(stderr, " InnoDB: Error: unable to create" - " temporary file %s\n", name ? name : "name"); - if (fd != -1) { - _close(fd); +#ifdef UNIV_HOTBACKUP + int tries; + for (tries = 10; tries--; ) { + char* name = tempnam(fil_path_to_mysql_datadir, "ib"); + if (!name) { + break; } + + fd = open(name, +# ifdef __WIN__ + O_SEQUENTIAL | O_SHORT_LIVED | O_TEMPORARY | +# endif /* __WIN__ */ + O_CREAT | O_EXCL | O_RDWR, + S_IREAD | S_IWRITE); + if (fd >= 0) { +# ifndef __WIN__ + unlink(name); +# endif /* !__WIN__ */ + free(name); + break; + } + + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: Warning: " + "unable to create temporary file %s, retrying\n", + name); + free(name); } - free(name); -#else /* __WIN__ */ - file = tmpfile(); - if (file == NULL) { +#else /* UNIV_HOTBACKUP */ + fd = innobase_mysql_tmpfile(); +#endif /* UNIV_HOTBACKUP */ + + if (fd >= 0) { + file = fdopen(fd, "w+b"); + } + + if (!file) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: unable to create temporary file\n", stderr); + if (fd >= 0) { + close(fd); + } } -#endif /* __WIN__ */ + return(file); } diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 6319c1494d3..f233dd5a5c5 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -406,6 +406,30 @@ innobase_mysql_print_thd( putc('\n', f); } +/************************************************************************* +Creates a temporary file. */ +extern "C" +int +innobase_mysql_tmpfile(void) +/*========================*/ + /* out: temporary file descriptor, or < 0 on error */ +{ + char filename[FN_REFLEN]; + File fd = create_temp_file(filename, NullS, "ib", +#ifdef __WIN__ + O_BINARY | O_TRUNC | O_SEQUENTIAL | + O_TEMPORARY | O_SHORT_LIVED | +#endif /* __WIN__ */ + O_CREAT | O_EXCL | O_RDWR, + MYF(MY_WME)); +#ifndef __WIN__ + if (fd >= 0) { + unlink(filename); + } +#endif /* !__WIN__ */ + return(fd); +} + /************************************************************************* Gets the InnoDB transaction handle for a MySQL handler object, creates an InnoDB transaction struct if the corresponding MySQL thread struct still From 61c509fbd7def7cbc091154f7c65c24dc6842ece Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Tue, 10 Aug 2004 16:11:34 +0300 Subject: [PATCH 38/63] os0file.c: os_file_create_tmpfile(): display errno in case of failure --- innobase/os/os0file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 63a86d8ab68..56f01568ead 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -429,8 +429,9 @@ os_file_create_tmpfile(void) if (!file) { ut_print_timestamp(stderr); - fputs(" InnoDB: Error: unable to create temporary file\n", - stderr); + fprintf(stderr, + " InnoDB: Error: unable to create temporary file;" + " errno: %d\n", errno); if (fd >= 0) { close(fd); } From b49b5e9c68364e86be885eaec9cde6c380eb263e Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 10 Aug 2004 16:34:29 +0200 Subject: [PATCH 39/63] disable safe-updates for mysql_fix_privilege_tables --- scripts/mysql_fix_privilege_tables.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index bfff05151e5..6e1fd0d1be5 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -9,6 +9,8 @@ -- this sql script. -- On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' +SET SQL_SAFE_UPDATES=0; + USE mysql; ALTER TABLE user type=MyISAM; ALTER TABLE db type=MyISAM; From 341aaa375b7969e19e8bd7e2d37840dd7e283969 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 10 Aug 2004 16:50:29 +0200 Subject: [PATCH 40/63] - Added libmygcc.a to the "devel" RPM subpackage (required to link applications against the the embedded server libmysqld.a) (BUG#4921) --- support-files/mysql.spec.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 366af1929f1..b6243cbd4ad 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -282,7 +282,18 @@ mv sql/mysqld sql/mysqld-max nm --numeric-sort sql/mysqld-max > sql/mysqld-max.sym # Install embedded server library in the build root -install -m 644 libmysqld/libmysqld.a $RBR%{_libdir}/mysql +install -m 644 libmysqld/libmysqld.a $RBR%{_libdir}/mysql/ + +# Include libgcc.a in the devel subpackage (BUG 4921) +if [ "$CC" = gcc ] +then + libgcc=`$CC --print-libgcc-file` + if [ -f $libgcc ] + then + %define have_libgcc 1 + install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a + fi +fi # Save libraries (cd libmysql/.libs; tar cf $RBR/shared-libs.tar *.so*) @@ -540,6 +551,9 @@ fi %{_libdir}/mysql/libdbug.a %{_libdir}/mysql/libheap.a %{_libdir}/mysql/libmerge.a +%if %{have_libgcc} +%{_libdir}/mysql/libmygcc.a +%endif %{_libdir}/mysql/libmyisam.a %{_libdir}/mysql/libmyisammrg.a %{_libdir}/mysql/libmysqlclient.a @@ -576,6 +590,11 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Tue Aug 10 2004 Lenz Grimmer + +- Added libmygcc.a to the devel subpackage (required to link applications + against the the embedded server libmysqld.a) (BUG 4921) + * Mon Aug 09 2004 Lenz Grimmer - Added EXCEPTIONS-CLIENT to the "devel" package From f78ec279e9d7dfd27833d896ee46bf4cf7dda58b Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 11 Aug 2004 13:11:59 +0200 Subject: [PATCH 41/63] - fixed non-predictable floating point results in func_math by adding format() around them (as suggested by serg) --- mysql-test/r/func_math.result | 6 +++--- mysql-test/t/func_math.test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index d90071e0b56..4688adc61d8 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -35,9 +35,9 @@ set @@rand_seed1=10000000,@@rand_seed2=1000000; select rand(999999),rand(); rand(999999) rand() 0.014231365187309 0.028870999839968 -select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1); -pi() sin(pi()/2) cos(pi()/2) abs(tan(pi())) cot(1) asin(1) acos(0) atan(1) -3.141593 1 6.1230317691119e-17 1.2246063538224e-16 0.64209261593433 1.5707963267949 1.5707963267949 0.78539816339745 +select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6); +pi() format(sin(pi()/2),6) format(cos(pi()/2),6) format(abs(tan(pi())),6) format(cot(1),6) format(asin(1),6) format(acos(0),6) format(atan(1),6) +3.141593 1.000000 0.000000 0.000000 0.642093 1.570796 1.570796 0.785398 select degrees(pi()),radians(360); degrees(pi()) radians(360) 180 6.2831853071796 diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index ca958253d14..e745c7738ac 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -15,7 +15,7 @@ select log10(100),log10(18),log10(-4),log10(0),log10(NULL); select pow(10,log10(10)),power(2,4); set @@rand_seed1=10000000,@@rand_seed2=1000000; select rand(999999),rand(); -select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1); +select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6); select degrees(pi()),radians(360); # From e1f264748cd0723522d06aef45fd41d617d25966 Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Wed, 11 Aug 2004 18:55:12 +0500 Subject: [PATCH 42/63] fixed Bug #4973 Memory is not released when HEAP table is dropped --- sql/ha_heap.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index eb4bf517374..5aa42fa1beb 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -264,7 +264,8 @@ THR_LOCK_DATA **ha_heap::store_lock(THD *thd, int ha_heap::delete_table(const char *name) { - int error=heap_delete_table(name); + char buff[FN_REFLEN]; + int error= heap_delete_table(fn_format(buff,name,"","",4+2)); return error == ENOENT ? 0 : error; } From cc89f70dfaf0c307c6c1108ad0e56816ca89eda4 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 11 Aug 2004 22:03:12 +0200 Subject: [PATCH 43/63] Bootstrap enhancements: - Changed the default log file name to Bootstrap-.log (e.g. Bootstrap-mysql-4.0.log) (thanks to Joerg for the hint) - added option "--archive-log" to automatically move the log file into the Log directory of the exported tree --- Build-tools/Bootstrap | 44 ++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index fa3c6344a05..83613d1a1b5 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -28,8 +28,8 @@ else # Some predefined settings $build_command= "BUILD/compile-pentium-max"; $PWD= cwd(); -$LOGFILE= $PWD . "/Bootstrap.log"; $opt_docdir= $PWD . "/mysqldoc"; +$opt_archive_log= undef; $opt_build_command= undef; $opt_changelog= undef; $opt_delete= undef; @@ -51,6 +51,7 @@ $version= "unknown"; $major=$minor=$release=0; GetOptions( + "archive-log|a", "build-command|b=s", "changelog|c:s", "directory|d=s", @@ -72,6 +73,17 @@ GetOptions( "quiet|q", ) || print_help(""); +# +# Override predefined build command +# +if (defined $opt_build_command) +{ + $build_command= $opt_build_command; +} + +print_help("") if ($opt_help); +defined($REPO=$ARGV[0]) || print_help("Please enter the BK repository to be used!"); + # # Override predefined Log file name # @@ -89,18 +101,11 @@ if (defined $opt_log) } } } - -# -# Override predefined build command -# -if (defined $opt_build_command) +else { - $build_command= $opt_build_command; + $LOGFILE= $PWD . "/Bootstrap-" . $REPO . ".log"; } -print_help("") if ($opt_help); -defined($REPO=$ARGV[0]) || print_help("Please enter the BK repository to be used!"); - &logger("Starting build"); &abort("The directory \"$REPO\" could not be found!") if (!-d $REPO); &logger("Using $REPO as the BK parent repository"); @@ -351,6 +356,21 @@ if (!$opt_skip_check) # All done when we came down here # &logger("SUCCESS: Build finished successfully.") if (!$opt_dry_run); + +# +# Move the log file into the Log dir of the target dir +# +if ($opt_archive_log) +{ + my $logdir= $target_dir . "/Logs"; + &logger("Moving $LOGFILE to $logdir"); + mkdir "$logdir" if (! -d $logdir); + $command= "mv "; + $command.= "-v " if ($opt_verbose || defined $opt_log); + $command.= "$LOGFILE $logdir"; + &run_command($command, "Could not move $LOGFILE to $logdir!"); +} + exit 0; # @@ -378,6 +398,8 @@ distribution check can be run before the source archive is being created. Options: +-a, --archive-log Move the log file into the Logs directory of + the exported tree after a successful build -b, --build-command= Use to compile the sources before packing the distribution. (default is "$build_command") @@ -398,7 +420,7 @@ Options: do not build or test the source distribution -h, --help Print this help message -l, --log[=] Write a log file [to ] - (default is "$LOGFILE") + (default is "./Bootstrap-.log") -m, --mail=
Mail a failure report to the given address (and include a log file snippet, if logging is enabled) Note that the \@-Sign needs to be quoted! From 46ddf8f7028d1264ec470e9eeb092ca34df122c1 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 11 Aug 2004 23:01:08 +0200 Subject: [PATCH 44/63] - fixed Log file naming in Boostrap --- Build-tools/Bootstrap | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index 83613d1a1b5..c1063363bdf 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -101,10 +101,8 @@ if (defined $opt_log) } } } -else -{ - $LOGFILE= $PWD . "/Bootstrap-" . $REPO . ".log"; -} + +$LOGFILE= $PWD . "/Bootstrap-" . $REPO . ".log" unless ($LOGFILE); &logger("Starting build"); &abort("The directory \"$REPO\" could not be found!") if (!-d $REPO); From 6023b58b9f35f97bb70ce7dff42e36b31a76818a Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Wed, 11 Aug 2004 23:43:41 +0200 Subject: [PATCH 45/63] Bug #4797 - 32 bit and 64 bit builds behave differently on int32 overflow --- include/my_global.h | 28 +++++++++++++++++----------- mysql-test/r/type_uint.result | 2 ++ mysql-test/t/type_uint.test | 1 + sql/field.cc | 29 +++++++++++++++++++++++++++-- sql/sql_analyse.cc | 3 --- 5 files changed, 47 insertions(+), 16 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index 284cfdc1f97..33ae35d2308 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -642,21 +642,27 @@ extern double my_atof(const char*); #endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/ #if SIZEOF_LONG == 4 -#define INT_MIN32 (long) 0x80000000L -#define INT_MAX32 (long) 0x7FFFFFFFL -#define INT_MIN24 ((long) 0xff800000L) -#define INT_MAX24 0x007fffffL -#define INT_MIN16 ((short int) 0x8000) -#define INT_MAX16 0x7FFF -#define INT_MIN8 ((char) 0x80) -#define INT_MAX8 ((char) 0x7F) +#define INT_MIN32 ((long) 0x80000000L) +#define INT_MAX32 ((long) 0x7FFFFFFFL) +#define UINT_MAX32 ((long) 0xFFFFFFFFL) +#define INT_MIN24 ((long) 0xFF800000L) +#define INT_MAX24 0x007FFFFFL +#define UINT_MAX24 0x00FFFFFFL +#define INT_MIN16 ((short int) 0x8000) +#define INT_MAX16 0x7FFF +#define UINT_MAX16 0xFFFF +#define INT_MIN8 ((char) 0x80) +#define INT_MAX8 ((char) 0x7F) #else /* Probably Alpha */ #define INT_MIN32 ((long) (int) 0x80000000) #define INT_MAX32 ((long) (int) 0x7FFFFFFF) -#define INT_MIN24 ((long) (int) 0xff800000) -#define INT_MAX24 ((long) (int) 0x007fffff) -#define INT_MIN16 ((short int) 0xffff8000) +#define UINT_MAX32 ((long) (int) 0xFFFFFFFF) +#define INT_MIN24 ((long) (int) 0xFF800000) +#define INT_MAX24 ((long) (int) 0x007FFFFF) +#define UINT_MAX24 ((long) (int) 0x00FFFFFF) +#define INT_MIN16 ((short int) 0xFFFF8000) #define INT_MAX16 ((short int) 0x00007FFF) +#define UINT_MAX16 ((short int) 0x0000FFFF) #endif /* From limits.h instead */ diff --git a/mysql-test/r/type_uint.result b/mysql-test/r/type_uint.result index 1acfc700d3a..0b7452b566b 100644 --- a/mysql-test/r/type_uint.result +++ b/mysql-test/r/type_uint.result @@ -2,8 +2,10 @@ drop table if exists t1; create table t1 (this int unsigned); insert into t1 values (1); insert into t1 values (-1); +insert into t1 values ('5000000000'); select * from t1; this 1 0 +4294967295 drop table t1; diff --git a/mysql-test/t/type_uint.test b/mysql-test/t/type_uint.test index 32bcd61ecdb..7eb48ae21ac 100644 --- a/mysql-test/t/type_uint.test +++ b/mysql-test/t/type_uint.test @@ -6,5 +6,6 @@ drop table if exists t1; create table t1 (this int unsigned); insert into t1 values (1); insert into t1 values (-1); +insert into t1 values ('5000000000'); select * from t1; drop table t1; diff --git a/sql/field.cc b/sql/field.cc index e3bdf78e718..946f5ed8621 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1504,7 +1504,7 @@ void Field_long::store(const char *from,uint len) { len--; from++; } - long tmp; + long tmp, cuted_fields=0; String tmp_str(from,len); from= tmp_str.c_ptr(); // Add end null if needed errno=0; @@ -1520,9 +1520,34 @@ void Field_long::store(const char *from,uint len) } else tmp=strtol(from, &end, 10); - if (errno || + if (errno || (from+len != end && current_thd->count_cuted_fields && !test_if_int(from,len))) + cuted_fields=1; +#if SIZEOF_LONG > 4 + if (unsigned_flag) + { + if (tmp > UINT_MAX32) + { + tmp= UINT_MAX32; + cuted_fields=1; + } + } + else + { + if (tmp > INT_MAX32) + { + tmp= INT_MAX32; + cuted_fields=1; + } + else if (tmp < INT_MIN32) + { + tmp= INT_MIN32; + cuted_fields=1; + } + } +#endif + if (cuted_fields) current_thd->cuted_fields++; #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index bd8c0e5ba87..3847849d6a7 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -34,9 +34,6 @@ #define MAX_TREEMEM 8192 #define MAX_TREE_ELEMENTS 256 -#define UINT_MAX16 0xffff -#define UINT_MAX24 0xffffff -#define UINT_MAX32 0xffffffff int sortcmp2(void* cmp_arg __attribute__((unused)), const String *a,const String *b) From bc78a46ac4747bf430807f1969c207e13118404e Mon Sep 17 00:00:00 2001 From: "acurtis@pcgem.rdg.cyberkinetica.com" <> Date: Wed, 11 Aug 2004 23:24:36 +0100 Subject: [PATCH 46/63] Bug#4411 Fix for server hang bug --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/heap.result | 10 ++++++++++ mysql-test/t/heap.test | 14 ++++++++++++++ sql/opt_sum.cc | 1 + 4 files changed, 26 insertions(+) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 7a3063c3884..d2413d7a4dc 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -5,6 +5,7 @@ Administrator@fred. Greg@greg-laptop. Miguel@light.local Sinisa@sinisa.nasamreza.org +acurtis@pcgem.rdg.cyberkinetica.com ahlentz@co3064164-a.rochd1.qld.optusnet.com.au akishkin@work.mysql.com antony@ltantony.dsl-verizon.net diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index bdf7dc225f3..11958f0a619 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -217,3 +217,13 @@ DELETE from t1 where a < 100; SELECT * from t1; a DROP TABLE t1; +CREATE TABLE `job_titles` ( +`job_title_id` int(6) unsigned NOT NULL default '0', +`job_title` char(18) NOT NULL default '', +PRIMARY KEY (`job_title_id`), +UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`) +) TYPE=HEAP; +SELECT MAX(job_title_id) FROM job_titles; +MAX(job_title_id) +NULL +DROP TABLE job_titles; diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index b2de58ca083..87518798a36 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -147,3 +147,17 @@ INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); DELETE from t1 where a < 100; SELECT * from t1; DROP TABLE t1; + +# +# Bug#4411 Server hangs when trying to SELECT MAX(id) from an empty HEAP table +# +CREATE TABLE `job_titles` ( + `job_title_id` int(6) unsigned NOT NULL default '0', + `job_title` char(18) NOT NULL default '', + PRIMARY KEY (`job_title_id`), + UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`) +) TYPE=HEAP; + +SELECT MAX(job_title_id) FROM job_titles; + +DROP TABLE job_titles; diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index b5eec2d5dd4..0831c375f7a 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -401,6 +401,7 @@ static bool find_range_key(TABLE_REF *ref, Field* field, COND *cond) /* Can't use this key, for looking up min() or max(), end if last one */ if (key == 1) return 0; + key>>=1; idx++; } ref->key_length=0; ref->key=idx; From 798952dcf241d21cad7f2fc746159152be310bff Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Thu, 12 Aug 2004 09:41:35 +0500 Subject: [PATCH 47/63] A fix (Bug#4898: User privileges depending on ORDER BY Settings of table db) --- sql/sql_acl.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 4af6f407b57..58d0fe9a7fa 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -460,22 +460,30 @@ static ulong get_sort(uint count,...) va_start(args,count); ulong sort=0; + /* Should not use this function with more than 4 arguments for compare. */ + DBUG_ASSERT(count <= 4); + while (count--) { - char *str=va_arg(args,char*); - uint chars=0,wild=0; + char *start, *str= va_arg(args,char*); + uint chars= 0; + uint wild_pos= 0; /* first wildcard position */ - if (str) + if (start= str) { for (; *str ; str++) { if (*str == wild_many || *str == wild_one || *str == wild_prefix) - wild++; + { + wild_pos= str - start + 1; + break; + } else chars++; } } - sort= (sort << 8) + (wild ? 1 : chars ? 2 : 0); + sort= (sort << 8) + (wild_pos ? (wild_pos > 127 ? 127 : wild_pos) : + (chars ? 128 : 0)); } va_end(args); return sort; From 955e869d7cdb71e536017e5f70101dd975f06ba3 Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Thu, 12 Aug 2004 14:49:16 +0500 Subject: [PATCH 48/63] A test case (bug #4898: User privileges depending on ORDER BY Settings of table db) --- mysql-test/r/grant.result | 18 ++++++++++++++++++ mysql-test/t/grant.test | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 1a968fa4f2f..c76b6ee46d5 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -131,3 +131,21 @@ Wrong usage of DB GRANT and GLOBAL PRIVILEGES select 1; 1 1 +insert into mysql.user (host, user) values ('localhost', 'test11'); +insert into mysql.db (host, db, user, select_priv) values +('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); +flush privileges; +show grants for test11@localhost; +Grants for test11@localhost +GRANT USAGE ON *.* TO 'test11'@'localhost' +GRANT SELECT ON `ab%`.* TO 'test11'@'localhost' +GRANT SELECT ON `a%`.* TO 'test11'@'localhost' +alter table mysql.db order by db desc; +flush privileges; +show grants for test11@localhost; +Grants for test11@localhost +GRANT USAGE ON *.* TO 'test11'@'localhost' +GRANT SELECT ON `ab%`.* TO 'test11'@'localhost' +GRANT SELECT ON `a%`.* TO 'test11'@'localhost' +delete from mysql.user where user='test11'; +delete from mysql.db where user='test11'; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 598a7186a6e..442ce4918d8 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -89,3 +89,18 @@ drop table t1; --error 1221 GRANT FILE on mysqltest.* to mysqltest_1@localhost; select 1; -- To test that the previous command didn't cause problems + + +# +# Bug #4898: User privileges depending on ORDER BY Settings of table db +# +insert into mysql.user (host, user) values ('localhost', 'test11'); +insert into mysql.db (host, db, user, select_priv) values +('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); +flush privileges; +show grants for test11@localhost; +alter table mysql.db order by db desc; +flush privileges; +show grants for test11@localhost; +delete from mysql.user where user='test11'; +delete from mysql.db where user='test11'; From a8d3ad5e59da372248a6e35cc263603804804deb Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Thu, 12 Aug 2004 16:02:12 +0500 Subject: [PATCH 49/63] Added initial sorting in order to make test case repeatable. --- mysql-test/t/grant.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 442ce4918d8..a278b9d5928 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -97,6 +97,7 @@ select 1; -- To test that the previous command didn't cause problems insert into mysql.user (host, user) values ('localhost', 'test11'); insert into mysql.db (host, db, user, select_priv) values ('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); +alter table mysql.db order by db asc; flush privileges; show grants for test11@localhost; alter table mysql.db order by db desc; From 0f0b1ebe626a9c715e4961d1b14fb42ac5111d6d Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Thu, 12 Aug 2004 16:16:38 +0500 Subject: [PATCH 50/63] Added initial sorting in order to make test case repeatable. --- mysql-test/r/grant.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index c76b6ee46d5..d4d8dd1f026 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -134,6 +134,7 @@ select 1; insert into mysql.user (host, user) values ('localhost', 'test11'); insert into mysql.db (host, db, user, select_priv) values ('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); +alter table mysql.db order by db asc; flush privileges; show grants for test11@localhost; Grants for test11@localhost From 5406709672b92569218ffceb4875b6617e12a04f Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Thu, 12 Aug 2004 20:37:31 +0500 Subject: [PATCH 51/63] fixed Bug #4358 Problem with HAVING clause that uses alias from the select list and TEXT field make setup_copy_fields to insert Item_copy_string for blobs in the beginning of the copy_funcs (push_back instead of push_front) the thing is that Item_copy_string::copy for function can call Item_copy_string::val_int for blob via Item_ref. But if Item_copy_string::copy for blob isn't called before, it's value will be wrong. So all the Item_copy_string::copy for blobs should be called before Item_copy_string::copy for functions. --- mysql-test/r/having.result | 40 +++++++++++++++++++++++++++++++++ mysql-test/t/having.test | 46 ++++++++++++++++++++++++++++++++++++++ sql/sql_select.cc | 11 ++++++++- 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index d643070f7f9..f0e9172991c 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -78,3 +78,43 @@ sqty 5 9 drop table t1; +CREATE TABLE t1 ( +`id` bigint(20) NOT NULL default '0', +`description` text +) TYPE=MyISAM; +CREATE TABLE t2 ( +`id` bigint(20) NOT NULL default '0', +`description` varchar(20) +) TYPE=MyISAM; +INSERT INTO t1 VALUES (1, 'test'); +INSERT INTO t2 VALUES (1, 'test'); +CREATE TABLE t3 ( +`id` bigint(20) NOT NULL default '0', +`order_id` bigint(20) NOT NULL default '0' +) TYPE=MyISAM; +select +a.id, a.description, +count(b.id) as c +from t1 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); +id description c +1 test 0 +select +a.*, +count(b.id) as c +from t2 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); +id description c +1 test 0 +INSERT INTO t1 VALUES (2, 'test2'); +select +a.id, a.description, +count(b.id) as c +from t1 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); +id description c +1 test 0 +2 test2 0 diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index cb6fa85ffde..c8835bf1613 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -66,3 +66,49 @@ select id, sum(qty) as sqty from t1 group by id having sqty>2; select sum(qty) as sqty from t1 group by id having count(id) > 0; select sum(qty) as sqty from t1 group by id having count(distinct id) > 0; drop table t1; + +# +# Test case for Bug #4358 Problem with HAVING clause that uses alias from the +# select list and TEXT field +# + +CREATE TABLE t1 ( + `id` bigint(20) NOT NULL default '0', + `description` text +) TYPE=MyISAM; + +CREATE TABLE t2 ( + `id` bigint(20) NOT NULL default '0', + `description` varchar(20) +) TYPE=MyISAM; + +INSERT INTO t1 VALUES (1, 'test'); +INSERT INTO t2 VALUES (1, 'test'); + +CREATE TABLE t3 ( + `id` bigint(20) NOT NULL default '0', + `order_id` bigint(20) NOT NULL default '0' +) TYPE=MyISAM; + +select + a.id, a.description, + count(b.id) as c +from t1 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); + +select + a.*, + count(b.id) as c +from t2 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); + +INSERT INTO t1 VALUES (2, 'test2'); + +select + a.id, a.description, + count(b.id) as c +from t1 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 096b73c482f..8c30a1684b4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7158,7 +7158,16 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, List &fields) if (!(pos=new Item_copy_string(pos))) goto err; VOID(li.replace(pos)); - if (param->copy_funcs.push_back(pos)) + /* + Item_copy_string::copy for function can call + Item_copy_string::val_int for blob via Item_ref. + But if Item_copy_string::copy for blob isn't called before, + it's value will be wrong + so let's insert Item_copy_string for blobs in the beginning of + copy_funcs + (to see full test case look at having.test, BUG #4358) + */ + if (param->copy_funcs.push_front(pos)) goto err; continue; } From c8f8ca889fca8c5560e48a1b63f1c146db2aee91 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 12 Aug 2004 21:15:49 +0200 Subject: [PATCH 52/63] - giving a range does not work for platform detection in configure.in - resorting to having to separate sections for darwin7 and darwin8 --- configure.in | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index be3269d50d6..05f5c8917c1 100644 --- a/configure.in +++ b/configure.in @@ -1047,7 +1047,16 @@ case $SYSTEM_TYPE in MAX_C_OPTIMIZE="-O" fi ;; - *darwin[7-8]*) + *darwin7*) + if test "$ac_cv_prog_gcc" = "yes" + then + FLAGS="-DHAVE_DARWIN_THREADS -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ" + CFLAGS="$CFLAGS $FLAGS" + CXXFLAGS="$CXXFLAGS $FLAGS" + MAX_C_OPTIMIZE="-O" + fi + ;; + *darwin8*) if test "$ac_cv_prog_gcc" = "yes" then FLAGS="-DHAVE_DARWIN_THREADS -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ" From c484f82b21174c23903311f8b9274e0980764430 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 12 Aug 2004 21:40:34 +0200 Subject: [PATCH 53/63] - Fixed two small version number issues in MySQL-shared-compat.spec --- support-files/MySQL-shared-compat.spec.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/support-files/MySQL-shared-compat.spec.sh b/support-files/MySQL-shared-compat.spec.sh index 2a257a601a1..068daadab58 100644 --- a/support-files/MySQL-shared-compat.spec.sh +++ b/support-files/MySQL-shared-compat.spec.sh @@ -26,8 +26,8 @@ # # Change this to match the version of the shared libs you want to include # -%define version4 @VERSION@ -%define version3 3.23.56 +%define version4 @MYSQL_NO_DASH_VERSION@ +%define version3 3.23.58 Name: MySQL-shared-compat Packager: Lenz Grimmer From b1f5aa00949f2d381693392fbcd2f72ca2d435f4 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Thu, 12 Aug 2004 21:55:05 +0200 Subject: [PATCH 54/63] - portability fix for SCO Open Server 5.0.7 (thanks to Boyd Gerber) --- configure.in | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.in b/configure.in index 05f5c8917c1..263812193aa 100644 --- a/configure.in +++ b/configure.in @@ -1299,6 +1299,7 @@ then with_named_thread="-lgthreads -lsocket -lgthreads" # sched.h conflicts with fsu-threads touch ./include/sched.h + touch ./include/semaphore.h # We must have gcc if expr "$CC" : ".*gcc.*" From c9a46a43d274957f5faed3a9e0ed33e02407bb64 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Fri, 13 Aug 2004 15:29:47 +0200 Subject: [PATCH 55/63] Escaping [] so that darwin[7-8] gets into 'configure' and not darwin7-8 Adding a compilation define so that on recent Darwin mysqld does not react to SIGHUP and SIGQUIT: this fixes a rpl000001 problem on our Powermac G5 machine (popping after an upgrade from 10.3.4 to 10.3.5) and is expected to fix BUG#2030 "relay bin log on slave resets multiple times a second" (i.e. under some Mac OS X Panther versions, mysqld receives many SIGHUP and SIGQUIT). So this fix is more a problem-hider than a real understanding of why mysqld receives so many signals. Note that we saw other problems on this OS where mysqld reacts to Ctrl-Z but apparently only once, where using SSL seems to make the problem more frequent... --- configure.in | 5 +++-- sql/mysqld.cc | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index be3269d50d6..a3be0966a17 100644 --- a/configure.in +++ b/configure.in @@ -1047,10 +1047,11 @@ case $SYSTEM_TYPE in MAX_C_OPTIMIZE="-O" fi ;; - *darwin[7-8]*) + *darwin[[7-8]]*) + # don't forget to escape [] like above if test "$ac_cv_prog_gcc" = "yes" then - FLAGS="-DHAVE_DARWIN_THREADS -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ" + FLAGS="-DHAVE_DARWIN_THREADS -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT" CFLAGS="$CFLAGS $FLAGS" CXXFLAGS="$CXXFLAGS $FLAGS" MAX_C_OPTIMIZE="-O" diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3f7c187ccdd..8f08099f340 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1836,9 +1836,11 @@ static void init_signals(void) sigaddset(&set,SIGPIPE); #endif sigaddset(&set,SIGINT); +#ifndef IGNORE_SIGHUP_SIGQUIT sigaddset(&set,SIGQUIT); - sigaddset(&set,SIGTERM); sigaddset(&set,SIGHUP); +#endif + sigaddset(&set,SIGTERM); /* Fix signals if blocked by parents (can happen on Mac OS X) */ sigemptyset(&sa.sa_mask); @@ -1921,11 +1923,13 @@ extern "C" void *signal_hand(void *arg __attribute__((unused))) #ifdef USE_ONE_SIGNAL_HAND (void) sigaddset(&set,THR_SERVER_ALARM); // For alarms #endif +#ifndef IGNORE_SIGHUP_SIGQUIT (void) sigaddset(&set,SIGQUIT); - (void) sigaddset(&set,SIGTERM); #if THR_CLIENT_ALARM != SIGHUP (void) sigaddset(&set,SIGHUP); #endif +#endif + (void) sigaddset(&set,SIGTERM); (void) sigaddset(&set,SIGTSTP); /* Save pid to this process (or thread on Linux) */ From 5273b4e5f5944688b1663454748233ce856719e8 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 13 Aug 2004 17:27:58 +0300 Subject: [PATCH 56/63] row0mysql.c: Fix bug: if we RENAME a table, InnoDB forgot to load the foreign key constraints that reference the new table name, and forgot to check that they are compatible with the table --- innobase/row/row0mysql.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 98ab1a1e754..70743e3a753 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -2630,6 +2630,30 @@ row_rename_table_for_mysql( ut_print_name(stderr, new_name); fputs("\n" "InnoDB: has or is referenced in foreign key constraints\n" + "InnoDB: which are not compatible with the new table definition.\n", + stderr); + + ut_a(dict_table_rename_in_cache(table, + old_name, FALSE)); + + trx->error_state = DB_SUCCESS; + trx_general_rollback_for_mysql(trx, FALSE, + NULL); + trx->error_state = DB_SUCCESS; + } + } else { + err = dict_load_foreigns(new_name); + + if (err != DB_SUCCESS) { + + ut_print_timestamp(stderr); + + fputs( + " InnoDB: Error: in RENAME TABLE table ", + stderr); + ut_print_name(stderr, new_name); + fputs("\n" + "InnoDB: is referenced in foreign key constraints\n" "InnoDB: which are not compatible with the new table definition.\n", stderr); From 4a96a8a64fba89eabe559361f4c790113f2e8765 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Sat, 14 Aug 2004 15:24:40 +0200 Subject: [PATCH 57/63] Fix for BUG#5050 "mysql-test-run fails on rpl_trunc_binlog after 'make install'": The binlog files we use for some tests must be installed like other mysql-test/std_data/ files. --- mysql-test/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 66f931133e3..ba96c5947ba 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -48,6 +48,7 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/r/*.require $(DESTDIR)$(testdir)/r $(INSTALL_DATA) $(srcdir)/include/*.inc $(DESTDIR)$(testdir)/include $(INSTALL_DATA) $(srcdir)/std_data/*.dat $(DESTDIR)$(testdir)/std_data + $(INSTALL_DATA) $(srcdir)/std_data/*.*001 $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(DESTDIR)$(testdir)/std_data SUFFIXES = .sh From ee898804738e402c7dcfc6b87498f2729f60c430 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Mon, 16 Aug 2004 15:07:45 -0700 Subject: [PATCH 58/63] A desperate attempt to comment one place where we do conversions. --- sql/field.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sql/field.cc b/sql/field.cc index 946f5ed8621..aca1f8846f0 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2332,6 +2332,33 @@ String *Field_double::val_str(String *val_buffer, if (dec >= NOT_FIXED_DEC) { + /* + Let's try to pretty print a floating point number. Here we use + '%-*.*g' conversion string: + '-' stands for left-padding with spaces, if such padding will take + place + '*' is a placeholder for the first argument, field_length, and + signifies minimal width of result string. If result is less than + field length it will be space-padded. Note, however, that we'll not + pass spaces to Field_string::store(const char *, ...), due to + strcend in the next line. + '.*' is a placeholder for DBL_DIG and defines maximum number of + significant digits in the result string. DBL_DIG is a hardware + specific C define for maximum number of decimal digits of a floating + point number, such that rounding to hardware floating point + representation and back to decimal will not lead to loss of + precision. I.e if DBL_DIG is 15, number 123456789111315 can be + represented as double without precision loss. As one can judge from + this description, chosing DBL_DIG here is questionable, especially + because it introduces a system dependency. + 'g' means that conversion will use [-]ddd.ddd (conventional) style, + and fall back to [-]d.ddde[+|i]ddd (scientific) style if there is no + enough space for all digits. + Maximum length of result string (not counting spaces) is (I guess) + DBL_DIG + 8, where 8 is 1 for sign, 1 for decimal point, 1 for + exponent sign, 1 for exponent, and 4 for exponent value. + XXX: why do we use space-padding and trim spaces in the next line? + */ sprintf(to,"%-*.*g",(int) field_length,DBL_DIG,nr); to=strcend(to,' '); } From f1ab1b129fa6ea80537dcd1961801052e5d20b88 Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Tue, 17 Aug 2004 11:12:22 +0500 Subject: [PATCH 59/63] A fix (bug #5055: SQL_SELECT_LIMIT=0 crashes command line client): mysql outwits itself. --- client/mysql.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 66a99bbdf75..8343543ba33 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2351,13 +2351,16 @@ com_status(String *buffer __attribute__((unused)), MYSQL_RES *result; LINT_INIT(result); tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql)); - if (!mysql_query(&mysql,"select DATABASE(),USER()") && + if (!mysql_query(&mysql,"select DATABASE(), USER() limit 1") && (result=mysql_use_result(&mysql))) { MYSQL_ROW cur=mysql_fetch_row(result); - tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : ""); - tee_fprintf(stdout, "Current user:\t\t%s\n",cur[1]); - (void) mysql_fetch_row(result); // Read eof + if (cur) + { + tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : ""); + tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]); + } + mysql_free_result(result); } #ifdef HAVE_OPENSSL if (mysql.net.vio && mysql.net.vio->ssl_arg && From 8c9fc27f7ce221b9dca69263a12525ce5be53905 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Tue, 17 Aug 2004 14:12:37 +0200 Subject: [PATCH 60/63] Fix for BUG#5073 "--disable-local-infile has no effect if client reads it with MYSQL_READ_DEFAULT": that was a forgotten '~' probably. --- libmysql/libmysql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index cbe6bb3959f..a591ad9317d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -944,7 +944,7 @@ static void mysql_read_default_options(struct st_mysql_options *options, options->client_flag&= ~CLIENT_LOCAL_FILES; break; case 22: - options->client_flag&= CLIENT_LOCAL_FILES; + options->client_flag&= ~CLIENT_LOCAL_FILES; break; case 23: /* replication probe */ options->rpl_probe= 1; From ccc97ac12cffa234a8e4347ad24e839da3307f27 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Wed, 18 Aug 2004 00:04:43 +0200 Subject: [PATCH 61/63] use my_vsnprintf() just in case bug#4925 --- sql/net_pkg.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/net_pkg.cc b/sql/net_pkg.cc index 315cad5ca6d..cc9147fe90a 100644 --- a/sql/net_pkg.cc +++ b/sql/net_pkg.cc @@ -124,7 +124,9 @@ net_printf(NET *net, uint errcode, ...) } offset= net->return_errno ? 2 : 0; text_pos=(char*) net->buff+head_length+offset+1; - (void) vsprintf(my_const_cast(char*) (text_pos),format,args); + (void) my_vsnprintf(my_const_cast(char*) (text_pos), + (char*)net->buff_end-text_pos, + format,args); length=(uint) strlen((char*) text_pos); if (length >= sizeof(net->last_error)) length=sizeof(net->last_error)-1; /* purecov: inspected */ From 6feb6ea545ae158a61e497bb9212d367a17305e4 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Wed, 18 Aug 2004 01:48:01 +0300 Subject: [PATCH 62/63] srv0start.c, ut0mem.c, ut0dbg.c, ut0dbg.h, srv0start.h: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) mysqld.cc, ha_innodb.cc: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) --- innobase/include/srv0start.h | 4 +++- innobase/include/ut0dbg.h | 34 +++++++++++++++++++++++++++++++++- innobase/srv/srv0start.c | 24 ++++++++++++++++++------ innobase/ut/ut0dbg.c | 7 ++++++- innobase/ut/ut0mem.c | 6 ++++++ sql/ha_innodb.cc | 9 +++++++++ sql/mysqld.cc | 3 +++ 7 files changed, 78 insertions(+), 9 deletions(-) diff --git a/innobase/include/srv0start.h b/innobase/include/srv0start.h index c4c8dac5d7a..539ccb32744 100644 --- a/innobase/include/srv0start.h +++ b/innobase/include/srv0start.h @@ -63,11 +63,13 @@ innobase_start_or_create_for_mysql(void); /* out: DB_SUCCESS or error code */ /******************************************************************** Shuts down the Innobase database. */ - int innobase_shutdown_for_mysql(void); /*=============================*/ /* out: DB_SUCCESS or error code */ +#ifdef __NETWARE__ +void set_panic_flag_for_netware(void); +#endif extern ulint srv_sizeof_trx_t_in_ha_innodb_cc; diff --git a/innobase/include/ut0dbg.h b/innobase/include/ut0dbg.h index bec9cdd42b5..fe6aba2cccb 100644 --- a/innobase/include/ut0dbg.h +++ b/innobase/include/ut0dbg.h @@ -22,7 +22,38 @@ extern ulint* ut_dbg_null_ptr; extern const char* ut_dbg_msg_assert_fail; extern const char* ut_dbg_msg_trap; extern const char* ut_dbg_msg_stop; - +/* Have a graceful exit on NetWare rather than a segfault to avoid abends */ +#ifdef __NETWARE__ +extern ibool panic_shutdown; +#define ut_a(EXPR) do {\ + if (!((ulint)(EXPR) + ut_dbg_zero)) {\ + ut_print_timestamp(stderr);\ + fprintf(stderr, ut_dbg_msg_assert_fail,\ + os_thread_pf(os_thread_get_curr_id()), __FILE__,\ + (ulint)__LINE__);\ + fputs("InnoDB: Failing assertion: " #EXPR "\n", stderr);\ + fputs(ut_dbg_msg_trap, stderr);\ + ut_dbg_stop_threads = TRUE;\ + if (ut_dbg_stop_threads) {\ + fprintf(stderr, ut_dbg_msg_stop,\ + os_thread_pf(os_thread_get_curr_id()), __FILE__, (ulint)__LINE__);\ + }\ + if(!panic_shutdown){\ + panic_shutdown = TRUE;\ + innobase_shutdown_for_mysql();}\ + exit(1);\ + }\ +} while (0) +#define ut_error do {\ + ut_print_timestamp(stderr);\ + fprintf(stderr, ut_dbg_msg_assert_fail,\ + os_thread_pf(os_thread_get_curr_id()), __FILE__, (ulint)__LINE__);\ + fprintf(stderr, ut_dbg_msg_trap);\ + ut_dbg_stop_threads = TRUE;\ + if(!panic_shutdown){panic_shutdown = TRUE;\ + innobase_shutdown_for_mysql();}\ +} while (0) +#else #define ut_a(EXPR) do {\ if (!((ulint)(EXPR) + ut_dbg_zero)) {\ ut_print_timestamp(stderr);\ @@ -49,6 +80,7 @@ extern const char* ut_dbg_msg_stop; ut_dbg_stop_threads = TRUE;\ if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL;\ } while (0) +#endif #ifdef UNIV_DEBUG # define ut_ad(EXPR) ut_a(EXPR) diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 30c9982068e..9baa86234a0 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -1079,6 +1079,7 @@ NetWare. */ for (i = 0; i < srv_n_file_io_threads; i++) { n[i] = i; + os_thread_create(io_handler_thread, n + i, thread_ids + i); } @@ -1440,7 +1441,6 @@ NetWare. */ } fflush(stderr); - return((int) DB_SUCCESS); } @@ -1453,7 +1453,9 @@ innobase_shutdown_for_mysql(void) /* out: DB_SUCCESS or error code */ { ulint i; - +#ifdef __NETWARE__ + extern ibool panic_shutdown; +#endif if (!srv_was_started) { if (srv_is_being_started) { ut_print_timestamp(stderr); @@ -1471,8 +1473,11 @@ innobase_shutdown_for_mysql(void) The step 1 is the real InnoDB shutdown. The remaining steps just free data structures after the shutdown. */ +#ifdef __NETWARE__ + if(!panic_shutdown) +#endif logs_empty_and_mark_files_at_shutdown(); - + if (srv_conc_n_threads != 0) { fprintf(stderr, "InnoDB: Warning: query counter shows %ld queries still\n" @@ -1540,12 +1545,11 @@ innobase_shutdown_for_mysql(void) mem_free(srv_monitor_file_name); } } - + mutex_free(&srv_monitor_file_mutex); /* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside them */ - sync_close(); /* 4. Free the os_conc_mutex and all os_events and os_mutexes */ @@ -1556,7 +1560,7 @@ innobase_shutdown_for_mysql(void) /* 5. Free all allocated memory and the os_fast_mutex created in ut0mem.c */ - ut_free_all_mem(); + ut_free_all_mem(); if (os_thread_count != 0 || os_event_count != 0 @@ -1583,3 +1587,11 @@ innobase_shutdown_for_mysql(void) return((int) DB_SUCCESS); } + +#ifdef __NETWARE__ +void set_panic_flag_for_netware() +{ + extern ibool panic_shutdown; + panic_shutdown = TRUE; +} +#endif diff --git a/innobase/ut/ut0dbg.c b/innobase/ut/ut0dbg.c index 65703ec1c86..2a0cfe1f13a 100644 --- a/innobase/ut/ut0dbg.c +++ b/innobase/ut/ut0dbg.c @@ -14,7 +14,12 @@ ulint ut_dbg_zero = 0; /* If this is set to TRUE all threads will stop into the next assertion and assert */ ibool ut_dbg_stop_threads = FALSE; - +#ifdef __NETWARE__ +ibool panic_shutdown = FALSE; /* This is set to TRUE when on NetWare there + happens an InnoDB assertion failure or other + fatal error condition that requires an + immediate shutdown. */ +#endif /* Null pointer used to generate memory trap */ ulint* ut_dbg_null_ptr = NULL; diff --git a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c index 2cab36a9580..9b08b1e79aa 100644 --- a/innobase/ut/ut0mem.c +++ b/innobase/ut/ut0mem.c @@ -106,7 +106,13 @@ ut_malloc_low( /* Make an intentional seg fault so that we get a stack trace */ + /* Intentional segfault on NetWare causes an abend. Avoid this + by graceful exit handling in ut_a(). */ +#if (!defined __NETWARE__) if (*ut_mem_null_ptr) ut_mem_null_ptr = 0; +#else + ut_a(0); +#endif } if (set_to_zero) { diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index f233dd5a5c5..22ddfe779d5 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -121,6 +121,10 @@ char innodb_dummy_stmt_trx_handle = 'D'; static HASH innobase_open_tables; +#ifdef __NETWARE__ /* some special cleanup for NetWare */ +bool nw_panic = FALSE; +#endif + static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length, my_bool not_used __attribute__((unused))); static INNOBASE_SHARE *get_share(const char *table_name); @@ -950,6 +954,11 @@ innobase_end(void) DBUG_ENTER("innobase_end"); +#ifdef __NETWARE__ /* some special cleanup for NetWare */ + if (nw_panic) { + set_panic_flag_for_netware(); + } +#endif err = innobase_shutdown_for_mysql(); hash_free(&innobase_open_tables); my_free(internal_innobase_data_file_path,MYF(MY_ALLOW_ZERO_PTR)); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8f08099f340..e4d60fc9e7c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1547,6 +1547,8 @@ void registerwithneb() ulong neb_event_callback(struct EventBlock *eblock) { EventChangeVolStateEnter_s *voldata; + extern bool nw_panic; + voldata= (EventChangeVolStateEnter_s *)eblock->EBEventData; /* Deactivation of a volume */ @@ -1559,6 +1561,7 @@ ulong neb_event_callback(struct EventBlock *eblock) if (!memcmp(&voldata->volID, &datavolid, sizeof(VolumeID_t))) { consoleprintf("MySQL data volume is deactivated, shutting down MySQL Server \n"); + nw_panic = TRUE; kill_server(0); } } From 8ce92878a2c32785a5af86e9ffa27b4904d01694 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Wed, 18 Aug 2004 14:46:31 +0200 Subject: [PATCH 63/63] Bug 4937: different date -> string conversion when using SELECT ... UNION and INSERT ... SELECT ... UNION --- mysql-test/r/type_date.result | 17 +++++++ mysql-test/t/type_date.test | 19 ++++++++ sql/field.cc | 90 +++++++++++++++++++---------------- sql/field.h | 3 +- 4 files changed, 88 insertions(+), 41 deletions(-) diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index 3b08f7dcbf2..5ec2c9e0434 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -79,3 +79,20 @@ SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1; DATE_FORMAT(f1, "%l.%i %p") DATE_FORMAT(f2, "%l.%i %p") 9.00 AM 12.00 PM DROP TABLE t1; +CREATE TABLE t1 (f1 DATE); +CREATE TABLE t2 (f2 VARCHAR(8)); +CREATE TABLE t3 (f2 CHAR(8)); +INSERT INTO t1 VALUES ('1978-11-26'); +INSERT INTO t2 SELECT f1+0 FROM t1; +INSERT INTO t2 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1; +INSERT INTO t3 SELECT f1+0 FROM t1; +INSERT INTO t3 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1; +SELECT * FROM t2; +f2 +19781126 +19781126 +SELECT * FROM t3; +f2 +19781126 +19781126 +DROP TABLE t1, t2, t3; diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index fe706e9bf57..0f949e3a10a 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -84,3 +84,22 @@ CREATE TABLE t1 (f1 time default NULL, f2 time default NULL) TYPE=MyISAM; INSERT INTO t1 (f1, f2) VALUES ('09:00', '12:00'); SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1; DROP TABLE t1; + +# +# Bug 4937: different date -> string conversion when using SELECT ... UNION +# and INSERT ... SELECT ... UNION +# + +CREATE TABLE t1 (f1 DATE); +CREATE TABLE t2 (f2 VARCHAR(8)); +CREATE TABLE t3 (f2 CHAR(8)); + +INSERT INTO t1 VALUES ('1978-11-26'); +INSERT INTO t2 SELECT f1+0 FROM t1; +INSERT INTO t2 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1; +INSERT INTO t3 SELECT f1+0 FROM t1; +INSERT INTO t3 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1; +SELECT * FROM t2; +SELECT * FROM t3; + +DROP TABLE t1, t2, t3; diff --git a/sql/field.cc b/sql/field.cc index aca1f8846f0..33717d99583 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -37,6 +37,7 @@ #include "sql_select.h" #include #include +#include #ifdef HAVE_FCONVERT #include #endif @@ -58,6 +59,8 @@ template class List_iterator; uchar Field_null::null[1]={1}; const char field_separator=','; +#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE 320 + /***************************************************************************** Static help functions *****************************************************************************/ @@ -739,7 +742,7 @@ void Field_decimal::store(double nr) reg4 uint i,length; char fyllchar,*to; - char buff[320]; + char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; fyllchar = zerofill ? (char) '0' : (char) ' '; #ifdef HAVE_SNPRINTF @@ -2326,46 +2329,20 @@ String *Field_double::val_str(String *val_buffer, #endif doubleget(nr,ptr); - uint to_length=max(field_length,320); + uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE); val_buffer->alloc(to_length); char *to=(char*) val_buffer->ptr(); if (dec >= NOT_FIXED_DEC) { - /* - Let's try to pretty print a floating point number. Here we use - '%-*.*g' conversion string: - '-' stands for left-padding with spaces, if such padding will take - place - '*' is a placeholder for the first argument, field_length, and - signifies minimal width of result string. If result is less than - field length it will be space-padded. Note, however, that we'll not - pass spaces to Field_string::store(const char *, ...), due to - strcend in the next line. - '.*' is a placeholder for DBL_DIG and defines maximum number of - significant digits in the result string. DBL_DIG is a hardware - specific C define for maximum number of decimal digits of a floating - point number, such that rounding to hardware floating point - representation and back to decimal will not lead to loss of - precision. I.e if DBL_DIG is 15, number 123456789111315 can be - represented as double without precision loss. As one can judge from - this description, chosing DBL_DIG here is questionable, especially - because it introduces a system dependency. - 'g' means that conversion will use [-]ddd.ddd (conventional) style, - and fall back to [-]d.ddde[+|i]ddd (scientific) style if there is no - enough space for all digits. - Maximum length of result string (not counting spaces) is (I guess) - DBL_DIG + 8, where 8 is 1 for sign, 1 for decimal point, 1 for - exponent sign, 1 for exponent, and 4 for exponent value. - XXX: why do we use space-padding and trim spaces in the next line? - */ sprintf(to,"%-*.*g",(int) field_length,DBL_DIG,nr); to=strcend(to,' '); } else { #ifdef HAVE_FCONVERT - char buff[320],*pos=buff; + char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE], + char *pos= buff; int decpt,sign,tmp_dec=dec; VOID(fconvert(nr,tmp_dec,&decpt,&sign,buff)); @@ -3721,13 +3698,50 @@ void Field_string::store(const char *from,uint length) } +/* + Store double value in Field_string or Field_varstring. + + SYNOPSIS + store_double_in_string_field() + field field to store value in + field_length number of characters in the field + nr number + + DESCRIPTION + Pretty prints double number into field_length characters buffer. +*/ + +static void store_double_in_string_field(Field_str *field, uint32 field_length, + double nr) +{ + bool use_scientific_notation=TRUE; + char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; + int length; + if (field_length < 32 && nr > 1) + { + if (field->ceiling == 0) + { + static double e[]= {1e1, 1e2, 1e4, 1e8, 1e16 }; + double p= 1; + for (int i= sizeof(e)/sizeof(e[0]), j= 1<>= 1 ) + { + if (field_length & j) + p*= e[i]; + } + field->ceiling= p-1; + } + use_scientific_notation= (field->ceiling < nr); + } + length= sprintf(buff, "%-.*g", + use_scientific_notation ? max(0,field_length-5) : field_length, + nr); + DBUG_ASSERT(length <= field_length); + field->store(buff, (uint) length); +} + void Field_string::store(double nr) { - char buff[MAX_FIELD_WIDTH],*end; - int width=min(field_length,DBL_DIG+5); - sprintf(buff,"%-*.*g",width,max(width-5,0),nr); - end=strcend(buff,' '); - Field_string::store(buff,(uint) (end - buff)); + store_double_in_string_field(this, field_length, nr); } @@ -3927,11 +3941,7 @@ void Field_varstring::store(const char *from,uint length) void Field_varstring::store(double nr) { - char buff[MAX_FIELD_WIDTH],*end; - int width=min(field_length,DBL_DIG+5); - sprintf(buff,"%-*.*g",width,max(width-5,0),nr); - end=strcend(buff,' '); - Field_varstring::store(buff,(uint) (end - buff)); + store_double_in_string_field(this, field_length, nr); } diff --git a/sql/field.h b/sql/field.h index d93ed1db9b5..d25ce8d4774 100644 --- a/sql/field.h +++ b/sql/field.h @@ -255,12 +255,13 @@ public: class Field_str :public Field { public: + double ceiling; // for ::store(double nr) Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, struct st_table *table_arg) :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, table_arg) + unireg_check_arg, field_name_arg, table_arg), ceiling(0.0) {} Item_result result_type () const { return STRING_RESULT; } uint decimals() const { return NOT_FIXED_DEC; }