[asterisk-dev] [Code Review] Replace Berkeley DB astdb with SQLite3

Terry Wilson reviewboard at asterisk.org
Wed Jun 15 23:55:23 CDT 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1269/
-----------------------------------------------------------

(Updated 2011-06-15 23:55:23.757205)


Review request for Asterisk Developers.


Changes
-------

Bug fixes and improvements

1) Better logs for conversion failures
2) Add "database query" CLI command to execute arbitrary SQL statements on
   the astdb. Of course this is highly dangerous since a "drop table astdb"
   would be particularly bad. This may or may not stick around, but is 
   certainly useful for debugging right now.
3) Fix a bug with ast_db_put that crept in when changing things around for
   handling conversion via an external tool.
4) Register an atexit function to sync the database and close it.
5) Move astdb_init up in order of initialization. It is fairly self contained
   and provides an API for other parts of Asterisk. One wouldn't want someone
   to call ast_db_put before we had initialized the database.
6) Fix two bugs with the conersion utility--don't put the trailing null in the 
   key and be sure and close the database.


Summary
-------

There have been a couple of bugs reported lately against the Berkeley DB version that Asterisk uses for its internal database. These bugs have been tracked to the actual Berkeley code Asterisk uses, which is very very old and unmaintained. This patch replaces the Berkeley code with SQLite3 while maintaining exactly the same API. If there is no sqlite3 version of the database already and there is a Berkeley DB version, it automatically converts the old database to the new format.

If this goes in, I would then like to update Olle's patch for Realtime support for astdb as well and get that in.


Diffs (updated)
-----

  /trunk/configure.ac 323928 
  /trunk/main/Makefile 323928 
  /trunk/main/asterisk.c 323928 
  /trunk/main/db.c 323928 
  /trunk/tests/test_db.c 323928 
  /trunk/utils/Makefile 323928 
  /trunk/utils/astdb2sqlite3.c PRE-CREATION 
  /trunk/utils/db1-ast/Makefile PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_close.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_conv.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_debug.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_delete.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_get.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_open.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_overflow.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_page.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_put.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_search.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_seq.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_split.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/bt_utils.c PRE-CREATION 
  /trunk/utils/db1-ast/btree/btree.h PRE-CREATION 
  /trunk/utils/db1-ast/btree/extern.h PRE-CREATION 
  /trunk/utils/db1-ast/db/db.c PRE-CREATION 
  /trunk/utils/db1-ast/hash/README PRE-CREATION 
  /trunk/utils/db1-ast/hash/extern.h PRE-CREATION 
  /trunk/utils/db1-ast/hash/hash.h PRE-CREATION 
  /trunk/utils/db1-ast/hash/hash.c PRE-CREATION 
  /trunk/utils/db1-ast/hash/hash_bigkey.c PRE-CREATION 
  /trunk/utils/db1-ast/hash/hash_buf.c PRE-CREATION 
  /trunk/utils/db1-ast/hash/hash_func.c PRE-CREATION 
  /trunk/utils/db1-ast/hash/hash_log2.c PRE-CREATION 
  /trunk/utils/db1-ast/hash/hash_page.c PRE-CREATION 
  /trunk/utils/db1-ast/hash/hsearch.c PRE-CREATION 
  /trunk/utils/db1-ast/hash/ndbm.c PRE-CREATION 
  /trunk/utils/db1-ast/hash/page.h PRE-CREATION 
  /trunk/utils/db1-ast/hash/search.h PRE-CREATION 
  /trunk/utils/db1-ast/include/circ-queue.h PRE-CREATION 
  /trunk/utils/db1-ast/include/compat.h PRE-CREATION 
  /trunk/utils/db1-ast/include/db.h PRE-CREATION 
  /trunk/utils/db1-ast/include/mpool.h PRE-CREATION 
  /trunk/utils/db1-ast/include/ndbm.h PRE-CREATION 
  /trunk/utils/db1-ast/libdb.map PRE-CREATION 
  /trunk/utils/db1-ast/mpool/README PRE-CREATION 
  /trunk/utils/db1-ast/mpool/mpool.c PRE-CREATION 
  /trunk/utils/db1-ast/recno/extern.h PRE-CREATION 
  /trunk/utils/db1-ast/recno/rec_close.c PRE-CREATION 
  /trunk/utils/db1-ast/recno/rec_delete.c PRE-CREATION 
  /trunk/utils/db1-ast/recno/rec_get.c PRE-CREATION 
  /trunk/utils/db1-ast/recno/rec_open.c PRE-CREATION 
  /trunk/utils/db1-ast/recno/rec_put.c PRE-CREATION 
  /trunk/utils/db1-ast/recno/rec_search.c PRE-CREATION 
  /trunk/utils/db1-ast/recno/rec_seq.c PRE-CREATION 
  /trunk/utils/db1-ast/recno/rec_utils.c PRE-CREATION 
  /trunk/utils/db1-ast/recno/recno.h PRE-CREATION 
  /trunk/utils/utils.xml 323928 

Diff: https://reviewboard.asterisk.org/r/1269/diff


Testing
-------

All astdb tests pass and I have tested converting several astdb databases.


Thanks,

Terry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20110616/758c5c0a/attachment.htm>


More information about the asterisk-dev mailing list