1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (c) 2006 MySQL AB
5
* Copyright (c) 2009 Sun Microsystems, Inc.
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; version 2 of the License.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29
#include "drizzled/charset_info.h"
30
#include "drizzled/internal/m_string.h"
31
#include "drizzled/option.h"
6
#include <mystrings/m_ctype.h>
7
#include <mystrings/m_string.h>
8
#include <mysys/my_getopt.h>
33
10
#define SHOW_VERSION "0.1"
35
using namespace drizzled;
37
int get_one_option(int optid, const struct option *opt, char *argument);
13
get_one_option(int optid, const struct my_option *opt, char *argument);
39
15
static void get_options(int *argc,char * * *argv);
40
16
static void print_version(void);
44
20
uint64_t new_auto_increment_value;
45
21
static const char *load_default_groups[]= { "archive_reader", 0 };
46
22
static char **default_argv;
47
int opt_check, opt_force, opt_quiet, opt_backup= 0, opt_extract_table_message;
23
int opt_check, opt_force, opt_quiet, opt_backup= 0, opt_extract_frm;
48
24
int opt_autoincrement;
50
26
int main(int argc, char *argv[])
111
87
printf("\tLongest Row %u\n", reader_handle.longest_row);
112
88
printf("\tShortest Row %u\n", reader_handle.shortest_row);
113
89
printf("\tState %s\n", ( reader_handle.dirty ? "dirty" : "clean"));
114
printf("\tTable protobuf message stored at %u\n",
115
reader_handle.frm_start_pos);
90
printf("\tFRM stored at %u\n", reader_handle.frm_start_pos);
116
91
printf("\tComment stored at %u\n", reader_handle.comment_start_pos);
117
92
printf("\tData starts at %u\n", (unsigned int)reader_handle.start);
118
93
if (reader_handle.frm_start_pos)
119
printf("\tTable proto message length %u\n", reader_handle.frm_length);
94
printf("\tFRM length %u\n", reader_handle.frm_length);
120
95
if (reader_handle.comment_start_pos)
233
208
azclose(&writer_handle);
236
if (opt_extract_table_message)
240
frm_file= internal::my_open(argv[1], O_CREAT|O_RDWR, MYF(0));
215
frm_file= my_open(argv[1], O_CREAT|O_RDWR, MYF(0));
241
216
ptr= (char *)malloc(sizeof(char) * reader_handle.frm_length);
247
222
azread_frm(&reader_handle, ptr);
248
internal::my_write(frm_file, (unsigned char*) ptr, reader_handle.frm_length, MYF(0));
249
internal::my_close(frm_file, MYF(0));
223
my_write(frm_file, (unsigned char*) ptr, reader_handle.frm_length, MYF(0));
224
my_close(frm_file, MYF(0));
302
static struct option my_long_options[] =
277
static struct my_option my_long_options[] =
305
280
"Make a backup of an archive table.",
306
281
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
307
282
{"check", 'c', "Check table for errors.",
308
283
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
309
{"extract-table-message", 'e',
310
"Extract the table protobuf message.",
285
"Extract the frm file.",
311
286
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
313
288
"Restart with -r if there are any errors in the table.",
345
320
\nand you are welcome to modify and redistribute it under the GPL \
347
322
puts("Read and modify Archive files directly\n");
348
printf("Usage: %s [OPTIONS] file_to_be_looked_at [file_for_backup]\n", internal::my_progname);
349
internal::print_defaults("drizzle", load_default_groups);
323
printf("Usage: %s [OPTIONS] file_to_be_looked_at [file_for_backup]\n", my_progname);
324
print_defaults("drizzle", load_default_groups);
350
325
my_print_help(my_long_options);
353
328
static void print_version(void)
355
printf("%s Ver %s, for %s-%s (%s)\n", internal::my_progname, SHOW_VERSION,
330
printf("%s Ver %s, for %s-%s (%s)\n", my_progname, SHOW_VERSION,
356
331
HOST_VENDOR, HOST_OS, HOST_CPU);
359
334
static void get_options(int *argc, char ***argv)
361
internal::load_defaults("drizzle", load_default_groups, argc, argv);
336
load_defaults("drizzle", load_default_groups, argc, argv);
362
337
default_argv= *argv;
364
339
handle_options(argc, argv, my_long_options, get_one_option);