myisammrg.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* Copyright (c) 2000-2002, 2004, 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc.
  2. Use is subject to license terms.
  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. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  13. /* This file should be included when using merge_isam_funktions */
  14. #ifndef _myisammrg_h
  15. #define _myisammrg_h
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #ifndef _my_base_h
  20. #include <my_base.h>
  21. #endif
  22. #ifndef _myisam_h
  23. #include <myisam.h>
  24. #endif
  25. #include <queues.h>
  26. #define MYRG_NAME_EXT ".MRG"
  27. #define MYRG_NAME_TMPEXT ".MRG_TMP"
  28. /* In which table to INSERT rows */
  29. #define MERGE_INSERT_DISABLED 0
  30. #define MERGE_INSERT_TO_FIRST 1
  31. #define MERGE_INSERT_TO_LAST 2
  32. extern TYPELIB merge_insert_method;
  33. /* Param to/from myrg_info */
  34. typedef struct st_mymerge_info /* Struct from h_info */
  35. {
  36. ulonglong records; /* Records in database */
  37. ulonglong deleted; /* Deleted records in database */
  38. ulonglong recpos; /* Pos for last used record */
  39. ulonglong data_file_length;
  40. ulonglong dupp_key_pos; /* Offset of the Duplicate key in the merge table */
  41. uint reclength; /* Recordlength */
  42. int errkey; /* With key was dupplicated on err */
  43. uint options; /* HA_OPTION_... used */
  44. ulong *rec_per_key; /* for sql optimizing */
  45. } MYMERGE_INFO;
  46. typedef struct st_myrg_table_info
  47. {
  48. struct st_myisam_info *table;
  49. ulonglong file_offset;
  50. } MYRG_TABLE;
  51. typedef struct st_myrg_info
  52. {
  53. MYRG_TABLE *open_tables,*current_table,*end_table,*last_used_table;
  54. ulonglong records; /* records in tables */
  55. ulonglong del; /* Removed records */
  56. ulonglong data_file_length;
  57. ulong cache_size;
  58. uint merge_insert_method;
  59. uint tables,options,reclength,keys;
  60. my_bool cache_in_use;
  61. /* If MERGE children attached to parent. See top comment in ha_myisammrg.cc */
  62. my_bool children_attached;
  63. LIST open_list;
  64. QUEUE by_key;
  65. ulong *rec_per_key_part; /* for sql optimizing */
  66. mysql_mutex_t mutex;
  67. } MYRG_INFO;
  68. /* Prototypes for merge-functions */
  69. extern int myrg_close(MYRG_INFO *file);
  70. extern int myrg_delete(MYRG_INFO *file,const uchar *buff);
  71. extern MYRG_INFO *myrg_open(const char *name,int mode,int wait_if_locked);
  72. extern MYRG_INFO *myrg_parent_open(const char *parent_name,
  73. int (*callback)(void*, const char*),
  74. void *callback_param);
  75. extern int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
  76. MI_INFO *(*callback)(void*),
  77. void *callback_param,
  78. my_bool *need_compat_check);
  79. extern int myrg_detach_children(MYRG_INFO *m_info);
  80. extern int myrg_panic(enum ha_panic_function function);
  81. extern int myrg_rfirst(MYRG_INFO *file,uchar *buf,int inx);
  82. extern int myrg_rlast(MYRG_INFO *file,uchar *buf,int inx);
  83. extern int myrg_rnext(MYRG_INFO *file,uchar *buf,int inx);
  84. extern int myrg_rprev(MYRG_INFO *file,uchar *buf,int inx);
  85. extern int myrg_rnext_same(MYRG_INFO *file,uchar *buf);
  86. extern int myrg_rkey(MYRG_INFO *info,uchar *buf,int inx, const uchar *key,
  87. key_part_map keypart_map, enum ha_rkey_function search_flag);
  88. extern int myrg_rrnd(MYRG_INFO *file,uchar *buf,ulonglong pos);
  89. extern int myrg_rsame(MYRG_INFO *file,uchar *record,int inx);
  90. extern int myrg_update(MYRG_INFO *file,const uchar *old,uchar *new_rec);
  91. extern int myrg_write(MYRG_INFO *info,uchar *rec);
  92. extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag);
  93. extern int myrg_lock_database(MYRG_INFO *file,int lock_type);
  94. extern int myrg_create(const char *name, const char **table_names,
  95. uint insert_method, my_bool fix_names);
  96. extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function,
  97. void *extra_arg);
  98. extern int myrg_reset(MYRG_INFO *info);
  99. extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv);
  100. extern ha_rows myrg_records_in_range(MYRG_INFO *info, int inx,
  101. key_range *min_key, key_range *max_key);
  102. extern ha_rows myrg_records(MYRG_INFO *info);
  103. extern ulonglong myrg_position(MYRG_INFO *info);
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107. #endif