Prevent errors in cases where OldValue is NULL

In sufficiently old or inconsistent databases, OldValue may be NULL; on
Pg, this results in a fatal error.  On all databases, error-proof by
assuming that values of NULL are really 0 and continue.
Merge branch '4.2/timeworked-upgrade-bulletproof'