1/* Copyright (c) 2008, 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 Foundation,
14 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15
16#ifndef TABLE_THREADS_H
17#define TABLE_THREADS_H
18
19#include "pfs_column_types.h"
20#include "cursor_by_thread.h"
21
22struct PFS_thread;
23
24/**
25 \addtogroup Performance_schema_tables
26 @{
27*/
28
29/**
30 A row of PERFORMANCE_SCHEMA.THREADS.
31*/
32struct row_threads
33{
34 /** Column THREAD_ID. */
35 ulonglong m_thread_internal_id;
36 /** Column PROCESSLIST_ID. */
37 ulonglong m_processlist_id;
38 /** Column NAME. */
39 const char* m_name;
40 /** Length in bytes of @c m_name. */
41 uint m_name_length;
42 /** Column PROCESSLIST_USER. */
43 char m_username[USERNAME_LENGTH];
44 /** Length in bytes of @c m_username. */
45 uint m_username_length;
46 /** Column PROCESSLIST_HOST. */
47 char m_hostname[HOSTNAME_LENGTH];
48 /** Length in bytes of @c m_hostname. */
49 uint m_hostname_length;
50 /** Column PROCESSLIST_DB. */
51 char m_dbname[NAME_LEN];
52 /** Length in bytes of @c m_dbname. */
53 uint m_dbname_length;
54 /** Column PROCESSLIST_COMMAND. */
55 int m_command;
56 /** Column PROCESSLIST_TIME. */
57 time_t m_start_time;
58 /** Column PROCESSLIST_STATE. */
59 const char* m_processlist_state_ptr;
60 /** Length in bytes of @c m_processlist_state_ptr. */
61 uint m_processlist_state_length;
62 /** Column PROCESSLIST_INFO. */
63 const char* m_processlist_info_ptr;
64 /** Length in bytes of @c m_processlist_info_ptr. */
65 uint m_processlist_info_length;
66 /** Column INSTRUMENTED. */
67 bool *m_enabled_ptr;
68 /** Column PARENT_THREAD_ID. */
69 ulonglong m_parent_thread_internal_id;
70};
71
72/** Table PERFORMANCE_SCHEMA.THREADS. */
73class table_threads : public cursor_by_thread
74{
75public:
76 /** Table share */
77 static PFS_engine_table_share m_share;
78 /** Table builder */
79 static PFS_engine_table* create();
80
81protected:
82 virtual int read_row_values(TABLE *table,
83 unsigned char *buf,
84 Field **fields,
85 bool read_all);
86
87
88 virtual int update_row_values(TABLE *table,
89 const unsigned char *old_buf,
90 const unsigned char *new_buf,
91 Field **fields);
92
93protected:
94 table_threads();
95
96public:
97 ~table_threads()
98 {}
99
100private:
101 virtual void make_row(PFS_thread *pfs);
102
103 /** Table share lock. */
104 static THR_LOCK m_table_lock;
105
106 /** Current row. */
107 row_threads m_row;
108 /** True if the current row exists. */
109 bool m_row_exists;
110};
111
112/** @} */
113#endif
114