MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
myisammrg.h
1 /* Copyright (c) 2000-2002, 2004, 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc.
2  Use is subject to license terms.
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 /* This file should be included when using merge_isam_funktions */
18 
19 #ifndef _myisammrg_h
20 #define _myisammrg_h
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #ifndef _my_base_h
26 #include <my_base.h>
27 #endif
28 #ifndef _myisam_h
29 #include <myisam.h>
30 #endif
31 
32 #include <queues.h>
33 
34 #define MYRG_NAME_EXT ".MRG"
35 
36 /* In which table to INSERT rows */
37 #define MERGE_INSERT_DISABLED 0
38 #define MERGE_INSERT_TO_FIRST 1
39 #define MERGE_INSERT_TO_LAST 2
40 
41 extern TYPELIB merge_insert_method;
42 
43  /* Param to/from myrg_info */
44 
45 typedef struct st_mymerge_info /* Struct from h_info */
46 {
47  ulonglong records; /* Records in database */
48  ulonglong deleted; /* Deleted records in database */
49  ulonglong recpos; /* Pos for last used record */
50  ulonglong data_file_length;
51  ulonglong dupp_key_pos; /* Offset of the Duplicate key in the merge table */
52  uint reclength; /* Recordlength */
53  int errkey; /* With key was dupplicated on err */
54  uint options; /* HA_OPTION_... used */
55  ulong *rec_per_key; /* for sql optimizing */
56 } MYMERGE_INFO;
57 
58 typedef struct st_myrg_table_info
59 {
60  struct st_myisam_info *table;
61  ulonglong file_offset;
62 } MYRG_TABLE;
63 
64 typedef struct st_myrg_info
65 {
66  MYRG_TABLE *open_tables,*current_table,*end_table,*last_used_table;
67  ulonglong records; /* records in tables */
68  ulonglong del; /* Removed records */
69  ulonglong data_file_length;
70  ulong cache_size;
71  uint merge_insert_method;
72  uint tables,options,reclength,keys;
73  my_bool cache_in_use;
74  /* If MERGE children attached to parent. See top comment in ha_myisammrg.cc */
75  my_bool children_attached;
76  LIST open_list;
77  QUEUE by_key;
78  ulong *rec_per_key_part; /* for sql optimizing */
79  mysql_mutex_t mutex;
80 } MYRG_INFO;
81 
82 
83  /* Prototypes for merge-functions */
84 
85 extern int myrg_close(MYRG_INFO *file);
86 extern int myrg_delete(MYRG_INFO *file,const uchar *buff);
87 extern MYRG_INFO *myrg_open(const char *name,int mode,int wait_if_locked);
88 extern MYRG_INFO *myrg_parent_open(const char *parent_name,
89  int (*callback)(void*, const char*),
90  void *callback_param);
91 extern int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
92  MI_INFO *(*callback)(void*),
93  void *callback_param,
94  my_bool *need_compat_check);
95 extern int myrg_detach_children(MYRG_INFO *m_info);
96 extern int myrg_panic(enum ha_panic_function function);
97 extern int myrg_rfirst(MYRG_INFO *file,uchar *buf,int inx);
98 extern int myrg_rlast(MYRG_INFO *file,uchar *buf,int inx);
99 extern int myrg_rnext(MYRG_INFO *file,uchar *buf,int inx);
100 extern int myrg_rprev(MYRG_INFO *file,uchar *buf,int inx);
101 extern int myrg_rnext_same(MYRG_INFO *file,uchar *buf);
102 extern int myrg_rkey(MYRG_INFO *info,uchar *buf,int inx, const uchar *key,
103  key_part_map keypart_map, enum ha_rkey_function search_flag);
104 extern int myrg_rrnd(MYRG_INFO *file,uchar *buf,ulonglong pos);
105 extern int myrg_rsame(MYRG_INFO *file,uchar *record,int inx);
106 extern int myrg_update(MYRG_INFO *file,const uchar *old,uchar *new_rec);
107 extern int myrg_write(MYRG_INFO *info,uchar *rec);
108 extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag);
109 extern int myrg_lock_database(MYRG_INFO *file,int lock_type);
110 extern int myrg_create(const char *name, const char **table_names,
111  uint insert_method, my_bool fix_names);
112 extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function,
113  void *extra_arg);
114 extern int myrg_reset(MYRG_INFO *info);
115 extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv);
116 extern ha_rows myrg_records_in_range(MYRG_INFO *info, int inx,
117  key_range *min_key, key_range *max_key);
118 extern ha_rows myrg_records(MYRG_INFO *info);
119 
120 extern ulonglong myrg_position(MYRG_INFO *info);
121 #ifdef __cplusplus
122 }
123 #endif
124 #endif