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