24#ifndef SQL_REWRITE_INCLUDED
25#define SQL_REWRITE_INCLUDED
74 String *param_metadata_str)
112 bool do_ps_instrument =
true);
Wrapper object for parameters required for GRANT statement.
Definition: sql_rewrite.h:87
Grant_params(bool grant_as_specified, LEX_GRANT_AS *grant_as)
Definition: sql_rewrite.h:89
bool grant_as_provided
Definition: sql_rewrite.h:93
LEX_GRANT_AS * grant_as_info
Definition: sql_rewrite.h:94
An abstract base class to enable the implementation of various query rewriters.
Definition: sql_rewrite.h:127
Consumer_type consumer_type()
Return the current consumer type set in the object.
Definition: sql_rewrite.cc:481
const I_rewriter & operator=(const I_rewriter &&)=delete
I_rewriter(const I_rewriter &)=delete
virtual bool rewrite(String &rlb) const =0
Consumer_type m_consumer_type
Definition: sql_rewrite.h:146
I_rewriter(const I_rewriter &&)=delete
void set_consumer_type(Consumer_type type)
Reset the previous consumer type.
Definition: sql_rewrite.cc:473
const I_rewriter & operator=(const I_rewriter &)=delete
THD *const m_thd
Definition: sql_rewrite.h:145
I_rewriter(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:462
Definition: sql_lex.h:3907
An interface to wrap the parameters required by specific Rewriter.
Definition: sql_rewrite.h:52
virtual ~Rewrite_params()=default
Rewrites the ALTER SERVER statement.
Definition: sql_rewrite.h:330
Rewriter_alter_server(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1775
bool rewrite(String &rlb) const override
Rewrite the query for the ALTER SERVER statement.
Definition: sql_rewrite.cc:1786
Definition: sql_rewrite.h:396
Rewriter_alter_table(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:2072
bool rewrite(String &rlb) const override
Rewrite the alter table statement with the PAR id being redacted.
Definition: sql_rewrite.cc:2083
Rewrites the ALTER USER statement.
Definition: sql_rewrite.h:228
void rewrite_password_history(const LEX *lex, String *str) const override
Append the PASSWORD HISTORY clause for users iff it is specified.
Definition: sql_rewrite.cc:1074
void append_user_auth_info(LEX_USER *user, bool comma, String *str) const override
Append the authID, plugin and auth str of the user to output string :
Definition: sql_rewrite.cc:997
void rewrite_user_application_user_metadata(const LEX *lex, String *str) const override
Default implementation of the the rewriter for user applicatiton user metadata.
Definition: sql_rewrite.cc:550
void rewrite_password_reuse(const LEX *lex, String *str) const override
Append the PASSWORD REUSE clause for users iff it is specified.
Definition: sql_rewrite.cc:1086
Rewriter_alter_user(THD *thd, Consumer_type type=Consumer_type::TEXTLOG)
Definition: sql_rewrite.cc:967
bool rewrite(String &rlb) const override
Rewrite the query for the ALTER USER statement.
Definition: sql_rewrite.cc:977
Rewrites the CHANGE REPLICATION SOURCE statement.
Definition: sql_rewrite.h:300
bool rewrite(String &rlb) const override
Rewrite the query for the CHANGE REPLICATION SOURCE statement.
Definition: sql_rewrite.cc:1531
Rewriter_change_replication_source(THD *thd, Consumer_type)
Definition: sql_rewrite.cc:1519
Rewrites CLONE statement.
Definition: sql_rewrite.h:346
bool rewrite(String &rlb) const override
Rewrite the query for the CLONE statement to hide password.
Definition: sql_rewrite.cc:1833
Rewriter_clone(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1822
Rewriter for CREATE EXTERNAL TABLE statements in the binary log.
Definition: sql_rewrite.h:390
Rewriter_create_external_table(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1958
bool rewrite(String &rlb) const override
Rewrite CREATE EXTERNAL TABLE to CREATE TABLE with explicit ENGINE and SECONDARY_ENGINE for binary lo...
Definition: sql_rewrite.cc:1976
Rewrites the CREATE PROCEDURE or CREATE FUNCTION statement.
Definition: sql_rewrite.h:370
Rewriter_create_procedure(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1923
bool rewrite(String &rlb) const override
Rewrite the query for CREATE PROCEDURE or ROUTINES with the PAR id being redacted.
Definition: sql_rewrite.cc:1934
Rewrites the CREATE SERVER statement.
Definition: sql_rewrite.h:322
Rewriter_create_server(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1728
bool rewrite(String &rlb) const override
Rewrite the query for the CREATE SERVER statement.
Definition: sql_rewrite.cc:1757
Rewrites the CREATE TABLE statement for external tables.
Definition: sql_rewrite.h:377
Rewriter_create_table(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1941
bool rewrite(String &rlb) const override
Rewrite the create table statement with the PAR id being redacted.
Definition: sql_rewrite.cc:1951
Rewrites the CREATE USER statement.
Definition: sql_rewrite.h:212
void append_user_auth_info(LEX_USER *user, bool comma, String *str) const override
Append the authID, plugin and auth str of the user to output string :
Definition: sql_rewrite.cc:890
void rewrite_password_history(const LEX *lex, String *str) const override
Append the PASSWORD HISTORY clause for users iff it is specified.
Definition: sql_rewrite.cc:949
void rewrite_password_reuse(const LEX *lex, String *str) const override
Append the PASSWORD REUSE clause for users iff it is specified.
Definition: sql_rewrite.cc:961
void rewrite_user_application_user_metadata(const LEX *lex, String *str) const override
Default implementation of the the rewriter for user applicatiton user metadata.
Definition: sql_rewrite.cc:539
Rewriter_create_user(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:859
bool rewrite(String &rlb) const override
Rewrite the query for the CREATE USER statement.
Definition: sql_rewrite.cc:869
Rewrites the GRANT statement.
Definition: sql_rewrite.h:289
bool rewrite(String &rlb) const override
Rewrite the query for the GRANT statement.
Definition: sql_rewrite.cc:1346
Rewriter_grant(THD *thd, Consumer_type type, const Rewrite_params *params)
Definition: sql_rewrite.cc:1333
const Grant_params * grant_params
Definition: sql_rewrite.h:296
Rewrites the PREPARE statement.
Definition: sql_rewrite.h:339
Rewriter_prepare(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1800
bool rewrite(String &rlb) const override
Rewrite the query for the PREPARE statement.
Definition: sql_rewrite.cc:1811
Rewrites the START REPLICA statement.
Definition: sql_rewrite.h:307
bool rewrite(String &rlb) const override
Rewrite the query for the SLAVE REPLICA statement.
Definition: sql_rewrite.cc:1664
Rewriter_replica_start(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1654
Rewrites the SELECT statement.
Definition: sql_rewrite.h:363
Rewriter_select_query(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1902
bool rewrite(String &rlb) const override
Rewrite the query with the PAR id being redacted if the query exports query result to the object stor...
Definition: sql_rewrite.cc:1914
Base class for SERVER OPTIONS related statement.
Definition: sql_rewrite.h:313
void mysql_rewrite_server_options(const LEX *lex, String *str) const
Append the SERVER OPTIONS clause.
Definition: sql_rewrite.cc:1736
Rewriter_server_option(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1726
Definition: sql_rewrite.h:275
bool rewrite(String &rlb) const override
Rewrite the query for the SET PASSWORD statement.
Definition: sql_rewrite.cc:1284
std::set< LEX_USER * > * m_users
Definition: sql_rewrite.h:285
Rewriter_set_password(THD *thd, Consumer_type type, const Rewrite_params *params)
Definition: sql_rewrite.cc:1269
Rewrites the SET statement.
Definition: sql_rewrite.h:267
Rewriter_set(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1239
bool rewrite(String &rlb) const override
Rewrite the query for the SET statement.
Definition: sql_rewrite.cc:1250
Rewrites the SHOW CREATE USER statement.
Definition: sql_rewrite.h:244
void rewrite_password_history(const LEX *lex, String *str) const override
Append the PASSWORD HISTORY clause for users.
Definition: sql_rewrite.cc:1174
void rewrite_password_reuse(const LEX *lex, String *str) const override
Append the PASSWORD REUSE clause for users.
Definition: sql_rewrite.cc:1184
Rewriter_show_create_user(THD *thd, Consumer_type type, const Rewrite_params *params)
Definition: sql_rewrite.cc:1092
void append_user_auth_info(LEX_USER *user, bool comma, String *str) const override
Append the authID, plugin name and suth str user to output string.
Definition: sql_rewrite.cc:1195
void rewrite_user_application_user_metadata(const LEX *lex, String *str) const override
Overrides implementation of the the rewriter for user application user metadata.
Definition: sql_rewrite.cc:1123
void append_auth_str(LEX_USER *lex, String *str) const override
A special rewriter override to make SHOW CREATE USER convert the string to hex if print_identified_wi...
Definition: sql_rewrite.cc:1142
bool rewrite(String &rlb) const override
Rewrite the query for the SHOW CREATE USER statement.
Definition: sql_rewrite.cc:1110
const Show_user_params * show_params_
Definition: sql_rewrite.h:263
Rewrites the START GROUP_REPLICATION command.
Definition: sql_rewrite.h:353
Rewriter_start_group_replication(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1838
bool rewrite(String &rlb) const override
Rewrite the query for the START GROUP_REPLICATION command.
Definition: sql_rewrite.cc:1849
Abstract base class to define the skeleton of rewriting the users, yet deferring some steps to the co...
Definition: sql_rewrite.h:153
void append_mfa_auth_str(const LEX_MFA *user, String *str) const
Append the authentication string from LEX_MFA for the user.
Definition: sql_rewrite.cc:775
void rewrite_user_resources(const LEX *lex, String *str) const
Append the user resource clauses for users.
Definition: sql_rewrite.cc:624
void append_literal_secret(String *str) const
Append the literal <secret> in place of password to the output string.
Definition: sql_rewrite.cc:560
void rewrite_password_require_current(LEX *lex, String *str) const
Append the PASSWORD REQUIRE CURRENT clause for users.
Definition: sql_rewrite.cc:687
Rewriter_user(THD *thd, Consumer_type target_type)
Definition: sql_rewrite.cc:483
void rewrite_password_expired(const LEX *lex, String *str) const
Append the PASSWORD EXPIRE clause for users iff it is specified.
Definition: sql_rewrite.cc:666
virtual void rewrite_user_application_user_metadata(const LEX *lex, String *str) const =0
void rewrite_users(LEX *lex, String *str) const
Fetch the users from user_list in LEX struct and append them to the String.
Definition: sql_rewrite.cc:826
void rewrite_in_memory_user_application_user_metadata(const LEX *user, String *str) const
Use the LEX for reconstructing the ATTRIBUTE or COMMENT clause.
Definition: sql_rewrite.cc:515
void rewrite_account_lock_state(LEX *lex, String *str) const
Append the account lock state.
Definition: sql_rewrite.cc:716
virtual void rewrite_password_history(const LEX *lex, String *str) const =0
The default implementation is to append the PASSWORD HISTORY clause iff it is specified.
Definition: sql_rewrite.cc:794
virtual void append_user_auth_info(LEX_USER *user, bool comma, String *str) const =0
void rewrite_ssl_properties(const LEX *lex, String *str) const
Append the SSL clause for users iff it is specified.
Definition: sql_rewrite.cc:582
void append_mfa_plugin_name(const LEX_MFA *user, String *str) const
Append the authentication plugin name from LEX_MFA for the user.
Definition: sql_rewrite.cc:759
virtual void append_auth_str(LEX_USER *lex, String *str) const
Append the password hash to the output string.
Definition: sql_rewrite.cc:570
bool rewrite(String &rlb) const override
Appends the essential clauses for SHOW CREATE|CREATE|ALTER USER statements in the buffer rlb.
Definition: sql_rewrite.cc:494
void rewrite_account_lock(const LEX *lex, String *str) const
Append the ACCOUNT LOCK clause for users iff it is specified.
Definition: sql_rewrite.cc:651
void append_plugin_name(const LEX_USER *user, String *str) const
Append the authentication plugin name for the user.
Definition: sql_rewrite.cc:736
virtual void rewrite_password_reuse(const LEX *lex, String *str) const =0
The default implementation is to append the PASSWORD REUSE clause iff it is specified.
Definition: sql_rewrite.cc:810
void rewrite_default_roles(const LEX *lex, String *str) const
Append the DEFAULT ROLE clause for users iff it is specified.
Definition: sql_rewrite.cc:844
Wrapper object for parameters required by SHOW CREATE USER statement.
Definition: sql_rewrite.h:71
String * metadata_str
Definition: sql_rewrite.h:81
bool hide_password_hash
Definition: sql_rewrite.h:79
Show_user_params(bool hide_password_hash, bool print_identified_with_as_hex, String *param_metadata_str)
Definition: sql_rewrite.h:73
bool print_identified_with_as_hex_
Definition: sql_rewrite.h:80
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Wrapper object for user related parameters required by: SET PASSWORD|CREATE USER|ALTER USER statement...
Definition: sql_rewrite.h:61
User_params(std::set< LEX_USER * > *users_set)
Definition: sql_rewrite.h:63
std::set< LEX_USER * > * users
Definition: sql_rewrite.h:65
char * user
Definition: mysqladmin.cc:67
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1084
required string type
Definition: replication_group_member_actions.proto:34
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.
Definition: sql_rewrite.cc:421
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.
Definition: sql_rewrite.cc:383
void mysql_rewrite_query_for_binlog(THD *thd)
Rewrite query for binary log.
Definition: sql_rewrite.cc:452
void redact_par_url(String original_query_str, String &rlb)
Rewrites the par URL used in external tables.
Definition: sql_rewrite.cc:1871
Consumer_type
Target types where the rewritten query will be added.
Definition: sql_rewrite.h:38
The LEX object currently serves three different purposes:
Definition: sql_lex.h:3994