Fixed for Ia64 + delayed key creation + a lot of small bug fixes

This commit is contained in:
monty@donna.mysql.com 2000-08-15 20:09:37 +03:00
parent 807460bbce
commit ea013c2152
67 changed files with 787 additions and 635 deletions

View file

@ -1,14 +1 @@
tim@localhost.polyesthetic.msg
tim@work.mysql.com
monty@work.mysql.com
tonu@work.mysql.com
sinisa@work.mysql.com
paul@work.mysql.com
jamppa@work.mysql.com
davida@work.mysql.com
matt@work.mysql.com
serg@work.mysql.com
bk@work.mysql.com
sasha@mysql.sashanet.com
sasha@work.mysql.com
jcole@jcole.burghcom.com
monty@donna.mysql.com

View file

@ -1,5 +1,3 @@
# Monty
# Normally you do not need to remake the files here. But if you want
# to you will need the GNU TeX-info utilities. To make a Postscript
# files you also need TeX and dvips. To make the PDF file you will

View file

@ -121,6 +121,28 @@ After this it will give other threads a possibility to open the
same tables.
@end itemize
@node Filesort
@chapter How do MySQL do sorting (filesort)
- Read all rows according to key or by table-scanning.
- Store the sort-key in a buffer (sort_buffer).
- When the buffer gets full, run a qsort on it and store the result
in a temporary file. Save a pointer to the sorted block.
- Repeate the above until all rows has been read.
- Repeat the following until there is less than MERGEBUFF2 (15) blocks left.
- Do a multi-merge of up to MERGEBUFF (7) regions to one block in
another temporary file. Repeat until all blocks from the first file
is in the second file.
- On the last multi-merge, only the pointer to the row (last part of
the sort-key) is written to a result file.
- Now the code in sql/records.cc will be used to read through the
in sorted order by using the row pointersin the result file.
To optimize this, we read in a big block of row pointers, sort these
and then we read the rows in the sorted order into a row buffer
(record_buffer) .
@node Index
@unnumbered Index

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,7 @@ int heap_rnext(HP_INFO *info, byte *record)
pos=0; /* Read next after last */
my_errno=HA_ERR_KEY_NOT_FOUND;
}
else if (!info->current_ptr && (info->update & HA_STATE_PREV_FOUND))
else if (!info->current_ptr) /* Deleted or first call */
pos= _hp_search(info,share->keydef+info->lastinx, info->lastkey, 0);
else
pos= _hp_search(info,share->keydef+info->lastinx, info->lastkey, 1);

View file

@ -85,9 +85,6 @@
typedef unsigned short ushort;
typedef unsigned int uint;
#ifndef _WIN64
typedef unsigned int size_t;
#endif
typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
typedef __int64 longlong;
typedef int sigset_t;
@ -96,6 +93,12 @@ typedef int sigset_t;
Use my_off_t or os_off_t instead */
typedef long off_t;
typedef __int64 os_off_t;
#ifdef _WIN64
typedef UINT_PTR rf_SetTimer;
#else
typedef unsigned int size_t;
typedef uint rf_SetTimer;
#endif
#define Socket_defined
#define my_socket SOCKET
@ -288,4 +291,3 @@ inline double ulonglong2double(ulonglong value)
#define statistic_add(V,C,L) (V)+=(C)
#endif
#define statistic_increment(V,L) thread_safe_increment((V),(L))

View file

@ -572,7 +572,9 @@ typedef long longlong;
#endif
#undef SIZEOF_OFF_T
#define SIZEOF_OFF_T 8
#endif
#else
#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
#endif /* USE_RAID */
#if SIZEOF_OFF_T > 4
typedef ulonglong my_off_t;

View file

@ -262,4 +262,11 @@ typedef ulong ha_rows;
#define HA_POS_ERROR (~ (ha_rows) 0)
#define HA_OFFSET_ERROR (~ (my_off_t) 0)
#if SYSTEM_SIZEOF_OFF_T == 4
#define MAX_FILE_SIZE INT_MAX32
#else
#define MAX_FILE_SIZE LONGLONG_MAX
#endif
#endif /* _my_base_h */

View file

@ -43,6 +43,8 @@ extern "C" {
#define MI_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */
#define MI_NAME_IEXT ".MYI"
#define MI_NAME_DEXT ".MYD"
/* Max extra space to use when sorting keys */
#define MI_MAX_TEMP_LENGTH 1024L*1024L*1024L
#define mi_portable_sizeof_char_ptr 8
@ -263,9 +265,13 @@ extern uint mi_get_pointer_length(ulonglong file_length, uint def);
#define T_MEDIUM T_READONLY*2
#define T_AUTO_INC T_MEDIUM*2
#define T_CHECK T_AUTO_INC*2
#define T_UPDATE_STATE T_CHECK*2
#define T_CHECK_ONLY_CHANGED T_UPDATE_STATE*2
#define T_DONT_CHECK_CHECKSUM T_CHECK_ONLY_CHANGED*2
#define T_UPDATE_STATE T_CHECK*2
#define T_CHECK_ONLY_CHANGED T_UPDATE_STATE*2
#define T_DONT_CHECK_CHECKSUM T_CHECK_ONLY_CHANGED*2
#define T_TRUST_HEADER T_DONT_CHECK_CHECKSUM*2
#define T_CREATE_MISSING_KEYS T_TRUST_HEADER*2
#define T_SAFE_REPAIR T_CREATE_MISSING_KEYS*2
#define T_AUTO_REPAIR T_SAFE_REPAIR*2
#define O_NEW_INDEX 1 /* Bits set in out_flag */
#define O_NEW_DATA 2
@ -357,8 +363,8 @@ int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type,
const char *filetype, const char *filename);
void lock_memory(MI_CHECK *param);
int flush_blocks(MI_CHECK *param, File file);
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
my_bool repair);
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
my_bool repair);
int update_state_info(MI_CHECK *param, MI_INFO *info,uint update);
int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
my_off_t length, const char *type);
@ -370,6 +376,8 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
ulong);
int test_if_almost_full(MI_INFO *info);
int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename);
void mi_dectivate_non_unique_index(MI_INFO *info, ha_rows rows);
my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows);
#ifdef __cplusplus
}

View file

@ -1,15 +1,15 @@
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
@ -63,8 +63,8 @@ int _nisam_write_blob_record(N_INFO *info, const byte *record)
extra=ALIGN_SIZE(MAX_DYN_BLOCK_HEADER)+N_SPLITT_LENGTH+
DYN_DELETE_BLOCK_HEADER;
if (!(rec_buff=(byte*) my_alloca(info->s->base.pack_reclength+
_calc_total_blob_length(info,record)+
extra)))
_calc_total_blob_length(info,record)+
extra)))
return(-1);
reclength=_nisam_rec_pack(info,rec_buff+ALIGN_SIZE(MAX_DYN_BLOCK_HEADER),
record);
@ -84,8 +84,8 @@ int _nisam_update_blob_record(N_INFO *info, ulong pos, const byte *record)
extra=ALIGN_SIZE(MAX_DYN_BLOCK_HEADER)+N_SPLITT_LENGTH+
DYN_DELETE_BLOCK_HEADER;
if (!(rec_buff=(byte*) my_alloca(info->s->base.pack_reclength+
_calc_total_blob_length(info,record)+
extra)))
_calc_total_blob_length(info,record)+
extra)))
return(-1);
reclength=_nisam_rec_pack(info,rec_buff+ALIGN_SIZE(MAX_DYN_BLOCK_HEADER),
record);

View file

@ -342,7 +342,7 @@ int _nisam_key_cmp(register N_KEYSEG *keyseg, register uchar *a, register uchar
else
{
if ((flag = my_strnncoll(default_charset_info,
a, (end-a), b, b_length)))
a, (int) (end-a), b, b_length)))
return (keyseg->base.flag & HA_REVERSE_SORT) ? -flag : flag;
b+= (uint) (end-a);
a=end;
@ -393,7 +393,7 @@ int _nisam_key_cmp(register N_KEYSEG *keyseg, register uchar *a, register uchar
else
{
if ((flag = my_strnncoll(default_charset_info,
a, (end-a), b, (end-a))))
a, (int) (end-a), b, (int) (end-a))))
return (keyseg->base.flag & HA_REVERSE_SORT) ? -flag : flag;
b+= (uint) (end-a);
a=end;

View file

