repair postgres where bug