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.
@appendixsubsec Changes in release 3.23.25
@itemize @bullet
@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
......@@ -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);
......
......@@ -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)
......
......@@ -503,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
};
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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 */
{
......
......@@ -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)) ||
......
......@@ -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 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",
......@@ -228,12 +228,13 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
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;
}
......
......@@ -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
......@@ -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)
......@@ -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;
}
......
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