MySQL 9.1.0
Source Code Documentation
fts0ast.h File Reference

The FTS query parser (AST) abstract syntax tree routines. More...

#include "ha_prototypes.h"
#include "mem0mem.h"

Go to the source code of this file.

Classes

struct  fts_ast_string_t
 
struct  fts_ast_term_t
 
struct  fts_ast_text_t
 
struct  fts_ast_list_t
 
struct  fts_ast_node_t
 
struct  fts_ast_state_t
 

Typedefs

typedef dberr_t(* fts_ast_callback) (fts_ast_oper_t, fts_ast_node_t *, void *)
 

Enumerations

enum  fts_ast_type_t {
  FTS_AST_OPER , FTS_AST_NUMB , FTS_AST_TERM , FTS_AST_TEXT ,
  FTS_AST_PARSER_PHRASE_LIST , FTS_AST_LIST , FTS_AST_SUBEXP_LIST
}
 
enum  fts_ast_oper_t {
  FTS_NONE , FTS_IGNORE , FTS_EXIST , FTS_NEGATE ,
  FTS_INCR_RATING , FTS_DECR_RATING , FTS_DISTANCE , FTS_IGNORE_SKIP ,
  FTS_EXIST_SKIP
}
 

Functions

int fts_parse (fts_ast_state_t *state)
 in: ast state instance. More...
 
fts_ast_node_tfts_ast_create_node_oper (void *arg, fts_ast_oper_t oper)
 in: ast operator More...
 
fts_ast_node_tfts_ast_create_node_term (void *arg, const fts_ast_string_t *ptr)
 in: term string More...
 
fts_ast_node_tfts_ast_create_node_text (void *arg, const fts_ast_string_t *ptr)
 in: text string More...
 
fts_ast_node_tfts_ast_create_node_list (void *arg, fts_ast_node_t *expr)
 in: ast expr More...
 
fts_ast_node_tfts_ast_create_node_subexp_list (void *arg, fts_ast_node_t *expr)
 in: ast expr instance More...
 
void fts_ast_term_set_wildcard (fts_ast_node_t *node)
 in: term to change More...
 
void fts_ast_text_set_distance (fts_ast_node_t *node, ulint distance)
 in: the text proximity distance More...
 
fts_ast_node_tfts_ast_free_node (fts_ast_node_t *node)
 Free a fts_ast_node_t instance. More...
 
fts_ast_node_tfts_ast_add_node (fts_ast_node_t *list, fts_ast_node_t *node)
 in: (sub) expr to add More...
 
void fts_ast_node_print (fts_ast_node_t *node)
 in: ast node to print More...
 
void fts_ast_state_free (fts_ast_state_t *state)
 in: state instance to free More...
 
bool fts_ast_node_check_union (fts_ast_node_t *node)
 Check only union operation involved in the node. More...
 
dberr_t fts_ast_visit (fts_ast_oper_t oper, fts_ast_node_t *node, fts_ast_callback visitor, void *arg, bool *has_ignore)
 Traverse the AST - in-order traversal. More...
 
fts_lexer_tfts_lexer_create (bool boolean_mode, const byte *query, ulint query_len)
 
void fts_lexer_free (fts_lexer_t *fts_lexer)
 in: lexer instance to free More...
 
fts_ast_string_tfts_ast_string_create (const byte *str, ulint len)
 Create an ast string object, with NUL-terminator, so the string has one more byte than len. More...
 
void fts_ast_string_free (fts_ast_string_t *ast_str)
 Free an ast string instance. More...
 
ulint fts_ast_string_to_ul (const fts_ast_string_t *ast_str, int base)
 Translate ast string of type FTS_AST_NUMB to unsigned long by strtoul. More...
 
fts_ast_node_tfts_ast_create_node_term_for_parser (void *arg, const char *ptr, const ulint len)
 Create an AST term node, makes a copy of ptr for plugin parser. More...
 
fts_ast_node_tfts_ast_create_node_phrase_list (void *arg)
 Create an AST phrase list node for plugin parser. More...
 
const char * fts_ast_node_type_get (fts_ast_type_t type)
 

Detailed Description

The FTS query parser (AST) abstract syntax tree routines.

Created 2007/03/16/03 Sunny Bains

Typedef Documentation

◆ fts_ast_callback

typedef dberr_t(* fts_ast_callback) (fts_ast_oper_t, fts_ast_node_t *, void *)

Enumeration Type Documentation

◆ fts_ast_oper_t

Enumerator
FTS_NONE 

No operator.

FTS_IGNORE 

Ignore rows that contain this word.

FTS_EXIST 

Include rows that contain this word.

FTS_NEGATE 

Include rows that contain this word but rank them lower.

FTS_INCR_RATING 

Increase the rank for this word.

FTS_DECR_RATING 

Decrease the rank for this word.

FTS_DISTANCE 

Proximity distance.

FTS_IGNORE_SKIP 

Transient node operator signifies that this is a FTS_IGNORE node, and ignored in the first pass of fts_ast_visit()

FTS_EXIST_SKIP 

Transient node operator signifies that this ia a FTS_EXIST node, and ignored in the first pass of fts_ast_visit()

◆ fts_ast_type_t

Enumerator
FTS_AST_OPER 

Operator.

FTS_AST_NUMB 

Number.

FTS_AST_TERM 

Term (or word)

FTS_AST_TEXT 

Text string.

FTS_AST_PARSER_PHRASE_LIST 

Phase for plugin parser The difference from text type is that we tokenize text into term list.

FTS_AST_LIST 

Expression list.

FTS_AST_SUBEXP_LIST 

Sub-Expression list.

Function Documentation

◆ fts_ast_add_node()

