~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/csv/ha_tina.cc

  • Committer: Jay Pipes
  • Date: 2008-07-17 19:43:08 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717194308-l9i4ti57gikm2qbv
Phase 1 removal of DBUG in mysys

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
 -Brian
42
42
*/
43
 
#include <drizzled/common_includes.h>
 
43
 
 
44
#ifdef USE_PRAGMA_IMPLEMENTATION
 
45
#pragma implementation        // gcc: Class implementation
 
46
#endif
 
47
 
 
48
#include "mysql_priv.h"
 
49
#include <mysql/plugin.h>
44
50
#include "ha_tina.h"
45
51
 
46
52
 
47
53
/*
48
 
  unsigned char + unsigned char + uint64_t + uint64_t + uint64_t + uint64_t + unsigned char
 
54
  uchar + uchar + uint64_t + uint64_t + uint64_t + uint64_t + uchar
49
55
*/
50
 
#define META_BUFFER_SIZE sizeof(unsigned char) + sizeof(unsigned char) + sizeof(uint64_t) \
51
 
  + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(unsigned char)
 
56
#define META_BUFFER_SIZE sizeof(uchar) + sizeof(uchar) + sizeof(uint64_t) \
 
57
  + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(uchar)
52
58
#define TINA_CHECK_HEADER 254 // The number we use to determine corruption
53
59
#define BLOB_MEMROOT_ALLOC_SIZE 8192
54
60
 
58
64
#define CSM_EXT ".CSM"               // Meta file
59
65
 
60
66
 
61
 
static TINA_SHARE *get_share(const char *table_name, Table *table);
 
67
static TINA_SHARE *get_share(const char *table_name, TABLE *table);
62
68
static int free_share(TINA_SHARE *share);
63
69
static int read_meta_file(File meta_file, ha_rows *rows);
64
70
static int write_meta_file(File meta_file, ha_rows rows, bool dirty);
91
97
  return ( a->begin > b->begin ? 1 : ( a->begin < b->begin ? -1 : 0 ) );
92
98
}
93
99
 
94
 
static unsigned char* tina_get_key(TINA_SHARE *share, size_t *length,
 
100
static uchar* tina_get_key(TINA_SHARE *share, size_t *length,
95
101
                          bool not_used __attribute__((unused)))
96
102
{
97
103
  *length=share->table_name_length;
98
 
  return (unsigned char*) share->table_name;
 
104
  return (uchar*) share->table_name;
99
105
}
100
106
 
101
107
static int tina_init_func(void *p)
103
109
  handlerton *tina_hton;
104
110
 
105
111
  tina_hton= (handlerton *)p;
106
 
  pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST);
 
112
  VOID(pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST));
107
113
  (void) hash_init(&tina_open_tables,system_charset_info,32,0,0,
108
114
                   (hash_get_key) tina_get_key,0,0);
109
115
  tina_hton->state= SHOW_OPTION_YES;
 
116
  tina_hton->db_type= DB_TYPE_CSV_DB;
110
117
  tina_hton->create= tina_create_handler;
111
118
  tina_hton->flags= (HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES | 
112
119
                     HTON_NO_PARTITION);
113
120
  return 0;
114
121
}
115
122
 
116
 
static int tina_done_func(void *p __attribute__((unused)))
 
123
static int tina_done_func(void *p __attribute__((__unused__)))
117
124
{
118
125
  hash_free(&tina_open_tables);
119
126
  pthread_mutex_destroy(&tina_mutex);
126
133
  Simple lock controls.
127
134
*/
128
135
static TINA_SHARE *get_share(const char *table_name,
129
 
                             Table *table __attribute__((unused)))
 
136
                             TABLE *table __attribute__((__unused__)))
