MySQL 5.6.14 Source Code Document
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
fts0ast.h
Go to the documentation of this file.
1
/*****************************************************************************
2
3
Copyright (c) 2007, 2013, 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
80
typedef
dberr_t
(*fts_ast_callback)(
fts_ast_oper_t
,
fts_ast_node_t
*,
void
*);
81
82
/********************************************************************
83
Parse the string using the lexer setup within state.*/
84
int
85
fts_parse
(
86
/*======*/
87
/* out: 0 on OK, 1 on error */
88
fts_ast_state_t
* state);
90
/********************************************************************
91
Create an AST operator node */
92
extern
93
fts_ast_node_t
*
94
fts_ast_create_node_oper
(
95
/*=====================*/
96
void
* arg,
97
fts_ast_oper_t
oper);
98
/********************************************************************
99
Create an AST term node, makes a copy of ptr */
100
extern
101
fts_ast_node_t
*
102
fts_ast_create_node_term
(
103
/*=====================*/
104
void
* arg,
105
const
char
* ptr);
106
/********************************************************************
107
Create an AST text node */
108
extern
109
fts_ast_node_t
*
110
fts_ast_create_node_text
(
111
/*=====================*/
112
void
* arg,
113
const
char
* ptr);
114
/********************************************************************
115
Create an AST expr list node */
116
extern
117
fts_ast_node_t
*
118
fts_ast_create_node_list
(
119
/*=====================*/
120
void
* arg,
121
fts_ast_node_t
* expr);
122
/********************************************************************
123
Create a sub-expression list node. This function takes ownership of
124
expr and is responsible for deleting it. */
125
extern
126
fts_ast_node_t
*
127
fts_ast_create_node_subexp_list
(
128
/*============================*/
129
/* out: new node */
130
void
* arg,
131
fts_ast_node_t
* expr);
132
/********************************************************************
133
Set the wildcard attribute of a term.*/
134
extern
135
void
136
fts_ast_term_set_wildcard
(
137
/*======================*/
138
fts_ast_node_t
* node);
139
/********************************************************************
140
Set the proximity attribute of a text node. */
141
142
void
143
fts_ast_term_set_distance
(
144
/*======================*/
145
fts_ast_node_t
* node,
146
ulint distance);
148
/********************************************************************/
151
UNIV_INTERN
152
fts_ast_node_t
*
153
fts_ast_free_node
(
154
/*==============*/
155
fts_ast_node_t
* node);
156
/********************************************************************
157
Add a sub-expression to an AST*/
158
extern
159
fts_ast_node_t
*
160
fts_ast_add_node
(
161
/*=============*/
162
fts_ast_node_t
*
list
,
163
fts_ast_node_t
* node);
164
/********************************************************************
165
Print the AST node recursively.*/
166
extern
167
void
168
fts_ast_node_print
(
169
/*===============*/
170
fts_ast_node_t
* node);
171
/********************************************************************
172
For tracking node allocations, in case there is an during parsing.*/
173
extern
174
void
175
fts_ast_state_add_node
(
176
/*===================*/
177
fts_ast_state_t
*state,
178
fts_ast_node_t
* node);
179
/********************************************************************
180
Free node and expr allocations.*/
181
extern
182
void
183
fts_ast_state_free
(
184
/*===============*/
185
fts_ast_state_t
*state);
187
/******************************************************************/
190
UNIV_INTERN
191
dberr_t
192
fts_ast_visit
(
193
/*==========*/
194
fts_ast_oper_t
oper,
195
fts_ast_node_t
* node,
196
fts_ast_callback visitor,
197
void
* arg,
198
bool
* has_ignore)
202
__attribute__((nonnull, warn_unused_result));
203
/*****************************************************************/
208
UNIV_INTERN
209
dberr_t
210
fts_ast_visit_sub_exp
(
211
/*==================*/
212
fts_ast_node_t
* node,
213
fts_ast_callback visitor,
214
void
* arg)
215
__attribute__((nonnull, warn_unused_result));
216
/********************************************************************
217
Create a lex instance.*/
218
UNIV_INTERN
219
fts_lexer_t
*
220
fts_lexer_create
(
221
/*=============*/
222
ibool boolean_mode,
223
const
byte*
query
,
224
ulint query_len)
225
__attribute__((nonnull, malloc, warn_unused_result));
226
/********************************************************************
227
Free an fts_lexer_t instance.*/
228
UNIV_INTERN
229
void
230
fts_lexer_free
(
231
/*===========*/
232
fts_lexer_t
* fts_lexer)
234
__attribute__((nonnull));
235
236
/* Query term type */
237
struct
fts_ast_term_t
{
238
byte*
ptr
;
239
ibool
wildcard
;
240
};
241
242
/* Query text type */
243
struct
fts_ast_text_t
{
244
byte*
ptr
;
245
ulint
distance
;
247
};
248
249
/* The list of nodes in an expr list */
250
struct
fts_ast_list_t
{
251
fts_ast_node_t
*
head
;
252
fts_ast_node_t
*
tail
;
253
};
254
255
/* FTS AST node to store the term, text, operator and sub-expressions.*/
256
struct
fts_ast_node_t
{
257
fts_ast_type_t
type
;
258
fts_ast_text_t
text
;
259
fts_ast_term_t
term
;
260
fts_ast_oper_t
oper
;
261
fts_ast_list_t
list
;
262
fts_ast_node_t
*
next
;
263
fts_ast_node_t
*
next_alloc
;
264
bool
visited
;
266
};
267
268
/* To track state during parsing */
269
struct
fts_ast_state_t
{
270
mem_heap_t
*
heap
;
271
fts_ast_node_t
*
root
;
274
fts_ast_list_t
list
;
276
fts_lexer_t
*
lexer
;
277
CHARSET_INFO
*
charset
;
279
};
280
281
#endif
/* INNOBASE_FSTS0AST_H */
storage
innobase
include
fts0ast.h
Generated on Sat Nov 9 2013 01:26:34 for MySQL 5.6.14 Source Code Document by
1.8.1.2