| 1 | /* Copyright (c) 2008, 2010, 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 TABLE_SYNC_INSTANCE_H |
| 17 | #define TABLE_SYNC_INSTANCE_H |
| 18 | |
| 19 | /** |
| 20 | @file storage/perfschema/table_sync_instances.h |
| 21 | Table MUTEX_INSTANCES, RWLOCK_INSTANCES and COND_INSTANCES (declarations). |
| 22 | */ |
| 23 | |
| 24 | #include "pfs_column_types.h" |
| 25 | #include "pfs_engine_table.h" |
| 26 | |
| 27 | struct PFS_mutex; |
| 28 | struct PFS_rwlock; |
| 29 | struct PFS_cond; |
| 30 | |
| 31 | /** |
| 32 | @addtogroup Performance_schema_tables |
| 33 | @{ |
| 34 | */ |
| 35 | |
| 36 | /** A row of table PERFORMANCE_SCHEMA.MUTEX_INSTANCES. */ |
| 37 | struct row_mutex_instances |
| 38 | { |
| 39 | /** Column NAME. */ |
| 40 | const char *m_name; |
| 41 | /** Length in bytes of @c m_name. */ |
| 42 | uint m_name_length; |
| 43 | /** Column OBJECT_INSTANCE_BEGIN. */ |
| 44 | const void *m_identity; |
| 45 | /** True if column LOCKED_BY_THREAD_ID is not null. */ |
| 46 | bool m_locked; |
| 47 | /** Column LOCKED_BY_THREAD_ID. */ |
| 48 | ulonglong m_locked_by_thread_id; |
| 49 | }; |
| 50 | |
| 51 | /** Table PERFORMANCE_SCHEMA.MUTEX_INSTANCES. */ |
| 52 | class table_mutex_instances : public PFS_engine_table |
| 53 | { |
| 54 | public: |
| 55 | /** Table share. */ |
| 56 | static PFS_engine_table_share m_share; |
| 57 | static PFS_engine_table* create(); |
| 58 | |
| 59 | virtual int rnd_next(); |
| 60 | virtual int rnd_pos(const void *pos); |
| 61 | virtual void reset_position(void); |
| 62 | |
| 63 | private: |
| 64 | virtual int read_row_values(TABLE *table, |
| 65 | unsigned char *buf, |
| 66 | Field **fields, |
| 67 | bool read_all); |
| 68 | |
| 69 | table_mutex_instances(); |
| 70 | |
| 71 | public: |
| 72 | ~table_mutex_instances() |
| 73 | {} |
| 74 | |
| 75 | private: |
| 76 | void make_row(PFS_mutex *pfs); |
| 77 | |
| 78 | /** Table share lock. */ |
| 79 | static THR_LOCK m_table_lock; |
| 80 | |
| 81 | /** Current row. */ |
| 82 | row_mutex_instances m_row; |
| 83 | /** True if the current row exists. */ |
| 84 | bool m_row_exists; |
| 85 | /** Current position. */ |
| 86 | PFS_simple_index m_pos; |
| 87 | /** Next position. */ |
| 88 | PFS_simple_index m_next_pos; |
| 89 | }; |
| 90 | |
| 91 | /** A row of table PERFORMANCE_SCHEMA.RWLOCK_INSTANCES. */ |
| 92 | struct row_rwlock_instances |
| 93 | { |
| 94 | /** Column NAME. */ |
| 95 | const char *m_name; |
| 96 | /** Length in bytes of @c m_name. */ |
| 97 | uint m_name_length; |
| 98 | /** Column OBJECT_INSTANCE_BEGIN. */ |
| 99 | const void *m_identity; |
| 100 | /** True if column WRITE_LOCKED_BY_THREAD_ID is not null. */ |
| 101 | bool m_write_locked; |
| 102 | /** Column WRITE_LOCKED_BY_THREAD_ID. */ |
| 103 | ulonglong m_write_locked_by_thread_id; |
| 104 | /** Column READ_LOCKED_BY_COUNT. */ |
| 105 | ulong m_readers; |
| 106 | }; |
| 107 | |
| 108 | /** Table PERFORMANCE_SCHEMA.RWLOCK_INSTANCES. */ |
| 109 | class table_rwlock_instances : public PFS_engine_table |
| 110 | { |
| 111 | public: |
| 112 | /** Table share */ |
| 113 | static PFS_engine_table_share m_share; |
| 114 | static PFS_engine_table* create(); |
| 115 | |
| 116 | virtual int rnd_next(); |
| 117 | virtual int rnd_pos(const void *pos); |
| 118 | virtual void reset_position(void); |
| 119 | |
| 120 | private: |
| 121 | virtual int read_row_values(TABLE *table, |
| 122 | unsigned char *buf, |
| 123 | Field **fields, |
| 124 | bool read_all); |
| 125 | |
| 126 | table_rwlock_instances(); |
| 127 | |
| 128 | public: |
| 129 | ~table_rwlock_instances() |
| 130 | {} |
| 131 | |
| 132 | private: |
| 133 | void make_row(PFS_rwlock *pfs); |
| 134 | |
| 135 | /** Table share lock. */ |
| 136 | static THR_LOCK m_table_lock; |
| 137 | |
| 138 | /** Current row. */ |
| 139 | row_rwlock_instances m_row; |
| 140 | /** True if the current row exists. */ |
| 141 | bool m_row_exists; |
| 142 | /** Current position. */ |
| 143 | PFS_simple_index m_pos; |
| 144 | /** Next position. */ |
| 145 | PFS_simple_index m_next_pos; |
| 146 | }; |
| 147 | |
| 148 | /** A row of table PERFORMANCE_SCHEMA.COND_INSTANCES. */ |
| 149 | struct row_cond_instances |
| 150 | { |
| 151 | /** Column NAME. */ |
| 152 | const char *m_name; |
| 153 | /** Length in bytes of @c m_name. */ |
| 154 | uint m_name_length; |
| 155 | /** Column OBJECT_INSTANCE_BEGIN. */ |
| 156 | const void *m_identity; |
| 157 | }; |
| 158 | |
| 159 | /** Table PERFORMANCE_SCHEMA.COND_INSTANCES. */ |
| 160 | class table_cond_instances : public PFS_engine_table |
| 161 | { |
| 162 | public: |
| 163 | /** Table share. */ |
| 164 | static PFS_engine_table_share m_share; |
| 165 | static PFS_engine_table* create(); |
| 166 | |
| 167 | virtual int rnd_next(); |
| 168 | virtual int rnd_pos(const void *pos); |
| 169 | virtual void reset_position(void); |
| 170 | |
| 171 | private: |
| 172 | virtual int read_row_values(TABLE *table, |
| 173 | unsigned char *buf, |
| 174 | Field **fields, |
| 175 | bool read_all); |
| 176 | |
| 177 | table_cond_instances(); |
| 178 | |
| 179 | public: |
| 180 | ~table_cond_instances() |
| 181 | {} |
| 182 | |
| 183 | private: |
| 184 | void make_row(PFS_cond *pfs); |
| 185 | |
| 186 | /** Table share lock. */ |
| 187 | static THR_LOCK m_table_lock; |
| 188 | |
| 189 | /** Current row. */ |
| 190 | row_cond_instances m_row; |
| 191 | /** True if the current row exists. */ |
| 192 | bool m_row_exists; |
| 193 | /** Current position. */ |
| 194 | PFS_simple_index m_pos; |
| 195 | /** Next position. */ |
| 196 | PFS_simple_index m_next_pos; |
| 197 | }; |
| 198 | |
| 199 | /** @} */ |
| 200 | #endif |
| 201 | |