130
137
{
131
138
  TINA_SHARE *share;
132
139
  char meta_file_name[FN_REFLEN];
133
140
  struct stat file_stat;
134
141
  char *tmp_name;
135
 
  uint32_t length;
 
142
  uint length;
136
143
 
137
144
  pthread_mutex_lock(&tina_mutex);
138
145
  length=(uint) strlen(table_name);
142
149
    initialize its members.
143
150
  */
144
151
  if (!(share=(TINA_SHARE*) hash_search(&tina_open_tables,
145
 
                                        (unsigned char*) table_name,
 
152
                                        (uchar*) table_name,
146
153
                                       length)))
147
154
  {
148
155
    if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
149
156
                         &share, sizeof(*share),
150
157
                         &tmp_name, length+1,
151
 
                         NULL))
 
158
                         NullS))
152
159
    {
153
160
      pthread_mutex_unlock(&tina_mutex);
154
161
      return NULL;
155
162
    }
156
163
 
157
164
    share->use_count= 0;
 
165
    share->is_log_table= false;
158
166
    share->table_name_length= length;
159
167
    share->table_name= tmp_name;
160
168
    share->crashed= false;
162
170
    share->update_file_opened= false;
163
171
    share->tina_write_opened= false;
164
172
    share->data_file_version= 0;
165
 
    my_stpcpy(share->table_name, table_name);
 
173
    strmov(share->table_name, table_name);
166
174
    fn_format(share->data_file_name, table_name, "", CSV_EXT,
167
175
              MY_REPLACE_EXT|MY_UNPACK_FILENAME);
168
176
    fn_format(meta_file_name, table_name, "", CSM_EXT,
172
180
      goto error;
173
181
    share->saved_data_file_length= file_stat.st_size;
174
182
 
175
 
    if (my_hash_insert(&tina_open_tables, (unsigned char*) share))
 
183
    if (my_hash_insert(&tina_open_tables, (uchar*) share))
176
184
      goto error;
177
185
    thr_lock_init(&share->lock);
178
186
    pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
201
209
 
202
210
error:
203
211
  pthread_mutex_unlock(&tina_mutex);
204
 
  free((unsigned char*) share);
 
212
  my_free((uchar*) share, MYF(0));
205
213
 
206
214
  return NULL;
207
215
}
228
236
 
229
237
static int read_meta_file(File meta_file, ha_rows *rows)
230
238
{
231
 
  unsigned char meta_buffer[META_BUFFER_SIZE];
232
 
  unsigned char *ptr= meta_buffer;
 
239
  uchar meta_buffer[META_BUFFER_SIZE];
 
240
  uchar *ptr= meta_buffer;
233
241
 
234
 
  my_seek(meta_file, 0, MY_SEEK_SET, MYF(0));
235
 
  if (my_read(meta_file, (unsigned char*)meta_buffer, META_BUFFER_SIZE, 0)
 
242
  VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0)));
 
243
  if (my_read(meta_file, (uchar*)meta_buffer, META_BUFFER_SIZE, 0)
236
244
      != META_BUFFER_SIZE)
237
245
    return(HA_ERR_CRASHED_ON_USAGE);
238
246
 
240
248
    Parse out the meta data, we ignore version at the moment
241
249
  */
242
250
 
243
 
  ptr+= sizeof(unsigned char)*2; // Move past header
 
251
  ptr+= sizeof(uchar)*2; // Move past header
244
252
  *rows= (ha_rows)uint8korr(ptr);
245
253
  ptr+= sizeof(uint64_t); // Move past rows
246
254
  /*
250
258
  ptr+= 3*sizeof(uint64_t);
251
259
 
252
260
  /* check crashed bit and magic number */
