PostgreSQL support

Hi Paul,

Many thanks for your work. About a year and a half ago, I added support for PostgreSQL for profiling a production backend by hacking the source with a sledge hammer. I now decided to sit down and see what it would take to add proper support which could be pushed back to trunk using the budding new database abstraction layer. This is it. Changes were required in quite a few places and as such this patch is likely to break at least some pull requests which have not been merged in. I would appreciate any comments you have and will be happy to clean things up further as needed should you wish to merge.

Keep up the great work!
 -Kris