~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/myisamchk.cc

Removing global errbuff and cleaning up two remaining instances that referenced it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* Describe, check and repair of MyISAM tables */
17
17
 
18
 
#include <drizzled/global.h>
 
18
#include "myisamdef.h"
 
19
#include "myisam.h"
19
20
 
20
21
#include <mystrings/m_ctype.h>
21
 
#include <stdarg.h>
22
22
#include <mysys/my_getopt.h>
23
23
#include <mysys/my_bit.h>
24
 
#include <myisam.h>
25
24
#include <mystrings/m_string.h>
 
25
#include <stdio.h>
 
26
#include <stdarg.h>
26
27
#ifdef HAVE_SYS_VADVICE_H
27
28
#include <sys/vadvise.h>
28
29
#endif
29
30
#ifdef HAVE_SYS_MMAN_H
30
31
#include <sys/mman.h>
31
32
#endif
32
 
 
33
 
#define my_raid_create(A,B,C,D,E,F,G) my_create(A,B,C,G)
34
 
#define my_raid_delete(A,B,C) my_delete(A,B)
35
 
 
36
 
#include "myisamdef.h"
 
33
#include <drizzled/util/test.h>
 
34
 
 
35
 
 
36
pthread_mutex_t THR_LOCK_myisam= PTHREAD_MUTEX_INITIALIZER;
37
37
 
38
38
static uint32_t decode_bits;
39
39
static char **default_argv;
43
43
static long opt_myisam_block_size;
44
44
static long opt_key_cache_block_size;
45
45
static const char *my_progname_short;
46
 
static MY_TMPDIR myisamchk_tmpdir;
47
46
 
48
47
static const char *type_names[]=
49
48
{ "impossible","char","binary", "short", "long", "float",
77
76
                             MI_KEYDEF *keyinfo,
78
77
                             my_off_t page,unsigned char *buff,uint32_t sortkey,
79
78
                             File new_file, bool update_index);
 
79
extern "C"
 
80
bool get_one_option(int optid, const struct my_option *, char *argument);
80
81
 
81
82
MI_CHECK check_param;
82
83
 
131
132
    printf("\nTotal of all %d MyISAM-files:\nData records: %9s   Deleted blocks: %9s\n",check_param.total_files,llstr(check_param.total_records,buff),
132
133
           llstr(check_param.total_deleted,buff2));
133
134
  }
 
135
 
 
136
  pthread_mutex_destroy(&THR_LOCK_myisam);
 
137
 
134
138
  free_defaults(default_argv);
135
 
  free_tmpdir(&myisamchk_tmpdir);
136
139
  my_end(check_param.testflag & T_INFO ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
137
 
  exit(error);
138
 
#ifndef _lint
139
 
  return 0;                             /* No compiler warning */
140
 
#endif
 
140
  return error;
141
141
} /* main */
142
142
 
