1 /* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
2 
3   This program is free software; you can redistribute it and/or modify
4   it under the terms of the GNU General Public License, version 2.0,
5   as published by the Free Software Foundation.
6 
7   This program is also distributed with certain software (including
8   but not limited to OpenSSL) that is licensed under separate terms,
9   as designated in a particular file or component or in included license
10   documentation.  The authors of MySQL hereby grant you an additional
11   permission to link the program and your derivative works with the
12   separately licensed software that they have included with MySQL.
13 
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License, version 2.0, for more details.
18 
19   You should have received a copy of the GNU General Public License
20   along with this program; if not, write to the Free Software Foundation,
21   51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
22 
23 #ifndef PFS_SETUP_ACTOR_H
24 #define PFS_SETUP_ACTOR_H
25 
26 /**
27   @file storage/perfschema/pfs_setup_actor.h
28   Performance schema setup actors (declarations).
29 */
30 
31 #include "sql_string.h"
32 #include "pfs_lock.h"
33 #include "lf.h"
34 
35 struct PFS_global_param;
36 
37 /* WL#988 Roles Not implemented yet */
38 #define ROLENAME_LENGTH 64
39 
40 /**
41   @addtogroup Performance_schema_buffers
42   @{
43 */
44 
45 /** Hash key for @sa PFS_setup_actor. */
46 struct PFS_setup_actor_key
47 {
48   /**
49     Hash search key.
50     This has to be a string for LF_HASH,
51     the format is "<username><0x00><hostname><0x00><rolename><0x00>"
52   */
53   char m_hash_key[USERNAME_LENGTH + 1 + HOSTNAME_LENGTH + 1 + ROLENAME_LENGTH + 1];
54   /** Length of @c m_hash_key. */
55   uint m_key_length;
56 };
57 
58 /** A setup_actor record. */
59 struct PFS_ALIGNED PFS_setup_actor
60 {
61   /** Internal lock. */
62   pfs_lock m_lock;
63   /** Hash key. */
64   PFS_setup_actor_key m_key;
65   /** User name. This points inside the hash key. */
66   const char *m_username;
67   /** Length of @c m_username. */
68   uint m_username_length;
69   /** Host name. This points inside the hash key. */
70   const char *m_hostname;
71   /** Length of @c m_hostname. */
72   uint m_hostname_length;
73   /** Role name. This points inside the hash key. */
74   const char *m_rolename;
75   /** Length of @c m_rolename. */
76   uint m_rolename_length;
77 };
78 
79 int init_setup_actor(const PFS_global_param *param);
80 void cleanup_setup_actor(void);
81 int init_setup_actor_hash(void);
82 void cleanup_setup_actor_hash(void);
83 
84 int insert_setup_actor(const String *user, const String *host, const String *role);
85 int delete_setup_actor(const String *user, const String *host, const String *role);
86 int reset_setup_actor(void);
87 long setup_actor_count(void);
88 
89 void lookup_setup_actor(PFS_thread *thread,
90                         const char *user, uint user_length,
91                         const char *host, uint host_length,
92                         bool *enabled);
93 
94 /* For iterators and show status. */
95 
96 extern ulong setup_actor_max;
97 
98 /* Exposing the data directly, for iterators. */
99 
100 extern PFS_setup_actor *setup_actor_array;
101 
102 extern LF_HASH setup_actor_hash;
103 
104 /** @} */
105 #endif
106 
107