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:123
Consumer_type consumer_type()
Return the current consumer type set in the object.
Definition: sql_rewrite.cc:436
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:142
I_rewriter(const I_rewriter &&)=delete
void set_consumer_type(Consumer_type type)
Reset the previous consumer type.
Definition: sql_rewrite.cc:428
const I_rewriter & operator=(const I_rewriter &)=delete
THD *const m_thd
Definition: sql_rewrite.h:141
I_rewriter(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:417
Definition: sql_lex.h:3739
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:326
Rewriter_alter_server(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1727
bool rewrite(String &rlb) const override
Rewrite the query for the ALTER SERVER statement.
Definition: sql_rewrite.cc:1738
Rewrites the ALTER USER statement.
Definition: sql_rewrite.h:224
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:1029
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:952
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:505
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:1041
Rewriter_alter_user(THD *thd, Consumer_type type=Consumer_type::TEXTLOG)
Definition: sql_rewrite.cc:922
bool rewrite(String &rlb) const override
Rewrite the query for the ALTER USER statement.
Definition: sql_rewrite.cc:932
Rewrites the CHANGE REPLICATION SOURCE statement.
Definition: sql_rewrite.h:296
bool rewrite(String &rlb) const override
Rewrite the query for the CHANGE REPLICATION SOURCE statement.
Definition: sql_rewrite.cc:1483
Rewriter_change_replication_source(THD *thd, Consumer_type)
Definition: sql_rewrite.cc:1471
Rewrites CLONE statement.
Definition: sql_rewrite.h:342
bool rewrite(String &rlb) const override
Rewrite the query for the CLONE statement to hide password.
Definition: sql_rewrite.cc:1785
Rewriter_clone(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1774
Rewrites the CREATE SERVER statement.
Definition: sql_rewrite.h:318
Rewriter_create_server(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1680
bool rewrite(String &rlb) const override
Rewrite the query for the CREATE SERVER statement.
Definition: sql_rewrite.cc:1709
Rewrites the CREATE USER statement.
Definition: sql_rewrite.h:208
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:845
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:904
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:916
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:494
Rewriter_create_user(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:814
bool rewrite(String &rlb) const override
Rewrite the query for the CREATE USER statement.
Definition: sql_rewrite.cc:824
Rewrites the GRANT statement.
Definition: sql_rewrite.h:285
bool rewrite(String &rlb) const override
Rewrite the query for the GRANT statement.
Definition: sql_rewrite.cc:1301
Rewriter_grant(THD *thd, Consumer_type type, const Rewrite_params *params)
Definition: sql_rewrite.cc:1288
const Grant_params * grant_params
Definition: sql_rewrite.h:292
Rewrites the PREPARE statement.
Definition: sql_rewrite.h:335
Rewriter_prepare(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1752
bool rewrite(String &rlb) const override
Rewrite the query for the PREPARE statement.
Definition: sql_rewrite.cc:1763
Rewrites the START REPLICA statement.
Definition: sql_rewrite.h:303
bool rewrite(String &rlb) const override
Rewrite the query for the SLAVE REPLICA statement.
Definition: sql_rewrite.cc:1616
Rewriter_replica_start(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1606
Base class for SERVER OPTIONS related statement.
Definition: sql_rewrite.h:309
void mysql_rewrite_server_options(const LEX *lex, String *str) const
Append the SERVER OPTIONS clause.
Definition: sql_rewrite.cc:1688
Rewriter_server_option(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1678
Definition: sql_rewrite.h:271
bool rewrite(String &rlb) const override
Rewrite the query for the SET PASSWORD statement.
Definition: sql_rewrite.cc:1239
std::set< LEX_USER * > * m_users
Definition: sql_rewrite.h:281
Rewriter_set_password(THD *thd, Consumer_type type, const Rewrite_params *params)
Definition: sql_rewrite.cc:1224
Rewrites the SET statement.
Definition: sql_rewrite.h:263
Rewriter_set(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1194
bool rewrite(String &rlb) const override
Rewrite the query for the SET statement.
Definition: sql_rewrite.cc:1205
Rewrites the SHOW CREATE USER statement.
Definition: sql_rewrite.h:240
void rewrite_password_history(const LEX *lex, String *str) const override
Append the PASSWORD HISTORY clause for users.
Definition: sql_rewrite.cc:1129
void rewrite_password_reuse(const LEX *lex, String *str) const override
Append the PASSWORD REUSE clause for users.
Definition: sql_rewrite.cc:1139
Rewriter_show_create_user(THD *thd, Consumer_type type, const Rewrite_params *params)
Definition: sql_rewrite.cc:1047
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:1150
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:1078
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:1097
bool rewrite(String &rlb) const override
Rewrite the query for the SHOW CREATE USER statement.
Definition: sql_rewrite.cc:1065
const Show_user_params * show_params_
Definition: sql_rewrite.h:259
Rewrites the START GROUP_REPLICATION command.
Definition: sql_rewrite.h:349
Rewriter_start_group_replication(THD *thd, Consumer_type type)
Definition: sql_rewrite.cc:1790
bool rewrite(String &rlb) const override
Rewrite the query for the START GROUP_REPLICATION command.
Definition: sql_rewrite.cc:1801
Abstract base class to define the skeleton of rewriting the users, yet deferring some steps to the co...
Definition: sql_rewrite.h:149
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:730
void rewrite_user_resources(const LEX *lex, String *str) const
Append the user resource clauses for users.
Definition: sql_rewrite.cc:579
void append_literal_secret(String *str) const
Append the literal <secret> in place of password to the output string.
Definition: sql_rewrite.cc:515
void rewrite_password_require_current(LEX *lex, String *str) const
Append the PASSWORD REQUIRE CURRENT clause for users.
Definition: sql_rewrite.cc:642
Rewriter_user(THD *thd, Consumer_type target_type)
Definition: sql_rewrite.cc:438
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:621
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:781
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:470
void rewrite_account_lock_state(LEX *lex, String *str) const
Append the account lock state.
Definition: sql_rewrite.cc:671
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:749
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:537
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:714
virtual void append_auth_str(LEX_USER *lex, String *str) const
Append the password hash to the output string.
Definition: sql_rewrite.cc:525
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:449
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:606
void append_plugin_name(const LEX_USER *user, String *str) const
Append the authentication plugin name for the user.
Definition: sql_rewrite.cc:691
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:765
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:799
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:167
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:66
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
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:391
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:354
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:3823