1 /* Copyright (c) 2010, 2021, Oracle and/or its affiliates. 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 class PFS_opaque_container_page; 37 38 /** 39 @addtogroup Performance_schema_buffers 40 @{ 41 */ 42 43 /** Hash key for @sa PFS_setup_object. */ 44 struct PFS_setup_object_key 45 { 46 /** 47 Hash search key. 48 This has to be a string for LF_HASH, 49 the format is "<enum_object_type><schema_name><0x00><object_name><0x00>" 50 */ 51 char m_hash_key[1 + NAME_LEN + 1 + NAME_LEN + 1]; 52 uint m_key_length; 53 }; 54 55 /** A setup_object record. */ 56 struct PFS_ALIGNED PFS_setup_object 57 { get_object_typePFS_setup_object58 enum_object_type get_object_type() 59 { 60 return (enum_object_type) m_key.m_hash_key[0]; 61 } 62 63 /** Internal lock. */ 64 pfs_lock m_lock; 65 /** Hash key. */ 66 PFS_setup_object_key m_key; 67 /** Schema name. Points inside m_key. */ 68 const char *m_schema_name; 69 /** Length of @c m_schema_name. */ 70 uint m_schema_name_length; 71 /** Object name. Points inside m_key. */ 72 const char *m_object_name; 73 /** Length of @c m_object_name. */ 74 uint m_object_name_length; 75 /** ENABLED flag. */ 76 bool m_enabled; 77 /** TIMED flag. */ 78 bool m_timed; 79 /** Container page. */ 80 PFS_opaque_container_page *m_page; 81 }; 82 83 int init_setup_object(const PFS_global_param *param); 84 void cleanup_setup_object(void); 85 int init_setup_object_hash(const PFS_global_param *param); 86 void cleanup_setup_object_hash(void); 87 88 int insert_setup_object(enum_object_type object_type, const String *schema, 89 const String *object, bool enabled, bool timed); 90 int delete_setup_object(enum_object_type object_type, const String *schema, 91 const String *object); 92 int reset_setup_object(void); 93 long setup_object_count(void); 94 95 void lookup_setup_object(PFS_thread *thread, 96 enum_object_type object_type, 97 const char *schema_name, int schema_name_length, 98 const char *object_name, int object_name_length, 99 bool *enabled, bool *timed); 100 101 /* For show status. */ 102 103 extern LF_HASH setup_object_hash; 104 105 /** @} */ 106 #endif 107 108