The builtin type bytea was computing the size incorrectly on output.
Kudos to Chris Anderson (chris@clinton.toaster.ba.md.us) for finding the problem AND providing the fix!
Apply this patch.
===================================================================
RCS file: /usr/local/devel/pglite/cvs/src/backend/utils/adt/varlena.c,v
retrieving revision 1.5
diff -c -r1.5 varlena.c
*** 1.5 1995/06/02 20:36:02
--- src/backend/utils/adt/varlena.c 1995/09/14 18:32:46
***************
*** 123,129 ****
}
vp = vlena->vl_dat;
len = 1; /* empty string has 1 char */
! for (i = vlena->vl_len - sizeof(int32); i != 0; i--) /* varlena? */
if (*vp == '\\')
len += 2;
else if (isascii(*vp) && isprint(*vp))
--- 123,129 ----
}
vp = vlena->vl_dat;
len = 1; /* empty string has 1 char */
! for (i = vlena->vl_len - sizeof(int32); i != 0; i--, vp++) /* varlena? */
if (*vp == '\\')
len += 2;
else if (isascii(*vp) && isprint(*vp))