21 #include "my_global.h"
22 #include "my_pthread.h"
23 #include "my_atomic.h"
24 #include "sql_plugin.h"
25 #include "mysql/plugin.h"
36 #ifdef MY_ATOMIC_MODE_DUMMY
44 #error "The performance schema needs a functional MY_ATOMIC implementation."
56 static int compare_database_names(
const char *name1,
const char *name2)
58 if (lower_case_table_names)
59 return strcasecmp(name1, name2);
60 return strcmp(name1, name2);
64 find_table_share(
const char *db,
const char *
name)
66 DBUG_ENTER(
"find_table_share");
76 static int pfs_init_func(
void *p)
78 DBUG_ENTER(
"pfs_init_func");
82 pfs_hton->state= SHOW_OPTION_YES;
83 pfs_hton->create= pfs_create_handler;
85 pfs_hton->flags= HTON_ALTER_NOT_SUPPORTED |
86 HTON_TEMPORARY_NOT_SUPPORTED |
88 HTON_NO_BINLOG_ROW_OPT;
103 pfs_hton->db_type= DB_TYPE_PERFORMANCE_SCHEMA;
110 static int pfs_done_func(
void *p)
112 DBUG_ENTER(
"pfs_done_func");
123 {
"Performance_schema_mutex_classes_lost",
125 {
"Performance_schema_rwlock_classes_lost",
127 {
"Performance_schema_cond_classes_lost",
129 {
"Performance_schema_thread_classes_lost",
131 {
"Performance_schema_file_classes_lost",
133 {
"Performance_schema_socket_classes_lost",
135 {
"Performance_schema_mutex_instances_lost",
137 {
"Performance_schema_rwlock_instances_lost",
139 {
"Performance_schema_cond_instances_lost",
141 {
"Performance_schema_thread_instances_lost",
143 {
"Performance_schema_file_instances_lost",
145 {
"Performance_schema_file_handles_lost",
147 {
"Performance_schema_socket_instances_lost",
149 {
"Performance_schema_locker_lost",
152 {
"Performance_schema_table_instances_lost",
155 {
"Performance_schema_table_handles_lost",
157 {
"Performance_schema_hosts_lost",
158 (
char*) &host_lost, SHOW_LONG},
159 {
"Performance_schema_users_lost",
160 (
char*) &user_lost, SHOW_LONG},
161 {
"Performance_schema_accounts_lost",
162 (
char*) &account_lost, SHOW_LONG},
163 {
"Performance_schema_stage_classes_lost",
165 {
"Performance_schema_statement_classes_lost",
167 {
"Performance_schema_digest_lost",
168 (
char*) &digest_lost, SHOW_LONG},
169 {
"Performance_schema_session_connect_attrs_lost",
171 {NullS, NullS, SHOW_LONG}
175 { MYSQL_HANDLERTON_INTERFACE_VERSION };
179 mysql_declare_plugin(perfschema)
181 MYSQL_STORAGE_ENGINE_PLUGIN,
185 "Performance Schema",
195 mysql_declare_plugin_end;
198 :
handler(hton, share), m_table_share(NULL), m_table(NULL)
201 ha_perfschema::~ha_perfschema()
204 static const char *ha_pfs_exts[]= {
215 DBUG_ENTER(
"ha_perfschema::open");
217 m_table_share= find_table_share(table_share->db.str,
218 table_share->table_name.str);
220 DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
222 thr_lock_data_init(m_table_share->
m_thr_lock_ptr, &m_thr_lock, NULL);
230 DBUG_ENTER(
"ha_perfschema::close");
242 DBUG_ENTER(
"ha_perfschema::write_row");
244 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
246 DBUG_ASSERT(m_table_share);
247 ha_statistic_increment(&SSV::ha_write_count);
248 result= m_table_share->
write_row(table, buf, table->field);
260 table->column_bitmaps_set_no_signal(&table->s->all_set, table->write_set);
265 DBUG_ENTER(
"ha_perfschema::update_row");
267 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
269 DBUG_ASSERT(m_table);
270 ha_statistic_increment(&SSV::ha_update_count);
271 int result= m_table->
update_row(table, old_data, new_data, table->field);
277 DBUG_ENTER(
"ha_perfschema::delete_row");
279 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
281 DBUG_ASSERT(m_table);
282 ha_statistic_increment(&SSV::ha_delete_count);
283 int result= m_table->
delete_row(table, buf, table->field);
290 DBUG_ENTER(
"ha_perfschema::rnd_init");
292 DBUG_ASSERT(m_table_share);
304 result= m_table ? 0 : HA_ERR_OUT_OF_MEM;
310 DBUG_ENTER(
"ha_perfschema::rnd_end");
311 DBUG_ASSERT(m_table);
319 DBUG_ENTER(
"ha_perfschema::rnd_next");
321 DBUG_RETURN(HA_ERR_END_OF_FILE);
323 DBUG_ASSERT(m_table);
324 ha_statistic_increment(&SSV::ha_read_rnd_next_count);
329 result= m_table->
read_row(table, buf, table->field);
338 DBUG_ENTER(
"ha_perfschema::position");
340 DBUG_ASSERT(m_table);
347 DBUG_ENTER(
"ha_perfschema::rnd_pos");
349 DBUG_RETURN(HA_ERR_END_OF_FILE);
351 DBUG_ASSERT(m_table);
352 ha_statistic_increment(&SSV::ha_read_rnd_count);
353 int result= m_table->
rnd_pos(pos);
355 result= m_table->
read_row(table, buf, table->field);
359 int ha_perfschema::info(uint flag)
361 DBUG_ENTER(
"ha_perfschema::info");
362 DBUG_ASSERT(m_table_share);
363 if (flag & HA_STATUS_VARIABLE)
365 if (flag & HA_STATUS_CONST)
374 DBUG_ENTER(
"ha_perfschema::delete_all_rows");
378 DBUG_ASSERT(m_table_share);
383 result= HA_ERR_WRONG_COMMAND;
395 enum thr_lock_type lock_type)
397 if (lock_type != TL_IGNORE && m_thr_lock.type == TL_UNLOCK)
398 m_thr_lock.type= lock_type;
400 m_thr_lock.m_psi=
m_psi;
406 DBUG_ENTER(
"ha_perfschema::delete_table");
412 DBUG_ENTER(
"ha_perfschema::rename_table ");
413 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
416 int ha_perfschema::create(
const char *name,
TABLE *table_arg,
419 DBUG_ENTER(
"ha_perfschema::create");
420 DBUG_ASSERT(table_arg);
421 DBUG_ASSERT(table_arg->s);
422 if (find_table_share(table_arg->s->db.str,
423 table_arg->s->table_name.str))
437 DBUG_RETURN(HA_ERR_WRONG_COMMAND);
444 case HA_ERR_TABLE_NEEDS_UPGRADE:
449 my_error(ER_WRONG_NATIVE_TABLE_STRUCTURE, MYF(0),
450 table_share->db.str, table_share->table_name.str);
452 case HA_ERR_WRONG_COMMAND:
463 my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));