CRM-13072 api improvements, return failed sql to permissioned users, cast getcount to an integer, whitespace