mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Incompatible ftparser plugin API change.
mysql_parse() and mysql_add_word() now take a MYSQL_FTPARSER_PARAM*, not a mysql_ftparam. client/Makefile.am: don't fail when rm cannot delete from read-only dir sql/sql_plugin.cc: fix min_plugin_info_interface_version to be less error-prone
This commit is contained in:
@ -83,12 +83,12 @@ link_sources:
|
||||
for f in $(sql_src) ; do \
|
||||
rm -f $$f; \
|
||||
@LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \
|
||||
done; \
|
||||
done;
|
||||
for f in $(strings_src) ; do \
|
||||
rm -f $(srcdir)/$$f; \
|
||||
@LN_CP_F@ $(top_srcdir)/strings/$$f $$f; \
|
||||
done; \
|
||||
rm -f $(srcdir)/my_user.c; \
|
||||
done;
|
||||
-rm -f $(srcdir)/my_user.c;
|
||||
@LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c
|
||||
|
||||
|
||||
|
@ -98,9 +98,11 @@ struct st_mysql_plugin
|
||||
API for Full-text [pre]parser plugin. (MYSQL_FTPARSER_PLUGIN)
|
||||
*/
|
||||
|
||||
#define MYSQL_FTPARSER_INTERFACE_VERSION 0x0000
|
||||
#define MYSQL_FTPARSER_INTERFACE_VERSION 0x0100
|
||||
|
||||
/* Parsing modes. Set in MYSQL_FTPARSER_PARAM::mode */
|
||||
enum enum_ftparser_mode
|
||||
{
|
||||
/*
|
||||
Fast and simple mode. This mode is used for indexing, and natural
|
||||
language queries.
|
||||
@ -109,7 +111,7 @@ struct st_mysql_plugin
|
||||
index. Stopwords or too short/long words should not be returned. The
|
||||
'boolean_info' argument of mysql_add_word() does not have to be set.
|
||||
*/
|
||||
#define MYSQL_FTPARSER_SIMPLE_MODE 0
|
||||
MYSQL_FTPARSER_SIMPLE_MODE= 0,
|
||||
|
||||
/*
|
||||
Parse with stopwords mode. This mode is used in boolean searches for
|
||||
@ -120,7 +122,7 @@ struct st_mysql_plugin
|
||||
or long. The 'boolean_info' argument of mysql_add_word() does not
|
||||
have to be set.
|
||||
*/
|
||||
#define MYSQL_FTPARSER_WITH_STOPWORDS 1
|
||||
MYSQL_FTPARSER_WITH_STOPWORDS= 1,
|
||||
|
||||
/*
|
||||
Parse in boolean mode. This mode is used to parse a boolean query string.
|
||||
@ -133,7 +135,8 @@ struct st_mysql_plugin
|
||||
MYSQL_FTPARSER_WITH_STOPWORDS mode, no word should be ignored.
|
||||
Instead, use FT_TOKEN_STOPWORD for the token type of such a word.
|
||||
*/
|
||||
#define MYSQL_FTPARSER_FULL_BOOLEAN_INFO 2
|
||||
MYSQL_FTPARSER_FULL_BOOLEAN_INFO= 2
|
||||
};
|
||||
|
||||
/*
|
||||
Token types for boolean mode searching (used for the type member of
|
||||
@ -209,22 +212,20 @@ typedef struct st_mysql_ftparser_boolean_info
|
||||
to invoke the MySQL default parser. If plugin's role is to extract
|
||||
textual data from .doc, .pdf or .xml content, it might extract
|
||||
plaintext from the content, and then pass the text to the default
|
||||
MySQL parser to be parsed. When mysql_parser is called, its param
|
||||
argument should be given as the mysql_ftparam value.
|
||||
MySQL parser to be parsed.
|
||||
|
||||
mysql_add_word: A server callback to add a new word. When parsing
|
||||
a document, the server sets this to point at a function that adds
|
||||
the word to MySQL full-text index. When parsing a search query,
|
||||
this function will add the new word to the list of words to search
|
||||
for. When mysql_add_word is called, its param argument should be
|
||||
given as the mysql_ftparam value. boolean_info can be NULL for all
|
||||
cases except when mode is MYSQL_FTPARSER_FULL_BOOLEAN_INFO.
|
||||
for. The boolean_info argument can be NULL for all cases except
|
||||
when mode is MYSQL_FTPARSER_FULL_BOOLEAN_INFO.
|
||||
|
||||
ftparser_state: A generic pointer. The plugin can set it to point
|
||||
to information to be used internally for its own purposes.
|
||||
|
||||
mysql_ftparam: This is set by the server. It is passed as the first
|
||||
argument to the mysql_parse or mysql_add_word callback. The plugin
|
||||
mysql_ftparam: This is set by the server. It is used by MySQL functions
|
||||
called via mysql_parse() and mysql_add_word() callback. The plugin
|
||||
should not modify it.
|
||||
|
||||
cs: Information about the character set of the document or query string.
|
||||
@ -239,15 +240,17 @@ typedef struct st_mysql_ftparser_boolean_info
|
||||
|
||||
typedef struct st_mysql_ftparser_param
|
||||
{
|
||||
int (*mysql_parse)(void *param, char *doc, int doc_len);
|
||||
int (*mysql_add_word)(void *param, char *word, int word_len,
|
||||
int (*mysql_parse)(struct st_mysql_ftparser_param *,
|
||||
char *doc, int doc_len);
|
||||
int (*mysql_add_word)(struct st_mysql_ftparser_param *,
|
||||
char *word, int word_len,
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info);
|
||||
void *ftparser_state;
|
||||
void *mysql_ftparam;
|
||||
struct charset_info_st *cs;
|
||||
char *doc;
|
||||
int length;
|
||||
int mode;
|
||||
enum enum_ftparser_mode mode;
|
||||
} MYSQL_FTPARSER_PARAM;
|
||||
|
||||
/*
|
||||
|
@ -144,10 +144,7 @@ static void add_word(MYSQL_FTPARSER_PARAM *param, char *word, size_t len)
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO bool_info=
|
||||
{ FT_TOKEN_WORD, 0, 0, 0, 0, ' ', 0 };
|
||||
|
||||
if (param->mode == MYSQL_FTPARSER_FULL_BOOLEAN_INFO)
|
||||
param->mysql_add_word(param->mysql_ftparam, word, len, &bool_info);
|
||||
else
|
||||
param->mysql_add_word(param->mysql_ftparam, word, len, 0);
|
||||
param->mysql_add_word(param, word, len, &bool_info);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -41,8 +41,8 @@ static int min_plugin_interface_version= 0x0000;
|
||||
static int min_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
||||
{
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x0000
|
||||
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||
MYSQL_FTPARSER_INTERFACE_VERSION
|
||||
};
|
||||
static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
||||
{
|
||||
@ -50,6 +50,7 @@ static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
||||
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||
MYSQL_FTPARSER_INTERFACE_VERSION
|
||||
};
|
||||
|
||||
static DYNAMIC_ARRAY plugin_dl_array;
|
||||
static DYNAMIC_ARRAY plugin_array;
|
||||
static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM];
|
||||
|
@ -160,7 +160,6 @@ static int FTB_WORD_cmp_list(CHARSET_INFO *cs, FTB_WORD **a, FTB_WORD **b)
|
||||
|
||||
typedef struct st_my_ftb_param
|
||||
{
|
||||
MYSQL_FTPARSER_PARAM *up;
|
||||
FTB *ftb;
|
||||
FTB_EXPR *ftbe;
|
||||
byte *up_quot;
|
||||
@ -168,10 +167,11 @@ typedef struct st_my_ftb_param
|
||||
} MY_FTB_PARAM;
|
||||
|
||||
|
||||
static int ftb_query_add_word(void *param, char *word, int word_len,
|
||||
static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param,
|
||||
char *word, int word_len,
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO *info)
|
||||
{
|
||||
MY_FTB_PARAM *ftb_param= (MY_FTB_PARAM *)param;
|
||||
MY_FTB_PARAM *ftb_param= param->mysql_ftparam;
|
||||
FTB_WORD *ftbw;
|
||||
FTB_EXPR *ftbe, *tmp_expr;
|
||||
FT_WORD *phrase_word;
|
||||
@ -269,9 +269,10 @@ static int ftb_query_add_word(void *param, char *word, int word_len,
|
||||
}
|
||||
|
||||
|
||||
static int ftb_parse_query_internal(void *param, char *query, int len)
|
||||
static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param,
|
||||
char *query, int len)
|
||||
{
|
||||
MY_FTB_PARAM *ftb_param= (MY_FTB_PARAM *)param;
|
||||
MY_FTB_PARAM *ftb_param= param->mysql_ftparam;
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO info;
|
||||
CHARSET_INFO *cs= ftb_param->ftb->charset;
|
||||
char **start= &query;
|
||||
@ -281,7 +282,7 @@ static int ftb_parse_query_internal(void *param, char *query, int len)
|
||||
info.prev= ' ';
|
||||
info.quot= 0;
|
||||
while (ft_get_word(cs, start, end, &w, &info))
|
||||
ftb_param->up->mysql_add_word(param, w.pos, w.len, &info);
|
||||
param->mysql_add_word(param, w.pos, w.len, &info);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -299,7 +300,6 @@ static void _ftb_parse_query(FTB *ftb, byte *query, uint len,
|
||||
if (! (param= ftparser_call_initializer(ftb->info, ftb->keynr, 0)))
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
ftb_param.up= param;
|
||||
ftb_param.ftb= ftb;
|
||||
ftb_param.depth= 0;
|
||||
ftb_param.ftbe= ftb->root;
|
||||
@ -571,7 +571,6 @@ err:
|
||||
|
||||
typedef struct st_my_ftb_phrase_param
|
||||
{
|
||||
MYSQL_FTPARSER_PARAM *up;
|
||||
LIST *phrase;
|
||||
LIST *document;
|
||||
CHARSET_INFO *cs;
|
||||
@ -581,10 +580,11 @@ typedef struct st_my_ftb_phrase_param
|
||||
} MY_FTB_PHRASE_PARAM;
|
||||
|
||||
|
||||
static int ftb_phrase_add_word(void *param, char *word, int word_len,
|
||||
static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param,
|
||||
char *word, int word_len,
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused)))
|
||||
{
|
||||
MY_FTB_PHRASE_PARAM *phrase_param= (MY_FTB_PHRASE_PARAM *)param;
|
||||
MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam;
|
||||
FT_WORD *w= (FT_WORD *)phrase_param->document->data;
|
||||
LIST *phrase, *document;
|
||||
w->pos= word;
|
||||
@ -611,14 +611,15 @@ static int ftb_phrase_add_word(void *param, char *word, int word_len,
|
||||
}
|
||||
|
||||
|
||||
static int ftb_check_phrase_internal(void *param, char *document, int len)
|
||||
static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param,
|
||||
char *document, int len)
|
||||
{
|
||||
FT_WORD word;
|
||||
MY_FTB_PHRASE_PARAM *phrase_param= (MY_FTB_PHRASE_PARAM *)param;
|
||||
MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam;
|
||||
const char *docend= document + len;
|
||||
while (ft_simple_get_word(phrase_param->cs, &document, docend, &word, FALSE))
|
||||
{
|
||||
phrase_param->up->mysql_add_word(param, word.pos, word.len, 0);
|
||||
param->mysql_add_word(param, word.pos, word.len, 0);
|
||||
if (phrase_param->match)
|
||||
return 1;
|
||||
}
|
||||
@ -651,7 +652,6 @@ static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len,
|
||||
if (! (param= ftparser_call_initializer(ftb->info, ftb->keynr, 1)))
|
||||
DBUG_RETURN(0);
|
||||
|
||||
ftb_param.up= param;
|
||||
ftb_param.phrase= ftbe->phrase;
|
||||
ftb_param.document= ftbe->document;
|
||||
ftb_param.cs= ftb->charset;
|
||||
@ -820,16 +820,16 @@ err:
|
||||
|
||||
typedef struct st_my_ftb_find_param
|
||||
{
|
||||
MYSQL_FTPARSER_PARAM *up;
|
||||
FT_INFO *ftb;
|
||||
FT_SEG_ITERATOR *ftsi;
|
||||
} MY_FTB_FIND_PARAM;
|
||||
|
||||
|
||||
static int ftb_find_relevance_add_word(void *param, char *word, int len,
|
||||
static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param,
|
||||
char *word, int len,
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused)))
|
||||
{
|
||||
MY_FTB_FIND_PARAM *ftb_param= (MY_FTB_FIND_PARAM *)param;
|
||||
MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam;
|
||||
FT_INFO *ftb= ftb_param->ftb;
|
||||
FTB_WORD *ftbw;
|
||||
int a, b, c;
|
||||
@ -859,14 +859,15 @@ static int ftb_find_relevance_add_word(void *param, char *word, int len,
|
||||
}
|
||||
|
||||
|
||||
static int ftb_find_relevance_parse(void *param, char *doc, int len)
|
||||
static int ftb_find_relevance_parse(MYSQL_FTPARSER_PARAM *param,
|
||||
char *doc, int len)
|
||||
{
|
||||
MY_FTB_FIND_PARAM *ftb_param=(MY_FTB_FIND_PARAM *)param;
|
||||
MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam;
|
||||
FT_INFO *ftb= ftb_param->ftb;
|
||||
char *end= doc + len;
|
||||
FT_WORD w;
|
||||
while (ft_simple_get_word(ftb->charset, &doc, end, &w, TRUE))
|
||||
ftb_param->up->mysql_add_word(param, w.pos, w.len, 0);
|
||||
param->mysql_add_word(param, w.pos, w.len, 0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -910,7 +911,6 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length)
|
||||
_mi_ft_segiterator_init(ftb->info, ftb->keynr, record, &ftsi);
|
||||
memcpy(&ftsi2, &ftsi, sizeof(ftsi));
|
||||
|
||||
ftb_param.up= param;
|
||||
ftb_param.ftb= ftb;
|
||||
ftb_param.ftsi= &ftsi2;
|
||||
param->mysql_parse= ftb_find_relevance_parse;
|
||||
|
@ -27,7 +27,6 @@ typedef struct st_ft_docstat {
|
||||
|
||||
typedef struct st_my_ft_parser_param
|
||||
{
|
||||
MYSQL_FTPARSER_PARAM *up;
|
||||
TREE *wtree;
|
||||
my_bool with_alloc;
|
||||
} MY_FT_PARSER_PARAM;
|
||||
@ -241,14 +240,16 @@ void ft_parse_init(TREE *wtree, CHARSET_INFO *cs)
|
||||
}
|
||||
|
||||
|
||||
static int ft_add_word(void *param, byte *word, uint word_len,
|
||||
static int ft_add_word(MYSQL_FTPARSER_PARAM *param,
|
||||
char *word, int word_len,
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused)))
|
||||
{
|
||||
TREE *wtree;
|
||||
FT_WORD w;
|
||||
MY_FT_PARSER_PARAM *ft_param=param->mysql_ftparam;
|
||||
DBUG_ENTER("ft_add_word");
|
||||
wtree= ((MY_FT_PARSER_PARAM *)param)->wtree;
|
||||
if (((MY_FT_PARSER_PARAM *)param)->with_alloc)
|
||||
wtree= ft_param->wtree;
|
||||
if (ft_param->with_alloc)
|
||||
{
|
||||
byte *ptr;
|
||||
/* allocating the data in the tree - to avoid mallocs and frees */
|
||||
@ -269,16 +270,17 @@ static int ft_add_word(void *param, byte *word, uint word_len,
|
||||
}
|
||||
|
||||
|
||||
static int ft_parse_internal(void *param, byte *doc, int doc_len)
|
||||
static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param,
|
||||
byte *doc, int doc_len)
|
||||
{
|
||||
byte *end=doc+doc_len;
|
||||
MY_FT_PARSER_PARAM *ft_param=(MY_FT_PARSER_PARAM *)param;
|
||||
MY_FT_PARSER_PARAM *ft_param=param->mysql_ftparam;
|
||||
TREE *wtree= ft_param->wtree;
|
||||
FT_WORD w;
|
||||
DBUG_ENTER("ft_parse_internal");
|
||||
|
||||
while (ft_simple_get_word(wtree->custom_arg, &doc, end, &w, TRUE))
|
||||
if (ft_param->up->mysql_add_word(param, w.pos, w.len, 0))
|
||||
if (param->mysql_add_word(param, w.pos, w.len, 0))
|
||||
DBUG_RETURN(1);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
@ -292,7 +294,6 @@ int ft_parse(TREE *wtree, byte *doc, int doclen, my_bool with_alloc,
|
||||
DBUG_ENTER("ft_parse");
|
||||
DBUG_ASSERT(parser);
|
||||
|
||||
my_param.up= param;
|
||||
my_param.wtree= wtree;
|
||||
my_param.with_alloc= with_alloc;
|
||||
|
||||
|
@ -629,7 +629,7 @@ const char *ft_precompiled_stopwords[] = {
|
||||
|
||||
static int ft_default_parser_parse(MYSQL_FTPARSER_PARAM *param)
|
||||
{
|
||||
return param->mysql_parse(param->mysql_ftparam, param->doc, param->length);
|
||||
return param->mysql_parse(param, param->doc, param->length);
|
||||
}
|
||||
|
||||
struct st_mysql_ftparser ft_default_parser=
|
||||
|
Reference in New Issue
Block a user