diff options
author | Michael Widenius <monty@askmonty.org> | 2009-11-30 15:36:06 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2009-11-30 15:36:06 +0200 |
commit | f12371c8601774eba10d42ddaf6399334f3378e1 (patch) | |
tree | d5878052823f9a1345068a3b20275d13e0a41e9e | |
parent | 35ddfbf36ee5bd9eb252b97879033cf8c7ae531f (diff) | |
download | mariadb-git-f12371c8601774eba10d42ddaf6399334f3378e1.tar.gz |
Fixes after comments from last push:
- Removed some not needed casts
- Change plugin.h to be 'binary compatible' with old versions
- Added mysql_ft_size_t typedef to plugin.h to make it trivial to change string lengths to size_t on next ABI change
- Made some fixes suggested by Kristian to make things more portable and future safe (when it comes to strict aliasing)
include/ft_global.h:
Introduced FT_WEIGTH, to handle fulltext weights in a slightly more portable manner
include/mysql/plugin.h:
Change plugin.h to be 'binary compatible' with old versions
Added mysql_ft_size_t typedef to plugin.h to make it trivial to change string lengths to size_t on next ABI change
Changed flags to unsigned (as flags should always be unsigned)
mysql-test/t/information_schema.test:
Fixed typo
sql/sp_head.cc:
Removed cast
sql/sql_select.cc:
Removed cast
sql/table.cc:
Removed cast
storage/maria/ma_ft_boolean_search.c:
Use mysql_ft_size_t instead of size_t for plugin.h code
Changed some other string lengths to size_t
storage/maria/ma_ft_nlq_search.c:
Use FT_WEIGTH to make code more portable
storage/maria/ma_ft_parser.c:
Use mysql_ft_size_t instead of size_t for plugin.h code
Changed some other string lengths to size_t
storage/maria/ma_ftdefs.h:
Changed some string lengths to size_t
storage/maria/maria_ftdump.c:
Use FT_WEIGTH to make code more portable
storage/myisam/ft_boolean_search.c:
Use mysql_ft_size_t instead of size_t for plugin.h code
storage/myisam/ft_nlq_search.c:
Use FT_WEIGTH to make code more portable
storage/myisam/ft_parser.c:
Use mysql_ft_size_t instead of size_t for plugin.h code
storage/myisam/myisam_ftdump.c:
Use FT_WEIGTH to make code more portable
-rw-r--r-- | include/ft_global.h | 2 | ||||
-rw-r--r-- | include/mysql/plugin.h | 13 | ||||
-rw-r--r-- | include/mysql/plugin.h.pp | 11 | ||||
-rw-r--r-- | mysql-test/t/information_schema.test | 2 | ||||
-rw-r--r-- | sql/sp_head.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | sql/table.cc | 2 | ||||
-rw-r--r-- | storage/maria/ma_ft_boolean_search.c | 35 | ||||
-rw-r--r-- | storage/maria/ma_ft_nlq_search.c | 22 | ||||
-rw-r--r-- | storage/maria/ma_ft_parser.c | 15 | ||||
-rw-r--r-- | storage/maria/ma_ftdefs.h | 8 | ||||
-rw-r--r-- | storage/maria/maria_ftdump.c | 16 | ||||
-rw-r--r-- | storage/myisam/ft_boolean_search.c | 16 | ||||
-rw-r--r-- | storage/myisam/ft_nlq_search.c | 10 | ||||
-rw-r--r-- | storage/myisam/ft_parser.c | 8 | ||||
-rw-r--r-- | storage/myisam/myisam_ftdump.c | 15 |
16 files changed, 99 insertions, 80 deletions
diff --git a/include/ft_global.h b/include/ft_global.h index dba8a6e75e5..8fe5ee5c42e 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -76,6 +76,8 @@ my_bool ft_boolean_check_syntax_string(const uchar *); extern const HA_KEYSEG ft_keysegs[FT_SEGS]; +typedef union {int32 i; float f;} FT_WEIGTH; + #ifdef __cplusplus } #endif diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 91e8a80b408..b33f5970110 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -564,19 +564,22 @@ typedef struct st_mysql_ftparser_boolean_info nothing. See enum_ftparser_mode above. */ +/* TODO: Change the following int to size_t at next ABI update */ +typedef int mysql_ft_size_t; + typedef struct st_mysql_ftparser_param { int (*mysql_parse)(struct st_mysql_ftparser_param *, - const unsigned char *doc, size_t doc_len); + const unsigned char *doc, mysql_ft_size_t doc_len); int (*mysql_add_word)(struct st_mysql_ftparser_param *, - const unsigned char *word, size_t word_len, + const unsigned char *word, mysql_ft_size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info); void *ftparser_state; void *mysql_ftparam; struct charset_info_st *cs; - char *doc; - int length; - int flags; + const unsigned char *doc; + mysql_ft_size_t length; + unsigned int flags; enum enum_ftparser_mode mode; } MYSQL_FTPARSER_PARAM; diff --git a/include/mysql/plugin.h.pp b/include/mysql/plugin.h.pp index 22b1f647736..2f44870b479 100644 --- a/include/mysql/plugin.h.pp +++ b/include/mysql/plugin.h.pp @@ -70,19 +70,20 @@ typedef struct st_mysql_ftparser_boolean_info char prev; char *quot; } MYSQL_FTPARSER_BOOLEAN_INFO; +typedef int mysql_ft_size_t; typedef struct st_mysql_ftparser_param { int (*mysql_parse)(struct st_mysql_ftparser_param *, - const unsigned char *doc, size_t doc_len); + const unsigned char *doc, mysql_ft_size_t doc_len); int (*mysql_add_word)(struct st_mysql_ftparser_param *, - const unsigned char *word, size_t word_len, + const unsigned char *word, mysql_ft_size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info); void *ftparser_state; void *mysql_ftparam; struct charset_info_st *cs; - char *doc; - int length; - int flags; + const unsigned char *doc; + mysql_ft_size_t length; + unsigned int flags; enum enum_ftparser_mode mode; } MYSQL_FTPARSER_PARAM; struct st_mysql_ftparser diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 7731c59baf3..1298bb89754 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -5,7 +5,7 @@ # on the presence of the log tables (which are CSV-based). --source include/have_csv.inc -# Check that innodb/xtradb is incompiled in as result depends on it +# Check that InnoDB/XtraDB was compiled in as result depends on it -- source include/have_innodb.inc # Save the initial number of concurrent sessions diff --git a/sql/sp_head.cc b/sql/sp_head.cc index ead4a1bfe58..5255ff8b915 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1924,7 +1924,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (spvar->mode == sp_param_out) { Item_null *null_item= new Item_null(); - Item *tmp_item= (Item*) null_item; + Item *tmp_item= null_item; if (!null_item || nctx->set_variable(thd, i, &tmp_item)) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b44accd1123..6c519dc1733 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3586,7 +3586,7 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level, { if (!field->eq(item->field)) { - Item *tmp_item= (Item*) item; + Item *tmp_item= item; add_key_field(key_fields, *and_level, cond_func, field, TRUE, &tmp_item, 1, usable_tables, sargables); diff --git a/sql/table.cc b/sql/table.cc index fa1f215d7b5..f44d3e15d3a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2077,7 +2077,7 @@ ulong get_form_pos(File file, uchar *head, TYPELIB *save_names) else { char *str; - const char **tmp = (const char**) (char*) buf; + const char **tmp = (const char**) buf; str=(char *) (buf+a_length); fix_type_pointers(&tmp, save_names, 1, &str); } diff --git a/storage/maria/ma_ft_boolean_search.c b/storage/maria/ma_ft_boolean_search.c index c91a4ac46f1..6cd23558784 100644 --- a/storage/maria/ma_ft_boolean_search.c +++ b/storage/maria/ma_ft_boolean_search.c @@ -180,7 +180,7 @@ typedef struct st_my_ftb_param static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t word_len, + const uchar *word, mysql_ft_size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *info) { MY_FTB_PARAM *ftb_param= param->mysql_ftparam; @@ -282,7 +282,7 @@ static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, - const uchar *query, size_t len) + const uchar *query, mysql_ft_size_t len) { MY_FTB_PARAM *ftb_param= param->mysql_ftparam; MYSQL_FTPARSER_BOOLEAN_INFO info; @@ -299,7 +299,7 @@ static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, } -static int _ftb_parse_query(FTB *ftb, uchar *query, uint len, +static int _ftb_parse_query(FTB *ftb, uchar *query, size_t len, struct st_mysql_ftparser *parser) { MYSQL_FTPARSER_PARAM *param; @@ -321,7 +321,7 @@ static int _ftb_parse_query(FTB *ftb, uchar *query, uint len, param->mysql_add_word= ftb_query_add_word; param->mysql_ftparam= (void *)&ftb_param; param->cs= ftb->charset; - param->doc= (char*) query; + param->doc= query; param->length= len; param->flags= 0; param->mode= MYSQL_FTPARSER_FULL_BOOLEAN_INFO; @@ -539,8 +539,8 @@ static void _ftb_init_index_search(FT_INFO *ftb) FT_INFO * maria_ft_init_boolean_search(MARIA_HA *info, uint keynr, - uchar *query, - uint query_len, CHARSET_INFO *cs) + uchar *query, size_t query_len, + CHARSET_INFO *cs) { FTB *ftb; FTB_EXPR *ftbe; @@ -615,8 +615,9 @@ typedef struct st_my_ftb_phrase_param static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t word_len, - MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) + const uchar *word, mysql_ft_size_t word_len, + MYSQL_FTPARSER_BOOLEAN_INFO + *boolean_info __attribute__((unused))) { MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; FT_WORD *w= (FT_WORD *)phrase_param->document->data; @@ -647,7 +648,8 @@ static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, - const uchar *document, size_t len) + const uchar *document, + mysql_ft_size_t len) { FT_WORD word; MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; @@ -678,8 +680,8 @@ static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, -1 is returned if error occurs. */ -static int _ftb_check_phrase(FTB *ftb, const uchar *document, uint len, - FTB_EXPR *ftbe, struct st_mysql_ftparser *parser) +static int _ftb_check_phrase(FTB *ftb, const uchar *document, size_t len, + FTB_EXPR *ftbe, struct st_mysql_ftparser *parser) { MY_FTB_PHRASE_PARAM ftb_param; MYSQL_FTPARSER_PARAM *param; @@ -699,7 +701,7 @@ static int _ftb_check_phrase(FTB *ftb, const uchar *document, uint len, param->mysql_add_word= ftb_phrase_add_word; param->mysql_ftparam= (void *)&ftb_param; param->cs= ftb->charset; - param->doc= (char *) document; + param->doc= document; param->length= len; param->flags= 0; param->mode= MYSQL_FTPARSER_WITH_STOPWORDS; @@ -872,8 +874,9 @@ typedef struct st_my_ftb_find_param static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t len, - MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) + const uchar *word, mysql_ft_size_t len, + MYSQL_FTPARSER_BOOLEAN_INFO + *boolean_info __attribute__((unused))) { MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam; FT_INFO *ftb= ftb_param->ftb; @@ -933,7 +936,7 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_find_relevance_parse(MYSQL_FTPARSER_PARAM *param, - const uchar *doc, size_t len) + const uchar *doc, mysql_ft_size_t len) { MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam; FT_INFO *ftb= ftb_param->ftb; @@ -997,7 +1000,7 @@ float maria_ft_boolean_find_relevance(FT_INFO *ftb, uchar *record, uint length) { if (!ftsi.pos) continue; - param->doc= (char *)ftsi.pos; + param->doc= ftsi.pos; param->length= ftsi.len; if (unlikely(parser->parse(param))) return 0; diff --git a/storage/maria/ma_ft_nlq_search.c b/storage/maria/ma_ft_nlq_search.c index 7187419b548..927f34f8b72 100644 --- a/storage/maria/ma_ft_nlq_search.c +++ b/storage/maria/ma_ft_nlq_search.c @@ -51,6 +51,7 @@ typedef struct st_ft_superdoc double tmp_weight; } FT_SUPERDOC; + static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)), FT_SUPERDOC *p1, FT_SUPERDOC *p2) { @@ -63,7 +64,7 @@ static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)), static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) { - int32 subkeys; + FT_WEIGTH subkeys; int r; uint doc_cnt; FT_SUPERDOC sdoc, *sptr; @@ -91,9 +92,9 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) /* Skip rows inserted by current inserted */ for (r= _ma_search(info, &key, SEARCH_FIND, key_root) ; !r && - (subkeys=ft_sintXkorr(info->last_key.data + - info->last_key.data_length + - info->last_key.ref_length - extra)) > 0 && + (subkeys.i= ft_sintXkorr(info->last_key.data + + info->last_key.data_length + + info->last_key.ref_length - extra)) > 0 && info->cur_row.lastpos >= info->state->data_file_length ; r= _ma_search_next(info, &info->last_key, SEARCH_BIGGER, key_root)) ; @@ -112,7 +113,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) key.data+1, key.data_length-1, 0, 0)) break; - if (subkeys<0) + if (subkeys.i < 0) { if (doc_cnt) DBUG_RETURN(1); /* index is corrupted */ @@ -128,7 +129,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*) (char*) &subkeys; + /* The weight we read was actually a float */ + tmp_weight= subkeys.f; #else #error #endif @@ -163,9 +165,9 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) else r= _ma_search(info, &info->last_key, SEARCH_BIGGER, key_root); do_skip: - while ((subkeys=ft_sintXkorr(info->last_key.data + - info->last_key.data_length + - info->last_key.ref_length - extra)) > 0 && + while ((subkeys.i= ft_sintXkorr(info->last_key.data + + info->last_key.data_length + + info->last_key.ref_length - extra)) > 0 && !r && info->cur_row.lastpos >= info->state->data_file_length) r= _ma_search_next(info, &info->last_key, SEARCH_BIGGER, key_root); @@ -206,7 +208,7 @@ static int FT_DOC_cmp(void *unused __attribute__((unused)), FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, uchar *query, - uint query_len, uint flags, uchar *record) + size_t query_len, uint flags, uchar *record) { TREE wtree; ALL_IN_ONE aio; diff --git a/storage/maria/ma_ft_parser.c b/storage/maria/ma_ft_parser.c index 11c9f2603a5..9c988c41c7b 100644 --- a/storage/maria/ma_ft_parser.c +++ b/storage/maria/ma_ft_parser.c @@ -260,7 +260,7 @@ void maria_ft_parse_init(TREE *wtree, CHARSET_INFO *cs) static int maria_ft_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t word_len, + const uchar *word, mysql_ft_size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) { @@ -290,7 +290,8 @@ static int maria_ft_add_word(MYSQL_FTPARSER_PARAM *param, static int maria_ft_parse_internal(MYSQL_FTPARSER_PARAM *param, - const uchar *doc_arg, size_t doc_len) + const uchar *doc_arg, + mysql_ft_size_t doc_len) { const uchar *doc= doc_arg; const uchar *end= doc + doc_len; @@ -306,8 +307,8 @@ static int maria_ft_parse_internal(MYSQL_FTPARSER_PARAM *param, } -int maria_ft_parse(TREE *wtree, uchar *doc, int doclen, - struct st_mysql_ftparser *parser, +int maria_ft_parse(TREE *wtree, uchar *doc, size_t doclen, + struct st_mysql_ftparser *parser, MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root) { MY_FT_PARSER_PARAM my_param; @@ -320,7 +321,7 @@ int maria_ft_parse(TREE *wtree, uchar *doc, int doclen, param->mysql_add_word= maria_ft_add_word; param->mysql_ftparam= &my_param; param->cs= wtree->custom_arg; - param->doc= (char *) doc; + param->doc= doc; param->length= doclen; param->mode= MYSQL_FTPARSER_SIMPLE_MODE; DBUG_RETURN(parser->parse(param)); @@ -380,8 +381,8 @@ MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *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 *, const uchar *, size_t, - MYSQL_FTPARSER_BOOLEAN_INFO *)) 1; + (int (*)(struct st_mysql_ftparser_param *, const uchar *, + mysql_ft_size_t, MYSQL_FTPARSER_BOOLEAN_INFO *)) 1; if (parser->init && parser->init(&info->ftparser_param[ftparser_nr])) return 0; } diff --git a/storage/maria/ma_ftdefs.h b/storage/maria/ma_ftdefs.h index f9ccbf16de3..4ce4e9e22ba 100644 --- a/storage/maria/ma_ftdefs.h +++ b/storage/maria/ma_ftdefs.h @@ -122,15 +122,17 @@ void _ma_ft_segiterator_dummy_init(const uchar *, uint, FT_SEG_ITERATOR *); uint _ma_ft_segiterator(FT_SEG_ITERATOR *); void maria_ft_parse_init(TREE *, CHARSET_INFO *); -int maria_ft_parse(TREE *, uchar *, int, struct st_mysql_ftparser *parser, +int maria_ft_parse(TREE *, uchar *, size_t, struct st_mysql_ftparser *parser, MYSQL_FTPARSER_PARAM *, MEM_ROOT *); FT_WORD * maria_ft_linearize(TREE *, MEM_ROOT *); FT_WORD * _ma_ft_parserecord(MARIA_HA *, uint, const uchar *, MEM_ROOT *); uint _ma_ft_parse(TREE *, MARIA_HA *, uint, const uchar *, MYSQL_FTPARSER_PARAM *, MEM_ROOT *); -FT_INFO *maria_ft_init_nlq_search(MARIA_HA *, uint, uchar *, uint, uint, uchar *); -FT_INFO *maria_ft_init_boolean_search(MARIA_HA *, uint, uchar *, uint, CHARSET_INFO *); +FT_INFO *maria_ft_init_nlq_search(MARIA_HA *, uint, uchar *, size_t, uint, + uchar *); +FT_INFO *maria_ft_init_boolean_search(MARIA_HA *, uint, uchar *, size_t, + CHARSET_INFO *); extern const struct _ft_vft _ma_ft_vft_nlq; int maria_ft_nlq_read_next(FT_INFO *, char *); diff --git a/storage/maria/maria_ftdump.c b/storage/maria/maria_ftdump.c index 180b6dfd90d..8b545e6e9af 100644 --- a/storage/maria/maria_ftdump.c +++ b/storage/maria/maria_ftdump.c @@ -53,7 +53,7 @@ static struct my_option my_long_options[] = int main(int argc,char *argv[]) { - int error=0, subkeys; + int error=0; uint keylen, keylen2=0, inx, doc_cnt=0; float weight= 1.0; double gws, min_gws=0, avg_gws=0; @@ -112,11 +112,12 @@ int main(int argc,char *argv[]) while (!(error=maria_rnext(info,NULL,inx))) { + FT_WEIGTH subkeys; keylen=*(info->lastkey_buff); - subkeys=ft_sintXkorr(info->lastkey_buff + keylen + 1); - if (subkeys >= 0) - weight=*(float*) (char*) &subkeys; + subkeys.i= ft_sintXkorr(info->lastkey_buff + keylen + 1); + if (subkeys.i >= 0) + weight= subkeys.f; #ifdef HAVE_SNPRINTF snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey_buff+1); @@ -153,14 +154,15 @@ int main(int argc,char *argv[]) keylen2=keylen; doc_cnt=0; } - doc_cnt+= (subkeys >= 0 ? 1 : -subkeys); + doc_cnt+= (subkeys.i >= 0 ? 1 : -subkeys.i); } if (dump) { - if (subkeys>=0) + if (subkeys.i >= 0) printf("%9lx %20.7f %s\n", (long) info->cur_row.lastpos,weight,buf); else - printf("%9lx => %17d %s\n",(long) info->cur_row.lastpos,-subkeys,buf); + printf("%9lx => %17d %s\n",(long) info->cur_row.lastpos,-subkeys.i, + buf); } if (verbose && (total%HOW_OFTEN_TO_WRITE)==0) printf("%10ld\r",total); diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 193ce510f98..b09d8c43321 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, - const uchar *word, size_t word_len, + const uchar *word, mysql_ft_size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *info) { MY_FTB_PARAM *ftb_param= param->mysql_ftparam; @@ -282,7 +282,7 @@ static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, - const uchar *query, size_t len) + const uchar *query, mysql_ft_size_t len) { MY_FTB_PARAM *ftb_param= param->mysql_ftparam; MYSQL_FTPARSER_BOOLEAN_INFO info; @@ -616,7 +616,7 @@ typedef struct st_my_ftb_phrase_param static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t word_len, + const uchar *word, mysql_ft_size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) { MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; @@ -648,7 +648,8 @@ static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, - const uchar *document, size_t len) + const uchar *document, + mysql_ft_size_t len) { FT_WORD word; MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; @@ -874,8 +875,9 @@ typedef struct st_my_ftb_find_param static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t len, - MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) + const uchar *word, mysql_ft_size_t len, + MYSQL_FTPARSER_BOOLEAN_INFO + *boolean_info __attribute__((unused))) { MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam; FT_INFO *ftb= ftb_param->ftb; @@ -935,7 +937,7 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param, static int ftb_find_relevance_parse(MYSQL_FTPARSER_PARAM *param, - const uchar *doc, size_t len) + const uchar *doc, mysql_ft_size_t len) { MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam; FT_INFO *ftb= ftb_param->ftb; diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index da593a3debc..c4d27bcbd8e 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -63,7 +63,7 @@ static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)), static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) { - int32 subkeys; + FT_WEIGTH subkeys; int r; uint keylen, doc_cnt; FT_SUPERDOC sdoc, *sptr; @@ -91,7 +91,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) /* Skip rows inserted by current inserted */ for (r=_mi_search(info, keyinfo, keybuff, keylen, SEARCH_FIND, key_root) ; !r && - (subkeys=ft_sintXkorr(info->lastkey+info->lastkey_length-extra)) > 0 && + (subkeys.i= ft_sintXkorr(info->lastkey+info->lastkey_length-extra)) > 0 && info->lastpos >= info->state->data_file_length ; r= _mi_search_next(info, keyinfo, info->lastkey, info->lastkey_length, SEARCH_BIGGER, key_root)) @@ -108,7 +108,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) info->lastkey_length-extra-1, keybuff+1,keylen-1,0,0)) break; - if (subkeys<0) + if (subkeys.i < 0) { if (doc_cnt) DBUG_RETURN(1); /* index is corrupted */ @@ -125,7 +125,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) } #if HA_FT_WTYPE == HA_KEYTYPE_FLOAT /* The weight we read was actually a float */ - tmp_weight=*(float*) (char*) &subkeys; + tmp_weight= subkeys.f; #else #error #endif @@ -162,7 +162,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) r=_mi_search(info, keyinfo, info->lastkey, info->lastkey_length, SEARCH_BIGGER, key_root); do_skip: - while ((subkeys=ft_sintXkorr(info->lastkey+info->lastkey_length-extra)) > 0 && + while ((subkeys.i= ft_sintXkorr(info->lastkey+info->lastkey_length-extra)) > 0 && !r && info->lastpos >= info->state->data_file_length) r= _mi_search_next(info, keyinfo, info->lastkey, info->lastkey_length, SEARCH_BIGGER, key_root); diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index cacedaaeea0..e4d500f6d8a 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -258,7 +258,7 @@ void ft_parse_init(TREE *wtree, CHARSET_INFO *cs) static int ft_add_word(MYSQL_FTPARSER_PARAM *param, - const uchar *word, size_t word_len, + const uchar *word, mysql_ft_size_t word_len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) { @@ -288,7 +288,7 @@ static int ft_add_word(MYSQL_FTPARSER_PARAM *param, static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, - const uchar *doc_arg, size_t doc_len) + const uchar *doc_arg, mysql_ft_size_t doc_len) { const uchar *doc= doc_arg; const uchar *end= doc + doc_len; @@ -379,8 +379,8 @@ 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 *, const uchar *, size_t, - MYSQL_FTPARSER_BOOLEAN_INFO *)) 1; + (int (*)(struct st_mysql_ftparser_param *, const uchar *, + mysql_ft_size_t, MYSQL_FTPARSER_BOOLEAN_INFO *)) 1; if (parser->init && parser->init(&info->ftparser_param[ftparser_nr])) return 0; } diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c index b7b035559f7..3eecb08bd99 100644 --- a/storage/myisam/myisam_ftdump.c +++ b/storage/myisam/myisam_ftdump.c @@ -53,7 +53,7 @@ static struct my_option my_long_options[] = int main(int argc,char *argv[]) { - int error=0, subkeys; + int error=0; uint keylen, keylen2=0, inx, doc_cnt=0; float weight= 1.0; double gws, min_gws=0, avg_gws=0; @@ -109,11 +109,12 @@ int main(int argc,char *argv[]) while (!(error=mi_rnext(info,NULL,inx))) { + FT_WEIGTH subkeys; keylen=*(info->lastkey); - subkeys=ft_sintXkorr(info->lastkey+keylen+1); - if (subkeys >= 0) - weight= *(float*) (char*) &subkeys; + subkeys.i =ft_sintXkorr(info->lastkey+keylen+1); + if (subkeys.i >= 0) + weight= subkeys.f; #ifdef HAVE_SNPRINTF snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey+1); @@ -150,14 +151,14 @@ int main(int argc,char *argv[]) keylen2=keylen; doc_cnt=0; } - doc_cnt+= (subkeys >= 0 ? 1 : -subkeys); + doc_cnt+= (subkeys.i >= 0 ? 1 : -subkeys.i); } if (dump) { - if (subkeys>=0) + if (subkeys.i >= 0) printf("%9lx %20.7f %s\n", (long) info->lastpos,weight,buf); else - printf("%9lx => %17d %s\n",(long) info->lastpos,-subkeys,buf); + printf("%9lx => %17d %s\n",(long) info->lastpos,-subkeys.i,buf); } if (verbose && (total%HOW_OFTEN_TO_WRITE)==0) printf("%10ld\r",total); |