Improvements to the C++ generator.
Apply Firebird-specific patch by Alex Peshkov - to be reworked or reverted.