MySQL 9.1.0
Source Code Documentation
sql_rewrite.h File Reference
#include <set>
#include "my_sqlcommand.h"
#include "sql/table.h"

Go to the source code of this file.

Classes

class  Rewrite_params
 An interface to wrap the parameters required by specific Rewriter. More...
 
class  User_params
 Wrapper object for user related parameters required by: SET PASSWORD|CREATE USER|ALTER USER statements. More...
 
class  Show_user_params
 Wrapper object for parameters required by SHOW CREATE USER statement. More...
 
class  Grant_params
 Wrapper object for parameters required for GRANT statement. More...
 
class  I_rewriter
 An abstract base class to enable the implementation of various query rewriters. More...
 
class  Rewriter_user
 Abstract base class to define the skeleton of rewriting the users, yet deferring some steps to the concrete classes. More...
 
class  Rewriter_create_user
 Rewrites the CREATE USER statement. More...
 
class  Rewriter_alter_user
 Rewrites the ALTER USER statement. More...
 
class  Rewriter_show_create_user
 Rewrites the SHOW CREATE USER statement. More...
 
class  Rewriter_set
 Rewrites the SET statement. More...
 
class  Rewriter_set_password
 
class  Rewriter_grant
 Rewrites the GRANT statement. More...
 
class  Rewriter_change_replication_source
 Rewrites the CHANGE REPLICATION SOURCE statement. More...
 
class  Rewriter_replica_start
 Rewrites the START REPLICA statement. More...
 
class  Rewriter_server_option
 Base class for SERVER OPTIONS related statement. More...
 
class  Rewriter_create_server
 Rewrites the CREATE SERVER statement. More...
 
class  Rewriter_alter_server
 Rewrites the ALTER SERVER statement. More...
 
class  Rewriter_prepare
 Rewrites the PREPARE statement. More...
 
class  Rewriter_clone
 Rewrites CLONE statement. More...
 
class  Rewriter_start_group_replication
 Rewrites the START GROUP_REPLICATION command. More...
 

Enumerations

enum class  Consumer_type { TEXTLOG , BINLOG , STDOUT }
 Target types where the rewritten query will be added. More...
 

Functions

void mysql_rewrite_query (THD *thd, Consumer_type type=Consumer_type::TEXTLOG, const Rewrite_params *params=nullptr)
 Provides the default interface to rewrite the SQL statements to to obfuscate passwords. More...
 
void mysql_rewrite_acl_query (THD *thd, String &rlb, Consumer_type type, const Rewrite_params *params=nullptr, bool do_ps_instrument=true)
 Provides the default interface to rewrite the ACL query. More...
 

Enumeration Type Documentation

◆ Consumer_type

enum class Consumer_type
strong

Target types where the rewritten query will be added.

Query rewrite might vary based on this type.

Enumerator
TEXTLOG 
BINLOG 
STDOUT 

Function Documentation

◆ mysql_rewrite_acl_query()

void mysql_rewrite_acl_query ( THD thd,
String rlb,
Consumer_type  type,
const Rewrite_params params,
bool  do_ps_instrument 
)

Provides the default interface to rewrite the ACL query.

If do_ps_instrument, it sets the thd->rewritten_query with a rewritten query.

Parameters
thdThe THD to rewrite for.
rlbBuffer to return rewritten query in (if any) if do_ps_instrument is false.
typePurpose of rewriting the query Consumer_type::TEXTLOG To rewrite the query either for general, slow query and audit log. Consumer_type::BINLOG To rewrite the query for binlogs. Consumer_type::STDOUT To rewrite the query for standard output.
paramsWrapper object of parameters in case needed by a SQL rewriter.
do_ps_instrumentflag to indicate if the query has to be instrumented in the PSI. Default value is true. If instrumented, the previous

◆ mysql_rewrite_query()

void mysql_rewrite_query ( THD thd,
Consumer_type  type,
const Rewrite_params params 
)

Provides the default interface to rewrite the SQL statements to to obfuscate passwords.

It either sets the thd->rewritten_query with a rewritten query, or clears it if no rewriting took place.

The query aimed to be rewritten in the usual log files (i.e. General, slow query and audit log) uses default value of type which is Consumer_type::TEXTLOG

Side-effects:

  • thd->m_rewritten_query will contain a rewritten query, or be cleared if no rewriting took place. LOCK_thd_query will be temporarily acquired to make that change.
Note
Keep in mind that these side-effects will only happen when calling this top-level function, but not when calling individual sub-functions directly!
Parameters
thdThe THD to rewrite for.
typePurpose of rewriting the query Consumer_type::TEXTLOG To rewrite the query either for general, slow query and audit log. Consumer_type::BINLOG To rewrite the query for binlogs. Consumer_type::STDOUT To rewrite the query for standard output.
paramsWrapper object of parameters in case needed by a SQL rewriter.