From 0b2a28f5cf69237f501b075dd3cfde318768fce8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Sep 2006 22:02:06 +0400 Subject: [PATCH 1/8] BUG#9678: Client library hangs after network communication failure (back-port to 4.0) Socket timeouts in client library were used only on Windows. Additionally, in 4.0 write operations erroneously set read timeout. The solution is to use socket timeouts in client library on all systems were they are supported, and to differentiate between read and write timeouts. No test case is provided because it is impossible to simulate network failure in current test suite. include/violite.h: Add argument to vio_timeout() to determine which timeout should be set: for read (false) or for write (true). libmysqld/lib_vio.c: Add argument to vio_timeout() to determine which timeout should be set: for read (false) or for write (true). sql/net_serv.cc: Add argument to vio_timeout() to determine which timeout should be set: for read (false) or for write (true). vio/viosocket.c: Add argument to vio_timeout() to determine which timeout should be set: for read (false) or for write (true). Implement socket timeouts on POSIX systems. --- include/violite.h | 6 +++--- libmysqld/lib_vio.c | 1 + sql/net_serv.cc | 4 ++-- vio/viosocket.c | 26 ++++++++++++++++++++------ 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/include/violite.h b/include/violite.h index 23fd694d355..ee19cbd62fe 100644 --- a/include/violite.h +++ b/include/violite.h @@ -77,7 +77,7 @@ my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port); /* Remotes in_addr */ void vio_in_addr(Vio *vio, struct in_addr *in); my_bool vio_poll_read(Vio *vio,uint timeout); -void vio_timeout(Vio *vio,uint timeout); +void vio_timeout(Vio *vio, uint which, uint timeout); #ifdef HAVE_OPENSSL #include @@ -140,7 +140,7 @@ Vio *new_VioSSL(struct st_VioSSLAcceptorFd *fd, Vio *sd, int state); #define vio_close(vio) ((vio)->vioclose)(vio) #define vio_peer_addr(vio, buf, prt) (vio)->peer_addr(vio, buf, prt) #define vio_in_addr(vio, in) (vio)->in_addr(vio, in) -#define vio_timeout(vio, seconds) (vio)->timeout(vio, seconds) +#define vio_timeout(vio, which, seconds) (vio)->timeout(vio, which, seconds) #endif /* defined(HAVE_VIO) && !defined(DONT_MAP_VIO) */ /* This enumerator is used in parser - should be always visible */ @@ -180,7 +180,7 @@ struct st_vio my_bool (*should_retry)(Vio*); my_bool (*was_interrupted)(Vio*); int (*vioclose)(Vio*); - void (*timeout)(Vio*, unsigned int timeout); + void (*timeout)(Vio*, unsigned int which, unsigned int timeout); void *ssl_arg; #endif /* HAVE_VIO */ }; diff --git a/libmysqld/lib_vio.c b/libmysqld/lib_vio.c index 0f5f7fda550..883080e8b92 100644 --- a/libmysqld/lib_vio.c +++ b/libmysqld/lib_vio.c @@ -229,6 +229,7 @@ my_bool vio_poll_read(Vio *vio,uint timeout) void vio_timeout(Vio *vio __attribute__((unused)), + uint which __attribute__((unused)), uint timeout __attribute__((unused))) { } diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 1e66bfc3e19..af54dd6b2f0 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -436,7 +436,7 @@ net_real_write(NET *net,const char *packet,ulong len) thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff); #else alarmed=0; - vio_timeout(net->vio, net->write_timeout); + vio_timeout(net->vio, 1, net->write_timeout); #endif /* NO_ALARM */ pos=(char*) packet; end=pos+len; @@ -627,7 +627,7 @@ my_real_read(NET *net, ulong *complen) if (net_blocking) thr_alarm(&alarmed,net->read_timeout,&alarm_buff); #else - vio_timeout(net->vio, net->read_timeout); + vio_timeout(net->vio, 0, net->read_timeout); #endif /* NO_ALARM */ pos = net->buff + net->where_b; /* net->packet -4 */ diff --git a/vio/viosocket.c b/vio/viosocket.c index 7ea130c9949..2738f7743dc 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -345,12 +345,26 @@ my_bool vio_poll_read(Vio *vio,uint timeout) } -void vio_timeout(Vio *vio __attribute__((unused)), - uint timeout __attribute__((unused))) +void vio_timeout(Vio *vio, uint which, uint timeout) { +#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) + #ifdef __WIN__ - ulong wait_timeout= (ulong) timeout * 1000; - (void) setsockopt(vio->sd, SOL_SOCKET, SO_RCVTIMEO, (char*) &wait_timeout, - sizeof(wait_timeout)); -#endif /* __WIN__ */ + + /* Windows expects time in milliseconds as int. */ + int wait_timeout= (int) timeout * 1000; + +#else /* ! __WIN__ */ + + /* POSIX specifies time as struct timeval. */ + struct timeval wait_timeout; + wait_timeout.tv_sec= timeout; + wait_timeout.tv_usec= 0; + +#endif /* ! __WIN__ */ + + (void) setsockopt(vio->sd, SOL_SOCKET, which ? SO_SNDTIMEO : SO_RCVTIMEO, + (char*) &wait_timeout, sizeof(wait_timeout)); + +#endif /* defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) */ } From 0f3a12870ea59429854afb7c9db1df56cce4ac05 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Oct 2006 23:05:52 -0400 Subject: [PATCH 2/8] Back port change from 5.1 that adds the Windows database files to the source package. This is needed for WiX pacakging. --- Makefile.am | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile.am b/Makefile.am index d48f0e24966..474d268db38 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,8 +89,18 @@ bin-dist: all $(top_builddir)/scripts/make_binary_distribution @MAKE_BINARY_DISTRIBUTION_OPTIONS@ # Remove BK's "SCCS" subdirectories from source distribution +# Create initial database files for Windows installations. dist-hook: rm -rf `find $(distdir) -type d -name SCCS -print` + if echo "$(distdir)" | grep -q '^/' ; then \ + scripts/mysql_install_db --no-defaults --windows \ + --basedir=$(top_srcdir) \ + --datadir="$(distdir)/win/data"; \ + else \ + scripts/mysql_install_db --no-defaults --windows \ + --basedir=$(top_srcdir) \ + --datadir="$$(pwd)/$(distdir)/win/data"; \ + fi tags: support-files/build-tags From 2268afedea366951d1f4ac10d1aa8394fb2b5b69 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Oct 2006 18:23:53 +0500 Subject: [PATCH 3/8] BUG#21381 - Engine not notified about multi-table UPDATE IGNORE Though this is not storage engine specific problem, I was able to repeat this problem with BDB and NDB engines only. That was the reason to add a test case into ndb_update.test. As a result different bad things could happen. BDB has removed duplicate rows which is not expected. NDB returns an error. For multi table update notify storage engine about UPDATE IGNORE as it is done in single table UPDATE. mysql-test/r/ndb_update.result: A test case for bug#21381. mysql-test/t/ndb_update.test: A test case for bug#21381. sql/sql_update.cc: For multi table update notify storage engine about UPDATE IGNORE as it is done in single table UPDATE. --- mysql-test/r/ndb_update.result | 8 ++++++++ mysql-test/t/ndb_update.test | 9 +++++++++ sql/sql_update.cc | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/mysql-test/r/ndb_update.result b/mysql-test/r/ndb_update.result index c2247564e65..4848284b4af 100644 --- a/mysql-test/r/ndb_update.result +++ b/mysql-test/r/ndb_update.result @@ -31,3 +31,11 @@ pk1 b c 12 2 2 14 1 1 DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a INT NOT NULL, UNIQUE(a)) ENGINE=ndbcluster; +INSERT INTO t1 VALUES(1),(2); +UPDATE IGNORE t1, t1 AS t1a SET t1.a=3; +SELECT a FROM t1 ORDER BY a; +a +1 +3 +DROP TABLE t1; diff --git a/mysql-test/t/ndb_update.test b/mysql-test/t/ndb_update.test index 45e3add4639..e7c5fd0c4a5 100644 --- a/mysql-test/t/ndb_update.test +++ b/mysql-test/t/ndb_update.test @@ -33,4 +33,13 @@ select * from t1 order by pk1; DROP TABLE IF EXISTS t1; --enable_warnings +# +# BUG#21381 - Engine not notified about multi-table UPDATE IGNORE +# +CREATE TABLE t1(a INT NOT NULL, UNIQUE(a)) ENGINE=ndbcluster; +INSERT INTO t1 VALUES(1),(2); +UPDATE IGNORE t1, t1 AS t1a SET t1.a=3; +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; + # End of 4.1 tests diff --git a/sql/sql_update.cc b/sql/sql_update.cc index af4ba8025f9..6742fbad5c4 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -901,6 +901,8 @@ multi_update::initialize_tables(JOIN *join) List temp_fields= *fields_for_table[cnt]; ORDER group; + if (ignore) + table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); if (table == main_table) // First table in join { if (safe_update_on_fly(join->join_tab, &temp_fields)) @@ -1007,7 +1009,11 @@ multi_update::~multi_update() { TABLE_LIST *table; for (table= update_tables ; table; table= table->next) + { table->table->no_keyread= table->table->no_cache= 0; + if (ignore) + table->table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); + } if (tmp_tables) { From f463cb389be2a421b117190b863f72ddf72b354b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Oct 2006 10:54:47 +0500 Subject: [PATCH 4/8] Addition to fix for bug#10974. Fixed spelling. --- mysql-test/r/merge.result | 8 ++++---- sql/share/english/errmsg.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index ff4828144a7..a1ef7597143 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -178,9 +178,9 @@ t3 CREATE TABLE `t3` ( ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`) create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2); select * from t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist alter table t4 add column c int; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist create database mysqltest; create table mysqltest.t6 (a int not null primary key auto_increment, message char(20)); create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6); @@ -775,9 +775,9 @@ DROP TABLE t1, t2; CREATE TABLE t1(a INT) ENGINE=MEMORY; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1); SELECT * FROM t2; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist DROP TABLE t1, t2; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3); SELECT * FROM t2; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist DROP TABLE t2; diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index a8b06a07218..62c8f4f9991 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -184,7 +184,7 @@ character-set=latin1 "INSERT DELAYED can't be used with table '%-.64s' because it is locked with LOCK TABLES", "Incorrect column name '%-.100s'", "The used storage engine can't index column '%-.64s'", -"Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists", +"Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist", "Can't write, because of unique constraint, to table '%-.64s'", "BLOB/TEXT column '%-.64s' used in key specification without a key length", "All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead", From 15d2a32c0f43ea73a683eda384da52373fe8c2e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Oct 2006 11:03:14 +0500 Subject: [PATCH 5/8] Addition to fix for bug#10974. Fixed spelling. --- sql/share/errmsg.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 5ed7466b0df..2b6d2b18f88 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -3813,7 +3813,7 @@ ER_WRONG_MRG_TABLE cze "V-B¹echny tabulky v MERGE tabulce nejsou definovány stejnì" dan "Tabellerne i MERGE er ikke defineret ens" nla "Niet alle tabellen in de MERGE tabel hebben identieke gedefinities" - eng "Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists" + eng "Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist" est "Kõik tabelid MERGE tabeli määratluses ei ole identsed" fre "Toutes les tables de la table de type MERGE n'ont pas la même définition" ger "Nicht alle Tabellen in der MERGE-Tabelle sind gleich definiert" From b7d1c482130820faa714a126c4a858517c1f268c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Oct 2006 14:47:58 +0500 Subject: [PATCH 6/8] Per discussion with pekka removed non-deterministic test case for bug#21381. --- mysql-test/r/ndb_update.result | 8 -------- mysql-test/t/ndb_update.test | 9 --------- 2 files changed, 17 deletions(-) diff --git a/mysql-test/r/ndb_update.result b/mysql-test/r/ndb_update.result index 4848284b4af..c2247564e65 100644 --- a/mysql-test/r/ndb_update.result +++ b/mysql-test/r/ndb_update.result @@ -31,11 +31,3 @@ pk1 b c 12 2 2 14 1 1 DROP TABLE IF EXISTS t1; -CREATE TABLE t1(a INT NOT NULL, UNIQUE(a)) ENGINE=ndbcluster; -INSERT INTO t1 VALUES(1),(2); -UPDATE IGNORE t1, t1 AS t1a SET t1.a=3; -SELECT a FROM t1 ORDER BY a; -a -1 -3 -DROP TABLE t1; diff --git a/mysql-test/t/ndb_update.test b/mysql-test/t/ndb_update.test index e7c5fd0c4a5..45e3add4639 100644 --- a/mysql-test/t/ndb_update.test +++ b/mysql-test/t/ndb_update.test @@ -33,13 +33,4 @@ select * from t1 order by pk1; DROP TABLE IF EXISTS t1; --enable_warnings -# -# BUG#21381 - Engine not notified about multi-table UPDATE IGNORE -# -CREATE TABLE t1(a INT NOT NULL, UNIQUE(a)) ENGINE=ndbcluster; -INSERT INTO t1 VALUES(1),(2); -UPDATE IGNORE t1, t1 AS t1a SET t1.a=3; -SELECT a FROM t1 ORDER BY a; -DROP TABLE t1; - # End of 4.1 tests From 47a70282f91fed6dfae77d5d0e5ce3424cfb6c1d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Oct 2006 15:17:42 +0500 Subject: [PATCH 7/8] BUG#22937 - Valgrind failure in 'merge' test (ha_myisammrg.cc:329) This is addition to fix for bug21617. Valgrind reports an error when opening merge table that has underlying tables with less indexes than in a merge table itself. Copy at most min(file->keys, table->key_parts) elements from rec_per_key array. This fixes problems when merge table and subtables have different number of keys. sql/ha_myisammrg.cc: Copy at most min(file->keys, table->key_parts) elements from rec_per_key array. This fixes problems when merge table and subtables have different number of keys. --- sql/ha_myisammrg.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index edb3521470f..3408f7090f2 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -249,9 +249,22 @@ void ha_myisammrg::info(uint flag) if (flag & HA_STATUS_CONST) { if (table->key_parts && info.rec_per_key) + { +#ifdef HAVE_purify + /* + valgrind may be unhappy about it, because optimizer may access values + between file->keys and table->key_parts, that will be uninitialized. + It's safe though, because even if opimizer will decide to use a key + with such a number, it'll be an error later anyway. + */ + bzero((char*) table->key_info[0].rec_per_key, + sizeof(table->key_info[0].rec_per_key) * table->key_parts); +#endif memcpy((char*) table->key_info[0].rec_per_key, (char*) info.rec_per_key, - sizeof(table->key_info[0].rec_per_key)*table->key_parts); + sizeof(table->key_info[0].rec_per_key) * + min(file->keys, table->key_parts)); + } } } From 9397becc6d9c5af98ba1fd89a699b389d83a91c3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 8 Oct 2006 22:34:32 +0500 Subject: [PATCH 8/8] After merge fix. --- sql/ha_myisammrg.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 23af831cdf6..a4f23cd3cf0 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -335,7 +335,7 @@ void ha_myisammrg::info(uint flag) with such a number, it'll be an error later anyway. */ bzero((char*) table->key_info[0].rec_per_key, - sizeof(table->key_info[0].rec_per_key) * table->key_parts); + sizeof(table->key_info[0].rec_per_key) * table->s->key_parts); #endif memcpy((char*) table->key_info[0].rec_per_key, (char*) info.rec_per_key,