Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bsddb btree set_location() semantics changed #39062

Closed
gpshead opened this issue Aug 13, 2003 · 3 comments
Closed

bsddb btree set_location() semantics changed #39062

gpshead opened this issue Aug 13, 2003 · 3 comments
Assignees
Labels
extension-modules C modules in the Modules dir

Comments

@gpshead
Copy link
Member

gpshead commented Aug 13, 2003

BPO 788421
Nosy @gpshead

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/gpshead'
closed_at = <Date 2004-03-16.07:59:33.000>
created_at = <Date 2003-08-13.23:21:08.000>
labels = ['extension-modules']
title = 'bsddb btree set_location() semantics changed'
updated_at = <Date 2004-03-16.07:59:33.000>
user = 'https://github.com/gpshead'

bugs.python.org fields:

activity = <Date 2004-03-16.07:59:33.000>
actor = 'gregory.p.smith'
assignee = 'gregory.p.smith'
closed = True
closed_date = None
closer = None
components = ['Extension Modules']
creation = <Date 2003-08-13.23:21:08.000>
creator = 'gregory.p.smith'
dependencies = []
files = []
hgrepos = []
issue_num = 788421
keywords = []
message_count = 3.0
messages = ['17747', '17748', '17749']
nosy_count = 1.0
nosy_names = ['gregory.p.smith']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue788421'
versions = ['Python 2.3']

@gpshead
Copy link
Member Author

gpshead commented Aug 13, 2003

In the old bsddb module a bsddb.btopen(..) database
would return the next available key+value on a
set_location(key) call when key did not exist in the
database. In python 2.3 (pybsddb) it raises an
exception and leaves the cursor at an unknown position
in the database.

[reported by Anthony McDonaly on comp.lang.python]

>>> import os
>>> import bsddb
>>> os.chdir('/tmp')
>>> my_data = bsddb.btopen('testing', 'c')
>>> for i in range(10):
...   if i == 5:
...     pass
...   else:
...     my_data['%d'%i] = '%d'%(i*i)
...
>>> my_data.keys()
['0', '1', '2', '3', '4', '6', '7', '8', '9']
>>> my_data.sync()
>>> my_data.set_location('5')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File
"/space/python-2.3/lib/python2.3/bsddb/__init__.py",
line 117, in set_location
    return self.dbc.set(key)
_bsddb.DBNotFoundError: (-30991, 'DB_NOTFOUND: No
matching key/data pair found')

Correct behaviour would have been to return ('6', '36')

@gpshead gpshead closed this as completed Aug 13, 2003
@gpshead gpshead self-assigned this Aug 13, 2003
@gpshead gpshead added the extension-modules C modules in the Modules dir label Aug 13, 2003
@gpshead gpshead closed this as completed Aug 13, 2003
@gpshead gpshead self-assigned this Aug 13, 2003
@gpshead gpshead added the extension-modules C modules in the Modules dir label Aug 13, 2003
@gpshead
Copy link
Member Author

gpshead commented Feb 26, 2004

Logged In: YES
user_id=413

Yes this is a bug. The set_location() method should have been calling set_range() rather than set() internally.

Fixing that exposed another bug: set_range() would crash when looking up a key that exists in hash or rn databases.

Both bugs have been fixed to fix this one in python 2.4 & pybsddb CVS.

This bugfix should go into python 2.3.4.

@gpshead
Copy link
Member Author

gpshead commented Mar 16, 2004

Logged In: YES
user_id=413

committed fix to head and release23-maint along with an associated fix for set_range where it could free() memory that it doesn't own on non B-Tree databases.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir
Projects
None yet
Development

No branches or pull requests

1 participant