Commit aff45e1b authored by unknown's avatar unknown

merge with 4.0


BitKeeper/deleted/.del-MYSQL.ICO~d93519b5f0d6ee1:
  Auto merged
client/client_priv.h:
  Auto merged
extra/resolveip.c:
  Auto merged
include/mysql.h:
  Auto merged
include/thr_alarm.h:
  Auto merged
myisam/myisamchk.c:
  Auto merged
scripts/mysql_config.sh:
  Auto merged
scripts/mysqld_safe.sh:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_handler.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_test.cc:
  Auto merged
parents 893797be 0fc97bc9
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* We have to define 'enum options' identical in all files to keep OS2 happy */ /* We have to define 'enum options' identical in all files to keep OS2 happy */
enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET, enum options_client { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
OPT_PAGER, OPT_NOPAGER, OPT_TEE, OPT_NOTEE, OPT_PAGER, OPT_NOPAGER, OPT_TEE, OPT_NOTEE,
OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS, OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS,
OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE, OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE,
......
...@@ -66,6 +66,9 @@ typedef int my_socket; ...@@ -66,6 +66,9 @@ typedef int my_socket;
extern unsigned int mysql_port; extern unsigned int mysql_port;
extern char *mysql_unix_port; extern char *mysql_unix_port;
#define CLIENT_NET_READ_TIMEOUT 365*24*3600 /* Timeout on read */
#define CLIENT_NET_WRITE_TIMEOUT 365*24*3600 /* Timeout on write */
#ifdef __NETWARE__ #ifdef __NETWARE__
#pragma pack(push, 8) /* 8 byte alignment */ #pragma pack(push, 8) /* 8 byte alignment */
#endif #endif
......
...@@ -49,6 +49,7 @@ int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key, ...@@ -49,6 +49,7 @@ int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key, int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
pbool max_at_top, queue_compare compare, pbool max_at_top, queue_compare compare,
void *first_cmp_arg); void *first_cmp_arg);
int resize_queue(QUEUE *queue, uint max_elements);
void delete_queue(QUEUE *queue); void delete_queue(QUEUE *queue);
void queue_insert(QUEUE *queue,byte *element); void queue_insert(QUEUE *queue,byte *element);
byte *queue_remove(QUEUE *queue,uint idx); byte *queue_remove(QUEUE *queue,uint idx);
......
...@@ -60,9 +60,10 @@ typedef my_bool ALARM; ...@@ -60,9 +60,10 @@ typedef my_bool ALARM;
#define thr_end_alarm(A) #define thr_end_alarm(A)
#define thr_alarm(A,B,C) ((*(A)=1)-1) #define thr_alarm(A,B,C) ((*(A)=1)-1)
/* The following should maybe be (*(A)) */ /* The following should maybe be (*(A)) */
#define thr_got_alarm(A) 0 #define thr_got_alarm(A) 0
#define init_thr_alarm(A) #define init_thr_alarm(A)
#define thr_alarm_kill(A) #define thr_alarm_kill(A)
#define resize_thr_alarm(N)
#define end_thr_alarm() #define end_thr_alarm()
#else #else
...@@ -100,6 +101,7 @@ typedef struct st_alarm { ...@@ -100,6 +101,7 @@ typedef struct st_alarm {
#define thr_alarm_init(A) (*(A))=0 #define thr_alarm_init(A) (*(A))=0
#define thr_alarm_in_use(A) (*(A)!= 0) #define thr_alarm_in_use(A) (*(A)!= 0)
void init_thr_alarm(uint max_alarm); void init_thr_alarm(uint max_alarm);
void resize_thr_alarm(uint max_alarms);
my_bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff); my_bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
void thr_alarm_kill(pthread_t thread_id); void thr_alarm_kill(pthread_t thread_id);
void thr_end_alarm(thr_alarm_t *alarmed); void thr_end_alarm(thr_alarm_t *alarmed);
......
...@@ -65,8 +65,8 @@ ...@@ -65,8 +65,8 @@
ulong net_buffer_length=8192; ulong net_buffer_length=8192;
ulong max_allowed_packet= 1024L*1024L*1024L; ulong max_allowed_packet= 1024L*1024L*1024L;
ulong net_read_timeout= NET_READ_TIMEOUT; ulong net_read_timeout= CLIENT_NET_READ_TIMEOUT;
ulong net_write_timeout= NET_WRITE_TIMEOUT; ulong net_write_timeout= CLIENT_NET_WRITE_TIMEOUT;
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
......
...@@ -146,7 +146,7 @@ int main(int argc, char **argv) ...@@ -146,7 +146,7 @@ int main(int argc, char **argv)
#endif #endif
} /* main */ } /* main */
enum options { enum options_mc {
OPT_CHARSETS_DIR=256, OPT_SET_CHARSET,OPT_START_CHECK_POS, OPT_CHARSETS_DIR=256, OPT_SET_CHARSET,OPT_START_CHECK_POS,
OPT_CORRECT_CHECKSUM, OPT_KEY_BUFFER_SIZE, OPT_MYISAM_BLOCK_SIZE, OPT_CORRECT_CHECKSUM, OPT_KEY_BUFFER_SIZE, OPT_MYISAM_BLOCK_SIZE,
OPT_READ_BUFFER_SIZE, OPT_WRITE_BUFFER_SIZE, OPT_SORT_BUFFER_SIZE, OPT_READ_BUFFER_SIZE, OPT_WRITE_BUFFER_SIZE, OPT_SORT_BUFFER_SIZE,
......
...@@ -220,6 +220,44 @@ ERROR 23000: Column 'k1' cannot be null ...@@ -220,6 +220,44 @@ ERROR 23000: Column 'k1' cannot be null
insert into t1 values (NULL, NULL); insert into t1 values (NULL, NULL);
ERROR 23000: Column 'k1' cannot be null ERROR 23000: Column 'k1' cannot be null
drop table t1; drop table t1;
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
create table if not exists t1 select 1,2,3,4;
Column count doesn't match value count at row 1
create table if not exists t1 select 1;
select * from t1;
1 2 3
1 2 3
0 1 2
0 0 1
drop table t1;
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
create table if not exists t1 select 1,2,3,4;
Column count doesn't match value count at row 1
create table if not exists t1 select 1;
select * from t1;
1 2 3
1 2 3
0 1 2
0 0 1
drop table t1;
create table t1 (a int not null, b int, primary key (a));
insert into t1 values (1,1);
create table if not exists t1 select 2;
select * from t1;
a b
1 1
0 2
create table if not exists t1 select 3 as 'a',4 as 'b';
create table if not exists t1 select 3 as 'a',3 as 'b';
Duplicate entry '3' for key 1
select * from t1;
a b
1 1
0 2
3 4
drop table t1;
create table t1 (a int, key(a)); create table t1 (a int, key(a));
create table t2 (b int, foreign key(b) references t1(a), key(b)); create table t2 (b int, foreign key(b) references t1(a), key(b));
drop table if exists t1,t2; drop table if exists t1,t2;
......
...@@ -21,21 +21,30 @@ drop table t1; ...@@ -21,21 +21,30 @@ drop table t1;
# Test of some CREATE TABLE'S that should fail # Test of some CREATE TABLE'S that should fail
# #
!$1146 create table t2 type=heap select * from t1; --error 1146
!$1146 create table t2 select auto+1 from t1; create table t2 type=heap select * from t1;
--error 1146
create table t2 select auto+1 from t1;
drop table if exists t1,t2; drop table if exists t1,t2;
!$1167 create table t1 (b char(0) not null, index(b)); --error 1167
create table t1 (b char(0) not null, index(b));
--error 1164
create table t1 (a int not null auto_increment,primary key (a)) type=heap; create table t1 (a int not null auto_increment,primary key (a)) type=heap;
!$1163 create table t1 (a int not null,b text) type=heap; --error 1163
create table t1 (a int not null,b text) type=heap;
drop table if exists t1; drop table if exists t1;
!$1075 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap; --error 1075
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
-- error 1044,1 -- error 1044,1
create table not_existing_database.test (a int); create table not_existing_database.test (a int);
!$1103 create table `a/a` (a int); --error 1103
!$1103 create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int); create table `a/a` (a int);
!$1059 create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int); --error 1103
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
--error 1059
create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
# #
# test of dummy table names # test of dummy table names
...@@ -166,6 +175,46 @@ insert into t1 values (NULL, 3); ...@@ -166,6 +175,46 @@ insert into t1 values (NULL, 3);
insert into t1 values (NULL, NULL); insert into t1 values (NULL, NULL);
drop table t1; drop table t1;
#
# Bug # 801
#
create table t1 select x'4132';
drop table t1;
#
# bug #1434
#
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
--error 1136
create table if not exists t1 select 1,2,3,4;
create table if not exists t1 select 1;
select * from t1;
drop table t1;
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
--error 1136
create table if not exists t1 select 1,2,3,4;
create table if not exists t1 select 1;
select * from t1;
drop table t1;
#
# Test create table if not exists with duplicate key error
#
create table t1 (a int not null, b int, primary key (a));
insert into t1 values (1,1);
create table if not exists t1 select 2;
select * from t1;
create table if not exists t1 select 3 as 'a',4 as 'b';
--error 1062
create table if not exists t1 select 3 as 'a',3 as 'b';
select * from t1;
drop table t1;
# #
# Test create with foreign keys # Test create with foreign keys
# #
...@@ -229,12 +278,6 @@ show create table t1; ...@@ -229,12 +278,6 @@ show create table t1;
SET SESSION table_type=default; SET SESSION table_type=default;
drop table t1; drop table t1;
#
# Bug # 801
#
create table t1 select x'4132';
drop table t1;
# #
# Test types of data for create select with functions # Test types of data for create select with functions
# #
......
...@@ -39,28 +39,28 @@ select "--- Local --" as ""; ...@@ -39,28 +39,28 @@ select "--- Local --" as "";
# #
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ $MYSQL_TEST_DIR/var/log/master-bin.000001
# this should not fail but shouldn't produce any working statements # this should not fail but shouldn't produce any working statements
--disable_query_log --disable_query_log
select "--- Broken LOAD DATA --" as ""; select "--- Broken LOAD DATA --" as "";
--enable_query_log --enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000002 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ $MYSQL_TEST_DIR/var/log/master-bin.000002
# this should show almost nothing # this should show almost nothing
--disable_query_log --disable_query_log
select "--- --database --" as ""; select "--- --database --" as "";
--enable_query_log --enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form --database=nottest $MYSQL_TEST_DIR/var/log/master-bin.000001 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --database=nottest $MYSQL_TEST_DIR/var/log/master-bin.000001
# this test for position option # this test for position option
--disable_query_log --disable_query_log
select "--- --position --" as ""; select "--- --position --" as "";
--enable_query_log --enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form --position=27 $MYSQL_TEST_DIR/var/log/master-bin.000002 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=27 $MYSQL_TEST_DIR/var/log/master-bin.000002
# These are tests for remote binlog. # These are tests for remote binlog.
# They should return the same as previous test. # They should return the same as previous test.
...@@ -76,28 +76,28 @@ select "--- Remote --" as ""; ...@@ -76,28 +76,28 @@ select "--- Remote --" as "";
# This is broken now # This is broken now
# By the way it seems that remote version fetches all events with name >= master-bin.000001 # By the way it seems that remote version fetches all events with name >= master-bin.000001
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
# This is broken too # This is broken too
--disable_query_log --disable_query_log
select "--- Broken LOAD DATA --" as ""; select "--- Broken LOAD DATA --" as "";
--enable_query_log --enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
# And this too ! (altough it is documented) # And this too ! (altough it is documented)
--disable_query_log --disable_query_log
select "--- --database --" as ""; select "--- --database --" as "";
--enable_query_log --enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001
# Strangely but this works # Strangely but this works
--disable_query_log --disable_query_log
select "--- --position --" as ""; select "--- --position --" as "";
--enable_query_log --enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form --read-from-remote-server --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
# clean up # clean up
drop table t1; drop table t1;
...@@ -51,16 +51,17 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) ...@@ -51,16 +51,17 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
#if defined(HAVE_SETFILEPOINTER) #if defined(HAVE_SETFILEPOINTER)
/* This is for the moment only true on windows */ /* This is for the moment only true on windows */
{ {
long is_success;
HANDLE win_file= (HANDLE) _get_osfhandle(fd); HANDLE win_file= (HANDLE) _get_osfhandle(fd);
long length_low, length_high; long length_low, length_high;
length_low= (long) (ulong) newlength; length_low= (long) (ulong) newlength;
length_high= (long) ((ulonglong) newlength >> 32); length_high= (long) ((ulonglong) newlength >> 32);
if (SetFilePointer(win_file, length_low, &length_high, FILE_BEGIN)) is_success= SetFilePointer(win_file, length_low, &length_high, FILE_BEGIN);
{ if (is_success == -1 && (my_errno= GetLastError()) != NO_ERROR)
if (SetEndOfFile(win_file)) goto err;
DBUG_RETURN(0); if (SetEndOfFile(win_file))
} DBUG_RETURN(0);
my_errno= errno; my_errno= GetLastError();
goto err; goto err;
} }
#elif defined(HAVE_FTRUNCATE) #elif defined(HAVE_FTRUNCATE)
......
...@@ -64,7 +64,7 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key, ...@@ -64,7 +64,7 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
/* /*
Reinitialize queue for other usage (deletes all elements) Reinitialize queue for other usage
SYNOPSIS SYNOPSIS
reinit_queue() reinit_queue()
...@@ -77,8 +77,8 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key, ...@@ -77,8 +77,8 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
first_cmp_arg First argument to compare function first_cmp_arg First argument to compare function
NOTES NOTES
You can't currently resize the number of elements! If you need this, This will delete all elements from the queue. If you don't want this,
fix it :) use resize_queue() instead.
RETURN RETURN
0 ok 0 ok
...@@ -90,15 +90,46 @@ int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key, ...@@ -90,15 +90,46 @@ int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
void *first_cmp_arg) void *first_cmp_arg)
{ {
DBUG_ENTER("reinit_queue"); DBUG_ENTER("reinit_queue");
if (queue->max_elements < max_elements)
/* It's real easy to do realloc here, just don't want to bother */
DBUG_RETURN(my_errno=EE_OUTOFMEMORY);
queue->elements=0; queue->elements=0;
queue->compare=compare; queue->compare=compare;
queue->first_cmp_arg=first_cmp_arg; queue->first_cmp_arg=first_cmp_arg;
queue->offset_to_key=offset_to_key; queue->offset_to_key=offset_to_key;
queue->max_at_top= max_at_top ? (-1 ^ 1) : 0; queue->max_at_top= max_at_top ? (-1 ^ 1) : 0;
resize_queue(queue, max_elements);
DBUG_RETURN(0);
}
/*
Resize queue
SYNOPSIS
resize_queue()
queue Queue
max_elements New max size for queue
NOTES
If you resize queue to be less than the elements you have in it,
the extra elements will be deleted
RETURN
0 ok
1 Error. In this case the queue is unchanged
*/
int resize_queue(QUEUE *queue, uint max_elements)
{
byte **new_root;
DBUG_ENTER("resize_queue");
if (queue->max_elements == max_elements)
DBUG_RETURN(0);
if ((new_root= (byte **) my_realloc((void *)queue->root,
(max_elements+1)*sizeof(void*),
MYF(MY_WME))) == 0)
DBUG_RETURN(1);
set_if_smaller(queue->elements, max_elements);
queue->max_elements= max_elements;
queue->root= new_root;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -120,6 +120,20 @@ void init_thr_alarm(uint max_alarms) ...@@ -120,6 +120,20 @@ void init_thr_alarm(uint max_alarms)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void resize_thr_alarm(uint max_alarms)
{
pthread_mutex_lock(&LOCK_alarm);
/*
It's ok not to shrink the queue as there may be more pending alarms than
than max_alarms
*/
if (alarm_queue.elements < max_alarms)
resize_queue(&alarm_queue,max_alarms+1);
pthread_mutex_unlock(&LOCK_alarm);
}
/* /*
Request alarm after sec seconds. Request alarm after sec seconds.
......
...@@ -62,7 +62,7 @@ get_full_path () ...@@ -62,7 +62,7 @@ get_full_path ()
{ {
case $1 in case $1 in
/*) echo "$1";; /*) echo "$1";;
./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/./;/;' ;; ./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/\./;/;' ;;
*) which $1 ;; *) which $1 ;;
esac esac
} }
......
...@@ -51,9 +51,9 @@ parse_arguments() { ...@@ -51,9 +51,9 @@ parse_arguments() {
;; ;;
# these two might have been set in a [mysqld_safe] section of my.cnf # these two might have been set in a [mysqld_safe] section of my.cnf
# they get passed via environment variables to mysqld_safe # they are added to mysqld command line to override settings from my.cnf
--socket=*) MYSQL_UNIX_PORT=`echo "$arg" | sed -e "s;--socket=;;"` ;; --socket=*) mysql_unix_port=`echo "$arg" | sed -e "s;--socket=;;"` ;;
--port=*) MYSQL_TCP_PORT=`echo "$arg" | sed -e "s;--port=;;"` ;; --port=*) mysql_tcp_port=`echo "$arg" | sed -e "s;--port=;;"` ;;
# mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])! # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
--ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;; --ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;;
...@@ -114,8 +114,7 @@ else ...@@ -114,8 +114,7 @@ else
ledir=@libexecdir@ ledir=@libexecdir@
fi fi
MYSQL_UNIX_PORT=${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@} safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}}
MYSQL_TCP_PORT=${MYSQL_TCP_PORT:-@MYSQL_TCP_PORT@}
user=@MYSQLD_USER@ user=@MYSQLD_USER@
niceness=0 niceness=0
...@@ -171,9 +170,14 @@ else ...@@ -171,9 +170,14 @@ else
fi fi
test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
export MYSQL_UNIX_PORT if test -n "$mysql_unix_port"
export MYSQL_TCP_PORT then
args="--socket=$mysql_unix_port $args"
fi
if test -n "$mysql_tcp_port"
then
args="--port=$mysql_tcp_port $args"
fi
if test $niceness -eq 0 if test $niceness -eq 0
then then
...@@ -296,7 +300,7 @@ echo "Starting $MYSQLD daemon with databases from $DATADIR" ...@@ -296,7 +300,7 @@ echo "Starting $MYSQLD daemon with databases from $DATADIR"
echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
while true while true
do do
rm -f $MYSQL_UNIX_PORT $pid_file # Some extra safety rm -f $safe_mysql_unix_port $pid_file # Some extra safety
if test -z "$args" if test -z "$args"
then then
$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1 $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
......
...@@ -169,10 +169,10 @@ typedef struct st_ha_create_information ...@@ -169,10 +169,10 @@ typedef struct st_ha_create_information
SQL_LIST merge_list; SQL_LIST merge_list;
enum db_type db_type; enum db_type db_type;
enum row_type row_type; enum row_type row_type;
uint options; /* OR of HA_CREATE_ options */ uint options; /* OR of HA_CREATE_ options */
uint raid_type,raid_chunks; uint raid_type,raid_chunks;
uint merge_insert_method; uint merge_insert_method;
bool if_not_exists; bool table_existed; /* 1 in create if table existed */
} HA_CREATE_INFO; } HA_CREATE_INFO;
......
...@@ -3453,10 +3453,10 @@ error: ...@@ -3453,10 +3453,10 @@ error:
Handle start options Handle start options
******************************************************************************/ ******************************************************************************/
enum options enum options_mysqld
{ {
OPT_ISAM_LOG=256, OPT_SKIP_NEW, OPT_ISAM_LOG=256, OPT_SKIP_NEW,
OPT_SKIP_GRANT, OPT_SKIP_LOCK, OPT_SKIP_GRANT, OPT_SKIP_LOCK,
OPT_ENABLE_LOCK, OPT_USE_LOCKING, OPT_ENABLE_LOCK, OPT_USE_LOCKING,
OPT_SOCKET, OPT_UPDATE_LOG, OPT_SOCKET, OPT_UPDATE_LOG,
OPT_BIN_LOG, OPT_SKIP_RESOLVE, OPT_BIN_LOG, OPT_SKIP_RESOLVE,
......
...@@ -90,6 +90,7 @@ static void fix_myisam_max_extra_sort_file_size(THD *thd, enum_var_type type); ...@@ -90,6 +90,7 @@ static void fix_myisam_max_extra_sort_file_size(THD *thd, enum_var_type type);
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type); static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
static void fix_max_binlog_size(THD *thd, enum_var_type type); static void fix_max_binlog_size(THD *thd, enum_var_type type);
static void fix_max_relay_log_size(THD *thd, enum_var_type type); static void fix_max_relay_log_size(THD *thd, enum_var_type type);
static void fix_max_connections(THD *thd, enum_var_type type);
static KEY_CACHE *create_key_cache(const char *name, uint length); static KEY_CACHE *create_key_cache(const char *name, uint length);
void fix_sql_mode_var(THD *thd, enum_var_type type); void fix_sql_mode_var(THD *thd, enum_var_type type);
static byte *get_error_count(THD *thd); static byte *get_error_count(THD *thd);
...@@ -162,7 +163,8 @@ sys_var_long_ptr sys_max_binlog_size("max_binlog_size", ...@@ -162,7 +163,8 @@ sys_var_long_ptr sys_max_binlog_size("max_binlog_size",
&max_binlog_size, &max_binlog_size,
fix_max_binlog_size); fix_max_binlog_size);
sys_var_long_ptr sys_max_connections("max_connections", sys_var_long_ptr sys_max_connections("max_connections",
&max_connections); &max_connections,
fix_max_connections);
sys_var_long_ptr sys_max_connect_errors("max_connect_errors", sys_var_long_ptr sys_max_connect_errors("max_connect_errors",
&max_connect_errors); &max_connect_errors);
sys_var_long_ptr sys_max_delayed_threads("max_delayed_threads", sys_var_long_ptr sys_max_delayed_threads("max_delayed_threads",
...@@ -773,7 +775,7 @@ static void fix_max_join_size(THD *thd, enum_var_type type) ...@@ -773,7 +775,7 @@ static void fix_max_join_size(THD *thd, enum_var_type type)
thd->options&= ~OPTION_BIG_SELECTS; thd->options&= ~OPTION_BIG_SELECTS;
} }
} }
/* /*
If one doesn't use the SESSION modifier, the isolation level If one doesn't use the SESSION modifier, the isolation level
...@@ -841,7 +843,7 @@ static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type) ...@@ -841,7 +843,7 @@ static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type)
#endif #endif
void fix_delay_key_write(THD *thd, enum_var_type type) extern void fix_delay_key_write(THD *thd, enum_var_type type)
{ {
switch ((enum_delay_key_write) delay_key_write_options) { switch ((enum_delay_key_write) delay_key_write_options) {
case DELAY_KEY_WRITE_NONE: case DELAY_KEY_WRITE_NONE:
...@@ -857,7 +859,7 @@ void fix_delay_key_write(THD *thd, enum_var_type type) ...@@ -857,7 +859,7 @@ void fix_delay_key_write(THD *thd, enum_var_type type)
} }
} }
void fix_max_binlog_size(THD *thd, enum_var_type type) static void fix_max_binlog_size(THD *thd, enum_var_type type)
{ {
DBUG_ENTER("fix_max_binlog_size"); DBUG_ENTER("fix_max_binlog_size");
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu", DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
...@@ -870,7 +872,7 @@ void fix_max_binlog_size(THD *thd, enum_var_type type) ...@@ -870,7 +872,7 @@ void fix_max_binlog_size(THD *thd, enum_var_type type)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void fix_max_relay_log_size(THD *thd, enum_var_type type) static void fix_max_relay_log_size(THD *thd, enum_var_type type)
{ {
DBUG_ENTER("fix_max_relay_log_size"); DBUG_ENTER("fix_max_relay_log_size");
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu", DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
...@@ -882,6 +884,13 @@ void fix_max_relay_log_size(THD *thd, enum_var_type type) ...@@ -882,6 +884,13 @@ void fix_max_relay_log_size(THD *thd, enum_var_type type)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
#include <thr_alarm.h>
static void
fix_max_connections(THD *thd, enum_var_type type)
{
resize_thr_alarm(max_connections);
}
bool sys_var_long_ptr::update(THD *thd, set_var *var) bool sys_var_long_ptr::update(THD *thd, set_var *var)
{ {
ulonglong tmp= var->value->val_int(); ulonglong tmp= var->value->val_int();
...@@ -2076,7 +2085,7 @@ int set_var::check(THD *thd) ...@@ -2076,7 +2085,7 @@ int set_var::check(THD *thd)
{ {
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name); my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name);
return -1; return -1;
} }
return var->check(thd, this) ? -1 : 0; return var->check(thd, this) ? -1 : 0;
} }
......
...@@ -1086,11 +1086,12 @@ static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi) ...@@ -1086,11 +1086,12 @@ static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi)
BINLOG_FORMAT_323_GEQ_57 ; BINLOG_FORMAT_323_GEQ_57 ;
break; break;
case '4': case '4':
case '5':
mi->old_format = BINLOG_FORMAT_CURRENT; mi->old_format = BINLOG_FORMAT_CURRENT;
break; break;
default: default:
errmsg = "Master reported unrecognized MySQL version"; /* 5.0 is not supported */
errmsg = "Master reported an unrecognized MySQL version. Note that 4.0 \
slaves can't replicate a 5.0 or newer master.";
break; break;
} }
...@@ -3165,6 +3166,8 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ ...@@ -3165,6 +3166,8 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
RPL_LOG_NAME, llstr(rli->group_master_log_pos,llbuff)); RPL_LOG_NAME, llstr(rli->group_master_log_pos,llbuff));
err: err:
/* Free temporary tables etc */
thd->cleanup();
VOID(pthread_mutex_lock(&LOCK_thread_count)); VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = thd->db = 0; // extra safety thd->query = thd->db = 0; // extra safety
VOID(pthread_mutex_unlock(&LOCK_thread_count)); VOID(pthread_mutex_unlock(&LOCK_thread_count));
......
...@@ -867,8 +867,7 @@ public: ...@@ -867,8 +867,7 @@ public:
List<Item> &select_fields,enum_duplicates duplic) List<Item> &select_fields,enum_duplicates duplic)
:select_insert (NULL, &select_fields, duplic), db(db_name), :select_insert (NULL, &select_fields, duplic), db(db_name),
name(table_name), extra_fields(&fields_par),keys(&keys_par), name(table_name), extra_fields(&fields_par),keys(&keys_par),
create_info(create_info_par), create_info(create_info_par), lock(0)
lock(0)
{} {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u); int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &values); bool send_data(List<Item> &values);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
The second is to be freeed only on thread end. mysql_ha_open should The second is to be freeed only on thread end. mysql_ha_open should
then do { handler_items=concat(handler_items, free_list); free_list=0; } then do { handler_items=concat(handler_items, free_list); free_list=0; }
But !!! do_cammand calls free_root at the end of every query and frees up But !!! do_command calls free_root at the end of every query and frees up
all the sql_alloc'ed memory. It's harder to work around... all the sql_alloc'ed memory. It's harder to work around...
*/ */
...@@ -72,7 +72,11 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok) ...@@ -72,7 +72,11 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok)
if (*ptr) if (*ptr)
{ {
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
close_thread_table(thd, ptr); if (close_thread_table(thd, ptr))
{
/* Tell threads waiting for refresh that something has happened */
VOID(pthread_cond_broadcast(&COND_refresh));
}
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
} }
else else
...@@ -89,8 +93,11 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok) ...@@ -89,8 +93,11 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok)
int mysql_ha_closeall(THD *thd, TABLE_LIST *tables) int mysql_ha_closeall(THD *thd, TABLE_LIST *tables)
{ {
TABLE **ptr=find_table_ptr_by_name(thd, tables->db, tables->real_name, 0); TABLE **ptr=find_table_ptr_by_name(thd, tables->db, tables->real_name, 0);
if (*ptr) if (*ptr && close_thread_table(thd, ptr))
close_thread_table(thd, ptr); {
/* Tell threads waiting for refresh that something has happened */
VOID(pthread_cond_broadcast(&COND_refresh));
}
return 0; return 0;
} }
......
...@@ -1553,6 +1553,14 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u) ...@@ -1553,6 +1553,14 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if (!table) if (!table)
DBUG_RETURN(-1); // abort() deletes table DBUG_RETURN(-1); // abort() deletes table
if (table->fields < values.elements)
{
my_printf_error(ER_WRONG_VALUE_COUNT_ON_ROW,
ER(ER_WRONG_VALUE_COUNT_ON_ROW),
MYF(0),1);
DBUG_RETURN(-1);
}
/* First field to copy */ /* First field to copy */
field=table->field+table->fields - values.elements; field=table->field+table->fields - values.elements;
...@@ -1611,7 +1619,7 @@ bool select_create::send_eof() ...@@ -1611,7 +1619,7 @@ bool select_create::send_eof()
*/ */
if (!table->tmp_table) if (!table->tmp_table)
hash_delete(&open_cache,(byte*) table); hash_delete(&open_cache,(byte*) table);
lock=0; lock=0;
table=0; table=0;
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
} }
...@@ -1632,7 +1640,8 @@ void select_create::abort() ...@@ -1632,7 +1640,8 @@ void select_create::abort()
enum db_type table_type=table->db_type; enum db_type table_type=table->db_type;
if (!table->tmp_table) if (!table->tmp_table)
hash_delete(&open_cache,(byte*) table); hash_delete(&open_cache,(byte*) table);
quick_rm_table(table_type,db,name); if (!create_info->table_existed)
quick_rm_table(table_type,db,name);
table=0; table=0;
} }
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
......
...@@ -3407,7 +3407,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, ...@@ -3407,7 +3407,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
/* grant_option is set if there exists a single table or column grant */ /* grant_option is set if there exists a single table or column grant */
if (db_access == want_access || if (db_access == want_access ||
((grant_option && !dont_check_global_grants) && ((grant_option && !dont_check_global_grants) &&
!(want_access & ~TABLE_ACLS))) !(want_access & ~(db_access | TABLE_ACLS))))
DBUG_RETURN(FALSE); /* Ok */ DBUG_RETURN(FALSE); /* Ok */
if (!no_errors) if (!no_errors)
net_printf(thd,ER_DBACCESS_DENIED_ERROR, net_printf(thd,ER_DBACCESS_DENIED_ERROR,
......
...@@ -901,7 +901,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -901,7 +901,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
&& find_temporary_table(thd,db,table_name)) && find_temporary_table(thd,db,table_name))
{ {
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
{
create_info->table_existed= 1; // Mark that table existed
DBUG_RETURN(0); DBUG_RETURN(0);
}
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
...@@ -913,14 +916,18 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -913,14 +916,18 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
if (!access(path,F_OK)) if (!access(path,F_OK))
{ {
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
{
create_info->table_existed= 1; // Mark that table existed
error= 0; error= 0;
}
else else
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
goto end; goto end;
} }
} }
thd->proc_info="creating table"; thd->proc_info="creating table";
create_info->table_existed= 0; // Mark that table is created
if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE) if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)
create_info->data_file_name= create_info->index_file_name= 0; create_info->data_file_name= create_info->index_file_name= 0;
......
...@@ -301,6 +301,8 @@ void mysql_print_status(THD *thd) ...@@ -301,6 +301,8 @@ void mysql_print_status(THD *thd)
printf("\nStatus information:\n\n"); printf("\nStatus information:\n\n");
my_getwd(current_dir, sizeof(current_dir),MYF(0)); my_getwd(current_dir, sizeof(current_dir),MYF(0));
printf("Current dir: %s\n", current_dir); printf("Current dir: %s\n", current_dir);
printf("Running threads: %d Stack size: %ld\n", thread_count,
(long) thread_stack);
if (thd) if (thd)
thd->proc_info="locks"; thd->proc_info="locks";
thr_print_locks(); // Write some debug info thr_print_locks(); // Write some debug info
...@@ -379,8 +381,9 @@ Maximum total allocated space: %d\n\ ...@@ -379,8 +381,9 @@ Maximum total allocated space: %d\n\
Space available in freed fastbin blocks: %d\n\ Space available in freed fastbin blocks: %d\n\
Total allocated space: %d\n\ Total allocated space: %d\n\
Total free space: %d\n\ Total free space: %d\n\
Top-most, releasable space: %d\n", Top-most, releasable space: %d\n\
(int) info.arena, Estimated memory (with thread stack): %ld\n",
(int) info.arena ,
(int) info.ordblks, (int) info.ordblks,
(int) info.smblks, (int) info.smblks,
(int) info.hblks, (int) info.hblks,
...@@ -389,7 +392,8 @@ Top-most, releasable space: %d\n", ...@@ -389,7 +392,8 @@ Top-most, releasable space: %d\n",
(int) info.fsmblks, (int) info.fsmblks,
(int) info.uordblks, (int) info.uordblks,
(int) info.fordblks, (int) info.fordblks,
(int) info.keepcost); (int) info.keepcost,
(long) (thread_count * thread_stack + info.hblkhd + info.arena));
#endif #endif
puts(""); puts("");
if (thd) if (thd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment