[Python-checkins] r46685 - in python/branches/release24-maint: Misc/NEWS Modules/_bsddb.c
gregory.p.smith
python-checkins at python.org
Tue Jun 6 02:23:26 CEST 2006
Author: gregory.p.smith
Date: Tue Jun 6 02:23:21 2006
New Revision: 46685
Modified:
python/branches/release24-maint/Misc/NEWS
python/branches/release24-maint/Modules/_bsddb.c
Log:
- Bug #1493322: bsddb: the __len__ method of a DB object has been fixed to
return correct results. It could previously incorrectly return 0 in some
cases. Fixes SF bug 1493322 (pybsddb bug 1184012).
Modified: python/branches/release24-maint/Misc/NEWS
==============================================================================
--- python/branches/release24-maint/Misc/NEWS (original)
+++ python/branches/release24-maint/Misc/NEWS Tue Jun 6 02:23:21 2006
@@ -35,6 +35,11 @@
- Bug #1117761: bsddb.*open() no longer raises an exception when using
the cachesize parameter.
+- Bug #1493322: bsddb: the __len__ method of a DB object has been fixed to
+ return correct results. It could previously incorrectly return 0 in some
+ cases. Fixes SF bug 1493322 (pybsddb bug 1184012).
+
+
Library
-------
Modified: python/branches/release24-maint/Modules/_bsddb.c
==============================================================================
--- python/branches/release24-maint/Modules/_bsddb.c (original)
+++ python/branches/release24-maint/Modules/_bsddb.c Tue Jun 6 02:23:21 2006
@@ -2450,10 +2450,15 @@
if (self->haveStat) { /* Has the stat function been called recently? If
so, we can use the cached value. */
+#if (DBVER <= 32)
flags = DB_CACHED_COUNTS;
+#else
+ flags = DB_FAST_STAT;
+#endif
}
MYDB_BEGIN_ALLOW_THREADS;
+redo_stat_for_length:
#if (DBVER >= 43)
err = self->db->stat(self->db, /*txnid*/ NULL, &sp, flags);
#elif (DBVER >= 33)
@@ -2461,6 +2466,20 @@
#else
err = self->db->stat(self->db, &sp, NULL, flags);
#endif
+
+ /* All the stat structures have matching fields upto the ndata field,
+ so we can use any of them for the type cast */
+ size = ((DB_BTREE_STAT*)sp)->bt_ndata;
+
+ /* A size of 0 could mean that BerkeleyDB no longer had the stat values cached.
+ * redo a full stat to make sure.
+ * Fixes SF python bug 1493322, pybsddb bug 1184012
+ */
+ if (size == 0 && (flags & DB_FAST_STAT)) {
+ flags = 0;
+ goto redo_stat_for_length;
+ }
+
MYDB_END_ALLOW_THREADS;
if (err)
@@ -2468,9 +2487,6 @@
self->haveStat = 1;
- /* All the stat structures have matching fields upto the ndata field,
- so we can use any of them for the type cast */
- size = ((DB_BTREE_STAT*)sp)->bt_ndata;
free(sp);
return size;
}
More information about the Python-checkins
mailing list