~drizzle-trunk/drizzle/development

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