[pybsddb] Problems with set_get_returns_none
Albert Chin
pybsddb at mlists.thewrittenword.com
Tue May 13 19:56:12 CEST 2014
If set_get_returns_none is set in the environment and a database is
created under this environment, should the set_get_returns_none()
setting be propagated?
Consider the following:
#!/usr/bin/python2
from bsddb3 import db
e = db.DBEnv ()
e.set_get_returns_none (0)
e.open (None, db.DB_CREATE | db.DB_PRIVATE | db.DB_RECOVER | \
db.DB_INIT_LOCK | db.DB_INIT_LOG | db.DB_INIT_MPOOL | \
db.DB_INIT_TXN)
d = db.DB (e)
d.open ('files.db', db.DB_BTREE, db.DB_CREATE, 0664)
c = d.cursor ()
c.set ('foo')
c.close ()
d.close ()
e.close ()
Executing it returns nothing:
# ./t
<empty>
However, if I add "d.set_get_returns_none (0)" to get:
#!/usr/bin/python2
from bsddb3 import db
e = db.DBEnv ()
e.set_get_returns_none (0)
e.open (None, db.DB_CREATE | db.DB_PRIVATE | db.DB_RECOVER | \
db.DB_INIT_LOCK | db.DB_INIT_LOG | db.DB_INIT_MPOOL | \
db.DB_INIT_TXN)
d = db.DB (e)
d.set_get_returns_none (0)
d.open ('files.db', db.DB_BTREE, db.DB_CREATE, 0664)
c = d.cursor ()
c.set ('foo')
c.close ()
d.close ()
e.close ()
then executing it returns:
# ./t
Traceback (most recent call last):
File "./t.py", line 16, in <module>
c.set ('foo')
bsddb3._pybsddb.DBNotFoundError: (-30988, 'DB_NOTFOUND: No matching key/data pair found')
I would expect the latter behaviour from the original code.
--
albert chin (china at thewrittenword.com)
More information about the pybsddb
mailing list