MySQL 8.0.39
Source Code Documentation
anonymous_namespace{sql_rewrite.cc} Namespace Reference

Functions

void comma_maybe (String *str, bool *comma)
 Append a comma to given string if item wasn't the first to be added. More...
 
bool append_int (String *str, bool comma, const char *txt, size_t len, long val, int cond)
 Append a key/value pair to a string, with an optional preceding comma. More...
 
bool append_str (String *str, bool comma, const char *key, const char *val)
 Append a key/value pair to a string if the value is non-NULL, with an optional preceding comma. More...
 
void append_auth_id (const THD *thd, const LEX_USER *user, bool comma, String *str)
 Append the authorization id for the user. More...
 
void append_auth_id_identifier (const THD *thd, const LEX_USER *user, bool comma, String *str)
 Append the authorization id for the user. More...
 
int lex_user_comp (LEX_USER *l1, LEX_USER *l2)
 Used with List<>::sort for alphabetic sorting of LEX_USER records using user,host as keys. More...
 
bool rewrite_query (THD *thd, Consumer_type type, const Rewrite_params *params, String &rlb)
 Util method which does the real rewrite of the SQL statement. More...
 

Function Documentation

◆ append_auth_id()

void anonymous_namespace{sql_rewrite.cc}::append_auth_id ( const THD thd,
const LEX_USER user,
bool  comma,
String str 
)

Append the authorization id for the user.

Parameters
[in]thdThe THD to find the SQL mode
[in]userLEX User to retrieve the plugin string
[in]commaSeparator to be prefixed before adding user info
[in,out]strThe string in which authID is suffixed

◆ append_auth_id_identifier()

void anonymous_namespace{sql_rewrite.cc}::append_auth_id_identifier ( const THD thd,
const LEX_USER user,
bool  comma,
String str 
)

Append the authorization id for the user.

This quotes auth_id with ` or " based on the sql_mode set.

Parameters
[in]thdThe THD to find the SQL mode
[in]userLEX User to retrieve the plugin string
[in]commaSeparator to be prefixed before adding user info
[in,out]strThe string in which authID is suffixed

◆ append_int()

bool anonymous_namespace{sql_rewrite.cc}::append_int ( String str,
bool  comma,
const char *  txt,
size_t  len,
long  val,
int  cond 
)

Append a key/value pair to a string, with an optional preceding comma.

For numeric values.

Parameters
[in,out]strThe string to append to
commaPrepend a comma?
txtC-string, must end in a space
lenstrlen(txt)
valnumeric value
condonly append if this evaluates to true
Return values
falseif any subsequent key/value pair would be the first

◆ append_str()

bool anonymous_namespace{sql_rewrite.cc}::append_str ( String str,
bool  comma,
const char *  key,
const char *  val 
)

Append a key/value pair to a string if the value is non-NULL, with an optional preceding comma.

Parameters
[in,out]strThe string to append to
commaPrepend a comma?
keyC-string: the key, must be non-NULL
valC-string: the value
Return values
falseif any subsequent key/value pair would be the first

◆ comma_maybe()

void anonymous_namespace{sql_rewrite.cc}::comma_maybe ( String str,
bool *  comma 
)

Append a comma to given string if item wasn't the first to be added.

Parameters
[in,out]strThe string to (maybe) append to.
[in,out]commaIf true, there are already items in the list. Always true afterwards.

◆ lex_user_comp()

int anonymous_namespace{sql_rewrite.cc}::lex_user_comp ( LEX_USER l1,
LEX_USER l2 
)

Used with List<>::sort for alphabetic sorting of LEX_USER records using user,host as keys.

Parameters
l1A LEX_USER element
l2A LEX_USER element
Return values
1if n1 > n2
0if n1 <= n2

◆ rewrite_query()

bool anonymous_namespace{sql_rewrite.cc}::rewrite_query ( THD thd,
Consumer_type  type,
const Rewrite_params params,
String rlb 
)

Util method which does the real rewrite of the SQL statement.

If a Rewriter is available for the specified SQL command then the rewritten query will be stored in the String rlb; otherwise, the string will just be cleared.

Parameters
thdThe THD to rewrite for.
typePurpose of rewriting the query
paramsWrapper object of parameters in case needed by a SQL rewriter.
[in,out]rlbBuffer to return the rewritten query in. Will be empty if no rewriting happened.
Return values
trueIf the Query is re-written.
falseOtherwise