1 /* Copyright (c) 2008, 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_FILE_INSTANCES_H
24 #define TABLE_FILE_INSTANCES_H
25 
26 /**
27   @file storage/perfschema/table_file_instances.h
28   Table FILE_INSTANCES (declarations).
29 */
30 
31 #include "pfs_column_types.h"
32 #include "pfs_engine_table.h"
33 
34 /**
35   @addtogroup Performance_schema_tables
36   @{
37 */
38 
39 /** A row of PERFORMANCE_SCHEMA.FILE_INSTANCES. */
40 struct row_file_instances
41 {
42   /** Column FILE_NAME. */
43   const char *m_filename;
44   /** Length in bytes of @c m_filename. */
45   uint m_filename_length;
46   /** Column EVENT_NAME. */
47   const char *m_event_name;
48   /** Length in bytes of @c m_event_name. */
49   uint m_event_name_length;
50   /** Column OPEN_COUNT. */
51   uint m_open_count;
52 };
53 
54 /** Table PERFORMANCE_SCHEMA.FILE_INSTANCES. */
55 class table_file_instances : public PFS_engine_table
56 {
57 public:
58   /** Table share */
59   static PFS_engine_table_share m_share;
60   static PFS_engine_table* create();
61   static ha_rows get_row_count();
62 
63   virtual int rnd_next();
64   virtual int rnd_pos(const void *pos);
65   virtual void reset_position(void);
66 
67 private:
68   virtual int read_row_values(TABLE *table,
69                               unsigned char *buf,
70                               Field **fields,
71                               bool read_all);
72 
73   table_file_instances();
74 
75 public:
~table_file_instances()76   ~table_file_instances()
77   {}
78 
79 private:
80   void make_row(PFS_file *pfs);
81 
82   /** Table share lock. */
83   static THR_LOCK m_table_lock;
84   /** Fields definition. */
85   static TABLE_FIELD_DEF m_field_def;
86 
87   /** Current row. */
88   row_file_instances m_row;
89   /** True if the current row exists. */
90   bool m_row_exists;
91   /** Current position. */
92   PFS_simple_index m_pos;
93   /** Next position. */
94   PFS_simple_index m_next_pos;
95 };
96 
97 /** @} */
98 #endif
99