summaryrefslogtreecommitdiff
path: root/storage/archive
diff options
context:
space:
mode:
authorunknown <brian@zim.(none)>2007-01-26 10:17:53 -0800
committerunknown <brian@zim.(none)>2007-01-26 10:17:53 -0800
commit45a46fa1339e790b12d533966b3fca44205058f5 (patch)
treeefdf560a73195d74bc3c7fdc27434fb4921453b6 /storage/archive
parent8664552c1e3ca6d8566b159ccfbbf9cd7ba89e07 (diff)
downloadmariadb-git-45a46fa1339e790b12d533966b3fca44205058f5.tar.gz
Fixed a warning. Added the -A option so that the autoincrement could be set outside of the file.
storage/archive/archive_reader.c: Add option to autoincrement file. storage/archive/ha_archive.cc: Fixed warning
Diffstat (limited to 'storage/archive')
-rw-r--r--storage/archive/archive_reader.c46
-rw-r--r--storage/archive/ha_archive.cc4
2 files changed, 43 insertions, 7 deletions
diff --git a/storage/archive/archive_reader.c b/storage/archive/archive_reader.c
index 89cc6740300..66b90130882 100644
--- a/storage/archive/archive_reader.c
+++ b/storage/archive/archive_reader.c
@@ -3,6 +3,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
+#include <m_ctype.h>
#include <my_getopt.h>
#include <mysql_version.h>
@@ -15,10 +16,12 @@ static void get_options(int *argc,char * * *argv);
static void print_version(void);
static void usage(void);
static const char *opt_tmpdir;
-static const char *new_auto_increment_value;
+static const char *new_auto_increment;
+unsigned long long 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, opt_extract_frm;
+int opt_autoincrement;
int main(int argc, char *argv[])
{
@@ -40,6 +43,35 @@ int main(int argc, char *argv[])
return 0;
}
+ if (opt_autoincrement)
+ {
+ azio_stream writer_handle;
+
+ if (new_auto_increment_value)
+ {
+ if (reader_handle.auto_increment >= new_auto_increment_value)
+ {
+ printf("Value is lower then current value\n");
+ goto end;
+ }
+ }
+ else
+ {
+ new_auto_increment_value= reader_handle.auto_increment + 1;
+ }
+
+ if (!(ret= azopen(&writer_handle, argv[0], O_CREAT|O_RDWR|O_BINARY)))
+ {
+ printf("Could not open file for update: %s\n", argv[0]);
+ goto end;
+ }
+
+ writer_handle.auto_increment= new_auto_increment_value;
+
+ azclose(&writer_handle);
+ azflush(&reader_handle, Z_SYNC_FLUSH);
+ }
+
printf("Version %u\n", reader_handle.version);
if (reader_handle.version > 2)
{
@@ -272,7 +304,11 @@ get_one_option(int optid,
printf("Not implemented yet\n");
break;
case 'A':
- printf("Not implemented yet\n");
+ opt_autoincrement= 1;
+ if (argument)
+ new_auto_increment_value= strtoull(argument, NULL, 0);
+ else
+ new_auto_increment_value= 0;
break;
case '?':
usage();
@@ -317,9 +353,9 @@ static struct my_option my_long_options[] =
{"repair", 'r', "Repair a damaged Archive version 3 or above file.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"set-auto-increment", 'A',
- "Force auto_increment to start at this or higher value.",
- (gptr*) &new_auto_increment_value,
- (gptr*) &new_auto_increment_value,
+ "Force auto_increment to start at this or higher value. If no value is given, then sets the next auto_increment value to the highest used value for the auto key + 1.",
+ (gptr*) &new_auto_increment,
+ (gptr*) &new_auto_increment,
0, GET_ULL, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's',
"Only print errors. One can use two -s to make archive_reader very silent.",
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index 41f3017fdc2..db90c0bfb8d 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -587,7 +587,7 @@ int ha_archive::create(const char *name, TABLE *table_arg,
azio_stream create_stream; /* Archive file we are working with */
File frm_file; /* File handler for readers */
MY_STAT file_stat; // Stat information for the data file
- char *frm_ptr;
+ byte *frm_ptr;
DBUG_ENTER("ha_archive::create");
@@ -659,7 +659,7 @@ int ha_archive::create(const char *name, TABLE *table_arg,
VOID(my_fstat(frm_file, &file_stat, MYF(MY_WME)));
frm_ptr= (char *)my_malloc(sizeof(char) * file_stat.st_size , MYF(0));
my_read(frm_file, frm_ptr, file_stat.st_size, MYF(0));
- azwrite_frm(&create_stream, frm_ptr, file_stat.st_size);
+ azwrite_frm(&create_stream, (char *)frm_ptr, file_stat.st_size);
my_close(frm_file, MYF(0));
my_free(frm_ptr, MYF(0));