Commit 83d94d27 authored by Yoni Fogel's avatar Yoni Fogel

Commented out some portions of db_load/dump

that are not yet compatible with tokudb.

Provided a fix for tokudb bug 43.

git-svn-id: file:///svn/tokudb@480 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2f28e2b7
......@@ -388,7 +388,13 @@ int __toku_db_open (DB *db, DB_TXN *txn, const char *fname, const char *dbname,
/* If the database exists at the file level, and we specified no db_name, then complain here. */
if (dbname==0 && (flags&DB_CREATE)) return EEXIST;
} else {
if (!(flags&DB_CREATE)) return ENOENT;
if (!(flags&DB_CREATE)) {
toku_free(db->i->database_name);
toku_free(db->i->full_fname);
db->i->database_name = NULL;
db->i->full_fname = NULL;
return ENOENT;
}
}
}
......
......@@ -9,6 +9,7 @@ if (0) g.dbenv->err(g.dbenv, retval, __VA_ARGS__); \
else { \
fprintf(stderr, "%s: %s:", g.progname, db_strerror(retval)); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
}
//DB_ENV->err disabled since it does not use db_strerror, errx does not exist.
......@@ -17,6 +18,7 @@ if (0) g.dbenv->err(g.dbenv, 0, __VA_ARGS__); \
else { \
fprintf(stderr, "%s: ", g.progname); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
}
int strtoint32 (char* str, int32_t* num, int32_t min, int32_t max, int base);
......
......@@ -46,7 +46,9 @@ int main(int argc, char *argv[]) {
/* Set up the globals. */
memset(&g, 0, sizeof(g));
g.leadingspace = true;
g.dbtype = DB_UNKNOWN;
//TODO: Uncomment when DB_UNKNOWN + db->get_type are implemented.
//g.dbtype = DB_UNKNOWN;
g.dbtype = DB_BTREE;
g.progname = argv[0];
g.header = true;
g.footer = true;
......@@ -80,14 +82,16 @@ int main(int argc, char *argv[]) {
break;
}
case ('R'): {
g.recover_flags |= DB_SALVAGE | DB_AGGRESSIVE;
//TODO: Uncomment when DB_SALVAGE,DB_AGGRESSIVE are implemented.
/*g.recover_flags |= DB_SALVAGE | DB_AGGRESSIVE;*/
//TODO: Implement aggressive recovery (requires db->verify())
ERRORX("-%c option not supported.\n", ch);
goto error;
}
case ('r'): {
g.recover_flags |= DB_SALVAGE;
//TODO: Uncomment when DB_SALVAGE,DB_AGGRESSIVE are implemented.
/*g.recover_flags |= DB_SALVAGE;*/
//TODO: Implement recovery (requires db->verify())
ERRORX("-%c option not supported.\n", ch);
......@@ -134,6 +138,8 @@ int main(int argc, char *argv[]) {
argc -= optind;
argv += optind;
//TODO: Uncomment when DB_SALVAGE,DB_AGGRESSIVE,DB_PRINTABLE,db->verify are implemented.
/*
if (g.plaintext) g.recover_flags |= DB_PRINTABLE;
if (g.subdatabase != NULL && IS_SET_ALL(g.recover_flags, DB_SALVAGE)) {
......@@ -145,6 +151,7 @@ int main(int argc, char *argv[]) {
goto error;
}
*/
if (argc != 1) {
g.exitcode = usage();
......@@ -286,7 +293,8 @@ int dump_header()
assert(g.header);
printf("VERSION=3\n");
printf("format=%s\n", g.plaintext ? "print" : "bytevalue");
assert(g.dbtype == DB_BTREE || (g.dbtype == DB_UNKNOWN && g.opened_dbtype == DB_BTREE));
//TODO: Uncomment when DB_UNKNOWN + db->get_type are implemented.
/*assert(g.dbtype == DB_BTREE || (g.dbtype == DB_UNKNOWN && g.opened_dbtype == DB_BTREE));*/
printf("type=btree\n");
//TODO: Get page size from db. Currently tokudb does not support db->get_pagesize.
printf("db_pagesize=4096\n");
......@@ -295,6 +303,8 @@ int dump_header()
outputplaintextstring(g.subdatabase);
printf("\n");
}
//TODO: Uncomment when db->get_flags is implemented
/*
if ((retval = db->get_flags(db, &flags)) != 0) {
ERROR(retval, "DB->get_flags");
goto error;
......@@ -302,7 +312,7 @@ int dump_header()
DUMP_IGNORED_FLAG(DB_CHKSUM, "chksum=1");
DUMP_FLAG( DB_DUP, "duplicates=1");
DUMP_IGNORED_FLAG(DB_DUPSORT, "dupsort=1");
DUMP_IGNORED_FLAG(DB_RECNUM, "recnum=1");
DUMP_IGNORED_FLAG(DB_RECNUM, "recnum=1");*/
printf("HEADER=END\n");
if (ferror(stdout)) goto error;
......@@ -336,6 +346,8 @@ int open_database()
ERROR(retval, "DB->open: %s", g.database);
goto error;
}
//TODO: Uncomment when DB_UNKNOWN + db->get_type are implemented.
/*
retval = db->get_type(db, &g.opened_dbtype);
if (retval != 0) {
ERROR(retval, "DB->get_type");
......@@ -348,7 +360,7 @@ int open_database()
if (g.dbtype != DB_UNKNOWN && g.opened_dbtype != g.dbtype) {
ERRORX("DBTYPE %d does not match opened DBTYPE %d.\n", g.dbtype, g.opened_dbtype);
goto error;
}
}*/
return EXIT_SUCCESS;
error:
fprintf(stderr, "Quitting out due to errors.\n");
......
......@@ -59,7 +59,8 @@ int main(int argc, char *argv[]) {
memset(&g, 0, sizeof(g));
g.leadingspace = true;
g.overwritekeys = true;
g.dbtype = DB_UNKNOWN;
//TODO: g.dbtype = DB_UNKNOWN; when defined.
g.dbtype = DB_BTREE;
g.progname = argv[0];
g.header = true;
......@@ -591,20 +592,24 @@ int open_database()
//Try to see if it exists first.
retval = db->open(db, NULL, g.database, g.subdatabase, g.dbtype, open_flags, 0666);
if (retval != 0) {
if (retval == ENOENT) {
//Does not exist and we did not specify a type.
//TODO: Uncomment when DB_UNKNOWN + db->get_type are implemented.
/*
if (g.dbtype == DB_UNKNOWN) {
ERRORX("no database type specified");
goto error;
}
}*/
SET_BITS(open_flags, DB_CREATE);
//Try creating it.
retval = db->open(db, NULL, g.database, g.subdatabase, g.dbtype, open_flags, 0666);
}
if (retval != 0) {
ERROR(retval, "DB->open: %s", g.database);
goto error;
}
}
//TODO: Uncomment when DB_UNKNOWN + db->get_type are implemented.
/*
if ((retval = db->get_type(db, &opened_type)) != 0) {
ERROR(retval, "DB->get_type");
goto error;
......@@ -616,7 +621,7 @@ int open_database()
if (g.dbtype != DB_UNKNOWN && opened_type != g.dbtype) {
ERRORX("DBTYPE %d does not match opened DBTYPE %d.\n", g.dbtype, opened_type);
goto error;
}
}*/
return EXIT_SUCCESS;
error:
fprintf(stderr, "Quitting out due to errors.\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment