[pybsddb] bsddb3 patch for DB_DBT_MULTIPLE support

phu kungphu at gmail.com
Tue Oct 14 22:13:07 CEST 2008


Attached is a very simple patch to Modules/_bsddb.c which adds the ability
for associate() callback functions to return lists of strings as opposed to
just DB_DONOTINDEX or a single string.

I ran the normal tests (against BDB 4.6.21_p3-r1 on gentoo amd64) to ensure
I haven't broken anything; I also replaced a few genre entries in
test_associate.py with lists of genre strings to ensure that the library did
not break when running the unit test again (which is the successful output
shown below).  While more detailed testing could be done to ensure that the
secondary keys are being inserted correctly, I have confirmed that they are
on a separate app that's using this module.

While I think BDB should be taking care of the allocated DBT memory thanks
to DB_APPMALLOC based on the other code in this module and on a previous
pure C module I wrote, I can't be 100% sure (I unfortunately don't have a
whole lot of time to test in a more in-depth manner).

My apologies if there's a more formal way patches should be introduced and I
missed it.  I hope this is useful!
Eric

# python setup.py build && python setup.py install && python test.py
Found Berkeley DB 4.6 installation.
  include files in /usr/include
  library files in /usr/lib64
  library name is libdb-4.6
running build
running build_py
running build_ext
building 'bsddb3._pybsddb' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -fPIC -DPYBSDDB_STANDALONE=1 -I/usr/include
-I/usr/local/include/python2.6 -c Modules/_bsddb.c -o
build/temp.linux-x86_64-2.6/Modules/_bsddb.o
gcc -pthread -shared build/temp.linux-x86_64-2.6/Modules/_bsddb.o
-L/usr/lib64 -Wl,-R/usr/lib64 -ldb-4.6 -o
build/lib.linux-x86_64-2.6/bsddb3/_pybsddb.so
Found Berkeley DB 4.6 installation.
  include files in /usr/include
  library files in /usr/lib64
  library name is libdb-4.6
running install
running build
running build_py
running build_ext
running install_lib
copying build/lib.linux-x86_64-2.6/bsddb3/_pybsddb.so ->
/usr/local/lib/python2.6/site-packages/bsddb3
running install_headers
running install_egg_info
Removing /usr/local/lib/python2.6/site-packages/bsddb3-4.7.3-py2.6.egg-info
Writing /usr/local/lib/python2.6/site-packages/bsddb3-4.7.3-py2.6.egg-info
Running tests from /home/username/Desktop/bsddb3-4.7.3/build

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Berkeley DB 4.6.21: (October  2, 2008)
bsddb.db.version():   (4, 6, 21)
bsddb.db.__version__: 4.7.3
bsddb.db.cvsid:       $Id: _bsddb.c 629 2008-10-03 12:48:06Z jcea $
py module:
/home/username/Desktop/bsddb3-4.7.3/build/lib.linux-x86_64-2.6/bsddb3/__init__.pyc
extension module:
/home/username/Desktop/bsddb3-4.7.3/build/lib.linux-x86_64-2.6/bsddb3/_pybsddb.so
python version:       2.6 (r26:66714, Oct 13 2008, 12:39:03)
[GCC 4.1.2 (Gentoo 4.1.2 p1.1)]
My pid:               8296
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
----------------------------------------------------------------------
Ran 318 tests in 45.226s

OK
#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.jcea.es/pipermail/pybsddb/attachments/20081014/1c58dc79/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DB_DBT_MULTIPLE.patch
Type: application/octet-stream
Size: 1931 bytes
Desc: not available
URL: <https://mailman.jcea.es/pipermail/pybsddb/attachments/20081014/1c58dc79/attachment.obj>


More information about the pybsddb mailing list