postgres sequence error fix, issue #602