~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/archive_reader.c

  • Committer: Brian Aker
  • Date: 2008-07-13 22:45:08 UTC
  • Revision ID: brian@tangent.org-20080713224508-hb20z4okblotb39a
longlong replacement

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#include <assert.h>
4
4
#include <stdio.h>
5
5
#include <stdarg.h>
6
 
#include <mystrings/m_ctype.h>
7
 
#include <mystrings/m_string.h>
8
 
#include <mysys/my_getopt.h>
 
6
#include <m_ctype.h>
 
7
#include <m_string.h>
 
8
#include <my_getopt.h>
 
9
#include <drizzle_version.h>
9
10
 
10
11
#define BUFFER_LEN 1024
11
12
#define ARCHIVE_ROW_HEADER_SIZE 4
78
79
  if (reader_handle.version > 2)
79
80
  {
80
81
    printf("\tMinor version %u\n", reader_handle.minor_version);
81
 
    printf("\tStart position %"PRIu64"\n", (uint64_t)reader_handle.start);
 
82
    printf("\tStart position %lu\n", (uint64_t)reader_handle.start);
82
83
    printf("\tBlock size %u\n", reader_handle.block_size);
83
 
    printf("\tRows %"PRIu64"\n", reader_handle.rows);
84
 
    printf("\tAutoincrement %"PRIu64"\n", reader_handle.auto_increment);
85
 
    printf("\tCheck Point %"PRIu64"\n", reader_handle.check_point);
86
 
    printf("\tForced Flushes %"PRIu64"\n", reader_handle.forced_flushes);
 
84
    printf("\tRows %lu\n", reader_handle.rows);
 
85
    printf("\tAutoincrement %lu\n", reader_handle.auto_increment);
 
86
    printf("\tCheck Point %lu\n", reader_handle.check_point);
 
87
    printf("\tForced Flushes %lu\n", reader_handle.forced_flushes);
87
88
    printf("\tLongest Row %u\n", reader_handle.longest_row);
88
89
    printf("\tShortest Row %u\n", reader_handle.shortest_row);
89
90
    printf("\tState %s\n", ( reader_handle.dirty ? "dirty" : "clean"));
127
128
 
128
129
      if (read > reader_handle.longest_row)
129
130
      {
130
 
        printf("Table is damaged, row %"PRIu64" is invalid\n", row_count);
 
131
        printf("Table is damaged, row %lu is invalid\n", row_count);
131
132
        goto end;
132
133
      }
133
134
    }
134
135
 
135
 
    printf("Found %"PRIu64" rows\n", row_count);
 
136
    printf("Found %lu rows\n", row_count);
136
137
  }
137
138
 
138
139
  if (opt_backup)
147
148
    buffer= (char *)malloc(reader_handle.longest_row);
148
149
    if (buffer == NULL)
149
150
    {
150
 
      printf("Could not allocate memory for row %"PRIu64"\n", row_count);
 
151
      printf("Could not allocate memory for row %lu\n", row_count);
151
152
      goto end;
152
153
    }
153
154
 
166
167
      ptr= (char *)my_malloc(sizeof(char) * reader_handle.frm_length, MYF(0));
167
168
      azread_frm(&reader_handle, ptr);
168
169
      azwrite_frm(&writer_handle, ptr, reader_handle.frm_length);
169
 
      free(ptr);
 
170
      my_free(ptr, MYF(0));
170
171
    }
171
172
 
172
173
    if (reader_handle.comment_length)
175
176
      ptr= (char *)my_malloc(sizeof(char) * reader_handle.comment_length, MYF(0));
176
177
      azread_comment(&reader_handle, ptr);
177
178
      azwrite_comment(&writer_handle, ptr, reader_handle.comment_length);
178
 
      free(ptr);
 
179
      my_free(ptr, MYF(0));
179
180
    }
180
181
 
181
182
    while ((read= azread_row(&reader_handle, &error)))
210
211
    frm_file= my_open(argv[1], O_CREAT|O_RDWR|O_BINARY, MYF(0));
211
212
    ptr= (char *)my_malloc(sizeof(char) * reader_handle.frm_length, MYF(0));
212
213
    azread_frm(&reader_handle, ptr);
213
 
    my_write(frm_file, (unsigned char*) ptr, reader_handle.frm_length, MYF(0));
 
214
    my_write(frm_file, (uchar*) ptr, reader_handle.frm_length, MYF(0));
214
215
    my_close(frm_file, MYF(0));
215
 
    free(ptr);
 
216
    my_free(ptr, MYF(0));
216
217
  }
217
218
 
218
219
end:
262
263
  case '?':
263
264
    usage();
264
265
    exit(0);
 
266
  case '#':
 
267
    if (argument == disabled_my_option)
 
268
    {
 
269
      DBUG_POP();
 
270
    }
 
271
    else
 
272
    {
 
273
      DBUG_PUSH(argument ? argument : "d:t:o,/tmp/archive_reader.trace");
 
274
    }
 
275
    break;
265
276
  }
266
277
  return 0;
267
278
}
273
284
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
274
285
  {"check", 'c', "Check table for errors.",
275
286
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
 
287
#ifndef DBUG_OFF
 
288
  {"debug", '#',
 
289
   "Output debug log. Often this is 'd:t:o,filename'.",
 
290
   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 
291
#endif
276
292
  {"extract-frm", 'e',
277
293
   "Extract the frm file.",
278
294
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
319
335
 
320
336
static void print_version(void)
321
337
{
322
 
  printf("%s  Ver %s, for %s (%s)\n", my_progname, SHOW_VERSION,
323
 
         SYSTEM_TYPE, MACHINE_TYPE);
 
338
  printf("%s  Ver %s Distrib %s, for %s (%s)\n", my_progname, SHOW_VERSION,
 
339
         MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
324
340
}
325
341
 
326
342
static void get_options(int *argc, char ***argv)