MySQL 8.0.39
Source Code Documentation
dynamic_privilege_table.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23#ifndef DYNAMIC_PRIVILEGE_TABLE_H
24#define DYNAMIC_PRIVILEGE_TABLE_H
25
26#include <functional>
27#include <string>
28#include <unordered_set>
29
30#include "lex_string.h"
32
33class THD;
34struct TABLE;
35class Table_ref;
36
37typedef std::unordered_set<std::string> Dynamic_privilege_register;
38
41 const Auth_id_ref &auth_id,
42 const LEX_CSTRING &privilege,
43 bool with_grant_option,
44 bool delete_option);
46 public:
50 : m_thd(thd), m_table(table), m_no_update(false) {}
51 bool operator()(const std::string &priv, const Auth_id_ref &auth_id,
52 bool grant_option,
54 if (m_no_update) return false;
55 LEX_CSTRING cstr_priv = {priv.c_str(), priv.length()};
57 cstr_priv, grant_option,
58 op == Operation::REVOKE);
59 }
60
61 private:
65};
66
68void register_dynamic_privilege_impl(const std::string &priv);
70 std::function<bool(const char *)> action);
71#endif
std::pair< LEX_CSTRING, LEX_CSTRING > Auth_id_ref
user, host tuple which reference either acl_cache or g_default_roles
Definition: auth_common.h:80
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Definition: table.h:2791
TABLE * table
Definition: table.h:3568
Definition: dynamic_privilege_table.h:45
Operation
Definition: dynamic_privilege_table.h:47
@ REVOKE
Definition: dynamic_privilege_table.h:47
@ GRANT
Definition: dynamic_privilege_table.h:47
bool m_no_update
Definition: dynamic_privilege_table.h:64
bool operator()(const std::string &priv, const Auth_id_ref &auth_id, bool grant_option, Update_dynamic_privilege_table::Operation op)
Definition: dynamic_privilege_table.h:51
TABLE * m_table
Definition: dynamic_privilege_table.h:63
THD * m_thd
Definition: dynamic_privilege_table.h:62
Update_dynamic_privilege_table()
Definition: dynamic_privilege_table.h:48
Update_dynamic_privilege_table(THD *thd, TABLE *table)
Definition: dynamic_privilege_table.h:49
void register_dynamic_privilege_impl(const std::string &priv)
Dynamic_privilege_register * get_dynamic_privilege_register(void)
This function returns a pointer to a global variable allocated on the heap.
Definition: dynamic_privilege_table.cc:72
std::unordered_set< std::string > Dynamic_privilege_register
Definition: dynamic_privilege_table.h:35
bool populate_dynamic_privilege_caches(THD *thd, Table_ref *tablelst)
Given an open table handler this function refresh the list of dynamic privilege grants by reading the...
Definition: dynamic_privilege_table.cc:89
bool modify_dynamic_privileges_in_table(THD *thd, TABLE *table, const Auth_id_ref &auth_id, const LEX_CSTRING &privilege, bool with_grant_option, bool delete_option)
Delete or insert a row in the mysql.dynamic_privilege table.
Definition: dynamic_privilege_table.cc:196
bool iterate_all_dynamic_privileges(THD *thd, std::function< bool(const char *)> action)
Definition: dynamic_privilege_table.cc:242
repeated Action action
Definition: replication_group_member_actions.proto:43
@ REVOKE
Definition: sql_yacc.h:520
Definition: mysql_lex_string.h:40
size_t length
Definition: mysql_lex_string.h:42
Definition: table.h:1399