@ -82,7 +82,7 @@ int mrg_rrnd(MRG_INFO *info,byte *buf,mrg_off_t filepos)
}
}
info->current_table=find_table(info->open_tables,
info->last_used_table,filepos);
info->end_table,filepos);
isam_info=info->current_table->table;
isam_info->update&= HA_STATE_CHANGED;
return ((*isam_info->s->read_rnd)(isam_info,(byte*) buf,

View file

@ -84,7 +84,7 @@ int main(int argc,char *argv[])
for(i=1;create_record(record,qf);i++) {
FT_DOCLIST *result; double w; int t;
result=ft_init_search(file,0,blob_record,strlen(blob_record),1);
result=ft_init_search(file,0,blob_record,(uint) strlen(blob_record),1);
if(!result) {
printf("Query %d failed with errno %3d\n",i,my_errno);
goto err;
@ -177,7 +177,7 @@ int create_record(char *pos, FILE *file)
{
if(feof(file)) return 0; else print_error(1,"fgets(docid) - 1");
}
tmp=strlen(pos+2)-1;
tmp=(uint) strlen(pos+2)-1;
int2store(pos,tmp);
pos+=recinfo[0].length;
@ -185,7 +185,7 @@ int create_record(char *pos, FILE *file)
if(!(fgets(blob_record,MAX_BLOB_LENGTH,file)))
print_error(1,"fgets(docid) - 2");
tmp=strlen(blob_record);
tmp=(uint) strlen(blob_record);
int4store(pos,tmp);
ptr=blob_record;
memcpy_fixed(pos+4,&ptr,sizeof(char*));

View file

@ -140,7 +140,7 @@ TREE * ft_parse(TREE *wtree, byte *doc, int doclen)
if(word_char(*doc)) break;
for(w.pos=doc; doc<end; doc++)
if(!word_char(*doc)) break;
if((w.len=doc-w.pos) < MIN_WORD_LEN) continue;
if((w.len= (uint) (doc-w.pos)) < MIN_WORD_LEN) continue;
if(!tree_insert(wtree, &w, 0))
{
delete_tree(wtree);

View file

@ -19,19 +19,19 @@
#include "ftdefs.h"
const MI_KEYSEG ft_keysegs[FT_SEGS]={
{
HA_KEYTYPE_VARTEXT, // type
7, // language
0, 0, 0, // null_bit, bit_start, bit_end
HA_VAR_LENGTH | HA_PACK_KEY, // flag
HA_FT_MAXLEN, // length
{
HA_KEYTYPE_VARTEXT, /* type */
7, /* language */
0, 0, 0, /* null_bit, bit_start, bit_end */
HA_VAR_LENGTH | HA_PACK_KEY, /* flag */
HA_FT_MAXLEN, /* length */
#ifdef EVAL_RUN
HA_FT_WLEN+1, // start
HA_FT_WLEN+1, /* start */
#else /* EVAL_RUN */
HA_FT_WLEN, // start
HA_FT_WLEN, /* start */
#endif /* EVAL_RUN */
0, // null_pos
NULL // sort_order
0, /* null_pos */
NULL /* sort_order */
},
#ifdef EVAL_RUN
{

View file

@ -220,7 +220,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr)
if (next_link > info->state->key_file_length ||
next_link & (info->s->blocksize-1))
DBUG_RETURN(1);
if (!(buff=key_cache_read(info->s->kfile, next_link, info->buff,
if (!(buff=key_cache_read(info->s->kfile, next_link, (byte*) info->buff,
myisam_block_size, block_size, 1)))
DBUG_RETURN(1);
next_link=mi_sizekorr(buff);
@ -1228,6 +1228,8 @@ err:
VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks,
MYF(MY_WME)));
}
mi_mark_crashed_on_repair(info);
info->update|= HA_STATE_CHANGED;
}
if (sort_info->record)
my_free(sort_info->record,MYF(0));
@ -1580,7 +1582,7 @@ err:
DBUG_RETURN(1);
}
/* Fix table using sorting */
/* Fix table or given index using sorting */
/* saves new table in temp_filename */
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
@ -1597,6 +1599,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
ulong *rec_per_key_part;
char llbuff[22];
SORT_INFO *sort_info= &param->sort_info;
ulonglong key_map=share->state.key_map;
DBUG_ENTER("rep_by_sort");
start_records=info->state->records;
@ -1621,7 +1624,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
init_io_cache(&info->rec_cache,info->dfile,
(uint) param->write_buffer_length,
WRITE_CACHE,new_header_length,1,
MYF(MY_WME | MY_WAIT_IF_FULL))))
MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw)))
goto err;
sort_info->key_block_end=sort_info->key_block+param->sort_key_blocks;
info->opt_flag|=WRITE_CACHE_USED;
@ -1664,10 +1667,15 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
}
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
for (i=0 ; i < share->base.keys ; i++)
share->state.key_root[i]= HA_OFFSET_ERROR;
for (i=0 ; i < share->state.header.max_block_size ; i++)
share->state.key_del[i]= HA_OFFSET_ERROR;
if (!(param->testflag & T_CREATE_MISSING_KEYS))
{
for (i=0 ; i < share->base.keys ; i++)
share->state.key_root[i]= HA_OFFSET_ERROR;
for (i=0 ; i < share->state.header.max_block_size ; i++)
share->state.key_del[i]= HA_OFFSET_ERROR;
}
else
key_map= ~key_map; /* Create the missing keys */
info->state->key_file_length=share->base.keystart;
@ -1696,7 +1704,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
else
length=share->base.pack_reclength;
sort_param.max_records=sort_info->max_records=
(ha_rows) (sort_info->filelength/length+1);
((param->testflag & T_TRUST_HEADER) ? info->state->records :
(ha_rows) (sort_info->filelength/length+1));
sort_param.key_cmp=sort_key_cmp;
sort_param.key_write=sort_key_write;
sort_param.key_read=sort_key_read;
@ -1714,7 +1723,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
rec_per_key_part+=sort_info->keyinfo->keysegs, sort_info->key++)
{
sort_info->keyinfo=share->keyinfo+sort_info->key;
if (!(((ulonglong) 1 << sort_info->key) & share->state.key_map))
if (!(((ulonglong) 1 << sort_info->key) & key_map))
continue;
if ((!(param->testflag & T_SILENT)))
@ -1755,6 +1764,15 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
param->read_cache.end_of_file=sort_info->filepos;
if (write_data_suffix(param,info) || end_io_cache(&info->rec_cache))
goto err;
if (param->testflag & T_SAFE_REPAIR)
{
/* Don't repair if we loosed more than one row */
if (info->state->records+1 < start_records)
{
info->state->records=start_records;
goto err;
}
}
share->state.state.data_file_length = info->state->data_file_length
= sort_info->filepos;
/* Only whole records */
@ -1837,6 +1855,8 @@ err:
VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks,
MYF(MY_WME)));
}
mi_mark_crashed_on_repair(info);
info->update|= HA_STATE_CHANGED;
}
my_free((gptr) sort_info->key_block,MYF(MY_ALLOW_ZERO_PTR));
my_free(sort_info->record,MYF(MY_ALLOW_ZERO_PTR));
@ -1844,7 +1864,7 @@ err:
VOID(end_io_cache(&param->read_cache));
VOID(end_io_cache(&info->rec_cache));
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
if (!got_error && param->testflag & T_UNPACK)
if (!got_error && (param->testflag & T_UNPACK))
{
share->state.header.options[0]&= (uchar) ~HA_OPTION_COMPRESS_RECORD;
share->pack.header_length=0;
@ -2884,3 +2904,58 @@ ha_checksum mi_byte_checksum(const byte *buf, uint length)
test(crc & (((ha_checksum) 1) << (8*sizeof(ha_checksum)-1)));
return crc;
}
/*
Deactive all not unique index that can be recreated fast
These include packed keys on which sorting will use more temporary
space than the max allowed file length or for which the unpacked keys
will take much more space than packed keys.
Note that 'rows' may be zero for the case when we don't know how many
rows we will put into the file.
*/
static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows)
{
return (key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY | HA_FULLTEXT) &&
((ulonglong) rows * key->maxlength > MAX_FILE_SIZE ||
(ulonglong) rows * (key->maxlength - key->minlength) / 2 >
MI_MAX_TEMP_LENGTH ||
(rows == 0 && (key->maxlength / key->minlength) > 2)));
}
void mi_dectivate_non_unique_index(MI_INFO *info, ha_rows rows)
{
MYISAM_SHARE *share=info->s;
uint i;
if (!info->state->records) /* Don't do this if old rows */
{
MI_KEYDEF *key=share->keyinfo;
for (i=0 ; i < share->base.keys ; i++,key++)
{
if (!(key->flag & HA_NOSAME) && ! mi_too_big_key_for_sort(key,rows))
{
share->state.key_map&= ~ ((ulonglong) 1 << i);
info->update|= HA_STATE_CHANGED;
}
}
}
}
/* Return TRUE if we can use repair by sorting */
my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows)
{
MYISAM_SHARE *share=info->s;
uint i;
MI_KEYDEF *key=share->keyinfo;
if (!share->state.key_map)
return FALSE; /* Can't use sort */
for (i=0 ; i < share->base.keys ; i++,key++)
{
if (mi_too_big_key_for_sort(key,rows))
return FALSE;
}
return TRUE;
}

