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