143
143
enum options_mc {
154
154
  {"analyze", 'a',
155
155
   "Analyze distribution of keys. Will make some joins in MySQL faster. You can check the calculated distribution.",
156
156
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
157
 
  {"block-search", 'b',
158
 
   "No help available.",
159
 
   0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
160
157
  {"backup", 'B',
161
158
   "Make a backup of the .MYD file as 'filename-time.BAK'.",
162
159
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
163
 
  {"character-sets-dir", OPT_CHARSETS_DIR,
164
 
   "Directory where character sets are.",
165
 
   (char**) &charsets_dir, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
166
160
  {"check", 'c',
167
161
   "Check table for errors.",
168
162
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
276
270
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
277
271
  { "key_buffer_size", OPT_KEY_BUFFER_SIZE, "",
278
272
    (char**) &check_param.use_buffers, (char**) &check_param.use_buffers, 0,
279
 
    GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD,
 
273
    GET_UINT64, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD,
280
274
    INT32_MAX, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0},
281
275
  { "key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,  "",
282
276
    (char**) &opt_key_cache_block_size,
289
283
    MI_MAX_KEY_BLOCK_LENGTH, 0, MI_MIN_KEY_BLOCK_LENGTH, 0},
290
284
  { "read_buffer_size", OPT_READ_BUFFER_SIZE, "",
291
285
    (char**) &check_param.read_buffer_length,
292
 
    (char**) &check_param.read_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
 
286
    (char**) &check_param.read_buffer_length, 0, GET_SIZE, REQUIRED_ARG,
293
287
    (long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD,
294
 
    INT32_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0},
 
288
    SIZE_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0},
295
289
  { "write_buffer_size", OPT_WRITE_BUFFER_SIZE, "",
296
290
    (char**) &check_param.write_buffer_length,
297
 
    (char**) &check_param.write_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
 
291
    (char**) &check_param.write_buffer_length, 0, GET_SIZE, REQUIRED_ARG,
298
292
    (long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD,
299
 
    INT32_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0},
 
293
    SIZE_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0},
300
294
  { "sort_buffer_size", OPT_SORT_BUFFER_SIZE, "",
301
295
    (char**) &check_param.sort_buffer_length,
302
 
    (char**) &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
 
296
    (char**) &check_param.sort_buffer_length, 0, GET_SIZE, REQUIRED_ARG,
303
297
    (long) SORT_BUFFER_INIT, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD),
304
 
    INT32_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0},
 
298
    SIZE_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0},
305
299
  { "sort_key_blocks", OPT_SORT_KEY_BLOCKS, "",
306
300
    (char**) &check_param.sort_key_blocks,
307
 
    (char**) &check_param.sort_key_blocks, 0, GET_ULONG, REQUIRED_ARG,
 
301
    (char**) &check_param.sort_key_blocks, 0, GET_SIZE, REQUIRED_ARG,
308
302
    BUFFERS_WHEN_SORTING, 4L, 100L, 0L, 1L, 0},
309
303
  { "decode_bits", OPT_DECODE_BITS, "", (char**) &decode_bits,
310
304
    (char**) &decode_bits, 0, GET_UINT, REQUIRED_ARG, 9L, 4L, 17L, 0L, 1L, 0},
430
424
  -R, --sort-records=#\n\
431
425
                      Sort records according to an index.  This makes your\n\
432
426
                      data much more localized and may speed up things\n\
433
 
                      (It may be VERY slow to do a sort the first time!).\n\
434
 
  -b,  --block-search=#\n\
435
 
                       Find a record, a block at given offset belongs to.");
 
427
                      (It may be VERY slow to do a sort the first time!).\n");
436
428
 
437
 
  print_defaults("my", load_default_groups);
 
429
  print_defaults("drizzle", load_default_groups);
438
430
  my_print_variables(my_long_options);
439
431
}
440
432
 
446
438
 
447
439
         /* Read options */
448
440
 
449
 
static bool
450
 
get_one_option(int optid,
451
 
               const struct my_option *opt __attribute__((unused)),
452
 
               char *argument)
 
441
bool get_one_option(int optid, const struct my_option *, char *argument)
453
442
{
454
443
  switch (optid) {
455
444
  case 'a':
567
556
    if (argument != disabled_my_option)
568
557
    {
569
558
      check_param.testflag|= T_REP;
570
 
      my_disable_async_io= 1;           /* More safety */
 
559
      my_disable_async_io= true;                /* More safety */
571
560
    }
572
561
    break;
573
562
  case 'n':
659
648
      exit(1);
660
649
    }
661
650
    switch (method-1) {
662
 
    case 0: 
 
651
    case 0:
663
652
      method_conv= MI_STATS_METHOD_NULLS_EQUAL;
664
653
      break;
665
654
    case 1:
669
658
      method_conv= MI_STATS_METHOD_IGNORE_NULLS;
670
659
      break;
671
660
    default: assert(0);                         /* Impossible */
 
661
      fprintf(stderr, "Invalid value of stats_method: %s.\n", argument);
 
662
      exit(1);
672
663
    }
673
664
    check_param.stats_method= method_conv;
674
665
    break;
693
684
{
694
685
  int ho_error;
695
686
 
696
 
  load_defaults("my", load_default_groups, argc, argv);
 
687
  load_defaults("drizzle", load_default_groups, argc, argv);
697
688
  default_argv= *argv;
698
689
  if (isatty(fileno(stdout)))
699
690
    check_param.testflag|=T_WRITE_LOOP;
731
722
    exit(1);
732
723
  }
733
724
 
734
 
  if (init_tmpdir(&myisamchk_tmpdir, opt_tmpdir))
735
 
    exit(1);
736
 
 
737
 
  check_param.tmpdir=&myisamchk_tmpdir;
738
725
  check_param.key_cache_block_size= opt_key_cache_block_size;
739
726
 
740
727
  if (set_collation_name)
741
 
    if (!(set_collation= get_charset_by_name(set_collation_name,
742
 
                                             MYF(MY_WME))))
 
728
    if (!(set_collation= get_charset_by_name(set_collation_name)))
743
729
      exit(1);
744
730
 
745
731
  myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size);
1032
1018
      {
1033
1019
        if (param->testflag & (T_EXTEND | T_MEDIUM))
1034
1020
          init_key_cache(dflt_key_cache,opt_key_cache_block_size,
1035
 
                         param->use_buffers, 0, 0);
 
1021
                         (size_t)param->use_buffers, 0, 0);
1036
1022
        init_io_cache(&param->read_cache,datafile,
1037
1023
                      (uint) param->read_buffer_length,
1038
1024
                      READ_CACHE,
1150
1136
  else
1151
1137
    puts("Fixed length");
1152
1138
  printf("Character set:       %s (%d)\n",
1153
 
         get_charset_name(share->state.header.language),
1154
 
         share->state.header.language);
 
1139
  get_charset_name(share->state.header.language),
 
1140
  share->state.header.language);
1155
1141
 
1156
1142
  if (param->testflag & T_VERBOSE)
1157
1143
  {
1169
1155
    }
1170
1156
    pos=buff;
1171
1157
    if (share->state.changed & STATE_CRASHED)
1172
 
      my_stpcpy(buff,"crashed");
 
1158
      strcpy(buff,"crashed");
1173
1159
    else
1174
1160
    {
1175
1161
      if (share->state.open_count)
1176
 
        pos=my_stpcpy(pos,"open,");
 
1162
        pos= strcpy(pos,"open,")+5;
1177
1163
      if (share->state.changed & STATE_CHANGED)
1178
 
        pos=my_stpcpy(pos,"changed,");
 
1164
        pos= strcpy(pos,"changed,")+8;
1179
1165
      else
1180
 
        pos=my_stpcpy(pos,"checked,");
 
1166
        pos= strcpy(pos,"checked,")+8;
1181
1167
      if (!(share->state.changed & STATE_NOT_ANALYZED))
1182
 
        pos=my_stpcpy(pos,"analyzed,");
 
1168
        pos= strcpy(pos,"analyzed,")+9;
1183
1169
      if (!(share->state.changed & STATE_NOT_OPTIMIZED_KEYS))
1184
 
        pos=my_stpcpy(pos,"optimized keys,");
 
1170
        pos= strcpy(pos,"optimized keys,")+15;
1185
1171
      if (!(share->state.changed & STATE_NOT_SORTED_PAGES))
1186
 
        pos=my_stpcpy(pos,"sorted index pages,");
 
1172
        pos= strcpy(pos,"sorted index pages,")+19;
1187
1173
      pos[-1]=0;                                /* Remove extra ',' */
1188
 
    }      
 
1174
    }
1189
1175
    printf("Status:              %s\n",buff);
1190
1176
    if (share->base.auto_key)
1191
1177
    {
1193
1179
             share->base.auto_key,
1194
1180
             llstr(share->state.auto_increment,llbuff));
1195
1181
    }
1196
 
