Added sql functions to check if we really need to do any conversion.