From 2d1a6434619e7096db66f179d606cee9684cf511 Mon Sep 17 00:00:00 2001 From: "jcole@tetra.spaceapes.com" <> Date: Fri, 13 Jul 2001 04:09:40 -0500 Subject: [PATCH 01/13] Put those back after I forgot to push. --- Docs/manual.texi | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index f258afb0ed5..49ef490e364 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -19267,7 +19267,7 @@ key that can have @code{NULL} values (In this case the packed key length will be stored in the same byte that is used to mark if a key is @code{NULL}.) @item -If you specify a @code{SELECT} after the @code{CREATE STATEMENT}, +If you specify a @code{SELECT} after the @code{CREATE} statement, @strong{MySQL} will create new fields for all elements in the @code{SELECT}. For example: @@ -19277,9 +19277,37 @@ mysql> CREATE TABLE test (a int not null auto_increment, TYPE=MyISAM SELECT b,c from test2; @end example -This will create a @code{MyISAM} table with 3 columns. Note that the -table will automatically be deleted if any errors occur while copying -data into the table. +This will create a @code{MyISAM} table with three columns, a, b, and c. +Notice that the columns from the @code{SELECT} statement are appended to +the right side of the table, not overlapped onto it. Take the following +example: + +@example +mysql> select * from foo; ++---+ +| n | ++---+ +| 1 | ++---+ + +mysql> create table bar (m int) select n from foo; +Query OK, 1 row affected (0.02 sec) +Records: 1 Duplicates: 0 Warnings: 0 + +mysql> select * from bar; ++------+---+ +| m | n | ++------+---+ +| NULL | 1 | ++------+---+ +1 row in set (0.00 sec) +@end example + +For each row in table @code{foo}, a row is inserted in @code{bar} with +the values from @code{foo} and default values for the new columns. + +If any errors occur while copying the data to the table, it will +automatically be deleted. To ensure that the update log/binary log can be used to re-create the original tables, @strong{MySQL} will not allow concurrent inserts during @@ -23119,7 +23147,8 @@ for replication of tables with fancy column names to work. @item TIMESTAMP = timestamp_value | DEFAULT Set the time for this client. This is used to get the original timestamp if -you use the update log to restore rows. +you use the update log to restore rows. @code{timestamp_value} should be a +UNIX Epoch timestamp, not a @strong{MySQL} timestamp. @item LAST_INSERT_ID = # Set the value to be returned from @code{LAST_INSERT_ID()}. This is stored in From 9f00125ab8bf87aba6beb495012985a5231a4452 Mon Sep 17 00:00:00 2001 From: "sasha@mysql.sashanet.com" <> Date: Fri, 13 Jul 2001 17:25:37 -0600 Subject: [PATCH 02/13] test case for low priority updates race bug not yet fixed --- mysql-test/r/lock.result | 2 ++ mysql-test/t/lock.test | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index 7b1be604024..eb49d03a17b 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -4,3 +4,5 @@ Table Op Msg_type Msg_text test.t1 check status OK Table Op Msg_type Msg_text test.t2 check error Table 't2' was not locked with LOCK TABLES +n +1 diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index 385713174d2..677a5a19f6b 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -53,3 +53,25 @@ lock tables t1 write; check table t2; unlock tables; drop table t1,t2; + +#test to see if select will get the lock ahead of low priority update +connect (locker,localhost,root,,); +connect (reader,localhost,root,,); +connect (writer,localhost,root,,); + +connection locker; +create table t1(n int); +insert into t1 values (1); +lock tables t1 write; +connection writer; +send update low_priority t1 set n = 4; +connection reader; +send select n from t1; +connection locker; +unlock tables; +connection writer; +reap; +connection reader; +reap; +drop table t1; + From ace20e0c4190004e82a7d9b509dc5aba3f21172e Mon Sep 17 00:00:00 2001 From: "sasha@mysql.sashanet.com" <> Date: Fri, 13 Jul 2001 17:45:14 -0600 Subject: [PATCH 03/13] updated lock test --- mysql-test/r/lock.result | 2 ++ mysql-test/t/lock.test | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index eb49d03a17b..24a40321f13 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -6,3 +6,5 @@ Table Op Msg_type Msg_text test.t2 check error Table 't2' was not locked with LOCK TABLES n 1 +n +1 diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index 677a5a19f6b..1eed6bb91e9 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -75,3 +75,19 @@ connection reader; reap; drop table t1; +connection locker; +create table t1(n int); +insert into t1 values (1); +lock tables t1 read; +connection writer; +send update low_priority t1 set n = 4; +connection reader; +send select n from t1; +connection locker; +unlock tables; +connection writer; +reap; +connection reader; +reap; +drop table t1; + From 0947ebb1d7fbe4d0c386a788bcaf4a4349c3525b Mon Sep 17 00:00:00 2001 From: "serg@serg.mysql.com" <> Date: Sun, 15 Jul 2001 13:16:01 +0200 Subject: [PATCH 04/13] second INSERT ... SELECT removed --- Docs/manual.texi | 2 -- 1 file changed, 2 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 49ef490e364..aa7ec775755 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -20512,8 +20512,6 @@ or INSERT [LOW_PRIORITY | DELAYED] [IGNORE] or INSERT [LOW_PRIORITY | DELAYED] [IGNORE] [INTO] tbl_name SET col_name=expression, col_name=expression, ... -or INSERT [LOW_PRIORITY] [IGNORE] [INTO] tbl_name - SELECT ... @end example From bf9876a195414ab8a5e2e1a56c5b041d807d926b Mon Sep 17 00:00:00 2001 From: "monty@tik.mysql.fi" <> Date: Mon, 16 Jul 2001 03:04:30 +0300 Subject: [PATCH 05/13] Patch for netBSD Added warning for tables where the auto_increment key is 0 Fixed DELETE ... LIMIT 0 Fixed UPDATE ..LIMIT 0 --- Docs/manual.texi | 55 ++++++++++++++++++---- configure.in | 14 ++++-- mit-pthreads/gen/ctime.c | 2 +- mit-pthreads/machdep/netbsd-1.1/__signal.h | 7 +++ mit-pthreads/stdio/strerror.c | 7 ++- myisam/mi_check.c | 16 ++++++- myisam/myisamchk.c | 2 +- mysql-test/r/auto_increment.result | 5 ++ mysql-test/r/limit.result | 3 ++ mysql-test/t/auto_increment.test | 11 +++++ mysql-test/t/limit.test | 11 +++++ sql/Makefile.am | 2 +- sql/ha_gemini.cc | 5 +- sql/ha_gemini.h | 2 +- sql/sql_delete.cc | 7 +-- sql/sql_update.cc | 3 +- 16 files changed, 128 insertions(+), 24 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 247f453bef7..2e74f89d80f 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -19861,6 +19861,28 @@ still get strange errors from a table when @strong{MySQL} tries to update a row or find a row by key (this is VERY unlikely to happen if a normal check has succeeded!). +Some things reported by check table, can't be corrected automaticly: + +@itemize @bullet +@item +@code{Found row where the auto_increment column has the value 0}. + +This means that you have in the table a row where the +@code{auto_increment} index column contains the value 0. +(It's possible to create a row where the auto_increment column is 0 by +explicitely setting the column to 0 with an @code{UPDATE} statement) + +This isn't an error in itself, but could cause trouble if you decide to +dump the table and restore it or do an @code{ALTER TABLE} on the +table. In this case the auto_increment column will change value, +according to the rules of auto_increment columns, which could cause +problems like a duplicate key error. + +To get rid of the warning, just execute an @code{UPDATE} statement +to set the column to some other value than 0. +@end itemize + + @findex BACKUP TABLE @node BACKUP TABLE, RESTORE TABLE, CHECK TABLE, Reference @section @code{BACKUP TABLE} Syntax @@ -21464,7 +21486,8 @@ If you have specified the update log file or a binary log file without an extension, the extension number of the log file will be incremented by one relative to the previous file. If you have used an extension in the file name, @strong{MySQL} will close and reopen the update log file. -@xref{Update log}. +@xref{Update log}. This is the same thing as sending the @code{SIGHUP} +signal to the @code{mysqld} server. @item @code{PRIVILEGES} @tab Reloads the privileges from the grant tables in the @code{mysql} database. @@ -21475,13 +21498,16 @@ the @code{mysql} database. @item @code{TABLES WITH READ LOCK} @tab Closes all open tables and locks all tables for all databases with a read until one executes @code{UNLOCK TABLES}. This is very convenient way to get backups if you have a file system, like Veritas,that can take snapshots in time. -@item @code{STATUS} @tab Resets most status variables to zero. +@item @code{STATUS} @tab Resets most status variables to zero. This is something one should only use when debugging a query. @end multitable You can also access each of the commands shown above with the @code{mysqladmin} utility, using the @code{flush-hosts}, @code{flush-logs}, @code{reload}, or @code{flush-tables} commands. +Take also a look at the @code{RESET} command used with +replication. @xref{Replication SQL}. + @cindex @code{mysqladmin} @findex KILL @node KILL, SHOW, FLUSH, Reference @@ -30117,14 +30143,14 @@ The following table has the options you can use for the @strong{MASTER}: @item @strong{Option} @tab @strong{Description} @item @code{log-bin=filename} @tab Write to a binary update log to the specified location. Note that if you -give it a parameter with an extension -(for example, @code{log-bin=/mysql/logs/replication.log} ) versions up to 3.23.24 -will not work right during replication if you do @code{FLUSH LOGS} . The -problem is fixed in Version 3.23.25. If you are using this kind of log name, -@code{FLUSH LOGS} will be ignored on binlog. To clear the log, run +give it a parameter with an extension (for example, +@code{log-bin=/mysql/logs/replication.log} ) versions up to 3.23.24 will +not work right during replication if you do @code{FLUSH LOGS} . The +problem is fixed in Version 3.23.25. If you are using this kind of log +name, @code{FLUSH LOGS} will be ignored on binlog. To clear the log, run @code{FLUSH MASTER}, and do not forget to run @code{FLUSH SLAVE} on all -slaves. In Version 3.23.26 and in later versions you should use @code{RESET MASTER} -and @code{RESET SLAVE} +slaves. In Version 3.23.26 and in later versions you should use +@code{RESET MASTER} and @code{RESET SLAVE} @item @code{log-bin-index=filename} @tab Because the user could issue the @code{FLUSH LOGS} command, we need to @@ -46558,6 +46584,14 @@ not yet 100% confident in this code. @appendixsubsec Changes in release 3.23.40 @itemize @bullet @item +Fixed that @code{DELETE FROM table_name ... LIMIT 0} and +@code{UPDATE FROM table_name ... LIMIT 0} doesn't delete/update anything. +@item +@code{CHECK TABLE} now checks if an auto_increment column contains the value 0. +@item +Sending a @code{SIGHUP} to @code{mysqld} will now only flush the logs, +not reset the replication. +@item Fixed parser to allow floats of type @code{1.0e1} (no sign after @code{e}). @item Option @code{--force} to @code{myisamchk} now also updates states. @@ -51998,6 +52032,9 @@ efficiently, we need to add an API to allow binding of variables. Make it possible to specify @code{long_query_time} with a granularity in microseconds. @item +Add a configurable prompt to the @code{mysql} command line client, with +options like database in use, time and date... +@item Add range checking to @code{MERGE} tables. @item Link the @code{myisampack} code into the server. diff --git a/configure.in b/configure.in index 37bc22ff63e..d3428b6f702 100644 --- a/configure.in +++ b/configure.in @@ -629,7 +629,10 @@ struct request_info *req; AC_MSG_RESULT(yes) AC_DEFINE(LIBWRAP) AC_DEFINE(HAVE_LIBWRAP) - WRAPLIBS="-L$with_libwrap/lib -lwrap", + if test "$with_libwrap" != "yes"; then + WRAPLIBS="-L${with_libwrap}/lib" + fi + WRAPLIBS="${WRAPLIBS} -lwrap", AC_MSG_RESULT(no) CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}), CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}) @@ -798,6 +801,11 @@ case $SYSTEM_TYPE in echo "Adding fix for interrupted reads" CXXFLAGS="$CXXFLAGS -DMYSQLD_NET_RETRY_COUNT=1000000" ;; + *netbsd*) + echo "Adding flag -Dunix" + CFLAGS="$CFLAGS -Dunix" + CXXFLAGS="$CXXFLAGS -Dunix" + ;; *bsdi*) echo "Adding fix for BSDI" CFLAGS="$CFLAGS -D__BSD__ -DHAVE_BROKEN_REALPATH" @@ -2043,15 +2051,15 @@ EOF AC_DEFINE(HAVE_mit_thread) MT_INCLUDES="-I\$(top_srcdir)/mit-pthreads/include" AC_SUBST(MT_INCLUDES) - MT_LD_ADD="-L \$(top_srcdir)/mit-pthreads/obj/ -lpthread" + MT_LD_ADD="\$(top_srcdir)/mit-pthreads/obj/libpthread.a" AC_SUBST(MT_LD_ADD) - LIBS="$MT_LD_ADD $LIBS" echo "" echo "Configuring MIT Pthreads" # We will never install so installation paths are not needed. (cd mit-pthreads; sh ./configure) echo "End of MIT Pthreads configuration" echo "" + LIBS="$MT_LD_ADD $LIBS" fi fi AC_SUBST(sql_server_dirs) diff --git a/mit-pthreads/gen/ctime.c b/mit-pthreads/gen/ctime.c index 0c1e711cf13..9b38d41e495 100644 --- a/mit-pthreads/gen/ctime.c +++ b/mit-pthreads/gen/ctime.c @@ -177,7 +177,7 @@ time_t altzone = 0; static int detzcode(const char * codep) { - long result; + int result; int i; result = 0; diff --git a/mit-pthreads/machdep/netbsd-1.1/__signal.h b/mit-pthreads/machdep/netbsd-1.1/__signal.h index e41e9218261..ea2979f2b4e 100755 --- a/mit-pthreads/machdep/netbsd-1.1/__signal.h +++ b/mit-pthreads/machdep/netbsd-1.1/__signal.h @@ -1,5 +1,7 @@ #include +__BEGIN_DECLS + #if NSIG <= 32 #define __SIGEMPTYSET 0 #define __SIGFILLSET 0xffffffff @@ -8,6 +10,9 @@ #define __SIGISMEMBER(s, n) ((*(s) & (1 << ((n) - 1))) != 0) #else /* XXX Netbsd >= 1.3H */ + +int sigaction __P_((int, const struct sigaction *, struct sigaction *)) __RENAME(__sigaction14); + #define __SIGEMPTYSET { 0, 0, 0, 0} #define __SIGFILLSET { 0xffffffff, 0xffffffff, \ 0xffffffff, 0xffffffff } @@ -18,3 +23,5 @@ #define __SIGISMEMBER(s, n) (((s)->__bits[__SIGWORD(n)] & __SIGMASK(n)) != 0) #endif + +__END_DECLS diff --git a/mit-pthreads/stdio/strerror.c b/mit-pthreads/stdio/strerror.c index 5aea7e7a4fc..d35235e63b0 100644 --- a/mit-pthreads/stdio/strerror.c +++ b/mit-pthreads/stdio/strerror.c @@ -36,13 +36,18 @@ static char sccsid[] = "@(#)strerror.c 5.6 (Berkeley) 5/4/91"; #endif /* LIBC_SCCS and not lint */ #include +#if defined(__NetBSD__) +#include +#endif char * strerror(num) int num; { +#if !defined(__NetBSD__) extern int sys_nerr; extern char *sys_errlist[]; +#endif #define UPREFIX "Unknown error: " static char ebuf[40] = UPREFIX; /* 64-bit number + slop */ register unsigned int errnum; @@ -51,7 +56,7 @@ strerror(num) errnum = num; /* convert to unsigned */ if (errnum < sys_nerr) - return(sys_errlist[errnum]); + return((char *)sys_errlist[errnum]); /* Do this by hand, so we don't include stdio(3). */ t = tmp; diff --git a/myisam/mi_check.c b/myisam/mi_check.c index c6e07445bcf..0caedbe1a51 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -432,9 +432,9 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) } else full_text_keys++; - /* Check that auto_increment key is bigger than max key value */ if ((uint) share->base.auto_key -1 == key) { + /* Check that auto_increment key is bigger than max key value */ ulonglong save_auto_value=info->s->state.auto_increment; info->s->state.auto_increment=0; info->lastinx=key; @@ -454,6 +454,20 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) } else info->s->state.auto_increment=save_auto_value; + + /* Check that there isn't a row with auto_increment = 0 in the table */ + mi_extra(info,HA_EXTRA_KEYREAD); + bzero(info->lastkey,keyinfo->seg->length); + if (!mi_rkey(info, info->rec_buff, key, info->lastkey, + keyinfo->seg->length, HA_READ_KEY_EXACT)) + { + /* Don't count this as a real warning, as myisamchk can't correct it */ + uint save=param->warning_printed; + mi_check_print_warning(param, + "Found row where the auto_increment column has the value 0"); + param->warning_printed=save; + } + mi_extra(info,HA_EXTRA_NO_KEYREAD); } length=(my_off_t) isam_key_length(info,keyinfo)*keys + param->key_blocks*2; diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index dd23e214ccf..61ad939d6ed 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -201,7 +201,7 @@ static struct option long_options[] = static void print_version(void) { - printf("%s Ver 1.47 for %s at %s\n",my_progname,SYSTEM_TYPE, + printf("%s Ver 1.48 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE); } diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index 9ff02d7a7b8..bf6265e5b64 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -55,3 +55,8 @@ ordid ord 2 sdj 3 sdj 1 zzz +a +0 +Table Op Msg_type Msg_text +test.t1 check warning Found row where the auto_increment column has the value 0 +test.t1 check status OK diff --git a/mysql-test/r/limit.result b/mysql-test/r/limit.result index 0f5586e3b31..6c3a1ed17e4 100644 --- a/mysql-test/r/limit.result +++ b/mysql-test/r/limit.result @@ -20,3 +20,6 @@ a b a b 2 2 3 4 +i +2 +1 diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index 1741b51b2d6..b9b8c244699 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -64,3 +64,14 @@ create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null insert into t1 values (NULL,'sdj'),(NULL,'sdj'),(NULL,"abc"),(NULL,'abc'),(NULL,'zzz'),(NULL,'sdj'),(NULL,'abc'); select * from t1; drop table t1; + +# +# Test of auto_increment columns when they are set to 0 +# + +create table t1 (a int not null primary key auto_increment); +insert into t1 values (0); +update t1 set a=0; +select * from t1; +check table t1; +drop table t1; diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test index ba075f73d37..112761abd87 100644 --- a/mysql-test/t/limit.test +++ b/mysql-test/t/limit.test @@ -17,3 +17,14 @@ select * from t1; delete from t1 limit 1; select * from t1; drop table t1; + +create table t1 (i int); +insert into t1 (i) values(1); +insert into t1 (i) values(1); +insert into t1 (i) values(1); +delete from t1 limit 1; +update t1 set i=2 limit 1; +delete from t1 limit 0; +update t1 set i=3 limit 0; +select * from t1; +drop table t1; diff --git a/sql/Makefile.am b/sql/Makefile.am index 774ef06f17c..28484f09b3d 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -85,7 +85,7 @@ gen_lex_hash_SOURCES = gen_lex_hash.cc gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS) mysqlbinlog_SOURCES = mysqlbinlog.cc mini_client.cc net_serv.cc \ mini_client_errors.c violite.c password.c -mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) $(mysqld_LDADD) +mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) # $(mysqld_LDADD) DEFS = -DMYSQL_SERVER \ -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \ diff --git a/sql/ha_gemini.cc b/sql/ha_gemini.cc index c95a348f238..e80d9a001e6 100644 --- a/sql/ha_gemini.cc +++ b/sql/ha_gemini.cc @@ -1,5 +1,5 @@ -/* Copyright (C) 2000 NuSphere Corporation - +/* Copyright (C) 2000 MySQL AB & NuSphere Corporation + 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 @@ -14,6 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* This file is based on ha_berkeley.cc */ #ifdef __GNUC__ #pragma implementation // gcc: Class implementation diff --git a/sql/ha_gemini.h b/sql/ha_gemini.h index 495dc2fd1c9..3bfe85bfba2 100644 --- a/sql/ha_gemini.h +++ b/sql/ha_gemini.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 NuSphere Corporation +/* Copyright (C) 2000 MySQL AB & NuSphere Corporation 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 diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 587b205886e..8b4b1b527ca 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -170,12 +170,13 @@ int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit, select=make_select(table,0,0,conds,&error); if (error) DBUG_RETURN(-1); - if (select && select->check_quick(test(thd->options & SQL_SAFE_UPDATES), - limit)) + if ((select && select->check_quick(test(thd->options & SQL_SAFE_UPDATES), + limit)) || + !limit) { delete select; send_ok(&thd->net,0L); - DBUG_RETURN(0); + DBUG_RETURN(0); // Nothing to delete } /* If running in safe sql mode, don't allow updates without keys */ diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 87a2f5c7b2b..c41586c58c8 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -110,7 +110,8 @@ int mysql_update(THD *thd,TABLE_LIST *table_list,List &fields, select=make_select(table,0,0,conds,&error); if (error || (select && select->check_quick(test(thd->options & SQL_SAFE_UPDATES), - limit))) + limit)) || + !limit) { delete select; table->time_stamp=save_time_stamp; // Restore timestamp pointer From ecefc69c5024147811ae5c0c08cf8a9d502e7ea8 Mon Sep 17 00:00:00 2001 From: "monty@tik.mysql.fi" <> Date: Mon, 16 Jul 2001 13:27:29 +0300 Subject: [PATCH 06/13] Made replication test portable accross table handlers --- mysql-test/r/rpl_sporadic_master.result | 12 ++++++------ mysql-test/t/rpl_sporadic_master.test | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/rpl_sporadic_master.result b/mysql-test/r/rpl_sporadic_master.result index 414468f0998..ed616c26b67 100644 --- a/mysql-test/r/rpl_sporadic_master.result +++ b/mysql-test/r/rpl_sporadic_master.result @@ -1,7 +1,7 @@ n -1 -2 -3 -4 -5 -6 +10 +11 +12 +13 +14 +15 diff --git a/mysql-test/t/rpl_sporadic_master.test b/mysql-test/t/rpl_sporadic_master.test index ce6568f659e..a3217f9dd55 100644 --- a/mysql-test/t/rpl_sporadic_master.test +++ b/mysql-test/t/rpl_sporadic_master.test @@ -1,16 +1,18 @@ -#test to see if replication can continue when master sporadically fails on +# test to see if replication can continue when master sporadically fails on # COM_BINLOG_DUMP and additionally limits the number of events per dump + source include/master-slave.inc; connection master; drop table if exists t1; create table t1(n int not null auto_increment primary key); insert into t1 values (NULL),(NULL); delete from t1; -insert into t1 values (NULL),(NULL); +# We have to use 4 in the following to make this test work with all table types +insert into t1 values (4),(NULL); insert into t1 values (NULL),(NULL); flush logs; delete from t1; -insert into t1 values (NULL),(NULL); +insert into t1 values (10),(NULL); insert into t1 values (NULL),(NULL); insert into t1 values (NULL),(NULL); save_master_pos; From 83d5333ffb270f9d935e2f04f83e24b7ed846766 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Mon, 16 Jul 2001 13:27:30 +0300 Subject: [PATCH 07/13] Fix that libmysqlclient_r can be compiled with mit-pthreads on Linux --- configure.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index d3428b6f702..97452c52719 100644 --- a/configure.in +++ b/configure.in @@ -805,6 +805,7 @@ case $SYSTEM_TYPE in echo "Adding flag -Dunix" CFLAGS="$CFLAGS -Dunix" CXXFLAGS="$CXXFLAGS -Dunix" + OVERRIDE_MT_LD_ADD="\$(top_srcdir)/mit-pthreads/obj/libpthread.a" ;; *bsdi*) echo "Adding fix for BSDI" @@ -2051,7 +2052,12 @@ EOF AC_DEFINE(HAVE_mit_thread) MT_INCLUDES="-I\$(top_srcdir)/mit-pthreads/include" AC_SUBST(MT_INCLUDES) - MT_LD_ADD="\$(top_srcdir)/mit-pthreads/obj/libpthread.a" + if test -n "$OVERRIDE_MT_LD_ADD" + then + MT_LD_ADD="$OVERRIDE_MT_LD_ADD" + else + MT_LD_ADD="-L \$(top_srcdir)/mit-pthreads/obj/ -lpthread.a" + fi AC_SUBST(MT_LD_ADD) echo "" echo "Configuring MIT Pthreads" From 02f72a801b2f29d5c604da72bfcf53c61706ce6f Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Mon, 16 Jul 2001 14:32:11 +0300 Subject: [PATCH 08/13] Changed GPL license example to make it more clear --- Docs/manual.texi | 13 ++++++++----- configure.in | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 45ace36a255..48e5597489e 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -3574,11 +3574,14 @@ A license is required if: @itemize @minus @item -You link a part of the of @strong{MySQL} that has a GPL Copyright to a -program that is not free software (embedded usage of the @strong{MySQL} -server). In this case your application would also become GPL through the -clause in the GPL license that acts as a virus. By licensing @strong{MySQL} -from us under a commercial license you will avoid this problem. +You link a program, that is not free software, with code from the +@strong{MySQL} server or clients that has the GPL copyright. This +happens for example when you use @strong{MySQL} as an embedded server +in your applications or when you add not free extensions to the +@strong{MySQL} server. In this case your application/code would also +become GPL through the GPL license that acts as a virus. By licensing +@strong{MySQL} server from @strong{MySQL AB} under a commercial +license you will avoid this problem. @item You have a commercial application that ONLY works with @strong{MySQL} diff --git a/configure.in b/configure.in index 97452c52719..20c419c7328 100644 --- a/configure.in +++ b/configure.in @@ -2056,7 +2056,7 @@ EOF then MT_LD_ADD="$OVERRIDE_MT_LD_ADD" else - MT_LD_ADD="-L \$(top_srcdir)/mit-pthreads/obj/ -lpthread.a" + MT_LD_ADD="-L \$(top_srcdir)/mit-pthreads/obj/ -lpthread" fi AC_SUBST(MT_LD_ADD) echo "" From 03c23571e8fbfb317957639e51b6529711c9699a Mon Sep 17 00:00:00 2001 From: "jcole@tetra.spaceapes.com" <> Date: Mon, 16 Jul 2001 10:16:18 -0500 Subject: [PATCH 09/13] Updated link to mod_auth_mysql. --- Docs/manual.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 49ef490e364..8fae8c3fad6 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -2733,8 +2733,8 @@ entity relationship diagram (ERD). @subheading Web Servers with @strong{MySQL} Tools @table @asis -@item @uref{http://bourbon.netvision.net.il/mysql/mod_auth_mysql/} -An Apache authentication module. +@item @uref{ftp://ftp.kcilink.com/pub/} +mod_auth_mysql, An Apache authentication module. @item @uref{http://www.roxen.com/} The Roxen Challenger Web server. From c9014d88a30e63925c59a31a230f201f527b8e7a Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Mon, 16 Jul 2001 21:10:29 +0300 Subject: [PATCH 10/13] ha_innobase.cc Fix a bug in showing of Auto_increment in SHOW TABLE STATUS ha_innobase.h Fix a bug in showing of Auto_increment in SHOW TABLE STATUS --- sql/ha_innobase.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ sql/ha_innobase.h | 1 + 2 files changed, 46 insertions(+) diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 184c97837db..bab5dc582e7 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -2885,4 +2885,49 @@ ha_innobase::store_lock( return(to); } +/*********************************************************************** +Returns the next auto-increment column value for the table. write_row +normally fetches the value from the cache in the data dictionary. This +function in used by SHOW TABLE STATUS and when the first insert to the table +is done after database startup. */ + +longlong +ha_innobase::get_auto_increment() +/*=============================*/ + /* out: the next auto-increment column value */ +{ + row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; + longlong nr; + int error; + + (void) extra(HA_EXTRA_KEYREAD); + index_init(table->next_number_index); + + /* We use an exclusive lock when we read the max key value from the + auto-increment column index. This is because then build_template will + advise InnoDB to fetch all columns. In SHOW TABLE STATUS the query + id of the auto-increment column is not changed, and previously InnoDB + did not fetch it, causing SHOW TABLE STATUS to show wrong values + for the autoinc column. */ + + prebuilt->select_lock_type = LOCK_X; + prebuilt->trx->mysql_n_tables_locked += 1; + + error=index_last(table->record[1]); + + if (error) { + nr = 1; + } else { + nr = (longlong) table->next_number_field-> + val_int_offset(table->rec_buff_length) + 1; + } + + (void) extra(HA_EXTRA_NO_KEYREAD); + + index_end(); + + return(nr); +} + + #endif /* HAVE_INNOBASE_DB */ diff --git a/sql/ha_innobase.h b/sql/ha_innobase.h index d832ac93d0f..4dbff654337 100644 --- a/sql/ha_innobase.h +++ b/sql/ha_innobase.h @@ -147,6 +147,7 @@ class ha_innobase: public handler THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); + longlong get_auto_increment(); }; extern bool innodb_skip; From aecef7614e1c6d131417f2b21d2cddc9199c3ab2 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Tue, 17 Jul 2001 21:04:01 +0300 Subject: [PATCH 11/13] Removed wrong warning from thr_lock Fixed problem with UPDATE and BDB tables Fixed problem with GRANT FILE privilege on database level mysqld --warnings works now Fixed problem with SHOW OPEN TABLES when not using BDB Added some tests for ALTER TABLE to the test scripts --- Docs/manual.texi | 25 +++++++++++----- configure.in | 2 +- mysys/thr_lock.c | 36 +++++++++++++---------- sql/ha_berkeley.cc | 4 ++- sql/sql_acl.cc | 7 ++--- sql/sql_parse.cc | 2 +- sql/sql_show.cc | 2 +- tests/fork2_test.pl | 35 ++++++++++++++++++++-- tests/fork_big.pl | 72 ++++++++++++++++++++++++++++++++++++++++++--- 9 files changed, 148 insertions(+), 37 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 48e5597489e..6e2d730459f 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -3582,7 +3582,7 @@ in your applications or when you add not free extensions to the become GPL through the GPL license that acts as a virus. By licensing @strong{MySQL} server from @strong{MySQL AB} under a commercial license you will avoid this problem. - +See @uref{http://www.gnu.org/copyleft/gpl-faq.html}. @item You have a commercial application that ONLY works with @strong{MySQL} and ships the application with the @strong{MySQL} server. This is @@ -45717,6 +45717,11 @@ not yet 100% confident in this code. @appendixsubsec Changes in release 3.23.40 @itemize @bullet @item +Fixed problem with @code{UPDATE} and BDB tables. +@item +Fixed problem when using the @code{GRANT FILE ON database.* ...}; Previously +we added the @code{DROP} privilege for the database. +@item Fixed that @code{DELETE FROM table_name ... LIMIT 0} and @code{UPDATE FROM table_name ... LIMIT 0} doesn't delete/update anything. @item @@ -45747,8 +45752,8 @@ Fixed bug in @code{BDB} tables when querying empty tables. Fixed a bug when using @code{COUNT(DISTINCT)} with @code{LEFT JOIN} and there wasn't any matching rows. @item -Removed all documentation referring to the @code{GEMINI} table type. @code{GEMINI} -is not released under an Open Source license. +Removed all documentation referring to the @code{GEMINI} table +type. @code{GEMINI} is not released under an Open Source license. @end itemize @node News-3.23.39, News-3.23.38, News-3.23.40, News-3.23.x @@ -50795,16 +50800,20 @@ Don't execute @code{ALTER TABLE} on a @code{BDB} table on which you are running not completed multi-statement transactions. (The transaction will probably be ignored). +@item +@code{ANALYZE TABLE}, @code{OPTIMIZE TABLE} and @code{REPAIR TABLE} may +cause problems on tables for which you are using @code{INSERT DELAYED}. + @item Doing a @code{LOCK TABLE ..} and @code{FLUSH TABLES ..} doesn't guarantee that there isn't a half-finished transaction in progress on the table. @item -BDB tables are a bit slow to open from this. If you have many BDB tables -in a database, it will take a long time to use the @code{mysql} client -on the database if you are not using the @code{-A} option or if you are -using @code{rehash}. This is especially notable when you have a big table +BDB tables are a bit slow to open. If you have many BDB tables in a +database, it will take a long time to use the @code{mysql} client on the +database if you are not using the @code{-A} option or if you are using +@code{rehash}. This is especially notable when you have a big table cache. @item @@ -50959,6 +50968,8 @@ values in double. Using these will cause problems when trying to export and import data. We should as an intermediate solution change @code{NaN} to @code{NULL} (if possible) and @code{-Inf} and @code{Inf} to the Minimum respective maximum possible @code{double} value. +@item +@code{LIMIT} on negative numbers are treated as big positive numbers. @end itemize The following are known bugs in earlier versions of @strong{MySQL}: diff --git a/configure.in b/configure.in index 20c419c7328..aa84f152095 100644 --- a/configure.in +++ b/configure.in @@ -2011,7 +2011,7 @@ and GNU make work together causes some files to depend on this header, even if we're not building with Berkeley DB. Obviously, if this file *is* used, it'll break and hopefully we can find -out why this file was generated by $(top_srcdir)/configure instead of +out why this file was generated by ${top_srcdir}/configure instead of the real db.h. If you run into some problems because of this file, please use mysql_bug diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 7c92a7fa5fa..cff4d3bbac8 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -110,7 +110,8 @@ my_bool init_thr_lock() } #ifdef EXTRA_DEBUG -static int found_errors=0; +#define MAX_FOUND_ERRORS 10 /* Report 10 first errors */ +static uint found_errors=0; static int check_lock(struct st_lock_list *list, const char* lock_type, const char *where, my_bool same_thread) @@ -167,15 +168,16 @@ static int check_lock(struct st_lock_list *list, const char* lock_type, static void check_locks(THR_LOCK *lock, const char *where, my_bool allow_no_locks) { - if (!found_errors) + uint old_found_errors=found_errors; + if (found_errors < MAX_FOUND_ERRORS) { if (check_lock(&lock->write,"write",where,1) | check_lock(&lock->write_wait,"write_wait",where,0) | check_lock(&lock->read,"read",where,0) | check_lock(&lock->read_wait,"read_wait",where,0)) - found_errors=1; + found_errors++; - if (!found_errors) + if (found_errors < MAX_FOUND_ERRORS) { uint count=0; THR_LOCK_DATA *data; @@ -186,7 +188,7 @@ static void check_locks(THR_LOCK *lock, const char *where, } if (count != lock->read_no_write_count) { - found_errors=1; + found_errors++; fprintf(stderr, "Warning at '%s': Locks read_no_write_count was %u when it should have been %u\n", where, lock->read_no_write_count,count); } @@ -196,7 +198,7 @@ static void check_locks(THR_LOCK *lock, const char *where, if (!allow_no_locks && !lock->read.data && (lock->write_wait.data || lock->read_wait.data)) { - found_errors=1; + found_errors++; fprintf(stderr, "Warning at '%s': No locks in use but locks are in wait queue\n", where); @@ -205,7 +207,7 @@ static void check_locks(THR_LOCK *lock, const char *where, { if (!allow_no_locks && lock->read_wait.data) { - found_errors=1; + found_errors++; fprintf(stderr, "Warning at '%s': No write locks and waiting read locks\n", where); @@ -221,7 +223,7 @@ static void check_locks(THR_LOCK *lock, const char *where, (lock->write_wait.data->type == TL_WRITE_DELAYED && !lock->read.data))) { - found_errors=1; + found_errors++; fprintf(stderr, "Warning at '%s': Write lock %d waiting while no exclusive read locks\n",where,(int) lock->write_wait.data->type); } @@ -235,7 +237,7 @@ static void check_locks(THR_LOCK *lock, const char *where, lock->write.data->type == TL_WRITE_ALLOW_WRITE && lock->write_wait.data->type == TL_WRITE_ALLOW_WRITE) { - found_errors=1; + found_errors++; fprintf(stderr, "Warning at '%s': Found WRITE_ALLOW_WRITE lock waiting for WRITE_ALLOW_WRITE lock\n", where); @@ -243,16 +245,18 @@ static void check_locks(THR_LOCK *lock, const char *where, } if (lock->read.data) { - if ((!pthread_equal(lock->write.data->thread,lock->read.data->thread) && - lock->write.data->type > TL_WRITE_DELAYED) || + if ((!pthread_equal(lock->write.data->thread, + lock->read.data->thread) && + lock->write.data->type > TL_WRITE_DELAYED && + lock->write.data->type != TL_WRITE_ONLY) || ((lock->write.data->type == TL_WRITE_CONCURRENT_INSERT || lock->write.data->type == TL_WRITE_ALLOW_WRITE) && lock->read_no_write_count)) { - found_errors=1; + found_errors++; fprintf(stderr, - "Warning at '%s': Found lock that is write and read locked\n", - where); + "Warning at '%s': Found lock of type %d that is write and read locked\n", + where, lock->write.data->type); } } if (lock->read_wait.data) @@ -260,7 +264,7 @@ static void check_locks(THR_LOCK *lock, const char *where, if (!allow_no_locks && lock->write.data->type <= TL_WRITE_DELAYED && lock->read_wait.data->type <= TL_READ_HIGH_PRIORITY) { - found_errors=1; + found_errors++; fprintf(stderr, "Warning at '%s': Found read lock of type %d waiting for write lock of type %d\n", where, @@ -270,7 +274,7 @@ static void check_locks(THR_LOCK *lock, const char *where, } } } - if (found_errors) + if (found_errors != old_found_errors) { DBUG_PRINT("error",("Found wrong lock")); } diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 32af39e4a0d..d2b3ef62865 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -453,9 +453,11 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) if ((primary_key=table->primary_key) >= MAX_KEY) { // No primary key primary_key=table->keys; + key_used_on_scan=MAX_KEY; ref_length=hidden_primary_key=BDB_HIDDEN_PRIMARY_KEY_LENGTH; } - key_used_on_scan=primary_key; + else + key_used_on_scan=primary_key; /* Need some extra memory in case of packed keys */ uint max_key_length= table->max_key_length + MAX_REF_PARTS*3; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 0f3ee483400..0cca3df0b16 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1824,10 +1824,9 @@ int mysql_grant (THD *thd, const char *db, List &list, uint rights, *Str, (!db ? rights : 0), what))) result= -1; - if (db) - if (( replace_db_table(tables[1].table, db, *Str, rights, - what))) - result= -1; + if (db && replace_db_table(tables[1].table, db, *Str, rights & DB_ACLS, + what)) + result= -1; } VOID(pthread_mutex_unlock(&acl_cache->lock)); pthread_mutex_unlock(&LOCK_grant); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ef2919c2e6c..87fbed47ef1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -554,7 +554,7 @@ pthread_handler_decl(handle_one_connection,arg) free_root(&thd->mem_root,MYF(0)); if (net->error && net->vio != 0) { - if (!thd->killed && ! opt_warnings) + if (!thd->killed && opt_warnings) sql_print_error(ER(ER_NEW_ABORTING_CONNECTION), thd->thread_id,(thd->db ? thd->db : "unconnected"), thd->user ? thd->user : "unauthenticated", diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 84dc5931139..637ab4fe7e9 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -599,7 +599,7 @@ mysqld_show_logs(THD *thd) DBUG_RETURN(1); #ifdef HAVE_BERKELEY_DB - if (berkeley_show_logs(thd)) + if (!berkeley_skip && berkeley_show_logs(thd)) DBUG_RETURN(-1); #endif diff --git a/tests/fork2_test.pl b/tests/fork2_test.pl index e8a579d9d81..b5564e99c3f 100755 --- a/tests/fork2_test.pl +++ b/tests/fork2_test.pl @@ -6,6 +6,9 @@ # the last 3 does different selects on the tables. # Er, hmmm..., something like that :^) # Modified to do crazy-join, à la Nasdaq. +# +# This test uses the old obsolete mysql interface. For a test that uses +# DBI, please take a look at fork_big.pl $opt_loop_count=10000; # Change this to make test harder/easier @@ -26,8 +29,8 @@ GetOptions("host=s","db=s","loop-count=i","skip-create","skip-in", "force") || die "Aborted"; $opt_verbose=$opt_debug=$opt_lock_tables=$opt_fast_insert=$opt_fast=$opt_skip_in=$Mysql::db_errstr=$opt_force=undef; # Ignore warnings from these -print "Testing 9 multiple connections to a server with 1 insert/update\n"; -print "and 8 select connections.\n"; +print "Testing 10 multiple connections to a server with 1 insert/update\n"; +print "and 8 select connections and one ALTER TABLE.\n"; @testtables = qw(bench_f21 bench_f22 bench_f23 bench_f24 bench_f25); @@ -83,6 +86,7 @@ test_2() if (($pid=fork()) == 0); $work{$pid}="simple3"; test_3() if (($pid=fork()) == 0); $work{$pid}="funny3"; test_2() if (($pid=fork()) == 0); $work{$pid}="simple4"; test_3() if (($pid=fork()) == 0); $work{$pid}="funny4"; +alter_test() if (($pid=fork()) == 0); $work{$pid}="alter"; $errors=0; while (($pid=wait()) != -1) @@ -205,6 +209,33 @@ sub test_3 exit(0); } +# +# Do an ALTER TABLE every 20 seconds +# +sub alter_test +{ + my ($dbh,$count,$old_row_count,$row_count,$id,@row,$sth); + $dbh = Mysql->Connect($opt_host, $opt_db) || die $Mysql::db_errstr; + $id=$count=$row_count=0; $old_row_count= -1; + # Execute the test as long as we get more data into the table + while ($row_count != $old_row_count) + { + sleep(10); + $sth=$dbh->Query("ALTER TABLE $testtables[$id] modify info varchar(32)") or die "Couldn't execute ALTER TABLE\n"; + $sth=0; + $id=($id+1) % $numtables; + + # Test if insert test has ended + $sth=$dbh->query("select count(*) from $testtables[0]") or die "Couldn't execute count(*)\n"; + @row = $sth->FetchRow(); + $old_row_count= $row_count; + $row_count=$row[0]; + $count++; + } + $dbh=0; + print "alter: Executed $count ALTER TABLE commands\n"; + exit(0); +} diff --git a/tests/fork_big.pl b/tests/fork_big.pl index 4009a9da71b..e082225604c 100755 --- a/tests/fork_big.pl +++ b/tests/fork_big.pl @@ -23,7 +23,7 @@ GetOptions("host=s","db=s","user=s","password=s","loop-count=i","skip-create","s $opt_verbose=$opt_debug=$opt_lock_tables=$opt_fast_insert=$opt_fast=$opt_skip_in=$opt_force=undef; # Ignore warnings from these print "Test of multiple connections that test the following things:\n"; -print "insert, select, delete, update, check, repair and flush\n"; +print "insert, select, delete, update, alter, check, repair and flush\n"; @testtables = ( ["bench_f31", ""], ["bench_f32", "row_format=fixed"], @@ -34,7 +34,8 @@ $abort_table="bench_f39"; $numtables = $#testtables+1; srand 100; # Make random numbers repeatable -#### + +#### #### Start timeing and start test #### @@ -88,12 +89,14 @@ for ($i=0 ; $i < $opt_threads ; $i ++) { test_select() if (($pid=fork()) == 0); $work{$pid}="select_key"; } +test_join() if (($pid=fork()) == 0); $work{$pid}="test_join"; test_select_count() if (($pid=fork()) == 0); $work{$pid}="select_count"; test_delete() if (($pid=fork()) == 0); $work{$pid}="delete"; test_update() if (($pid=fork()) == 0); $work{$pid}="update"; test_flush() if (($pid=fork()) == 0); $work{$pid}= "flush"; test_check() if (($pid=fork()) == 0); $work{$pid}="check"; test_repair() if (($pid=fork()) == 0); $work{$pid}="repair"; +test_alter() if (($pid=fork()) == 0); $work{$pid}="alter"; #test_database("test2") if (($pid=fork()) == 0); $work{$pid}="check_database"; print "Started " . ($opt_threads*2+4) . " threads\n"; @@ -243,6 +246,44 @@ sub test_select_count exit(0); } +# +# select records +# Do continously joins between the first and second table +# + +sub test_join +{ + my ($dbh, $i, $j, $count, $loop); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + $count_query=make_count_query($numtables); + $count=0; + $loop=9999; + + $i=0; + while (($i++ % 100) || !test_if_abort($dbh)) + { + if ($loop++ >= 100) + { + $loop=0; + $row_counts=simple_query($dbh, $count_query); + } + for ($j=0 ; $j < $numtables-1 ; $j++) + { + my ($id)= int rand $row_counts->[$j]; + my ($t1,$t2)= ($testtables[$j]->[0],$testtables[$j+1]->[0]); + simple_query($dbh, "select $t1.id,$t2.info from $t1, $t2 where $t1.id=$t2.id and $t1.id=$id"); + $count++; + } + } + $dbh->disconnect; $dbh=0; + print "Test_join: Executed $count joins\n"; + exit(0); +} + # # Delete 1-5 rows from the first 2 tables. # Test ends when the number of rows for table 3 didn't change during @@ -457,6 +498,29 @@ sub test_database exit(0); } +# +# Test ALTER TABLE on the second table +# + +sub test_alter +{ + my ($dbh, $row, $i, $type, $table); + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + for ($i=0 ; !test_if_abort($dbh) ; $i++) + { + sleep(100); + $table=$testtables[1]->[0]; + $sth=$dbh->prepare("ALTER table $table modify info char(32)") || die "Got error on prepare: $DBI::errstr\n"; + $sth->execute || die $DBI::errstr; + } + $dbh->disconnect; $dbh=0; + print "test_alter: Executed $i ALTER TABLE\n"; + exit(0); +} + # # Help functions @@ -507,8 +571,8 @@ sub simple_query() my ($dbh, $query)= @_; my ($sth,$row); - $sth=$dbh->prepare($query) || die "Got error on '$query': $DBI::errstr\n"; - $sth->execute || die "Got error on '$query': $dbh->errstr\n"; + $sth=$dbh->prepare($query) || die "Got error on '$query': " . $dbh->errstr . "\n"; + $sth->execute || die "Got error on '$query': " . $dbh->errstr . "\n"; $row= $sth->fetchrow_arrayref(); $sth=0; return $row; From e3e51204ecdeb84f3f9a8685b504ecfec30e5ff7 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Tue, 17 Jul 2001 22:59:14 +0300 Subject: [PATCH 12/13] Added timeouts to make lock test repeatable --- mysql-test/r/lock.result | 2 +- mysql-test/t/lock.test | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index 24a40321f13..ccd3c02558d 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -5,6 +5,6 @@ test.t1 check status OK Table Op Msg_type Msg_text test.t2 check error Table 't2' was not locked with LOCK TABLES n -1 +4 n 1 diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index 1eed6bb91e9..77354e63252 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -66,8 +66,10 @@ lock tables t1 write; connection writer; send update low_priority t1 set n = 4; connection reader; +--sleep 2 send select n from t1; connection locker; +--sleep 2 unlock tables; connection writer; reap; @@ -82,8 +84,10 @@ lock tables t1 read; connection writer; send update low_priority t1 set n = 4; connection reader; +--sleep 2 send select n from t1; connection locker; +--sleep 2 unlock tables; connection writer; reap; From 14c23716a6b5c2168ec5096baff5029eb14d0abb Mon Sep 17 00:00:00 2001 From: "sasha@mysql.sashanet.com" <> Date: Tue, 17 Jul 2001 14:22:52 -0600 Subject: [PATCH 13/13] added slave_net_timeout --- sql/mysqld.cc | 4 ++++ sql/slave.cc | 1 + sql/slave.h | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 12fa557635f..422d27ec624 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -262,6 +262,7 @@ ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size, net_interactive_timeout, slow_launch_time = 2L, net_read_timeout,net_write_timeout,slave_open_temp_tables=0, open_files_limit=0, max_binlog_size; +ulong slave_net_timeout; ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0; volatile ulong cached_thread_count=0; @@ -2740,6 +2741,8 @@ CHANGEABLE_VAR changeable_vars[] = { 0, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE }, { "record_buffer", (long*) &my_default_record_cache_size, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE }, + { "slave_net_timeout", (long*) &slave_net_timeout, + SLAVE_NET_TIMEOUT, 1, 65535, 0, 1 }, { "slow_launch_time", (long*) &slow_launch_time, 2L, 0L, ~0L, 0, 1 }, { "sort_buffer", (long*) &sortbuff_size, @@ -2856,6 +2859,7 @@ struct show_var_st init_vars[]= { {"query_buffer_size", (char*) &query_buff_size, SHOW_LONG}, {"safe_show_database", (char*) &opt_safe_show_db, SHOW_BOOL}, {"server_id", (char*) &server_id, SHOW_LONG}, + {"slave_net_timeout", (char*) &slave_net_timeout, SHOW_LONG}, {"skip_locking", (char*) &my_disable_locking, SHOW_MY_BOOL}, {"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL}, {"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL}, diff --git a/sql/slave.cc b/sql/slave.cc index 17420b8fde9..ab1a880a46e 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -678,6 +678,7 @@ static int init_slave_thread(THD* thd) thd->system_thread = thd->bootstrap = 1; thd->client_capabilities = 0; my_net_init(&thd->net, 0); + thd->net.timeout = slave_net_timeout; thd->max_packet_length=thd->net.max_packet; thd->master_access= ~0; thd->priv_user = 0; diff --git a/sql/slave.h b/sql/slave.h index 1f3955d8a09..1932bcb04fe 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -1,6 +1,10 @@ #ifndef SLAVE_H #define SLAVE_H +#define SLAVE_NET_TIMEOUT 3600 + +extern ulong slave_net_timeout; + typedef struct st_master_info { char log_file_name[FN_REFLEN];