Refactoring DBMS string escaping functions