This patch fixes one serious bug (runaway INSERT) and a few rare (andhard to reproduce) error conditions.
Servus Manfred