Eneboo - Documentación para desarrolladores
src/libmysql_std/include/nisam.h
Ir a la documentación de este archivo.
00001 /* Copyright (C) 2000 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; either version 2 of the License, or
00006    (at your option) any later version.
00007 
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012 
00013    You should have received a copy of the GNU General Public License
00014    along with this program; if not, write to the Free Software
00015    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00016 
00017 /* This file should be included when using nisam_funktions */
00018 /* Author: Michael Widenius */
00019 
00020 #ifndef _nisam_h
00021 #define _nisam_h
00022 #ifdef  __cplusplus
00023 extern "C" {
00024 #endif
00025 
00026 #ifndef _my_base_h
00027 #include <my_base.h>
00028 #endif
00029         /* defines used by nisam-funktions */
00030 
00031 #define N_MAXKEY        16              /* Max allowed keys */
00032 #define N_MAXKEY_SEG    16              /* Max segments for key */
00033 #define N_MAX_KEY_LENGTH 256            /* May be increased up to 500 */
00034 #define N_MAX_KEY_BUFF   (N_MAX_KEY_LENGTH+N_MAXKEY_SEG+sizeof(double)-1)
00035 #define N_MAX_POSSIBLE_KEY_BUFF 500+9
00036 
00037 #define N_NAME_IEXT     ".ISM"
00038 #define N_NAME_DEXT     ".ISD"
00039 #define NI_POS_ERROR    (~ (ulong) 0)
00040 
00041 
00042         /* Param to/from nisam_info */
00043 
00044 typedef struct st_n_isaminfo            /* Struct from h_info */
00045 {
00046   ulong records;                        /* Records in database */
00047   ulong deleted;                        /* Deleted records in database */
00048   ulong recpos;                         /* Pos for last used record */
00049   ulong newrecpos;                      /* Pos if we write new record */
00050   ulong dupp_key_pos;                   /* Position to record with dupp key */
00051   ulong data_file_length,               /* Length of data file */
00052         max_data_file_length,
00053         index_file_length,
00054         max_index_file_length,
00055         delete_length;
00056   uint  reclength;                      /* Recordlength */
00057   uint  mean_reclength;                 /* Mean recordlength (if packed) */
00058   uint  keys;                           /* How many keys used */
00059   uint  options;                        /* HA_OPTION_... used */
00060   int   errkey,                         /* With key was dupplicated on err */
00061         sortkey;                        /* clustered by this key */
00062   File  filenr;                         /* (uniq) filenr for datafile */
00063   time_t create_time;                   /* When table was created */
00064   time_t isamchk_time;
00065   time_t update_time;
00066   ulong *rec_per_key;                   /* for sql optimizing */
00067 } N_ISAMINFO;
00068 
00069 
00070         /* Info saved on file for each info-part */
00071 
00072 #ifdef __WATCOMC__
00073 #pragma pack(2)
00074 #define uint uint16                     /* Same format as in MSDOS */
00075 #endif
00076 
00077 #ifdef __ZTC__
00078 #pragma ZTC align 2
00079 #define uint uint16                     /* Same format as in MSDOS */
00080 #endif
00081 
00082 typedef struct st_n_save_keyseg         /* Key-portion */
00083 {
00084   uint8  type;                          /* Typ av nyckel (f|r sort) */
00085   uint8  flag;                          /* HA_DIFF_LENGTH */
00086   uint16 start;                         /* Start of key in record */
00087   uint16 length;                        /* Keylength */
00088 } N_SAVE_KEYSEG;
00089 
00090 typedef struct st_n_save_keydef /* Key definition with create & info */
00091 {
00092   uint8 flag;                           /* NOSAME, PACK_USED */
00093   uint8 keysegs;                        /* Number of key-segment */
00094   uint16 block_length;                  /* Length of keyblock (auto) */
00095   uint16 keylength;                     /* Tot length of keyparts (auto) */
00096   uint16 minlength;                     /* min length of (packed) key (auto) */
00097   uint16 maxlength;                     /* max length of (packed) key (auto) */
00098 } N_SAVE_KEYDEF;
00099 
00100 typedef struct st_n_save_recinfo        /* Info of record */
00101 {
00102   int16  type;                          /* en_fieldtype */
00103   uint16 length;                        /* length of field */
00104 } N_SAVE_RECINFO;
00105 
00106 
00107 #ifdef __ZTC__
00108 #pragma ZTC align
00109 #undef uint
00110 #endif
00111 
00112 #ifdef __WATCOMC__
00113 #pragma pack()
00114 #undef uint
00115 #endif
00116 
00117 
00118 struct st_isam_info;                    /* For referense */
00119 
00120 #ifndef ISAM_LIBRARY
00121 typedef struct st_isam_info N_INFO;
00122 #endif
00123 
00124 typedef struct st_n_keyseg              /* Key-portion */
00125 {
00126   N_SAVE_KEYSEG base;
00127 } N_KEYSEG;
00128 
00129 
00130 typedef struct st_n_keydef              /* Key definition with open & info */
00131 {
00132   N_SAVE_KEYDEF base;
00133   N_KEYSEG seg[N_MAXKEY_SEG+1];
00134   int (*bin_search)(struct st_isam_info *info,struct st_n_keydef *keyinfo,
00135                     uchar *page,uchar *key,
00136                     uint key_len,uint comp_flag,uchar * *ret_pos,
00137                     uchar *buff);
00138   uint (*get_key)(struct st_n_keydef *keyinfo,uint nod_flag,uchar * *page,
00139                   uchar *key);
00140 } N_KEYDEF;
00141 
00142 
00143 typedef struct st_decode_tree           /* Decode huff-table */
00144 {
00145   uint16 *table;
00146   uint   quick_table_bits;
00147   byte   *intervalls;
00148 } DECODE_TREE;
00149 
00150 
00151 struct st_bit_buff;
00152 
00153 typedef struct st_n_recinfo             /* Info of record */
00154 {
00155   N_SAVE_RECINFO base;
00156 #ifndef NOT_PACKED_DATABASES
00157   void (*unpack)(struct st_n_recinfo *rec,struct st_bit_buff *buff,
00158                  uchar *start,uchar *end);
00159   enum en_fieldtype base_type;
00160   uint space_length_bits,pack_type;
00161   DECODE_TREE *huff_tree;
00162 #endif
00163 } N_RECINFO;
00164 
00165 
00166 extern my_string nisam_log_filename;            /* Name of logfile */
00167 extern uint nisam_block_size;
00168 extern my_bool nisam_flush;
00169 
00170         /* Prototypes for nisam-functions */
00171 
00172 extern int nisam_close(struct st_isam_info *file);
00173 extern int nisam_delete(struct st_isam_info *file,const byte *buff);
00174 extern struct st_isam_info *nisam_open(const char *name,int mode,
00175                                     uint wait_if_locked);
00176 extern int nisam_panic(enum ha_panic_function function);
00177 extern int nisam_rfirst(struct st_isam_info *file,byte *buf,int inx);
00178 extern int nisam_rkey(struct st_isam_info *file,byte *buf,int inx,
00179                    const byte *key,
00180                    uint key_len, enum ha_rkey_function search_flag);
00181 extern int nisam_rlast(struct st_isam_info *file,byte *buf,int inx);
00182 extern int nisam_rnext(struct st_isam_info *file,byte *buf,int inx);
00183 extern int nisam_rprev(struct st_isam_info *file,byte *buf,int inx);
00184 extern int nisam_rrnd(struct st_isam_info *file,byte *buf,ulong pos);
00185 extern int nisam_rsame(struct st_isam_info *file,byte *record,int inx);
00186 extern int nisam_rsame_with_pos(struct st_isam_info *file,byte *record,
00187                              int inx,ulong pos);
00188 extern int nisam_update(struct st_isam_info *file,const byte *old,
00189                      const byte *new_record);
00190 extern int nisam_write(struct st_isam_info *file,const byte *buff);
00191 extern int nisam_info(struct st_isam_info *file,N_ISAMINFO *x,int flag);
00192 extern ulong nisam_position(struct st_isam_info *info);
00193 extern int nisam_lock_database(struct st_isam_info *file,int lock_type);
00194 extern int nisam_create(const char *name,uint keys,N_KEYDEF *keyinfo,
00195                      N_RECINFO *recinfo,ulong records,
00196                      ulong reloc,uint flags,uint options,
00197                      ulong data_file_length);
00198 extern int nisam_extra(struct st_isam_info *file,
00199                     enum ha_extra_function function);
00200 extern ulong nisam_records_in_range(struct st_isam_info *info,int inx,
00201                                  const byte *start_key,uint start_key_len,
00202                                  enum ha_rkey_function start_search_flag,
00203                                  const byte *end_key,uint end_key_len,
00204                                  enum ha_rkey_function end_search_flag);
00205 extern int nisam_log(int activate_log);
00206 extern int nisam_is_changed(struct st_isam_info *info);
00207 extern uint _calc_blob_length(uint length , const byte *pos);
00208 
00209 #ifdef  __cplusplus
00210 }
00211 #endif
00212 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'