Fixes needed to allow build with HAVE_EXT_POSTGRESQL

This commit provides changes needed to allow a build with HAVE_EXT_POSTGRESQL defined. 

The DB components use sprintf in MyString rather than formatstr, so to limit the scope of the changes I added an "sprintf" function as a duplicate of the formatstr function, rather than rewriting dozens of sprintf references in multiple files.

Config for successful build was:

cmake cmake -DWANT_CONTRIB:BOOL=TRUE -DWANT_QUILL:BOOL=TRUE -DWITH_POSTGRESQL:BOOL=TRUE .