InnoDB Plugin
1.0
Main Page
Data Structures
Files
File List
Globals
include
fts0ast.h
Go to the documentation of this file.
1
/*****************************************************************************
2
3
Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved.
4
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
8
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc.,
15
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16
17
*****************************************************************************/
18
19
/******************************************************************/
26
#ifndef INNOBASE_FST0AST_H
27
#define INNOBASE_FST0AST_H
28
29
#include "
mem0mem.h
"
30
#include "
ha_prototypes.h
"
31
32
/* The type of AST Node */
33
enum
fts_ast_type_t
{
34
FTS_AST_OPER
,
35
FTS_AST_NUMB
,
36
FTS_AST_TERM
,
37
FTS_AST_TEXT
,
38
FTS_AST_LIST
,
39
FTS_AST_SUBEXP_LIST
40
};
41
42
/* The FTS query operators that we support */
43
enum
fts_ast_oper_t
{
44
FTS_NONE
,
46
FTS_IGNORE
,
49
FTS_EXIST
,
52
FTS_NEGATE
,
56
FTS_INCR_RATING
,
59
FTS_DECR_RATING
,
62
FTS_DISTANCE
,
63
FTS_IGNORE_SKIP
,
68
FTS_EXIST_SKIP
73
};
74
75
/* Data types used by the FTS parser */
76
struct
fts_lexer_t;
77
struct
fts_ast_node_t
;
78
struct
fts_ast_state_t
;
79
struct
fts_ast_string_t
;
80
81
typedef
dberr_t
(*fts_ast_callback)(
fts_ast_oper_t
,
fts_ast_node_t
*,
void
*);
82
83
/********************************************************************
84
Parse the string using the lexer setup within state.*/
85
int
86
fts_parse
(
87
/*======*/
88
/* out: 0 on OK, 1 on error */
89
fts_ast_state_t
* state);
91
/********************************************************************
92
Create an AST operator node */
93
extern
94
fts_ast_node_t
*
95
fts_ast_create_node_oper
(
96
/*=====================*/
97
void
* arg,
98
fts_ast_oper_t
oper);
99
/********************************************************************
100
Create an AST term node, makes a copy of ptr */
101
extern
102
fts_ast_node_t
*
103
fts_ast_create_node_term
(
104
/*=====================*/
105
void
* arg,
106
const
fts_ast_string_t
* ptr);
107
/********************************************************************
108
Create an AST text node */
109
extern
110
fts_ast_node_t
*
111
fts_ast_create_node_text
(
112
/*=====================*/
113
void
* arg,
114
const
fts_ast_string_t
* ptr);
115
/********************************************************************
116
Create an AST expr list node */
117
extern
118
fts_ast_node_t
*
119
fts_ast_create_node_list
(
120
/*=====================*/
121
void
* arg,
122
fts_ast_node_t
* expr);
123
/********************************************************************
124
Create a sub-expression list node. This function takes ownership of
125
expr and is responsible for deleting it. */
126
extern
127
fts_ast_node_t
*
128
fts_ast_create_node_subexp_list
(
129
/*============================*/
130
/* out: new node */
131
void
* arg,
132
fts_ast_node_t
* expr);
133
/********************************************************************
134
Set the wildcard attribute of a term.*/
135
extern
136
void
137
fts_ast_term_set_wildcard
(
138
/*======================*/
139
fts_ast_node_t
* node);
140
/********************************************************************
141
Set the proximity attribute of a text node. */
142
143
void
144
fts_ast_term_set_distance
(
145
/*======================*/
146
fts_ast_node_t
* node,
147
ulint distance);
149
/********************************************************************/
152
UNIV_INTERN
153
fts_ast_node_t
*
154
fts_ast_free_node
(
155
/*==============*/
156
fts_ast_node_t
* node);
157
/********************************************************************
158
Add a sub-expression to an AST*/
159
extern
160
fts_ast_node_t
*
161
fts_ast_add_node
(
162
/*=============*/
163
fts_ast_node_t
* list,
164
fts_ast_node_t
* node);
165
/********************************************************************
166
Print the AST node recursively.*/
167
extern
168
void
169
fts_ast_node_print
(
170
/*===============*/
171
fts_ast_node_t
* node);
172
/********************************************************************
173
For tracking node allocations, in case there is an during parsing.*/
174
extern
175
void
176
fts_ast_state_add_node
(
177
/*===================*/
178
fts_ast_state_t
*state,
179
fts_ast_node_t
* node);
180
/********************************************************************
181
Free node and expr allocations.*/
182
extern
183
void
184
fts_ast_state_free
(
185
/*===============*/
186
fts_ast_state_t
*state);
188
/******************************************************************/
191
UNIV_INTERN
192
dberr_t
193
fts_ast_visit
(
194
/*==========*/
195
fts_ast_oper_t
oper,
196
fts_ast_node_t
* node,
197
fts_ast_callback visitor,
198
void
* arg,
199
bool
* has_ignore)
203
__attribute__((nonnull, warn_unused_result));
204
/*****************************************************************/
209
UNIV_INTERN
210
dberr_t
211
fts_ast_visit_sub_exp
(
212
/*==================*/
213
fts_ast_node_t
* node,
214
fts_ast_callback visitor,
215
void
* arg)
216
__attribute__((nonnull, warn_unused_result));
217
/********************************************************************
218
Create a lex instance.*/
219
UNIV_INTERN
220
fts_lexer_t*
221
fts_lexer_create
(
222
/*=============*/
223
ibool
boolean_mode,
224
const
byte* query,
225
ulint query_len)
226
__attribute__((nonnull, malloc, warn_unused_result));
227
/********************************************************************
228
Free an fts_lexer_t instance.*/
229
UNIV_INTERN
230
void
231
fts_lexer_free
(
232
/*===========*/
233
fts_lexer_t* fts_lexer)
235
__attribute__((nonnull));
236
243
UNIV_INTERN
244
fts_ast_string_t
*
245
fts_ast_string_create
(
246
const
byte*
str
,
247
ulint len);
248
252
UNIV_INTERN
253
void
254
fts_ast_string_free
(
255
fts_ast_string_t
* ast_str);
256
262
UNIV_INTERN
263
ulint
264
fts_ast_string_to_ul
(
265
const
fts_ast_string_t
* ast_str,
266
int
base);
267
271
UNIV_INTERN
272
void
273
fts_ast_string_print
(
274
const
fts_ast_string_t
* ast_str);
275
276
/* String of length len.
277
We always store the string of length len with a terminating '\0',
278
regardless of there is any 0x00 in the string itself */
279
struct
fts_ast_string_t
{
281
byte*
str
;
282
284
ulint len;
285
};
286
287
/* Query term type */
288
struct
fts_ast_term_t
{
289
fts_ast_string_t
*
ptr
;
290
ibool
wildcard
;
291
};
292
293
/* Query text type */
294
struct
fts_ast_text_t
{
295
fts_ast_string_t
*
ptr
;
296
ulint
distance
;
298
};
299
300
/* The list of nodes in an expr list */
301
struct
fts_ast_list_t
{
302
fts_ast_node_t
*
head
;
303
fts_ast_node_t
*
tail
;
304
};
305
306
/* FTS AST node to store the term, text, operator and sub-expressions.*/
307
struct
fts_ast_node_t
{
308
fts_ast_type_t
type
;
309
fts_ast_text_t
text
;
310
fts_ast_term_t
term
;
311
fts_ast_oper_t
oper
;
312
fts_ast_list_t
list
;
313
fts_ast_node_t
*
next
;
314
fts_ast_node_t
*
next_alloc
;
315
bool
visited
;
317
};
318
319
/* To track state during parsing */
320
struct
fts_ast_state_t
{
321
mem_heap_t
*
heap
;
322
fts_ast_node_t
*
root
;
325
fts_ast_list_t
list
;
327
fts_lexer_t*
lexer
;
328
CHARSET_INFO*
charset
;
330
};
331
332
#ifdef UNIV_DEBUG
333
const
char
*
334
fts_ast_oper_name_get(
fts_ast_oper_t
oper);
335
const
char
*
336
fts_ast_node_type_get(
fts_ast_type_t
type);
337
#endif
/* UNIV_DEBUG */
338
339
#endif
/* INNOBASE_FSTS0AST_H */
Generated on Fri Aug 21 2015 19:14:24 for InnoDB Plugin by
1.8.1.2