MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ha_perfschema.h
Go to the documentation of this file.
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 HA_PERFSCHEMA_H
17 #define HA_PERFSCHEMA_H
18 
19 #include "handler.h" /* class handler */
20 
30 class PFS_engine_table;
32 extern const char *pfs_engine_name;
33 
35 class ha_perfschema : public handler
36 {
37 public:
43  ha_perfschema(handlerton *hton, TABLE_SHARE *share);
44 
45  ~ha_perfschema();
46 
47  const char *table_type(void) const { return pfs_engine_name; }
48 
49  const char *index_type(uint) { return ""; }
50 
51  const char **bas_ext(void) const;
52 
54  ulonglong table_flags(void) const
55  {
56  /*
57  About HA_FAST_KEY_READ:
58 
59  The storage engine ::rnd_pos() method is fast to locate records by key,
60  so HA_FAST_KEY_READ is technically true, but the record content can be
61  overwritten between ::rnd_next() and ::rnd_pos(), because all the P_S
62  data is volatile.
63  The HA_FAST_KEY_READ flag is not advertised, to force the optimizer
64  to cache records instead, to provide more consistent records.
65  For example, consider the following statement:
66  - select * from P_S.EVENTS_WAITS_HISTORY_LONG where THREAD_ID=<n>
67  order by ...
68  With HA_FAST_KEY_READ, it can return records where "THREAD_ID=<n>"
69  is false, because the where clause was evaluated to true after
70  ::rnd_pos(), then the content changed, then the record was fetched by
71  key using ::rnd_pos().
72  Without HA_FAST_KEY_READ, the optimizer reads all columns and never
73  calls ::rnd_pos(), so it is guaranteed to return only thread <n>
74  records.
75  */
76  return HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_NO_AUTO_INCREMENT |
77  HA_PRIMARY_KEY_REQUIRED_FOR_DELETE;
78  }
79 
84  ulong index_flags(uint , uint , bool ) const
85  { return 0; }
86 
87  uint max_supported_record_length(void) const
88  { return HA_MAX_REC_LENGTH; }
89 
90  uint max_supported_keys(void) const
91  { return 0; }
92 
93  uint max_supported_key_parts(void) const
94  { return 0; }
95 
96  uint max_supported_key_length(void) const
97  { return 0; }
98 
100  { return HA_POS_ERROR; }
101 
102  double scan_time(void)
103  { return 1.0; }
104 
112  int open(const char *name, int mode, uint test_if_locked);
113 
118  int close(void);
119 
125  int write_row(uchar *buf);
126 
127  void use_hidden_primary_key();
128 
135  int update_row(const uchar *old_data, uchar *new_data);
136 
142  int delete_row(const uchar *buf);
143 
144  int rnd_init(bool scan);
145 
150  int rnd_end(void);
151 
157  int rnd_next(uchar *buf);
158 
165  int rnd_pos(uchar *buf, uchar *pos);
166 
171  void position(const uchar *record);
172 
173  int info(uint);
174 
175  int delete_all_rows(void);
176 
177  int truncate();
178 
179  int delete_table(const char *from);
180 
181  int rename_table(const char * from, const char * to);
182 
183  int create(const char *name, TABLE *form,
184  HA_CREATE_INFO *create_info);
185 
187  enum thr_lock_type lock_type);
188 
189  virtual uint8 table_cache_type(void)
190  { return HA_CACHE_TBL_NOCACHE; }
191 
192  virtual my_bool register_query_cache_table
193  (THD *, char *, uint , qc_engine_callback *engine_callback, ulonglong *)
194  {
195  *engine_callback= 0;
196  return FALSE;
197  }
198 
199  virtual void print_error(int error, myf errflags);
200 
201 private:
203  THR_LOCK_DATA m_thr_lock;
205  const PFS_engine_table_share *m_table_share;
207  PFS_engine_table *m_table;
208 };
209 
211 #endif
212