MySQL 9.1.0
Source Code Documentation
fts0ast.cc File Reference

Full Text Search parser helper file. More...

#include <stdlib.h>
#include "row0sel.h"
#include "fts0ast.h"
#include "fts0fts.h"
#include "fts0pars.h"
#include "ha_prototypes.h"

Enumerations

enum  fts_ast_visit_pass_t { FTS_PASS_FIRST , FTS_PASS_EXIST , FTS_PASS_IGNORE }
 

Functions

static fts_ast_node_tfts_ast_node_create (void)
 Create an empty fts_ast_node_t. More...
 
static void fts_ast_state_add_node (fts_ast_state_t *state, fts_ast_node_t *node)
 Track node allocations, in case there is an error during parsing. More...
 
fts_ast_node_tfts_ast_create_node_oper (void *arg, fts_ast_oper_t oper)
 Create a operator fts_ast_node_t. More...
 
fts_ast_node_tfts_ast_create_node_term (void *arg, const fts_ast_string_t *ptr)
 This function takes ownership of the ptr and is responsible for free'ing it. 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_text (void *arg, const fts_ast_string_t *ptr)
 This function takes ownership of the ptr and is responsible for free'ing it. More...
 
fts_ast_node_tfts_ast_create_node_phrase_list (void *arg)
 Create an AST phrase list node for plugin parser. More...
 
fts_ast_node_tfts_ast_create_node_list (void *arg, fts_ast_node_t *expr)
 This function takes ownership of the expr and is responsible for free'ing it. More...
 
fts_ast_node_tfts_ast_create_node_subexp_list (void *arg, fts_ast_node_t *expr)
 Create a sub-expression list node. More...
 
static void fts_ast_free_list (fts_ast_node_t *node)
 Free an expr list node elements. 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 *node, fts_ast_node_t *elem)
 This AST takes ownership of the expr and is responsible for free'ing it. More...
 
void fts_ast_term_set_wildcard (fts_ast_node_t *node)
 Set the wildcard attribute of a term. More...
 
void fts_ast_text_set_distance (fts_ast_node_t *node, ulint distance)
 Set the proximity attribute of a text node. More...
 
void fts_ast_state_free (fts_ast_state_t *state)
 Free node and expr allocations. More...
 
static void fts_ast_string_print (const fts_ast_string_t *ast_str)
 Print the ast string. More...
 
static void fts_ast_node_print_recursive (fts_ast_node_t *node, ulint level)
 Print an ast node recursively. More...
 
void fts_ast_node_print (fts_ast_node_t *node)
 Print an ast node. 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, except for the FTX_EXIST and FTS_IGNORE nodes, which will be ignored in the first pass of each level, and visited in a second and third pass after all other nodes in the same level are visited. 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...
 
const char * fts_ast_node_type_get (fts_ast_type_t type)
 

Detailed Description

Full Text Search parser helper file.

Created 2007/3/16 Sunny Bains.

Enumeration Type Documentation

◆ fts_ast_visit_pass_t

Enumerator
FTS_PASS_FIRST 

First visit pass, process operators excluding FTS_EXIST and FTS_IGNORE.

FTS_PASS_EXIST 

Exist visit pass, process operator FTS_EXIST.

FTS_PASS_IGNORE 

Ignore visit pass, process operator FTS_IGNORE.

Function Documentation

◆ fts_ast_add_node()

fts_ast_node_t * fts_ast_add_node ( fts_ast_node_t node,
fts_ast_node_t elem 
)

This AST takes ownership of the expr and is responsible for free'ing it.

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 
)

This function takes ownership of the expr and is responsible for free'ing it.

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 
)

Create a operator fts_ast_node_t.

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
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 
)

Create a sub-expression list node.

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 
)

This function takes ownership of the ptr and is responsible for free'ing it.

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
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 
)

This function takes ownership of the ptr and is responsible for free'ing it.

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_list()

static void fts_ast_free_list ( fts_ast_node_t node)
static

Free an expr list node elements.

< No op

Parameters
nodein: ast node to free

◆ 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
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_create()

static fts_ast_node_t * fts_ast_node_create ( void  )
static

Create an empty fts_ast_node_t.

Returns
Create a new node

◆ fts_ast_node_print()

void fts_ast_node_print ( fts_ast_node_t node)

Print an ast node.

in: ast node to print

Parameters
nodein: ast node to print

◆ fts_ast_node_print_recursive()

static void fts_ast_node_print_recursive ( fts_ast_node_t node,
ulint  level 
)
static

Print an ast node recursively.

Parameters
nodein: ast node to print
levelin: recursive level

◆ fts_ast_node_type_get()

const char * fts_ast_node_type_get ( fts_ast_type_t  type)

◆ fts_ast_state_add_node()

static void fts_ast_state_add_node ( fts_ast_state_t state,
fts_ast_node_t node 
)
static

Track node allocations, in case there is an error during parsing.

Parameters
statein: ast instance
nodein: node to add to ast

◆ fts_ast_state_free()

void fts_ast_state_free ( fts_ast_state_t state)

Free node and expr allocations.

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_print()

static void fts_ast_string_print ( const fts_ast_string_t ast_str)
static

Print the ast string.

Parameters
[in]ast_strstring to print

◆ 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)

Set the wildcard attribute of a term.

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 
)

Set the proximity attribute of a text node.

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, except for the FTX_EXIST and FTS_IGNORE nodes, which will be ignored in the first pass of each level, and visited in a second and third pass after all other nodes in the same level are visited.

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