    if (share->base.raid_type)
1197
 
    {
1198
 
      printf("RAID:                Type:  %u   Chunks: %u  Chunksize: %lu\n",
1199
 
             share->base.raid_type,
1200
 
             share->base.raid_chunks,
1201
 
             share->base.raid_chunksize);
1202
 
    }
1203
1182
    if (share->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
1204
1183
      printf("Checksum:  %23s\n",llstr(info->state->checksum,llbuff));
1205
1184
;
1208
1187
 
1209
1188
  }
1210
1189
  printf("Data records:        %13s  Deleted blocks:     %13s\n",
1211
 
         llstr(info->state->records,llbuff),llstr(info->state->del,llbuff2));
 
1190
  llstr(info->state->records,llbuff),llstr(info->state->del,llbuff2));
1212
1191
  if (param->testflag & T_SILENT)
1213
1192
    return;                             /* This is enough */
1214
1193
 
1218
1197
    printf("Init-relocation:     %13s\n",llstr(share->base.reloc,llbuff));
1219
1198
#endif
1220
1199
    printf("Datafile parts:      %13s  Deleted data:       %13s\n",
1221
 
           llstr(share->state.split,llbuff),
1222
 
           llstr(info->state->empty,llbuff2));
 
1200
    llstr(share->state.split,llbuff),
 
