summaryrefslogtreecommitdiff
path: root/lib/db2.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2000-03-23 20:58:01 +0000
committerjbj <devnull@localhost>2000-03-23 20:58:01 +0000
commitea8051c29adcce7688286c3c7c620b46d6dad5b3 (patch)
treea2d9731b92ba8965ad368f4f24db2773700d4d94 /lib/db2.c
parentcab176172b8ef247f24e5aa0928c3aa0b8adabd9 (diff)
downloadlibrpm-tizen-ea8051c29adcce7688286c3c7c620b46d6dad5b3.tar.gz
librpm-tizen-ea8051c29adcce7688286c3c7c620b46d6dad5b3.tar.bz2
librpm-tizen-ea8051c29adcce7688286c3c7c620b46d6dad5b3.zip
convert db1 -> db2 on-disk format using --rebuilddb.
CVS patchset: 3637 CVS date: 2000/03/23 20:58:01
Diffstat (limited to 'lib/db2.c')
-rw-r--r--lib/db2.c145
1 files changed, 117 insertions, 28 deletions
diff --git a/lib/db2.c b/lib/db2.c
index fa5e01f0e..037133a2b 100644
--- a/lib/db2.c
+++ b/lib/db2.c
@@ -1,7 +1,8 @@
#include "system.h"
-#include <db.h>
+static int _debug = 0;
+#include <db.h>
#include <rpmlib.h>
@@ -49,7 +50,8 @@ static int db_init(dbiIndex dbi, const char *home, int dbflags,
if (rc)
goto errxit;
- dbinfo->db_pagesize = 1024;
+ /* XXX W2DO? */
+ dbinfo->db_pagesize = 32 * 1024;
if (dbenvp)
*dbenvp = dbenv;
@@ -85,10 +87,15 @@ int db2open(dbiIndex dbi)
((dbi->dbi_flags & O_CREAT) ? DB_CREATE : 0));
rc = db_init(dbi, dbhome, dbflags, &dbenv, &dbinfo);
+if (_debug)
+fprintf(stderr, "*** db%d db_init rc %d errno %d\n", dbi->dbi_major, rc, errno);
- if (rc == 0)
+ if (rc == 0) {
rc = db_open(dbi->dbi_file, dbi_to_dbtype(dbi->dbi_type), dbflags,
dbi->dbi_perms, dbenv, dbinfo, &db);
+if (_debug)
+fprintf(stderr, "*** db%d db_open rc %d errno %d\n", dbi->dbi_major, rc, errno);
+ }
dbi->dbi_db = db;
dbi->dbi_dbenv = dbenv;
@@ -112,7 +119,7 @@ int db2open(dbiIndex dbi)
int db2close(dbiIndex dbi, unsigned int flags) {
DB * db = GetDB(dbi);
- int rc;
+ int rc, xx;
#if defined(__USE_DB2)
DB_ENV * dbenv = (DB_ENV *)dbi->dbi_dbenv;
@@ -120,11 +127,15 @@ int db2close(dbiIndex dbi, unsigned int flags) {
DBC * dbcursor = (DBC *)dbi->dbi_dbcursor;
if (dbcursor) {
- (void)dbcursor->c_close(dbcursor);
+ xx = dbcursor->c_close(dbcursor);
+if (_debug)
+fprintf(stderr, "*** db%d db->c_close rc %d errno %d\n", dbi->dbi_major, xx, errno);
dbi->dbi_dbcursor = NULL;
}
rc = db->close(db, 0);
+if (_debug)
+fprintf(stderr, "*** db%d db->close rc %d errno %d\n", dbi->dbi_major, rc, errno);
dbi->dbi_db = NULL;
if (dbinfo) {
@@ -132,7 +143,9 @@ int db2close(dbiIndex dbi, unsigned int flags) {
dbi->dbi_dbinfo = NULL;
}
if (dbenv) {
- (void) db_appexit(dbenv);
+ xx = db_appexit(dbenv);
+if (_debug)
+fprintf(stderr, "*** db%d db_appexit rc %d errno %d\n", dbi->dbi_major, xx, errno);
free(dbenv);
dbi->dbi_dbenv = NULL;
}
@@ -142,13 +155,23 @@ int db2close(dbiIndex dbi, unsigned int flags) {
switch (rc) {
default:
- case RET_ERROR: /* -1 */
rc = -1;
break;
- case RET_SPECIAL: /* 1 */
+ case DB_INCOMPLETE:
+ case DB_KEYEMPTY:
+ case DB_KEYEXIST:
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ case DB_LOCK_NOTHELD:
+ case DB_NOTFOUND:
+ case DB_DELETED:
+ case DB_NEEDSPLIT:
+ case DB_REGISTERED:
+ case DB_SWAPBYTES:
+ case DB_TXN_CKP:
rc = 1;
break;
- case RET_SUCCESS: /* 0 */
+ case 0:
rc = 0;
break;
}
@@ -162,19 +185,31 @@ int db2sync(dbiIndex dbi, unsigned int flags) {
#if defined(__USE_DB2)
rc = db->sync(db, flags);
+if (_debug)
+fprintf(stderr, "*** db%d db->sync rc %d errno %d\n", dbi->dbi_major, rc, errno);
#else
rc = db->sync(db, flags);
#endif
switch (rc) {
default:
- case RET_ERROR: /* -1 */
rc = -1;
break;
- case RET_SPECIAL: /* 1 */
+ case DB_INCOMPLETE:
+ case DB_KEYEMPTY:
+ case DB_KEYEXIST:
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ case DB_LOCK_NOTHELD:
+ case DB_NOTFOUND:
+ case DB_DELETED:
+ case DB_NEEDSPLIT:
+ case DB_REGISTERED:
+ case DB_SWAPBYTES:
+ case DB_TXN_CKP:
rc = 1;
break;
- case RET_SUCCESS: /* 0 */
+ case 0:
rc = 0;
break;
}
@@ -185,7 +220,7 @@ int db2sync(dbiIndex dbi, unsigned int flags) {
int db2GetFirstKey(dbiIndex dbi, const char ** keyp) {
DBT key, data;
DB * db;
- int rc;
+ int rc, xx;
if (dbi == NULL || dbi->dbi_db == NULL)
return 1;
@@ -200,10 +235,18 @@ int db2GetFirstKey(dbiIndex dbi, const char ** keyp) {
#if defined(__USE_DB2)
{ DBC * dbcursor = NULL;
rc = db->cursor(db, NULL, &dbcursor);
- if (rc == 0)
+if (_debug)
+fprintf(stderr, "*** db%d db->cursor rc %d errno %d\n", dbi->dbi_major, rc, errno);
+ if (rc == 0) {
rc = dbcursor->c_get(dbcursor, &key, &data, DB_FIRST);
- if (dbcursor)
- (void)dbcursor->c_close(dbcursor);
+if (_debug)
+fprintf(stderr, "*** db%d dbcursor->c_get rc %d errno %d\n", dbi->dbi_major, rc, errno);
+ }
+ if (dbcursor) {
+ xx = dbcursor->c_close(dbcursor);
+if (_debug)
+fprintf(stderr, "*** db%d dbcursor->c_close rc %d errno %d\n", dbi->dbi_major, xx, errno);
+ }
}
#else
rc = db->seq(db, &key, &data, R_FIRST);
@@ -211,11 +254,21 @@ int db2GetFirstKey(dbiIndex dbi, const char ** keyp) {
switch (rc) {
default:
- case RET_ERROR: /* -1 */
- case RET_SPECIAL: /* 1 */
+ case DB_INCOMPLETE:
+ case DB_KEYEMPTY:
+ case DB_KEYEXIST:
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ case DB_LOCK_NOTHELD:
+ case DB_NOTFOUND:
+ case DB_DELETED:
+ case DB_NEEDSPLIT:
+ case DB_REGISTERED:
+ case DB_SWAPBYTES:
+ case DB_TXN_CKP:
rc = 1;
break;
- case RET_SUCCESS: /* 0 */
+ case 0:
rc = 0;
if (keyp) {
char *k = xmalloc(key.size + 1);
@@ -245,19 +298,31 @@ int db2SearchIndex(dbiIndex dbi, const char * str, dbiIndexSet * set) {
#if defined(__USE_DB2)
rc = db->get(db, NULL, &key, &data, 0);
+if (_debug)
+fprintf(stderr, "*** db%d db->get rc %d errno %d\n", dbi->dbi_major, rc, errno);
#else
rc = db->get(db, &key, &data, 0);
#endif
switch (rc) {
default:
- case RET_ERROR: /* -1 */
rc = -1;
break;
- case RET_SPECIAL: /* 1 */
+ case DB_INCOMPLETE:
+ case DB_KEYEMPTY:
+ case DB_KEYEXIST:
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ case DB_LOCK_NOTHELD:
+ case DB_NOTFOUND:
+ case DB_DELETED:
+ case DB_NEEDSPLIT:
+ case DB_REGISTERED:
+ case DB_SWAPBYTES:
+ case DB_TXN_CKP:
rc = 1;
break;
- case RET_SUCCESS: /* 0 */
+ case 0:
rc = 0;
if (set) {
*set = dbiCreateIndexSet();
@@ -289,17 +354,29 @@ int db2UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) {
#if defined(__USE_DB2)
rc = db->put(db, NULL, &key, &data, 0);
+if (_debug)
+fprintf(stderr, "*** db%d db->put rc %d errno %d\n", dbi->dbi_major, rc, errno);
#else
rc = db->put(db, &key, &data, 0);
#endif
switch (rc) {
default:
- case RET_ERROR: /* -1 */
- case RET_SPECIAL: /* 1 */
+ case DB_INCOMPLETE:
+ case DB_KEYEMPTY:
+ case DB_KEYEXIST:
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ case DB_LOCK_NOTHELD:
+ case DB_NOTFOUND:
+ case DB_DELETED:
+ case DB_NEEDSPLIT:
+ case DB_REGISTERED:
+ case DB_SWAPBYTES:
+ case DB_TXN_CKP:
rc = 1;
break;
- case RET_SUCCESS: /* 0 */
+ case 0: /* 0 */
rc = 0;
break;
}
@@ -307,17 +384,29 @@ int db2UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) {
#if defined(__USE_DB2)
rc = db->del(db, NULL, &key, 0);
+if (_debug)
+fprintf(stderr, "*** db%d db->del rc %d errno %d\n", dbi->dbi_major, rc, errno);
#else
rc = db->del(db, &key, 0);
#endif
switch (rc) {
default:
- case RET_ERROR: /* -1 */
- case RET_SPECIAL: /* 1 */
+ case DB_INCOMPLETE:
+ case DB_KEYEMPTY:
+ case DB_KEYEXIST:
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ case DB_LOCK_NOTHELD:
+ case DB_NOTFOUND:
+ case DB_DELETED:
+ case DB_NEEDSPLIT:
+ case DB_REGISTERED:
+ case DB_SWAPBYTES:
+ case DB_TXN_CKP:
rc = 1;
break;
- case RET_SUCCESS: /* 0 */
+ case 0:
rc = 0;
break;
}