u_int32_t flags = 0;
int dbversion_major, dbversion_minor, dbversion_patch;
- fprintf(stderr, "db: open_dbenv() starting\n"
- "db: Linked zlib: %s\n"
- "db: Compiled libdb: %s\n"
- "db: Linked libdb: %s\n",
- zlibVersion(),
- DB_VERSION_STRING,
- db_version(&dbversion_major, &dbversion_minor, &dbversion_patch)
- );
-
// Create synthetic integer version numbers and compare them.
// Never run with a libdb older than the one with which it was compiled.
int compiled_db_version = ( (DB_VERSION_MAJOR * 1000000) + (DB_VERSION_MINOR * 1000) + (DB_VERSION_PATCH) );
exit(CTDLEXIT_DB);
}
- fprintf(stderr,"db: Setting up DB environment\n");
ret = db_env_create(&dbenv, 0);
if (ret) {
fprintf(stderr,"db: db_env_create: %s\n", db_strerror(ret));
}
flags = DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_INIT_LOG;
- fprintf(stderr,"db: dbenv open(dir=%s, flags=%d)\n", dirname, flags);
ret = dbenv->open(dbenv, dirname, flags, 0);
if (ret) {
fprintf(stderr,"db: dbenv->open: %s\n", db_strerror(ret));
void close_dbenv(DB_ENV *dbenv) {
- fprintf(stderr,"db: closing dbenv\n");
int ret = dbenv->close(dbenv, 0);
if (ret) {
fprintf(stderr,"db: dbenv->close: %s\n", db_strerror(ret));
// Ingest one line of dump data. NOT REENTRANT
void ingest_one(char *line, DB_ENV *dst_dbenv) {
+ static int good_rows = 0;
+ static int bad_rows = 0;
static int previous_cdb = -1 ;
static int current_cdb = -1 ;
static DB *dst_dbp;
fprintf(stderr, "db: db_close: %s\n", db_strerror(ret));
}
}
+ if (previous_cdb > 0) {
+ fprintf(stderr, "\n");
+ }
if (current_cdb >= 0) {
+ good_rows = 0;
+ bad_rows = 0;
snprintf(dbfilename, sizeof dbfilename, "cdb.%02x", current_cdb);
// create a database handle for the destination table
else row_was_good = 0;
if (row_was_good) {
+ ++good_rows;
ret = dst_dbp->put(dst_dbp, NULL, &out_key, &out_data, 0);
if (ret) {
- fprintf(stderr, "db: cdb_put(%d): %s", current_cdb, db_strerror(ret));
+ fprintf(stderr, "db: cdb_put(%x): %s", current_cdb, db_strerror(ret));
exit(CTDLEXIT_DB);
}
}
+ else {
+ ++bad_rows;
+ }
free(out_key.data);
free(out_data.data);
+
+ if (current_cdb > 0) {
+ fprintf(stderr, " %02x %9d %8d\r", current_cdb, good_rows, bad_rows);
+ fflush(stderr);
+ }
}
static size_t line_len = 0;
char ch;
+ fprintf(stderr, "table good_rows bad_rows\n");
+ fprintf(stderr, "----- --------- --------\n");
line = reallok(NULL, line_alloc);
do {