myisammrg.h 3.84 KB
Newer Older
unknown's avatar
unknown committed
1
/* Copyright (C) 2000 MySQL AB
unknown's avatar
 
unknown committed
2

unknown's avatar
unknown committed
3 4 5 6
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
unknown's avatar
 
unknown committed
7

unknown's avatar
unknown committed
8
   This program is distributed in the hope that it will be useful,
unknown's avatar
unknown committed
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
unknown's avatar
unknown committed
10 11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
unknown's avatar
 
unknown committed
12

unknown's avatar
unknown committed
13 14 15
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
unknown's avatar
unknown committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

/* This file should be included when using merge_isam_funktions */

#ifndef _myisammrg_h
#define _myisammrg_h
#ifdef	__cplusplus
extern "C" {
#endif

#ifndef _my_base_h
#include <my_base.h>
#endif
#ifndef _myisam_h
#include <myisam.h>
#endif

unknown's avatar
 
unknown committed
32 33
#include <queues.h>

unknown's avatar
unknown committed
34 35
#define MYRG_NAME_EXT	".MRG"

36 37 38 39 40 41 42
/* In which table to INSERT rows */
#define MERGE_INSERT_DISABLED	0
#define MERGE_INSERT_TO_FIRST	1
#define MERGE_INSERT_TO_LAST	2

extern TYPELIB merge_insert_method;

unknown's avatar
unknown committed
43 44 45 46 47 48 49 50 51 52
	/* Param to/from myrg_info */

typedef struct st_mymerge_info		/* Struct from h_info */
{
  ulonglong records;			/* Records in database */
  ulonglong deleted;			/* Deleted records in database */
  ulonglong recpos;			/* Pos for last used record */
  ulonglong data_file_length;
  uint	reclength;			/* Recordlength */
  int	errkey;				/* With key was dupplicated on err */
53
  uint	options;			/* HA_OPTION_... used */
unknown's avatar
unknown committed
54
  ulong *rec_per_key;			/* for sql optimizing */
unknown's avatar
unknown committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68
} MYMERGE_INFO;

typedef struct st_myrg_table_info
{
  struct st_myisam_info *table;
  ulonglong file_offset;
} MYRG_TABLE;

typedef struct st_myrg_info
{
  MYRG_TABLE *open_tables,*current_table,*end_table,*last_used_table;
  ulonglong records;			/* records in tables */
  ulonglong del;			/* Removed records */
  ulonglong data_file_length;
unknown's avatar
unknown committed
69 70
  ulong  cache_size;
  uint	 merge_insert_method;
unknown's avatar
unknown committed
71
  uint	 tables,options,reclength,keys;
unknown's avatar
unknown committed
72
  my_bool cache_in_use;
unknown's avatar
unknown committed
73 74
  LIST	 open_list;
  QUEUE  by_key;
unknown's avatar
unknown committed
75
  ulong *rec_per_key_part;			/* for sql optimizing */
unknown's avatar
unknown committed
76 77 78 79 80 81 82 83 84 85
} MYRG_INFO;


	/* Prototypes for merge-functions */

extern int myrg_close(MYRG_INFO *file);
extern int myrg_delete(MYRG_INFO *file,const byte *buff);
extern MYRG_INFO *myrg_open(const char *name,int mode,int wait_if_locked);
extern int myrg_panic(enum ha_panic_function function);
extern int myrg_rfirst(MYRG_INFO *file,byte *buf,int inx);
unknown's avatar
 
unknown committed
86 87 88
extern int myrg_rlast(MYRG_INFO *file,byte *buf,int inx);
extern int myrg_rnext(MYRG_INFO *file,byte *buf,int inx);
extern int myrg_rprev(MYRG_INFO *file,byte *buf,int inx);
unknown's avatar
unknown committed
89
extern int myrg_rnext_same(MYRG_INFO *file,byte *buf);
unknown's avatar
unknown committed
90 91 92 93 94
extern int myrg_rkey(MYRG_INFO *file,byte *buf,int inx,const byte *key,
		       uint key_len, enum ha_rkey_function search_flag);
extern int myrg_rrnd(MYRG_INFO *file,byte *buf,ulonglong pos);
extern int myrg_rsame(MYRG_INFO *file,byte *record,int inx);
extern int myrg_update(MYRG_INFO *file,const byte *old,byte *new_rec);
95
extern int myrg_write(MYRG_INFO *info,byte *rec);
unknown's avatar
unknown committed
96 97
extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag);
extern int myrg_lock_database(MYRG_INFO *file,int lock_type);
98 99
extern int myrg_create(const char *name, const char **table_names,
                       uint insert_method, my_bool fix_names);
unknown's avatar
unknown committed
100 101
extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function,
		      void *extra_arg);
unknown's avatar
unknown committed
102
extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv);
unknown's avatar
unknown committed
103 104 105 106 107 108 109 110 111 112 113
extern ha_rows myrg_records_in_range(MYRG_INFO *info,int inx,
				    const byte *start_key,uint start_key_len,
				    enum ha_rkey_function start_search_flag,
				    const byte *end_key,uint end_key_len,
				    enum ha_rkey_function end_search_flag);

extern ulonglong myrg_position(MYRG_INFO *info);
#ifdef	__cplusplus
}
#endif
#endif