~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/myisam.h

  • Committer: Jay Pipes
  • Date: 2008-12-18 15:55:03 UTC
  • mto: This revision was merged to the branch mainline in revision 717.
  • Revision ID: jpipes@serialcoder-20081218155503-u45ygyunrdyyvquq
Fix for Bug#308457.  Gave UTF8 enclosure and escape character on LOAD DATA INFILE and changed the error message to be more descriptive

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* This file should be included when using myisam_funktions */
17
17
 
18
 
#ifndef PLUGIN_MYISAM_MYISAM_H
19
 
#define PLUGIN_MYISAM_MYISAM_H
20
 
 
21
 
#include <drizzled/identifier.h>
22
 
 
23
 
#include <drizzled/key_map.h>
 
18
#ifndef _myisam_h
 
19
#define _myisam_h
 
20
#ifdef  __cplusplus
 
21
extern "C" {
 
22
#endif
24
23
 
25
24
#include <drizzled/base.h>
26
25
#ifndef _m_ctype_h
27
 
#include <drizzled/charset_info.h>
 
26
#include <mystrings/m_ctype.h>
28
27
#endif
29
28
#ifndef _keycache_h
30
29
#include "keycache.h"
31
30
#endif
32
 
#include <plugin/myisam/my_handler.h>
33
 
#include <drizzled/internal/iocache.h>
 
31
#include <storage/myisam/my_handler.h>
 
32
#include <mysys/iocache.h>
34
33
 
35
34
/*
36
35
  Limit max keys according to HA_MAX_POSSIBLE_KEY
124
123
 
125
124
typedef struct st_mi_isaminfo           /* Struct from h_info */
126
125
{
127
 
  drizzled::ha_rows records;                    /* Records in database */
128
 
  drizzled::ha_rows deleted;                    /* Deleted records in database */
129
 
  drizzled::internal::my_off_t recpos;                  /* Pos for last used record */
130
 
  drizzled::internal::my_off_t newrecpos;                       /* Pos if we write new record */
131
 
  drizzled::internal::my_off_t dupp_key_pos;            /* Position to record with dupp key */
132
 
  drizzled::internal::my_off_t data_file_length,                /* Length of data file */
 
126
  ha_rows records;                      /* Records in database */
 
127
  ha_rows deleted;                      /* Deleted records in database */
 
128
  my_off_t recpos;                      /* Pos for last used record */
 
129
  my_off_t newrecpos;                   /* Pos if we write new record */
 
130
  my_off_t dupp_key_pos;                /* Position to record with dupp key */
 
131
  my_off_t data_file_length,            /* Length of data file */
133
132
           max_data_file_length,
134
133
           index_file_length,
135
134
           max_index_file_length,
143
142
  uint  options;                        /* HA_OPTION_... used */
144
143
  int   errkey,                         /* With key was dupplicated on err */
145
144
        sortkey;                        /* clustered by this key */
146
 
  int   filenr;                         /* (uniq) filenr for datafile */
 
145
  File  filenr;                         /* (uniq) filenr for datafile */
147
146
  time_t create_time;                   /* When table was created */
148
147
  time_t check_time;
149
148
  time_t update_time;
156
155
typedef struct st_mi_create_info
157
156
{
158
157
  const char *index_file_name, *data_file_name; /* If using symlinks */
159
 
  drizzled::ha_rows max_rows;
160
 
  drizzled::ha_rows reloc_rows;
 
158
  ha_rows max_rows;
 
159
  ha_rows reloc_rows;
161
160
  uint64_t auto_increment;
162
161
  uint64_t data_file_length;
163
162
  uint64_t key_file_length;
164
163
  uint32_t old_options;
165
164
  uint8_t language;
166
165
  bool with_auto_increment;
167
 
 
168
 
  st_mi_create_info():
169
 
    index_file_name(0),
170
 
    data_file_name(0),
171
 
    max_rows(0),
172
 
    reloc_rows(0),
173
 
    auto_increment(0),
174
 
    data_file_length(0),
175
 
    key_file_length(0),
176
 
    old_options(0),
177
 
    language(0),
178
 
    with_auto_increment(0)
179
 
  { }
180
 
 
181
166
} MI_CREATE_INFO;
182
167
 
183
168
struct st_myisam_info;                  /* For referense */
244
229
  type, length, null_bit and null_pos
245
230
*/
246
231
 
247
 
namespace drizzled
248
 
{
249
 
 
250
232
typedef struct st_columndef             /* column information */
251
233
{
252
234
  int16_t  type;                                /* en_fieldtype */
258
240
#ifndef NOT_PACKED_DATABASES
259
241
  void (*unpack)(struct st_columndef *rec,struct st_mi_bit_buff *buff,
260
242
                 unsigned char *start,unsigned char *end);
261
 
  enum drizzled::en_fieldtype base_type;
 
243
  enum en_fieldtype base_type;
262
244
  uint32_t space_length_bits,pack_type;
263
245
  MI_DECODE_TREE *huff_tree;
264
246
#endif
265
247
} MI_COLUMNDEF;
266
248
 
267
 
}
268
 
 
269
249
 
270
250
extern char * myisam_log_filename;              /* Name of logfile */
271
251
extern uint32_t myisam_block_size;
272
252
extern uint32_t myisam_concurrent_insert;
273
 
extern uint32_t myisam_bulk_insert_tree_size; 
274
 
extern uint32_t data_pointer_size;
 
253
extern bool myisam_flush,myisam_delay_key_write,myisam_single_user;
 
254
extern my_off_t myisam_max_temp_length;
 
255
extern uint32_t myisam_bulk_insert_tree_size, myisam_data_pointer_size;
275
256
 
276
257
        /* Prototypes for myisam-functions */
277
258
 
278
259
extern int mi_close(struct st_myisam_info *file);
279
260
extern int mi_delete(struct st_myisam_info *file,const unsigned char *buff);
280
 
extern struct st_myisam_info *mi_open(const drizzled::identifier::Table &identifier,
281
 
                                      int mode,
 
261
extern struct st_myisam_info *mi_open(const char *name,int mode,
282
262
                                      uint32_t wait_if_locked);
283
 
extern int mi_panic(enum drizzled::ha_panic_function function);
 
263
extern int mi_panic(enum ha_panic_function function);
284
264
extern int mi_rfirst(struct st_myisam_info *file,unsigned char *buf,int inx);
285
265
extern int mi_rkey(MI_INFO *info, unsigned char *buf, int inx, const unsigned char *key,
286
 
                   drizzled::key_part_map keypart_map, enum drizzled::ha_rkey_function search_flag);
 
266
                   key_part_map keypart_map, enum ha_rkey_function search_flag);
287
267
extern int mi_rlast(struct st_myisam_info *file,unsigned char *buf,int inx);
288
268
extern int mi_rnext(struct st_myisam_info *file,unsigned char *buf,int inx);
289
269
extern int mi_rnext_same(struct st_myisam_info *info, unsigned char *buf);
290
270
extern int mi_rprev(struct st_myisam_info *file,unsigned char *buf,int inx);
291
 
extern int mi_rrnd(struct st_myisam_info *file,unsigned char *buf, drizzled::internal::my_off_t pos);
 
271
extern int mi_rrnd(struct st_myisam_info *file,unsigned char *buf, my_off_t pos);
292
272
extern int mi_scan_init(struct st_myisam_info *file);
293
273
extern int mi_scan(struct st_myisam_info *file,unsigned char *buf);
294
274
extern int mi_rsame(struct st_myisam_info *file,unsigned char *record,int inx);
 
275
extern int mi_rsame_with_pos(struct st_myisam_info *file,unsigned char *record,
 
276
                             int inx, my_off_t pos);
295
277
extern int mi_update(struct st_myisam_info *file,const unsigned char *old,
296
278
                     unsigned char *new_record);
297
279
extern int mi_write(struct st_myisam_info *file,unsigned char *buff);
298
 
extern drizzled::internal::my_off_t mi_position(struct st_myisam_info *file);
 
280
extern my_off_t mi_position(struct st_myisam_info *file);
299
281
extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint32_t flag);
300
282
extern int mi_lock_database(struct st_myisam_info *file,int lock_type);
301
283
extern int mi_create(const char *name,uint32_t keys,MI_KEYDEF *keydef,
302
 
                     uint32_t columns, drizzled::MI_COLUMNDEF *columndef,
 
284
                     uint32_t columns, MI_COLUMNDEF *columndef,
303
285
                     uint32_t uniques, MI_UNIQUEDEF *uniquedef,
304
286
                     MI_CREATE_INFO *create_info, uint32_t flags);
305
287
extern int mi_delete_table(const char *name);
306
288
extern int mi_rename(const char *from, const char *to);
307
289
extern int mi_extra(struct st_myisam_info *file,
308
 
                    enum drizzled::ha_extra_function function,
 
290
                    enum ha_extra_function function,
309
291
                    void *extra_arg);
310
292
extern int mi_reset(struct st_myisam_info *file);
311
 
extern drizzled::ha_rows mi_records_in_range(MI_INFO *info, int inx,
312
 
                                   drizzled::key_range *min_key, drizzled::key_range *max_key);
 
293
extern ha_rows mi_records_in_range(MI_INFO *info, int inx,
 
294
                                   key_range *min_key, key_range *max_key);
313
295
extern int mi_log(int activate_log);
 
296
extern int mi_is_changed(struct st_myisam_info *info);
314
297
extern int mi_delete_all_rows(struct st_myisam_info *info);
315
298
extern ulong _mi_calc_blob_length(uint32_t length , const unsigned char *pos);
316
299
extern uint32_t mi_get_pointer_length(uint64_t file_length, uint32_t def);
365
348
 
366
349
#define T_REP_ANY               (T_REP | T_REP_BY_SORT | T_REP_PARALLEL)
367
350
 
 
351
/*
 
352
  Flags used by myisamchk.c or/and ha_myisam.cc that are NOT passed
 
353
  to mi_check.c follows:
 
354
*/
 
355
 
 
356
#define TT_USEFRM               1
 
357
#define TT_FOR_UPGRADE          2
 
358
 
368
359
#define O_NEW_INDEX     1               /* Bits set in out_flag */
369
360
#define O_NEW_DATA      2
370
361
#define O_DATA_LOST     4
402
393
  uint64_t max_data_file_length;
403
394
  uint64_t keys_in_use;
404
395
  uint64_t max_record_length;
405
 
  drizzled::internal::my_off_t search_after_block;
406
 
  drizzled::internal::my_off_t new_file_pos,key_file_blocks;
407
 
  drizzled::internal::my_off_t keydata,totaldata,key_blocks,start_check_pos;
408
 
  drizzled::ha_rows total_records,total_deleted;
409
 
  drizzled::internal::ha_checksum record_checksum,glob_crc;
410
 
  uint64_t use_buffers;
411
 
  size_t read_buffer_length, write_buffer_length,
412
 
         sort_buffer_length, sort_key_blocks;
 
396
  my_off_t search_after_block;
 
397
  my_off_t new_file_pos,key_file_blocks;
 
398
  my_off_t keydata,totaldata,key_blocks,start_check_pos;
 
399
  ha_rows total_records,total_deleted;
 
400
  ha_checksum record_checksum,glob_crc;
 
401
  ulong use_buffers,read_buffer_length,write_buffer_length,
 
402
        sort_buffer_length,sort_key_blocks;
413
403
  uint32_t out_flag,warning_printed,error_printed,verbose;
414
404
  uint32_t opt_sort_key,total_files,max_level;
415
405
  uint32_t testflag, key_cache_block_size;
418
408
  bool retry_repair, force_sort;
419
409
  char temp_filename[FN_REFLEN],*isam_file_name;
420
410
  int tmpfile_createflag;
421
 
  drizzled::myf myf_rw;
422
 
  drizzled::internal::IO_CACHE read_cache;
 
411
  myf myf_rw;
 
412
  IO_CACHE read_cache;
423
413
 
424
414
  /*
425
415
    The next two are used to collect statistics, see update_key_parts for
428
418
  uint64_t unique_count[MI_MAX_KEY_SEG+1];
429
419
  uint64_t notnull_count[MI_MAX_KEY_SEG+1];
430
420
 
431
 
  drizzled::internal::ha_checksum key_crc[HA_MAX_POSSIBLE_KEY];
 
421
  ha_checksum key_crc[HA_MAX_POSSIBLE_KEY];
432
422
  ulong rec_per_key_part[MI_MAX_KEY_SEG*HA_MAX_POSSIBLE_KEY];
433
423
  void *session;
434
424
  const char *db_name, *table_name;
438
428
 
439
429
typedef struct st_sort_info
440
430
{
441
 
  drizzled::internal::my_off_t filelength,dupp,buff_length;
442
 
  drizzled::ha_rows max_records;
 
431
  my_off_t filelength,dupp,buff_length;
 
432
  ha_rows max_records;
443
433
  uint32_t current_key, total_keys;
444
 
  drizzled::myf myf_rw;
445
 
  enum drizzled::data_file_type new_data_file_type;
 
434
  myf myf_rw;
 
435
  enum data_file_type new_data_file_type;
446
436
  MI_INFO *info;
447
437
  MI_CHECK *param;
448
438
  unsigned char *buff;
465
455
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name);
466
456
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
467
457
                      const char * name, int rep_quick);
 
458
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
 
459
                      const char * name, int rep_quick);
468
460
int change_to_newfile(const char * filename, const char * old_ext,
469
461
                      const char * new_ext, uint32_t raid_chunks,
470
 
                      drizzled::myf myflags);
 
462
                      myf myflags);
471
463
void lock_memory(MI_CHECK *param);
472
464
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
473
465
                               bool repair);
475
467
void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part,
476
468
                      uint64_t *unique, uint64_t *notnull,
477
469
                      uint64_t records);
478
 
int filecopy(MI_CHECK *param, int to,int from,drizzled::internal::my_off_t start,
479
 
             drizzled::internal::my_off_t length, const char *type);
480
 
int movepoint(MI_INFO *info,unsigned char *record,drizzled::internal::my_off_t oldpos,
481
 
              drizzled::internal::my_off_t newpos, uint32_t prot_key);
 
470
int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
 
471
             my_off_t length, const char *type);
 
472
int movepoint(MI_INFO *info,unsigned char *record,my_off_t oldpos,
 
473
              my_off_t newpos, uint32_t prot_key);
482
474
int write_data_suffix(SORT_INFO *sort_info, bool fix_datafile);
483
475
int test_if_almost_full(MI_INFO *info);
484
 
bool mi_test_if_sort_rep(MI_INFO *info, drizzled::ha_rows rows, uint64_t key_map,
 
476
int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename);
 
477
bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, uint64_t key_map,
485
478
                            bool force);
486
479
 
487
 
int mi_init_bulk_insert(MI_INFO *info, uint32_t cache_size, drizzled::ha_rows rows);
 
480
int mi_init_bulk_insert(MI_INFO *info, uint32_t cache_size, ha_rows rows);
488
481
void mi_flush_bulk_insert(MI_INFO *info, uint32_t inx);
489
482
void mi_end_bulk_insert(MI_INFO *info);
 
483
int mi_assign_to_key_cache(MI_INFO *info, uint64_t key_map,
 
484
                           KEY_CACHE *key_cache);
 
485
void mi_change_key_cache(KEY_CACHE *old_key_cache,
 
486
                         KEY_CACHE *new_key_cache);
490
487
int mi_preload(MI_INFO *info, uint64_t key_map, bool ignore_leaves);
491
488
 
492
 
#endif /* PLUGIN_MYISAM_MYISAM_H */
 
489
#ifdef  __cplusplus
 
490
}
 
491
#endif
 
492
#endif