1201
    llstr(info->state->empty,llbuff2));
1223
1202
    printf("Datafile pointer (bytes):%9d  Keyfile pointer (bytes):%9d\n",
1224
 
           share->rec_reflength,share->base.key_reflength);
 
1203
    share->rec_reflength,share->base.key_reflength);
1225
1204
    printf("Datafile length:     %13s  Keyfile length:     %13s\n",
1226
 
           llstr(info->state->data_file_length,llbuff),
1227
 
           llstr(info->state->key_file_length,llbuff2));
 
1205
    llstr(info->state->data_file_length,llbuff),
 
1206
    llstr(info->state->key_file_length,llbuff2));
1228
1207
 
1229
1208
    if (info->s->base.reloc == 1L && info->s->base.records == 1L)
1230
1209
      puts("This is a one-record table");
1231
1210
    else
1232
1211
    {
1233
1212
      if (share->base.max_data_file_length != HA_OFFSET_ERROR ||
1234
 
          share->base.max_key_file_length != HA_OFFSET_ERROR)
1235
 
        printf("Max datafile length: %13s  Max keyfile length: %13s\n",
1236
 
               llstr(share->base.max_data_file_length-1,llbuff),
1237
 
               llstr(share->base.max_key_file_length-1,llbuff2));
 
1213
          share->base.max_key_file_length != HA_OFFSET_ERROR)
 
1214
        printf("Max datafile length: %13s  Max keyfile length: %13s\n",
 
1215
                     llstr(share->base.max_data_file_length-1,llbuff),
 
1216
                     llstr(share->base.max_key_file_length-1,llbuff2));
1238
1217
    }
1239
1218
  }
1240
1219
 
1243
1222
  {
1244
1223
    int64_t2str(share->state.key_map,buff,2);
1245
1224
    printf("Using only keys '%s' of %d possibly keys\n",
1246
 
           buff, share->base.keys);
 
1225
    buff, share->base.keys);
1247
1226
  }
1248
1227
  puts("\ntable description:");
1249
1228
  printf("Key Start Len Index   Type");
1262
1241
    pos=buff;
1263
1242
    if (keyseg->flag & HA_REVERSE_SORT)
1264
1243
      *pos++ = '-';
1265
 
    pos=my_stpcpy(pos,type_names[keyseg->type]);
 
1244
    pos= strcpy(pos,type_names[keyseg->type]);
 
1245
    pos+= strlen(type_names[keyseg->type]);
1266
1246
    *pos++ = ' ';
1267
1247
    *pos=0;
1268
1248
    if (keyinfo->flag & HA_PACK_KEY)
1269
 
      pos=my_stpcpy(pos,prefix_packed_txt);
 
1249
      pos= strcpy(pos,prefix_packed_txt) + strlen(prefix_packed_txt);
1270
1250
    if (keyinfo->flag & HA_BINARY_PACK_KEY)
1271
 
      pos=my_stpcpy(pos,bin_packed_txt);
 
1251
      pos= strcpy(pos,bin_packed_txt) + strlen(bin_packed_txt);
1272
1252
    if (keyseg->flag & HA_SPACE_PACK)
1273
 
      pos=my_stpcpy(pos,diff_txt);
 
1253
      pos= strcpy(pos,diff_txt) + strlen(diff_txt);
1274
1254
    if (keyseg->flag & HA_BLOB_PART)
1275
 
      pos=my_stpcpy(pos,blob_txt);
 
1255
      pos= strcpy(pos,blob_txt) + strlen(blob_txt);
1276
1256
    if (keyseg->flag & HA_NULL_PART)
1277
 
      pos=my_stpcpy(pos,null_txt);
 