253
 
  if ((meta_buffer[0] != (unsigned char)TINA_CHECK_HEADER) ||
 
261
  if ((meta_buffer[0] != (uchar)TINA_CHECK_HEADER) ||
254
262
      ((bool)(*ptr)== true))
255
263
    return(HA_ERR_CRASHED_ON_USAGE);
256
264
 
281
289
 
282
290
static int write_meta_file(File meta_file, ha_rows rows, bool dirty)
283
291
{
284
 
  unsigned char meta_buffer[META_BUFFER_SIZE];
285
 
  unsigned char *ptr= meta_buffer;
 
292
  uchar meta_buffer[META_BUFFER_SIZE];
 
293
  uchar *ptr= meta_buffer;
286
294
 
287
 
  *ptr= (unsigned char)TINA_CHECK_HEADER;
288
 
  ptr+= sizeof(unsigned char);
289
 
  *ptr= (unsigned char)TINA_VERSION;
290
 
  ptr+= sizeof(unsigned char);
 
295
  *ptr= (uchar)TINA_CHECK_HEADER;
 
296
  ptr+= sizeof(uchar);
 
297
  *ptr= (uchar)TINA_VERSION;
 
298
  ptr+= sizeof(uchar);
291
299
  int8store(ptr, (uint64_t)rows);
292
300
  ptr+= sizeof(uint64_t);
293
301
  memset(ptr, 0, 3*sizeof(uint64_t));
296
304
     We'll need them later.
297
305
  */
298
306
  ptr+= 3*sizeof(uint64_t);
299
 
  *ptr= (unsigned char)dirty;
 
307
  *ptr= (uchar)dirty;
300
308
 
301
 
  my_seek(meta_file, 0, MY_SEEK_SET, MYF(0));
302
 
  if (my_write(meta_file, (unsigned char *)meta_buffer, META_BUFFER_SIZE, 0)
 
309
  VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0)));
 
310
  if (my_write(meta_file, (uchar *)meta_buffer, META_BUFFER_SIZE, 0)
303
311
      != META_BUFFER_SIZE)
304
312
    return(-1);
305
313
 
364
372
      share->tina_write_opened= false;
365
373
    }
366
374
 
367
 
    hash_delete(&tina_open_tables, (unsigned char*) share);
 
375
    hash_delete(&tina_open_tables, (uchar*) share);
368
376
    thr_lock_delete(&share->lock);
369
377
    pthread_mutex_destroy(&share->mutex);
370
 
    free((unsigned char*) share);
 
378
    my_free((uchar*) share, MYF(0));
371
379
  }
372
380
  pthread_mutex_unlock(&tina_mutex);
373
381
 
442
450
  Encode a buffer into the quoted format.
443
451
*/
444
452
 
445
 
int ha_tina::encode_quote(unsigned char *buf __attribute__((unused)))
 
453
int ha_tina::encode_quote(uchar *buf __attribute__((__unused__)))
446
454
{
447
455
  char attribute_buffer[1024];
448
456
  String attribute(attribute_buffer, sizeof(attribute_buffer),
449
457
                   &my_charset_bin);
450
458
 
 
459
  my_bitmap_map *org_bitmap= dbug_tmp_use_all_columns(table, table->read_set);
451
460
  buffer.length(0);
452
461
 
453
462
  for (Field **field=table->field ; *field ; field++)
522
531
 
523
532
  //buffer.replace(buffer.length(), 0, "\n", 1);
524
533
 
 
534
  dbug_tmp_restore_column_map(table->read_set, org_bitmap);
525
535
  return (buffer.length());
526
536
}
527
537
 
544
554
      if (chain_alloced)
