Code review for GUC serialization/deserialization code.
Code review for GUC serialization/deserialization code.

The serialization code dumped core for a string-valued GUC whose value
is NULL, which is a legal state.  The infrastructure isn't capable of
transmitting that state exactly, but fortunately, transmitting an empty
string instead should be close enough (compare, eg, commit e45e990e4).

The code potentially underestimated the space required to format a
real-valued variable, both because it made an unwarranted assumption that
%g output would never be longer than %e output, and because it didn't count
right even for %e format.  In practice this would pretty much always be
masked by overestimates for other variables, but it's still wrong.

Also fix boundary-case error in read_gucstate, incorrect handling of the
case where guc_sourcefile is non-NULL but zero length (not clear that can
happen, but if it did, this code would get totally confused), and
confusingly useless check for a NULL result from read_gucstate.

Andreas Seltenreich discovered the core dump; other issues noted while
reading nearby code.  Back-patch to 9.5 where this code was introduced.

Michael Paquier and Tom Lane

Discussion: <c421fca78f7b1093fd5bf5d6825182eea846d791@credativ.de>

xinzweb/gpdb,adam8157/gpdb,50wu/gpdb,lisakowen/gpdb,lisakowen/gpdb,greenplum-db/gpdb,xinzweb/gpdb,adam8157/gpdb,xinzweb/gpdb,greenplum-db/gpdb,50wu/gpdb,greenplum-db/gpdb,xinzweb/gpdb,adam8157/gpdb,50wu/gpdb,xinzweb/gpdb,adam8157/gpdb,greenplum-db/gpdb,lisakowen/gpdb,50wu/gpdb,greenplum-db/gpdb,adam8157/gpdb,lisakowen/gpdb,lisakowen/gpdb,lisakowen/gpdb,xinzweb/gpdb,adam8157/gpdb,greenplum-db/gpdb,50wu/gpdb,50wu/gpdb,adam8157/gpdb,lisakowen/gpdb,lisakowen/gpdb,50wu/gpdb,xinzweb/gpdb,greenplum-db/gpdb,xinzweb/gpdb,50wu/gpdb,adam8157/gpdb,greenplum-db/gpdb