MySQL 8.0.39
Source Code Documentation
service_parser.h File Reference

Plugin service that provides access to the parser and some operations on the parse tree. More...

#include <mysql/mysql_lex_string.h>
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  mysql_parser_service_st
 

Macros

#define MYSQL_THD   THD *
 
#define PARSER_SERVICE_DIGEST_LENGTH   32
 
#define STATEMENT_TYPE_SELECT   1
 
#define STATEMENT_TYPE_UPDATE   2
 
#define STATEMENT_TYPE_INSERT   3
 
#define STATEMENT_TYPE_DELETE   4
 
#define STATEMENT_TYPE_REPLACE   5
 
#define STATEMENT_TYPE_OTHER   6
 

Typedefs

typedef ItemMYSQL_ITEM
 
typedef int(* parse_node_visit_function) (MYSQL_ITEM item, unsigned char *arg)
 
typedef int(* sql_condition_handler_function) (int sql_errno, const char *sqlstate, const char *msg, void *state)
 
typedef MYSQL_THD(* mysql_current_session_t) ()
 
typedef MYSQL_THD(* mysql_open_session_t) ()
 
typedef void(* mysql_start_thread_t) (MYSQL_THD thd, void *(*callback_fun) (void *), void *arg, struct my_thread_handle *thread_handle)
 
typedef void(* mysql_join_thread_t) (struct my_thread_handle *thread_handle)
 
typedef void(* mysql_set_current_database_t) (MYSQL_THD thd, const MYSQL_LEX_STRING db)
 
typedef int(* mysql_parse_t) (MYSQL_THD thd, const MYSQL_LEX_STRING query, unsigned char is_prepared, sql_condition_handler_function handle_condition, void *condition_handler_state)
 Parses the query. More...
 
typedef int(* mysql_get_statement_type_t) (MYSQL_THD thd)
 
typedef int(* mysql_get_statement_digest_t) (MYSQL_THD thd, unsigned char *digest)
 Returns the digest of the last parsed statement in the session. More...
 
typedef int(* mysql_get_number_params_t) (MYSQL_THD thd)
 Returns the number of parameters ('?') in the parsed query. More...
 
typedef int(* mysql_extract_prepared_params_t) (MYSQL_THD thd, int *positions)
 Stores in 'positions' the positions in the last parsed query of each parameter marker('?'). More...
 
typedef int(* mysql_visit_tree_t) (MYSQL_THD thd, parse_node_visit_function processor, unsigned char *arg)
 Walks the tree depth first and applies a user defined function on each literal. More...
 
typedef MYSQL_LEX_STRING(* mysql_item_string_t) (MYSQL_ITEM item)
 Renders the MYSQL_ITEM as a string and returns a reference in the form of a MYSQL_LEX_STRING. More...
 
typedef void(* mysql_free_string_t) (MYSQL_LEX_STRING string)
 Frees a string buffer allocated by the server. More...
 
typedef MYSQL_LEX_STRING(* mysql_get_query_t) (MYSQL_THD thd)
 Returns the current query string. More...
 
typedef MYSQL_LEX_STRING(* mysql_get_normalized_query_t) (MYSQL_THD thd)
 Returns the current query in normalized form. More...
 
typedef void *(* callback_function) (void *)
 

Functions

MYSQL_THD mysql_parser_current_session ()
 
MYSQL_THD mysql_parser_open_session ()
 
void mysql_parser_start_thread (MYSQL_THD thd, callback_function fun, void *arg, struct my_thread_handle *thread_handle)
 
void mysql_parser_join_thread (struct my_thread_handle *thread_handle)
 
void mysql_parser_set_current_database (MYSQL_THD thd, const MYSQL_LEX_STRING db)
 
int mysql_parser_parse (MYSQL_THD thd, const MYSQL_LEX_STRING query, unsigned char is_prepared, sql_condition_handler_function handle_condition, void *condition_handler_state)
 
int mysql_parser_get_statement_type (MYSQL_THD thd)
 
int mysql_parser_get_statement_digest (MYSQL_THD thd, unsigned char *digest)
 
int mysql_parser_get_number_params (MYSQL_THD thd)
 
int mysql_parser_extract_prepared_params (MYSQL_THD thd, int *positions)
 
int mysql_parser_visit_tree (MYSQL_THD thd, parse_node_visit_function processor, unsigned char *arg)
 