545
555
      {
546
556
        /* Must cast since my_malloc unlike malloc doesn't have a void ptr */
547
 
        if ((chain= (tina_set *) my_realloc((unsigned char*)chain,
 
557
        if ((chain= (tina_set *) my_realloc((uchar*)chain,
548
558
                                            chain_size, MYF(MY_WME))) == NULL)
549
559
          return -1;
550
560
      }
570
580
/*
571
581
  Scans for a row.
572
582
*/
573
 
int ha_tina::find_current_row(unsigned char *buf)
 
583
int ha_tina::find_current_row(uchar *buf)
574
584
{
575
585
  off_t end_offset, curr_offset= current_position;
576
586
  int eoln_len;
 
587
  my_bitmap_map *org_bitmap;
577
588
  int error;
578
589
  bool read_all;
579
590
 
590
601
 
591
602
  /* We must read all columns in case a table is opened for update */
592
603
  read_all= !bitmap_is_clear_all(table->write_set);
 
604
  /* Avoid asserts in ::store() for columns that are not going to be updated */
 
605
  org_bitmap= dbug_tmp_use_all_columns(table, table->write_set);
593
606
  error= HA_ERR_CRASHED_ON_USAGE;
594
607
 
595
608
  memset(buf, 0, table->s->null_bytes);
667
680
      if ((*field)->flags & BLOB_FLAG)
668
681
      {
669
682
        Field_blob *blob= *(Field_blob**) field;
670
 
        unsigned char *src, *tgt;
671
 
        uint32_t length, packlength;
 
683
        uchar *src, *tgt;
 
684
        uint length, packlength;
672
685
        
673
686
        packlength= blob->pack_length_no_ptr();
674
687
        length= blob->get_length(blob->ptr);
675
 
        memcpy(&src, blob->ptr + packlength, sizeof(char*));
 
688
        memcpy_fixed(&src, blob->ptr + packlength, sizeof(char*));
676
689
        if (src)
677
690
        {
678
 
          tgt= (unsigned char*) alloc_root(&blobroot, length);
679
 
          memcpy(tgt, src, length);
680
 
          memcpy(blob->ptr + packlength, &tgt, sizeof(char*));
 
691
          tgt= (uchar*) alloc_root(&blobroot, length);
 
692
          bmove(tgt, src, length);
 
693
          memcpy_fixed(blob->ptr + packlength, &tgt, sizeof(char*));
681
694
        }
682
695
      }
683
696
    }
686
699
  error= 0;
687
700
 
688
701
err:
 
702
  dbug_tmp_restore_column_map(table->write_set, org_bitmap);
689
703
 
690
704
  return(error);
691
705
}
697
711
static const char *ha_tina_exts[] = {
698
712
  CSV_EXT,
699
713
  CSM_EXT,
700
 
  NULL
 
714
  NullS
701
715
};
702
716
 
703
717
const char **ha_tina::bas_ext() const
711
725
*/
712
726
 
713
727
void tina_get_status(void* param,
714
 
                     int concurrent_insert __attribute__((unused)))
 
728
                     int concurrent_insert __attribute__((__unused__)))
715
729
{
716
730
  ha_tina *tina= (ha_tina*) param;
717
731
  tina->get_status();
724
738
}
725
739
 
726
740
/* this should exist and return 0 for concurrent insert to work */
727
 
bool tina_check_status(void* param __attribute__((unused)))
 
741
bool tina_check_status(void* param __attribute__((__unused__)))
728
742
{
729
743
  return 0;
730
744
}
743
757
 
744
758
void ha_tina::get_status()
745
759
{
 
760
  if (share->is_log_table)
 
761
  {
 
762
    /*
 
763
      We have to use mutex to follow pthreads memory visibility
 
764
      rules for share->saved_data_file_length
 
765
    */
 
766
    pthread_mutex_lock(&share->mutex);
 
767
    local_saved_data_file_length= share->saved_data_file_length;
 
768
    pthread_mutex_unlock(&share->mutex);
 
769
    return;
 
770
  }
746
771
  local_saved_data_file_length= share->saved_data_file_length;
747
772
}
748
773
 
764
789
    For log tables concurrent insert works different. The reason is that
765
790
    log tables are always opened and locked. And as they do not unlock
766
791
    tables, the file length after writes should be updated in a different
767
 
    way. 
 
792
    way. For this purpose we need is_log_table flag. When this flag is set
 
793
    we call update_status() explicitly after each row write.
768
794
*/
769
795
 
770
796
void ha_tina::update_status()
779
805
  this will not be called for every request. Any sort of positions
780
806
  that need to be reset should be kept in the ::extra() call.
781
807
*/
782
 
int ha_tina::open(const char *name, int mode __attribute__((unused)),
783
 
                  uint32_t open_options)
 
808
int ha_tina::open(const char *name, int mode __attribute__((__unused__)),
 
809
                  uint open_options)
784
810
{
785
811
  if (!(share= get_share(name, table)))
786
812
    return(HA_ERR_OUT_OF_MEM);
827
853
  of the file and appends the data. In an error case it really should
828
854
  just truncate to the original position (this is not done yet).
829
855
*/
830
 
int ha_tina::write_row(unsigned char * buf)
 
856
int ha_tina::write_row(uchar * buf)
831
857
{
832
858
  int size;
833
859
 
846
872
      return(-1);
847
873
 
848
874
   /* use pwrite, as concurrent reader could have changed the position */
849
 
  if (my_write(share->tina_write_filedes, (unsigned char*)buffer.ptr(), size,
 
875
  if (my_write(share->tina_write_filedes, (uchar*)buffer.ptr(), size,
850
876
               MYF(MY_WME | MY_NABP)))
851
877
    return(-1);
852
878
 
857
883
  pthread_mutex_lock(&share->mutex);
858
884
  share->rows_recorded++;
859
885
  /* update status for the log tables */
 
886
  if (share->is_log_table)
 
887
    update_status();
860
888
  pthread_mutex_unlock(&share->mutex);
861
889
 
862
890
  stats.records++;
890
918
  This will be called in a table scan right before the previous ::rnd_next()
891
919
  call.
892
920
*/
893
 
int ha_tina::update_row(const unsigned char * old_data __attribute__((unused)),
894
 
                        unsigned char * new_data)
 
921
int ha_tina::update_row(const uchar * old_data __attribute__((__unused__)),
 
922
                        uchar * new_data)
895
923
{
896
924
  int size;
897
925
  int rc= -1;
916
944
  if (open_update_temp_file_if_needed())
917
945
    goto err;
918
946
 
919
 
  if (my_write(update_temp_file, (unsigned char*)buffer.ptr(), size,
 
947
  if (my_write(update_temp_file, (uchar*)buffer.ptr(), size,
920
948
               MYF(MY_WME | MY_NABP)))
921
949
    goto err;
922
950
  temp_file_length+= size;
923
951
  rc= 0;
924
952
 
 
953
  /* UPDATE should never happen on the log tables */
 
954
  assert(!share->is_log_table);
 
955
 
925
956
err:
926
957
  return(rc);
927
958
}
936
967
  The table will then be deleted/positioned based on the ORDER (so RANDOM,
937
968
  DESC, ASC).
938
969
*/
939
 
int ha_tina::delete_row(const unsigned char * buf __attribute__((unused)))
 
970
int ha_tina::delete_row(const uchar * buf __attribute__((__unused__)))
940
971
{
941
972
  ha_statistic_increment(&SSV::ha_delete_count);
942
973
 
950
981
  share->rows_recorded--;
951
982
  pthread_mutex_unlock(&share->mutex);
952
983
 
 
984
  /* DELETE should never happen on the log table */
 
985
  assert(!share->is_log_table);
 
986
 
953
987
  return(0);
954
988
}
955
989
 
1012
1046
 
1013
1047
*/
1014
1048
 
1015
 
int ha_tina::rnd_init(bool scan __attribute__((unused)))
 
1049
int ha_tina::rnd_init(bool scan __attribute__((__unused__)))
1016
1050
{
1017
1051
  /* set buffer to the beginning of the file */
1018
1052
  if (share->crashed || init_data_file())
1042
1076
  NULL and "". This is ok since this table handler is for spreadsheets and
1043
1077
  they don't know about them either :)
1044
1078
*/
1045
 
int ha_tina::rnd_next(unsigned char *buf)
 
1079
int ha_tina::rnd_next(uchar *buf)
1046
1080
{
1047
1081
  int rc;
1048
1082
 
1073
1107
  its just a position. Look at the bdb code if you want to see a case
1074
1108
  where something other then a number is stored.
1075
1109
*/
1076
 
void ha_tina::position(const unsigned char *record __attribute__((unused)))
 
1110
void ha_tina::position(const uchar *record __attribute__((__unused__)))
1077
1111
{
1078
1112
  my_store_ptr(ref, ref_length, current_position);
1079
1113
  return;
1085
1119
  my_get_ptr() retrieves the data for you.
1086
1120
*/
1087
1121
 
1088
 
int ha_tina::rnd_pos(unsigned char * buf, unsigned char *pos)
 
1122
int ha_tina::rnd_pos(uchar * buf, uchar *pos)
1089
1123
{
1090
1124
  ha_statistic_increment(&SSV::ha_read_rnd_count);
1091
1125
  current_position= (off_t)my_get_ptr(pos,ref_length);
1097
1131
  Currently this table handler doesn't implement most of the fields
1098
1132
  really needed. SHOW also makes use of this data
1099
1133
*/
1100
 
int ha_tina::info(uint32_t flag __attribute__((unused)))
 
1134
int ha_tina::info(uint flag __attribute__((__unused__)))
1101
1135
{
1102
1136
  /* This is a lie, but you don't want the optimizer to see zero or 1 */
1103
1137
  if (!records_is_known && stats.records < 2) 
1115
1149
  if (closest_hole == chain_ptr) /* no more chains */
1116
1150
    *end_pos= file_buff->end();
1117
1151
  else
1118
 
    *end_pos= std::min(file_buff->end(),
1119
 
                       closest_hole->begin);
 
1152
    *end_pos= min(file_buff->end(),
 
1153
                  closest_hole->begin);
1120
1154
  return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
1121
1155
}
1122
1156
 
1168
1202
      if (write_length)
1169
1203
      {
1170
1204
        if (my_write(update_temp_file, 
1171
 
                     (unsigned char*) (file_buff->ptr() +
 
1205
                     (uchar*) (file_buff->ptr() +
1172
1206
                               (write_begin - file_buff->start())),
1173
1207
                     write_length, MYF_RW))
1174
1208
          goto error;
1270
1304
*/
1271
1305
 
1272
1306
int ha_tina::repair(THD* thd,
1273
 
                    HA_CHECK_OPT* check_opt __attribute__((unused)))
 
1307
                    HA_CHECK_OPT* check_opt __attribute__((__unused__)))
1274
1308
{
1275
1309
  char repaired_fname[FN_REFLEN];
1276
 
  unsigned char *buf;
 
1310
  uchar *buf;
1277
1311
  File repair_file;
1278
1312
  int rc;
1279
1313
  ha_rows rows_repaired= 0;
1288
1322
 
1289
1323
  /* Don't assert in field::val() functions */
1290
1324
  table->use_all_columns();
1291
 
  if (!(buf= (unsigned char*) my_malloc(table->s->reclength, MYF(MY_WME))))
 
1325
  if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME))))
1292
1326
    return(HA_ERR_OUT_OF_MEM);
1293
1327
 
1294
1328
  /* position buffer to the start of the file */
1316
1350
 
1317
1351
  free_root(&blobroot, MYF(0));
1318
1352
 
1319
 
  free((char*)buf);
 
1353
  my_free((char*)buf, MYF(0));
1320
1354
 
1321
1355
  if (rc == HA_ERR_END_OF_FILE)
1322
1356
  {
1348
1382
  /* write repaired file */
1349
1383
  while (1)
1350
1384
  {
1351
 
    write_end= std::min(file_buff->end(), current_position);
 
1385
    write_end= min(file_buff->end(), current_position);
1352
1386
    if ((write_end - write_begin) &&
1353
 
        (my_write(repair_file, (unsigned char*)file_buff->ptr(),
 
1387
        (my_write(repair_file, (uchar*)file_buff->ptr(),
1354
1388
                  write_end - write_begin, MYF_RW)))
1355
1389
      return(-1);
1356
1390
 
1415
1449
  Called by the database to lock the table. Keep in mind that this
1416
1450
  is an internal lock.
1417
1451
*/
1418
 
THR_LOCK_DATA **ha_tina::store_lock(THD *thd __attribute__((unused)),
 
1452
THR_LOCK_DATA **ha_tina::store_lock(THD *thd __attribute__((__unused__)),
1419
1453
                                    THR_LOCK_DATA **to,
1420
1454
                                    enum thr_lock_type lock_type)
1421
1455
{
1430
1464
  this (the database will call ::open() if it needs to).
1431
1465
*/
1432
1466
 
1433
 
int ha_tina::create(const char *name, Table *table_arg,
1434
 
                    HA_CREATE_INFO *create_info __attribute__((unused)))
 
1467
int ha_tina::create(const char *name, TABLE *table_arg,
 
1468
                    HA_CREATE_INFO *create_info __attribute__((__unused__)))
1435
1469
{
1436
1470
  char name_buff[FN_REFLEN];
1437
1471
  File create_file;
1468
1502
}
1469
1503
 
1470
1504
int ha_tina::check(THD* thd,
1471
 
                   HA_CHECK_OPT* check_opt __attribute__((unused)))
 
1505
                   HA_CHECK_OPT* check_opt __attribute__((__unused__)))
1472
1506
{
1473
1507
  int rc= 0;
1474
 
  unsigned char *buf;
 
1508
  uchar *buf;
1475
1509
  const char *old_proc_info;
1476
1510
  ha_rows count= share->rows_recorded;
1477
1511
 
1478
1512
  old_proc_info= thd_proc_info(thd, "Checking table");
1479
 
  if (!(buf= (unsigned char*) my_malloc(table->s->reclength, MYF(MY_WME))))
 
1513
  if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME))))
1480
1514
    return(HA_ERR_OUT_OF_MEM);
1481
1515
 
1482
1516
  /* position buffer to the start of the file */
1504
1538
  
1505
1539
  free_root(&blobroot, MYF(0));
1506
1540
 
1507
 
  free((char*)buf);
 
1541
  my_free((char*)buf, MYF(0));
1508
1542
  thd_proc_info(thd, old_proc_info);
1509
1543
 
1510
1544
  if ((rc != HA_ERR_END_OF_FILE) || count)
1517
1551
}
1518
1552
 
1519
1553
 
1520
 
bool ha_tina::check_if_incompatible_data(HA_CREATE_INFO *info __attribute__((unused)),
1521
 
                                         uint32_t table_changes __attribute__((unused)))
 
1554
bool ha_tina::check_if_incompatible_data(HA_CREATE_INFO *info __attribute__((__unused__)),
 
1555
                                         uint table_changes __attribute__((__unused__)))
1522
1556
{
1523
1557
  return COMPATIBLE_DATA_YES;
1524
1558
}
1525
1559
 
 
1560
struct st_mysql_storage_engine csv_storage_engine=
 
1561
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
 
1562
 
1526
1563
mysql_declare_plugin(csv)
1527
1564
{
1528
 
  DRIZZLE_STORAGE_ENGINE_PLUGIN,
 
1565
  MYSQL_STORAGE_ENGINE_PLUGIN,
 
1566
  &csv_storage_engine,
1529
1567
  "CSV",
1530
 
  "1.0",
1531
1568
  "Brian Aker, MySQL AB",
1532
1569
  "CSV storage engine",
1533
1570
  PLUGIN_LICENSE_GPL,
1534
1571
  tina_init_func, /* Plugin Init */
1535
1572
  tina_done_func, /* Plugin Deinit */
 
1573
  0x0100 /* 1.0 */,
1536
1574
  NULL,                       /* status variables                */
1537
1575
  NULL,                       /* system variables                */
1538
1576
  NULL                        /* config options                  */