MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ha_myisammrg.h
1 /*
2  Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16 
17 
18 /* class for the the myisam merge handler */
19 
20 #include <myisammrg.h>
21 
29 class Mrg_child_def: public Sql_alloc
30 {
31  /* Remembered MERGE child def version. See top comment in ha_myisammrg.cc */
32  enum_table_ref_type m_child_table_ref_type;
33  ulonglong m_child_def_version;
34 public:
35  LEX_STRING db;
36  LEX_STRING name;
37 
38  /* Access MERGE child def version. See top comment in ha_myisammrg.cc */
39  inline enum_table_ref_type get_child_table_ref_type()
40  {
41  return m_child_table_ref_type;
42  }
43  inline ulonglong get_child_def_version()
44  {
45  return m_child_def_version;
46  }
47  inline void set_child_def_version(enum_table_ref_type child_table_ref_type,
48  ulonglong version)
49  {
50  m_child_table_ref_type= child_table_ref_type;
51  m_child_def_version= version;
52  }
53 
54  Mrg_child_def(char *db_arg, size_t db_len_arg,
55  char *table_name_arg, size_t table_name_len_arg)
56  {
57  db.str= db_arg;
58  db.length= db_len_arg;
59  name.str= table_name_arg;
60  name.length= table_name_len_arg;
61  m_child_def_version= ~0ULL;
62  m_child_table_ref_type= TABLE_REF_NULL;
63  }
64 };
65 
66 
67 class ha_myisammrg: public handler
68 {
69  MYRG_INFO *file;
70  my_bool is_cloned; /* This instance has been cloned */
71 
72 public:
73  MEM_ROOT children_mem_root; /* mem root for children list */
74  List<Mrg_child_def> child_def_list;
75  TABLE_LIST *children_l; /* children list */
76  TABLE_LIST **children_last_l; /* children list end */
77  uint test_if_locked; /* flags from ::open() */
78 
79  ha_myisammrg(handlerton *hton, TABLE_SHARE *table_arg);
80  ~ha_myisammrg();
81  const char *table_type() const { return "MRG_MyISAM"; }
82  const char **bas_ext() const;
83  const char *index_type(uint key_number);
84  ulonglong table_flags() const
85  {
86  return (HA_REC_NOT_IN_SEQ | HA_AUTO_PART_KEY | HA_NO_TRANSACTIONS |
87  HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
88  HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED |
89  HA_ANY_INDEX_MAY_BE_UNIQUE | HA_CAN_BIT_FIELD |
90  HA_HAS_RECORDS |
91  HA_NO_COPY_ON_ALTER |
92  HA_DUPLICATE_POS);
93  }
94  ulong index_flags(uint inx, uint part, bool all_parts) const
95  {
96  return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ?
97  0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE |
98  HA_READ_ORDER | HA_KEYREAD_ONLY);
99  }
100  uint max_supported_keys() const { return MI_MAX_KEY; }
101  uint max_supported_key_length() const { return MI_MAX_KEY_LENGTH; }
102  uint max_supported_key_part_length() const { return MI_MAX_KEY_LENGTH; }
103  double scan_time()
104  { return ulonglong2double(stats.data_file_length) / IO_SIZE + file->tables; }
105 
106  int open(const char *name, int mode, uint test_if_locked);
107  int add_children_list(void);
108  int attach_children(void);
109  int detach_children(void);
110  virtual handler *clone(const char *name, MEM_ROOT *mem_root);
111  int close(void);
112  int write_row(uchar * buf);
113  int update_row(const uchar * old_data, uchar * new_data);
114  int delete_row(const uchar * buf);
115  int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map,
116  enum ha_rkey_function find_flag);
117  int index_read_idx_map(uchar *buf, uint index, const uchar *key,
118  key_part_map keypart_map,
119  enum ha_rkey_function find_flag);
120  int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map);
121  int index_next(uchar * buf);
122  int index_prev(uchar * buf);
123  int index_first(uchar * buf);
124  int index_last(uchar * buf);
125  int index_next_same(uchar *buf, const uchar *key, uint keylen);
126  int rnd_init(bool scan);
127  int rnd_next(uchar *buf);
128  int rnd_pos(uchar * buf, uchar *pos);
129  void position(const uchar *record);
130  ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
131  int truncate();
132  int info(uint);
133  int reset(void);
134  int extra(enum ha_extra_function operation);
135  int extra_opt(enum ha_extra_function operation, ulong cache_size);
136  int external_lock(THD *thd, int lock_type);
137  uint lock_count(void) const;
138  int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
140  enum thr_lock_type lock_type);
141  void update_create_info(HA_CREATE_INFO *create_info);
142  void append_create_info(String *packet);
143  MYRG_INFO *myrg_info() { return file; }
144  TABLE *table_ptr() { return table; }
145  bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
146  int check(THD* thd, HA_CHECK_OPT* check_opt);
147  ha_rows records();
148 };