fts_ast_node_t * fts_ast_add_node ( fts_ast_node_t node,
fts_ast_node_t elem 
)

in: (sub) expr to add

in: (sub) expr to add

Returns
in param "list"
Parameters
nodein: list instance
elemin: node to add to list

◆ fts_ast_create_node_list()

fts_ast_node_t * fts_ast_create_node_list ( void *  arg,
fts_ast_node_t expr 
)

in: ast expr

in: ast expr

Returns
new node
Parameters
argin: ast state instance
exprin: ast expr instance

◆ fts_ast_create_node_oper()

fts_ast_node_t * fts_ast_create_node_oper ( void *  arg,
fts_ast_oper_t  oper 
)

in: ast operator

in: ast operator

Returns
new node
Parameters
argin: ast state instance
operin: ast operator

◆ fts_ast_create_node_phrase_list()

fts_ast_node_t * fts_ast_create_node_phrase_list ( void *  arg)

Create an AST phrase list node for plugin parser.

Returns
node in: ast state
node
Parameters
argin: ast state

◆ fts_ast_create_node_subexp_list()

fts_ast_node_t * fts_ast_create_node_subexp_list ( void *  arg,
fts_ast_node_t expr 
)

in: ast expr instance

in: ast expr instance

This function takes ownership of expr and is responsible for deleting it.

Returns
new node
Parameters
argin: ast state instance
exprin: ast expr instance

◆ fts_ast_create_node_term()

fts_ast_node_t * fts_ast_create_node_term ( void *  arg,
const fts_ast_string_t ptr 
)

in: term string

in: term string

Returns
new node or a node list with tokenized words
Parameters
argin: ast state instance
ptrin: ast term string

◆ fts_ast_create_node_term_for_parser()

fts_ast_node_t * fts_ast_create_node_term_for_parser ( void *  arg,
const char *  ptr,
const ulint  len 
)

Create an AST term node, makes a copy of ptr for plugin parser.

Returns
node in: term string length
node
Parameters
argin: ast state
ptrin: term string
lenin: term string length

◆ fts_ast_create_node_text()

fts_ast_node_t * fts_ast_create_node_text ( void *  arg,
const fts_ast_string_t ptr 
)

in: text string

in: text string

Returns
new node

< We ignore the actual quotes ""

< Skip copying the first quote

Parameters
argin: ast state instance
ptrin: ast text string

◆ fts_ast_free_node()

fts_ast_node_t * fts_ast_free_node ( fts_ast_node_t node)

Free a fts_ast_node_t instance.

Returns
next node to free in: node to free
next node to free
Parameters
nodein: the node to free

◆ fts_ast_node_check_union()

bool fts_ast_node_check_union ( fts_ast_node_t node)

Check only union operation involved in the node.

Parameters
[in]nodeast node to check
Returns
true if the node contains only union else false.

◆ fts_ast_node_print()

void fts_ast_node_print ( fts_ast_node_t node)

in: ast node to print

in: ast node to print

Parameters
nodein: ast node to print

◆ fts_ast_node_type_get()

const char * fts_ast_node_type_get ( fts_ast_type_t  type)

◆ fts_ast_state_free()

void fts_ast_state_free ( fts_ast_state_t state)

in: state instance to free

in: state instance to free

Parameters
statein: ast state to free

◆ fts_ast_string_create()

fts_ast_string_t * fts_ast_string_create ( const byte str,
ulint  len 
)

Create an ast string object, with NUL-terminator, so the string has one more byte than len.

Parameters
[in]strpointer to string
[in]lenlength of the string
Returns
ast string with NUL-terminator

◆ fts_ast_string_free()

void fts_ast_string_free ( fts_ast_string_t ast_str)

Free an ast string instance.

Parameters
[in,out]ast_strstring to free

◆ fts_ast_string_to_ul()

ulint fts_ast_string_to_ul ( const fts_ast_string_t ast_str,
int  base 
)

Translate ast string of type FTS_AST_NUMB to unsigned long by strtoul.

Parameters
[in]ast_strstring to translate
[in]basethe base
Returns
translated number

◆ fts_ast_term_set_wildcard()

void fts_ast_term_set_wildcard ( fts_ast_node_t node)

in: term to change

in: term to change

Parameters
nodein/out: set attribute of a term node

◆ fts_ast_text_set_distance()

void fts_ast_text_set_distance ( fts_ast_node_t node,
ulint  distance 
)

in: the text proximity distance

in: the text proximity distance

Parameters
nodein/out: text node
distancein: the text proximity distance

◆ fts_ast_visit()

dberr_t fts_ast_visit ( fts_ast_oper_t  oper,
fts_ast_node_t node,
fts_ast_callback  visitor,
void *  arg,
bool *  has_ignore 
)

Traverse the AST - in-order traversal.

Returns
DB_SUCCESS if all went well out: whether we encounter and ignored processing an operator, currently we only ignore FTS_IGNORE operator

Traverse the AST - in-order traversal.

Returns
DB_SUCCESS if all went well
Parameters
operin: current operator
nodein: current root node
visitorin: callback function
argin: arg for callback
has_ignoreout: true, if the operator was ignored during processing, currently we ignore FTS_EXIST and FTS_IGNORE operators

◆ fts_lexer_create()

fts_lexer_t * fts_lexer_create ( bool  boolean_mode,
const byte query,
ulint  query_len 
)
Parameters
boolean_modein: query type
queryin: query string
query_lenin: query string len

◆ fts_lexer_free()

void fts_lexer_free ( fts_lexer_t fts_lexer)

in: lexer instance to free

◆ fts_parse()

int fts_parse ( fts_ast_state_t state)

in: ast state instance.