INN commit: trunk (5 files)
INN Commit
Russ_Allbery at isc.org
Mon May 5 21:28:43 UTC 2008
Date: Monday, May 5, 2008 @ 14:28:43
Author: iulius
Revision: 7820
Remove support for Berkeley DB < 4.4.
The code will now we cleaner!
Modified:
trunk/frontends/ovdb_init.c
trunk/frontends/ovdb_monitor.c
trunk/frontends/ovdb_stat.c
trunk/storage/ovdb/ovdb-private.h
trunk/storage/ovdb/ovdb.c
-----------------------------+
frontends/ovdb_init.c | 46 +------------
frontends/ovdb_monitor.c | 52 --------------
frontends/ovdb_stat.c | 138 ---------------------------------------
storage/ovdb/ovdb-private.h | 65 ------------------
storage/ovdb/ovdb.c | 148 ++----------------------------------------
5 files changed, 18 insertions(+), 431 deletions(-)
Modified: frontends/ovdb_init.c
===================================================================
--- frontends/ovdb_init.c 2008-05-05 21:27:28 UTC (rev 7819)
+++ frontends/ovdb_init.c 2008-05-05 21:28:43 UTC (rev 7820)
@@ -21,7 +21,7 @@
int main(int argc UNUSED, char **argv UNUSED)
{
- die("BerkeleyDB support not compiled");
+ die("Berkeley DB support not compiled");
}
#else /* USE_BERKELEY_DB */
@@ -29,41 +29,23 @@
static int open_db(DB **db, const char *name, int type)
{
int ret;
-#if DB_VERSION_MAJOR == 2
- DB_INFO dbinfo;
- memset(&dbinfo, 0, sizeof dbinfo);
-
- ret = db_open(name, type, DB_CREATE, 0666, OVDBenv, &dbinfo, db);
- if (ret != 0) {
- warn("db_open failed: %s", db_strerror(ret));
- return ret;
- }
-#else
ret = db_create(db, OVDBenv, 0);
if (ret != 0) {
warn("db_create failed: %s\n", db_strerror(ret));
return ret;
}
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
ret = (*db)->open(*db, NULL, name, NULL, type, DB_CREATE, 0666);
-#else
- ret = (*db)->open(*db, name, NULL, type, DB_CREATE, 0666);
-#endif
if (ret != 0) {
(*db)->close(*db, 0);
warn("%s->open failed: %s", name, db_strerror(ret));
return ret;
}
-#endif
return 0;
}
-/* Upgrade BerkeleyDB version */
+/* Upgrade Berkeley DB version */
static int upgrade_database(const char *name UNUSED)
{
-#if DB_VERSION_MAJOR == 2
- return 0;
-#else
int ret;
DB *db;
@@ -78,7 +60,6 @@
db->close(db, 0);
return ret;
-#endif
}
@@ -113,9 +94,6 @@
char group[MAXHEADERSIZE];
u_int32_t v2 = 2;
int ret;
-#if DB_VERSION_MAJOR < 3
- char *p;
-#endif
notice("upgrading data to version 2");
ret = open_db(&groupstats, "groupstats", DB_BTREE);
@@ -222,7 +200,6 @@
groupinfo->close(groupinfo, 0);
vdb->close(vdb, 0);
-#if DB_VERSION_MAJOR >= 3
ret = db_create(&groupstats, OVDBenv, 0);
if (ret != 0)
return ret;
@@ -231,15 +208,6 @@
if (ret != 0)
return ret;
groupsbyname->remove(groupsbyname, "groupsbyname", NULL, 0);
-#else
- /* This won't work if someone changed DB_DATA_DIR in DB_CONFIG */
- p = concatpath(ovdb_conf.home, "groupstats");
- unlink(p);
- free(p);
- p = concatpath(ovdb_conf.home, "groupsbyname");
- unlink(p);
- free(p);
-#endif
return 0;
}
@@ -339,17 +307,11 @@
ret = ovdb_open_berkeleydb(OV_WRITE, OVDB_UPGRADE);
if (ret != 0)
return ret;
-#if DB_VERSION_MAJOR >= 3
-#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 0
- ret = OVDBenv->remove(OVDBenv, ovdb_conf.home, NULL, 0);
-#else
ret = OVDBenv->remove(OVDBenv, ovdb_conf.home, 0);
-#endif
if (ret != 0)
return ret;
OVDBenv = NULL;
ret = ovdb_open_berkeleydb(OV_WRITE, 0);
-#endif
return ret;
}
@@ -429,7 +391,7 @@
}
}
if(ret != 0)
- die("cannot open BerkeleyDB: %s", db_strerror(ret));
+ die("cannot open Berkeley DB: %s", db_strerror(ret));
if(recover_only)
exit(0);
@@ -437,7 +399,7 @@
if(do_upgrade) {
ret = upgrade_environment();
if(ret != 0)
- die("cannot upgrade BerkeleyDB environment: %s", db_strerror(ret));
+ die("cannot upgrade Berkeley DB environment: %s", db_strerror(ret));
}
if(check_upgrade(do_upgrade)) {
Modified: frontends/ovdb_monitor.c
===================================================================
--- frontends/ovdb_monitor.c 2008-05-05 21:27:28 UTC (rev 7819)
+++ frontends/ovdb_monitor.c 2008-05-05 21:28:43 UTC (rev 7820)
@@ -71,13 +71,7 @@
setproctitle("deadlock");
while(!signalled) {
-#if DB_VERSION_MAJOR == 2
- ret = lock_detect(OVDBenv->lk_info, 0, atype);
-#elif DB_VERSION_MAJOR == 3
- ret = lock_detect(OVDBenv, 0, atype, NULL);
-#else
ret = OVDBenv->lock_detect(OVDBenv, 0, atype, NULL);
-#endif
if(ret != 0) {
warn("OVDB: lock_detect: %s", db_strerror(ret));
status = 1;
@@ -94,9 +88,6 @@
{
int ret, status = 0;
DB *db;
-#if DB_VERSION_MAJOR == 2
- DB_INFO dbinfo;
-#endif
if(ovdb_open_berkeleydb(OV_WRITE, 0))
_exit(1);
@@ -106,58 +97,23 @@
/* Open a database and close it. This is so a necessary initialization
gets performed (by the db->open function). */
-#if DB_VERSION_MAJOR == 2
- memset(&dbinfo, 0, sizeof dbinfo);
- ret = db_open("version", DB_BTREE, DB_CREATE, 0666, OVDBenv, &dbinfo, &db);
- if (ret != 0) {
- warn("OVDB: checkpoint: db_open failed: %s", db_strerror(ret));
- _exit(1);
- }
-#else
ret = db_create(&db, OVDBenv, 0);
if (ret != 0) {
warn("OVDB: checkpoint: db_create: %s", db_strerror(ret));
_exit(1);
}
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
ret = db->open(db, NULL, "version", NULL, DB_BTREE, DB_CREATE, 0666);
-#else
- ret = db->open(db, "version", NULL, DB_BTREE, DB_CREATE, 0666);
-#endif
if (ret != 0) {
db->close(db, 0);
warn("OVDB: checkpoint: version open: %s", db_strerror(ret));
_exit(1);
}
-#endif
db->close(db, 0);
while(!signalled) {
-#if DB_VERSION_MAJOR == 2
- ret = txn_checkpoint(OVDBenv->tx_info, 2048, 1);
-#elif DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 0
- ret = txn_checkpoint(OVDBenv, 2048, 1);
-#elif DB_VERSION_MAJOR == 3
- ret = txn_checkpoint(OVDBenv, 2048, 1, 0);
-#elif DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 1
- ret = OVDBenv->txn_checkpoint(OVDBenv, 2048, 1, 0);
-#else
OVDBenv->txn_checkpoint(OVDBenv, 2048, 1, 0);
-#endif
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
sleep(30);
-#else
- if(ret != 0 && ret != DB_INCOMPLETE) {
- warn("OVDB: txn_checkpoint: %s", db_strerror(ret));
- status = 1;
- break;
- }
- if(ret == DB_INCOMPLETE)
- sleep(2);
- else
- sleep(30);
-#endif
}
ovdb_close_berkeleydb();
@@ -175,15 +131,7 @@
setproctitle("logremover");
while(!signalled) {
-#if DB_VERSION_MAJOR == 2
- ret = log_archive(OVDBenv->lg_info, &listp, DB_ARCH_ABS, malloc);
-#elif DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR <= 2
- ret = log_archive(OVDBenv, &listp, DB_ARCH_ABS, malloc);
-#elif DB_VERSION_MAJOR == 3
- ret = log_archive(OVDBenv, &listp, DB_ARCH_ABS);
-#else
ret = OVDBenv->log_archive(OVDBenv, &listp, DB_ARCH_ABS);
-#endif
if(ret != 0) {
warn("OVDB: log_archive: %s", db_strerror(ret));
status = 1;
Modified: frontends/ovdb_stat.c
===================================================================
--- frontends/ovdb_stat.c 2008-05-05 21:27:28 UTC (rev 7819)
+++ frontends/ovdb_stat.c 2008-05-05 21:28:43 UTC (rev 7820)
@@ -25,7 +25,7 @@
int main(int argc UNUSED, char **argv UNUSED)
{
- die("BerkeleyDB support not compiled");
+ die("Berkeley DB support not compiled");
}
#else /* USE_BERKELEY_DB */
@@ -241,53 +241,27 @@
#define F(f) OFFSETOF(DB_LOCK_STAT, f)
static struct datatab LOCK_tab[] = {
-#if DB_VERSION_MAJOR >= 3
{ INT32,
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
F(st_id),
-#else
- F(st_lastid),
-#endif
-1, -1, "Last allocated locker ID" },
-#endif
{ INT32, F(st_maxlocks), -1, -1, "Maximum number of locks possible" },
-#if DB_VERSION_MAJOR >= 4 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR >= 2)
{ INT32, F(st_maxlockers), -1, -1, "Maximum number of lockers possible" },
{ INT32, F(st_maxobjects), -1, -1, "Maximum number of objects possible" },
-#endif
{ INT32, F(st_nmodes), -1, -1, "Lock modes" },
-#if DB_VERSION_MAJOR >= 4 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR >= 2)
{ INT32, F(st_nlocks), -1, -1, "Current locks" },
{ INT32, F(st_maxnlocks), -1, -1, "Maximum locks" },
-#endif
{ INT32, F(st_nlockers), -1, -1, "Current lockers" },
-#if DB_VERSION_MAJOR >= 3
{ INT32, F(st_maxnlockers), -1, -1, "Maximum lockers" },
-#else
- { INT32, F(st_numobjs), -1, -1, "Lock objects" },
-#endif
-#if DB_VERSION_MAJOR >= 4 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR >= 2)
{ INT32, F(st_nobjects), -1, -1, "Current objects" },
{ INT32, F(st_maxnobjects), -1, -1, "Maximum objects" },
-#endif
-#if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 4
{ INT32, F(st_lock_wait), -1, -1, "Lock conflicts" },
-#else
- { INT32, F(st_nconflicts), -1, -1, "Lock conflicts" },
-#endif
{ INT32, F(st_nrequests), -1, -1, "Lock requests" },
{ INT32, F(st_nreleases), -1, -1, "Lock releases" },
{ DIFF32, F(st_nrequests), F(st_nreleases), F(st_ndeadlocks), "Outstanding locks" },
-#if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 4
{ INT32, F(st_lock_nowait), -1, -1, "Lock conflicts w/o subsequent wait" },
-#elif DB_VERSION_MAJOR >= 4 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR > 0)
- { INT32, F(st_nnowaits), -1, -1, "Lock conflicts w/o subsequent wait" },
-#endif
{ INT32, F(st_ndeadlocks), -1, -1, "Deadlocks" },
-#if DB_VERSION_MAJOR >= 4
{ INT32, F(st_nlocktimeouts), -1, -1, "Lock timeouts" },
{ INT32, F(st_ntxntimeouts), -1, -1, "Transaction timeouts" },
-#endif
{ INT32, F(st_region_nowait), -1, -1, "Region locks granted without waiting" },
{ INT32, F(st_region_wait), -1, -1, "Region locks granted after waiting" },
{ BYTES, F(st_regsize), -1, -1, "Lock region size" },
@@ -298,15 +272,7 @@
{
DB_LOCK_STAT *sp;
-#if DB_VERSION_MAJOR == 2
- if(lock_stat(OVDBenv->lk_info, &sp, NULL) != 0)
-#elif DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR <= 2
- if(lock_stat(OVDBenv, &sp, NULL) != 0)
-#elif DB_VERSION_MAJOR == 3
- if(lock_stat(OVDBenv, &sp) != 0)
-#else
if(OVDBenv->lock_stat(OVDBenv, &sp, 0) != 0)
-#endif
return 1;
display_heading("Lock Region Statistics");
@@ -324,37 +290,22 @@
{ HEX32, F(st_magic), -1, -1, "Log magic number" },
{ INT32, F(st_version), -1, -1, "Log version number" },
{ MODE, F(st_mode), -1, -1, "Log file mode" },
-#if DB_VERSION_MAJOR >= 3
{ BYTES, F(st_lg_bsize), -1, -1, "Log record cache size" },
-#endif
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
{ BYTES, F(st_lg_size), -1, -1, "The current log file size" },
-#else
- { BYTES, F(st_lg_max), -1, -1, "Max log file size" },
-#endif
{ BYTES, F(st_w_bytes), F(st_w_mbytes), -1, "Log bytes written" },
{ BYTES, F(st_wc_bytes), F(st_wc_mbytes), -1, "Log bytes written since last checkpoint" },
{ INT32, F(st_wcount), -1, -1, "Total log writes" },
-#if DB_VERSION_MAJOR >= 3
{ INT32, F(st_wcount_fill), -1, -1, "Total log writes due to overflow" },
-#endif
{ INT32, F(st_scount), -1, -1, "Total log flushes" },
{ INT32, F(st_region_nowait), -1, -1, "Region locks granted without waiting" },
{ INT32, F(st_region_wait), -1, -1, "Region locks granted after waiting" },
{ INT32, F(st_cur_file), -1, -1, "Current log file number" },
{ INT32, F(st_cur_offset), -1, -1, "Current log file offset" },
-#if DB_VERSION_MAJOR >= 4 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR >= 3)
{ INT32, F(st_disk_file), -1, -1, "Known on disk log file number" },
{ INT32, F(st_disk_offset), -1, -1, "Known on disk log file offset" },
-#endif
{ BYTES, F(st_regsize), -1, -1, "Log region size" },
-#if DB_VERSION_MAJOR >= 4
-#if DB_VERSION_MINOR < 1
- { INT32, F(st_flushcommit), -1, -1, "Flushes containing a commit"},
-#endif
{ INT32, F(st_maxcommitperflush), -1, -1, "Max number of commits in a flush"},
{ INT32, F(st_mincommitperflush), -1, -1, "Min number of commits in a flush"},
-#endif
{ END, -1, -1, -1, NULL }
};
@@ -362,15 +313,7 @@
{
DB_LOG_STAT *sp;
-#if DB_VERSION_MAJOR == 2
- if(log_stat(OVDBenv->lg_info, &sp, NULL) != 0)
-#elif DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR <= 2
- if(log_stat(OVDBenv, &sp, NULL) != 0)
-#elif DB_VERSION_MAJOR == 3
- if(log_stat(OVDBenv, &sp) != 0)
-#else
if(OVDBenv->log_stat(OVDBenv, &sp, 0) != 0)
-#endif
return 1;
display_heading("Log Region Statistics");
@@ -388,18 +331,9 @@
{ INT32, F(st_cache_hit), -1, -1, "Cache hits"},
{ INT32, F(st_cache_miss), -1, -1, "Cache misses"},
{ PCT32, F(st_cache_hit), F(st_cache_miss), -1, "Cache hit percentage"},
-#if DB_VERSION_MAJOR == 2
- { INT32, F(st_cachesize), -1, -1, "Total cache size"},
- { INT32, F(st_regsize), -1, -1, "Pool region size"},
-#else
{ BYTES, F(st_bytes), -1, F(st_gbytes), "Total cache size"},
-#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 0
- { INT32, F(st_regsize), -1, -1, "Pool region size"},
-#else
{ INT32, F(st_ncache), -1, -1, "Number of caches"},
{ INT32, F(st_regsize), -1, -1, "Pool individual cache size"},
-#endif
-#endif
{ INT32, F(st_map), -1, -1, "Memory mapped pages"},
{ INT32, F(st_page_create), -1, -1, "Pages created in the cache"},
{ INT32, F(st_page_in), -1, -1, "Pages read into the cache"},
@@ -439,15 +373,7 @@
DB_MPOOL_FSTAT **fsp;
DB_MPOOL_STAT *gsp;
-#if DB_VERSION_MAJOR == 2
- if(memp_stat(OVDBenv->mp_info, &gsp, &fsp, NULL) != 0)
-#elif DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR <= 2
- if(memp_stat(OVDBenv, &gsp, &fsp, NULL) != 0)
-#elif DB_VERSION_MAJOR == 3
- if(memp_stat(OVDBenv, &gsp, &fsp) != 0)
-#else
if(OVDBenv->memp_stat(OVDBenv, &gsp, &fsp, 0) != 0)
-#endif
return 1;
display_heading("Memory Pool Statistics");
@@ -482,19 +408,12 @@
static struct datatab TXN_tab[] = {
{ LSN, F(st_last_ckp), -1, -1, "File/offset for last checkpoint LSN" },
-#if DB_VERSION_MAJOR < 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 1)
- { LSN, F(st_pending_ckp), -1, -1, "File/offset for last pending checkpoint LSN" },
-#endif
{ TIME, F(st_time_ckp), -1, -1, "Checkpoint timestamp" },
{ HEX32, F(st_last_txnid), -1, -1, "Last transaction ID allocated" },
{ INT32, F(st_maxtxns), -1, -1, "Maximum active transactions possible" },
{ INT32, F(st_nactive), -1, -1, "Active transactions" },
-#if DB_VERSION_MAJOR >= 4 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR >= 3)
{ INT32, F(st_nrestores), -1, -1, "Restored transactions after recovery" },
-#endif
-#if DB_VERSION_MAJOR >= 3
{ INT32, F(st_maxnactive), -1, -1, "Maximum active transactions" },
-#endif
{ INT32, F(st_nbegins), -1, -1, "Transactions started" },
{ INT32, F(st_ncommits), -1, -1, "Transactions committed" },
{ INT32, F(st_naborts), -1, -1, "Transactions aborted" },
@@ -509,9 +428,7 @@
static struct datatab TXNA_tab[] = {
{ INT32, F(txnid), -1, -1, "Transaction ID" },
-#if DB_VERSION_MAJOR >= 3
{ INT32, F(parentid), -1, -1, "Parent Transaction ID" },
-#endif
{ LSN, F(lsn), -1, -1, "Initial LSN file/offset" },
{ END, -1, -1, -1, NULL }
};
@@ -521,15 +438,7 @@
DB_TXN_STAT *sp;
u_int32_t i;
-#if DB_VERSION_MAJOR == 2
- if(txn_stat(OVDBenv->tx_info, &sp, NULL) != 0)
-#elif DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR <= 2
- if(txn_stat(OVDBenv, &sp, NULL) != 0)
-#elif DB_VERSION_MAJOR == 3
- if(txn_stat(OVDBenv, &sp) != 0)
-#else
if(OVDBenv->txn_stat(OVDBenv, &sp, 0) != 0)
-#endif
return 1;
display_heading("Transaction Region Statistics");
@@ -551,7 +460,7 @@
if(html) puts("<p>");
printf("ovdb data version: %d\n", ovdb_data_ver);
if(html) puts("<br>");
- printf("BerkeleyDB version: %s\n", db_version(NULL,NULL,NULL));
+ printf("Berkeley DB version: %s\n", db_version(NULL,NULL,NULL));
if(html) puts("<p>");
return 0;
}
@@ -565,12 +474,8 @@
{ INT32, F(bt_minkey), -1, -1, "Minimum keys per page (minkey)" },
{ INT32, F(bt_pagesize), -1, -1, "Database page size" },
{ INT32, F(bt_levels), -1, -1, "Levels in the tree" },
-#if DB_VERSION_MAJOR == 2 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 0)
- { INT32, F(bt_nrecs), -1, -1, "Keys in the tree" },
-#else
{ INT32, F(bt_nkeys), -1, -1, "Unique keys in the tree" },
{ INT32, F(bt_ndata), -1, -1, "Data items in the tree" },
-#endif
{ INT32, F(bt_int_pg), -1, -1, "Tree internal pages" },
{ BYTES, F(bt_int_pgfree), -1, -1, "Bytes free in internal pages" },
{ FF, F(bt_int_pgfree), F(bt_int_pg), F(bt_pagesize), "Internal page fill factor" },
@@ -587,9 +492,7 @@
{ BYTES, F(bt_over_pgfree), -1, -1, "Bytes free overflow pages" },
{ FF, F(bt_over_pgfree), F(bt_over_pg), F(bt_pagesize), "Overflow page fill factor" },
-#if DB_VERSION_MAJOR >= 3
{ INT32, F(bt_free), -1, -1, "Pages on the free list" },
-#endif
{ END, -1, -1, -1, NULL }
};
@@ -597,15 +500,7 @@
{
DB_BTREE_STAT *sp;
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
if(db->stat(db, NULL, &sp, 0))
-#else
-#if DB_VERSION_MAJOR == 4 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR >= 3)
- if(db->stat(db, &sp, 0))
-#else
- if(db->stat(db, &sp, NULL, 0))
-#endif
-#endif
return 1;
display_heading("Btree Statistics");
@@ -616,8 +511,6 @@
}
-#if DB_VERSION_MAJOR >= 3
-
#undef F
#define F(f) OFFSETOF(DB_HASH_STAT, f)
@@ -625,12 +518,8 @@
{ HEX32, F(hash_magic), -1, -1, "Hash magic number" },
{ INT32, F(hash_version), -1, -1, "Hash version number" },
{ INT32, F(hash_pagesize), -1, -1, "Database page size" },
-#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 0
- { INT32, F(hash_nrecs), -1, -1, "Keys in the database" },
-#else
{ INT32, F(hash_nkeys), -1, -1, "Keys in the database" },
{ INT32, F(hash_ndata), -1, -1, "Data items in the database" },
-#endif
{ INT32, F(hash_buckets), -1, -1, "Hash buckets" },
{ BYTES, F(hash_bfree), -1, -1, "Bytes free on bucket pages" },
{ FF, F(hash_buckets), F(hash_bfree), F(hash_pagesize), "Bucket page fill factor" },
@@ -650,32 +539,18 @@
{ INT32, F(hash_free), -1, -1, "Pages on the free list"},
{ END, -1, -1, -1, NULL }
};
-#endif
static int display_hash(DB *db UNUSED)
{
-#if DB_VERSION_MAJOR == 2
- printf("Hash statistics not available.\n");
- return 0;
-#else
DB_HASH_STAT *sp;
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
if(db->stat(db, NULL, &sp, 0))
-#else
-#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR <= 2
- if(db->stat(db, &sp, NULL, 0))
-#else
- if(db->stat(db, &sp, 0))
-#endif
-#endif
return 1;
display_heading("Hash Information");
display_data(sp, HASH_tab);
return 0;
-#endif
}
static int display_db(char *dbfile)
@@ -683,19 +558,10 @@
int ret;
DB *db;
-#if DB_VERSION_MAJOR == 2
- if(db_open(dbfile, DB_UNKNOWN, DB_RDONLY, 0, OVDBenv, NULL, &db))
- return 1;
-#else
if(db_create(&db, OVDBenv, 0))
return 1;
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
if(db->open(db, NULL, dbfile, NULL, DB_UNKNOWN, DB_RDONLY, 0))
-#else
- if(db->open(db, dbfile, NULL, DB_UNKNOWN, DB_RDONLY, 0))
-#endif
return 1;
-#endif
switch(db->type) {
case DB_BTREE:
Modified: storage/ovdb/ovdb-private.h
===================================================================
--- storage/ovdb/ovdb-private.h 2008-05-05 21:27:28 UTC (rev 7819)
+++ storage/ovdb/ovdb-private.h 2008-05-05 21:28:43 UTC (rev 7820)
@@ -2,15 +2,9 @@
#include <db.h>
-#if DB_VERSION_MAJOR == 2
-#if DB_VERSION_MINOR < 6
-#error "Need BerkeleyDB 2.6.x, 2.7.x, 3.x or 4.x"
+#if DB_VERSION_MAJOR < 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 3)
+#error "Need Berkeley DB 4.4 or higher"
#endif
-#else
-#if DB_VERSION_MAJOR < 3 || DB_VERSION_MAJOR > 4
-#error "Need BerkeleyDB 2.6.x, 2.7.x, 3.x or 4.x"
-#endif
-#endif
/*
* How data is stored:
@@ -27,7 +21,7 @@
* 'struct datakey' as their keys, which consists of the group ID (in
* native byteorder) followed by the article number in network byteorder.
* The reason for storing the article number in net byte order (big-endian)
- * is that the keys will sort correctly using BerkeleyDB's default sort
+ * is that the keys will sort correctly using Berkeley DB's default sort
* function (basically, a memcmp).
*
* The overview records consist of a 'struct ovdata' followed by the actual
@@ -174,62 +168,11 @@
};
-#if DB_VERSION_MAJOR == 2
-char *db_strerror(int err);
-
/* Used when TXN_RETRY will never be called, to avoid a warning about an
unused label. */
#define TXN_START_NORETRY(label, tid) \
{ \
int txn_ret; \
- txn_ret = txn_begin(OVDBenv->tx_info, NULL, &tid); \
- if (txn_ret != 0) { \
- warn("OVDB: " #label " txn_begin: %s", db_strerror(ret)); \
- tid = NULL; \
- } \
-}
-
-#define TXN_START(label, tid) label: TXN_START_NORETRY(label, tid)
-
-#define TXN_RETRY(label, tid) \
-{ txn_abort(tid); goto label; }
-
-#define TXN_ABORT(label, tid) txn_abort(tid)
-#define TXN_COMMIT(label, tid) txn_commit(tid)
-
-#define TRYAGAIN EAGAIN
-
-#elif DB_VERSION_MAJOR == 3
-
-/* Used when TXN_RETRY will never be called, to avoid a warning about an
- unused label. */
-#define TXN_START_NORETRY(label, tid) \
-{ \
- int txn_ret; \
- txn_ret = txn_begin(OVDBenv, NULL, &tid, 0); \
- if (txn_ret != 0) { \
- warn("OVDB: " #label " txn_begin: %s", db_strerror(ret)); \
- tid = NULL; \
- } \
-}
-
-#define TXN_START(label, tid) label: TXN_START_NORETRY(label, tid)
-
-#define TXN_RETRY(label, tid) \
-{ txn_abort(tid); goto label; }
-
-#define TXN_ABORT(label, tid) txn_abort(tid)
-#define TXN_COMMIT(label, tid) txn_commit(tid, 0)
-
-#define TRYAGAIN DB_LOCK_DEADLOCK
-
-#else /* DB_VERSION_MAJOR == 4 */
-
-/* Used when TXN_RETRY will never be called, to avoid a warning about an
- unused label. */
-#define TXN_START_NORETRY(label, tid) \
-{ \
- int txn_ret; \
txn_ret = OVDBenv->txn_begin(OVDBenv, NULL, &tid, 0); \
if (txn_ret != 0) { \
warn("OVDB: " #label " txn_begin: %s", db_strerror(ret)); \
@@ -247,6 +190,4 @@
#define TRYAGAIN DB_LOCK_DEADLOCK
-#endif /* DB_VERSION_MAJOR == 2 */
-
#endif /* USE_BERKELEY_DB */
Modified: storage/ovdb/ovdb.c
===================================================================
--- storage/ovdb/ovdb.c 2008-05-05 21:27:28 UTC (rev 7819)
+++ storage/ovdb/ovdb.c 2008-05-05 21:28:43 UTC (rev 7820)
@@ -1,7 +1,7 @@
/*
* ovdb.c
* ovdb 2.00
- * Overview storage using BerkeleyDB 2.x/3.x/4.x
+ * Overview storage using Berkeley DB 4.4 or higher
*
* 2004-02-17 : Need to track search cursors, since it's possible that
* ovdb_closesearch does not get called. We now close
@@ -11,7 +11,7 @@
* 2002-08-11 : Cleaned up use of sprintf and fixed a bunch of warnings.
* 2002-02-28 : Update getartinfo for the overview API change in 2.4. This
* breaks compatibility with INN 2.3.x....
- * 2000-12-12 : Add support for BerkeleyDB DB_SYSTEM_MEM option, controlled
+ * 2000-12-12 : Add support for Berkeley DB DB_SYSTEM_MEM option, controlled
* : by ovdb.conf 'useshm' and 'shmkey'
* 2000-11-27 : Update for DB 3.2.x compatibility
* 2000-11-13 : New 'readserver' feature
@@ -32,7 +32,7 @@
* 2000-09-19 : *lo wasn't being set in ovdb_expiregroup
* 2000-09-15 : added ovdb_check_user(); tweaked some error msgs; fixed an
* improper use of RENEW
- * 2000-08-28: New major release: version 2.00 (beta)
+ * 2000-08-28 : New major release: version 2.00 (beta)
* + "groupsbyname" and "groupstats" databases replaced with "groupinfo".
* + ovdb_recover, ovdb_upgrade, and dbprocs are now deprecated; their
* functionality is now in ovdb_init and ovdb_monitor.
@@ -43,7 +43,7 @@
* in inefficient disk-space use).
* + Add "nocompact" to ovdb.conf, which controls whether ovdb_expiregroup()
* rewrites OV data.
- * + No longer needs the BerkeleyDB tools db_archive, db_checkpoint, and
+ * + No longer needs the Berkeley DB tools db_archive, db_checkpoint, and
* db_deadlock. That functionality is now in ovdb_monitor.
* + ovdb_open() won't succeed if ovdb_monitor is not running. This will
* prevent the problems that happen if the database is not regularly
@@ -51,7 +51,7 @@
* + Internal group IDs (32-bit ints) are now reused.
* + Add "maxlocks" to ovdb.conf, which will set the DB lk_max parameter.
* + Pull "test" code out into ovdb_stat. ovdb_stat will also provide
- * functionality similar to the BerkeleyDB "db_stat" command.
+ * functionality similar to the Berkeley DB "db_stat" command.
* + Update docs: write man pages for the new ovdb_* commands; update
* ovdb.pod
*
@@ -59,14 +59,14 @@
* 2000-07-07 : bugfix: timestamp handling
* 2000-06-10 : Modified groupnum() interface; fix ovdb_add() to return false
* for certain groupnum() errors
- * 2000-06-08 : Added BerkeleyDB 3.1.x compatibility
+ * 2000-06-08 : Added Berkeley DB 3.1.x compatibility
* 2000-04-09 : Tweak some default parameters; store aliased group info
* 2000-03-29 : Add DB_RMW flag to the 'get' of get-modify-put sequences
* 2000-02-17 : Update expire behavior to be consistent with current
* ov3 and buffindexed
* 2000-01-13 : Fix to make compatible with unmodified nnrpd/article.c
* 2000-01-04 : Added data versioning
- * 1999-12-20 : Added BerkeleyDB 3.x compatibility
+ * 1999-12-20 : Added Berkeley DB 3.x compatibility
* 1999-12-06 : First Release -- H. Kehoe <hakehoe at avalon.net>
*/
@@ -350,19 +350,6 @@
/*********** internal functions ***********/
-#if DB_VERSION_MAJOR == 2
-char *db_strerror(int err)
-{
- switch(err) {
- case DB_RUNRECOVERY:
- return "Recovery Needed";
- default:
- return strerror(err);
- }
-}
-#endif /* DB_VERSION_MAJOR == 2 */
-
-
static bool conf_bool_val(char *str, bool *value)
{
if(strcasecmp(str, "on") == 0
@@ -592,41 +579,24 @@
}
/* Function that db will use to report errors */
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
static void OVDBerror(const DB_ENV *dbenv UNUSED, const char *db_errpfx UNUSED, const char *buffer)
-#else
-static void OVDBerror(const char *db_errpfx UNUSED, char *buffer)
-#endif
{
warn("OVDB: %s", buffer);
}
static u_int32_t _db_flags = 0;
-#if DB_VERSION_MAJOR == 2
-static DB_INFO _dbinfo;
-#endif
static int open_db_file(int which)
{
int ret;
char name[10];
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
DB_TXN *tid;
-#endif
if(dbs[which] != NULL)
return 0;
snprintf(name, sizeof(name), "ov%05d", which);
-#if DB_VERSION_MAJOR == 2
- ret = db_open(name, DB_BTREE, _db_flags, 0666, OVDBenv, &_dbinfo,
- &(dbs[which]));
- if (ret != 0) {
- dbs[which] = NULL;
- return ret;
- }
-#else
ret = db_create(&(dbs[which]), OVDBenv, 0);
if (ret != 0)
return ret;
@@ -636,22 +606,16 @@
if(ovdb_conf.pagesize > 0)
(dbs[which])->set_pagesize(dbs[which], ovdb_conf.pagesize);
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
TXN_START_NORETRY(t_open_db_file, tid);
ret = (dbs[which])->open(dbs[which], tid, name, NULL, DB_BTREE, _db_flags,
0666);
if (ret == 0)
TXN_COMMIT(t_open_db_file, tid);
-#else
- ret = (dbs[which])->open(dbs[which], name, NULL, DB_BTREE, _db_flags,
- 0666);
-#endif
if (ret != 0) {
(dbs[which])->close(dbs[which], 0);
dbs[which] = NULL;
return ret;
}
-#endif
return 0;
}
@@ -1397,34 +1361,18 @@
DBT key, val;
u_int32_t dv;
-#if DB_VERSION_MAJOR == 2
- DB_INFO dbinfo;
- memset(&dbinfo, 0, sizeof dbinfo);
-
- ret = db_open("version", DB_BTREE, _db_flags, 0666, OVDBenv, &dbinfo,
- &vdb);
- if (ret != 0) {
- warn("OVDB: db_open failed: %s", db_strerror(ret));
- return ret;
- }
-#else
/* open version db */
ret = db_create(&vdb, OVDBenv, 0);
if (ret != 0) {
warn("OVDB: open: db_create: %s", db_strerror(ret));
return ret;
}
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
ret = vdb->open(vdb, NULL, "version", NULL, DB_BTREE, _db_flags, 0666);
-#else
- ret = vdb->open(vdb, "version", NULL, DB_BTREE, _db_flags, 0666);
-#endif
if (ret != 0) {
vdb->close(vdb, 0);
warn("OVDB: open: version->open: %s", db_strerror(ret));
return ret;
}
-#endif
memset(&key, 0, sizeof key);
memset(&val, 0, sizeof val);
key.data = (char *) "dataversion";
@@ -1543,28 +1491,6 @@
if(flags & OVDB_RECOVER)
ai_flags |= DB_RECOVER;
-#if DB_VERSION_MAJOR == 2 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR < 2)
- if(ovdb_conf.txn_nosync)
- ai_flags |= DB_TXN_NOSYNC;
-#endif
-
-#if DB_VERSION_MAJOR == 2
-
- OVDBenv = xcalloc(1, sizeof(DB_ENV));
-
- OVDBenv->db_errcall = OVDBerror;
- OVDBenv->mp_size = ovdb_conf.cachesize;
- OVDBenv->lk_max = ovdb_conf.maxlocks;
-
- /* initialize environment */
- ret = db_appinit(ovdb_conf.home, NULL, OVDBenv, ai_flags);
- if (ret != 0) {
- free(OVDBenv);
- OVDBenv = NULL;
- warn("OVDB: db_appinit failed: %s", db_strerror(ret));
- return ret;
- }
-#else
ret = db_env_create(&OVDBenv, 0);
if (ret != 0) {
warn("OVDB: db_env_create: %s", db_strerror(ret));
@@ -1576,32 +1502,20 @@
if(!(ai_flags & DB_PRIVATE)) {
if(ovdb_conf.useshm)
ai_flags |= DB_SYSTEM_MEM;
-#if DB_VERSION_MAJOR >= 4 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR > 0)
OVDBenv->set_shm_key(OVDBenv, ovdb_conf.shmkey);
-#endif
}
OVDBenv->set_errcall(OVDBenv, OVDBerror);
OVDBenv->set_cachesize(OVDBenv, 0, ovdb_conf.cachesize, ovdb_conf.ncache);
-#if DB_VERSION_MAJOR >= 4
OVDBenv->set_lk_max_locks(OVDBenv, ovdb_conf.maxlocks);
OVDBenv->set_lk_max_lockers(OVDBenv, ovdb_conf.maxlocks);
OVDBenv->set_lk_max_objects(OVDBenv, ovdb_conf.maxlocks);
-#else
- OVDBenv->set_lk_max(OVDBenv, ovdb_conf.maxlocks);
-#endif
-#if DB_VERSION_MAJOR >= 4 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR >= 2)
if(ovdb_conf.txn_nosync)
OVDBenv->set_flags(OVDBenv, DB_TXN_NOSYNC, 1);
-#endif
if((flags & (OVDB_UPGRADE | OVDB_RECOVER)) != OVDB_UPGRADE) {
-#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 0
- ret = OVDBenv->open(OVDBenv, ovdb_conf.home, NULL, ai_flags, 0666);
-#else
ret = OVDBenv->open(OVDBenv, ovdb_conf.home, ai_flags, 0666);
-#endif
if (ret != 0) {
OVDBenv->close(OVDBenv, 0);
OVDBenv = NULL;
@@ -1609,7 +1523,6 @@
return ret;
}
}
-#endif /* DB_VERSION_MAJOR == 2 */
return 0;
}
@@ -1617,11 +1530,7 @@
bool ovdb_open(int mode)
{
int i, ret;
-#if DB_VERSION_MAJOR == 2
- DB_INFO dbinfo;
-#else
DB_TXN *tid;
-#endif
if(OVDBenv != NULL || clientmode) {
warn("OVDB: ovdb_open called more than once");
@@ -1661,12 +1570,6 @@
oneatatime = 1;
}
-#if DB_VERSION_MAJOR == 2
- memset(&_dbinfo, 0, sizeof _dbinfo);
- _dbinfo.db_pagesize = ovdb_conf.pagesize;
- _dbinfo.bt_minkey = ovdb_conf.minkey;
-#endif
-
dbs = xcalloc(ovdb_conf.numdbfiles, sizeof(DB *));
if(!oneatatime) {
@@ -1679,38 +1582,16 @@
}
}
-#if DB_VERSION_MAJOR == 2
- memset(&dbinfo, 0, sizeof dbinfo);
-
- ret = db_open("groupinfo", DB_BTREE, _db_flags, 0666, OVDBenv,
- &dbinfo, &groupinfo);
- if (ret != 0) {
- warn("OVDB: db_open failed: %s", db_strerror(ret));
- return false;
- }
-
- ret = db_open("groupaliases", DB_HASH, _db_flags, 0666, OVDBenv,
- &dbinfo, &groupaliases);
- if (ret != 0) {
- warn("OVDB: db_open failed: %s", db_strerror(ret));
- return false;
- }
-#else
ret = db_create(&groupinfo, OVDBenv, 0);
if (ret != 0) {
warn("OVDB: open: db_create: %s", db_strerror(ret));
return false;
}
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
TXN_START_NORETRY(t_open_groupinfo, tid);
ret = groupinfo->open(groupinfo, tid, "groupinfo", NULL, DB_BTREE,
_db_flags, 0666);
if (ret == 0)
TXN_COMMIT(t_open_groupinfo, tid);
-#else
- ret = groupinfo->open(groupinfo, "groupinfo", NULL, DB_BTREE,
- _db_flags, 0666);
-#endif
if (ret != 0) {
groupinfo->close(groupinfo, 0);
warn("OVDB: open: groupinfo->open: %s", db_strerror(ret));
@@ -1721,22 +1602,16 @@
warn("OVDB: open: db_create: %s", db_strerror(ret));
return false;
}
-#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
TXN_START_NORETRY(t_open_groupaliases, tid);
ret = groupaliases->open(groupaliases, tid, "groupaliases", NULL, DB_HASH,
_db_flags, 0666);
if (ret == 0)
TXN_COMMIT(t_open_groupaliases, tid);
-#else
- ret = groupaliases->open(groupaliases, "groupaliases", NULL, DB_HASH,
- _db_flags, 0666);
-#endif
if (ret != 0) {
groupaliases->close(groupaliases, 0);
warn("OVDB: open: groupaliases->open: %s", db_strerror(ret));
return false;
}
-#endif
Cutofflow = false;
return true;
@@ -2061,8 +1936,8 @@
databuf = xrealloc(databuf, databuflen);
}
- /* hmm... BerkeleyDB needs something like a 'struct iovec' so that we don't
- have to make a new buffer and copy everything in to it */
+ /* Hmm... Berkeley DB needs something like a 'struct iovec' so that we don't
+ have to make a new buffer and copy everything in to it. */
((struct ovdata *)databuf)->token = token;
((struct ovdata *)databuf)->arrived = arrived;
@@ -3135,12 +3010,7 @@
{
if(OVDBenv) {
/* close db environment */
-#if DB_VERSION_MAJOR == 2
- db_appexit(OVDBenv);
- free(OVDBenv);
-#else
OVDBenv->close(OVDBenv, 0);
-#endif
OVDBenv = NULL;
}
}
More information about the inn-committers
mailing list