fallback to memory stream when tmpfile fails

stop logging sql exceptions during header insertions