summaryrefslogtreecommitdiff
path: root/storage/archive/archive_reader.c
diff options
context:
space:
mode:
authorunknown <brian@zim.(none)>2007-01-24 10:30:06 -0800
committerunknown <brian@zim.(none)>2007-01-24 10:30:06 -0800
commit9fd43125361b8d8e3a6fa7cfcb8e975f385c4a8c (patch)
tree8fc1c9e9f6fcb67b11f8e8d81fad8bdf5cb6604e /storage/archive/archive_reader.c
parent58b898f60867f0a9839c8be1d60b4e85f87c1175 (diff)
downloadmariadb-git-9fd43125361b8d8e3a6fa7cfcb8e975f385c4a8c.tar.gz
This patch passes comment to be embedded in ARZ.
Fixes autodiscovery of tables. Allows the FRM to be extracted from the ARZ file via archive_reader. storage/archive/archive_reader.c: Extract FRM command added. We now print the embedded comment storage/archive/archive_test.c: Additional tests for FRM annd comment storage/archive/azio.c: Filled in functionality for comment and frm. storage/archive/azlib.h: Refactored position. storage/archive/ha_archive.cc: Discovery mechanism filled in.
Diffstat (limited to 'storage/archive/archive_reader.c')
-rw-r--r--storage/archive/archive_reader.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/storage/archive/archive_reader.c b/storage/archive/archive_reader.c
index 1de398625dc..89cc6740300 100644
--- a/storage/archive/archive_reader.c
+++ b/storage/archive/archive_reader.c
@@ -18,7 +18,7 @@ static const char *opt_tmpdir;
static const char *new_auto_increment_value;
static const char *load_default_groups[]= { "archive_reader", 0 };
static char **default_argv;
-int opt_check, opt_force, opt_quiet, opt_backup= 0;
+int opt_check, opt_force, opt_quiet, opt_backup= 0, opt_extract_frm;
int main(int argc, char *argv[])
{
@@ -53,6 +53,20 @@ int main(int argc, char *argv[])
printf("\tLongest Row %u\n", reader_handle.longest_row);
printf("\tShortest Row %u\n", reader_handle.shortest_row);
printf("\tState %s\n", ( reader_handle.dirty ? "dirty" : "clean"));
+ printf("\tFRM stored at %u\n", reader_handle.frm_start_pos);
+ printf("\tComment stored at %u\n", reader_handle.comment_start_pos);
+ printf("\tData starts at %u\n", (unsigned int)reader_handle.start);
+ if (reader_handle.frm_start_pos)
+ printf("\tFRM length %u\n", reader_handle.frm_length);
+ if (reader_handle.comment_start_pos)
+ {
+ char *comment =
+ (char *) malloc(sizeof(char) * reader_handle.comment_length);
+ azread_comment(&reader_handle, comment);
+ printf("\tComment length %u\n\t\t%.*s\n", reader_handle.comment_length,
+ reader_handle.comment_length, comment);
+ free(comment);
+ }
}
else
{
@@ -148,6 +162,23 @@ int main(int argc, char *argv[])
}
writer_handle.auto_increment= reader_handle.auto_increment;
+ if (reader_handle.frm_length)
+ {
+ char *ptr;
+ ptr= (char *)my_malloc(sizeof(char) * reader_handle.frm_length, MYF(0));
+ azread_frm(&reader_handle, ptr);
+ azwrite_frm(&writer_handle, ptr, reader_handle.frm_length);
+ my_free(ptr, MYF(0));
+ }
+
+ if (reader_handle.comment_length)
+ {
+ char *ptr;
+ ptr= (char *)my_malloc(sizeof(char) * reader_handle.comment_length, MYF(0));
+ azread_comment(&reader_handle, ptr);
+ azwrite_comment(&writer_handle, ptr, reader_handle.comment_length);
+ my_free(ptr, MYF(0));
+ }
while ((read= azread(&reader_handle, (byte *)size_buffer,
ARCHIVE_ROW_HEADER_SIZE, &error)))
@@ -192,6 +223,18 @@ int main(int argc, char *argv[])
azclose(&writer_handle);
}
+ if (opt_extract_frm)
+ {
+ File frm_file;
+ char *ptr;
+ frm_file= my_open(argv[1], O_CREAT|O_RDWR|O_BINARY, MYF(0));
+ ptr= (char *)my_malloc(sizeof(char) * reader_handle.frm_length, MYF(0));
+ azread_frm(&reader_handle, ptr);
+ my_write(frm_file, ptr, reader_handle.frm_length, MYF(0));
+ my_close(frm_file, MYF(0));
+ my_free(ptr, MYF(0));
+ }
+
end:
printf("\n");
azclose(&reader_handle);
@@ -211,6 +254,9 @@ get_one_option(int optid,
case 'c':
opt_check= 1;
break;
+ case 'e':
+ opt_extract_frm= 1;
+ break;
case 'f':
opt_force= 1;
printf("Not implemented yet\n");
@@ -257,6 +303,9 @@ static struct my_option my_long_options[] =
"Output debug log. Often this is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
+ {"extract-frm", 'e',
+ "Extract the frm file.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f',
"Restart with -r if there are any errors in the table.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},