View file

@ -74,12 +74,12 @@ int mi_lock_database(MI_INFO *info, int lock_type)
share->state.process= share->last_process=share->this_process;
share->state.unique= info->last_unique= info->this_unique;
#ifndef HAVE_PREAD
pthread_mutex_lock(&THR_LOCK_keycache); // QQ; Has to be removed!
pthread_mutex_lock(&THR_LOCK_keycache); /* QQ; Has to be removed! */
#endif
if (mi_state_info_write(share->kfile, &share->state, 1))
error=my_errno;
#ifndef HAVE_PREAD
pthread_mutex_unlock(&THR_LOCK_keycache);// QQ; Has to be removed!
pthread_mutex_unlock(&THR_LOCK_keycache);/* QQ; Has to be removed! */
#endif
share->changed=0;
if (myisam_flush)

View file

@ -284,7 +284,9 @@ struct st_myisam_info {
mi_int2store(x,boh); }
#define mi_test_if_nod(x) (x[0] & 128 ? info->s->base.key_reflength : 0)
#define mi_mark_crashed(x) (x)->s->state.changed|=2
#define mi_mark_crashed_on_repair(x) (x)->s->state.changed|=4+2
#define mi_is_crashed(x) ((x)->s->state.changed & 2)
#define mi_is_crashed_on_repair(x) ((x)->s->state.changed & 4)
/* Functions to store length of space packed keys, VARCHAR or BLOB keys */
@ -606,6 +608,7 @@ void mi_get_status(void* param);
void mi_update_status(void* param);
void mi_copy_status(void* to,void *from);
my_bool mi_check_status(void* param);
void mi_dectivate_non_unique_index(MI_INFO *info, ha_rows rows);
/* Functions needed by mi_check */
#ifdef __cplusplus

View file

