From a1a78bbc4a80322b231f5e68751bbeb10b209af0 Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Tue, 15 Feb 2005 11:16:17 +0200 Subject: [PATCH 1/8] InnoDB: Create temporary files in the MySQL tmpdir instead of $TMPDIR. (Bug #5822) --- sql/ha_innodb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 1a870ce3abf..81a803e36b9 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -424,7 +424,7 @@ innobase_mysql_tmpfile(void) { char filename[FN_REFLEN]; int fd2 = -1; - File fd = create_temp_file(filename, NullS, "ib", + File fd = create_temp_file(filename, mysql_tmpdir, "ib", #ifdef __WIN__ O_BINARY | O_TRUNC | O_SEQUENTIAL | O_TEMPORARY | O_SHORT_LIVED | From 625f7f0d5565c90ce3d2ea3cf14706f28fc5c0e5 Mon Sep 17 00:00:00 2001 From: "mats@mysql.com" <> Date: Tue, 15 Feb 2005 11:02:01 +0100 Subject: [PATCH 2/8] Bug#7879: Using TL_READ_NO_INSERT locks instead of TL_READ locks when reading tables in "complex" SQL statements. If inserts happen in a table being read, the statements have no serialization order and the change can therefore not be reproduced on the slave. --- sql/sql_update.cc | 5 ++++- sql/sql_yacc.yy | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 4f7e34ec74f..bff360d02dc 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -479,7 +479,10 @@ int mysql_multi_update(THD *thd, else { DBUG_PRINT("info",("setting table `%s` for read-only", tl->alias)); - tl->lock_type= TL_READ; + // If we are using the binary log, we need TL_READ_NO_INSERT to get + // correct order of statements. Otherwise, we use a TL_READ lock to + // improve performance. + tl->lock_type= using_update_log ? TL_READ_NO_INSERT : TL_READ; tl->updating= 0; wants= SELECT_ACL; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7b72c73a915..3e45e35c618 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -822,7 +822,7 @@ create_select: SELECT_SYM { LEX *lex=Lex; - lex->lock_option= (using_update_log) ? TL_READ_NO_INSERT : TL_READ; + lex->lock_option= using_update_log ? TL_READ_NO_INSERT : TL_READ; if (lex->sql_command == SQLCOM_INSERT) lex->sql_command= SQLCOM_INSERT_SELECT; else if (lex->sql_command == SQLCOM_REPLACE) @@ -1532,7 +1532,7 @@ select_part2: { LEX *lex=Lex; lex->lock_option=TL_READ; - mysql_init_select(lex); + mysql_init_select(lex); } select_options select_item_list select_into select_lock_type; From 788a2658a3d572152efdb65027b5b57b55b0cfed Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Tue, 15 Feb 2005 14:42:13 +0200 Subject: [PATCH 3/8] Better bug fix for #5569: "Incorrect "Access Denied" error with SAME login DIFFERENT host" This fixes also the reverse lookup bug introduced by the previous patch --- mysql-test/t/group_by.test | 1 - sql/sql_parse.cc | 23 +++++++++++++---------- vio/viosocket.c | 12 ++++++++++++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 5af78b924f8..2e5446c2d92 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -455,4 +455,3 @@ select min(a) is null from t1; select min(a) is null or null from t1; select 1 and min(a) is null from t1; drop table t1; - diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index cd0abafc0c9..613484ebf50 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -504,8 +504,6 @@ check_connections(THD *thd) DBUG_PRINT("info",("New connection received on %s", vio_description(net->vio))); - vio_in_addr(net->vio,&thd->remote.sin_addr); - if (!thd->host) // If TCP/IP connection { char ip[30]; @@ -515,6 +513,7 @@ check_connections(THD *thd) if (!(thd->ip = my_strdup(ip,MYF(0)))) return (ER_OUT_OF_RESOURCES); thd->host_or_ip=thd->ip; + vio_in_addr(net->vio, &thd->remote.sin_addr); #if !defined(HAVE_SYS_UN_H) || defined(HAVE_mit_thread) /* Fast local hostname resolve for Win32 */ if (!strcmp(thd->ip,"127.0.0.1")) @@ -524,17 +523,19 @@ check_connections(THD *thd) } else #endif - if (!(specialflag & SPECIAL_NO_RESOLVE)) { - thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors); - /* Cut very long hostnames to avoid possible overflows */ - if (thd->host) + if (!(specialflag & SPECIAL_NO_RESOLVE)) { - thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0; - thd->host_or_ip= thd->host; + thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors); + /* Cut very long hostnames to avoid possible overflows */ + if (thd->host) + { + thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0; + thd->host_or_ip= thd->host; + } + if (connect_errors > max_connect_errors) + return(ER_HOST_IS_BLOCKED); } - if (connect_errors > max_connect_errors) - return(ER_HOST_IS_BLOCKED); } DBUG_PRINT("info",("Host: %s ip: %s", thd->host ? thd->host : "unknown host", @@ -547,6 +548,8 @@ check_connections(THD *thd) DBUG_PRINT("info",("Host: %s",thd->host)); thd->host_or_ip= thd->host; thd->ip= 0; + /* Reset sin_addr */ + bzero((char*) &thd->remote, sizeof(thd->remote)); } vio_keepalive(net->vio, TRUE); diff --git a/vio/viosocket.c b/vio/viosocket.c index 1b6f46c57cf..f45c9dd98c4 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -291,6 +291,18 @@ my_bool vio_peer_addr(Vio * vio, char *buf, uint16 *port) } +/* + Get in_addr for a TCP/IP connection + + SYNOPSIS + vio_in_addr() + vio vio handle + in put in_addr here + + NOTES + one must call vio_peer_addr() before calling this one +*/ + void vio_in_addr(Vio *vio, struct in_addr *in) { DBUG_ENTER("vio_in_addr"); From c962d060ac40b15e3280f71b59e17b8428c421b6 Mon Sep 17 00:00:00 2001 From: "dean@mysql.com" <> Date: Tue, 15 Feb 2005 17:27:23 -0600 Subject: [PATCH 4/8] ft_nlq_search.c: Added bounds check to avoid accessing unallocated FT_DOC array. (BUG #8522) --- BitKeeper/etc/logging_ok | 1 + myisam/ft_nlq_search.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 9465991bc17..f8621170f64 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -24,6 +24,7 @@ bk@admin.bk brian@brian-akers-computer.local carsten@tsort.bitbybit.dk davida@isil.mysql.com +dean@mysql.com dellis@goetia.(none) dlenev@brandersnatch.localdomain dlenev@build.mysql.com diff --git a/myisam/ft_nlq_search.c b/myisam/ft_nlq_search.c index 3ad983f0a37..13cbf24b3f7 100644 --- a/myisam/ft_nlq_search.c +++ b/myisam/ft_nlq_search.c @@ -205,6 +205,10 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query, left_root_right)) goto err2; + /* + If ndocs == 0, this will not allocate RAM for FT_INFO.doc[], + so if ndocs == 0, FT_INFO.doc[] must not be accessed. + */ dlist=(FT_INFO *)my_malloc(sizeof(FT_INFO)+ sizeof(FT_DOC)*(aio.dtree.elements_in_tree-1), MYF(0)); @@ -275,7 +279,8 @@ float ft_nlq_find_relevance(FT_INFO *handler, else a=c; } - if (docs[a].dpos == docid) + /* bounds check to avoid accessing unallocated handler->doc */ + if (a < handler->ndocs && docs[a].dpos == docid) return (float) docs[a].weight; else return 0.0; From d4779d353424dea97f20b1776452b42efc9fae1c Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Tue, 15 Feb 2005 18:45:42 -0800 Subject: [PATCH 5/8] delete.result, delete.test: Added a test case for bug #8392. sql_delete.cc: Fixed bug #8392. The bug caused a crash for a delete statement with ORDER BY that explicitly referred to the modified table. --- mysql-test/r/delete.result | 9 +++++++++ mysql-test/t/delete.test | 11 +++++++++++ sql/sql_delete.cc | 1 + 3 files changed, 21 insertions(+) diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index 7353e687ae7..378371f2982 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -61,3 +61,12 @@ select * from t1; a b 1 apple drop table t1; +CREATE TABLE t1 ( a int PRIMARY KEY ); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +INSERT INTO t1 VALUES (0),(1),(2); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1; +SELECT * FROM t1; +a +0 +2 +DROP TABLE t1; diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 07cb9155b3f..5fcdd6263ed 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -71,3 +71,14 @@ select * from t1; delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a; select * from t1; drop table t1; + +# +# Bug #8392: delete with ORDER BY containing a direct reference to the table +# + +CREATE TABLE t1 ( a int PRIMARY KEY ); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +INSERT INTO t1 VALUES (0),(1),(2); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1; +SELECT * FROM t1; +DROP TABLE t1; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 92193e3abf2..475df34dc4f 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -111,6 +111,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, bzero((char*) &tables,sizeof(tables)); tables.table = table; + tables.alias = table_list->alias; table->io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE), MYF(MY_FAE | MY_ZEROFILL)); From 87718094aaa61a417c6b99c18c1636151cc5bf51 Mon Sep 17 00:00:00 2001 From: "dean@mysql.com" <> Date: Wed, 16 Feb 2005 03:13:29 -0600 Subject: [PATCH 6/8] fulltext.test, fulltext.result: Test case for bug#8522, to test for out of bounds memory access in ft_nlq_find_relevance(). --- mysql-test/r/fulltext.result | 6 ++++++ mysql-test/t/fulltext.test | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 50f0a1dc120..ce1703fca0e 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -315,3 +315,9 @@ select count(*) from t1; count(*) 1 drop table t1; +CREATE TABLE t1 ( a TEXT, FULLTEXT (a) ); +INSERT INTO t1 VALUES ('testing ft_nlq_find_relevance'); +SELECT MATCH(a) AGAINST ('nosuchword') FROM t1; +MATCH(a) AGAINST ('nosuchword') +0 +DROP TABLE t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index b44854860f9..90020e9468e 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -252,3 +252,11 @@ REPAIR TABLE t1; select count(*) from t1; drop table t1; +# +# testing out of bounds memory access in ft_nlq_find_relevance() +# (bug#8522); visible in valgrind. +# +CREATE TABLE t1 ( a TEXT, FULLTEXT (a) ); +INSERT INTO t1 VALUES ('testing ft_nlq_find_relevance'); +SELECT MATCH(a) AGAINST ('nosuchword') FROM t1; +DROP TABLE t1; From aecc58b3d8cc448c789ac34567f9ae3388e4ddc1 Mon Sep 17 00:00:00 2001 From: "acurtis@pcgem.rdg.cyberkinetica.com" <> Date: Wed, 16 Feb 2005 16:05:18 +0000 Subject: [PATCH 7/8] Bug#4445 Make a more informative platform info for Windows --- include/config-win.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/include/config-win.h b/include/config-win.h index 152e85c8e68..42aa23c3afe 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -23,18 +23,25 @@ #include #include -#if defined(__NT__) -#define SYSTEM_TYPE "NT" -#elif defined(__WIN2000__) -#define SYSTEM_TYPE "WIN2000" +#if defined(_WIN64) || defined(WIN64) +#define SYSTEM_TYPE "Win64" +#elif defined(_WIN32) || defined(WIN32) +#define SYSTEM_TYPE "Win32" #else -#define SYSTEM_TYPE "Win95/Win98" +#define SYSTEM_TYPE "Windows" #endif -#if defined(_WIN64) || defined(WIN64) -#define MACHINE_TYPE "ia64" /* Define to machine type name */ +#if defined(_M_IA64) +#define MACHINE_TYPE "ia64" +#elif defined(_M_IX86) +#define MACHINE_TYPE "ia32" +#elif defined(_M_ALPHA) +#define MACHINE_TYPE "axp" #else -#define MACHINE_TYPE "i32" /* Define to machine type name */ +#define MACHINE_TYPE "unknown" /* Define to machine type name */ +#endif + +#if !(defined(_WIN64) || defined(WIN64)) #ifndef _WIN32 #define _WIN32 /* Compatible with old source */ #endif From af41813cffb08b101febee1e8173782267b98f28 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 16 Feb 2005 14:03:16 -0800 Subject: [PATCH 8/8] Make post-commit trigger not send emails when the message would not contain any actual changes. (Often the case in merges where the only change involves renumbering ChangeSet entries.) --- BitKeeper/triggers/post-commit | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BitKeeper/triggers/post-commit b/BitKeeper/triggers/post-commit index a38b1f5a068..d2a4f9153b2 100755 --- a/BitKeeper/triggers/post-commit +++ b/BitKeeper/triggers/post-commit @@ -19,6 +19,13 @@ BK_STATUS=$BK_STATUS$BK_COMMIT if [ "$BK_STATUS" = OK ] then +HAS_ACTUAL_CHANGES=`bk cset -r+ -d | grep -v "^#"` +if [ "$HAS_ACTUAL_CHANGES" = "" ] +then + echo ChangeSet had no real changes, not sending emails + exit +fi + CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet` BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/\1/p'`