diff options
Diffstat (limited to 'storage/myisam')
-rw-r--r-- | storage/myisam/ft_boolean_search.c | 36 | ||||
-rw-r--r-- | storage/myisam/ft_nlq_search.c | 6 | ||||
-rw-r--r-- | storage/myisam/ft_parser.c | 32 | ||||
-rw-r--r-- | storage/myisam/ft_stopwords.c | 5 | ||||
-rw-r--r-- | storage/myisam/ftdefs.h | 10 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 5 | ||||
-rw-r--r-- | storage/myisam/mi_check.c | 10 | ||||
-rw-r--r-- | storage/myisam/myisam_ftdump.c | 2 | ||||
-rw-r--r-- | storage/myisam/myisamchk.c | 6 | ||||
-rw-r--r-- | storage/myisam/myisamdef.h | 2 | ||||
-rw-r--r-- | storage/myisam/myisamlog.c | 2 | ||||
-rw-r--r-- | storage/myisam/sort.c | 11 |
12 files changed, 65 insertions, 62 deletions
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index ddb932e234e..193ce510f98 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -180,7 +180,7 @@ typedef struct st_my_ftb_param static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param, - char *word, int word_len, + const uchar *word, size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *info) { MY_FTB_PARAM *ftb_param= param->mysql_ftparam; @@ -282,19 +282,19 @@ static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, - char *query, int len) + const uchar *query, size_t len) { MY_FTB_PARAM *ftb_param= param->mysql_ftparam; MYSQL_FTPARSER_BOOLEAN_INFO info; CHARSET_INFO *cs= ftb_param->ftb->charset; - uchar **start= (uchar**) &query; - uchar *end= (uchar*) query + len; + const uchar **start= &query; + const uchar *end= query + len; FT_WORD w; info.prev= ' '; info.quot= 0; while (ft_get_word(cs, start, end, &w, &info)) - param->mysql_add_word(param, (char*) w.pos, w.len, &info); + param->mysql_add_word(param, w.pos, w.len, &info); return(0); } @@ -616,7 +616,7 @@ typedef struct st_my_ftb_phrase_param static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param, - char *word, int word_len, + const uchar *word, size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) { MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; @@ -648,15 +648,15 @@ static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, - char *document, int len) + const uchar *document, size_t len) { FT_WORD word; MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; const uchar *docend= (uchar*) document + len; - while (ft_simple_get_word(phrase_param->cs, (uchar**) &document, docend, + while (ft_simple_get_word(phrase_param->cs, &document, docend, &word, FALSE)) { - param->mysql_add_word(param, (char*) word.pos, word.len, 0); + param->mysql_add_word(param, word.pos, word.len, 0); if (phrase_param->match) break; } @@ -874,7 +874,7 @@ typedef struct st_my_ftb_find_param static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, - char *word, int len, + const uchar *word, size_t len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) { MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam; @@ -888,8 +888,8 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, for (a= 0, b= ftb->queue.elements, c= (a+b)/2; b-a>1; c= (a+b)/2) { ftbw= ftb->list[c]; - if (ha_compare_text(ftb->charset, (uchar*)word, len, - (uchar*)ftbw->word+1, ftbw->len-1, + if (ha_compare_text(ftb->charset, word, len, + ftbw->word+1, ftbw->len-1, (my_bool) (ftbw->flags & FTB_FLAG_TRUNC), 0) < 0) b= c; else @@ -915,8 +915,8 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, for (; c >= 0; c--) { ftbw= ftb->list[c]; - if (ha_compare_text(ftb->charset, (uchar*)word, len, - (uchar*)ftbw->word + 1,ftbw->len - 1, + if (ha_compare_text(ftb->charset, word, len, + ftbw->word + 1,ftbw->len - 1, (my_bool)(ftbw->flags & FTB_FLAG_TRUNC), 0)) { if (ftb->with_scan & FTB_FLAG_TRUNC) @@ -935,14 +935,14 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_find_relevance_parse(MYSQL_FTPARSER_PARAM *param, - char *doc, int len) + const uchar *doc, size_t len) { MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam; FT_INFO *ftb= ftb_param->ftb; - uchar *end= (uchar*) doc + len; + const uchar *end= doc + len; FT_WORD w; - while (ft_simple_get_word(ftb->charset, (uchar**) &doc, end, &w, TRUE)) - param->mysql_add_word(param, (char*) w.pos, w.len, 0); + while (ft_simple_get_word(ftb->charset, &doc, end, &w, TRUE)) + param->mysql_add_word(param, w.pos, w.len, 0); return(0); } diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index eb563638d36..da593a3debc 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -63,7 +63,8 @@ static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)), static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) { - int subkeys, r; + int32 subkeys; + int r; uint keylen, doc_cnt; FT_SUPERDOC sdoc, *sptr; TREE_ELEMENT *selem; @@ -123,7 +124,8 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) goto do_skip; } #if HA_FT_WTYPE == HA_KEYTYPE_FLOAT - tmp_weight=*(float*)&subkeys; + /* The weight we read was actually a float */ + tmp_weight=*(float*) (char*) &subkeys; #else #error #endif diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index 4cde3834ed7..cacedaaeea0 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -106,10 +106,10 @@ my_bool ft_boolean_check_syntax_string(const uchar *str) 3 - right bracket 4 - stopword found */ -uchar ft_get_word(CHARSET_INFO *cs, uchar **start, uchar *end, +uchar ft_get_word(CHARSET_INFO *cs, const uchar **start, const uchar *end, FT_WORD *word, MYSQL_FTPARSER_BOOLEAN_INFO *param) { - uchar *doc=*start; + const uchar *doc= *start; int ctype; uint mwc, length; int mbl; @@ -201,10 +201,11 @@ ret: return param->type; } -uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, - FT_WORD *word, my_bool skip_stopwords) +uchar ft_simple_get_word(CHARSET_INFO *cs, const uchar **start, + const uchar *end, FT_WORD *word, + my_bool skip_stopwords) { - uchar *doc= *start; + const uchar *doc= *start; uint mwc, length; int mbl; int ctype; @@ -216,7 +217,7 @@ uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, { if (doc >= end) DBUG_RETURN(0); - mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end); + mbl= cs->cset->ctype(cs, &ctype, doc, end); if (true_word_char(ctype, *doc)) break; } @@ -225,7 +226,7 @@ uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1))) { - mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end); + mbl= cs->cset->ctype(cs, &ctype, doc, end); if (true_word_char(ctype, *doc)) mwc= 0; else if (!misc_word_char(*doc) || mwc) @@ -238,7 +239,7 @@ uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, if (skip_stopwords == FALSE || (length >= ft_min_word_len && length < ft_max_word_len && - !is_stopword((char*) word->pos, word->len))) + !is_stopword(word->pos, word->len))) { *start= doc; DBUG_RETURN(1); @@ -257,8 +258,9 @@ void ft_parse_init(TREE *wtree, CHARSET_INFO *cs) static int ft_add_word(MYSQL_FTPARSER_PARAM *param, - char *word, int word_len, - MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) + const uchar *word, size_t word_len, + MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info + __attribute__((unused))) { TREE *wtree; FT_WORD w; @@ -286,10 +288,10 @@ static int ft_add_word(MYSQL_FTPARSER_PARAM *param, static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, - char *doc_arg, int doc_len) + const uchar *doc_arg, size_t doc_len) { - uchar *doc= (uchar*) doc_arg; - uchar *end= doc + doc_len; + const uchar *doc= doc_arg; + const uchar *end= doc + doc_len; MY_FT_PARSER_PARAM *ft_param=param->mysql_ftparam; TREE *wtree= ft_param->wtree; FT_WORD w; @@ -302,7 +304,7 @@ static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, } -int ft_parse(TREE *wtree, uchar *doc, int doclen, +int ft_parse(TREE *wtree, const uchar *doc, int doclen, struct st_mysql_ftparser *parser, MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root) { @@ -377,7 +379,7 @@ MYSQL_FTPARSER_PARAM *ftparser_call_initializer(MI_INFO *info, mysql_add_word != 0 - parser is initialized, or no initialization needed. */ info->ftparser_param[ftparser_nr].mysql_add_word= - (int (*)(struct st_mysql_ftparser_param *, char *, int, + (int (*)(struct st_mysql_ftparser_param *, const uchar *, size_t, MYSQL_FTPARSER_BOOLEAN_INFO *)) 1; if (parser->init && parser->init(&info->ftparser_param[ftparser_nr])) return 0; diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index 8aefffbee1d..db4cd3b32b6 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -66,7 +66,8 @@ int ft_init_stopwords() { File fd; uint len; - uchar *buffer, *start, *end; + uchar *buffer; + const uchar *start, *end; FT_WORD w; int error=-1; @@ -109,7 +110,7 @@ err0: } -int is_stopword(char *word, uint len) +int is_stopword(const uchar *word, size_t len) { FT_STOPWORD sw; sw.pos=word; diff --git a/storage/myisam/ftdefs.h b/storage/myisam/ftdefs.h index ddcf1a8dc26..2b4c46c78ad 100644 --- a/storage/myisam/ftdefs.h +++ b/storage/myisam/ftdefs.h @@ -96,18 +96,18 @@ #define FTB_RQUOT (ft_boolean_syntax[11]) typedef struct st_ft_word { - uchar * pos; + const uchar *pos; uint len; double weight; } FT_WORD; -int is_stopword(char *word, uint len); +int is_stopword(const uchar *word, size_t len); uint _ft_make_key(MI_INFO *, uint , uchar *, FT_WORD *, my_off_t); -uchar ft_get_word(CHARSET_INFO *, uchar **, uchar *, FT_WORD *, +uchar ft_get_word(CHARSET_INFO *, const uchar **, const uchar *, FT_WORD *, MYSQL_FTPARSER_BOOLEAN_INFO *); -uchar ft_simple_get_word(CHARSET_INFO *, uchar **, const uchar *, +uchar ft_simple_get_word(CHARSET_INFO *, const uchar **, const uchar *, FT_WORD *, my_bool); typedef struct _st_ft_seg_iterator { @@ -121,7 +121,7 @@ void _mi_ft_segiterator_dummy_init(const uchar *, uint, FT_SEG_ITERATOR *); uint _mi_ft_segiterator(FT_SEG_ITERATOR *); void ft_parse_init(TREE *, CHARSET_INFO *); -int ft_parse(TREE *, uchar *, int, struct st_mysql_ftparser *parser, +int ft_parse(TREE *, const uchar *, int, struct st_mysql_ftparser *parser, MYSQL_FTPARSER_PARAM *, MEM_ROOT *); FT_WORD * ft_linearize(TREE *, MEM_ROOT *); FT_WORD * _mi_ft_parserecord(MI_INFO *, uint, const uchar *, MEM_ROOT *); diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index fd35410682e..930f8ed8c59 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -497,10 +497,9 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, extern "C" { -volatile int *killed_ptr(HA_CHECK *param) +int killed_ptr(HA_CHECK *param) { - /* In theory Unsafe conversion, but should be ok for now */ - return (int*) &(((THD *)(param->thd))->killed); + return thd_killed((THD*)param->thd); } void mi_check_print_error(HA_CHECK *param, const char *fmt,...) diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index c6140e0bcd8..ac90f41e80d 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -166,7 +166,7 @@ int chk_del(HA_CHECK *param, register MI_INFO *info, ulonglong test_flag) empty=0; for (i= info->state->del ; i > 0L && next_link != HA_OFFSET_ERROR ; i--) { - if (*killed_ptr(param)) + if (killed_ptr(param)) DBUG_RETURN(1); if (test_flag & T_VERBOSE) printf(" %9s",llstr(next_link,buff)); @@ -261,7 +261,7 @@ static int check_k_link(HA_CHECK *param, register MI_INFO *info, uint nr) records= (ha_rows) (info->state->key_file_length / block_size); while (next_link != HA_OFFSET_ERROR && records > 0) { - if (*killed_ptr(param)) + if (killed_ptr(param)) DBUG_RETURN(1); if (param->testflag & T_VERBOSE) printf("%16s",llstr(next_link,llbuff)); @@ -778,7 +778,7 @@ static int chk_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, } for ( ;; ) { - if (*killed_ptr(param)) + if (killed_ptr(param)) goto err; memcpy((char*) info->lastkey,(char*) key,key_length); info->lastkey_length=key_length; @@ -990,7 +990,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend) bzero((char*) key_checksum, info->s->base.keys * sizeof(key_checksum[0])); while (pos < info->state->data_file_length) { - if (*killed_ptr(param)) + if (killed_ptr(param)) goto err2; switch (info->s->data_file_type) { case BLOCK_RECORD: @@ -3247,7 +3247,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) char llbuff[22],llbuff2[22]; DBUG_ENTER("sort_get_next_record"); - if (*killed_ptr(param)) + if (killed_ptr(param)) DBUG_RETURN(1); switch (share->data_file_type) { diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c index 63d954242a0..b7b035559f7 100644 --- a/storage/myisam/myisam_ftdump.c +++ b/storage/myisam/myisam_ftdump.c @@ -113,7 +113,7 @@ int main(int argc,char *argv[]) subkeys=ft_sintXkorr(info->lastkey+keylen+1); if (subkeys >= 0) - weight=*(float*)&subkeys; + weight= *(float*) (char*) &subkeys; #ifdef HAVE_SNPRINTF snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey+1); diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 6b3ea48e040..b4b4a0215c2 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -1745,11 +1745,9 @@ err: sorting */ -static int not_killed= 0; - -volatile int *killed_ptr(HA_CHECK *param __attribute__((unused))) +int killed_ptr(HA_CHECK *param __attribute__((unused))) { - return ¬_killed; /* always NULL */ + return 0; } /* print warnings and errors */ diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index c2841c49199..680bdbf16dd 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -725,7 +725,7 @@ my_bool mi_dynmap_file(MI_INFO *info, my_off_t size); void mi_remap_file(MI_INFO *info, my_off_t size); /* Functions needed by mi_check */ -volatile int *killed_ptr(HA_CHECK *param); +int killed_ptr(HA_CHECK *param); void mi_check_print_error _VARARGS((HA_CHECK *param, const char *fmt, ...)); void mi_check_print_warning _VARARGS((HA_CHECK *param, const char *fmt, ...)); void mi_check_print_info _VARARGS((HA_CHECK *param, const char *fmt, ...)); diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index 6e681676c12..679dc0b731b 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -385,7 +385,7 @@ static int examine_log(char * file_name, char **table_names) file_info.name=0; file_info.show_name=0; file_info.record=0; - if (read_string(&cache,(uchar**) &file_info.name, + if (read_string(&cache,(uchar**) (char*) &file_info.name, (uint) mi_uint2korr(head))) goto err; { diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index 3aaef41e1dd..607ddd66d3c 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -900,7 +900,6 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, uchar *strpos; BUFFPEK *buffpek,**refpek; QUEUE queue; - volatile int *killed= killed_ptr(info->sort_info->param); DBUG_ENTER("merge_buffers"); count=error=0; @@ -933,10 +932,6 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, { for (;;) { - if (*killed) - { - error=1; goto err; - } buffpek=(BUFFPEK*) queue_top(&queue); if (to_file) { @@ -956,6 +951,12 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, buffpek->key+=sort_length; if (! --buffpek->mem_count) { + /* It's enough to check for killedptr before a slow operation */ + if (killed_ptr(info->sort_info->param)) + { + error=1; + goto err; + } if (!(error=(int) info->read_to_buffer(from_file,buffpek,sort_length))) { uchar *base= buffpek->base; |