@ -249,7 +249,7 @@ static struct option long_options[] =
static void print_version(void)
{
printf("%s Ver 1.7 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE);
printf("%s Ver 1.8 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage(void)

View file

@ -81,7 +81,7 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos)
}
}
info->current_table=find_table(info->open_tables,
info->last_used_table,filepos);
info->end_table,filepos);
isam_info=info->current_table->table;
isam_info->update&= HA_STATE_CHANGED;
return ((*isam_info->s->read_rnd)(isam_info,(byte*) buf,

Binary file not shown.

View file

@ -112,7 +112,7 @@ static my_bool read_charset_index(TYPELIB *charsets, myf myflags)
while (!get_word(&fb, buf))
{
uint length;
if (!(s= (char*) my_once_alloc(length=strlen(buf)+1, myflags)))
if (!(s= (char*) my_once_alloc(length= (uint) strlen(buf)+1, myflags)))
{
my_fclose(fb.f,myflags);
return TRUE;
@ -292,7 +292,7 @@ static CHARSET_INFO *add_charset(uint cs_number, const char *cs_name)
cs = (CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO),
MYF(MY_WME));
*cs=tmp_cs;
cs->name = (char *) my_once_alloc(strlen(cs_name) + 1, MYF(MY_WME));
cs->name = (char *) my_once_alloc((uint) strlen(cs_name)+1, MYF(MY_WME));
cs->ctype = (uchar*) my_once_alloc(CTYPE_TABLE_SIZE, MYF(MY_WME));
cs->to_lower = (uchar*) my_once_alloc(TO_LOWER_TABLE_SIZE, MYF(MY_WME));
cs->to_upper = (uchar*) my_once_alloc(TO_UPPER_TABLE_SIZE, MYF(MY_WME));
@ -410,7 +410,7 @@ my_bool set_default_charset_by_name(const char *cs_name, myf flags)
static my_bool charset_in_string(const char *name, DYNAMIC_STRING *s)
{
uint length=strlen(name);
uint length= (uint) strlen(name);
const char *pos;
for (pos=s->str ; (pos=strstr(pos,name)) ; pos++)
{

View file

@ -32,7 +32,7 @@ void caseup_str(my_string str)
{
#ifdef USE_MB
register uint32 l;
register char *end=str+strlen(str);
register char *end=str+(uint) strlen(str);
if (use_mb(default_charset_info))
while (*str)
{
@ -51,7 +51,7 @@ void casedn_str(my_string str)
{
#ifdef USE_MB
register uint32 l;
register char *end=str+strlen(str);
register char *end=str+(uint) strlen(str);
if (use_mb(default_charset_info))
while (*str)
{
@ -144,7 +144,7 @@ int my_strcasecmp(const char *s, const char *t)
{
#ifdef USE_MB
register uint32 l;
register const char *end=s+strlen(s);
register const char *end=s+(uint) strlen(s);
if (use_mb(default_charset_info))
{
while (s<end)

View file

@ -53,13 +53,13 @@ void pack_dirname(my_string to, const char *from)
LINT_INIT(buff_length);
if (!(cwd_err= my_getwd(buff,FN_REFLEN,MYF(0))))
{
buff_length=strlen(buff);
buff_length= (uint) strlen(buff);
d_length=(uint) (start-to);
if ((start == to ||
(buff_length == d_length && !bcmp(buff,start,d_length))) &&
*start != FN_LIBCHAR && *start)
{ /* Put current dir before */
bchange(to,d_length,buff,buff_length,strlen(to)+1);
bchange(to,d_length,buff,buff_length,(uint) strlen(to)+1);
}
}
@ -68,7 +68,7 @@ void pack_dirname(my_string to, const char *from)
length=0;
if (home_dir)
{
length=strlen(home_dir);
length= (uint) strlen(home_dir);
if (home_dir[length-1] == FN_LIBCHAR)
length--; /* Don't test last '/' */
}
@ -92,7 +92,7 @@ void pack_dirname(my_string to, const char *from)
}
if (is_prefix(to,buff))
{
length=strlen(buff);
length= (uint) strlen(buff);
if (to[length])
(void) strmov_overlapp(to,to+length); /* Remove everything before */
else
@ -265,7 +265,7 @@ uint unpack_dirname(my_string to, const char *from)
DBUG_ENTER("unpack_dirname");
(void) intern_filename(buff,from); /* Change to intern name */
length=strlen(buff); /* Fix that '/' is last */
length= (uint) strlen(buff); /* Fix that '/' is last */
if (length &&
#ifdef FN_DEVCHAR
buff[length-1] != FN_DEVCHAR &&
@ -283,7 +283,7 @@ uint unpack_dirname(my_string to, const char *from)
if (tilde_expansion)
{
length-=(uint) (suffix-buff)-1;
if (length+(h_length=strlen(tilde_expansion)) <= FN_REFLEN)
if (length+(h_length= (uint) strlen(tilde_expansion)) <= FN_REFLEN)
{
if (tilde_expansion[h_length-1] == FN_LIBCHAR)
h_length--;

View file

@ -46,7 +46,7 @@ my_string my_path(my_string to, const char *progname,
if (!test_if_hard_path(to))
{
if (!my_getwd(curr_dir,FN_REFLEN,MYF(0)))
bchange(to,0,curr_dir,strlen(curr_dir),strlen(to)+1);
bchange(to,0,curr_dir, (uint) strlen(curr_dir), (uint) strlen(to)+1);
}
}
else

View file

@ -63,7 +63,8 @@ WF_PACK *wf_comp(my_string str)
#endif
if ((ret= (WF_PACK*) my_malloc((uint) ant*(sizeof(my_string*)+2)+
sizeof(WF_PACK)+strlen(str)+1,MYF(MY_WME)))
sizeof(WF_PACK)+ (uint) strlen(str)+1,
MYF(MY_WME)))
== 0)
DBUG_RETURN((WF_PACK *) NULL);
ret->wild= (my_string*) (ret+1);

View file

@ -112,7 +112,7 @@ void free_root(MEM_ROOT *root)
char *strdup_root(MEM_ROOT *root,const char *str)
{
uint len=strlen(str)+1;
uint len= (uint) strlen(str)+1;
char *pos;
if ((pos=alloc_root(root,len)))
memcpy(pos,str,len);

View file

@ -353,7 +353,11 @@ myf MyFlags;
ushort mode;
char tmp_path[FN_REFLEN],*tmp_file,attrib;
my_ptrdiff_t diff;
#ifdef _WIN64
__int64 handle;
#else
long handle;
#endif
DBUG_ENTER("my_dir");
DBUG_PRINT("my",("path: '%s' stat: %d MyFlags: %d",path,MyFlags));

View file

@ -32,7 +32,7 @@ uint32 my_lread(int Filedes, byte *Buffer, uint32 Count, myf MyFlags)
Filedes, Buffer, Count, MyFlags));
/* Temp hack to get count to int32 while read wants int */
if ((readbytes = (uint32) read(Filedes, Buffer, (size_t) Count)) != Count)
if ((readbytes = (uint32) read(Filedes, Buffer, (uint) Count)) != Count)
{
my_errno=errno;
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))

View file

@ -28,7 +28,7 @@ uint32 my_lwrite(int Filedes, const byte *Buffer, uint32 Count, myf MyFlags)
Filedes, Buffer, Count, MyFlags));
/* Temp hack to get count to int32 while write wants int */
if ((writenbytes = (uint32) write(Filedes, Buffer, (size_t) Count)) != Count)
if ((writenbytes = (uint32) write(Filedes, Buffer, (uint) Count)) != Count)
{
my_errno=errno;
if (writenbytes == (uint32) -1 || MyFlags & (MY_NABP | MY_FNABP))

View file

@ -83,11 +83,11 @@ int pthread_create(pthread_t *thread_id, pthread_attr_t *attr,
*thread_id=map->pthreadself=hThread;
pthread_mutex_unlock(&THR_LOCK_thread);
if ((long) hThread == -1L)
if (hThread == (HANDLE) -1)
{
long error=errno;
int error=errno;
DBUG_PRINT("error",
("Can't create thread to handle request (error %ld)",error));
("Can't create thread to handle request (error %d)",error));
DBUG_RETURN(error ? error : -1);
}
VOID(SetThreadPriority(hThread, attr->priority)) ;

View file

@ -33,7 +33,7 @@ my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
if (!alloc_increment)
alloc_increment=128;
length=1;
if (init_str && (length=strlen(init_str)+1) < init_alloc)
if (init_str && (length= (uint) strlen(init_str)+1) < init_alloc)
init_alloc=((length+alloc_increment-1)/alloc_increment)*alloc_increment;
if (!init_alloc)
init_alloc=alloc_increment;
@ -53,7 +53,7 @@ my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str)
uint length;
DBUG_ENTER("dynstr_set");
if (init_str && (length=strlen(init_str)+1) > str->max_length)
if (init_str && (length= (uint) strlen(init_str)+1) > str->max_length)
{
str->max_length=((length+str->alloc_increment-1)/str->alloc_increment)*
str->alloc_increment;

View file

@ -831,7 +831,7 @@ bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm)
alrm->crono=0;
return 1;
}
if (!(alrm->crono=SetTimer(NULL,0,(long) sec*1000L, (TIMERPROC) NULL)))
if (!(alrm->crono=SetTimer((HWND) NULL,0, sec*1000,(TIMERPROC) NULL)))
return 1;
return 0;
}

View file

@ -87,7 +87,7 @@ int my_rw_rdlock( rw_lock_t *rwp ) {
pthread_mutex_lock(&rwp->lock);
/* active or queued writers */
while ( ( rwp->state < 0 ) && rwp->waiters )
while ( ( rwp->state < 0 ) || rwp->waiters )
pthread_cond_wait( &rwp->readers, &rwp->lock);
rwp->state++;
@ -103,12 +103,8 @@ int my_rw_wrlock( rw_lock_t *rwp ) {
while ( rwp->state )
pthread_cond_wait( &rwp->writers, &rwp->lock);
rwp->state = -1;
if ( ( --rwp->waiters == 0 ) && ( rwp->state >= 0 ) )
pthread_cond_broadcast( &rwp->readers );
--rwp->waiters;
pthread_mutex_unlock( &rwp->lock );
return( 0 );

View file

@ -132,7 +132,7 @@ int cflags;
(NC-1)*sizeof(cat_t));
if (g == NULL)
return(REG_ESPACE);
p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
p->ssize = (long) (len/(size_t)2*(size_t)3 + (size_t)1); /* ugh */
p->strip = (sop *)malloc(p->ssize * sizeof(sop));
p->slen = 0;
if (p->strip == NULL) {
@ -268,7 +268,7 @@ register struct parse *p;
case '(':
REQUIRE(MORE(), REG_EPAREN);
p->g->nsub++;
subno = p->g->nsub;
subno = (sopno) p->g->nsub;
if (subno < NPAREN)
p->pbegin[subno] = HERE();
EMIT(OLPAREN, subno);
@ -488,7 +488,7 @@ int starordinary; /* is a leading * an ordinary character? */
break;
case BACKSL|'(':
p->g->nsub++;
subno = p->g->nsub;
subno = (sopno) p->g->nsub;
if (subno < NPAREN)
p->pbegin[subno] = HERE();
EMIT(OLPAREN, subno);
@ -811,8 +811,11 @@ int endc; /* name ended by endc,']' */
{
register char *sp = p->next;
register struct cname *cp;
#ifdef _WIN64
register __int64 len;
#else
register int len;
#endif
while (MORE() && !SEETWO(endc, ']'))
NEXT();
if (!MORE()) {
@ -1076,9 +1079,9 @@ register cset *cs;
register size_t css = (size_t)p->g->csetsize;
for (i = 0; i < css; i++)
CHsub(cs, i);
CHsub(cs, i);
if (cs == top-1) /* recover only the easy case */
p->g->ncsets--;
p->g->ncsets--;
}
/*

View file

@ -6,7 +6,11 @@ extern "C" {
#endif
/* === regex2.h === */
#ifdef _WIN64
typedef __int64 regoff_t;
#else
typedef off_t regoff_t;
#endif
struct re_guts; /* none of your business :-) */
typedef struct {
int re_magic;

View file

@ -95,8 +95,8 @@ typedef struct {
char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */
} cset;
/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c))
#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (uch) (c))
#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (uch)(c))
#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask)
#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */
#define MCsub(p, cs, cp) mcsub(p, cs, cp)

View file

@ -25,7 +25,7 @@ WARNING: THIS IS VERY MUCH A FIRST-CUT ALPHA. Comments/patches welcome.
# Documentation continued at end of file
my $VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/o);
my $VERSION = "1.5";
my $OPTIONS = <<"_OPTIONS";

View file

@ -395,6 +395,11 @@ All benchmarks takes the following options:
extra information that 'uname -a' doesn\'t give and if the database was
stared with some specific, non default, options.
--cmp=server[,server...]
Run the test with limits from the given servers. If you run all servers
with the same --cmp, you will get a test that is comparable between
the different sql servers.
--database (Default $opt_database)
In which database the test tables are created.

View file

@ -535,23 +535,23 @@ sub new
$limits{'group_functions'} = 1;
$limits{'group_distinct_functions'}= 1; # Have count(distinct)
$limits{'having_with_alias'} = 0;
$limits{'having_with_group'} = 0;
$limits{'having_with_group'} = 1;
$limits{'left_outer_join'} = 0;
$limits{'like_with_column'} = 1;
$limits{'lock_tables'} = 0; # in ATIS gives this a problem
$limits{'max_column_name'} = 32; # Is this true
$limits{'max_columns'} = 300; # 500 crashes pg 6.3
$limits{'max_tables'} = 65000; # Should be big enough
$limits{'max_conditions'} = 9; # This makes Pg real slow
$limits{'max_index'} = 7; # Is this true ?
$limits{'max_index_parts'} = 16; # Is this true ?
$limits{'max_text_size'} = 7000; # 8000 crashes pg 6.3
$limits{'multi_drop'} = 1;
$limits{'order_by_position'} = 1;
$limits{'query_size'} = 8191;
$limits{'select_without_from'}= 1;
$limits{'subqueries'} = 1;
$limits{'table_wildcard'} = 1;
$limits{'max_column_name'} = 32; # Is this true
$limits{'max_columns'} = 1000; # 500 crashes pg 6.3
$limits{'max_tables'} = 65000; # Should be big enough
$limits{'max_conditions'} = 30; # This makes Pg real slow
$limits{'max_index'} = 64; # Is this true ?
$limits{'max_index_parts'} = 16; # Is this true ?
$limits{'max_text_size'} = 7000; # 8000 crashes pg 6.3
$limits{'query_size'} = 8191;
# the different cases per query ...
$smds{'q1'} = 'b'; # with time

View file

@ -1,3 +1,9 @@
2000-08-08 Michael Widenius <monty@mysql.com>
* Changed ALTER TABLE and LOAD DATA INFILE to create non unique, small keys
after all rows are inserted.
* Fixed use of UDF function with const arguments in WHERE clause.
2000-07-11 Michael Widenius <monty@mysql.com>
* Extended safe_mysqld; Patch by Christian Hammers

View file

@ -2418,6 +2418,7 @@ bool Field_timestamp::get_date(TIME *ltime,
ltime->second= start->tm_sec;
ltime->second_part= 0;
ltime->neg= 0;
ltime->time_type=TIMESTAMP_FULL;
}
return 0;
}
@ -3005,6 +3006,7 @@ bool Field_newdate::get_date(TIME *ltime,bool fuzzydate)
ltime->day= tmp & 31;
ltime->month= (tmp >> 5) & 15;
ltime->year= (tmp >> 9);
ltime->time_type=TIMESTAMP_DATE;
return (!fuzzydate && (!ltime->month || !ltime->day) && ltime->year) ? 1 : 0;
}
@ -3181,6 +3183,7 @@ bool Field_datetime::get_date(TIME *ltime,bool fuzzydate)
part1=(long) (tmp/LL(1000000));
part2=(long) (tmp - (ulonglong) part1*LL(1000000));
ltime->time_type= TIMESTAMP_FULL;
ltime->neg=0;
ltime->second_part=0;
ltime->second= part2%100;

View file

@ -192,7 +192,7 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
memavl=MIN_SORT_MEMORY;
}
param.keys--;
maxbuffer+=10; /* Some extra range */
maxbuffer+=10; /* Some extra range */
if (memavl < MIN_SORT_MEMORY)
{
@ -209,7 +209,7 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
&tempfile, selected_records_file)) ==
HA_POS_ERROR)
goto err;
if (maxbuffer == 0)
if (maxbuffer == 0) // The whole set is in memory
{
if (save_index(&param,sort_keys,(uint) records))
goto err;

View file

@ -27,6 +27,7 @@
#include "lex.h"
bool opt_search=0,opt_verbose=0;
ulong opt_count=100000;
#define max_allowed_array 8000 // Don't generate bigger arrays than this
#define max_symbol 32767 // Use this for 'not found'
@ -316,6 +317,7 @@ void print_arrays()
static struct option long_options[] =
{
{"count", required_argument, 0, 'c'},
{"search", no_argument, 0, 'S'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
@ -328,7 +330,7 @@ static struct option long_options[] =
static void usage(int version)
{
printf("%s Ver 3.0 Distrib %s, for %s (%s)\n",
printf("%s Ver 3.1 Distrib %s, for %s (%s)\n",
my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
if (version)
return;
@ -337,6 +339,7 @@ static void usage(int version)
puts("This program generates a perfect hashing function for the sql_lex.cc");
printf("Usage: %s [OPTIONS]\n", my_progname);
printf("\n\
-c, --count=# Try count times to find a optimal hash table\n\
-r, --rnd1=# Set 1 part of rnd value for hash generator\n\
-R, --rnd2=# Set 2 part of rnd value for hash generator\n\
-t, --type=# Set type of char table to generate\n\
@ -353,10 +356,13 @@ static int get_options(int argc, char **argv)
{
int c,option_index=0;
while ((c=getopt_long(argc,argv,"?SvVr:R:t:",
while ((c=getopt_long(argc,argv,"?SvVc:r:R:t:",
long_options, &option_index)) != EOF)
{
switch(c) {
case 'c':
opt_count=atol(optarg);
break;
case 'r':
best_t1=atol(optarg);
break;
@ -466,8 +472,7 @@ int main(int argc,char **argv)
int error;
MY_INIT(argv[0]);
start_value=1277803L; best_t1=331678L; best_t2=4097229L; best_type=1;
/* mode=5791 add=6 func_type: 0 */
start_value=6059524L; best_t1=2194873L; best_t2=4441039L; best_type=4; /* mode=4159 add=8 func_type: 0 */
if (get_options(argc,(char **) argv))
exit(1);
@ -488,7 +493,7 @@ int main(int argc,char **argv)
start_value, best_t1,best_t2,best_type,best_mod,best_add,
best_functype);
for (uint i=1 ; i <= 100000 ; i++)
for (uint i=1 ; i <= opt_count ; i++)
{
if (i % 10 == 0)
{
@ -532,7 +537,9 @@ printf("/* This code is generated by gen_lex_hash.cc that seeks for a perfect\nh
print_arrays();
printf("/* t1= %lu t2=%lu type= %d */\n\n",best_t1,best_t2,best_type);
printf("/* start_value=%ldL; best_t1=%ldL; best_t2=%ldL; best_type=%d; */ /* mode=%d add=%d type: %d */\n\n",
start_value, best_t1, best_t2,best_type,
best_mod, best_add, best_functype);
printf("inline SYMBOL *get_hash_symbol(const char *s,unsigned int length,bool function)\n\
{\n\

View file

@ -228,7 +228,7 @@ berkeley_cmp_packed_key(const DBT *new_key, const DBT *saved_key)
key_length-=length;
saved_key_ptr+=key_part->field->packed_col_length(saved_key_ptr);
}
return 0;
return key->handler.bdb_return_if_eq;
}
@ -250,7 +250,7 @@ berkeley_cmp_fix_length_key(const DBT *new_key, const DBT *saved_key)
key_length-= key_part->length;
saved_key_ptr+=key_part->length;
}
return 0;
return key->handler.bdb_return_if_eq;
}
@ -964,6 +964,8 @@ int ha_berkeley::read_row(int error, char *buf, uint keynr, DBT *row,
}
/* This is only used to read whole keys */
int ha_berkeley::index_read_idx(byte * buf, uint keynr, const byte * key,
uint key_len, enum ha_rkey_function find_flag)
{
@ -982,14 +984,38 @@ int ha_berkeley::index_read(byte * buf, const byte * key,
uint key_len, enum ha_rkey_function find_flag)
{
DBT row;
int error;
DBUG_ENTER("index_read");
statistic_increment(ha_read_key_count,&LOCK_status);
bzero((char*) &row,sizeof(row));
DBUG_RETURN(read_row(cursor->c_get(cursor,
pack_key(&last_key, active_index,
key_buff, key, key_len),
&row, DB_SET),
buf, active_index, &row, 0));
if (key_len == table->key_info[active_index].key_length)
{
error=read_row(cursor->c_get(cursor, pack_key(&last_key,
active_index,
key_buff,
key, key_len),
&row, DB_SET),
buf, active_index, &row, 0);
}
else
{
/* read of partial key */
pack_key(&last_key, active_index, key_buff, key, key_len);
/* Store for compare */
memcpy(key_buff2, key_buff, last_key.size);
((KEY*) last_key.app_private)->handler.bdb_return_if_eq= -1;
error=read_row(cursor->c_get(cursor, &last_key, &row, DB_SET_RANGE),
buf, active_index, &row, 0);
((KEY*) last_key.app_private)->handler.bdb_return_if_eq=0;
if (!error && find_flag == HA_READ_KEY_EXACT)
{
/* Check that we didn't find a key that wasn't equal to the current
one */
if (!error && ::key_cmp(table, key_buff2, active_index, key_len))
error=HA_ERR_KEY_NOT_FOUND;
}
}
DBUG_RETURN(error);
}

View file

@ -121,7 +121,7 @@ class ha_berkeley: public handler
enum ha_rkey_function end_search_flag);
int create(const char *name, register TABLE *form,
HA_CREATE_INFO *create_info);
HA_CREATE_INFO *create_info);
int delete_table(const char *name);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type);

View file

@ -30,11 +30,12 @@
#include "../myisam/myisamdef.h"
#endif
ulong myisam_sort_buffer_size;
#if !defined(HAVE_PREAD)
pthread_mutex_t THR_LOCK_keycache;
#endif
ulong myisam_sort_buffer_size;
/*****************************************************************************
** MyISAM tables
*****************************************************************************/
@ -57,7 +58,12 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
sql_print_error(msgbuf);
return;
}
if (param->testflag & (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR |
T_AUTO_REPAIR))
{
my_message(ER_NOT_KEYFILE,msgbuf,MYF(MY_WME));
return;
}
net_store_data(packet, param->table_name);
net_store_data(packet, param->op_name);
net_store_data(packet, msg_type);
@ -328,29 +334,37 @@ int ha_myisam::analyze(THD *thd)
}
int ha_myisam::repair(THD* thd, HA_CHECK_OPT* check_opt)
int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
{
if (!file) return HA_CHECK_INTERNAL_ERROR;
int error ;
MI_CHECK param;
MYISAM_SHARE* share = file->s;
char fixed_name[FN_REFLEN];
myisamchk_init(&param);
param.thd = thd;
param.op_name = (char*) "repair";
param.table_name = table->table_name;
param.testflag = check_opt->flags | T_SILENT|T_FORCE_CREATE|T_REP_BY_SORT;
param.sort_buffer_length= check_opt->sort_buffer_size;
param.testflag = (check_opt->flags | T_SILENT|T_FORCE_CREATE|T_REP_BY_SORT|
T_STATISTICS);
if (check_opt->quick)
param.opt_rep_quick++;
param.sort_buffer_length= check_opt->sort_buffer_size;
return repair(thd,param);
}
int ha_myisam::repair(THD *thd, MI_CHECK &param)
{
int error;
char fixed_name[FN_REFLEN];
MYISAM_SHARE* share = file->s;
param.table_name = table->table_name;
param.tmpfile_createflag = O_RDWR | O_TRUNC;
param.using_global_keycache = 1;
VOID(fn_format(fixed_name,file->filename,"",MI_NAME_IEXT,
4+ (param.opt_follow_links ? 16 : 0)));
if (share->state.key_map)
if (mi_test_if_sort_rep(file,file->state->records))
error = mi_repair_by_sort(&param, file, fixed_name, param.opt_rep_quick);
else
error= mi_repair(&param, file, fixed_name, param.opt_rep_quick);
@ -397,6 +411,38 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT* check_opt)
}
/* Deactive all not unique index that can be recreated fast */
void ha_myisam::deactivate_non_unique_index(ha_rows rows)
{
if (!(specialflag & SPECIAL_SAFE_MODE))
mi_dectivate_non_unique_index(file,rows);
}
bool ha_myisam::activate_all_index(THD *thd)
{
int error=0;
char fixed_name[FN_REFLEN];
MI_CHECK param;
MYISAM_SHARE* share = file->s;
DBUG_ENTER("activate_all_index");
if (share->state.key_map != ((ulonglong) 1L << share->base.keys)-1)
{
const char *save_proc_info=thd->proc_info;
thd->proc_info="creating index";
myisamchk_init(&param);
param.op_name = (char*) "recreating_index";
param.testflag = (T_SILENT | T_REP_BY_SORT |
T_STATISTICS | T_CREATE_MISSING_KEYS | T_TRUST_HEADER);
param.myf_rw&= ~MY_WAIT_IF_FULL;
param.sort_buffer_length= myisam_sort_buffer_size;
param.opt_rep_quick++;
error=repair(thd,param) != HA_CHECK_OK;
thd->proc_info=save_proc_info;
}
DBUG_RETURN(error);
}
int ha_myisam::update_row(const byte * old_data, byte * new_data)
{
@ -870,4 +916,3 @@ int ha_myisam::ft_read(byte * buf)
table->status=error ? STATUS_NOT_FOUND: 0;
return error;
}

View file

@ -30,6 +30,7 @@ class ha_myisam: public handler
{
MI_INFO *file;
uint int_option_flag;
int repair(THD *thd, MI_CHECK &param);
public:
ha_myisam(TABLE *table): handler(table), file(0),
@ -76,6 +77,8 @@ class ha_myisam: public handler
int reset(void);
int external_lock(THD *thd, int lock_type);
int delete_all_rows(void);
void deactivate_non_unique_index(ha_rows rows);
bool activate_all_index(THD *thd);
ha_rows records_in_range(int inx,
const byte *start_key,uint start_key_len,
enum ha_rkey_function start_search_flag,

View file

@ -261,6 +261,8 @@ public:
virtual int optimize(THD* thd);
virtual int analyze(THD* thd);
virtual int dump(THD* thd, int fd = -1) { return ER_DUMP_NOT_IMPLEMENTED; }
virtual void deactivate_non_unique_index(ha_rows rows) {}
virtual bool activate_all_index(THD *thd) {return 0;}
// not implemented by default
virtual int net_read_dump(NET* net)
{ return ER_DUMP_NOT_IMPLEMENTED; }

View file

@ -1040,9 +1040,13 @@ udf_handler::fix_fields(THD *thd,TABLE_LIST *tables,Item_result_field *func,
char buff[sizeof(double)]; // Max argument in function
DBUG_ENTER("Item_udf_func::fix_fields");
if (thd && check_stack_overrun(thd,buff))
return 0; // Fatal error flag is set!
if (thd)
{
if (check_stack_overrun(thd,buff))
return 0; // Fatal error flag is set!
}
else
thd=current_thd; // In WHERE / const clause
udf_func *tmp_udf=find_udf(u_d->name,strlen(u_d->name),1);
if (!tmp_udf)
@ -1140,9 +1144,7 @@ udf_handler::fix_fields(THD *thd,TABLE_LIST *tables,Item_result_field *func,
break;
}
}
if(thd)
thd->net.last_error[0]=0;
thd->net.last_error[0]=0;
my_bool (*init)(UDF_INIT *, UDF_ARGS *, char *)=
(my_bool (*)(UDF_INIT *, UDF_ARGS *, char *))
u_d->func_init;
@ -1588,6 +1590,8 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
bool Item_func_set_user_var::fix_fields(THD *thd,TABLE_LIST *tables)
{
if (!thd)
thd=current_thd;
if (Item_func::fix_fields(thd,tables) ||
!(entry= get_variable(&thd->user_vars, name, 1)))
return 1;

View file

@ -431,6 +431,7 @@ void Item_func_curdate::fix_length_and_dec()
ltime.second= 0;
ltime.second_part=0;
ltime.neg=0;
ltime.time_type=TIMESTAMP_DATE;
}
bool Item_func_curdate::get_date(TIME *res,
@ -487,6 +488,7 @@ void Item_func_now::fix_length_and_dec()
ltime.second= start->tm_sec;
ltime.second_part=0;
ltime.neg=0;
ltime.time_type=TIMESTAMP_FULL;
}
bool Item_func_now::get_date(TIME *res,

View file

@ -231,7 +231,7 @@ static int mc_sock_connect(File s, const struct sockaddr *name, uint namelen, ui
return connect(s, (struct sockaddr*) name, namelen);
#else
int flags, res, s_err;
size_socket s_err_size = sizeof(uint);
socklen_t s_err_size = sizeof(uint);
fd_set sfds;
struct timeval tv;
@ -500,7 +500,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
UNIXaddr.sun_family = AF_UNIX;
strmov(UNIXaddr.sun_path, unix_socket);
if (mc_sock_connect(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
mysql->options.connect_timeout) <0)
mysql->options.connect_timeout) <0)
{
DBUG_PRINT("error",("Got error %d on connect to local server",ERRNO));
net->last_errno=CR_CONNECTION_ERROR;

View file

@ -219,6 +219,7 @@ int quick_rm_table(enum db_type base,const char *db,
const char *table_name);
bool mysql_change_db(THD *thd,const char *name);
void mysql_parse(THD *thd,char *inBuf,uint length);
void mysql_init_select(LEX *lex);
pthread_handler_decl(handle_one_connection,arg);
int handle_bootstrap(THD *thd,FILE *file);
sig_handler end_thread_signal(int sig);

View file

@ -656,7 +656,7 @@ static void set_user(const char *user)
unireg_abort(1);
}
#ifdef HAVE_INITGROUPS
initgroups(user,ent->pw_gid);
initgroups((char*) user,ent->pw_gid);
#endif
if (setgid(ent->pw_gid) == -1)
{
@ -876,8 +876,8 @@ void end_thread(THD *thd, bool put_in_cache)
thread_count--;
delete thd;
if (cached_thread_count < thread_cache_size && ! abort_loop &&
!kill_cached_threads)
if (put_in_cache && cached_thread_count < thread_cache_size &&
! abort_loop && !kill_cached_threads)
{
/* Don't kill the thread, just put it in cache for reuse */
DBUG_PRINT("info", ("Adding thread to cache"))
@ -891,8 +891,9 @@ void end_thread(THD *thd, bool put_in_cache)
{
wake_thread--;
thd=thread_cache.get();
threads.append(thd);
thd->real_id=pthread_self();
(void) thd->store_globals();
threads.append(thd);
pthread_mutex_unlock(&LOCK_thread_count);
DBUG_VOID_RETURN;
}
@ -2229,7 +2230,7 @@ CHANGEABLE_VAR changeable_vars[] = {
{ "bdb_cache_size", (long*) &berkeley_cache_size, KEY_CACHE_SIZE,
20*1024, (long) ~0, 0, IO_SIZE},
#endif
{ "connect_timeout", (long*) &connect_timeout,CONNECT_TIMEOUT,1,65535,0,1},
{ "connect_timeout", (long*) &connect_timeout,CONNECT_TIMEOUT,2,65535,0,1},
{ "delayed_insert_timeout",(long*) &delayed_insert_timeout,
DELAYED_WAIT_TIMEOUT,1,~0L,0,1},
{ "delayed_insert_limit",(long*) &delayed_insert_limit,

View file

@ -217,13 +217,16 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
table->time_stamp=0;
table->next_number_field=table->found_next_number_field;
VOID(table->file->extra(HA_EXTRA_WRITE_CACHE));
table->file->deactivate_non_unique_index((ha_rows) 0);
table->copy_blobs=1;
if (!field_term->length() && !enclosed->length())
error=read_fixed_length(thd,info,table,fields,read_info);
else
error=read_sep_field(thd,info,table,fields,read_info,*enclosed);
if (table->file->extra(HA_EXTRA_NO_CACHE))
if (table->file->extra(HA_EXTRA_NO_CACHE) ||
table->file->activate_all_index((ha_rows) 0))
error=1; /* purecov: inspected */
table->time_stamp=save_time_stamp;
table->next_number_field=0;
if (thd->lock)

View file

@ -34,6 +34,9 @@ extern I_List<i_string> binlog_do_db, binlog_ignore_db;
extern int yyparse(void);
extern "C" pthread_mutex_t THR_LOCK_keycache;
#ifdef SOLARIS
extern "C" int gethostname(char *name, int namelen);
#endif
static bool check_table_access(THD *thd,uint want_access,TABLE_LIST *tables);
static bool check_lock_tables(THD *thd,TABLE_LIST *tables);
@ -1571,22 +1574,23 @@ mysql_execute_command(void)
/* Check that the user isn't trying to change a password for another
user if he doesn't have UPDATE privilege to the MySQL database */
List_iterator <LEX_USER> user_list(lex->users_list);
LEX_USER *user;
if(thd->user)
if (thd->user) // If not replication
{
LEX_USER *user;
List_iterator <LEX_USER> user_list(lex->users_list);
while ((user=user_list++))
{
if (user->password.str &&
(strcmp(thd->user,user->user.str) ||
user->host.str &&
my_strcasecmp(user->host.str, thd->host ? thd->host : thd->ip)))
{
if (user->password.str &&
(strcmp(thd->user,user->user.str) ||
user->host.str && my_strcasecmp(user->host.str,
thd->host ? thd->host : thd->ip)))
{
if (check_access(thd, UPDATE_ACL, "mysql",0,1))
goto error;
break; // We are allowed to do changes
}
if (check_access(thd, UPDATE_ACL, "mysql",0,1))
goto error;
break; // We are allowed to do changes
}
}
}
if (tables)
{
if (grant_option && check_grant(thd,
@ -1614,11 +1618,11 @@ mysql_execute_command(void)
res = mysql_grant(thd, lex->db, lex->users_list, lex->grant,
lex->sql_command == SQLCOM_REVOKE);
if(!res)
{
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
{
mysql_update_log.write(thd->query,thd->query_length);
Query_log_event qinfo(thd, thd->query);
mysql_bin_log.write(&qinfo);
}
}
break;
}
@ -1853,12 +1857,27 @@ mysql_init_query(THD *thd)
thd->lex.table_list.first=0;
thd->lex.table_list.next= (byte**) &thd->lex.table_list.first;
thd->lex.proc_list.first=0; // Needed by sql_select
thd->fatal_error=0; // Safety
thd->last_insert_id_used=thd->query_start_used=thd->insert_id_used=0;
DBUG_VOID_RETURN;
}
void
mysql_init_select(LEX *lex)
{
lex->where=lex->having=0;
lex->select_limit=current_thd->default_select_limit;
lex->offset_limit=0L;
lex->options=0;
lex->exchange = 0;
lex->proc_list.first=0;
lex->order_list.elements=lex->group_list.elements=0;
lex->order_list.first=0;
lex->order_list.next= (byte**) &lex->order_list.first;
lex->group_list.first=0;
lex->group_list.next= (byte**) &lex->group_list.first;
}
void
mysql_parse(THD *thd,char *inBuf,uint length)

View file

@ -1939,35 +1939,37 @@ get_best_combination(JOIN *join)
}
else
{
for (i=0 ; i < keyparts ; keyuse++,i++)
{
while (keyuse->keypart != i ||
((~used_tables) & keyuse->used_tables))
keyuse++; /* Skipp other parts */
THD *thd=current_thd;
for (i=0 ; i < keyparts ; keyuse++,i++)
{
while (keyuse->keypart != i ||
((~used_tables) & keyuse->used_tables))
keyuse++; /* Skipp other parts */
uint maybe_null= test(keyinfo->key_part[i].null_bit);
j->ref.items[i]=keyuse->val; // Save for cond removal
if (!keyuse->used_tables &&
!(join->select_options & SELECT_DESCRIBE))
{ // Compare against constant
store_key_item *tmp=new store_key_item(keyinfo->key_part[i].field,
(char*)key_buff + maybe_null,
maybe_null ?
(char*) key_buff : 0,
keyinfo->key_part[i].length,
keyuse->val);
if (current_thd->fatal_error)
{
return TRUE;
uint maybe_null= test(keyinfo->key_part[i].null_bit);
j->ref.items[i]=keyuse->val; // Save for cond removal
if (!keyuse->used_tables &&
!(join->select_options & SELECT_DESCRIBE))
{ // Compare against constant
store_key_item *tmp=new store_key_item(keyinfo->key_part[i].field,
(char*)key_buff +
maybe_null,
maybe_null ?
(char*) key_buff : 0,
keyinfo->key_part[i].length,
keyuse->val);
if (thd->fatal_error)
{
return TRUE;
}
tmp->copy();
}
tmp->copy();
else
*ref_key++= get_store_key(keyuse,join->const_table_map,
&keyinfo->key_part[i],
(char*) key_buff,maybe_null);
key_buff+=keyinfo->key_part[i].store_length;
}
else
*ref_key++= get_store_key(keyuse,join->const_table_map,
&keyinfo->key_part[i],
(char*) key_buff,maybe_null);
key_buff+=keyinfo->key_part[i].store_length;
}
} /* not ftkey */
*ref_key=0; // end_marker
if (j->type == JT_FT) /* no-op */;
@ -2319,8 +2321,11 @@ join_free(JOIN *join)
if (join->table)
{
/* only sorted table is cached */
if (join->tables > join->const_tables)
/*
Only a sorted table may be cached. This sorted table is always the
first non const table in join->table
*/
if (join->tables > join->const_tables) // Test for not-const tables
free_io_cache(join->table[join->const_tables]);
for (tab=join->join_tab,end=tab+join->tables ; tab != end ; tab++)
{
@ -2858,23 +2863,24 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
Item_func_isnull *func=(Item_func_isnull*) cond;
Item **args= func->arguments();
THD *thd=current_thd;
if (args[0]->type() == Item::FIELD_ITEM)
{
Field *field=((Item_field*) args[0])->field;
if (field->flags & AUTO_INCREMENT_FLAG && !field->table->maybe_null &&
(current_thd->options & OPTION_AUTO_IS_NULL) &&
current_thd->insert_id())
(thd->options & OPTION_AUTO_IS_NULL) &&
thd->insert_id())
{
COND *new_cond;
if ((new_cond= new Item_func_eq(args[0],
new Item_int("last_insert_id()",
current_thd->insert_id(),
thd->insert_id(),
21))))
{
cond=new_cond;
cond->fix_fields(current_thd,0);
cond->fix_fields(thd,0);
}
current_thd->insert_id(0); // Clear for next request
thd->insert_id(0); // Clear for next request
}
/* fix to replace 'NULL' dates with '0' (shreeve@uci.edu) */
else if (((field->type() == FIELD_TYPE_DATE) ||
@ -2885,7 +2891,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
if ((new_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2))))
{
cond=new_cond;
cond->fix_fields(current_thd,0);
cond->fix_fields(thd,0);
}
}
}
@ -6229,6 +6235,11 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
}
if (thd->fatal_error)
DBUG_RETURN(TRUE);
/*
Here we pass 0 as the first argument to fix_fields that don't need
to do any stack checking (This is already done in the initial fix_fields).
*/
cond->fix_fields((THD *) 0,(TABLE_LIST *) 0);
if (join_tab->select)
{

View file

@ -709,6 +709,7 @@ bool close_cached_table(THD *thd,TABLE *table)
DBUG_RETURN(result);
}
int mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
{
TABLE_LIST *table;
@ -1144,6 +1145,11 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
if (alter)
{
if (def->sql_type == FIELD_TYPE_BLOB)
{
my_error(ER_BLOB_CANT_HAVE_DEFAULT,MYF(0),def->change);
DBUG_RETURN(-1);
}
def->def=alter->def; // Use new default
alter_it.remove();
}
@ -1504,6 +1510,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,List<create_field> &create,
to->file->external_lock(thd,F_WRLCK);
to->file->extra(HA_EXTRA_WRITE_CACHE);
from->file->info(HA_STATUS_VARIABLE);
to->file->deactivate_non_unique_index(from->file->records);
List_iterator<create_field> it(create);
create_field *def;
@ -1554,6 +1562,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,List<create_field> &create,
to->file->print_error(tmp_error,MYF(0));
error=1;
}
if (to->file->activate_all_index(thd))
error=1;
if (ha_commit(thd) || to->file->external_lock(thd,F_UNLCK))
error=1;
*copied= found_count;

View file

@ -680,17 +680,7 @@ create3:
/* empty*/ {}
| opt_duplicate SELECT_SYM
{
LEX *lex=Lex;
lex->where=lex->having=0;
lex->select_limit=current_thd->default_select_limit;
lex->offset_limit=0L;
lex->options=0;
lex->exchange = 0;
lex->order_list.elements=lex->group_list.elements=0;
lex->order_list.first=0;
lex->order_list.next= (byte**) &lex->order_list.first;
lex->group_list.first=0;
lex->group_list.next= (byte**) &lex->group_list.first;
mysql_init_select(Lex);
}
select_options select_item_list opt_select_from {}
@ -1149,17 +1139,8 @@ select:
SELECT_SYM
{
LEX *lex=Lex;
lex->where=lex->having=0;
lex->select_limit=current_thd->default_select_limit;
lex->offset_limit=0L;
lex->options=0;
lex->sql_command= SQLCOM_SELECT;
lex->exchange = 0;
lex->order_list.elements=lex->group_list.elements=0;
lex->order_list.first=0;
lex->order_list.next= (byte**) &lex->order_list.first;
lex->group_list.first=0;
lex->group_list.next= (byte**) &lex->group_list.first;
mysql_init_select(lex);
}
select_options select_item_list select_into
@ -1973,17 +1954,9 @@ insert_values:
| SELECT_SYM
{
LEX *lex=Lex;
lex->where=lex->having=0;
lex->select_limit=current_thd->default_select_limit;
lex->offset_limit=0L;
lex->options=0;
lex->order_list.elements=lex->group_list.elements=0;
lex->order_list.first=0;
lex->order_list.next= (byte**) &lex->order_list.first;
lex->group_list.first=0;
lex->group_list.next= (byte**) &lex->group_list.first;
lex->sql_command = (lex->sql_command == SQLCOM_INSERT ?
SQLCOM_INSERT_SELECT : SQLCOM_REPLACE_SELECT);
mysql_init_select(lex);
}
select_options select_item_list select_from {}

View file

@ -70,6 +70,9 @@ typedef struct st_key {
KEY_PART_INFO *key_part;
char *name; /* Name of key */
ulong *rec_per_key; /* Key part distribution */
union {
uint bdb_return_if_eq;
} handler;
} KEY;

View file

@ -224,7 +224,7 @@ int my_strnncoll_sjis(const uchar *s1, int len1, const uchar *s2, int len2)
int my_strcoll_sjis(const uchar *s1, const uchar *s2)
{
return my_strnncoll_sjis(s1, strlen(s1), s2, strlen(s2));
return (uint) my_strnncoll_sjis(s1,(uint) strlen(s1), s2,(uint) strlen(s2));
}
int my_strnxfrm_sjis(uchar *dest, uchar *src, int len, int srclen)
@ -245,7 +245,7 @@ int my_strnxfrm_sjis(uchar *dest, uchar *src, int len, int srclen)
int my_strxfrm_sjis(uchar *dest, uchar *src, int len)
{
return my_strnxfrm_sjis(dest, src, len, strlen(src));
return my_strnxfrm_sjis(dest, src, len, (uint) strlen(src));
}

View file

@ -12,7 +12,7 @@
*/
/* $Id$
/*
This file is basicly tis620 character sets with some extra functions
for tis-620 handling
*/
@ -443,7 +443,7 @@ static uchar* thai2sortable(const uchar * tstr,uint len)
uint bufSize;
len = (uint) strnlen((char*) tstr,len);
bufSize = buffsize((char*) tstr);
bufSize = (uint) buffsize((char*) tstr);
if(!(pRight1 = (uchar *)malloc(sizeof(uchar) * bufSize))) {
return( (uchar*) tstr);
}
@ -530,7 +530,7 @@ int my_strnxfrm_tis620(uchar * dest, uchar * src, int len, int srclen)
{
uint bufSize;
uchar *tmp;
bufSize = buffsize((char*)src);
bufSize = (uint) buffsize((char*)src);
tmp = thai2sortable(src,srclen);
set_if_smaller(bufSize,(uint) len);
memcpy((uchar *)dest, tmp, bufSize);
@ -563,7 +563,7 @@ int my_strxfrm_tis620(uchar * dest, uchar * src, int len)
uint bufSize;
uchar *tmp;
bufSize = buffsize((char*) src);
bufSize = (uint) buffsize((char*) src);
tmp = thai2sortable(src, len);
memcpy((uchar *) dest, tmp, bufSize);
free(tmp);
@ -586,7 +586,7 @@ my_bool my_like_range_tis620(const char *ptr, uint ptr_length, pchar escape,
uint tbuff_length;
tbuff = (char*) (tc=thai2sortable((uchar*) ptr, ptr_length));
tbuff_length = buffsize(ptr);
tbuff_length = (uint) buffsize(ptr);
end = tbuff + tbuff_length;
for(;tbuff != end && min_str != min_end; tbuff++)
{

View file

@ -9,8 +9,8 @@
"as is" without express or implied warranty.
*/
/* $Id$
LC_COLLATE category + Level information
/*
LC_COLLATE category + Level information
*/
#ifndef _t_ctype_h

View file

@ -162,6 +162,8 @@ sh -c "PATH=\"${MYSQL_BUILD_PATH:-/bin:/usr/bin}\" \
--with-comment=\"Official MySQL RPM\";
# Add this for more debugging support
# --with-debug
# Add this for MyISAM RAID support:
# --with-raid
"
# benchdir does not fit in above model. Maybe a separate bench distribution

View file

@ -6,8 +6,6 @@
#include <unistd.h>
VIO_RCSID(vio, viotest_ssl, "$Id$")
void
fatal_error( const char* r)
{

View file

@ -13,8 +13,6 @@
#include <unistd.h>
VIO_RCSID(vio, viotest_sslconnect, "$Id$")
void
fatal_error( const char* r)
{

View file

@ -11,8 +11,6 @@
#include <string.h>
VIO_RCSID(vio, Vio, "$Id$")
VIO_NS_USING;
int