summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BitKeeper/etc/logging_ok1
-rw-r--r--Docs/manual.texi67
-rw-r--r--client/mysql.cc19
-rw-r--r--include/config-win.h1
-rw-r--r--include/my_pthread.h9
-rw-r--r--include/myisam.h2
-rw-r--r--include/myisammrg.h2
-rw-r--r--myisam/ft_stopwords.c1
-rw-r--r--myisam/mi_check.c4
-rw-r--r--myisam/mi_search.c4
-rw-r--r--myisam/myisamchk.c21
-rw-r--r--myisammrg/myrg_open.c14
-rw-r--r--myisammrg/myrg_queue.c31
-rw-r--r--myisammrg/myrg_rfirst.c2
-rw-r--r--myisammrg/myrg_rkey.c2
-rw-r--r--mysys/my_thr_init.c7
-rw-r--r--mysys/my_winthread.c10
-rw-r--r--mysys/thr_mutex.c23
-rw-r--r--scripts/safe_mysqld.sh9
-rw-r--r--sql/ha_myisammrg.cc2
-rw-r--r--sql/log.cc8
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/share/Makefile.am5
-rw-r--r--sql/sql_class.h4
-rw-r--r--sql/sql_string.cc31
25 files changed, 179 insertions, 102 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index 85eebc7230c..4c82a23befa 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -20,3 +20,4 @@ tim@localhost.polyesthetic.msg
tim@work.mysql.com
tonu@work.mysql.com
jcole@nslinux.bedford.progress.com
+nusphere@main.burghcom.com
diff --git a/Docs/manual.texi b/Docs/manual.texi
index ee16f828e9e..ba218cddd4f 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -3627,12 +3627,12 @@ Greece [NTUA, Athens] @
@c @uref{http://xenia.sote.hu/ftp/mirrors/www.mysql.com/, WWW}
@c @uref{ftp://xenia.sote.hu/pub/mirrors/www.mysql.com/,FTP}
-@c @item
-@c Not ok 20000919; Old site (Matt)
+@item
@c EMAIL: mirrors@gm.is (Tomas Edwardsson)
-@c @image{Flags/iceland} Island [GM] @
-@c @uref{http://mysql.gm.is/, WWW}
-@c @uref{ftp://ftp.gm.is/pub/mysql, WWW}
+@c @image{Flags/iceland}
+Iceland [GM] @
+@uref{http://mysql.gm.is/, WWW}
+@uref{ftp://ftp.gm.is/pub/mysql/, FTP}
@c @item
@c Out of date 990906
@@ -3750,12 +3750,12 @@ Switzerland [Sunsite] @
@c @image{Flags/great-britain} UK [Oyster/UK] @
@c @uref{ftp://ftp.oyster.co.uk/pub/mysql, FTP}
-@c @item
-@c Not ok 20000919; Old site (Matt)
+@item
@c gareth@omnipotent.net (Gareth Watts)
-@c @image{Flags/great-britain} UK [Omnipotent/UK] @
-@c @uref{http://mysql.omnipotent.net/, WWW}
-@c @uref{ftp://mysql.omnipotent.net/, FTP}
+@c @image{Flags/great-britain}
+UK [Omnipotent/UK] @
+@uref{http://mysql.omnipotent.net/, WWW}
+@uref{ftp://mysql.omnipotent.net/, FTP}
@item
@c keet@mordor.plig.net (Christiaan Keet)
@@ -3776,12 +3776,12 @@ UK [PLiG/UK] @
@c @uref{http://sunsite.org.uk/packages/mysql/, WWW}
@c @uref{ftp://sunsite.org.uk/packages/mysql/, FTP}
-@c @item
-@c Not ok 20000919; Old site (Matt)
+@item
@c sander@paco.net (Alexander Ivanov)
-@c @image{Flags/ukraine} Ukraine [PACO] @
-@c @uref{http://mysql.paco.net.ua, WWW}
-@c @uref{ftp://mysql.paco.net.ua/, FTP}
+@c @image{Flags/ukraine}
+Ukraine [PACO] @
+@uref{http://mysql.paco.net.ua, WWW}
+@uref{ftp://mysql.paco.net.ua/, FTP}
@end itemize
@@ -3879,12 +3879,12 @@ USA [Circle Net/North Carolina] @
@c @image{Flags/usa} USA [pingzero/Los Angeles] @
@c @uref{http://mysql.pingzero.net/, WWW}
-@c @item
-@c Not ok 20000919; Out of date (Matt)
+@item
@c EMAIL: ftpkeeper@mirror.sit.wisc.edu
-@c @image{Flags/usa} USA [Wisconsin University/Wisconsin] @
-@c @uref{http://mirror.sit.wisc.edu/mysql/, WWW}
-@c @uref{ftp://mirror.sit.wisc.edu/mirrors/mysql/, FTP}
+@c @image{Flags/usa}
+USA [Wisconsin University/Wisconsin] @
+@uref{http://mirror.sit.wisc.edu/mysql/, WWW}
+@uref{ftp://mirror.sit.wisc.edu/mirrors/mysql/, FTP}
@c @item
@c Not ok 20000919; Out of date (Matt)
@@ -4001,11 +4001,11 @@ Singapore [HJC] @
@c @image{Flags/taiwan} Taiwan [HT] @
@c @uref{http://mysql.ht.net.tw, WWW}
-@c @item
-@c Not ok 20000919; Old site (Matt)
+@item
@c EMAIL: linda@ttn.com.tw (Linda Hu)
-@c @image{Flags/taiwan} Taiwan [TTN] @
-@c @uref{http://mysql.ttn.net, WWW}
+@c @image{Flags/taiwan}
+Taiwan [TTN] @
+@uref{http://mysql.ttn.net, WWW}
@c @item
@c Ok 980321 No connect -> removed 990730
@@ -23935,8 +23935,13 @@ of the are available starting in 3.23.15 unless indicated otherwise.
@code{log-bin}
@tab Should be set on the master. Tells it to keep a binary update log.
If a parameter is specified, the log will be written to the specified
-location.
-(Set on @strong{Master}, Example: @code{log-bin})
+location. Note that if you give it a parameter with an extention
+(eg. @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 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.
@item
@code{log-bin-index}
@@ -36742,6 +36747,13 @@ though, so 3.23 is not released as a stable version yet.
@appendixsubsec Changes in release 3.23.25
@itemize @bullet
@item
+@code{FLUSH LOGS} broke replication if one had @code{log-bin} with
+a log with explicit extension
+@item
+Fixed a bug in MyISAM with packed multi-part keys.
+@item
+Fixed crash when using @code{CHECK TABLE} on Windows.
+@item
Fixed a bug where @code{FULLTEXT} index always used the koi8_ukr
character set.
@item
@@ -40860,6 +40872,9 @@ Fixed @code{DISTINCT} with calculated columns.
@itemize @bullet
@item
+@code{mysqldump} on a @code{MERGE} table doesn't include the current
+mapped tables.
+@item
For the moment @code{MATCH} only works with @code{SELECT} statements.
@item
You cannot build in another directory when using
diff --git a/client/mysql.cc b/client/mysql.cc
index 71d9310785d..292a273594a 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -254,13 +254,9 @@ int main(int argc,char *argv[])
if (sql_connect(current_host,current_db,current_user,opt_password,
opt_silent))
{
- if (connected)
- mysql_close(&mysql);
- glob_buffer.free();
- old_buffer.free();
- batch_readline_end(status.line_buff);
- my_end(0);
- exit(1);
+ quick=1; // Avoid history
+ status.exit_status=1;
+ mysql_end(-1);
}
if (!status.batch)
ignore_errors=1; // Don't abort monitor
@@ -324,7 +320,8 @@ sig_handler mysql_end(int sig)
batch_readline_end(status.line_buff);
completion_hash_free(&ht);
#endif
- put_info(sig ? "Aborted" : "Bye", INFO_RESULT);
+ if (sig >= 0)
+ put_info(sig ? "Aborted" : "Bye", INFO_RESULT);
glob_buffer.free();
old_buffer.free();
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
@@ -402,7 +399,7 @@ CHANGEABLE_VAR changeable_vars[] = {
static void usage(int version)
{
- printf("%s Ver 10.11 Distrib %s, for %s (%s)\n",
+ printf("%s Ver 10.12 Distrib %s, for %s (%s)\n",
my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
if (version)
return;
@@ -603,7 +600,7 @@ static int get_options(int argc, char **argv)
break;
case 'W':
#ifdef __WIN__
- opt_mysql_unix_port=MYSQL_NAMEDPIPE;
+ opt_mysql_unix_port=my_strdup(MYSQL_NAMEDPIPE,MYF(0));
#endif
break;
case 'V': usage(1); exit(0);
@@ -1013,7 +1010,7 @@ static void build_completion_hash(bool skip_rehash,bool write_info)
int i,j,num_fields;
DBUG_ENTER("build_completion_hash");
- if (status.batch || quick)
+ if (status.batch || quick || !current_db)
DBUG_VOID_RETURN; // We don't need completion in batches
completion_hash_clean(&ht);
diff --git a/include/config-win.h b/include/config-win.h
index 4dc3ecd74e2..d9a6ce8d56b 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -82,6 +82,7 @@
#define SIGQUIT SIGTERM /* No SIGQUIT */
#undef _REENTRANT /* Crashes something for win32 */
+#undef SAFE_MUTEX /* Can't be used on windows */
#define LONGLONG_MIN ((__int64) 0x8000000000000000)
#define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF)
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 71ad5e42bf2..e34fffbb239 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -60,6 +60,7 @@ typedef int pthread_mutexattr_t;
#define pthread_handler_decl(A,B) unsigned __cdecl A(void *B)
typedef unsigned (__cdecl *pthread_handler)(void *);
+void win_pthread_init(void);
int win_pthread_setspecific(void *A,void *B,uint length);
int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
@@ -502,15 +503,15 @@ extern int pthread_dummy(int);
struct st_my_thread_var
{
int thr_errno;
- int cmp_length;
- volatile int abort;
- long id;
pthread_cond_t suspend, *current_cond;
pthread_mutex_t mutex, *current_mutex;
pthread_t pthread_self;
+ long id;
+ int cmp_length;
+ volatile int abort;
#ifndef DBUG_OFF
- char name[THREAD_NAME_SIZE+1];
gptr dbug;
+ char name[THREAD_NAME_SIZE+1];
#endif
};
diff --git a/include/myisam.h b/include/myisam.h
index b4e51c5f625..33d2e258b03 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -320,7 +320,7 @@ typedef struct st_mi_check_param
ulonglong max_data_file_length;
ulonglong keys_in_use;
my_off_t new_file_pos,key_file_blocks;
- my_off_t keydata,totaldata,key_blocks;
+ my_off_t keydata,totaldata,key_blocks,start_check_pos;
ha_checksum record_checksum,glob_crc;
char temp_filename[FN_REFLEN],*isam_file_name,*tmpdir;
int tmpfile_createflag;
diff --git a/include/myisammrg.h b/include/myisammrg.h
index 6b1124fa180..a797c954614 100644
--- a/include/myisammrg.h
+++ b/include/myisammrg.h
@@ -59,7 +59,7 @@ typedef struct st_myrg_info
ulonglong records; /* records in tables */
ulonglong del; /* Removed records */
ulonglong data_file_length;
- uint tables,options,reclength;
+ uint tables,options,reclength,keys;
my_bool cache_in_use;
LIST open_list;
QUEUE by_key;
diff --git a/myisam/ft_stopwords.c b/myisam/ft_stopwords.c
index ce08fee9e1e..d796b87ed71 100644
--- a/myisam/ft_stopwords.c
+++ b/myisam/ft_stopwords.c
@@ -72,6 +72,7 @@ void ft_free_stopwords()
if (stopwords3)
{
delete_tree(stopwords3); /* purecov: inspected */
+ my_free((char*) stopwords3,MYF(0));
stopwords3=0;
}
}
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index c556c816590..1d5806486b1 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -94,6 +94,7 @@ void myisamchk_init(MI_CHECK *param)
param->tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL;
param->myf_rw=MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL);
param->sort_info.param=param;
+ param->start_check_pos=0;
}
/* Check delete links */
@@ -668,7 +669,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
intern_record_checksum=param->glob_crc=0;
LINT_INIT(left_length); LINT_INIT(start_recpos); LINT_INIT(to);
got_error=error=0;
- empty=pos=info->s->pack.header_length;
+ empty=info->s->pack.header_length;
/* Check how to calculate checksum of rows */
static_row_size=1;
@@ -685,6 +686,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
}
}
+ pos=my_b_tell(&param->read_cache);
bzero((char*) key_checksum, info->s->base.keys * sizeof(key_checksum[0]));
while (pos < info->state->data_file_length)
{
diff --git a/myisam/mi_search.c b/myisam/mi_search.c
index 8fb35f3af65..eead2a84c29 100644
--- a/myisam/mi_search.c
+++ b/myisam/mi_search.c
@@ -1407,7 +1407,7 @@ _mi_calc_var_key_length(MI_KEYDEF *keyinfo,uint nod_flag,
Keys are compressed the following way:
If the max length of first key segment <= 127 characters the prefix is
- 1 byte else its 2 byte
+ 1 byte else it's 2 byte
prefix byte The high bit is set if this is a prefix for the prev key
length Packed length if the previous was a prefix byte
@@ -1492,7 +1492,7 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key,
if (new_key_length && new_key_length == org_key_length)
same_length=1;
else if (new_key_length > org_key_length)
- end=key+ org_key_length+1;
+ end=key + org_key_length;
if (sort_order) /* SerG */
{
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index ed1681c728c..73cd50b4e49 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -146,7 +146,7 @@ static CHANGEABLE_VAR changeable_vars[] = {
{ "decode_bits",(long*) &decode_bits,9L,4L,17L,0L,1L },
{ NullS,(long*) 0,0L,0L,0L,0L,0L,} };
-enum options {OPT_CHARSETS_DIR=256, OPT_SET_CHARSET};
+enum options {OPT_CHARSETS_DIR=256, OPT_SET_CHARSET,OPT_START_CHECK_POS};
static struct option long_options[] =
@@ -173,6 +173,7 @@ static struct option long_options[] =
{"read-only", no_argument, 0, 'T'},
{"recover", no_argument, 0, 'r'},
{"safe-recover", no_argument, 0, 'o'},
+ {"start-check-pos", required_argument, 0, OPT_START_CHECK_POS},
{"set-auto-increment",optional_argument, 0, 'A'},
{"set-character-set",required_argument,0,OPT_SET_CHARSET},
{"set-variable", required_argument, 0, 'O'},
@@ -190,7 +191,7 @@ static struct option long_options[] =
static void print_version(void)
{
- printf("%s Ver 1.30 for %s at %s\n",my_progname,SYSTEM_TYPE,
+ printf("%s Ver 1.31 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
}
@@ -416,6 +417,11 @@ static void get_options(register int *argc,register char ***argv)
case OPT_SET_CHARSET:
set_charset_name=optarg;
break;
+#ifdef DEBUG /* Only useful if debugging */
+ case OPT_START_CHECK_POS:
+ check_param.start_check_pos=strtoull(optarg,NULL,0);
+ break;
+#endif
case '?':
usage();
exit(0);
@@ -732,7 +738,8 @@ static int myisamchk(MI_CHECK *param, my_string filename)
error =chk_size(param,info);
if (!error || !(param->testflag & (T_FAST | T_FORCE_CREATE)))
error|=chk_del(param, info,param->testflag);
- if (!error || !(param->testflag & (T_FAST | T_FORCE_CREATE)))
+ if ((!error || !(param->testflag & (T_FAST | T_FORCE_CREATE)) &&
+ !param->start_check_pos))
{
error|=chk_key(param, info);
if (!error && (param->testflag & (T_STATISTICS | T_AUTO_INC)))
@@ -745,8 +752,12 @@ static int myisamchk(MI_CHECK *param, my_string filename)
VOID(init_key_cache(param->use_buffers,(uint) NEAD_MEM));
VOID(init_io_cache(&param->read_cache,datafile,
(uint) param->read_buffer_length,
- READ_CACHE,share->pack.header_length,1,
- MYF(MY_WME)));
+ READ_CACHE,
+ (param->start_check_pos ?
+ param->start_check_pos :
+ share->pack.header_length),
+ 1,
+ MYF(MY_WME)));
lock_memory(param);
if ((info->s->options & (HA_OPTION_PACK_RECORD |
HA_OPTION_COMPRESS_RECORD)) ||
diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c
index 7f80a88dddc..9159b4edb0f 100644
--- a/myisammrg/myrg_open.c
+++ b/myisammrg/myrg_open.c
@@ -86,6 +86,7 @@ int handle_locking;
*m_info=info;
m_info->open_tables=(MYRG_TABLE *) (m_info+1);
m_info->tables=files;
+ errpos=2;
for (i=files ; i-- > 0 ; )
{
@@ -104,16 +105,21 @@ int handle_locking;
m_info->open_tables[i].file_offset=(my_off_t) file_offset;
file_offset+=m_info->open_tables[i].table->state->data_file_length;
}
- errpos=2;
if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L)
{
my_errno=HA_ERR_RECORD_FILE_FULL;
goto err;
}
/* Allocate memory for queue */
- if (m_info->open_tables->table->s->base.keys &&
- _myrg_init_queue(m_info,0,HA_READ_KEY_EXACT))
- goto err;
+ m_info->keys=0;
+ if (files)
+ {
+ if ((m_info->keys=m_info->open_tables->table->s->base.keys) &&
+ _myrg_init_queue(m_info,0,HA_READ_KEY_EXACT))
+ goto err;
+ }
+ else
+ bzero((char*) &m_info->by_key,sizeof(m_info->by_key));
m_info->end_table=m_info->open_tables+files;
m_info->last_used_table=m_info->open_tables;
diff --git a/myisammrg/myrg_queue.c b/myisammrg/myrg_queue.c
index 4d94f984722..d6f831db48c 100644
--- a/myisammrg/myrg_queue.c
+++ b/myisammrg/myrg_queue.c
@@ -34,21 +34,24 @@ int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag)
int error=0;
QUEUE *q= &(info->by_key);
- if (!is_queue_inited(q))
+ if (inx < (int) info->keys)
{
- if (init_queue(q,info->tables, 0,
- (myisam_readnext_vec[search_flag] == SEARCH_SMALLER),
- queue_key_cmp,
- info->open_tables->table->s->keyinfo[inx].seg))
- error=my_errno;
- }
- else
- {
- if (reinit_queue(q,info->tables, 0,
- (myisam_readnext_vec[search_flag] == SEARCH_SMALLER),
- queue_key_cmp,
- info->open_tables->table->s->keyinfo[inx].seg))
- error=my_errno;
+ if (!is_queue_inited(q))
+ {
+ if (init_queue(q,info->tables, 0,
+ (myisam_readnext_vec[search_flag] == SEARCH_SMALLER),
+ queue_key_cmp,
+ info->open_tables->table->s->keyinfo[inx].seg))
+ error=my_errno;
+ }
+ else
+ {
+ if (reinit_queue(q,info->tables, 0,
+ (myisam_readnext_vec[search_flag] == SEARCH_SMALLER),
+ queue_key_cmp,
+ info->open_tables->table->s->keyinfo[inx].seg))
+ error=my_errno;
+ }
}
return error;
}
diff --git a/myisammrg/myrg_rfirst.c b/myisammrg/myrg_rfirst.c
index 3f29414f076..0625e848660 100644
--- a/myisammrg/myrg_rfirst.c
+++ b/myisammrg/myrg_rfirst.c
@@ -27,7 +27,7 @@ int myrg_rfirst(MYRG_INFO *info, byte *buf, int inx)
if (_myrg_init_queue(info,inx,HA_READ_KEY_OR_NEXT))
return my_errno;
- for (table=info->open_tables ; table < info->end_table ; table++)
+ for (table=info->open_tables ; table != info->end_table ; table++)
{
if ((err=mi_rfirst(table->table,NULL,inx)))
{
diff --git a/myisammrg/myrg_rkey.c b/myisammrg/myrg_rkey.c
index 465d61ce3c6..d66d5ec3fe7 100644
--- a/myisammrg/myrg_rkey.c
+++ b/myisammrg/myrg_rkey.c
@@ -49,7 +49,7 @@ int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key,
if (_myrg_init_queue(info,inx,search_flag))
return my_errno;
- for (table=info->open_tables ; table < info->end_table ; table++)
+ for (table=info->open_tables ; table != info->end_table ; table++)
{
mi=table->table;
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 6b75444f3fc..f24c8393ba9 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -35,9 +35,6 @@ pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache,
#ifndef HAVE_LOCALTIME_R
pthread_mutex_t LOCK_localtime_r;
#endif
-#ifdef __WIN__
-pthread_mutex_t THR_LOCK_thread;
-#endif
/* FIXME Note. TlsAlloc does not set an auto destructor, so
the function my_thread_global_free must be called from
@@ -60,7 +57,7 @@ my_bool my_thread_global_init(void)
pthread_mutex_init(&THR_LOCK_net,NULL);
pthread_mutex_init(&THR_LOCK_charset,NULL);
#ifdef __WIN__
- pthread_mutex_init(&THR_LOCK_thread,NULL);
+ win_pthread_init();
#endif
#ifndef HAVE_LOCALTIME_R
pthread_mutex_init(&LOCK_localtime_r,NULL);
@@ -78,7 +75,7 @@ void my_thread_global_end(void)
static long thread_id=0;
/*
- We can't use mutex_locks here if we re using windows as
+ We can't use mutex_locks here if we are using windows as
we may have compiled the program with SAFE_MUTEX, in which
case the checking of mutex_locks will not work until
the pthread_self thread specific variable is initialized.
diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c
index e410121af98..6a99fa0bb02 100644
--- a/mysys/my_winthread.c
+++ b/mysys/my_winthread.c
@@ -19,13 +19,16 @@
** Simulation of posix threads calls for WIN95 and NT
*****************************************************************************/
+/* SAFE_MUTEX will not work until the thread structure is up to date */
+#undef SAFE_MUTEX
+
#include "mysys_priv.h"
#if defined(THREAD) && defined(__WIN__)
#include <m_string.h>
#undef getpid
#include <process.h>
-extern pthread_mutex_t THR_LOCK_thread;
+static pthread_mutex_t THR_LOCK_thread;
struct pthread_map
{
@@ -34,6 +37,11 @@ struct pthread_map
void *param;
};
+void win_pthread_init(void)
+{
+ pthread_mutex_init(&THR_LOCK_thread,NULL);
+}
+
/*
** We have tried to use '_beginthreadex' instead of '_beginthread' here
** but in this case the program leaks about 512 characters for each
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 73d1d24d9a4..7cc3b30aaf9 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -67,6 +67,7 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line)
{
fprintf(stderr,"safe_mutex: Trying to lock mutex at %s, line %d, when the mutex was already locked at %s, line %d\n",
file,line,mp->file,mp->line);
+ fflush(stderr);
abort();
}
pthread_mutex_unlock(&mp->global);
@@ -75,11 +76,13 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line)
{
fprintf(stderr,"Got error %d when trying to lock mutex at %s, line %d\n",
error, file, line);
+ fflush(stderr);
abort();
}
if (mp->count++)
{
fprintf(stderr,"safe_mutex: Error in thread libray: Got mutex at %s, line %d more than 1 time\n", file,line);
+ fflush(stderr);
abort();
}
mp->thread=pthread_self();
@@ -98,12 +101,14 @@ int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line)
{
fprintf(stderr,"safe_mutex: Trying to unlock mutex that wasn't locked at %s, line %d\n Last used at %s, line: %d\n",
file,line,mp->file ? mp->file : "",mp->line);
+ fflush(stderr);
abort();
}
if (!pthread_equal(pthread_self(),mp->thread))
{
fprintf(stderr,"safe_mutex: Trying to unlock mutex at %s, line %d that was locked by another thread at: %s, line: %d\n",
file,line,mp->file,mp->line);
+ fflush(stderr);
abort();
}
mp->count--;
@@ -115,6 +120,7 @@ int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line)
if (error)
{
fprintf(stderr,"safe_mutex: Got error: %d when trying to unlock mutex at %s, line %d\n", error, file, line);
+ fflush(stderr);
abort();
}
#endif /* __WIN__ */
@@ -131,12 +137,14 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
if (mp->count == 0)
{
fprintf(stderr,"safe_mutex: Trying to cond_wait on a unlocked mutex at %s, line %d\n",file,line);
+ fflush(stderr);
abort();
}
if (!pthread_equal(pthread_self(),mp->thread))
{
fprintf(stderr,"safe_mutex: Trying to cond_wait on a mutex at %s, line %d that was locked by another thread at: %s, line: %d\n",
file,line,mp->file,mp->line);
+ fflush(stderr);
abort();
}
@@ -144,6 +152,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
{
fprintf(stderr,"safe_mutex: Count was %d on locked mutex at %s, line %d\n",
mp->count+1, file, line);
+ fflush(stderr);
abort();
}
pthread_mutex_unlock(&mp->global);
@@ -152,6 +161,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
if (error)
{
fprintf(stderr,"safe_mutex: Got error: %d when doing a safe_mutex_wait at %s, line %d\n", error, file, line);
+ fflush(stderr);
abort();
}
if (mp->count++)
@@ -159,6 +169,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
fprintf(stderr,
"safe_mutex: Count was %d in thread %lx when locking mutex at %s, line %d\n",
mp->count-1, my_thread_id(), file, line);
+ fflush(stderr);
abort();
}
mp->thread=pthread_self();
@@ -178,6 +189,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
if (mp->count != 1 || !pthread_equal(pthread_self(),mp->thread))
{
fprintf(stderr,"safe_mutex: Trying to cond_wait at %s, line %d on a not hold mutex\n",file,line);
+ fflush(stderr);
abort();
}
mp->count--; /* Mutex will be released */
@@ -195,6 +207,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
fprintf(stderr,
"safe_mutex: Count was %d in thread %lx when locking mutex at %s, line %d (error: %d)\n",
mp->count-1, my_thread_id(), file, line, error);
+ fflush(stderr);
abort();
}
mp->thread=pthread_self();
@@ -206,20 +219,22 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
{
- int error;
+ int error=0;
if (mp->count != 0)
{
fprintf(stderr,"safe_mutex: Trying to destroy a mutex that was locked at %s, line %d at %s, line %d\n",
mp->file,mp->line, file, line);
+ fflush(stderr);
abort();
}
#ifdef __WIN__
- error=0;
pthread_mutex_destroy(&mp->global);
pthread_mutex_destroy(&mp->mutex);
#else
- error= (int) (pthread_mutex_destroy(&mp->global) ||
- pthread_mutex_destroy(&mp->mutex));
+ if (pthread_mutex_destroy(&mp->global))
+ error=1;
+ if (pthread_mutex_destroy(&mp->mutex))
+ error=1;
#endif
return error;
}
diff --git a/scripts/safe_mysqld.sh b/scripts/safe_mysqld.sh
index 5a5f8dddb02..91d99c283f6 100644
--- a/scripts/safe_mysqld.sh
+++ b/scripts/safe_mysqld.sh
@@ -92,10 +92,10 @@ NOHUP_NICENESS="nohup"
if test -w /
then
NOHUP_NICENESS=`nohup nice`
- if test $? -ne 0 || test x"$NOHUP_NICENESS" = x0 || test ! nice --1 echo foo > /dev/null 2>&1; then
- NOHUP_NICENESS="nohup"
- else
+ if test $? -eq 0 && test x"$NOHUP_NICENESS" != x0 && nice --1 echo foo > /dev/null 2>&1; then
NOHUP_NICENESS="nice --$NOHUP_NICENESS nohup"
+ else
+ NOHUP_NICENESS="nohup"
fi
fi
@@ -193,4 +193,5 @@ do
echo "`date +'%y%m%d %H:%M:%S mysqld restarted'`" | tee -a $err_log
done
-echo -e "`date +'%y%m%d %H:%M:%S mysqld ended\n'`" | tee -a $err_log
+echo "`date +'%y%m%d %H:%M:%S mysqld ended\n'`" | tee -a $err_log
+echo "" | tee -a $err_log
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index 45822444527..b0043f3f828 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -48,7 +48,7 @@ int ha_myisammrg::open(const char *name, int mode, int test_if_locked)
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED))
myrg_extra(file,HA_EXTRA_WAIT_LOCK);
- if (table->reclength != mean_rec_length)
+ if (table->reclength != mean_rec_length && mean_rec_length)
{
DBUG_PRINT("error",("reclength: %d mean_rec_length: %d",
table->reclength, mean_rec_length));
diff --git a/sql/log.cc b/sql/log.cc
index d23c71e6ef3..94cd553bfce 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -77,7 +77,8 @@ static int find_uniq_filename(char *name)
MYSQL_LOG::MYSQL_LOG(): file(0),index_file(0),last_time(0),query_start(0),
- name(0), log_type(LOG_CLOSED),write_error(0),inited(0)
+ name(0), log_type(LOG_CLOSED),write_error(0),inited(0),
+ no_rotate(0)
{
/*
We don't want to intialize LOCK_Log here as the thread system may
@@ -133,6 +134,8 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
inited=1;
(void) pthread_mutex_init(&LOCK_log,NULL);
(void) pthread_mutex_init(&LOCK_index, NULL);
+ if(log_type_arg == LOG_BIN && *fn_ext(log_name))
+ no_rotate = 1;
}
log_type=log_type_arg;
@@ -320,6 +323,9 @@ void MYSQL_LOG::new_file()
{
if (file)
{
+ if(no_rotate) // do not rotate logs that are marked non-rotatable
+ return; // ( for binlog with constant name)
+
char new_name[FN_REFLEN], *old_name=name;
VOID(pthread_mutex_lock(&LOCK_log));
if (generate_new_name(new_name, name))
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 9cb5644fe7b..90b68f074e5 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2400,7 +2400,7 @@ struct show_var_st init_vars[]= {
{"interactive_timeout", (char*) &net_interactive_timeout, SHOW_LONG},
{"key_buffer_size", (char*) &keybuff_size, SHOW_LONG},
{"language", language, SHOW_CHAR},
-#ifdef HAVE_MEMLOCKALL
+#ifdef HAVE_MLOCKALL
{"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL},
#endif
{"log", (char*) &opt_log, SHOW_BOOL},
diff --git a/sql/share/Makefile.am b/sql/share/Makefile.am
index 6080899c33e..cee8d4e2d0b 100644
--- a/sql/share/Makefile.am
+++ b/sql/share/Makefile.am
@@ -16,7 +16,8 @@ install-data-local:
$(DESTDIR)$(pkgdatadir)/$$lang/errmsg.txt; \
done
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/charsets
- (cd $(srcdir)/charsets; for f in Index README "*.conf"; \
+ (for f in $(srcdir)/charsets/Index $(srcdir)/charsets/README $(srcdir)/charsets/*.conf; \
do \
- $(INSTALL_DATA) $$f $(DESTDIR)$(pkgdatadir)/charsets/; \
+ n=`basename $$f`; \
+ $(INSTALL_DATA) $$f $(DESTDIR)$(pkgdatadir)/charsets/$$n; \
done)
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 7c67b0e7a4a..9e4293c7b62 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -85,6 +85,10 @@ class MYSQL_LOG {
char time_buff[20],db[NAME_LEN+1];
char log_file_name[FN_REFLEN],index_file_name[FN_REFLEN];
bool write_error,inited;
+ bool no_rotate; // for binlog - if log name can never change
+ // we should not try to rotate it or write any rotation events
+ // the user should use FLUSH MASTER instead of FLUSH LOGS for
+ // purging
public:
MYSQL_LOG();
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 67ce0f6ff54..7ca2d3c419e 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -81,7 +81,8 @@ bool String::realloc(uint32 alloc_length)
}
else if ((new_ptr= (char*) my_malloc(len,MYF(MY_WME))))
{
- memcpy(new_ptr,Ptr,str_length);
+ if (str_length) // Avoid bugs in memcpy on AIX
+ memcpy(new_ptr,Ptr,str_length);
new_ptr[str_length]=0;
Ptr=new_ptr;
Alloced_length=len;
@@ -221,8 +222,8 @@ bool String::copy(const char *str,uint32 arg_length)
{
if (alloc(arg_length))
return TRUE;
- str_length=arg_length;
- memcpy(Ptr,str,arg_length);
+ if ((str_length=arg_length))
+ memcpy(Ptr,str,arg_length);
Ptr[arg_length]=0;
return FALSE;
}
@@ -251,17 +252,21 @@ void String::strip_sp()
bool String::append(const String &s)
{
- if (realloc(str_length+s.length()))
- return TRUE;
- memcpy(Ptr+str_length,s.ptr(),s.length());
- str_length+=s.length();
+ if (s.length())
+ {
+ if (realloc(str_length+s.length()))
+ return TRUE;
+ memcpy(Ptr+str_length,s.ptr(),s.length());
+ str_length+=s.length();
+ }
return FALSE;
}
bool String::append(const char *s,uint32 arg_length)
{
if (!arg_length) // Default argument
- arg_length= (uint32) strlen(s);
+ if (!(arg_length= (uint32) strlen(s)))
+ return FALSE;
if (realloc(str_length+arg_length))
return TRUE;
memcpy(Ptr+str_length,s,arg_length);
@@ -398,7 +403,8 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to)
{
if (diff < 0)
{
- memcpy(Ptr+offset,to.ptr(),to.length());
+ if (to.length())
+ memcpy(Ptr+offset,to.ptr(),to.length());
bmove(Ptr+offset+to.length(),Ptr+offset+arg_length,
str_length-offset-arg_length);
}
@@ -411,7 +417,8 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to)
bmove_upp(Ptr+str_length+diff,Ptr+str_length,
str_length-offset-arg_length);
}
- memcpy(Ptr+offset,to.ptr(),to.length());
+ if (to.length())
+ memcpy(Ptr+offset,to.ptr(),to.length());
}
str_length+=(uint32) diff;
}
@@ -502,8 +509,8 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
}
if (to->realloc(from_length))
return from; // Actually an error
- to->str_length=min(from->str_length,from_length);
- memcpy(to->Ptr,from->Ptr,to->str_length);
+ if ((to->str_length=min(from->str_length,from_length)))
+ memcpy(to->Ptr,from->Ptr,to->str_length);
return to;
}