~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/ha_archive.cc

  • Committer: Jim Winstead
  • Date: 2008-07-19 02:56:45 UTC
  • mto: (202.1.8 codestyle)
  • mto: This revision was merged to the branch mainline in revision 207.
  • Revision ID: jimw@mysql.com-20080719025645-w2pwytebgzusjzjb
Various fixes to enable compilation on Mac OS X, and remove the glib dependency.
Temporarily disables tab-completion in the drizzle client until an appropriate
autoconf check can be added/enabled.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
  along with this program; if not, write to the Free Software
14
14
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
 
16
#ifdef USE_PRAGMA_IMPLEMENTATION
 
17
#pragma implementation        // gcc: Class implementation
 
18
#endif
16
19
 
17
 
#include <drizzled/common_includes.h>
18
 
#include <storage/myisam/myisam.h>
 
20
#include "mysql_priv.h"
 
21
#include <myisam.h>
19
22
 
20
23
#include "ha_archive.h"
 
24
#include <my_dir.h>
 
25
 
 
26
#include <mysql/plugin.h>
21
27
 
22
28
/*
23
29
  First, if you want to understand storage engines you should look at 
98
104
#define ARM ".ARM"               // Meta file (deprecated)
99
105
 
100
106
/*
101
 
  unsigned char + unsigned char
 
107
  uchar + uchar
102
108
*/
103
109
#define DATA_BUFFER_SIZE 2       // Size of the data used in the data file
104
110
#define ARCHIVE_CHECK_HEADER 254 // The number we use to determine corruption
109
115
                                       MEM_ROOT *mem_root);
110
116
int archive_discover(handlerton *hton, THD* thd, const char *db, 
111
117
                     const char *name,
112
 
                     unsigned char **frmblob, 
 
118
                     uchar **frmblob, 
113
119
                     size_t *frmlen);
114
120
 
115
 
static bool archive_use_aio= false;
 
121
static my_bool archive_use_aio= false;
116
122
 
117
123
/*
118
124
  Number of rows that will force a bulk insert.
134
140
/*
135
141
  Used for hash table that tracks open tables.
136
142
*/
137
 
static unsigned char* archive_get_key(ARCHIVE_SHARE *share, size_t *length,
138
 
                             bool not_used __attribute__((unused)))
 
143
static uchar* archive_get_key(ARCHIVE_SHARE *share, size_t *length,
 
144
                             my_bool not_used __attribute__((unused)))
139
145
{
140
146
  *length=share->table_name_length;
141
 
  return (unsigned char*) share->table_name;
 
147
  return (uchar*) share->table_name;
142
148
}
143
149
 
144
150
 
160
166
 
161
167
  archive_hton= (handlerton *)p;
162
168
  archive_hton->state= SHOW_OPTION_YES;
 
169
  archive_hton->db_type= DB_TYPE_ARCHIVE_DB;
163
170
  archive_hton->create= archive_create_handler;
164
171
  archive_hton->flags= HTON_NO_FLAGS;
165
172
  archive_hton->discover= archive_discover;
172
179
  if (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
173
180
                (hash_get_key) archive_get_key, 0, 0))
174
181
  {
175
 
    pthread_mutex_destroy(&archive_mutex);
 
182
    VOID(pthread_mutex_destroy(&archive_mutex));
176
183
  }
177
184
  else
178
185
  {
193
200
    false       OK
194
201
*/
195
202
 
196
 
int archive_db_done(void *p __attribute__((unused)))
 
203
int archive_db_done(void *p __attribute__((__unused__)))
197
204
{
198
205
  hash_free(&archive_open_tables);
199
 
  pthread_mutex_destroy(&archive_mutex);
 
206
  VOID(pthread_mutex_destroy(&archive_mutex));
200
207
 
201
208
  return 0;
202
209
}
213
220
  archive_reader_open= false;
214
221
}
215
222
 
216
 
