在UNIX环境下使用DBSQL作为FireFox/SQLite Manager的底层存储引擎
本文介绍如何在UNIX/Linux环境下将FireFox/SQLite Manager的底层存储引擎由SQLite转换为DBSQL.本博客介绍的过程同样也可推及到Google Chrome等使用SQLite作为存储引擎的优秀开源软件.
本文假定您已经根据在unixlinux平台上应用berkeley db 11gr2sql成功编译了DBSQL.
最后,需要特别强调的是,在做存储引擎转换和数据迁移前,必须做好用户数据的备份,以防操作不慎或其它意外造成的数据损坏.
Firefox 3.6 on Linux
Firefox distributions do not link to external/system sqlite3 lib. So we have to rebuild firefox from source code to force it to link system sqlite3 by “–enable-system-sqlite”
1. Install sqlite-3.6.22
We need original sqlite3 because we have to migrate existing database.
Download http://www.sqlite.org/sqlite-3.6.22.tar.gz
tar zxf sqlite-3.6.22.tar.gz env CFLAGS="-DSQLITE_SECURE_DELETE=1" ./configure --prefix=/usr make sudo make install
2. Build Firefox 3.6
Note:This step may replace your system Firefox. Please backup your ~/.mozilla at first.
Get source code
mkdir $HOME/src/firefox-3.6 hg clone http://hg.mozilla.org/mozilla-central/ src cd $HOME/src/firefox-3.6
Create a file “mozconfig” in current directory. Content of file “mozconfig”:
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-release ac_add_options --enable-system-sqlite ac_add_options --disable-ogg ac_add_options --disable-wave ac_add_options --disable-crashreporter ac_add_options --disable-necko-wifi
Build
make -f client.mk sudo make -f client.mk install
3. Buid BDB SQL
Place up-to-date db source code on $HOME/hg/db_x86
cd $HOME/hg/db_x86/build_unix env CFLAGS="-O3" ../dist/configure --enable-sql_compat --enable-sql make dbsql && make install
4. Modify Firefox linking
cd /usr/local/lib/firefox-3.7a2pre sudo ln -sf $HOME/install/lib/libdb_sql-5.0.so libsqlite3.so.0
5. Data Migration
(The directory name on my computer is “yezkdh8w.default”. It may be different in your platform)
Here is an example for data migration. Here we just take downloads.sqlite as example. You may need to go through all *.sqlite files:
cd ~/.mozilla/firefox/ cp yezkdh8w.default yezkdh8w.default.bak -r # backup cd yezkdh8w.default bash ../firefox_convert.sh /usr/bin/sqlite3 /home/rucong/install/bin/dbsql $ sqlite3 downloads.sqlite SQLite version 3.6.22 Enter ".help" for instructions sqlite> .echo ON sqlite> .output dump .output dump sqlite> .dump .dump sqlite> .quit .quit $ mv downloads.sqlite downloads.sqlite.bak $ ~/hg/db_x86/build_unix/dbsql downloads.sqlite Berkeley DB 11g Release 2, library version 11.2.5.0.21: (March 30, 2010) Enter ".help" for instructions Enter SQL statements terminated with a ";" dbsql> .read dump dbsql> .quit $ rm dump
6. End
That’s all. Execute the new Firefox to see how it works.
SQLite Manager
1. Install SQLite Manager
Use above Firefox to visit SQLite Manager Plugin and install it.
Restart Firefox. We can start SQLite Manager by Menu->Tools->SQLite Manager now.
2. Open a BDB SQL Database
Generate database
Note: The version of BDB SQL has to be the same as the one we applied in Firefox.
cd db/build_unix make ex_sql_binding ./ex_sql_binding
Now we get BDB SQL database ex_sql_binding.db.
Use SQLite Manager to open the generated db
Start SQLite Manager to open database db/build_unix/ex_sql_binding.db:

最近评论