summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2001-07-17 16:23:36 -0600
committerunknown <sasha@mysql.sashanet.com>2001-07-17 16:23:36 -0600
commitbab169b6923870bf2e08a80aa8e22d8851a9a10f (patch)
tree6b12d97d09cd80fd52fbc48fbe802efa550e1112
parent90acfb9ff36c796650b40c8b85f2f4042c60d1fc (diff)
parent4c26f24575d8c95a39a3f007ef72f6818d8d1439 (diff)
downloadmariadb-git-bab169b6923870bf2e08a80aa8e22d8851a9a10f.tar.gz
merged with 3.23
configure.in: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged sql/mysqld.cc: Auto merged sql/slave.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_update.cc: Auto merged Docs/manual.texi: merged mysql-test/t/rpl_sporadic_master.test: merged sql/Makefile.am: merged sql/slave.h: merged
-rw-r--r--configure.in22
-rw-r--r--mit-pthreads/gen/ctime.c2
-rwxr-xr-xmit-pthreads/machdep/netbsd-1.1/__signal.h7
-rw-r--r--mit-pthreads/stdio/strerror.c7
-rw-r--r--myisam/mi_check.c16
-rw-r--r--myisam/myisamchk.c2
-rw-r--r--mysql-test/r/auto_increment.result5
-rw-r--r--mysql-test/r/limit.result3
-rw-r--r--mysql-test/r/lock.result4
-rw-r--r--mysql-test/r/rpl_sporadic_master.result12
-rw-r--r--mysql-test/t/auto_increment.test11
-rw-r--r--mysql-test/t/limit.test11
-rw-r--r--mysql-test/t/lock.test42
-rw-r--r--mysql-test/t/rpl_sporadic_master.test12
-rw-r--r--mysys/thr_lock.c36
-rw-r--r--sql/ha_berkeley.cc4
-rw-r--r--sql/ha_gemini.cc5
-rw-r--r--sql/ha_gemini.h2
-rw-r--r--sql/ha_innobase.cc45
-rw-r--r--sql/ha_innobase.h1
-rw-r--r--sql/mysqld.cc4
-rw-r--r--sql/slave.cc1
-rw-r--r--sql/slave.h4
-rw-r--r--sql/sql_acl.cc7
-rw-r--r--sql/sql_delete.cc7
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_show.cc2
-rw-r--r--sql/sql_update.cc3
-rwxr-xr-xtests/fork2_test.pl35
-rwxr-xr-xtests/fork_big.pl72
30 files changed, 331 insertions, 55 deletions
diff --git a/configure.in b/configure.in
index d9c443c0dc8..36c484d7d20 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})
@@ -831,6 +834,12 @@ 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"
+ OVERRIDE_MT_LD_ADD="\$(top_srcdir)/mit-pthreads/obj/libpthread.a"
+ ;;
*bsdi*)
echo "Adding fix for BSDI"
CFLAGS="$CFLAGS -D__BSD__ -DHAVE_BROKEN_REALPATH"
@@ -2058,7 +2067,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
@@ -2099,15 +2108,20 @@ 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"
+ 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"
+ fi
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 <sys/signal.h>
+__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 <string.h>
+#if defined(__NetBSD__)
+#include <errno.h>
+#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 deb3f2071b3..a02652f0b48 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -434,9 +434,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;
@@ -456,6 +456,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 5b1d4b0ed61..bda1637314f 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -206,7 +206,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/r/lock.result b/mysql-test/r/lock.result
index 7b1be604024..ccd3c02558d 100644
--- a/mysql-test/r/lock.result
+++ b/mysql-test/r/lock.result
@@ -4,3 +4,7 @@ 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
+4
+n
+1
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/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/mysql-test/t/lock.test b/mysql-test/t/lock.test
index 385713174d2..77354e63252 100644
--- a/mysql-test/t/lock.test
+++ b/mysql-test/t/lock.test
@@ -53,3 +53,45 @@ 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;
+--sleep 2
+send select n from t1;
+connection locker;
+--sleep 2
+unlock tables;
+connection writer;
+reap;
+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;
+--sleep 2
+send select n from t1;
+connection locker;
+--sleep 2
+unlock tables;
+connection writer;
+reap;
+connection reader;
+reap;
+drop table t1;
+
diff --git a/mysql-test/t/rpl_sporadic_master.test b/mysql-test/t/rpl_sporadic_master.test
index b22a95612ba..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);
-truncate table t1;
-insert into t1 values (NULL),(NULL);
+delete from t1;
+# 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;
-truncate table t1;
-insert into t1 values (NULL),(NULL);
+delete from t1;
+insert into t1 values (10),(NULL);
insert into t1 values (NULL),(NULL);
insert into t1 values (NULL),(NULL);
save_master_pos;
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/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/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;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index f328ee56727..bbc14f307c0 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -272,6 +272,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;
@@ -2782,6 +2783,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,
@@ -2903,6 +2906,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 488fb357c52..60011209cde 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -735,6 +735,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 8e49511e08d..85db0b75f53 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -2,6 +2,10 @@
#define SLAVE_H
#include "mysql.h"
+#define SLAVE_NET_TIMEOUT 3600
+
+extern ulong slave_net_timeout;
+
typedef struct st_master_info
{
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 <LEX_USER> &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_delete.cc b/sql/sql_delete.cc
index c2ac8c05b85..d14201822e0 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -178,12 +178,13 @@ int mysql_delete(THD *thd,
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_parse.cc b/sql/sql_parse.cc
index 18774955f6a..981e64e5de5 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -556,7 +556,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 4ed59f7d1b0..34e8985007e 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/sql/sql_update.cc b/sql/sql_update.cc
index a6ded7cef9c..609c2642bc6 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -114,7 +114,8 @@ int mysql_update(THD *thd,
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
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";
@@ -244,6 +247,44 @@ sub test_select_count
}
#
+# 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
# one loop
@@ -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;