--- fe-exec.c	2003-11-02 23:42:41 +0300
+++ fe-exec.new.c	2003-11-18 18:52:43 +0300
@@ -2258,10 +2258,9 @@
  *		INSERT statement with a bytea type column as the target.
  *
  *		The following transformations are applied
- *		'\0' == ASCII  0 == \\000
  *		'\'' == ASCII 39 == \'
  *		'\\' == ASCII 92 == \\\\
- *		anything >= 0x80 ---> \\ooo (where ooo is an octal expression)
+ *		anything !isprint || !isascii ---> \\ooo (where ooo is an octal expression)
  */
 unsigned char *
 PQescapeBytea(const unsigned char *bintext, size_t binlen, size_t *bytealen)
@@ -2280,7 +2279,7 @@
 	vp = bintext;
 	for (i = binlen; i > 0; i--, vp++)
 	{
-		if (*vp == 0 || *vp >= 0x80)
+		if (!isprint(*vp) || !isascii(*vp))
 			len += 5;			/* '5' is for '\\ooo' */
 		else if (*vp == '\'')
 			len += 2;
@@ -2299,7 +2298,7 @@
 
 	for (i = binlen; i > 0; i--, vp++)
 	{
-		if (*vp == 0 || *vp >= 0x80)
+		if (!isprint(*vp) || !isascii(*vp))
 		{
 			(void) sprintf(rp, "\\\\%03o", *vp);
 			rp += 5;
