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