sql bug fixed in db.sql