MySQL 5.6.14 Source Code Document
 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 */
40 };
41 
42 /* The FTS query operators that we support */
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
95 /*=====================*/
96  void* arg,
97  fts_ast_oper_t oper);
98 /********************************************************************
99 Create an AST term node, makes a copy of ptr */
100 extern
103 /*=====================*/
104  void* arg,
105  const char* ptr);
106 /********************************************************************
107 Create an AST text node */
108 extern
111 /*=====================*/
112  void* arg,
113  const char* ptr);
114 /********************************************************************
115 Create an AST expr list node */
116 extern
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
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
137 /*======================*/
138  fts_ast_node_t* node);
139 /********************************************************************
140 Set the proximity attribute of a text node. */
141 
142 void
144 /*======================*/
145  fts_ast_node_t* node,
146  ulint distance);
148 /********************************************************************/
151 UNIV_INTERN
154 /*==============*/
155  fts_ast_node_t* node);
156 /********************************************************************
157 Add a sub-expression to an AST*/
158 extern
161 /*=============*/
163  fts_ast_node_t* node);
164 /********************************************************************
165 Print the AST node recursively.*/
166 extern
167 void
169 /*===============*/
170  fts_ast_node_t* node);
171 /********************************************************************
172 For tracking node allocations, in case there is an during parsing.*/
173 extern
174 void
176 /*===================*/
177  fts_ast_state_t*state,
178  fts_ast_node_t* node);
179 /********************************************************************
180 Free node and expr allocations.*/
181 extern
182 void
184 /*===============*/
185  fts_ast_state_t*state);
187 /******************************************************************/
190 UNIV_INTERN
191 dberr_t
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
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
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
231 /*===========*/
232  fts_lexer_t* fts_lexer)
234  __attribute__((nonnull));
235 
236 /* Query term type */
238  byte* ptr;
239  ibool wildcard;
240 };
241 
242 /* Query text type */
244  byte* ptr;
245  ulint distance;
247 };
248 
249 /* The list of nodes in an expr list */
253 };
254 
255 /* FTS AST node to store the term, text, operator and sub-expressions.*/
264  bool visited;
266 };
267 
268 /* To track state during parsing */
279 };
280 
281 #endif /* INNOBASE_FSTS0AST_H */