diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2014-08-07 19:12:45 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2014-08-07 19:12:45 +0200 |
commit | f835588cc2e32da97269cc58e97ee77b5927498a (patch) | |
tree | 8e5c53593e7e3a9db0892afefb118fd0d581e23a /storage/innobase/fts | |
parent | 0219ac1e98cc53250a8e165c4b37e83529932256 (diff) | |
parent | b81b6d3f836feb682b963c9489f00ca1ee6a6a95 (diff) | |
download | mariadb-git-f835588cc2e32da97269cc58e97ee77b5927498a.tar.gz |
- Commiting merge files
Diffstat (limited to 'storage/innobase/fts')
-rw-r--r-- | storage/innobase/fts/fts0ast.cc | 20 | ||||
-rw-r--r-- | storage/innobase/fts/fts0blex.cc | 474 | ||||
-rw-r--r-- | storage/innobase/fts/fts0config.cc | 4 | ||||
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 571 | ||||
-rw-r--r-- | storage/innobase/fts/fts0opt.cc | 10 | ||||
-rw-r--r-- | storage/innobase/fts/fts0pars.cc | 81 | ||||
-rw-r--r-- | storage/innobase/fts/fts0pars.y | 11 | ||||
-rw-r--r-- | storage/innobase/fts/fts0que.cc | 297 | ||||
-rw-r--r-- | storage/innobase/fts/fts0sql.cc | 22 | ||||
-rw-r--r-- | storage/innobase/fts/fts0tlex.cc | 101 |
10 files changed, 1079 insertions, 512 deletions
diff --git a/storage/innobase/fts/fts0ast.cc b/storage/innobase/fts/fts0ast.cc index 3a03fc63303..d6c19c0050a 100644 --- a/storage/innobase/fts/fts0ast.cc +++ b/storage/innobase/fts/fts0ast.cc @@ -112,9 +112,11 @@ fts_ast_create_node_term( if (str.f_n_char > 0) { /* If the subsequent term (after the first one)'s size - is less than fts_min_token_size, we shall ignore - that. This is to make consistent with MyISAM behavior */ - if (first_node && (str.f_n_char < fts_min_token_size)) { + is less than fts_min_token_size or the term is greater + than fts_max_token_size, we shall ignore that. This is + to make consistent with MyISAM behavior */ + if ((first_node && (str.f_n_char < fts_min_token_size)) + || str.f_n_char > fts_max_token_size) { continue; } @@ -394,6 +396,10 @@ fts_ast_term_set_distance( ulint distance) /*!< in: the text proximity distance */ { + if (node == NULL) { + return; + } + ut_a(node->type == FTS_AST_TEXT); ut_a(node->text.distance == ULINT_UNDEFINED); @@ -551,14 +557,6 @@ fts_ast_visit( break; - case FTS_AST_SUBEXP_LIST: - if (visit_pass != FTS_PASS_FIRST) { - break; - } - - error = fts_ast_visit_sub_exp(node, visitor, arg); - break; - case FTS_AST_OPER: oper = node->oper; oper_node = node; diff --git a/storage/innobase/fts/fts0blex.cc b/storage/innobase/fts/fts0blex.cc index dccedac0212..f83523825d2 100644 --- a/storage/innobase/fts/fts0blex.cc +++ b/storage/innobase/fts/fts0blex.cc @@ -35,7 +35,7 @@ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -52,7 +52,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; @@ -184,15 +184,15 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - #define YY_LESS_LINENO(n) - +#define YY_LESS_LINENO(n) + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = yyg->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ @@ -245,9 +245,9 @@ struct yy_buffer_state */ int yy_at_bol; - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -305,18 +305,18 @@ YY_BUFFER_STATE fts0b_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner YY_BUFFER_STATE fts0b_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE fts0b_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); -void *fts0balloc (yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void *fts0brealloc (void *,yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void fts0bfree (void * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +void *fts0balloc (yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +void *fts0brealloc (void *,yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +void fts0bfree (void * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); #define yy_new_buffer fts0b_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - fts0bensure_buffer_stack (yyscanner); \ + fts0bensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - fts0b_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + fts0b_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } @@ -324,9 +324,9 @@ void fts0bfree (void * , yyscan_t yyscanner __attribute__((unused)) __attri #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - fts0bensure_buffer_stack (yyscanner); \ + fts0bensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - fts0b_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + fts0b_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } @@ -347,14 +347,14 @@ typedef int yy_state_type; static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ + yyleng = static_cast<int>(yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; @@ -499,37 +499,37 @@ this program; if not, write to the Free Software Foundation, Inc., /* Holds the entire state of the reentrant scanner. */ struct yyguts_t - { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ +{ + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + +}; /* end struct yyguts_t */ static int yy_init_globals (yyscan_t yyscanner ); @@ -579,11 +579,11 @@ extern int fts0bwrap (yyscan_t yyscanner ); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); #endif #ifndef YY_NO_INPUT @@ -622,8 +622,8 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ + int n; \ + for ( n = 0; n < static_cast<int>(max_size) && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ @@ -635,7 +635,8 @@ static int input (yyscan_t yyscanner ); else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + while ( (result = static_cast<int>(fread(buf, 1, max_size, yyin))) \ + == 0 && ferror(yyin) ) \ { \ if( errno != EINTR) \ { \ @@ -703,12 +704,12 @@ YY_DECL register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; #line 43 "fts0blex.l" -#line 711 "fts0blex.cc" +#line 712 "fts0blex.cc" if ( !yyg->yy_init ) { @@ -839,7 +840,7 @@ YY_RULE_SETUP #line 73 "fts0blex.l" ECHO; YY_BREAK -#line 842 "fts0blex.cc" +#line 843 "fts0blex.cc" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -982,7 +983,7 @@ case YY_STATE_EOF(INITIAL): */ static int yy_get_next_buffer (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = yyg->yytext_ptr; register int number_to_move, i; @@ -1027,8 +1028,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + int num_to_read = static_cast<int>( + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1); while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ @@ -1041,7 +1042,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + int new_size = static_cast<int>(b->yy_buf_size * 2); if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1062,8 +1063,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; + num_to_read = static_cast<int>( + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1); } @@ -1072,7 +1073,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, (size_t) num_to_read ); + yyg->yy_n_chars, num_to_read); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } @@ -1115,11 +1116,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* yy_get_previous_state - get the state just before the EOB char was reached */ - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { register yy_state_type yy_current_state; register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_current_state = yyg->yy_start; @@ -1148,10 +1149,10 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * synopsis * next_state = yy_try_NUL_trans( current_state ); */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { register int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ register char *yy_cp = yyg->yy_c_buf_p; register YY_CHAR yy_c = 1; @@ -1174,14 +1175,14 @@ static int yy_get_next_buffer (yyscan_t yyscanner) #ifndef YY_NO_INPUT #ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) + static int yyinput (yyscan_t yyscanner) #else - static int input (yyscan_t yyscanner) + static int input (yyscan_t yyscanner) #endif { int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; *yyg->yy_c_buf_p = yyg->yy_hold_char; @@ -1252,14 +1253,14 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ - void fts0brestart (FILE * input_file , yyscan_t yyscanner) +void fts0brestart (FILE * input_file , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! YY_CURRENT_BUFFER ){ - fts0bensure_buffer_stack (yyscanner); + fts0bensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - fts0b_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + fts0b_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } fts0b_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); @@ -1270,15 +1271,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ - void fts0b_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +void fts0b_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with * fts0bpop_buffer_state(); * fts0bpush_buffer_state(new_buffer); - */ + */ fts0bensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -1304,7 +1305,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) static void fts0b_load_buffer_state (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; @@ -1317,10 +1318,10 @@ static void fts0b_load_buffer_state (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the allocated buffer state. */ - YY_BUFFER_STATE fts0b_create_buffer (FILE * file, int size , yyscan_t yyscanner) +YY_BUFFER_STATE fts0b_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) fts0balloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in fts0b_create_buffer()" ); @@ -1345,9 +1346,9 @@ static void fts0b_load_buffer_state (yyscan_t yyscanner) * @param b a buffer created with fts0b_create_buffer() * @param yyscanner The scanner object. */ - void fts0b_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void fts0b_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) return; @@ -1365,28 +1366,28 @@ static void fts0b_load_buffer_state (yyscan_t yyscanner) * This function is sometimes called more than once on the same buffer, * such as during a fts0brestart() or at EOF. */ - static void fts0b_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) +static void fts0b_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; fts0b_flush_buffer(b ,yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; - /* If b is the current buffer, then fts0b_init_buffer was _probably_ - * called from fts0brestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - + /* If b is the current buffer, then fts0b_init_buffer was _probably_ + * called from fts0brestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; } @@ -1394,9 +1395,9 @@ static void fts0b_load_buffer_state (yyscan_t yyscanner) * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ - void fts0b_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +void fts0b_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) return; @@ -1426,7 +1427,7 @@ static void fts0b_load_buffer_state (yyscan_t yyscanner) */ void fts0bpush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) return; @@ -1457,7 +1458,7 @@ void fts0bpush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) */ void fts0bpop_buffer_state (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!YY_CURRENT_BUFFER) return; @@ -1478,23 +1479,23 @@ void fts0bpop_buffer_state (yyscan_t yyscanner) static void fts0bensure_buffer_stack (yyscan_t yyscanner) { int num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. - */ + */ num_to_alloc = 1; yyg->yy_buffer_stack = (struct yy_buffer_state**)fts0balloc (num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in fts0bensure_buffer_stack()" ); - + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_top = 0; return; @@ -1505,7 +1506,7 @@ static void fts0bensure_buffer_stack (yyscan_t yyscanner) /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + num_to_alloc = static_cast<int>(yyg->yy_buffer_stack_max + grow_size); yyg->yy_buffer_stack = (struct yy_buffer_state**)fts0brealloc (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) @@ -1523,12 +1524,12 @@ static void fts0bensure_buffer_stack (yyscan_t yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE fts0b_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -1543,7 +1544,7 @@ YY_BUFFER_STATE fts0b_scan_buffer (char * base, yy_size_t size , yyscan_t yysc b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; + b->yy_n_chars = static_cast<int>(b->yy_buf_size); b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; @@ -1564,8 +1565,7 @@ YY_BUFFER_STATE fts0b_scan_buffer (char * base, yy_size_t size , yyscan_t yysc */ YY_BUFFER_STATE fts0b_scan_string (yyconst char * yystr , yyscan_t yyscanner) { - - return fts0b_scan_bytes(yystr,strlen(yystr) ,yyscanner); + return fts0b_scan_bytes(yystr,static_cast<int>(strlen(yystr)), yyscanner); } /** Setup the input buffer state to scan the given bytes. The next call to fts0blex() will @@ -1581,7 +1581,7 @@ YY_BUFFER_STATE fts0b_scan_bytes (yyconst char * yybytes, int _yybytes_len , y char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) fts0balloc(n ,yyscanner ); @@ -1609,9 +1609,9 @@ YY_BUFFER_STATE fts0b_scan_bytes (yyconst char * yybytes, int _yybytes_len , y #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { - (void) fprintf( stderr, "%s\n", msg ); + (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -1622,8 +1622,8 @@ static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner __attri do \ { \ /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = yyg->yy_hold_char; \ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ yyg->yy_hold_char = *yyg->yy_c_buf_p; \ @@ -1639,8 +1639,8 @@ static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner __attri */ YY_EXTRA_TYPE fts0bget_extra (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; } /** Get the current line number. @@ -1648,12 +1648,12 @@ YY_EXTRA_TYPE fts0bget_extra (yyscan_t yyscanner) */ int fts0bget_lineno (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; } /** Get the current column number. @@ -1661,12 +1661,12 @@ int fts0bget_lineno (yyscan_t yyscanner) */ int fts0bget_column (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; } /** Get the input stream. @@ -1674,8 +1674,8 @@ int fts0bget_column (yyscan_t yyscanner) */ FILE *fts0bget_in (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; } /** Get the output stream. @@ -1683,8 +1683,8 @@ FILE *fts0bget_in (yyscan_t yyscanner) */ FILE *fts0bget_out (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; } /** Get the length of the current token. @@ -1692,8 +1692,8 @@ FILE *fts0bget_out (yyscan_t yyscanner) */ int fts0bget_leng (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; } /** Get the current token. @@ -1702,8 +1702,8 @@ int fts0bget_leng (yyscan_t yyscanner) char *fts0bget_text (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; } /** Set the user-defined data. This data is never touched by the scanner. @@ -1712,8 +1712,8 @@ char *fts0bget_text (yyscan_t yyscanner) */ void fts0bset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; } /** Set the current line number. @@ -1722,13 +1722,13 @@ void fts0bset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) */ void fts0bset_lineno (int line_number , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "fts0bset_lineno called with no buffer" , yyscanner); - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "fts0bset_lineno called with no buffer" , yyscanner); - - yylineno = line_number; + yylineno = line_number; } /** Set the current column. @@ -1737,13 +1737,13 @@ void fts0bset_lineno (int line_number , yyscan_t yyscanner) */ void fts0bset_column (int column_no , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "fts0bset_column called with no buffer" , yyscanner); - - yycolumn = column_no; + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "fts0bset_column called with no buffer" , yyscanner); + + yycolumn = column_no; } /** Set the input stream. This does not discard the current @@ -1754,26 +1754,26 @@ void fts0bset_column (int column_no , yyscan_t yyscanner) */ void fts0bset_in (FILE * in_str , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = in_str ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; } void fts0bset_out (FILE * out_str , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = out_str ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; } int fts0bget_debug (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; } void fts0bset_debug (int bdebug , yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = bdebug ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; } /* Accessor methods for yylval and yylloc */ @@ -1788,22 +1788,22 @@ void fts0bset_debug (int bdebug , yyscan_t yyscanner) int fts0blex_init(yyscan_t* ptr_yy_globals) { - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } - *ptr_yy_globals = (yyscan_t) fts0balloc ( sizeof( struct yyguts_t ), NULL ); + *ptr_yy_globals = (yyscan_t) fts0balloc ( sizeof( struct yyguts_t ), NULL ); - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - return yy_init_globals ( *ptr_yy_globals ); + return yy_init_globals ( *ptr_yy_globals ); } /* fts0blex_init_extra has the same functionality as fts0blex_init, but follows the @@ -1817,70 +1817,70 @@ int fts0blex_init(yyscan_t* ptr_yy_globals) int fts0blex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) { - struct yyguts_t dummy_yyguts; - - fts0bset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) fts0balloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - fts0bset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); + struct yyguts_t dummy_yyguts; + + fts0bset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) fts0balloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + fts0bset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); } static int yy_init_globals (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from fts0blex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = 0; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = (char *) 0; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from fts0blex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + + /* Defined in main.c */ #ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; + yyin = stdin; + yyout = stdout; #else - yyin = (FILE *) 0; - yyout = (FILE *) 0; + yyin = (FILE *) 0; + yyout = (FILE *) 0; #endif - /* For future reference: Set errno on error, since we are called by - * fts0blex_init() - */ - return 0; + /* For future reference: Set errno on error, since we are called by + * fts0blex_init() + */ + return 0; } /* fts0blex_destroy is for both reentrant and non-reentrant scanners. */ int fts0blex_destroy (yyscan_t yyscanner) { - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Pop the buffer stack, destroying each element. */ + /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ fts0b_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; @@ -1891,18 +1891,18 @@ int fts0blex_destroy (yyscan_t yyscanner) fts0bfree(yyg->yy_buffer_stack ,yyscanner); yyg->yy_buffer_stack = NULL; - /* Destroy the start condition stack. */ - fts0bfree(yyg->yy_start_stack ,yyscanner ); - yyg->yy_start_stack = NULL; + /* Destroy the start condition stack. */ + fts0bfree(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * fts0blex() is called, initialization will occur. */ - yy_init_globals( yyscanner); + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * fts0blex() is called, initialization will occur. */ + yy_init_globals( yyscanner); - /* Destroy the main struct (reentrant only). */ - fts0bfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; + /* Destroy the main struct (reentrant only). */ + fts0bfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; } /* @@ -1910,7 +1910,7 @@ int fts0blex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { register int i; for ( i = 0; i < n; ++i ) @@ -1919,7 +1919,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { register int n; for ( n = 0; s[n]; ++n ) @@ -1929,12 +1929,12 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __attribu } #endif -void *fts0balloc (yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0balloc (yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { return (void *) malloc( size ); } -void *fts0brealloc (void * ptr, yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0brealloc (void * ptr, yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those @@ -1946,7 +1946,7 @@ void *fts0brealloc (void * ptr, yy_size_t size , yyscan_t yyscanner __at return (void *) realloc( (char *) ptr, size ); } -void fts0bfree (void * ptr , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void fts0bfree (void * ptr , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { free( (char *) ptr ); /* see fts0brealloc() for (char *) cast */ } @@ -1955,5 +1955,3 @@ void fts0bfree (void * ptr , yyscan_t yyscanner __attribute__((unused)) __ #line 73 "fts0blex.l" - - diff --git a/storage/innobase/fts/fts0config.cc b/storage/innobase/fts/fts0config.cc index c5cf38ca7f9..5b4ae5c39f7 100644 --- a/storage/innobase/fts/fts0config.cc +++ b/storage/innobase/fts/fts0config.cc @@ -151,7 +151,9 @@ fts_config_create_index_param_name( strcpy(name, param); name[len] = '_'; - fts_write_object_id(index->id, name + len + 1); + fts_write_object_id(index->id, name + len + 1, + DICT_TF2_FLAG_IS_SET(index->table, + DICT_TF2_FTS_AUX_HEX_NAME)); return(name); } diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 41f20c1dbb9..4a667686795 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1608,7 +1608,8 @@ fts_rename_aux_tables( new_name, old_table_name, trx); DBUG_EXECUTE_IF("fts_rename_failure", - err = DB_DEADLOCK;); + err = DB_DEADLOCK; + fts_sql_rollback(trx);); mem_free(old_table_name); @@ -2018,7 +2019,7 @@ fts_create_index_tables_low( fts_table.index_id = index->id; fts_table.table_id = table_id; fts_table.parent = table_name; - fts_table.table = NULL; + fts_table.table = index->table; #ifdef FTS_DOC_STATS_DEBUG char* sql; @@ -4479,7 +4480,7 @@ fts_sync_table( ut_ad(table->fts); - if (table->fts->cache) { + if (!dict_table_is_discarded(table) && table->fts->cache) { err = fts_sync(table->fts->cache->sync); } @@ -4506,15 +4507,11 @@ fts_process_token( fts_string_t str; ulint offset = 0; fts_doc_t* result_doc; - byte buf[FTS_MAX_WORD_LEN + 1]; - - str.f_str = buf; /* Determine where to save the result. */ result_doc = (result) ? result : doc; /* The length of a string in characters is set here only. */ - ret = innobase_mysql_fts_get_token( doc->charset, doc->text.f_str + start_pos, doc->text.f_str + doc->text.f_len, &str, &offset); @@ -4545,6 +4542,7 @@ fts_process_token( (char*) t_str.f_str, t_str.f_len); t_str.f_len = newlen; + t_str.f_str[newlen] = 0; /* Add the word to the document statistics. If the word hasn't been seen before we create a new entry for it. */ @@ -5797,7 +5795,7 @@ fts_is_aux_table_name( my_name[len] = 0; end = my_name + len; - ptr = static_cast<const char*>(memchr(my_name, '/', len)); + ptr = static_cast<const char*>(memchr(my_name, '/', len)); if (ptr != NULL) { /* We will start the match after the '/' */ @@ -5940,6 +5938,374 @@ fts_read_tables( return(TRUE); } +/******************************************************************//** +Callback that sets a hex formatted FTS table's flags2 in +SYS_TABLES. The flags is stored in MIX_LEN column. +@return FALSE if all OK */ +static +ibool +fts_set_hex_format( +/*===============*/ + void* row, /*!< in: sel_node_t* */ + void* user_arg) /*!< in: bool set/unset flag */ +{ + sel_node_t* node = static_cast<sel_node_t*>(row); + dfield_t* dfield = que_node_get_val(node->select_list); + + ut_ad(dtype_get_mtype(dfield_get_type(dfield)) == DATA_INT); + ut_ad(dfield_get_len(dfield) == sizeof(ib_uint32_t)); + /* There should be at most one matching record. So the value + must be the default value. */ + ut_ad(mach_read_from_4(static_cast<byte*>(user_arg)) + == ULINT32_UNDEFINED); + + ulint flags2 = mach_read_from_4( + static_cast<byte*>(dfield_get_data(dfield))); + + flags2 |= DICT_TF2_FTS_AUX_HEX_NAME; + + mach_write_to_4(static_cast<byte*>(user_arg), flags2); + + return(FALSE); +} + +/*****************************************************************//** +Update the DICT_TF2_FTS_AUX_HEX_NAME flag in SYS_TABLES. +@return DB_SUCCESS or error code. */ +UNIV_INTERN +dberr_t +fts_update_hex_format_flag( +/*=======================*/ + trx_t* trx, /*!< in/out: transaction that + covers the update */ + table_id_t table_id, /*!< in: Table for which we want + to set the root table->flags2 */ + bool dict_locked) /*!< in: set to true if the + caller already owns the + dict_sys_t::mutex. */ +{ + pars_info_t* info; + ib_uint32_t flags2; + + static const char sql[] = + "PROCEDURE UPDATE_HEX_FORMAT_FLAG() IS\n" + "DECLARE FUNCTION my_func;\n" + "DECLARE CURSOR c IS\n" + " SELECT MIX_LEN " + " FROM SYS_TABLES " + " WHERE ID = :table_id FOR UPDATE;" + "\n" + "BEGIN\n" + "OPEN c;\n" + "WHILE 1 = 1 LOOP\n" + " FETCH c INTO my_func();\n" + " IF c % NOTFOUND THEN\n" + " EXIT;\n" + " END IF;\n" + "END LOOP;\n" + "UPDATE SYS_TABLES" + " SET MIX_LEN = :flags2" + " WHERE ID = :table_id;\n" + "CLOSE c;\n" + "END;\n"; + + flags2 = ULINT32_UNDEFINED; + + info = pars_info_create(); + + pars_info_add_ull_literal(info, "table_id", table_id); + pars_info_bind_int4_literal(info, "flags2", &flags2); + + pars_info_bind_function( + info, "my_func", fts_set_hex_format, &flags2); + + if (trx_get_dict_operation(trx) == TRX_DICT_OP_NONE) { + trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); + } + + dberr_t err = que_eval_sql(info, sql, !dict_locked, trx); + + ut_a(flags2 != ULINT32_UNDEFINED); + + return (err); +} + +#ifdef _WIN32 + +/*********************************************************************//** +Rename an aux table to HEX format. It's called when "%016llu" is used +to format an object id in table name, which only happens in Windows. */ +static __attribute__((nonnull, warn_unused_result)) +dberr_t +fts_rename_one_aux_table_to_hex_format( +/*===================================*/ + trx_t* trx, /*!< in: transaction */ + const fts_aux_table_t* aux_table, /*!< in: table info */ + const dict_table_t* parent_table) /*!< in: parent table name */ +{ + const char* ptr; + fts_table_t fts_table; + char* new_name; + dberr_t error; + + ptr = strchr(aux_table->name, '/'); + ut_a(ptr != NULL); + ++ptr; + /* Skip "FTS_", table id and underscore */ + for (ulint i = 0; i < 2; ++i) { + ptr = strchr(ptr, '_'); + ut_a(ptr != NULL); + ++ptr; + } + + fts_table.suffix = NULL; + if (aux_table->index_id == 0) { + fts_table.type = FTS_COMMON_TABLE; + + for (ulint i = 0; fts_common_tables[i] != NULL; ++i) { + if (strcmp(ptr, fts_common_tables[i]) == 0) { + fts_table.suffix = fts_common_tables[i]; + break; + } + } + } else { + fts_table.type = FTS_INDEX_TABLE; + + /* Skip index id and underscore */ + ptr = strchr(ptr, '_'); + ut_a(ptr != NULL); + ++ptr; + + for (ulint i = 0; fts_index_selector[i].value; ++i) { + if (strcmp(ptr, fts_get_suffix(i)) == 0) { + fts_table.suffix = fts_get_suffix(i); + break; + } + } + } + + ut_a(fts_table.suffix != NULL); + + fts_table.parent = parent_table->name; + fts_table.table_id = aux_table->parent_id; + fts_table.index_id = aux_table->index_id; + fts_table.table = parent_table; + + new_name = fts_get_table_name(&fts_table); + ut_ad(strcmp(new_name, aux_table->name) != 0); + + if (trx_get_dict_operation(trx) == TRX_DICT_OP_NONE) { + trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); + } + + error = row_rename_table_for_mysql(aux_table->name, new_name, trx, + FALSE); + + if (error != DB_SUCCESS) { + ib_logf(IB_LOG_LEVEL_WARN, + "Failed to rename aux table \'%s\' to " + "new format \'%s\'. ", + aux_table->name, new_name); + } else { + ib_logf(IB_LOG_LEVEL_INFO, + "Renamed aux table \'%s\' to \'%s\'.", + aux_table->name, new_name); + } + + mem_free(new_name); + + return (error); +} + +/**********************************************************************//** +Rename all aux tables of a parent table to HEX format. Also set aux tables' +flags2 and parent table's flags2 with DICT_TF2_FTS_AUX_HEX_NAME. +It's called when "%016llu" is used to format an object id in table name, +which only happens in Windows. +Note the ids in tables are correct but the names are old ambiguous ones. + +This function should make sure that either all the parent table and aux tables +are set DICT_TF2_FTS_AUX_HEX_NAME with flags2 or none of them are set */ +static __attribute__((nonnull, warn_unused_result)) +dberr_t +fts_rename_aux_tables_to_hex_format( +/*================================*/ + trx_t* trx, /*!< in: transaction */ + dict_table_t* parent_table, /*!< in: parent table */ + ib_vector_t* tables) /*!< in: aux tables to rename. */ +{ + dberr_t error; + ulint count; + + ut_ad(!DICT_TF2_FLAG_IS_SET(parent_table, DICT_TF2_FTS_AUX_HEX_NAME)); + ut_ad(!ib_vector_is_empty(tables)); + + error = fts_update_hex_format_flag(trx, parent_table->id, true); + + if (error != DB_SUCCESS) { + ib_logf(IB_LOG_LEVEL_WARN, + "Setting parent table %s to hex format failed.", + parent_table->name); + + fts_sql_rollback(trx); + return (error); + } + + DICT_TF2_FLAG_SET(parent_table, DICT_TF2_FTS_AUX_HEX_NAME); + + for (count = 0; count < ib_vector_size(tables); ++count) { + dict_table_t* table; + fts_aux_table_t* aux_table; + + aux_table = static_cast<fts_aux_table_t*>( + ib_vector_get(tables, count)); + + table = dict_table_open_on_id(aux_table->id, TRUE, + DICT_TABLE_OP_NORMAL); + + ut_ad(table != NULL); + ut_ad(!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_AUX_HEX_NAME)); + + /* Set HEX_NAME flag here to make sure we can get correct + new table name in following function */ + DICT_TF2_FLAG_SET(table, DICT_TF2_FTS_AUX_HEX_NAME); + error = fts_rename_one_aux_table_to_hex_format(trx, + aux_table, parent_table); + /* We will rollback the trx if the error != DB_SUCCESS, + so setting the flag here is the same with setting it in + row_rename_table_for_mysql */ + DBUG_EXECUTE_IF("rename_aux_table_fail", error = DB_ERROR;); + + if (error != DB_SUCCESS) { + dict_table_close(table, TRUE, FALSE); + + ib_logf(IB_LOG_LEVEL_WARN, + "Failed to rename one aux table %s " + "Will revert all successful rename " + "operations.", aux_table->name); + + fts_sql_rollback(trx); + break; + } + + error = fts_update_hex_format_flag(trx, aux_table->id, true); + dict_table_close(table, TRUE, FALSE); + + if (error != DB_SUCCESS) { + ib_logf(IB_LOG_LEVEL_WARN, + "Setting aux table %s to hex format failed.", + aux_table->name); + + fts_sql_rollback(trx); + break; + } + } + + if (error != DB_SUCCESS) { + ut_ad(count != ib_vector_size(tables)); + /* If rename fails, thr trx would be rolled back, we can't + use it any more, we'll start a new background trx to do + the reverting. */ + ut_a(trx->state == TRX_STATE_NOT_STARTED); + bool not_rename = false; + + /* Try to revert those succesful rename operations + in order to revert the ibd file rename. */ + for (ulint i = 0; i <= count; ++i) { + dict_table_t* table; + fts_aux_table_t* aux_table; + trx_t* trx_bg; + dberr_t err; + + aux_table = static_cast<fts_aux_table_t*>( + ib_vector_get(tables, i)); + + table = dict_table_open_on_id(aux_table->id, TRUE, + DICT_TABLE_OP_NORMAL); + ut_ad(table != NULL); + + if (not_rename) { + DICT_TF2_FLAG_UNSET(table, + DICT_TF2_FTS_AUX_HEX_NAME); + } + + if (!DICT_TF2_FLAG_IS_SET(table, + DICT_TF2_FTS_AUX_HEX_NAME)) { + dict_table_close(table, TRUE, FALSE); + continue; + } + + trx_bg = trx_allocate_for_background(); + trx_bg->op_info = "Revert half done rename"; + trx_bg->dict_operation_lock_mode = RW_X_LATCH; + trx_start_for_ddl(trx_bg, TRX_DICT_OP_TABLE); + + DICT_TF2_FLAG_UNSET(table, DICT_TF2_FTS_AUX_HEX_NAME); + err = row_rename_table_for_mysql(table->name, + aux_table->name, + trx_bg, FALSE); + + trx_bg->dict_operation_lock_mode = 0; + dict_table_close(table, TRUE, FALSE); + + if (err != DB_SUCCESS) { + ib_logf(IB_LOG_LEVEL_WARN, "Failed to revert " + "table %s. Please revert manually.", + table->name); + fts_sql_rollback(trx_bg); + /* Continue to clear aux tables' flags2 */ + not_rename = true; + continue; + } + + fts_sql_commit(trx_bg); + } + + DICT_TF2_FLAG_UNSET(parent_table, DICT_TF2_FTS_AUX_HEX_NAME); + } + + return (error); +} + +/**********************************************************************//** +Convert an id, which is actually a decimal number but was regard as a HEX +from a string, to its real value. */ +static +ib_id_t +fts_fake_hex_to_dec( +/*================*/ + ib_id_t id) /*!< in: number to convert */ +{ + ib_id_t dec_id = 0; + char tmp_id[FTS_AUX_MIN_TABLE_ID_LENGTH]; + int ret; + + ret = sprintf(tmp_id, UINT64PFx, id); + ut_ad(ret == 16); + ret = sscanf(tmp_id, "%016llu", &dec_id); + ut_ad(ret == 1); + + return dec_id; +} + +/*********************************************************************//** +Compare two fts_aux_table_t parent_ids. +@return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ +UNIV_INLINE +int +fts_check_aux_table_parent_id_cmp( +/*==============================*/ + const void* p1, /*!< in: id1 */ + const void* p2) /*!< in: id2 */ +{ + const fts_aux_table_t* fa1 = static_cast<const fts_aux_table_t*>(p1); + const fts_aux_table_t* fa2 = static_cast<const fts_aux_table_t*>(p2); + + return static_cast<int>(fa1->parent_id - fa2->parent_id); +} + +#endif /* _WIN32 */ + /**********************************************************************//** Check and drop all orphaned FTS auxiliary tables, those that don't have a parent table or FTS index defined on them. @@ -5951,18 +6317,75 @@ fts_check_and_drop_orphaned_tables( trx_t* trx, /*!< in: transaction */ ib_vector_t* tables) /*!< in: tables to check */ { +#ifdef _WIN32 + mem_heap_t* heap; + ib_vector_t* aux_tables_to_rename; + ib_alloc_t* heap_alloc; + + heap = mem_heap_create(1024); + heap_alloc = ib_heap_allocator_create(heap); + + /* We store all aux tables belonging to the same parent table here, + and rename all these tables in a batch mode. */ + aux_tables_to_rename = ib_vector_create(heap_alloc, + sizeof(fts_aux_table_t), 128); + + /* Sort by parent_id first, in case rename will fail */ + ib_vector_sort(tables, fts_check_aux_table_parent_id_cmp); +#endif /* _WIN32 */ + for (ulint i = 0; i < ib_vector_size(tables); ++i) { - dict_table_t* table; + dict_table_t* parent_table; fts_aux_table_t* aux_table; bool drop = false; +#ifdef _WIN32 + dict_table_t* table; + fts_aux_table_t* next_aux_table = NULL; + ib_id_t orig_parent_id = 0; + bool rename = false; +#endif /* _WIN32 */ aux_table = static_cast<fts_aux_table_t*>( ib_vector_get(tables, i)); +#ifdef _WIN32 table = dict_table_open_on_id( + aux_table->id, TRUE, DICT_TABLE_OP_NORMAL); + orig_parent_id = aux_table->parent_id; + + if (table == NULL || strcmp(table->name, aux_table->name)) { + /* Skip these aux tables, which are common tables + with wrong table ids */ + if (table) { + dict_table_close(table, TRUE, FALSE); + } + + continue; + + } else if (!DICT_TF2_FLAG_IS_SET(table, + DICT_TF2_FTS_AUX_HEX_NAME)) { + + aux_table->parent_id = fts_fake_hex_to_dec( + aux_table->parent_id); + + if (aux_table->index_id != 0) { + aux_table->index_id = fts_fake_hex_to_dec( + aux_table->index_id); + } + + ut_ad(aux_table->id > aux_table->parent_id); + rename = true; + } + + if (table) { + dict_table_close(table, TRUE, FALSE); + } +#endif /* _WIN32 */ + + parent_table = dict_table_open_on_id( aux_table->parent_id, TRUE, DICT_TABLE_OP_NORMAL); - if (table == NULL || table->fts == NULL) { + if (parent_table == NULL || parent_table->fts == NULL) { drop = true; @@ -5971,7 +6394,7 @@ fts_check_and_drop_orphaned_tables( fts_t* fts; drop = true; - fts = table->fts; + fts = parent_table->fts; id = aux_table->index_id; /* Search for the FT index in the table's list. */ @@ -5979,33 +6402,28 @@ fts_check_and_drop_orphaned_tables( j < ib_vector_size(fts->indexes); ++j) { - const dict_index_t* index; + const dict_index_t* index; index = static_cast<const dict_index_t*>( ib_vector_getp_const(fts->indexes, j)); if (index->id == id) { - drop = false; break; } } } - if (table) { - dict_table_close(table, TRUE, FALSE); - } - if (drop) { ib_logf(IB_LOG_LEVEL_WARN, "Parent table of FTS auxiliary table %s not " "found.", aux_table->name); - dberr_t err = fts_drop_table(trx, aux_table->name); + dberr_t err = fts_drop_table(trx, aux_table->name); if (err == DB_FAIL) { - char* path; + char* path; path = fil_make_ibd_name( aux_table->name, false); @@ -6016,7 +6434,120 @@ fts_check_and_drop_orphaned_tables( mem_free(path); } } +#ifdef _WIN32 + if (!drop && rename) { + ib_vector_push(aux_tables_to_rename, aux_table); + } + + if (i + 1 < ib_vector_size(tables)) { + next_aux_table = static_cast<fts_aux_table_t*>( + ib_vector_get(tables, i + 1)); + } + + if ((next_aux_table == NULL + || orig_parent_id != next_aux_table->parent_id) + && !ib_vector_is_empty(aux_tables_to_rename)) { + /* All aux tables of parent table, whose id is + last_parent_id, have been checked, try to rename + them if necessary. We had better use a new background + trx to rename rather than the original trx, in case + any failure would cause a complete rollback. */ + dberr_t err; + trx_t* trx_rename = trx_allocate_for_background(); + trx_rename->op_info = "Rename aux tables to " + "hex format"; + trx_rename->dict_operation_lock_mode = RW_X_LATCH; + trx_start_for_ddl(trx_rename, TRX_DICT_OP_TABLE); + + err = fts_rename_aux_tables_to_hex_format(trx_rename, + parent_table, aux_tables_to_rename); + + trx_rename->dict_operation_lock_mode = 0; + + if (err != DB_SUCCESS) { + ib_logf(IB_LOG_LEVEL_WARN, + "Rollback operations on all " + "aux tables of table %s. " + "Please check why renaming aux tables " + "failed, and restart the server to " + "upgrade again to " + "get the table work.", + parent_table->name); + + fts_sql_rollback(trx_rename); + } else { + fts_sql_commit(trx_rename); + } + + trx_free_for_background(trx_rename); + ib_vector_reset(aux_tables_to_rename); + } +#else /* _WIN32 */ + if (!drop) { + dict_table_t* table; + + table = dict_table_open_on_id( + aux_table->id, TRUE, DICT_TABLE_OP_NORMAL); + if (table != NULL + && strcmp(table->name, aux_table->name)) { + dict_table_close(table, TRUE, FALSE); + table = NULL; + } + + if (table != NULL + && !DICT_TF2_FLAG_IS_SET( + table, + DICT_TF2_FTS_AUX_HEX_NAME)) { + dberr_t err = fts_update_hex_format_flag( + trx, table->id, true); + + if (err != DB_SUCCESS) { + ib_logf(IB_LOG_LEVEL_WARN, + "Setting aux table %s to hex " + "format failed.", table->name); + } else { + DICT_TF2_FLAG_SET(table, + DICT_TF2_FTS_AUX_HEX_NAME); + } + } + + if (table != NULL) { + dict_table_close(table, TRUE, FALSE); + } + + ut_ad(parent_table != NULL); + if (!DICT_TF2_FLAG_IS_SET(parent_table, + DICT_TF2_FTS_AUX_HEX_NAME)) { + dberr_t err = fts_update_hex_format_flag( + trx, parent_table->id, true); + + if (err != DB_SUCCESS) { + ib_logf(IB_LOG_LEVEL_WARN, + "Setting parent table %s of " + "FTS auxiliary %s to hex " + "format failed.", + parent_table->name, + aux_table->name); + } else { + DICT_TF2_FLAG_SET(parent_table, + DICT_TF2_FTS_AUX_HEX_NAME); + } + } + } + +#endif /* _WIN32 */ + + if (parent_table) { + dict_table_close(parent_table, TRUE, FALSE); + } + } + +#ifdef _WIN32 + /* Free the memory allocated at the beginning */ + if (heap != NULL) { + mem_heap_free(heap); } +#endif /* _WIN32 */ } /**********************************************************************//** @@ -6216,7 +6747,7 @@ fts_valid_stopword_table( return(innobase_get_fts_charset( static_cast<int>(col->prtype & DATA_MYSQL_TYPE_MASK), - static_cast<ulint>(dtype_get_charset_coll(col->prtype)))); + static_cast<uint>(dtype_get_charset_coll(col->prtype)))); } /**********************************************************************//** diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index 7cdad522564..a9f3a25530d 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -620,7 +620,7 @@ fts_zip_read_word( zip->zp->avail_in = FTS_MAX_WORD_LEN; } else { - zip->zp->avail_in = zip->block_sz; + zip->zp->avail_in = static_cast<uInt>(zip->block_sz); } ++zip->pos; @@ -721,7 +721,7 @@ fts_fetch_index_words( ib_vector_push(zip->blocks, &block); zip->zp->next_out = block; - zip->zp->avail_out = zip->block_sz; + zip->zp->avail_out = static_cast<uInt>(zip->block_sz); } switch (zip->status = deflate(zip->zp, Z_NO_FLUSH)) { @@ -1099,10 +1099,10 @@ fts_optimize_lookup( doc_id_t last_doc_id) /*!< in: doc id to lookup */ { int pos; - int upper = ib_vector_size(doc_ids); + int upper = static_cast<int>(ib_vector_size(doc_ids)); fts_update_t* array = (fts_update_t*) doc_ids->data; - pos = fts_bsearch(array, lower, upper, first_doc_id); + pos = fts_bsearch(array, static_cast<int>(lower), upper, first_doc_id); ut_a(abs(pos) <= upper + 1); @@ -1624,10 +1624,12 @@ fts_optimize_create( optim->fts_common_table.parent = table->name; optim->fts_common_table.table_id = table->id; optim->fts_common_table.type = FTS_COMMON_TABLE; + optim->fts_common_table.table = table; optim->fts_index_table.parent = table->name; optim->fts_index_table.table_id = table->id; optim->fts_index_table.type = FTS_INDEX_TABLE; + optim->fts_index_table.table = table; /* The common prefix for all this parent table's aux tables. */ optim->name_prefix = fts_get_table_name_prefix( diff --git a/storage/innobase/fts/fts0pars.cc b/storage/innobase/fts/fts0pars.cc index a4009106c83..83d465b0988 100644 --- a/storage/innobase/fts/fts0pars.cc +++ b/storage/innobase/fts/fts0pars.cc @@ -1,19 +1,19 @@ /* A Bison parser, made by GNU Bison 2.5. */ /* Bison implementation for Yacc-like parsers in C - + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. - + 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 3 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, see <http://www.gnu.org/licenses/>. */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -467,9 +467,9 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 79, 79, 85, 89, 99, 111, 115, 124, 128, - 132, 136, 141, 147, 152, 159, 165, 169, 173, 177, - 181, 186, 191, 197, 202 + 0, 79, 79, 85, 89, 99, 111, 119, 129, 133, + 137, 141, 146, 152, 157, 164, 170, 174, 178, 182, + 186, 191, 196, 202, 207 }; #endif @@ -1458,7 +1458,7 @@ yyreduce: (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (2)].node)); if (!(yyval.node)) { - (yyval.node) = fts_ast_create_node_subexp_list(state, (yyvsp[(2) - (2)].node)); + (yyval.node) = (yyvsp[(2) - (2)].node); } else { fts_ast_add_node((yyval.node), (yyvsp[(2) - (2)].node)); } @@ -1471,18 +1471,23 @@ yyreduce: #line 111 "fts0pars.y" { (yyval.node) = (yyvsp[(2) - (3)].node); + + if ((yyval.node)) { + (yyval.node) = fts_ast_create_node_subexp_list(state, (yyval.node)); + } } break; case 7: /* Line 1806 of yacc.c */ -#line 115 "fts0pars.y" +#line 119 "fts0pars.y" { - (yyval.node) = fts_ast_create_node_subexp_list(state, (yyvsp[(1) - (4)].node)); + (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (4)].node)); if ((yyvsp[(3) - (4)].node)) { - fts_ast_add_node((yyval.node), (yyvsp[(3) - (4)].node)); + fts_ast_add_node((yyval.node), + fts_ast_create_node_subexp_list(state, (yyvsp[(3) - (4)].node))); } } break; @@ -1490,7 +1495,7 @@ yyreduce: case 8: /* Line 1806 of yacc.c */ -#line 124 "fts0pars.y" +#line 129 "fts0pars.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } @@ -1499,7 +1504,7 @@ yyreduce: case 9: /* Line 1806 of yacc.c */ -#line 128 "fts0pars.y" +#line 133 "fts0pars.y" { (yyval.node) = (yyvsp[(1) - (1)].node); } @@ -1508,7 +1513,7 @@ yyreduce: case 10: /* Line 1806 of yacc.c */ -#line 132 "fts0pars.y" +#line 137 "fts0pars.y" { fts_ast_term_set_wildcard((yyvsp[(1) - (2)].node)); } @@ -1517,7 +1522,7 @@ yyreduce: case 11: /* Line 1806 of yacc.c */ -#line 136 "fts0pars.y" +#line 141 "fts0pars.y" { fts_ast_term_set_distance((yyvsp[(1) - (3)].node), strtoul((yyvsp[(3) - (3)].token), NULL, 10)); free((yyvsp[(3) - (3)].token)); @@ -1527,7 +1532,7 @@ yyreduce: case 12: /* Line 1806 of yacc.c */ -#line 141 "fts0pars.y" +#line 146 "fts0pars.y" { (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (3)].node)); fts_ast_add_node((yyval.node), (yyvsp[(2) - (3)].node)); @@ -1538,7 +1543,7 @@ yyreduce: case 13: /* Line 1806 of yacc.c */ -#line 147 "fts0pars.y" +#line 152 "fts0pars.y" { (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (2)].node)); fts_ast_add_node((yyval.node), (yyvsp[(2) - (2)].node)); @@ -1548,7 +1553,7 @@ yyreduce: case 14: /* Line 1806 of yacc.c */ -#line 152 "fts0pars.y" +#line 157 "fts0pars.y" { (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (4)].node)); fts_ast_add_node((yyval.node), (yyvsp[(2) - (4)].node)); @@ -1560,7 +1565,7 @@ yyreduce: case 15: /* Line 1806 of yacc.c */ -#line 159 "fts0pars.y" +#line 164 "fts0pars.y" { (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (2)].node)); fts_ast_add_node((yyval.node), (yyvsp[(2) - (2)].node)); @@ -1570,7 +1575,7 @@ yyreduce: case 16: /* Line 1806 of yacc.c */ -#line 165 "fts0pars.y" +#line 170 "fts0pars.y" { (yyval.node) = fts_ast_create_node_oper(state, FTS_IGNORE); } @@ -1579,7 +1584,7 @@ yyreduce: case 17: /* Line 1806 of yacc.c */ -#line 169 "fts0pars.y" +#line 174 "fts0pars.y" { (yyval.node) = fts_ast_create_node_oper(state, FTS_EXIST); } @@ -1588,7 +1593,7 @@ yyreduce: case 18: /* Line 1806 of yacc.c */ -#line 173 "fts0pars.y" +#line 178 "fts0pars.y" { (yyval.node) = fts_ast_create_node_oper(state, FTS_NEGATE); } @@ -1597,7 +1602,7 @@ yyreduce: case 19: /* Line 1806 of yacc.c */ -#line 177 "fts0pars.y" +#line 182 "fts0pars.y" { (yyval.node) = fts_ast_create_node_oper(state, FTS_DECR_RATING); } @@ -1606,7 +1611,7 @@ yyreduce: case 20: /* Line 1806 of yacc.c */ -#line 181 "fts0pars.y" +#line 186 "fts0pars.y" { (yyval.node) = fts_ast_create_node_oper(state, FTS_INCR_RATING); } @@ -1615,7 +1620,7 @@ yyreduce: case 21: /* Line 1806 of yacc.c */ -#line 186 "fts0pars.y" +#line 191 "fts0pars.y" { (yyval.node) = fts_ast_create_node_term(state, (yyvsp[(1) - (1)].token)); free((yyvsp[(1) - (1)].token)); @@ -1625,7 +1630,7 @@ yyreduce: case 22: /* Line 1806 of yacc.c */ -#line 191 "fts0pars.y" +#line 196 "fts0pars.y" { (yyval.node) = fts_ast_create_node_term(state, (yyvsp[(1) - (1)].token)); free((yyvsp[(1) - (1)].token)); @@ -1635,7 +1640,7 @@ yyreduce: case 23: /* Line 1806 of yacc.c */ -#line 197 "fts0pars.y" +#line 202 "fts0pars.y" { (yyval.node) = (yyvsp[(2) - (2)].node); } @@ -1644,7 +1649,7 @@ yyreduce: case 24: /* Line 1806 of yacc.c */ -#line 202 "fts0pars.y" +#line 207 "fts0pars.y" { (yyval.node) = fts_ast_create_node_text(state, (yyvsp[(1) - (1)].token)); free((yyvsp[(1) - (1)].token)); @@ -1654,7 +1659,7 @@ yyreduce: /* Line 1806 of yacc.c */ -#line 1658 "fts0pars.cc" +#line 1663 "fts0pars.cc" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1885,7 +1890,7 @@ yyreturn: /* Line 2067 of yacc.c */ -#line 207 "fts0pars.y" +#line 212 "fts0pars.y" /******************************************************************** @@ -1914,14 +1919,20 @@ fts_lexer_create( if (boolean_mode) { fts0blex_init(&fts_lexer->yyscanner); - fts0b_scan_bytes((char*) query, query_len, fts_lexer->yyscanner); - fts_lexer->scanner = (fts_scan) fts_blexer; + fts0b_scan_bytes( + reinterpret_cast<const char*>(query), + static_cast<int>(query_len), + fts_lexer->yyscanner); + fts_lexer->scanner = reinterpret_cast<fts_scan>(fts_blexer); /* FIXME: Debugging */ /* fts0bset_debug(1 , fts_lexer->yyscanner); */ } else { fts0tlex_init(&fts_lexer->yyscanner); - fts0t_scan_bytes((char*) query, query_len, fts_lexer->yyscanner); - fts_lexer->scanner = (fts_scan) fts_tlexer; + fts0t_scan_bytes( + reinterpret_cast<const char*>(query), + static_cast<int>(query_len), + fts_lexer->yyscanner); + fts_lexer->scanner = reinterpret_cast<fts_scan>(fts_tlexer); } return(fts_lexer); diff --git a/storage/innobase/fts/fts0pars.y b/storage/innobase/fts/fts0pars.y index 73d71bc87c5..ff22e9a9873 100644 --- a/storage/innobase/fts/fts0pars.y +++ b/storage/innobase/fts/fts0pars.y @@ -101,7 +101,7 @@ expr_lst: /* Empty */ { $$ = fts_ast_create_node_list(state, $1); if (!$$) { - $$ = fts_ast_create_node_subexp_list(state, $2); + $$ = $2; } else { fts_ast_add_node($$, $2); } @@ -110,13 +110,18 @@ expr_lst: /* Empty */ { sub_expr: '(' expr_lst ')' { $$ = $2; + + if ($$) { + $$ = fts_ast_create_node_subexp_list(state, $$); + } } | prefix '(' expr_lst ')' { - $$ = fts_ast_create_node_subexp_list(state, $1); + $$ = fts_ast_create_node_list(state, $1); if ($3) { - fts_ast_add_node($$, $3); + fts_ast_add_node($$, + fts_ast_create_node_subexp_list(state, $3)); } } ; diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc index a70c742da0c..adbf433e608 100644 --- a/storage/innobase/fts/fts0que.cc +++ b/storage/innobase/fts/fts0que.cc @@ -40,18 +40,14 @@ Completed 2011/7/10 Sunny and Jimmy Yang #include "fts0vlc.ic" #endif -#include <string> #include <vector> -#include <map> #define FTS_ELEM(t, n, i, j) (t[(i) * n + (j)]) #define RANK_DOWNGRADE (-1.0F) #define RANK_UPGRADE (1.0F) -/* Maximum number of words supported in a proximity search. -FIXME, this limitation can be removed easily. Need to see -if we want to enforce such limitation */ +/* Maximum number of words supported in a phrase or proximity search. */ #define MAX_PROXIMITY_ITEM 128 /* Memory used by rbt itself for create and node add */ @@ -66,8 +62,7 @@ static const double FTS_NORMALIZE_COEFF = 0.0115F; // FIXME: Need to have a generic iterator that traverses the ilist. -typedef std::map<std::string, ulint> word_map_t; -typedef std::vector<std::string> word_vector_t; +typedef std::vector<fts_string_t> word_vector_t; struct fts_word_freq_t; @@ -92,7 +87,7 @@ struct fts_query_t { fts_ast_node_t* cur_node; /*!< Current tree node */ - word_map_t* word_map; /*!< Matched word map for + ib_rbt_t* word_map; /*!< Matched word map for searching by word*/ word_vector_t* word_vector; /*!< Matched word vector for @@ -186,6 +181,8 @@ struct fts_select_t { the FTS index */ }; +typedef std::vector<ulint> pos_vector_t; + /** structure defines a set of ranges for original documents, each of which has a minimum position and maximum position. Text in such range should contain all words in the proximity search. We will need to count the @@ -195,9 +192,9 @@ struct fts_proximity_t { ulint n_pos; /*!< number of position set, defines a range (min to max) containing all matching words */ - ulint* min_pos; /*!< the minimum position (in bytes) + pos_vector_t min_pos; /*!< the minimum position (in bytes) of the range */ - ulint* max_pos; /*!< the maximum position (in bytes) + pos_vector_t max_pos; /*!< the maximum position (in bytes) of the range */ }; @@ -229,7 +226,7 @@ struct fts_doc_freq_t { /** To determine the word frequency per document. */ struct fts_word_freq_t { - byte* word; /*!< Word for which we need the freq, + fts_string_t word; /*!< Word for which we need the freq, it's allocated on the query heap */ ib_rbt_t* doc_freqs; /*!< RB Tree for storing per document @@ -257,15 +254,14 @@ static dberr_t fts_query_filter_doc_ids( /*=====================*/ - fts_query_t* query, /*!< in: query instance */ - const byte* word, /*!< in: the current word */ - fts_word_freq_t*word_freq, /*!< in/out: word frequency */ - const fts_node_t* - node, /*!< in: current FTS node */ - void* data, /*!< in: doc id ilist */ - ulint len, /*!< in: doc id ilist size */ - ibool calc_doc_count);/*!< in: whether to remember doc - count */ + fts_query_t* query, /*!< in: query instance */ + const fts_string_t* word, /*!< in: the current word */ + fts_word_freq_t* word_freq, /*!< in/out: word frequency */ + const fts_node_t* node, /*!< in: current FTS node */ + void* data, /*!< in: doc id ilist */ + ulint len, /*!< in: doc id ilist size */ + ibool calc_doc_count);/*!< in: whether to remember doc + count */ #if 0 /*****************************************************************//*** @@ -575,27 +571,41 @@ static void fts_ranking_words_add( /*==================*/ - fts_query_t* query, /*!< in: query instance */ - fts_ranking_t* ranking, /*!< in: ranking instance */ - const char* word) /*!< in: term/word to add */ + fts_query_t* query, /*!< in: query instance */ + fts_ranking_t* ranking, /*!< in: ranking instance */ + const fts_string_t* word) /*!< in: term/word to add */ { ulint pos; ulint byte_offset; ulint bit_offset; - word_map_t::iterator it; - - /* Note: we suppose the word map and vector are append-only */ - /* Check if need to add it to word map */ - it = query->word_map->lower_bound(word); - if (it != query->word_map->end() - && !query->word_map->key_comp()(word, it->first)) { - pos = it->second; + ib_rbt_bound_t parent; + + /* Note: we suppose the word map and vector are append-only. */ + ut_ad(query->word_vector->size() == rbt_size(query->word_map)); + + /* We use ib_rbt to simulate a map, f_n_char means position. */ + if (rbt_search(query->word_map, &parent, word) == 0) { + fts_string_t* result_word; + + result_word = rbt_value(fts_string_t, parent.last); + pos = result_word->f_n_char; + ut_ad(pos < rbt_size(query->word_map)); } else { - pos = query->word_map->size(); - query->word_map->insert(it, - std::pair<std::string, ulint>(word, pos)); + /* Add the word to map. */ + fts_string_t new_word; + + pos = rbt_size(query->word_map); + + new_word.f_str = static_cast<byte*>(mem_heap_alloc(query->heap, + word->f_len + 1)); + memcpy(new_word.f_str, word->f_str, word->f_len); + new_word.f_str[word->f_len] = 0; + new_word.f_len = word->f_len; + new_word.f_n_char = pos; - query->word_vector->push_back(word); + rbt_add_node(query->word_map, &parent, &new_word); + ut_ad(rbt_validate(query->word_map)); + query->word_vector->push_back(new_word); } /* Check words len */ @@ -630,7 +640,7 @@ fts_ranking_words_get_next( const fts_query_t* query, /*!< in: query instance */ fts_ranking_t* ranking,/*!< in: ranking instance */ ulint* pos, /*!< in/out: word start pos */ - byte** word) /*!< in/out: term/word to add */ + fts_string_t* word) /*!< in/out: term/word to add */ { bool ret = false; ulint max_pos = ranking->words_len * CHAR_BIT; @@ -651,7 +661,7 @@ fts_ranking_words_get_next( /* Get next word from word vector */ if (ret) { ut_ad(*pos < query->word_vector->size()); - *word = (byte*)query->word_vector->at((size_t)*pos).c_str(); + *word = query->word_vector->at((size_t)*pos); *pos += 1; } @@ -666,23 +676,22 @@ static fts_word_freq_t* fts_query_add_word_freq( /*====================*/ - fts_query_t* query, /*!< in: query instance */ - const byte* word) /*!< in: term/word to add */ + fts_query_t* query, /*!< in: query instance */ + const fts_string_t* word) /*!< in: term/word to add */ { ib_rbt_bound_t parent; /* Lookup the word in our rb tree and add if it doesn't exist. */ if (rbt_search(query->word_freqs, &parent, word) != 0) { fts_word_freq_t word_freq; - ulint len = ut_strlen((char*) word) + 1; memset(&word_freq, 0, sizeof(word_freq)); - word_freq.word = static_cast<byte*>( - mem_heap_alloc(query->heap, len)); - - /* Need to copy the NUL character too. */ - memcpy(word_freq.word, word, len); + word_freq.word.f_str = static_cast<byte*>( + mem_heap_alloc(query->heap, word->f_len + 1)); + memcpy(word_freq.word.f_str, word->f_str, word->f_len); + word_freq.word.f_str[word->f_len] = 0; + word_freq.word.f_len = word->f_len; word_freq.doc_count = 0; @@ -692,7 +701,7 @@ fts_query_add_word_freq( parent.last = rbt_add_node( query->word_freqs, &parent, &word_freq); - query->total_size += len + query->total_size += word->f_len + SIZEOF_RBT_CREATE + SIZEOF_RBT_NODE_ADD + sizeof(fts_word_freq_t); @@ -749,7 +758,7 @@ fts_query_union_doc_id( fts_update_t* array = (fts_update_t*) query->deleted->doc_ids->data; /* Check if the doc id is deleted and it's not already in our set. */ - if (fts_bsearch(array, 0, size, doc_id) < 0 + if (fts_bsearch(array, 0, static_cast<int>(size), doc_id) < 0 && rbt_search(query->doc_ids, &parent, &doc_id) != 0) { fts_ranking_t ranking; @@ -780,7 +789,7 @@ fts_query_remove_doc_id( fts_update_t* array = (fts_update_t*) query->deleted->doc_ids->data; /* Check if the doc id is deleted and it's in our set. */ - if (fts_bsearch(array, 0, size, doc_id) < 0 + if (fts_bsearch(array, 0, static_cast<int>(size), doc_id) < 0 && rbt_search(query->doc_ids, &parent, &doc_id) == 0) { ut_free(rbt_remove_node(query->doc_ids, parent.last)); @@ -810,7 +819,7 @@ fts_query_change_ranking( fts_update_t* array = (fts_update_t*) query->deleted->doc_ids->data; /* Check if the doc id is deleted and it's in our set. */ - if (fts_bsearch(array, 0, size, doc_id) < 0 + if (fts_bsearch(array, 0, static_cast<int>(size), doc_id) < 0 && rbt_search(query->doc_ids, &parent, &doc_id) == 0) { fts_ranking_t* ranking; @@ -856,7 +865,7 @@ fts_query_intersect_doc_id( if it matches 'b' and it's in doc_ids.(multi_exist = true). */ /* Check if the doc id is deleted and it's in our set */ - if (fts_bsearch(array, 0, size, doc_id) < 0) { + if (fts_bsearch(array, 0, static_cast<int>(size), doc_id) < 0) { fts_ranking_t new_ranking; if (rbt_search(query->doc_ids, &parent, &doc_id) != 0) { @@ -956,7 +965,7 @@ fts_query_add_word_to_document( /*===========================*/ fts_query_t* query, /*!< in: query to update */ doc_id_t doc_id, /*!< in: the document to update */ - const byte* word) /*!< in: the token to add */ + const fts_string_t* word) /*!< in: the token to add */ { ib_rbt_bound_t parent; fts_ranking_t* ranking = NULL; @@ -980,7 +989,7 @@ fts_query_add_word_to_document( } if (ranking != NULL) { - fts_ranking_words_add(query, ranking, (char*)word); + fts_ranking_words_add(query, ranking, word); } } @@ -1010,13 +1019,13 @@ fts_query_check_node( fts_word_freq_t*word_freqs; /* The word must exist. */ - ret = rbt_search(query->word_freqs, &parent, token->f_str); + ret = rbt_search(query->word_freqs, &parent, token); ut_a(ret == 0); word_freqs = rbt_value(fts_word_freq_t, parent.last); query->error = fts_query_filter_doc_ids( - query, token->f_str, word_freqs, node, + query, token, word_freqs, node, node->ilist, ilist_size, TRUE); } } @@ -1073,7 +1082,7 @@ fts_cache_find_wildcard( ret = rbt_search(query->word_freqs, &freq_parent, - srch_text.f_str); + &srch_text); ut_a(ret == 0); @@ -1082,7 +1091,7 @@ fts_cache_find_wildcard( freq_parent.last); query->error = fts_query_filter_doc_ids( - query, srch_text.f_str, + query, &srch_text, word_freqs, node, node->ilist, node->ilist_size, TRUE); @@ -1542,7 +1551,7 @@ fts_merge_doc_ids( for (node = rbt_first(doc_ids); node; node = rbt_next(doc_ids, node)) { fts_ranking_t* ranking; ulint pos = 0; - byte* word = NULL; + fts_string_t word; ranking = rbt_value(fts_ranking_t, node); @@ -1557,7 +1566,7 @@ fts_merge_doc_ids( ut_a(ranking->words); while (fts_ranking_words_get_next(query, ranking, &pos, &word)) { fts_query_add_word_to_document(query, ranking->doc_id, - word); + &word); } } @@ -1696,6 +1705,9 @@ fts_proximity_is_word_in_range( { fts_proximity_t* proximity_pos = phrase->proximity_pos; + ut_ad(proximity_pos->n_pos == proximity_pos->min_pos.size()); + ut_ad(proximity_pos->n_pos == proximity_pos->max_pos.size()); + /* Search each matched position pair (with min and max positions) and count the number of words in the range */ for (ulint i = 0; i < proximity_pos->n_pos; i++) { @@ -1913,6 +1925,7 @@ fts_query_fetch_document( if (cur_len != UNIV_SQL_NULL && cur_len != 0) { if (phrase->proximity_pos) { + ut_ad(prev_len + cur_len <= total_len); memcpy(document_text + prev_len, data, cur_len); } else { /* For phrase search */ @@ -1923,17 +1936,18 @@ fts_query_fetch_document( cur_len, prev_len, phrase->heap); } + + /* Document positions are calculated from the beginning + of the first field, need to save the length for each + searched field to adjust the doc position when search + phrases. */ + prev_len += cur_len + 1; } if (phrase->found) { break; } - /* Document positions are calculated from the beginning - of the first field, need to save the length for each - searched field to adjust the doc position when search - phrases. */ - prev_len += cur_len + 1; exp = que_node_get_next(exp); } @@ -2472,8 +2486,7 @@ fts_query_search_phrase( token = static_cast<fts_string_t*>( ib_vector_get(tokens, z)); fts_query_add_word_to_document( - query, match->doc_id, - token->f_str); + query, match->doc_id, token); } } } @@ -2562,7 +2575,7 @@ fts_query_phrase_search( && result_str.f_n_char <= fts_max_token_size) { /* Add the word to the RB tree so that we can calculate it's frequencey within a document. */ - fts_query_add_word_freq(query, token->f_str); + fts_query_add_word_freq(query, token); } else { ib_vector_pop(tokens); } @@ -2580,6 +2593,11 @@ fts_query_phrase_search( } num_token = ib_vector_size(tokens); + if (num_token > MAX_PROXIMITY_ITEM) { + query->error = DB_FTS_TOO_MANY_WORDS_IN_PHRASE; + goto func_exit; + } + ut_ad(ib_vector_size(orig_tokens) >= num_token); /* Ignore empty strings. */ @@ -2605,7 +2623,7 @@ fts_query_phrase_search( heap_alloc, sizeof(fts_match_t), 64); } else { - ut_a(num_token < MAX_PROXIMITY_ITEM); + ut_a(num_token <= MAX_PROXIMITY_ITEM); query->match_array = (ib_vector_t**) mem_heap_alloc( heap, @@ -2687,7 +2705,7 @@ fts_query_phrase_search( } fts_query_add_word_to_document( - query, match->doc_id, token->f_str); + query, match->doc_id, token); } query->oper = oper; goto func_exit; @@ -2837,6 +2855,8 @@ fts_query_visitor( ut_ad(query->intersection == NULL); query->intersection = rbt_create( sizeof(fts_ranking_t), fts_ranking_doc_id_cmp); + + query->total_size += SIZEOF_RBT_CREATE; } /* Set the current proximity distance. */ @@ -2858,10 +2878,12 @@ fts_query_visitor( break; case FTS_AST_TERM: + token.f_str = node->term.ptr; + token.f_len = ut_strlen(reinterpret_cast<char*>(token.f_str)); /* Add the word to our RB tree that will be used to calculate this terms per document frequency. */ - fts_query_add_word_freq(query, node->term.ptr); + fts_query_add_word_freq(query, &token); ptr = fts_query_get_token(node, &token); query->error = fts_query_execute(query, &token); @@ -2871,6 +2893,10 @@ fts_query_visitor( } break; + case FTS_AST_SUBEXP_LIST: + query->error = fts_ast_visit_sub_exp(node, fts_query_visitor, arg); + break; + default: ut_error; } @@ -2905,13 +2931,7 @@ fts_ast_visit_sub_exp( ut_a(node->type == FTS_AST_SUBEXP_LIST); - node = node->list.head; - - if (!node || !node->next) { - return(error); - } - - cur_oper = node->oper; + cur_oper = query->oper; /* Save current result set */ parent_doc_ids = query->doc_ids; @@ -2927,26 +2947,20 @@ fts_ast_visit_sub_exp( query->multi_exist = false; /* Process nodes in current sub-expression and store its result set in query->doc_ids we created above. */ - error = fts_ast_visit(FTS_NONE, node->next, visitor, + error = fts_ast_visit(FTS_NONE, node, visitor, arg, &will_be_ignored); - /* Reinstate parent node state and prepare for merge. */ + /* Reinstate parent node state */ query->multi_exist = multi_exist; query->oper = cur_oper; - subexpr_doc_ids = query->doc_ids; - - /* Restore current result set. */ - query->doc_ids = parent_doc_ids; /* Merge the sub-expression result with the parent result set. */ + subexpr_doc_ids = query->doc_ids; + query->doc_ids = parent_doc_ids; if (error == DB_SUCCESS && !rbt_empty(subexpr_doc_ids)) { error = fts_merge_doc_ids(query, subexpr_doc_ids); } - if (query->oper == FTS_EXIST) { - query->multi_exist = true; - } - /* Free current result set. Result already merged into parent. */ fts_query_free_doc_ids(query, subexpr_doc_ids); @@ -3033,14 +3047,13 @@ static dberr_t fts_query_filter_doc_ids( /*=====================*/ - fts_query_t* query, /*!< in: query instance */ - const byte* word, /*!< in: the current word */ - fts_word_freq_t*word_freq, /*!< in/out: word frequency */ - const fts_node_t* - node, /*!< in: current FTS node */ - void* data, /*!< in: doc id ilist */ - ulint len, /*!< in: doc id ilist size */ - ibool calc_doc_count) /*!< in: whether to remember doc count */ + fts_query_t* query, /*!< in: query instance */ + const fts_string_t* word, /*!< in: the current word */ + fts_word_freq_t* word_freq, /*!< in/out: word frequency */ + const fts_node_t* node, /*!< in: current FTS node */ + void* data, /*!< in: doc id ilist */ + ulint len, /*!< in: doc id ilist size */ + ibool calc_doc_count) /*!< in: whether to remember doc count */ { byte* ptr = static_cast<byte*>(data); doc_id_t doc_id = 0; @@ -3163,13 +3176,15 @@ fts_query_read_node( ib_rbt_bound_t parent; fts_word_freq_t* word_freq; ibool skip = FALSE; - byte term[FTS_MAX_WORD_LEN + 1]; + fts_string_t term; + byte buf[FTS_MAX_WORD_LEN + 1]; dberr_t error = DB_SUCCESS; ut_a(query->cur_node->type == FTS_AST_TERM || query->cur_node->type == FTS_AST_TEXT); memset(&node, 0, sizeof(node)); + term.f_str = buf; /* Need to consider the wildcard search case, the word frequency is created on the search string not the actual word. So we need @@ -3179,15 +3194,18 @@ fts_query_read_node( /* These cast are safe since we only care about the terminating NUL character as an end of string marker. */ - ut_strcpy((char*) term, (char*) query->cur_node->term.ptr); + term.f_len = ut_strlen(reinterpret_cast<char*> + (query->cur_node->term.ptr)); + ut_ad(FTS_MAX_WORD_LEN >= term.f_len); + memcpy(term.f_str, query->cur_node->term.ptr, term.f_len); } else { - /* Need to copy the NUL character too. */ - memcpy(term, word->f_str, word->f_len); - term[word->f_len] = 0; + term.f_len = word->f_len; + ut_ad(FTS_MAX_WORD_LEN >= word->f_len); + memcpy(term.f_str, word->f_str, word->f_len); } /* Lookup the word in our rb tree, it must exist. */ - ret = rbt_search(query->word_freqs, &parent, term); + ret = rbt_search(query->word_freqs, &parent, &term); ut_a(ret == 0); @@ -3239,7 +3257,7 @@ fts_query_read_node( case 4: /* ILIST */ error = fts_query_filter_doc_ids( - query, word_freq->word, word_freq, + query, &word_freq->word, word_freq, &node, data, len, FALSE); break; @@ -3332,7 +3350,7 @@ fts_query_calculate_idf( if (fts_enable_diag_print) { fprintf(stderr,"'%s' -> " UINT64PF "/" UINT64PF " %6.5lf\n", - word_freq->word, + word_freq->word.f_str, query->total_docs, word_freq->doc_count, word_freq->idf); } @@ -3349,12 +3367,12 @@ fts_query_calculate_ranking( fts_ranking_t* ranking) /*!< in: Document to rank */ { ulint pos = 0; - byte* word = NULL; + fts_string_t word; /* At this stage, ranking->rank should not exceed the 1.0 bound */ ut_ad(ranking->rank <= 1.0 && ranking->rank >= -1.0); - ut_ad(query->word_map->size() == query->word_vector->size()); + ut_ad(rbt_size(query->word_map) == query->word_vector->size()); while (fts_ranking_words_get_next(query, ranking, &pos, &word)) { int ret; @@ -3363,8 +3381,7 @@ fts_query_calculate_ranking( fts_doc_freq_t* doc_freq; fts_word_freq_t* word_freq; - ut_ad(word != NULL); - ret = rbt_search(query->word_freqs, &parent, word); + ret = rbt_search(query->word_freqs, &parent, &word); /* It must exist. */ ut_a(ret == 0); @@ -3490,14 +3507,14 @@ fts_query_prepare_result( doc_freq = rbt_value(fts_doc_freq_t, node); /* Don't put deleted docs into result */ - if (fts_bsearch(array, 0, size, doc_freq->doc_id) + if (fts_bsearch(array, 0, static_cast<int>(size), doc_freq->doc_id) >= 0) { continue; } ranking.doc_id = doc_freq->doc_id; - ranking.rank = doc_freq->freq * word_freq->idf - * word_freq->idf; + ranking.rank = static_cast<fts_rank_t>( + doc_freq->freq * word_freq->idf * word_freq->idf); ranking.words = NULL; fts_query_add_ranking(query, result->rankings_by_id, @@ -3620,18 +3637,18 @@ fts_query_free( ut_a(!query->intersection); - if (query->heap) { - mem_heap_free(query->heap); - } - if (query->word_map) { - delete query->word_map; + rbt_free(query->word_map); } if (query->word_vector) { delete query->word_vector; } + if (query->heap) { + mem_heap_free(query->heap); + } + memset(query, 0, sizeof(*query)); } @@ -3820,6 +3837,7 @@ fts_query( query.fts_common_table.type = FTS_COMMON_TABLE; query.fts_common_table.table_id = index->table->id; query.fts_common_table.parent = index->table->name; + query.fts_common_table.table = index->table; charset = fts_index_get_charset(index); @@ -3828,15 +3846,18 @@ fts_query( query.fts_index_table.table_id = index->table->id; query.fts_index_table.parent = index->table->name; query.fts_index_table.charset = charset; + query.fts_index_table.table = index->table; - query.word_map = new word_map_t; + query.word_map = rbt_create_arg_cmp( + sizeof(fts_string_t), innobase_fts_text_cmp, + (void *) charset); query.word_vector = new word_vector_t; query.error = DB_SUCCESS; /* Setup the RB tree that will be used to collect per term statistics. */ query.word_freqs = rbt_create_arg_cmp( - sizeof(fts_word_freq_t), innobase_fts_string_cmp, + sizeof(fts_word_freq_t), innobase_fts_text_cmp, (void*) charset); query.total_size += SIZEOF_RBT_CREATE; @@ -4061,13 +4082,14 @@ fts_print_doc_id( fts_ranking_t* ranking; ranking = rbt_value(fts_ranking_t, node); - fprintf(stderr, "doc_ids info, doc_id: %ld \n", + ib_logf(IB_LOG_LEVEL_INFO, "doc_ids info, doc_id: %ld \n", (ulint) ranking->doc_id); - ulint pos = 0; - byte* value = NULL; - while (fts_ranking_words_get_next(query, ranking, &pos, &value)) { - fprintf(stderr, "doc_ids info, value: %s \n", value); + ulint pos = 0; + fts_string_t word; + + while (fts_ranking_words_get_next(query, ranking, &pos, &word)) { + ib_logf(IB_LOG_LEVEL_INFO, "doc_ids info, value: %s \n", word.f_str); } } } @@ -4123,7 +4145,7 @@ fts_expand_query( fts_ranking_t* ranking; ulint pos; - byte* word; + fts_string_t word; ulint prev_token_size; ulint estimate_size; @@ -4145,22 +4167,17 @@ fts_expand_query( /* Remove words that have already been searched in the first pass */ pos = 0; - word = NULL; while (fts_ranking_words_get_next(query, ranking, &pos, - &word)) { - fts_string_t str; + &word)) { ibool ret; - /* FIXME: We are discarding a const qualifier here. */ - str.f_str = word; - str.f_len = ut_strlen((const char*) str.f_str); - ret = rbt_delete(result_doc.tokens, &str); + ret = rbt_delete(result_doc.tokens, &word); /* The word must exist in the doc we found */ if (!ret) { - fprintf(stderr, " InnoDB: Error: Did not " + ib_logf(IB_LOG_LEVEL_ERROR, "Did not " "find word %s in doc %ld for query " - "expansion search.\n", str.f_str, + "expansion search.\n", word.f_str, (ulint) ranking->doc_id); } } @@ -4185,7 +4202,8 @@ fts_expand_query( fts_token_t* mytoken; mytoken = rbt_value(fts_token_t, token_node); - fts_query_add_word_freq(query, mytoken->text.f_str); + ut_ad(mytoken->text.f_str[mytoken->text.f_len] == 0); + fts_query_add_word_freq(query, &mytoken->text); error = fts_query_union(query, &mytoken->text); if (error != DB_SUCCESS) { @@ -4230,10 +4248,6 @@ fts_phrase_or_proximity_search( ulint j; ulint k = 0; fts_proximity_t qualified_pos; - ulint qualified_pos_buf[MAX_PROXIMITY_ITEM * 2]; - - qualified_pos.min_pos = &qualified_pos_buf[0]; - qualified_pos.max_pos = &qualified_pos_buf[MAX_PROXIMITY_ITEM]; match[0] = static_cast<fts_match_t*>( ib_vector_get(query->match_array[0], i)); @@ -4324,8 +4338,7 @@ fts_phrase_or_proximity_search( token = static_cast<fts_string_t*>( ib_vector_get(tokens, z)); fts_query_add_word_to_document( - query, match[0]->doc_id, - token->f_str); + query, match[0]->doc_id, token); } } } @@ -4366,7 +4379,7 @@ fts_proximity_get_positions( qualified_pos->n_pos = 0; - ut_a(num_match < MAX_PROXIMITY_ITEM); + ut_a(num_match <= MAX_PROXIMITY_ITEM); /* Each word could appear multiple times in a doc. So we need to walk through each word's position list, and find @@ -4421,8 +4434,8 @@ fts_proximity_get_positions( length encoding, record the min_pos and max_pos, we will need to verify the actual number of characters */ - qualified_pos->min_pos[qualified_pos->n_pos] = min_pos; - qualified_pos->max_pos[qualified_pos->n_pos] = max_pos; + qualified_pos->min_pos.push_back(min_pos); + qualified_pos->max_pos.push_back(max_pos); qualified_pos->n_pos++; } @@ -4431,7 +4444,5 @@ fts_proximity_get_positions( idx[min_idx]++; } - ut_ad(qualified_pos->n_pos <= MAX_PROXIMITY_ITEM); - return(qualified_pos->n_pos != 0); } diff --git a/storage/innobase/fts/fts0sql.cc b/storage/innobase/fts/fts0sql.cc index 03c19d93af6..cb8eff3cacc 100644 --- a/storage/innobase/fts/fts0sql.cc +++ b/storage/innobase/fts/fts0sql.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2013, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -61,21 +61,28 @@ fts_get_table_id( long */ { int len; + bool hex_name = DICT_TF2_FLAG_IS_SET(fts_table->table, + DICT_TF2_FTS_AUX_HEX_NAME); + + ut_a(fts_table->table != NULL); switch (fts_table->type) { case FTS_COMMON_TABLE: - len = fts_write_object_id(fts_table->table_id, table_id); + len = fts_write_object_id(fts_table->table_id, table_id, + hex_name); break; case FTS_INDEX_TABLE: - len = fts_write_object_id(fts_table->table_id, table_id); + len = fts_write_object_id(fts_table->table_id, table_id, + hex_name); table_id[len] = '_'; ++len; table_id += len; - len += fts_write_object_id(fts_table->index_id, table_id); + len += fts_write_object_id(fts_table->index_id, table_id, + hex_name); break; default: @@ -110,7 +117,7 @@ fts_get_table_name_prefix( if (slash) { /* Print up to and including the separator. */ - dbname_len = (slash - fts_table->parent) + 1; + dbname_len = static_cast<int>(slash - fts_table->parent) + 1; } len = fts_get_table_id(fts_table, table_id); @@ -145,7 +152,8 @@ fts_get_table_name( prefix_name = fts_get_table_name_prefix(fts_table); - name_len = strlen(prefix_name) + 1 + strlen(fts_table->suffix) + 1; + name_len = static_cast<int>( + strlen(prefix_name) + 1 + strlen(fts_table->suffix) + 1); name = static_cast<char*>(mem_alloc(name_len)); @@ -191,7 +199,7 @@ fts_parse_sql( str = ut_str3cat(fts_sql_begin, str_tmp, fts_sql_end); mem_free(str_tmp); - dict_locked = (fts_table && fts_table->table + dict_locked = (fts_table && fts_table->table->fts && (fts_table->table->fts->fts_status & TABLE_DICT_LOCKED)); diff --git a/storage/innobase/fts/fts0tlex.cc b/storage/innobase/fts/fts0tlex.cc index 717ddb8a77e..ef17ab1acf2 100644 --- a/storage/innobase/fts/fts0tlex.cc +++ b/storage/innobase/fts/fts0tlex.cc @@ -35,7 +35,7 @@ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -52,7 +52,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; @@ -185,7 +185,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ @@ -247,7 +247,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -305,9 +305,9 @@ YY_BUFFER_STATE fts0t_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner YY_BUFFER_STATE fts0t_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE fts0t_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); -void *fts0talloc (yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void *fts0trealloc (void *,yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); -void fts0tfree (void * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +void *fts0talloc (yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +void *fts0trealloc (void *,yy_size_t , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +void fts0tfree (void * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); #define yy_new_buffer fts0t_create_buffer @@ -347,14 +347,14 @@ typedef int yy_state_type; static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); +static void yy_fatal_error (yyconst char msg[] , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ + yyleng = static_cast<int>(yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; @@ -575,11 +575,11 @@ extern int fts0twrap (yyscan_t yyscanner ); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static void yy_flex_strncpy (char *,yyconst char *,int , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); +static int yy_flex_strlen (yyconst char * , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))); #endif #ifndef YY_NO_INPUT @@ -618,8 +618,8 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ + int n; \ + for ( n = 0; n < static_cast<int>(max_size) && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ @@ -631,7 +631,8 @@ static int input (yyscan_t yyscanner ); else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + while ( (result = static_cast<int>(fread(buf, 1, max_size, yyin)))==0 \ + && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -1019,8 +1020,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + int num_to_read =static_cast<int>( + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1); while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ @@ -1033,7 +1034,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + int new_size = static_cast<int>(b->yy_buf_size * 2); if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1054,8 +1055,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; + num_to_read = static_cast<int>( + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1); } @@ -1064,7 +1065,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, (size_t) num_to_read ); + yyg->yy_n_chars, num_to_read); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } @@ -1312,7 +1313,7 @@ static void fts0t_load_buffer_state (yyscan_t yyscanner) YY_BUFFER_STATE fts0t_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) fts0talloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in fts0t_create_buffer()" ); @@ -1378,7 +1379,7 @@ static void fts0t_load_buffer_state (yyscan_t yyscanner) } b->yy_is_interactive = 0; - + errno = oerrno; } @@ -1484,9 +1485,9 @@ static void fts0tensure_buffer_stack (yyscan_t yyscanner) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in fts0tensure_buffer_stack()" ); - + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_top = 0; return; @@ -1497,7 +1498,7 @@ static void fts0tensure_buffer_stack (yyscan_t yyscanner) /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + num_to_alloc = static_cast<int>(yyg->yy_buffer_stack_max + grow_size); yyg->yy_buffer_stack = (struct yy_buffer_state**)fts0trealloc (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) @@ -1515,12 +1516,12 @@ static void fts0tensure_buffer_stack (yyscan_t yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE fts0t_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -1535,7 +1536,7 @@ YY_BUFFER_STATE fts0t_scan_buffer (char * base, yy_size_t size , yyscan_t yysc b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; + b->yy_n_chars = static_cast<int>(b->yy_buf_size); b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; @@ -1556,8 +1557,8 @@ YY_BUFFER_STATE fts0t_scan_buffer (char * base, yy_size_t size , yyscan_t yysc */ YY_BUFFER_STATE fts0t_scan_string (yyconst char * yystr , yyscan_t yyscanner) { - - return fts0t_scan_bytes(yystr,strlen(yystr) ,yyscanner); + + return fts0t_scan_bytes(yystr,static_cast<int>(strlen(yystr)) ,yyscanner); } /** Setup the input buffer state to scan the given bytes. The next call to fts0tlex() will @@ -1573,7 +1574,7 @@ YY_BUFFER_STATE fts0t_scan_bytes (yyconst char * yybytes, int _yybytes_len , y char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) fts0talloc(n ,yyscanner ); @@ -1601,7 +1602,7 @@ YY_BUFFER_STATE fts0t_scan_bytes (yyconst char * yybytes, int _yybytes_len , y #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); @@ -1641,10 +1642,10 @@ YY_EXTRA_TYPE fts0tget_extra (yyscan_t yyscanner) int fts0tget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -1654,10 +1655,10 @@ int fts0tget_lineno (yyscan_t yyscanner) int fts0tget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -1718,8 +1719,8 @@ void fts0tset_lineno (int line_number , yyscan_t yyscanner) /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "fts0tset_lineno called with no buffer" , yyscanner); - + yy_fatal_error( "fts0tset_lineno called with no buffer" , yyscanner); + yylineno = line_number; } @@ -1733,8 +1734,8 @@ void fts0tset_column (int column_no , yyscan_t yyscanner) /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "fts0tset_column called with no buffer" , yyscanner); - + yy_fatal_error( "fts0tset_column called with no buffer" , yyscanner); + yycolumn = column_no; } @@ -1817,20 +1818,20 @@ int fts0tlex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) errno = EINVAL; return 1; } - + *ptr_yy_globals = (yyscan_t) fts0talloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - + if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } - + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - + fts0tset_extra (yy_user_defined, *ptr_yy_globals); - + return yy_init_globals ( *ptr_yy_globals ); } @@ -1902,7 +1903,7 @@ int fts0tlex_destroy (yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { register int i; for ( i = 0; i < n; ++i ) @@ -1911,7 +1912,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { register int n; for ( n = 0; s[n]; ++n ) @@ -1921,12 +1922,12 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner __attribu } #endif -void *fts0talloc (yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0talloc (yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { return (void *) malloc( size ); } -void *fts0trealloc (void * ptr, yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void *fts0trealloc (void * ptr, yy_size_t size , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those @@ -1938,7 +1939,7 @@ void *fts0trealloc (void * ptr, yy_size_t size , yyscan_t yyscanner __at return (void *) realloc( (char *) ptr, size ); } -void fts0tfree (void * ptr , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) +void fts0tfree (void * ptr , yyscan_t yyscanner __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused)) __attribute__((unused))) { free( (char *) ptr ); /* see fts0trealloc() for (char *) cast */ } |