MYSQL_LEX_STRING mysql_parser_item_string (MYSQL_ITEM item)
 
void mysql_parser_free_string (MYSQL_LEX_STRING string)
 
MYSQL_LEX_STRING mysql_parser_get_query (MYSQL_THD thd)
 
MYSQL_LEX_STRING mysql_parser_get_normalized_query (MYSQL_THD thd)
 

Variables

struct mysql_parser_service_stmysql_parser_service
 

Detailed Description

Plugin service that provides access to the parser and some operations on the parse tree.

Macro Definition Documentation

◆ MYSQL_THD

#define MYSQL_THD   THD *

◆ PARSER_SERVICE_DIGEST_LENGTH

#define PARSER_SERVICE_DIGEST_LENGTH   32

◆ STATEMENT_TYPE_DELETE

#define STATEMENT_TYPE_DELETE   4

◆ STATEMENT_TYPE_INSERT

#define STATEMENT_TYPE_INSERT   3

◆ STATEMENT_TYPE_OTHER

#define STATEMENT_TYPE_OTHER   6

◆ STATEMENT_TYPE_REPLACE

#define STATEMENT_TYPE_REPLACE   5

◆ STATEMENT_TYPE_SELECT

#define STATEMENT_TYPE_SELECT   1

◆ STATEMENT_TYPE_UPDATE

#define STATEMENT_TYPE_UPDATE   2

Typedef Documentation

◆ callback_function

typedef void *(* callback_function) (void *)

◆ mysql_current_session_t

typedef MYSQL_THD(* mysql_current_session_t) ()

◆ mysql_extract_prepared_params_t

typedef int(* mysql_extract_prepared_params_t) (MYSQL_THD thd, int *positions)

Stores in 'positions' the positions in the last parsed query of each parameter marker('?').

Positions must be an already allocated array of at least mysql_parser_service_st::mysql_get_number_params() size. This works only if the last query was parsed as a prepared statement.

Parameters
thdThe session in which the query was parsed.
positionsAn already allocated array of at least mysql_parser_service_st::mysql_get_number_params() size.
Returns
The number of parameter markers and hence number of written positions.

◆ mysql_free_string_t

typedef void(* mysql_free_string_t) (MYSQL_LEX_STRING string)

Frees a string buffer allocated by the server.

Parameters
stringThe string whose buffer will be freed.

◆ mysql_get_normalized_query_t

typedef MYSQL_LEX_STRING(* mysql_get_normalized_query_t) (MYSQL_THD thd)

Returns the current query in normalized form.

This string is managed by the server and should not be freed by a plugin.

Parameters
thdThe session in which the query was submitted.
Returns
The query string normalized.

◆ mysql_get_number_params_t

typedef int(* mysql_get_number_params_t) (MYSQL_THD thd)

Returns the number of parameters ('?') in the parsed query.

This works only if the last query was parsed as a prepared statement.

Parameters
thdThe session in which the query was parsed.
Returns
The number of parameter markers.

◆ mysql_get_query_t

typedef MYSQL_LEX_STRING(* mysql_get_query_t) (MYSQL_THD thd)

Returns the current query string.

This string is managed by the server and should not be freed by a plugin.

Parameters
thdThe session in which the query was submitted.
Returns
The query string.

◆ mysql_get_statement_digest_t

typedef int(* mysql_get_statement_digest_t) (MYSQL_THD thd, unsigned char *digest)

Returns the digest of the last parsed statement in the session.

Parameters
thdThe session in which the statement was parsed.
[out]digestAn area of at least size PARSER_SERVICE_DIGEST_LENGTH, where the digest is written.
Return values
0Success.
1Parse error.

◆ mysql_get_statement_type_t

typedef int(* mysql_get_statement_type_t) (MYSQL_THD thd)

◆ MYSQL_ITEM

typedef Item* MYSQL_ITEM

◆ mysql_item_string_t

typedef MYSQL_LEX_STRING(* mysql_item_string_t) (MYSQL_ITEM item)

Renders the MYSQL_ITEM as a string and returns a reference in the form of a MYSQL_LEX_STRING.

The string buffer is allocated by the server and must be freed by mysql_free_string().

Parameters
itemThe literal to print.
Returns
The result of printing the literal.
See also
mysql_parser_service_st::mysql_free_string().

