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 |
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
15 | |
16 | #ifndef PFS_SETUP_OBJECT_H |
17 | #define PFS_SETUP_OBJECT_H |
18 | |
19 | /** |
20 | @file storage/perfschema/pfs_setup_object.h |
21 | Performance schema setup object (declarations). |
22 | */ |
23 | |
24 | #include "pfs_lock.h" |
25 | #include "lf.h" |
26 | |
27 | class String; |
28 | struct PFS_global_param; |
29 | |
30 | /** |
31 | @addtogroup Performance_schema_buffers |
32 | @{ |
33 | */ |
34 | |
35 | /** Hash key for @sa PFS_setup_object. */ |
36 | struct PFS_setup_object_key |
37 | { |
38 | /** |
39 | Hash search key. |
40 | This has to be a string for LF_HASH, |
41 | the format is "<enum_object_type><schema_name><0x00><object_name><0x00>" |
42 | */ |
43 | char m_hash_key[1 + NAME_LEN + 1 + NAME_LEN + 1]; |
44 | uint m_key_length; |
45 | }; |
46 | |
47 | /** A setup_object record. */ |
48 | struct PFS_ALIGNED PFS_setup_object |
49 | { |
50 | enum_object_type get_object_type() |
51 | { |
52 | return (enum_object_type) m_key.m_hash_key[0]; |
53 | } |
54 | |
55 | /** Internal lock. */ |
56 | pfs_lock m_lock; |
57 | /** Hash key. */ |
58 | PFS_setup_object_key m_key; |
59 | /** Schema name. Points inside m_key. */ |
60 | const char *m_schema_name; |
61 | /** Length of @c m_schema_name. */ |
62 | uint m_schema_name_length; |
63 | /** Object name. Points inside m_key. */ |
64 | const char *m_object_name; |
65 | /** Length of @c m_object_name. */ |
66 | uint m_object_name_length; |
67 | /** ENABLED flag. */ |
68 | bool m_enabled; |
69 | /** TIMED flag. */ |
70 | bool m_timed; |
71 | }; |
72 | |
73 | int init_setup_object(const PFS_global_param *param); |
74 | void cleanup_setup_object(void); |
75 | int init_setup_object_hash(void); |
76 | void cleanup_setup_object_hash(void); |
77 | |
78 | int insert_setup_object(enum_object_type object_type, const String *schema, |
79 | const String *object, bool enabled, bool timed); |
80 | int delete_setup_object(enum_object_type object_type, const String *schema, |
81 | const String *object); |
82 | int reset_setup_object(void); |
83 | long setup_object_count(void); |
84 | |
85 | void lookup_setup_object(PFS_thread *thread, |
86 | enum_object_type object_type, |
87 | const char *schema_name, int schema_name_length, |
88 | const char *object_name, int object_name_length, |
89 | bool *enabled, bool *timed); |
90 | |
91 | /* For iterators and show status. */ |
92 | |
93 | extern ulong setup_object_max; |
94 | |
95 | /* Exposing the data directly, for iterators. */ |
96 | |
97 | extern PFS_setup_object *setup_object_array; |
98 | |
99 | extern LF_HASH setup_object_hash; |
100 | |
101 | /** @} */ |
102 | #endif |
103 | |
104 | |