MySQL 9.1.0
Source Code Documentation
fts0sql.cc File Reference

Full Text Search functionality. More...

#include <sys/types.h>
#include "dict0dd.h"
#include "dict0dict.h"
#include "fts0priv.h"
#include "fts0types.h"
#include "pars0pars.h"
#include "que0que.h"
#include "trx0roll.h"
#include <algorithm>
#include <string>
#include "current_thd.h"

Functions

int fts_get_table_id (const fts_table_t *fts_table, char *table_id)
 Get the table id. More...
 
static char * fts_get_table_name_prefix_low (const fts_table_t *fts_table, bool is_5_7)
 Construct the prefix name of an FTS table. More...
 
char * fts_get_table_name_prefix (const fts_table_t *fts_table)
 Construct the prefix name of an FTS table. More...
 
char * fts_get_table_name_prefix_5_7 (const fts_table_t *fts_table)
 Construct the prefix name of an FTS table in 5.7 compatible name. More...
 
static void fts_get_table_name_low (const fts_table_t *fts_table, char *table_name, bool is_5_7)
 Construct the name of an ancillary FTS table for the given table. More...
 
void fts_get_table_name (const fts_table_t *fts_table, char *table_name)
 Construct the name of an ancillary FTS table for the given table. More...
 
void fts_get_table_name_5_7 (const fts_table_t *fts_table, char *table_name)
 Construct the name of an ancillary FTS table for the given table in 5.7 compatible format. More...
 
que_tfts_parse_sql (fts_table_t *fts_table, pars_info_t *info, const char *sql)
 Parse an SQL string. More...
 
dberr_t fts_eval_sql (trx_t *trx, que_t *graph)
 Evaluate an SQL query graph. More...
 
const char * fts_get_select_columns_str (dict_index_t *index, pars_info_t *info, mem_heap_t *heap)
 Construct the column specification part of the SQL string for selecting the indexed FTS columns for the given table. More...
 
dberr_t fts_sql_commit (trx_t *trx)
 Commit a transaction. More...
 
dberr_t fts_sql_rollback (trx_t *trx)
 Rollback a transaction. More...
 

Variables

static const char * fts_sql_begin = "PROCEDURE P() IS\n"
 SQL statements for creating the ancillary FTS tables. More...
 
static const char * fts_sql_end
 Postamble to non-committing SQL statements. More...
 

Detailed Description

Full Text Search functionality.

Created 2007-03-27 Sunny Bains

Function Documentation

◆ fts_eval_sql()

dberr_t fts_eval_sql ( trx_t trx,
que_t graph 
)

Evaluate an SQL query graph.

Evaluate a parsed SQL statement.

Returns
DB_SUCCESS or error code
Parameters
trxin: transaction
graphin: Query graph to evaluate

◆ fts_get_select_columns_str()

const char * fts_get_select_columns_str ( dict_index_t index,
pars_info_t info,
mem_heap_t heap 
)

Construct the column specification part of the SQL string for selecting the indexed FTS columns for the given table.

Adds the necessary bound ids to the given 'info' and returns the SQL string. Examples:

One indexed column named "text":

"$sel0", info/ids: sel0 -> "text"

Two indexed columns named "subject" and "content":

"$sel0, $sel1", info/ids: sel0 -> "subject", sel1 -> "content",

Returns
heap-allocated WHERE string
Parameters
indexin: index
infoin/out: parser info
heapin: memory heap

◆ fts_get_table_id()

int fts_get_table_id ( const fts_table_t fts_table,
char *  table_id 
)

Get the table id.

Returns
number of bytes written
Parameters
fts_tablein: FTS Auxiliary table
table_idout: table id, must be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long

◆ fts_get_table_name()

void fts_get_table_name ( const fts_table_t fts_table,
char *  table_name 
)

Construct the name of an ancillary FTS table for the given table.

Caller must allocate enough memory(usually size of MAX_FULL_NAME_LEN) for param 'table_name'.

Parameters
fts_tablein: Auxiliary table type
table_namein/out: aux table name

◆ fts_get_table_name_5_7()

void fts_get_table_name_5_7 ( const fts_table_t fts_table,
char *  table_name 
)

Construct the name of an ancillary FTS table for the given table in 5.7 compatible format.

Caller must allocate enough memory(usually size of MAX_FULL_NAME_LEN) for param 'table_name'

Parameters
[in]fts_tableAuxiliary table object
[in,out]table_nameaux table name

◆ fts_get_table_name_low()

static void fts_get_table_name_low ( const fts_table_t fts_table,
char *  table_name,
bool  is_5_7 
)
static

Construct the name of an ancillary FTS table for the given table.

Caller must allocate enough memory(usually size of MAX_FULL_NAME_LEN) for param 'table_name'

Parameters
[in]fts_tableFTS Aux table
[in,out]table_nameaux table name
[in]is_5_7true if we need 5.7 compatible name

◆ fts_get_table_name_prefix()

char * fts_get_table_name_prefix ( const fts_table_t fts_table)

Construct the prefix name of an FTS table.

Returns
own: table name, must be freed with ut::free()
Parameters
fts_tablein: Auxiliary table type

◆ fts_get_table_name_prefix_5_7()

char * fts_get_table_name_prefix_5_7 ( const fts_table_t fts_table)

Construct the prefix name of an FTS table in 5.7 compatible name.

Parameters
[in]fts_tableAuxiliary FTS table
Returns
own: table name, must be freed with ut::free()

◆ fts_get_table_name_prefix_low()

static char * fts_get_table_name_prefix_low ( const fts_table_t fts_table,
bool  is_5_7 
)
static

Construct the prefix name of an FTS table.

Parameters
[in]fts_tableAuxiliary FTS table
[in]is_5_7true if we need 5.7 compatible name
Returns
own: table name, must be freed with ut::free()

◆ fts_parse_sql()

que_t * fts_parse_sql ( fts_table_t fts_table,
pars_info_t info,
const char *  sql 
)

Parse an SQL string.

Returns
query graph
Parameters
fts_tablein: FTS auxiliarry table info
infoin: info struct, or NULL
sqlin: SQL string to evaluate

◆ fts_sql_commit()

dberr_t fts_sql_commit ( trx_t trx)

Commit a transaction.

Returns
DB_SUCCESS or error code
Parameters
trxin: transaction

◆ fts_sql_rollback()

dberr_t fts_sql_rollback ( trx_t trx)

Rollback a transaction.

Returns
DB_SUCCESS or error code
Parameters
trxin: transaction

Variable Documentation

◆ fts_sql_begin

const char* fts_sql_begin = "PROCEDURE P() IS\n"
static

SQL statements for creating the ancillary FTS tables.

Preamble to all SQL statements.

◆ fts_sql_end

const char* fts_sql_end
static
Initial value:
=
"\n"
"END;\n"

Postamble to non-committing SQL statements.