Progress of the SQL database backend

September 05, 2008

While Jan and Henner have been concentrating on the stacking feature, me and Jesper have been struggling in the database land.

So the SQL database support is progressing. I ported the SQL backend to QtSQL when the KDE 4 port of KPhotoAlbum was started, but back then I did not really have time to test it. So my first work here was to finish the port and make the backend work again, now with KDE 4 and QtSQL. That was not so hard after all, and now I am able to save my KPhotoAlbum database to SQL again. Currently I'm working with SQLite database, but others like MySQL and PostgreSQL will (probably) be supported too.

Then we also had few longish discussions how to make the damn thing fast. First we are optimizing the "Show thumbnails" action for all images. It's currently very slow with the SQL backend, if you have a lot of images (like 10 000 or more). We came up with an idea, that probably solves it and are already implementing it.

Schema of the database was also reviewed, leading to some field renames, which are good to make at this point before anybody uses the database for real work.

One big difference of the SQL backend compared to XML backend is error handling. Because XML backend is handled in memory and used by only a single user at a time, the operations done with it basically cannot fail, but with the SQL that is not the case. For example we have a problem when connection to database is lost while runnig the application or when there are some conflicts when users concurrently change the database.

The biggest problem for me to implement error handling was that I thought that basicly the whole user interface would have to be rewritten to do the right thing when there is an error. And so it would be a lot of work. Gladly Jan came up with a good solution to that. We just use a functor in the database API to give an error handler for the database backend and handle the errors in the database side. That functor could then pop up a dialog to ask user if she wants to try again or abort.

— Tuomas