1257
      pos= strcpy(pos,null_txt) + strlen(null_txt);
1278
1258
    *pos=0;
1279
1259
 
1280
1260
    printf("%-4d%-6ld%-3d %-8s%-21s",
1281
 
           key+1,(long) keyseg->start+1,keyseg->length,text,buff);
 
1261
           key+1,(long) keyseg->start+1,keyseg->length,text,buff);
1282
1262
    if (share->state.key_root[key] != HA_OFFSET_ERROR)
1283
1263
      llstr(share->state.key_root[key],buff);
1284
1264
    else
1285
1265
      buff[0]=0;
1286
1266
    if (param->testflag & T_VERBOSE)
1287
1267
      printf("%11lu %12s %10d",
1288
 
             share->state.rec_per_key_part[keyseg_nr++],
1289
 
             buff,keyinfo->block_length);
 
1268
    share->state.rec_per_key_part[keyseg_nr++],
 
1269
    buff,keyinfo->block_length);
1290
1270
    putchar('\n');
1291
1271
    while ((++keyseg)->type != HA_KEYTYPE_END)
1292
1272
    {
1293
1273
      pos=buff;
1294
1274
      if (keyseg->flag & HA_REVERSE_SORT)
1295
 
        *pos++ = '-';
1296
 
      pos=my_stpcpy(pos,type_names[keyseg->type]);
 
1275
        *pos++ = '-';
 
1276
      pos= strcpy(pos,type_names[keyseg->type]);
 
1277
      pos+= strlen(type_names[keyseg->type]);
1297
1278
      *pos++= ' ';
1298
1279
      if (keyseg->flag & HA_SPACE_PACK)
1299
 
        pos=my_stpcpy(pos,diff_txt);
 
1280
        pos= strcpy(pos,diff_txt) + strlen(diff_txt);
1300
1281
      if (keyseg->flag & HA_BLOB_PART)
1301
 
        pos=my_stpcpy(pos,blob_txt);
 
1282
        pos= strcpy(pos,blob_txt) + strlen(blob_txt);
1302
1283
      if (keyseg->flag & HA_NULL_PART)
1303
 
        pos=my_stpcpy(pos,null_txt);
 
1284
        pos= strcpy(pos,null_txt) + strlen(null_txt);
1304
1285
      *pos=0;
1305
1286
      printf("    %-6ld%-3d         %-21s",
1306
1287
             (long) keyseg->start+1,keyseg->length,buff);
1307
1288
      if (param->testflag & T_VERBOSE)
1308
 
        printf("%11lu", share->state.rec_per_key_part[keyseg_nr++]);
 
1289
        printf("%11lu", share->state.rec_per_key_part[keyseg_nr++]);
1309
1290
      putchar('\n');
1310
1291
    }
1311
1292
    keyseg++;
1315
1296
    MI_UNIQUEDEF *uniqueinfo;
1316
1297
    puts("\nUnique  Key  Start  Len  Nullpos  Nullbit  Type");
1317
1298
    for (key=0,uniqueinfo= &share->uniqueinfo[0] ;
1318
 
         key < share->state.header.uniques; key++, uniqueinfo++)
 
1299
         key < share->state.header.uniques; key++, uniqueinfo++)
1319
1300
    {
1320
1301
      bool new_row=0;
1321
1302
      char null_bit[8],null_pos[8];
1322
1303
      printf("%-8d%-5d",key+1,uniqueinfo->key+1);
1323
1304
      for (keyseg=uniqueinfo->seg ; keyseg->type != HA_KEYTYPE_END ; keyseg++)
1324
1305
      {
1325
 
        if (new_row)
1326
 
          fputs("             ",stdout);
1327
 
        null_bit[0]=null_pos[0]=0;
1328
 
        if (keyseg->null_bit)
1329
 
        {
1330
 
          sprintf(null_bit,"%d",keyseg->null_bit);
1331
 
          sprintf(null_pos,"%ld",(long) keyseg->null_pos+1);
1332
 
        }
1333
 
        printf("%-7ld%-5d%-9s%-10s%-30s\n",
1334
 
               (long) keyseg->start+1,keyseg->length,
1335
 
               null_pos,null_bit,
1336
 
               type_names[keyseg->type]);
1337
 
        new_row=1;
 
1306
        if (new_row)
 
1307
          fputs("             ",stdout);
 
1308
        null_bit[0]=null_pos[0]=0;
 
1309
        if (keyseg->null_bit)
 
1310
        {
 
1311
          sprintf(null_bit,"%d",keyseg->null_bit);
 
1312
          sprintf(null_pos,"%ld",(long) keyseg->null_pos+1);
 
1313
        }
 
1314
        printf("%-7ld%-5d%-9s%-10s%-30s\n",
 
1315
               (long) keyseg->start+1,keyseg->length,
 
1316
               null_pos,null_bit,
 
1317
               type_names[keyseg->type]);
 
1318
        new_row=1;
1338
1319
      }
1339
1320
    }