int archive_discover(handlerton *hton __attribute__((unused)),
217
 
                     THD* thd __attribute__((unused)),
 
223
int archive_discover(handlerton *hton __attribute__((__unused__)),
 
224
                     THD* thd __attribute__((__unused__)),
218
225
                     const char *db,
219
226
                     const char *name,
220
 
                     unsigned char **frmblob,
 
227
                     uchar **frmblob,
221
228
                     size_t *frmlen)
222
229
{
223
230
  azio_stream frm_stream;
230
237
  if (stat(az_file, &file_stat))
231
238
    goto err;
232
239
 
233
 
  if (!(azopen(&frm_stream, az_file, O_RDONLY, AZ_METHOD_BLOCK)))
 
240
  if (!(azopen(&frm_stream, az_file, O_RDONLY|O_BINARY, AZ_METHOD_BLOCK)))
234
241
  {
235
242
    if (errno == EROFS || errno == EACCES)
236
243
      return(my_errno= errno);
245
252
  azclose(&frm_stream);
246
253
 
247
254
  *frmlen= frm_stream.frm_length;
248
 
  *frmblob= (unsigned char*) frm_ptr;
 
255
  *frmblob= (uchar*) frm_ptr;
249
256
 
250
257
  return(0);
251
258
err:
277
284
*/
278
285
ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
279
286
{
280
 
  uint32_t length;
 
287
  uint length;
281
288
 
282
289
  pthread_mutex_lock(&archive_mutex);
283
290
  length=(uint) strlen(table_name);
284
291
 
285
292
  if (!(share=(ARCHIVE_SHARE*) hash_search(&archive_open_tables,
286
 
                                           (unsigned char*) table_name,
 
293
                                           (uchar*) table_name,
287
294
                                           length)))
288
295
  {
289
296
    char *tmp_name;
292
299
    if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
293
300
                          &share, sizeof(*share),
294
301
                          &tmp_name, length+1,
295
 
                          NULL)) 
 
302
                          NullS)) 
296
303
    {
297
304
      pthread_mutex_unlock(&archive_mutex);
298
305
      *rc= HA_ERR_OUT_OF_MEM;
306
313
    share->archive_write_open= false;
307
314
    fn_format(share->data_file_name, table_name, "",
308
315
              ARZ, MY_REPLACE_EXT | MY_UNPACK_FILENAME);
309
 
    my_stpcpy(share->table_name, table_name);
 
316
    strmov(share->table_name, table_name);
310
317
    /*
311
318
      We will use this lock for rows.
312
319
    */
313
 
    pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
 
320
    VOID(pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST));
314
321
    
315
322
    /*
316
323
      We read the meta file, but do not mark it dirty. Since we are not
318
325
      anything but reading... open it for write and we will generate null
319
326
      compression writes).
320
327
    */
321
 
    if (!(azopen(&archive_tmp, share->data_file_name, O_RDONLY,
 
328
    if (!(azopen(&archive_tmp, share->data_file_name, O_RDONLY|O_BINARY,
322
329
                 AZ_METHOD_BLOCK)))
323
330
    {
324
 
      pthread_mutex_destroy(&share->mutex);
 
331
      VOID(pthread_mutex_destroy(&share->mutex));
325
332
      free(share);
326
333
      pthread_mutex_unlock(&archive_mutex);
327
334
      *rc= HA_ERR_CRASHED_ON_REPAIR;
337
344
    }
338
345
    azclose(&archive_tmp);
339
346
 
340
 
    my_hash_insert(&archive_open_tables, (unsigned char*) share);
 
347
    VOID(my_hash_insert(&archive_open_tables, (uchar*) share));
341
348
    thr_lock_init(&share->lock);
342
349
  }
343
350
  share->use_count++;
360
367
  pthread_mutex_lock(&archive_mutex);
361
368
  if (!--share->use_count)
362
369
  {
363
 
    hash_delete(&archive_open_tables, (unsigned char*) share);
 
370
    hash_delete(&archive_open_tables, (uchar*) share);
364
371
    thr_lock_delete(&share->lock);
365
 
    pthread_mutex_destroy(&share->mutex);
 
372
    VOID(pthread_mutex_destroy(&share->mutex));
366
373
    /* 
367
374
      We need to make sure we don't reset the crashed state.
368
375
      If we open a crashed file, wee need to close it as crashed unless
375
382
      if (azclose(&(share->archive_write)))
376
383
        rc= 1;
377
384
    }
378
 
    free((unsigned char*) share);
 
385
    my_free((uchar*) share, MYF(0));
379
386
  }
380
387
  pthread_mutex_unlock(&archive_mutex);
381
388
 
390
397
    that is shared amoung all open tables.
391
398
  */
392
399
  if (!(azopen(&(share->archive_write), share->data_file_name, 
393
 
               O_RDWR, AZ_METHOD_BLOCK)))
 
400
               O_RDWR|O_BINARY, AZ_METHOD_BLOCK)))
394
401
  {
395
402
    share->crashed= true;
396
403
    return(1);
426
433
    default:
427
434
      method= AZ_METHOD_BLOCK;
428
435
    }
429
 
    if (!(azopen(&archive, share->data_file_name, O_RDONLY, 
 
436
    if (!(azopen(&archive, share->data_file_name, O_RDONLY|O_BINARY, 
430
437
                 method)))
431
438
    {
432
439
      share->crashed= true;
444
451
*/
445
452
static const char *ha_archive_exts[] = {
446
453
  ARZ,
447
 
  NULL
 
454
  NullS
448
455
};
449
456
 
450
457
const char **ha_archive::bas_ext() const
460
467
  We open the file we will read from.
461
468
*/
462
469
int ha_archive::open(const char *name,
463
 
                     int mode __attribute__((unused)),
464
 
                     uint32_t open_options)
 
470
                     int mode __attribute__((__unused__)),
 
471
                     uint open_options)
465
472
{
466
473
  int rc= 0;
467
474
  share= get_share(name, &rc);
545
552
  of creation.
546
553
*/
547
554
 
548
 
int ha_archive::create(const char *name, Table *table_arg,
 
555
int ha_archive::create(const char *name, TABLE *table_arg,
549
556
                       HA_CREATE_INFO *create_info)
550
557
{
551
558
  char name_buff[FN_REFLEN];
554
561
  azio_stream create_stream;            /* Archive file we are working with */
555
562
  File frm_file;                   /* File handler for readers */
556
563
  struct stat file_stat;
557
 
  unsigned char *frm_ptr;
 
564
  uchar *frm_ptr;
558
565
 
559
566
  stats.auto_increment_value= create_info->auto_increment_value;
560
567
 
561
 
  for (uint32_t key= 0; key < table_arg->sizeKeys(); key++)
 
568
  for (uint key= 0; key < table_arg->s->keys; key++)
562
569
  {
563
570
    KEY *pos= table_arg->key_info+key;
564
571
    KEY_PART_INFO *key_part=     pos->key_part;
600
607
  if (!stat(name_buff, &file_stat))
601
608
  {
602
609
    my_errno= 0;
603
 
    if (!(azopen(&create_stream, name_buff, O_CREAT|O_RDWR,
 
610
    if (!(azopen(&create_stream, name_buff, O_CREAT|O_RDWR|O_BINARY,
604
611
                 AZ_METHOD_BLOCK)))
605
612
    {
606
613
      error= errno;
619
626
    {
620
627
      if (fstat(frm_file, &file_stat))
621
628
      {
622
 
        frm_ptr= (unsigned char *)my_malloc(sizeof(unsigned char) * file_stat.st_size, MYF(0));
 
629
        frm_ptr= (uchar *)my_malloc(sizeof(uchar) * file_stat.st_size, MYF(0));
623
630
        if (frm_ptr)
624
631
        {
625
632
          my_read(frm_file, frm_ptr, file_stat.st_size, MYF(0));
626
633
          azwrite_frm(&create_stream, (char *)frm_ptr, file_stat.st_size);
627
 
          free((unsigned char*)frm_ptr);
 
634
          my_free((uchar*)frm_ptr, MYF(0));
628
635
        }
629
636
      }
630
637
      my_close(frm_file, MYF(0));
661
668
/*
662
669
  This is where the actual row is written out.
663
670
*/
664
 
int ha_archive::real_write_row(unsigned char *buf, azio_stream *writer)
 
671
int ha_archive::real_write_row(uchar *buf, azio_stream *writer)
665
672
{
666
673
  my_off_t written;
667
674
  unsigned int r_pack_length;
687
694
  the bytes required for the length in the header.
688
695
*/
689
696
 
690
 
uint32_t ha_archive::max_row_length(const unsigned char *buf __attribute__((unused)))
 
697
uint32 ha_archive::max_row_length(const uchar *buf __attribute__((__unused__)))
691
698
{
692
 
  uint32_t length= (uint32_t)(table->getRecordLength() + table->sizeFields()*2);
 
699
  uint32 length= (uint32)(table->s->reclength + table->s->fields*2);
693
700
  length+= ARCHIVE_ROW_HEADER_SIZE;
694
701
 
695
 
  uint32_t *ptr, *end;
696
 
  for (ptr= table->getBlobField(), end=ptr + table->sizeBlobFields();
 
702
  uint *ptr, *end;
 
703
  for (ptr= table->s->blob_field, end=ptr + table->s->blob_fields ;
697
704
       ptr != end ;
698
705
       ptr++)
699
706
  {
704
711
}
705
712
 
706
713
 
707
 
unsigned int ha_archive::pack_row(unsigned char *record)
 
714
unsigned int ha_archive::pack_row(uchar *record)
708
715
{
709
 
  unsigned char *ptr;
 
716
  uchar *ptr;
710
717
 
711
718
  if (fix_rec_buff(max_row_length(record)))
712
719
    return(HA_ERR_OUT_OF_MEM); /* purecov: inspected */
734
741
  for implementing start_bulk_insert() is that we could skip 
735
742
  setting dirty to true each time.
736
743
*/
737
 
int ha_archive::write_row(unsigned char *buf)
 
744
int ha_archive::write_row(uchar *buf)
738
745
{
739
746
  int rc;
740
 
  unsigned char *read_buf= NULL;
 
747
  uchar *read_buf= NULL;
741
748
  uint64_t temp_auto;
742
 
  unsigned char *record=  table->record[0];
 
749
  uchar *record=  table->record[0];
743
750
 
744
751
  if (share->crashed)
745
752
    return(HA_ERR_CRASHED_ON_USAGE);
782
789
        First we create a buffer that we can use for reading rows, and can pass
783
790
        to get_row().
784
791
      */
785
 
      if (!(read_buf= (unsigned char*) my_malloc(table->s->reclength, MYF(MY_WME))))
 
792
      if (!(read_buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME))))
786
793
      {
787
794
        rc= HA_ERR_OUT_OF_MEM;
788
795
        goto error;
832
839
error:
833
840
  pthread_mutex_unlock(&share->mutex);
834
841
  if (read_buf)
835
 
    free((unsigned char*) read_buf);
 
842
    my_free((uchar*) read_buf, MYF(0));
836
843
 
837
844
  return(rc);
838
845
}
839
846
 
840
847
 
841
 
void ha_archive::get_auto_increment(uint64_t offset __attribute__((unused)),
842
 
                                    uint64_t increment __attribute__((unused)),
843
 
                                    uint64_t nb_desired_values __attribute__((unused)),
844
 
                                    uint64_t *first_value __attribute__((unused)),
845
 
                                    uint64_t *nb_reserved_values __attribute__((unused)))
 
848
void ha_archive::get_auto_increment(uint64_t offset __attribute__((__unused__)),
 
849
                                    uint64_t increment __attribute__((__unused__)),
 
850
                                    uint64_t nb_desired_values __attribute__((__unused__)),
 
851
                                    uint64_t *first_value __attribute__((__unused__)),
 
852
                                    uint64_t *nb_reserved_values __attribute__((__unused__)))
846
853
{
847
854
  *nb_reserved_values= UINT64_MAX;
848
855
  *first_value= share->archive_write.auto_increment + 1;
849
856
}
850
857
 
851
858
/* Initialized at each key walk (called multiple times unlike rnd_init()) */
852
 
int ha_archive::index_init(uint32_t keynr, bool sorted __attribute__((unused)))
 
859
int ha_archive::index_init(uint keynr, bool sorted __attribute__((__unused__)))
853
860
{
854
861
  active_index= keynr;
855
862
  return(0);
860
867
  No indexes, so if we get a request for an index search since we tell
861
868
  the optimizer that we have unique indexes, we scan
862
869
*/
863
 
int ha_archive::index_read(unsigned char *buf, const unsigned char *key,
864
 
                             uint32_t key_len, enum ha_rkey_function find_flag)
 
870
int ha_archive::index_read(uchar *buf, const uchar *key,
 
871
                             uint key_len, enum ha_rkey_function find_flag)
865
872
{
866
873
  int rc;
867
874
  rc= index_read_idx(buf, active_index, key, key_len, find_flag);
869
876
}
870
877
 
871
878
 
872
 
int ha_archive::index_read_idx(unsigned char *buf, uint32_t index, const unsigned char *key,
873
 
                               uint32_t key_len,
874
 
                               enum ha_rkey_function find_flag __attribute__((unused)))
 
879
int ha_archive::index_read_idx(uchar *buf, uint index, const uchar *key,
 
880
                               uint key_len,
 
881
                               enum ha_rkey_function find_flag __attribute__((__unused__)))
875
882
{
876
883
  int rc;
877
884
  bool found= 0;
902
909
}
903
910
 
904
911
 
905
 
int ha_archive::index_next(unsigned char * buf) 
 
912
int ha_archive::index_next(uchar * buf) 
906
913
907
914
  bool found= 0;
908
915
 
946
953
  This is the method that is used to read a row. It assumes that the row is 
947
954
  positioned where you want it.
948
955
*/
949
 
int ha_archive::get_row(azio_stream *file_to_read, unsigned char *buf)
 
956
int ha_archive::get_row(azio_stream *file_to_read, uchar *buf)
950
957
{
951
958
  int rc;
952
959
 
965
972
 
966
973
  if (length > record_buffer->length)
967
974
  {
968
 
    unsigned char *newptr;
969
 
    if (!(newptr=(unsigned char*) my_realloc((unsigned char*) record_buffer->buffer, 
 
975
    uchar *newptr;
 
976
    if (!(newptr=(uchar*) my_realloc((uchar*) record_buffer->buffer, 
970
977
                                    length,
971
978
                                    MYF(MY_ALLOW_ZERO_PTR))))
972
979
      return(1);
979
986
  return(0);
980
987
}
981
988
 
982
 
int ha_archive::unpack_row(azio_stream *file_to_read, unsigned char *record)
 
989
int ha_archive::unpack_row(azio_stream *file_to_read, uchar *record)
983
990
{
984
991
  unsigned int read;
985
992
  int error;
986
 
  const unsigned char *ptr;
 
993
  const uchar *ptr;
987
994
 
988
995
  read= azread_row(file_to_read, &error);
989
 
  ptr= (const unsigned char *)file_to_read->row_ptr;
 
996
  ptr= (const uchar *)file_to_read->row_ptr;
990
997
 
991
998
  if (error || read == 0)
992
999
  {
994
1001
  }
995
1002
 
996
1003
  /* Copy null bits */
997
 
  memcpy(record, ptr, table->getNullBytes());
998
 
  ptr+= table->getNullBytes();
 
1004
  memcpy(record, ptr, table->s->null_bytes);
 
1005
  ptr+= table->s->null_bytes;
999
1006
  for (Field **field=table->field ; *field ; field++)
1000
1007
  {
1001
1008
    if (!((*field)->is_null()))
1007
1014
}
1008
1015
 
1009
1016
 
1010
 
int ha_archive::get_row_version3(azio_stream *file_to_read, unsigned char *buf)
 
1017
int ha_archive::get_row_version3(azio_stream *file_to_read, uchar *buf)
1011
1018
{
1012
1019
  int returnable= unpack_row(file_to_read, buf);
1013
1020
 
1020
1027
  or by having had ha_archive::rnd_pos() called before it is called.
1021
1028
*/
1022
1029
 
1023
 
int ha_archive::rnd_next(unsigned char *buf)
 
1030
int ha_archive::rnd_next(uchar *buf)
1024
1031
{
1025
1032
  int rc;
1026
1033
 
1047
1054
  needed.
1048
1055
*/
1049
1056
 
1050
 
void ha_archive::position(const unsigned char *record __attribute__((unused)))
 
1057
void ha_archive::position(const uchar *record __attribute__((__unused__)))
1051
1058
{
1052
1059
  my_store_ptr(ref, ref_length, current_position);
1053
1060
  return;
1061
1068
  correctly ordered row.
1062
1069
*/
1063
1070
 
1064
 
int ha_archive::rnd_pos(unsigned char * buf, unsigned char *pos)
 
1071
int ha_archive::rnd_pos(uchar * buf, uchar *pos)
1065
1072
{
1066
1073
  ha_statistic_increment(&SSV::ha_read_rnd_next_count);
1067
1074
  current_position= (my_off_t)my_get_ptr(pos, ref_length);
1091
1098
  The table can become fragmented if data was inserted, read, and then
1092
1099
  inserted again. What we do is open up the file and recompress it completely. 
1093
1100
*/
1094
 
int ha_archive::optimize(THD* thd __attribute__((unused)),
1095
 
                         HA_CHECK_OPT* check_opt __attribute__((unused)))
 
1101
int ha_archive::optimize(THD* thd __attribute__((__unused__)),
 
1102
                         HA_CHECK_OPT* check_opt __attribute__((__unused__)))
1096
1103
{
1097
1104
  int rc= 0;
1098
1105
  azio_stream writer;
1111
1118
  fn_format(writer_filename, share->table_name, "", ARN, 
1112
1119
            MY_REPLACE_EXT | MY_UNPACK_FILENAME);
1113
1120
 
1114
 
  if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR, AZ_METHOD_BLOCK)))
 
1121
  if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR|O_BINARY, AZ_METHOD_BLOCK)))
1115
1122
    return(HA_ERR_CRASHED_ON_USAGE); 
1116
1123
 
1117
1124
  /* 
1141
1148
      share->rows_recorded= 0;
1142
1149
      stats.auto_increment_value= 1;
1143
1150
      share->archive_write.auto_increment= 0;
 
1151
      my_bitmap_map *org_bitmap= dbug_tmp_use_all_columns(table, table->read_set);
1144
1152
 
1145
1153
      rows_restored= archive.rows;
1146
1154
 
1167
1175
              (share->archive_write.auto_increment= auto_value) + 1;
1168
1176
        }
1169
1177
      }
 
1178
      dbug_tmp_restore_column_map(table->read_set, org_bitmap);
1170
1179
      share->rows_recorded= (ha_rows)writer.rows;
1171
1180
    }
1172
1181
 
1209
1218
    /* 
1210
1219
      Here is where we get into the guts of a row level lock.
1211
1220
      If TL_UNLOCK is set 
1212
 
      If we are not doing a LOCK Table or DISCARD/IMPORT
 
1221
      If we are not doing a LOCK TABLE or DISCARD/IMPORT
1213
1222
      TABLESPACE, then allow multiple writers 
1214
1223
    */
1215
1224
 
1255
1264
/*
1256
1265
  Hints for optimizer, see ha_tina for more information
1257
1266
*/
1258
 
int ha_archive::info(uint32_t flag)
 
1267
int ha_archive::info(uint flag)
1259
1268
{
1260
1269
  /* 
1261
1270
    If dirty, we lock, and then reset/flush the data.
1290
1299
  {
1291
1300
    struct stat file_stat;  // Stat information for the data file
1292
1301
 
1293
 
    stat(share->data_file_name, &file_stat);
 
1302
    VOID(stat(share->data_file_name, &file_stat));
1294
1303
 
1295
 
    stats.mean_rec_length= table->getRecordLength()+ buffer.alloced_length();
 
1304
    stats.mean_rec_length= table->s->reclength + buffer.alloced_length();
1296
1305
    stats.data_file_length= file_stat.st_size;
1297
1306
    stats.create_time= file_stat.st_ctime;
1298
1307
    stats.update_time= file_stat.st_mtime;
1362
1371
*/
1363
1372
 
1364
1373
int ha_archive::check(THD* thd,
1365
 
                      HA_CHECK_OPT* check_opt __attribute__((unused)))
 
1374
                      HA_CHECK_OPT* check_opt __attribute__((__unused__)))
1366
1375
{
1367
1376
  int rc= 0;
1368
1377
  const char *old_proc_info;
1369
1378
  uint64_t x;
1370
1379
 
1371
 
  old_proc_info= get_thd_proc_info(thd);
1372
 
  set_thd_proc_info(thd, "Checking table");
 
1380
  old_proc_info= thd_proc_info(thd, "Checking table");
1373
1381
  /* Flush any waiting data */
1374
1382
  pthread_mutex_lock(&share->mutex);
1375
1383
  azflush(&(share->archive_write), Z_SYNC_FLUSH);
1390
1398
      break;
1391
1399
  }
1392
1400
 
1393
 
  set_thd_proc_info(thd, old_proc_info);
 
1401
  thd_proc_info(thd, old_proc_info);
1394
1402
 
1395
1403
  if ((rc && rc != HA_ERR_END_OF_FILE))  
1396
1404
  {
1426
1434
  }
1427
1435
  r->length= (int)length;
1428
1436
 
1429
 
  if (!(r->buffer= (unsigned char*) my_malloc(r->length,
 
1437
  if (!(r->buffer= (uchar*) my_malloc(r->length,
1430
1438
                                    MYF(MY_WME))))
1431
1439
  {
1432
 
    free((char*) r);
 
1440
    my_free((char*) r, MYF(MY_ALLOW_ZERO_PTR));
1433
1441
    return(NULL); /* purecov: inspected */
1434
1442
  }
1435
1443
 
1438
1446
 
1439
1447
void ha_archive::destroy_record_buffer(archive_record_buffer *r) 
1440
1448
{
1441
 
  free((char*) r->buffer);
1442
 
  free((char*) r);
 
1449
  my_free((char*) r->buffer, MYF(MY_ALLOW_ZERO_PTR));
 
1450
  my_free((char*) r, MYF(MY_ALLOW_ZERO_PTR));
1443
1451
  return;
1444
1452
}
1445
1453
 
1446
 
static DRIZZLE_SYSVAR_BOOL(aio, archive_use_aio,
 
1454
static MYSQL_SYSVAR_BOOL(aio, archive_use_aio,
1447
1455
  PLUGIN_VAR_NOCMDOPT,
1448
1456
  "Whether or not to use asynchronous IO.",
1449
1457
  NULL, NULL, true);
1450
1458
 
1451
1459
static struct st_mysql_sys_var* archive_system_variables[]= {
1452
 
  DRIZZLE_SYSVAR(aio),
 
1460
  MYSQL_SYSVAR(aio),
1453
1461
  NULL
1454
1462
};
1455
1463
 
 
1464
struct st_mysql_storage_engine archive_storage_engine=
 
1465
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
 
1466
 
1456
1467
mysql_declare_plugin(archive)
1457
1468
{
1458
 
  DRIZZLE_STORAGE_ENGINE_PLUGIN,
 
1469
  MYSQL_STORAGE_ENGINE_PLUGIN,
 
1470
  &archive_storage_engine,
1459
1471
  "ARCHIVE",
1460
 
  "3.5",
1461
1472
  "Brian Aker, MySQL AB",
1462
1473
  "Archive storage engine",
1463
1474
  PLUGIN_LICENSE_GPL,
1464
1475
  archive_db_init, /* Plugin Init */
1465
1476
  archive_db_done, /* Plugin Deinit */
 
1477
  0x0350 /* 3.0 */,
1466
1478
  NULL,                       /* status variables                */
1467
1479
  archive_system_variables,   /* system variables                */
1468
1480
  NULL                        /* config options                  */