1 /* Copyright (c) 2011, 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 Foundation,
21   51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
22 
23 #ifndef TABLE_HOSTS_H
24 #define TABLE_HOSTS_H
25 
26 #include "pfs_column_types.h"
27 #include "cursor_by_host.h"
28 #include "table_helper.h"
29 
30 struct PFS_host;
31 
32 /**
33   \addtogroup Performance_schema_tables
34   @{
35 */
36 
37 /**
38   A row of PERFORMANCE_SCHEMA.HOSTS.
39 */
40 struct row_hosts
41 {
42   /** Column HOST. */
43   PFS_host_row m_host;
44   /** Columns CURRENT_CONNECTIONS, TOTAL_CONNECTIONS. */
45   PFS_connection_stat_row m_connection_stat;
46 };
47 
48 /** Table PERFORMANCE_SCHEMA.THREADS. */
49 class table_hosts : public cursor_by_host
50 {
51 public:
52   /** Table share */
53   static PFS_engine_table_share m_share;
54   /** Table builder */
55   static PFS_engine_table* create();
56   static int delete_all_rows();
57 
58 protected:
59   virtual int read_row_values(TABLE *table,
60                               unsigned char *buf,
61                               Field **fields,
62                               bool read_all);
63 
64 
65 protected:
66   table_hosts();
67 
68 public:
~table_hosts()69   ~table_hosts()
70   {}
71 
72 private:
73   virtual void make_row(PFS_host *pfs);
74 
75   /** Table share lock. */
76   static THR_LOCK m_table_lock;
77   /** Fields definition. */
78   static TABLE_FIELD_DEF m_field_def;
79 
80   /** Current row. */
81   row_hosts m_row;
82   /** True if the current row exists. */
83   bool m_row_exists;
84 };
85 
86 /** @} */
87 #endif
88