◆ mysql_join_thread_t

typedef void(* mysql_join_thread_t) (struct my_thread_handle *thread_handle)

◆ mysql_open_session_t

typedef MYSQL_THD(* mysql_open_session_t) ()

◆ mysql_parse_t

typedef int(* mysql_parse_t) (MYSQL_THD thd, const MYSQL_LEX_STRING query, unsigned char is_prepared, sql_condition_handler_function handle_condition, void *condition_handler_state)

Parses the query.

Parameters
thdThe session in which to parse.
queryThe query to parse.
is_preparedIf non-zero, the query will be parsed as a prepared statement and won't throw errors when the query string contains '?'.
handle_conditionCallback function that is called if a condition is raised during the preparation, parsing or cleanup after parsing. If this argument is non-NULL, the diagnostics area will be cleared before this function returns.
condition_handler_stateWill be passed to handle_condition when called. Otherwise ignored.
Return values
0Success.
1Parse error.

◆ mysql_set_current_database_t

typedef void(* mysql_set_current_database_t) (MYSQL_THD thd, const MYSQL_LEX_STRING db)

◆ mysql_start_thread_t

typedef void(* mysql_start_thread_t) (MYSQL_THD thd, void *(*callback_fun)(void *), void *arg, struct my_thread_handle *thread_handle)

◆ mysql_visit_tree_t

typedef int(* mysql_visit_tree_t) (MYSQL_THD thd, parse_node_visit_function processor, unsigned char *arg)

Walks the tree depth first and applies a user defined function on each literal.

Parameters
thdThe session in which the query was parsed.
processorWill be called for each literal in the parse tree.
argWill be passed as argument to each call to 'processor'.

◆ parse_node_visit_function

typedef int(* parse_node_visit_function) (MYSQL_ITEM item, unsigned char *arg)

◆ sql_condition_handler_function

typedef int(* sql_condition_handler_function) (int sql_errno, const char *sqlstate, const char *msg, void *state)

Function Documentation

◆ mysql_parser_current_session()

MYSQL_THD mysql_parser_current_session ( )

◆ mysql_parser_extract_prepared_params()

int mysql_parser_extract_prepared_params ( MYSQL_THD  thd,
int *  positions 
)

◆ mysql_parser_free_string()

void mysql_parser_free_string ( MYSQL_LEX_STRING  string)

◆ mysql_parser_get_normalized_query()

MYSQL_LEX_STRING mysql_parser_get_normalized_query ( MYSQL_THD  thd)

◆ mysql_parser_get_number_params()

int mysql_parser_get_number_params ( MYSQL_THD  thd)

◆ mysql_parser_get_query()

MYSQL_LEX_STRING mysql_parser_get_query ( MYSQL_THD  thd)

◆ mysql_parser_get_statement_digest()

int mysql_parser_get_statement_digest ( MYSQL_THD  thd,
unsigned char *  digest 
)

◆ mysql_parser_get_statement_type()

int mysql_parser_get_statement_type ( MYSQL_THD  thd)

◆ mysql_parser_item_string()

MYSQL_LEX_STRING mysql_parser_item_string ( MYSQL_ITEM  item)

◆ mysql_parser_join_thread()

void mysql_parser_join_thread ( struct my_thread_handle thread_handle)

◆ mysql_parser_open_session()

MYSQL_THD mysql_parser_open_session ( )

◆ mysql_parser_parse()

int mysql_parser_parse ( MYSQL_THD  thd,
const MYSQL_LEX_STRING  query,
unsigned char  is_prepared,
sql_condition_handler_function  handle_condition,
void *  condition_handler_state 
)

◆ mysql_parser_set_current_database()

void mysql_parser_set_current_database ( MYSQL_THD  thd,
const MYSQL_LEX_STRING  db 
)

◆ mysql_parser_start_thread()

void mysql_parser_start_thread ( MYSQL_THD  thd,
callback_function  fun,
void *  arg,
struct my_thread_handle thread_handle 
)

◆ mysql_parser_visit_tree()

int mysql_parser_visit_tree ( MYSQL_THD  thd,
parse_node_visit_function  processor,
unsigned char *  arg 
)

Variable Documentation

◆ mysql_parser_service

struct mysql_parser_service_st * mysql_parser_service