Commit 5f124862 authored by unknown's avatar unknown

Fixes for MyISAM and packed keys + AIX


Docs/manual.texi:
  Updated changelog
client/mysql.cc:
  Free all memory, even if we can't connect to the server
include/config-win.h:
  Ensure that we don't use SAFE_MUTEX on windows
include/my_pthread.h:
  Optimze struct for Ia64
include/myisam.h:
  Hack for debugging BIG tables
myisam/mi_check.c:
  Hack for debugging BIG tables
myisam/mi_search.c:
  Fixed bug in packed keys
myisam/myisamchk.c:
  Hack for debugging BIG tables
mysys/thr_mutex.c:
  Make safe_mutex safe for windows
scripts/safe_mysqld.sh:
  Fix nice test and echo output
sql/share/Makefile.am:
  Fix character sets
sql/sql_string.cc:
  Fixes for AIX (which can't handle that the length argument is 0)
parent 5e955288
...@@ -36742,6 +36742,10 @@ though, so 3.23 is not released as a stable version yet. ...@@ -36742,6 +36742,10 @@ though, so 3.23 is not released as a stable version yet.
@appendixsubsec Changes in release 3.23.25 @appendixsubsec Changes in release 3.23.25
@itemize @bullet @itemize @bullet
@item @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 Fixed a bug where @code{FULLTEXT} index always used the koi8_ukr
character set. character set.
@item @item
...@@ -254,13 +254,9 @@ int main(int argc,char *argv[]) ...@@ -254,13 +254,9 @@ int main(int argc,char *argv[])
if (sql_connect(current_host,current_db,current_user,opt_password, if (sql_connect(current_host,current_db,current_user,opt_password,
opt_silent)) opt_silent))
{ {
if (connected) quick=1; // Avoid history
mysql_close(&mysql); status.exit_status=1;
glob_buffer.free(); mysql_end(-1);
old_buffer.free();
batch_readline_end(status.line_buff);
my_end(0);
exit(1);
} }
if (!status.batch) if (!status.batch)
ignore_errors=1; // Don't abort monitor ignore_errors=1; // Don't abort monitor
...@@ -324,6 +320,7 @@ sig_handler mysql_end(int sig) ...@@ -324,6 +320,7 @@ sig_handler mysql_end(int sig)
batch_readline_end(status.line_buff); batch_readline_end(status.line_buff);
completion_hash_free(&ht); completion_hash_free(&ht);
#endif #endif
if (sig >= 0)
put_info(sig ? "Aborted" : "Bye", INFO_RESULT); put_info(sig ? "Aborted" : "Bye", INFO_RESULT);
glob_buffer.free(); glob_buffer.free();
old_buffer.free(); old_buffer.free();
...@@ -402,7 +399,7 @@ CHANGEABLE_VAR changeable_vars[] = { ...@@ -402,7 +399,7 @@ CHANGEABLE_VAR changeable_vars[] = {
static void usage(int version) 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); my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
if (version) if (version)
return; return;
...@@ -603,7 +600,7 @@ static int get_options(int argc, char **argv) ...@@ -603,7 +600,7 @@ static int get_options(int argc, char **argv)
break; break;
case 'W': case 'W':
#ifdef __WIN__ #ifdef __WIN__
opt_mysql_unix_port=MYSQL_NAMEDPIPE; opt_mysql_unix_port=my_strdup(MYSQL_NAMEDPIPE,MYF(0));
#endif #endif
break; break;
case 'V': usage(1); exit(0); case 'V': usage(1); exit(0);
...@@ -1013,7 +1010,7 @@ static void build_completion_hash(bool skip_rehash,bool write_info) ...@@ -1013,7 +1010,7 @@ static void build_completion_hash(bool skip_rehash,bool write_info)
int i,j,num_fields; int i,j,num_fields;
DBUG_ENTER("build_completion_hash"); 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 DBUG_VOID_RETURN; // We don't need completion in batches
completion_hash_clean(&ht); completion_hash_clean(&ht);
......
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
#define SIGQUIT SIGTERM /* No SIGQUIT */ #define SIGQUIT SIGTERM /* No SIGQUIT */
#undef _REENTRANT /* Crashes something for win32 */ #undef _REENTRANT /* Crashes something for win32 */
#undef SAFE_MUTEX /* Can't be used on windows */
#define LONGLONG_MIN ((__int64) 0x8000000000000000) #define LONGLONG_MIN ((__int64) 0x8000000000000000)
#define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF) #define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF)
......
...@@ -503,15 +503,15 @@ extern int pthread_dummy(int); ...@@ -503,15 +503,15 @@ extern int pthread_dummy(int);
struct st_my_thread_var struct st_my_thread_var
{ {
int thr_errno; int thr_errno;
int cmp_length;
volatile int abort;
long id;
pthread_cond_t suspend, *current_cond; pthread_cond_t suspend, *current_cond;
pthread_mutex_t mutex, *current_mutex; pthread_mutex_t mutex, *current_mutex;
pthread_t pthread_self; pthread_t pthread_self;
long id;
int cmp_length;
volatile int abort;
#ifndef DBUG_OFF #ifndef DBUG_OFF
char name[THREAD_NAME_SIZE+1];
gptr dbug; gptr dbug;
char name[THREAD_NAME_SIZE+1];
#endif #endif
}; };
......
...@@ -320,7 +320,7 @@ typedef struct st_mi_check_param ...@@ -320,7 +320,7 @@ typedef struct st_mi_check_param
ulonglong max_data_file_length; ulonglong max_data_file_length;
ulonglong keys_in_use; ulonglong keys_in_use;
my_off_t new_file_pos,key_file_blocks; 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; ha_checksum record_checksum,glob_crc;
char temp_filename[FN_REFLEN],*isam_file_name,*tmpdir; char temp_filename[FN_REFLEN],*isam_file_name,*tmpdir;
int tmpfile_createflag; int tmpfile_createflag;
......
...@@ -94,6 +94,7 @@ void myisamchk_init(MI_CHECK *param) ...@@ -94,6 +94,7 @@ void myisamchk_init(MI_CHECK *param)
param->tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL; param->tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL;
param->myf_rw=MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL); param->myf_rw=MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL);
param->sort_info.param=param; param->sort_info.param=param;
param->start_check_pos=0;
} }
/* Check delete links */ /* Check delete links */
...@@ -668,7 +669,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) ...@@ -668,7 +669,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
intern_record_checksum=param->glob_crc=0; intern_record_checksum=param->glob_crc=0;
LINT_INIT(left_length); LINT_INIT(start_recpos); LINT_INIT(to); LINT_INIT(left_length); LINT_INIT(start_recpos); LINT_INIT(to);
got_error=error=0; got_error=error=0;
empty=pos=info->s->pack.header_length; empty=info->s->pack.header_length;
/* Check how to calculate checksum of rows */ /* Check how to calculate checksum of rows */
static_row_size=1; static_row_size=1;
...@@ -685,6 +686,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) ...@@ -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])); bzero((char*) key_checksum, info->s->base.keys * sizeof(key_checksum[0]));
while (pos < info->state->data_file_length) while (pos < info->state->data_file_length)
{ {
......
...@@ -1407,7 +1407,7 @@ _mi_calc_var_key_length(MI_KEYDEF *keyinfo,uint nod_flag, ...@@ -1407,7 +1407,7 @@ _mi_calc_var_key_length(MI_KEYDEF *keyinfo,uint nod_flag,
Keys are compressed the following way: Keys are compressed the following way:
If the max length of first key segment <= 127 characters the prefix is 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 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 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, ...@@ -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) if (new_key_length && new_key_length == org_key_length)
same_length=1; same_length=1;
else if (new_key_length > org_key_length) else if (new_key_length > org_key_length)
end=key+ org_key_length+1; end=key + org_key_length;
if (sort_order) /* SerG */ if (sort_order) /* SerG */
{ {
......
...@@ -146,7 +146,7 @@ static CHANGEABLE_VAR changeable_vars[] = { ...@@ -146,7 +146,7 @@ static CHANGEABLE_VAR changeable_vars[] = {
{ "decode_bits",(long*) &decode_bits,9L,4L,17L,0L,1L }, { "decode_bits",(long*) &decode_bits,9L,4L,17L,0L,1L },
{ NullS,(long*) 0,0L,0L,0L,0L,0L,} }; { 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[] = static struct option long_options[] =
...@@ -173,6 +173,7 @@ static struct option long_options[] = ...@@ -173,6 +173,7 @@ static struct option long_options[] =
{"read-only", no_argument, 0, 'T'}, {"read-only", no_argument, 0, 'T'},
{"recover", no_argument, 0, 'r'}, {"recover", no_argument, 0, 'r'},
{"safe-recover", no_argument, 0, 'o'}, {"safe-recover", no_argument, 0, 'o'},
{"start-check-pos", required_argument, 0, OPT_START_CHECK_POS},
{"set-auto-increment",optional_argument, 0, 'A'}, {"set-auto-increment",optional_argument, 0, 'A'},
{"set-character-set",required_argument,0,OPT_SET_CHARSET}, {"set-character-set",required_argument,0,OPT_SET_CHARSET},
{"set-variable", required_argument, 0, 'O'}, {"set-variable", required_argument, 0, 'O'},
...@@ -190,7 +191,7 @@ static struct option long_options[] = ...@@ -190,7 +191,7 @@ static struct option long_options[] =
static void print_version(void) 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); MACHINE_TYPE);
} }
...@@ -416,6 +417,11 @@ static void get_options(register int *argc,register char ***argv) ...@@ -416,6 +417,11 @@ static void get_options(register int *argc,register char ***argv)
case OPT_SET_CHARSET: case OPT_SET_CHARSET:
set_charset_name=optarg; set_charset_name=optarg;
break; break;
#ifdef DEBUG /* Only useful if debugging */
case OPT_START_CHECK_POS:
check_param.start_check_pos=strtoull(optarg,NULL,0);
break;
#endif
case '?': case '?':
usage(); usage();
exit(0); exit(0);
...@@ -732,7 +738,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -732,7 +738,8 @@ static int myisamchk(MI_CHECK *param, my_string filename)
error =chk_size(param,info); error =chk_size(param,info);
if (!error || !(param->testflag & (T_FAST | T_FORCE_CREATE))) if (!error || !(param->testflag & (T_FAST | T_FORCE_CREATE)))
error|=chk_del(param, info,param->testflag); 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); error|=chk_key(param, info);
if (!error && (param->testflag & (T_STATISTICS | T_AUTO_INC))) if (!error && (param->testflag & (T_STATISTICS | T_AUTO_INC)))
...@@ -745,7 +752,11 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -745,7 +752,11 @@ static int myisamchk(MI_CHECK *param, my_string filename)
VOID(init_key_cache(param->use_buffers,(uint) NEAD_MEM)); VOID(init_key_cache(param->use_buffers,(uint) NEAD_MEM));
VOID(init_io_cache(&param->read_cache,datafile, VOID(init_io_cache(&param->read_cache,datafile,
(uint) param->read_buffer_length, (uint) param->read_buffer_length,
READ_CACHE,share->pack.header_length,1, READ_CACHE,
(param->start_check_pos ?
param->start_check_pos :
share->pack.header_length),
1,
MYF(MY_WME))); MYF(MY_WME)));
lock_memory(param); lock_memory(param);
if ((info->s->options & (HA_OPTION_PACK_RECORD | if ((info->s->options & (HA_OPTION_PACK_RECORD |
......
...@@ -219,7 +219,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, ...@@ -219,7 +219,7 @@ 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 safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
{ {
int error; int error=0;
if (mp->count != 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", fprintf(stderr,"safe_mutex: Trying to destroy a mutex that was locked at %s, line %d at %s, line %d\n",
...@@ -228,12 +228,13 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) ...@@ -228,12 +228,13 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
abort(); abort();
} }
#ifdef __WIN__ #ifdef __WIN__
error=0;
pthread_mutex_destroy(&mp->global); pthread_mutex_destroy(&mp->global);
pthread_mutex_destroy(&mp->mutex); pthread_mutex_destroy(&mp->mutex);
#else #else
error= (int) (pthread_mutex_destroy(&mp->global) || if (pthread_mutex_destroy(&mp->global))
pthread_mutex_destroy(&mp->mutex)); error=1;
if (pthread_mutex_destroy(&mp->mutex))
error=1;
#endif #endif
return error; return error;
} }
......
...@@ -92,10 +92,10 @@ NOHUP_NICENESS="nohup" ...@@ -92,10 +92,10 @@ NOHUP_NICENESS="nohup"
if test -w / if test -w /
then then
NOHUP_NICENESS=`nohup nice` NOHUP_NICENESS=`nohup nice`
if test $? -ne 0 || test x"$NOHUP_NICENESS" = x0 || test ! nice --1 echo foo > /dev/null 2>&1; then if test $? -eq 0 && test x"$NOHUP_NICENESS" != x0 && nice --1 echo foo > /dev/null 2>&1; then
NOHUP_NICENESS="nohup"
else
NOHUP_NICENESS="nice --$NOHUP_NICENESS nohup" NOHUP_NICENESS="nice --$NOHUP_NICENESS nohup"
else
NOHUP_NICENESS="nohup"
fi fi
fi fi
...@@ -193,4 +193,5 @@ do ...@@ -193,4 +193,5 @@ do
echo "`date +'%y%m%d %H:%M:%S mysqld restarted'`" | tee -a $err_log echo "`date +'%y%m%d %H:%M:%S mysqld restarted'`" | tee -a $err_log
done 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
...@@ -16,7 +16,8 @@ install-data-local: ...@@ -16,7 +16,8 @@ install-data-local:
$(DESTDIR)$(pkgdatadir)/$$lang/errmsg.txt; \ $(DESTDIR)$(pkgdatadir)/$$lang/errmsg.txt; \
done done
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/charsets $(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 \ do \
$(INSTALL_DATA) $$f $(DESTDIR)$(pkgdatadir)/charsets/; \ n=`basename $$f`; \
$(INSTALL_DATA) $$f $(DESTDIR)$(pkgdatadir)/charsets/$$n; \
done) done)
...@@ -81,6 +81,7 @@ bool String::realloc(uint32 alloc_length) ...@@ -81,6 +81,7 @@ bool String::realloc(uint32 alloc_length)
} }
else if ((new_ptr= (char*) my_malloc(len,MYF(MY_WME)))) else if ((new_ptr= (char*) my_malloc(len,MYF(MY_WME))))
{ {
if (str_length) // Avoid bugs in memcpy on AIX
memcpy(new_ptr,Ptr,str_length); memcpy(new_ptr,Ptr,str_length);
new_ptr[str_length]=0; new_ptr[str_length]=0;
Ptr=new_ptr; Ptr=new_ptr;
...@@ -221,7 +222,7 @@ bool String::copy(const char *str,uint32 arg_length) ...@@ -221,7 +222,7 @@ bool String::copy(const char *str,uint32 arg_length)
{ {
if (alloc(arg_length)) if (alloc(arg_length))
return TRUE; return TRUE;
str_length=arg_length; if ((str_length=arg_length))
memcpy(Ptr,str,arg_length); memcpy(Ptr,str,arg_length);
Ptr[arg_length]=0; Ptr[arg_length]=0;
return FALSE; return FALSE;
...@@ -251,17 +252,21 @@ void String::strip_sp() ...@@ -251,17 +252,21 @@ void String::strip_sp()
bool String::append(const String &s) bool String::append(const String &s)
{ {
if (s.length())
{
if (realloc(str_length+s.length())) if (realloc(str_length+s.length()))
return TRUE; return TRUE;
memcpy(Ptr+str_length,s.ptr(),s.length()); memcpy(Ptr+str_length,s.ptr(),s.length());
str_length+=s.length(); str_length+=s.length();
}
return FALSE; return FALSE;
} }
bool String::append(const char *s,uint32 arg_length) bool String::append(const char *s,uint32 arg_length)
{ {
if (!arg_length) // Default argument if (!arg_length) // Default argument
arg_length= (uint32) strlen(s); if (!(arg_length= (uint32) strlen(s)))
return FALSE;
if (realloc(str_length+arg_length)) if (realloc(str_length+arg_length))
return TRUE; return TRUE;
memcpy(Ptr+str_length,s,arg_length); memcpy(Ptr+str_length,s,arg_length);
...@@ -398,6 +403,7 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to) ...@@ -398,6 +403,7 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to)
{ {
if (diff < 0) if (diff < 0)
{ {
if (to.length())
memcpy(Ptr+offset,to.ptr(),to.length()); memcpy(Ptr+offset,to.ptr(),to.length());
bmove(Ptr+offset+to.length(),Ptr+offset+arg_length, bmove(Ptr+offset+to.length(),Ptr+offset+arg_length,
str_length-offset-arg_length); str_length-offset-arg_length);
...@@ -411,6 +417,7 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to) ...@@ -411,6 +417,7 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to)
bmove_upp(Ptr+str_length+diff,Ptr+str_length, bmove_upp(Ptr+str_length+diff,Ptr+str_length,
str_length-offset-arg_length); str_length-offset-arg_length);
} }
if (to.length())
memcpy(Ptr+offset,to.ptr(),to.length()); memcpy(Ptr+offset,to.ptr(),to.length());
} }
str_length+=(uint32) diff; str_length+=(uint32) diff;
...@@ -502,7 +509,7 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) ...@@ -502,7 +509,7 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
} }
if (to->realloc(from_length)) if (to->realloc(from_length))
return from; // Actually an error return from; // Actually an error
to->str_length=min(from->str_length,from_length); if ((to->str_length=min(from->str_length,from_length)))
memcpy(to->Ptr,from->Ptr,to->str_length); memcpy(to->Ptr,from->Ptr,to->str_length);
return to; return to;
} }
......
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