log postgresql error context if it is available
remove excess parenthesis from sql statement of remove-by-attributes method