1340
1321
  }
1349
1330
    for (field=0 ; field < share->base.fields ; field++)
1350
1331
    {
1351
1332
      if (share->options & HA_OPTION_COMPRESS_RECORD)
1352
 
        type=share->rec[field].base_type;
 
1333
        type=share->rec[field].base_type;
1353
1334
      else
1354
 
        type=(enum en_fieldtype) share->rec[field].type;
1355
 
      end=my_stpcpy(buff,field_pack[type]);
 
1335
        type=(enum en_fieldtype) share->rec[field].type;
 
1336
      end= strcpy(buff, field_pack[type]);
 
1337
      end+= strlen(field_pack[type]);
1356
1338
      if (share->options & HA_OPTION_COMPRESS_RECORD)
1357
1339
      {
1358
 
        if (share->rec[field].pack_type & PACK_TYPE_SELECTED)
1359
 
          end=my_stpcpy(end,", not_always");
1360
 
        if (share->rec[field].pack_type & PACK_TYPE_SPACE_FIELDS)
1361
 
          end=my_stpcpy(end,", no empty");
1362
 
        if (share->rec[field].pack_type & PACK_TYPE_ZERO_FILL)
1363
 
        {
1364
 
          sprintf(end,", zerofill(%d)",share->rec[field].space_length_bits);
1365
 
          end= strchr(end, '\0');
1366
 
        }
 
1340
        if (share->rec[field].pack_type & PACK_TYPE_SELECTED)
 
1341
          end= strcpy(end,", not_always")+12;
 
1342
        if (share->rec[field].pack_type & PACK_TYPE_SPACE_FIELDS)
 
1343
          end= strcpy(end,", no empty")+10;
 
1344
        if (share->rec[field].pack_type & PACK_TYPE_ZERO_FILL)
 
1345
        {
 
1346
          sprintf(end,", zerofill(%d)",share->rec[field].space_length_bits);
 
1347
          end= strchr(end, '\0');
 
1348
        }
1367
1349
      }
1368
1350
      if (buff[0] == ',')
1369
 
        my_stpcpy(buff,buff+2);
 
1351
        strcpy(buff,buff+2);
1370
1352
      int10_to_str((long) share->rec[field].length,length,10);
1371
1353
      null_bit[0]=null_pos[0]=0;
1372
1354
      if (share->rec[field].null_bit)
1373
1355
      {
1374
 
        sprintf(null_bit,"%d",share->rec[field].null_bit);
1375
 
        sprintf(null_pos,"%d",share->rec[field].null_pos+1);
 
1356
        sprintf(null_bit,"%d",share->rec[field].null_bit);
 
1357
        sprintf(null_pos,"%d",share->rec[field].null_pos+1);
1376
1358
      }
1377
1359
      printf("%-6d%-6d%-7s%-8s%-8s%-35s",field+1,start,length,
1378
1360
             null_pos, null_bit, buff);
1444
1426
  if (share->state.key_root[sort_key] == HA_OFFSET_ERROR)
1445
1427
    return(0);                          /* Nothing to do */
1446
1428
 
1447
 
  init_key_cache(dflt_key_cache, opt_key_cache_block_size, param->use_buffers,
 
1429
  init_key_cache(dflt_key_cache, opt_key_cache_block_size, 
 
1430
                 (size_t)param->use_buffers,
1448
1431
                 0, 0);
1449
1432
  if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length,
1450
1433
                   WRITE_CACHE,share->pack.header_length,1,
1452
1435
    goto err;
1453
1436
  info->opt_flag|=WRITE_CACHE_USED;
1454
1437
 
1455
 
  if (!(temp_buff=(unsigned char*) my_alloca((uint) keyinfo->block_length)))
 
1438
  if (!(temp_buff=(unsigned char*) malloc(keyinfo->block_length)))
1456
1439
  {
1457
1440
    mi_check_print_error(param,"Not enough memory for key block");
1458
1441
    goto err;
1459
1442
  }
1460
1443
 
1461
 
  if (!mi_alloc_rec_buff(info, -1, &sort_param.record))
 
1444
  if (!mi_alloc_rec_buff(info, (ulong)-1, &sort_param.record))
1462
1445
  {
1463
1446
    mi_check_print_error(param,"Not enough memory for record");
1464
1447
    goto err;
1465
1448
  }
1466
1449
  fn_format(param->temp_filename,name,"", MI_NAME_DEXT,2+4+32);
1467
 
  new_file=my_raid_create(fn_format(param->temp_filename,
1468
 
                                    param->temp_filename,"",
1469
 
                                    DATA_TMP_EXT,2+4),
1470
 
                          0,param->tmpfile_createflag,
1471
 
                          share->base.raid_type,
1472
 
                          share->base.raid_chunks,
1473
 
                          share->base.raid_chunksize,
1474
 
                          MYF(0));
 
1450
  new_file=my_create(fn_format(param->temp_filename,
 
1451
                               param->temp_filename,"",
 
1452
                               DATA_TMP_EXT,2+4),
 
1453
                     0,param->tmpfile_createflag,
 
1454
                     MYF(0));
1475
1455
  if (new_file < 0)
1476
1456
  {
1477
1457
    mi_check_print_error(param,"Can't create new tempfile: '%s'",
1546
1526
  {
1547
1527
    end_io_cache(&info->rec_cache);
1548
1528
    (void) my_close(new_file,MYF(MY_WME));
1549
 
    (void) my_raid_delete(param->temp_filename, share->base.raid_chunks,
1550
 
                          MYF(MY_WME));
 
1529
    (void) my_delete(param->temp_filename, MYF(MY_WME));
1551
1530
  }
1552
1531
  if (temp_buff)
1553
1532
  {
1554
 
    my_afree((unsigned char*) temp_buff);
 
1533
    free((unsigned char*) temp_buff);
1555
1534
  }
1556
1535
  void * rec_buff_ptr= mi_get_rec_buff_ptr(info, sort_param.record);
1557
1536
  if (rec_buff_ptr != NULL)
1587
1566
 
1588
1567
  if (nod_flag)
1589
1568
  {
1590
 
    if (!(temp_buff=(unsigned char*) my_alloca((uint) keyinfo->block_length)))
 
1569
    if (!(temp_buff=(unsigned char*) malloc(keyinfo->block_length)))
1591
1570
    {
1592
1571
      mi_check_print_error(param,"Not Enough memory");
1593
1572
      return(-1);
1647
1626
    goto err;
1648
1627
  }
1649
1628
  if (temp_buff)
1650
 
    my_afree((unsigned char*) temp_buff);
 
1629
    free((unsigned char*) temp_buff);
1651
1630
  return(0);
1652
1631
err:
1653
1632
  if (temp_buff)
1654
 
    my_afree((unsigned char*) temp_buff);
 
1633
    free((unsigned char*) temp_buff);
1655
1634
  return(1);
1656
1635
} /* sort_record_index */
1657
1636
 
1665
1644
 
1666
1645
static int not_killed= 0;
1667
1646
 
1668
 
volatile int *killed_ptr(MI_CHECK *param __attribute__((unused)))
 
1647
volatile int *killed_ptr(MI_CHECK *)
1669
1648
{
1670
1649
  return &not_killed;                   /* always NULL */
1671
1650
}
1673
1652
        /* print warnings and errors */
1674
1653
        /* VARARGS */
1675
1654
 
1676
 
void mi_check_print_info(MI_CHECK *param __attribute__((unused)),
 
1655
void mi_check_print_info(MI_CHECK *,
1677
1656
                         const char *fmt,...)
1678
1657
{
1679
1658
  va_list args;