[server] Fix SQL syntax errors for Postgresql.