summaryrefslogtreecommitdiff
path: root/src/utilities/util_dump.c
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@wiredtiger.com>2011-10-08 14:35:01 +0000
committerKeith Bostic <keith.bostic@wiredtiger.com>2011-10-08 14:35:01 +0000
commit94979c58bd71bff6512a82df92622a8a24c3ad33 (patch)
tree713c25ca11950317c571d6ea1fb39d8234abb7bb /src/utilities/util_dump.c
parent68e350ccfd91dd0e4bbc426bbc18028ae2ca3e1a (diff)
downloadmongo-94979c58bd71bff6512a82df92622a8a24c3ad33.tar.gz
Re-work "wt load", it now supports loading individual files.
Add support for column-store files to the "wt load" command. Change the "wt dump -k" option to be "-R", and give "wt load" a matching options. Add a "wt load -a" option to append/add/overwrite, that is, don't remove and re-create the file/table, update it instead. Change the utilities to only handle EXIT_FAILURE/EXIT_SUCCESS in the main() code, subsidiary commands just return 0/1. Add a "Format" line to the "wt dump" output headers, currently all it has is "hex" and "print", but that means we don't need the -p flag to "wt load", we can figure out if it's a printable format from the headers. --HG-- extra : rebase_source : 7978ab8ceb0b222d814a6add7d790d6cd3b8603f
Diffstat (limited to 'src/utilities/util_dump.c')
-rw-r--r--src/utilities/util_dump.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/utilities/util_dump.c b/src/utilities/util_dump.c
index 9d7aa12aff2..899f5a65ab4 100644
--- a/src/utilities/util_dump.c
+++ b/src/utilities/util_dump.c
@@ -173,31 +173,29 @@ int
util_dump(WT_SESSION *session, int argc, char *argv[])
{
WT_CURSOR *cursor;
- int ch, dump_key, ret, reverse;
- const char *fmt;
+ int ch, dump_recno, hex, ret, reverse;
char *name;
- dump_key = reverse = 0;
+ dump_recno = hex = reverse = 0;
name = NULL;
- fmt = "dump=print";
- while ((ch = util_getopt(argc, argv, "f:kxr")) != EOF)
+ while ((ch = util_getopt(argc, argv, "f:Rrx")) != EOF)
switch (ch) {
case 'f': /* output file */
if (freopen(util_optarg, "w", stdout) == NULL) {
fprintf(stderr, "%s: %s: reopen: %s\n",
progname, util_optarg, strerror(errno));
- return (EXIT_FAILURE);
+ return (1);
}
break;
- case 'k':
- dump_key = 1;
- break;
- case 'x':
- fmt = "dump=hex";
+ case 'R':
+ dump_recno = 1;
break;
case 'r':
reverse = 1;
break;
+ case 'x':
+ hex = 1;
+ break;
case '?':
default:
return (usage());
@@ -208,8 +206,8 @@ util_dump(WT_SESSION *session, int argc, char *argv[])
/* The remaining argument is the uri. */
if (argc != 1)
return (usage());
- if ((name = util_name(
- *argv, "table", UTIL_FILE_OK | UTIL_TABLE_OK)) == NULL)
+ if ((name =
+ util_name(*argv, "table", UTIL_FILE_OK | UTIL_TABLE_OK)) == NULL)
goto err;
if (strncmp(name, "table:", strlen("table:")) == 0) {
@@ -218,13 +216,14 @@ util_dump(WT_SESSION *session, int argc, char *argv[])
printf("WiredTiger Dump %s\n",
wiredtiger_version(NULL, NULL, NULL));
printf("Header\n");
+ printf("Format=%s\n", hex ? "hex" : "print");
if ((ret = schema(session, *argv)) != 0)
goto err;
printf("Data\n");
}
- if ((ret =
- session->open_cursor(session, name, NULL, fmt, &cursor)) != 0) {
+ if ((ret = session->open_cursor(session,
+ name, NULL, hex ? "dump=hex" : "dump=print", &cursor)) != 0) {
fprintf(stderr, "%s: cursor open(%s) failed: %s\n",
progname, name, wiredtiger_strerror(ret));
goto err;
@@ -261,7 +260,7 @@ usage(void)
{
(void)fprintf(stderr,
"usage: %s%s "
- "dump [-krx] [-f output-file] table\n",
+ "dump [-Rrx] [-f output-file] uri\n",
progname, usage_prefix);
- return (EXIT_FAILURE);
+ return (1);
}