From a68a132a6c0f90e5d03e8409e843e6117d5412a2 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Sat, 6 Dec 1997 22:57:36 +0000
Subject: [PATCH] Add VARHDRSZ where needed.  Many places just used 4.

---
 src/backend/access/common/printtup.c |  4 +-
 src/backend/commands/async.c         |  4 +-
 src/backend/commands/trigger.c       |  2 +-
 src/backend/libpq/be-pqexec.c        |  8 ++--
 src/backend/parser/gram.y            |  4 +-
 src/backend/tcop/dest.c              | 10 ++---
 src/backend/tcop/fastpath.c          |  4 +-
 src/backend/utils/adt/arrayfuncs.c   | 32 +++++++-------
 src/backend/utils/adt/chunk.c        | 12 +++---
 src/backend/utils/adt/varchar.c      | 62 ++++++++++++++--------------
 src/backend/utils/adt/varlena.c      |  4 +-
 src/bin/pg_dump/pg_dump.c            |  4 +-
 src/bin/psql/psql.c                  |  6 +--
 13 files changed, 78 insertions(+), 78 deletions(-)

diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c
index 38d254af87e..41d307c9b8d 100644
--- a/src/backend/access/common/printtup.c
+++ b/src/backend/access/common/printtup.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.18 1997/09/12 04:07:12 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.19 1997/12/06 22:56:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -124,7 +124,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
 		{
 			outputstr = fmgr(typoutput, attr,
 							 gettypelem(typeinfo->attrs[i]->atttypid));
-			pq_putint(strlen(outputstr) + 4, 4);
+			pq_putint(strlen(outputstr) + VARHDRSZ, VARHDRSZ);
 			pq_putnchar(outputstr, strlen(outputstr));
 			pfree(outputstr);
 		}
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 257be8a1e9a..42a607051f3 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.24 1997/11/20 23:20:56 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.25 1997/12/06 22:56:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -619,7 +619,7 @@ Async_NotifyFrontEnd()
 		if (whereToSendOutput == Remote)
 		{
 			pq_putnchar("A", 1);
-			pq_putint(ourpid, 4);
+			pq_putint(ourpid, sizeof(ourpid));
 			pq_putstr(DatumGetName(d)->data);
 			pq_flush();
 		}
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 3427936f284..abc7815f918 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -176,7 +176,7 @@ CreateTrigger(CreateTrigStmt * stmt)
 		{
 			char	   *ar = (char *) lfirst(le);
 
-			len += strlen(ar) + 4;
+			len += strlen(ar) + VARHDRSZ;
 			for (; *ar; ar++)
 			{
 				if (*ar == '\\')
diff --git a/src/backend/libpq/be-pqexec.c b/src/backend/libpq/be-pqexec.c
index c090480ab8f..d0f133f47a4 100644
--- a/src/backend/libpq/be-pqexec.c
+++ b/src/backend/libpq/be-pqexec.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.9 1997/11/10 05:15:49 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.10 1997/12/06 22:56:35 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -80,7 +80,7 @@ PQfn(int fnid,
 		{
 			arg[i] = (char *) args[i].u.ptr;
 		}
-		else if (args[i].len > 4)
+		else if (args[i].len > sizeof(int4))
 		{
 			elog(WARN, "arg_length of argument %d too long", i);
 		}
@@ -357,7 +357,7 @@ pqtest_PQfn(char *q)
 		v = atoi(fields[j]);
 		if (v != 0 || (v == 0 && fields[j][0] == '0'))
 		{
-			pqargs[k].len = 4;
+			pqargs[k].len = sizeof(int4);
 			pqargs[k].u.integer = v;
 			printf("pqtest_PQfn: arg %d is int %d\n", k, v);	/* debug */
 		}
@@ -373,7 +373,7 @@ pqtest_PQfn(char *q)
 	 *	call PQfn
 	 * ----------------
 	 */
-	pqres = PQfn(f, &res, 4, 1, pqargs, i - 1);
+	pqres = PQfn(f, &res, sizeof(int4), 1, pqargs, i - 1);
 	printf("pqtest_PQfn: pqres is %s\n", pqres);		/* debug */
 
 	/* ----------------
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 145a2f0e3d2..082bf4e92f6 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.77 1997/12/04 23:07:23 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.78 1997/12/06 22:56:42 momjian Exp $
  *
  * HISTORY
  *	  AUTHOR			DATE			MAJOR EVENT
@@ -2660,7 +2660,7 @@ Character:  character '(' Iconst ')'
 					 * between this and "text" is that we blank-pad and
 					 * truncate where necessary
 					 */
-					$$->typlen = 4 + $3;
+					$$->typlen = VARHDRSZ + $3;
 				}
 		| character
 				{
diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c
index 81c80288465..c808a46e1d0 100644
--- a/src/backend/tcop/dest.c
+++ b/src/backend/tcop/dest.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.14 1997/11/27 03:01:12 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.15 1997/12/06 22:57:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -192,9 +192,9 @@ NullCommand(CommandDest dest)
 					 nPtr = (PQNotifyList *) SLGetSucc(&nPtr->Node))
 				{
 					pq_putnchar("A", 1);
-					pq_putint(0, 4);
+					pq_putint(0, sizeof(int4));
 					pq_putstr(nPtr->relname);
-					pq_putint(nPtr->be_pid, 4);
+					pq_putint(nPtr->be_pid, sizeof(nPtr->be_pid));
 					PQremoveNotify(nPtr);
 				}
 				pq_flush();
@@ -283,8 +283,8 @@ BeginCommand(char *pname,
 				{
 					pq_putstr(attrs[i]->attname.data);	/* if 16 char name
 														 * oops.. */
-					pq_putint((int) attrs[i]->atttypid, 4);
-					pq_putint(attrs[i]->attlen, 2);
+					pq_putint((int) attrs[i]->atttypid, sizeof(attrs[i]->atttypid));
+					pq_putint(attrs[i]->attlen, sizeof(attrs[i]->attlen));
 				}
 			}
 			break;
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index 0573ea2fc88..b4fb2ebaec4 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.7 1997/09/18 20:21:58 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.8 1997/12/06 22:57:03 momjian Exp $
  *
  * NOTES
  *	  This cruft is the server side of PQfn.
@@ -101,7 +101,7 @@ SendFunctionResult(Oid fid,		/* function id */
 		{						/* by-reference ... */
 			if (retlen < 0)
 			{					/* ... varlena */
-				pq_putint(VARSIZE(retval) - VARHDRSZ, 4);
+				pq_putint(VARSIZE(retval) - VARHDRSZ, VARHDRSZ);
 				pq_putnchar(VARDATA(retval), VARSIZE(retval) - VARHDRSZ);
 			}
 			else
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 6ba5f6b7e44..0b352fd309f 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.20 1997/09/18 20:22:10 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.21 1997/12/06 22:57:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -649,7 +649,7 @@ array_out(ArrayType *v, Oid element_type)
 
 		/* get a wide string to print to */
 		p = array_dims(v, &dummy_bool);
-		nbytes = strlen(ARR_DATA_PTR(v)) + 4 + *(int *) p;
+		nbytes = strlen(ARR_DATA_PTR(v)) + VARHDRSZ + *(int *) p;
 
 		save_p = (char *) palloc(nbytes);
 
@@ -787,18 +787,18 @@ array_dims(ArrayType *v, bool *isNull)
 	/*
 	 * 33 since we assume 15 digits per number + ':' +'[]'
 	 */
-	save_p = p = (char *) palloc(nbytes + 4);
-	MemSet(save_p, 0, nbytes + 4);
+	save_p = p = (char *) palloc(nbytes + VARHDRSZ);
+	MemSet(save_p, 0, nbytes + VARHDRSZ);
 	dimv = ARR_DIMS(v);
 	lb = ARR_LBOUND(v);
-	p += 4;
+	p += VARHDRSZ;
 	for (i = 0; i < ARR_NDIM(v); i++)
 	{
 		sprintf(p, "[%d:%d]", lb[i], dimv[i] + lb[i] - 1);
 		p += strlen(p);
 	}
-	nbytes = strlen(save_p + 4) + 4;
-	memmove(save_p, &nbytes, 4);
+	nbytes = strlen(save_p + VARHDRSZ) + VARHDRSZ;
+	memmove(save_p, &nbytes, VARHDRSZ);
 	return (save_p);
 }
 
@@ -874,7 +874,7 @@ array_ref(ArrayType *array,
 		}
 		if (*isNull)
 			RETURN_NULL;
-		if (VARSIZE(v) - 4 < elmlen)
+		if (VARSIZE(v) - VARHDRSZ < elmlen)
 			RETURN_NULL;
 		lo_close(fd);
 		retval = (char *) _ArrayCast((char *) VARDATA(v), reftype, elmlen);
@@ -1000,22 +1000,22 @@ array_clip(ArrayType *array,
 		{
 			char	   *buff;
 
-			rsize += 4;
+			rsize += VARHDRSZ;
 			buff = palloc(rsize);
 			if (buff)
 				isDestLO = false;
 			if (ARR_IS_CHUNKED(array))
 			{
-				_ReadChunkArray(lowerIndx, upperIndx, len, fd, &(buff[4]),
+				_ReadChunkArray(lowerIndx, upperIndx, len, fd, &(buff[VARHDRSZ]),
 								array, 0, isNull);
 			}
 			else
 			{
-				_ReadArray(lowerIndx, upperIndx, len, fd, (int) &(buff[4]),
+				_ReadArray(lowerIndx, upperIndx, len, fd, (int) &(buff[VARHDRSZ]),
 						   array,
 						   0, isNull);
 			}
-			memmove(buff, &rsize, 4);
+			memmove(buff, &rsize, VARHDRSZ);
 #ifdef LOARRAY
 			if (!*isNull)
 				bytes = LOwrite(newfd, (struct varlena *) buff);
@@ -1131,15 +1131,15 @@ array_set(ArrayType *array,
 #endif
 		if (lo_lseek(fd, offset, SEEK_SET) < 0)
 			return ((char *) array);
-		v = (struct varlena *) palloc(elmlen + 4);
-		VARSIZE(v) = elmlen + 4;
+		v = (struct varlena *) palloc(elmlen + VARHDRSZ);
+		VARSIZE(v) = elmlen + VARHDRSZ;
 		ArrayCastAndSet(dataPtr, (bool) reftype, elmlen, VARDATA(v));
 #ifdef LOARRAY
 		n = LOwrite(fd, v);
 #endif
 
 		/*
-		 * if (n < VARSIZE(v) - 4) RETURN_NULL;
+		 * if (n < VARSIZE(v) - VARHDRSZ) RETURN_NULL;
 		 */
 		pfree(v);
 		lo_close(fd);
@@ -1692,7 +1692,7 @@ _LOtransfer(char **destfd,
 		{
 #ifdef LOARRAY
 			v = (struct varlena *) LOread((int) *srcfd, inc);
-			if (VARSIZE(v) - 4 < inc)
+			if (VARSIZE(v) - VARHDRSZ < inc)
 			{
 				pfree(v);
 				return (-1);
diff --git a/src/backend/utils/adt/chunk.c b/src/backend/utils/adt/chunk.c
index ea274467a12..0fc431314cb 100644
--- a/src/backend/utils/adt/chunk.c
+++ b/src/backend/utils/adt/chunk.c
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.10 1997/09/08 21:48:19 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.11 1997/12/06 22:57:12 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -271,7 +271,7 @@ get_next(int d[], int k, int C, int dmax[])
 }
 
 #ifdef LOARRAY
-static char a_chunk[BLCKSZ + 4];/* 4 since a_chunk is in varlena format */
+static char a_chunk[BLCKSZ + VARHDRSZ];/* VARHDRSZ since a_chunk is in varlena format */
 
 #endif
 
@@ -318,8 +318,8 @@ _ConvertToChunkFile(int n,
 		csize *= C[i];
 	}
 	csize *= baseSize;
-	temp = csize + 4;
-	memmove(a_chunk, &temp, 4);
+	temp = csize + VARHDRSZ;
+	memmove(a_chunk, &temp, VARHDRSZ);
 
 	mda_get_prod(n, dim, PX);
 	mda_get_offset_values(n, dist, PX, C);
@@ -327,7 +327,7 @@ _ConvertToChunkFile(int n,
 		;
 	do
 	{
-		read_chunk(chunk_no, C, &(a_chunk[4]), srcfd, n, baseSize, PX, dist);
+		read_chunk(chunk_no, C, &(a_chunk[VARHDRSZ]), srcfd, n, baseSize, PX, dist);
 		write_chunk((struct varlena *) a_chunk, destfd);
 	} while (next_tuple(n, chunk_no, max_chunks) != -1);
 }
@@ -417,7 +417,7 @@ seek_and_read(int pos, int size, char buff[], int fp, int from)
 #ifdef LOARRAY
 	v = (struct varlena *) LOread(fp, size);
 #endif
-	if (VARSIZE(v) - 4 < size)
+	if (VARSIZE(v) - VARHDRSZ < size)
 		elog(WARN, "File read error");
 	memmove(buff, VARDATA(v), size);
 	pfree(v);
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index 9b2f4129c8b..1661f08cd8a 100644
--- a/src/backend/utils/adt/varchar.c
+++ b/src/backend/utils/adt/varchar.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.11 1997/10/25 01:10:50 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.12 1997/12/06 22:57:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -46,7 +46,7 @@
 /*
  * bpcharin -
  *	  converts a string of char() type to the internal representation.
- *	  len is the length specified in () plus 4 bytes. (XXX dummy is here
+ *	  len is the length specified in () plus VARHDRSZ bytes. (XXX dummy is here
  *	  because we pass typelem as the second argument for array_in.)
  */
 char	   *
@@ -54,7 +54,7 @@ bpcharin(char *s, int dummy, int typlen)
 {
 	char	   *result,
 			   *r;
-	int			len = typlen - 4;
+	int			len = typlen - VARHDRSZ;
 	int			i;
 
 	if (s == NULL)
@@ -67,7 +67,7 @@ bpcharin(char *s, int dummy, int typlen)
 		 * this is here because some functions can't supply the typlen
 		 */
 		len = strlen(s);
-		typlen = len + 4;
+		typlen = len + VARHDRSZ;
 	}
 
 	if (len > 4096)
@@ -75,7 +75,7 @@ bpcharin(char *s, int dummy, int typlen)
 
 	result = (char *) palloc(typlen);
 	*(int32 *) result = typlen;
-	r = result + 4;
+	r = result + VARHDRSZ;
 	for (i = 0; i < len; i++, r++, s++)
 	{
 		*r = *s;
@@ -104,9 +104,9 @@ bpcharout(char *s)
 	}
 	else
 	{
-		len = *(int32 *) s - 4;
+		len = *(int32 *) s - VARHDRSZ;
 		result = (char *) palloc(len + 1);
-		StrNCpy(result, s + 4, len+1);	/* these are blank-padded */
+		StrNCpy(result, s + VARHDRSZ, len+1);	/* these are blank-padded */
 	}
 	return (result);
 }
@@ -118,14 +118,14 @@ bpcharout(char *s)
 /*
  * vcharin -
  *	  converts a string of varchar() type to the internal representation.
- *	  len is the length specified in () plus 4 bytes. (XXX dummy is here
+ *	  len is the length specified in () plus VARHDRSZ bytes. (XXX dummy is here
  *	  because we pass typelem as the second argument for array_in.)
  */
 char	   *
 varcharin(char *s, int dummy, int typlen)
 {
 	char	   *result;
-	int			len = typlen - 4;
+	int			len = typlen - VARHDRSZ;
 
 	if (s == NULL)
 		return ((char *) NULL);
@@ -137,7 +137,7 @@ varcharin(char *s, int dummy, int typlen)
 		 * this is here because some functions can't supply the typlen
 		 */
 		len = strlen(s);
-		typlen = len + 4;
+		typlen = len + VARHDRSZ;
 	}
 
 	if (len > 4096)
@@ -145,7 +145,7 @@ varcharin(char *s, int dummy, int typlen)
 
 	result = (char *) palloc(typlen);
 	*(int32 *) result = typlen;
-	strncpy(result + 4, s, len+1);
+	strncpy(result + VARHDRSZ, s, len+1);
 
 	return (result);
 }
@@ -164,9 +164,9 @@ varcharout(char *s)
 	}
 	else
 	{
-		len = *(int32 *) s - 4;
+		len = *(int32 *) s - VARHDRSZ;
 		result = (char *) palloc(len + 1);
-		StrNCpy(result, s + 4, len+1);
+		StrNCpy(result, s + VARHDRSZ, len+1);
 	}
 	return (result);
 }
@@ -178,11 +178,11 @@ varcharout(char *s)
 static int
 bcTruelen(char *arg)
 {
-	char	   *s = arg + 4;
+	char	   *s = arg + VARHDRSZ;
 	int			i;
 	int			len;
 
-	len = *(int32 *) arg - 4;
+	len = *(int32 *) arg - VARHDRSZ;
 	for (i = len - 1; i >= 0; i--)
 	{
 		if (s[i] != ' ')
@@ -205,7 +205,7 @@ bpchareq(char *arg1, char *arg2)
 	if (len1 != len2)
 		return 0;
 
-	return (strncmp(arg1 + 4, arg2 + 4, len1) == 0);
+	return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) == 0);
 }
 
 bool
@@ -222,7 +222,7 @@ bpcharne(char *arg1, char *arg2)
 	if (len1 != len2)
 		return 1;
 
-	return (strncmp(arg1 + 4, arg2 + 4, len1) != 0);
+	return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) != 0);
 }
 
 bool
@@ -237,7 +237,7 @@ bpcharlt(char *arg1, char *arg2)
 	len1 = bcTruelen(arg1);
 	len2 = bcTruelen(arg2);
 
-	cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
+	cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
 	if (cmp == 0)
 		return (len1 < len2);
 	else
@@ -256,7 +256,7 @@ bpcharle(char *arg1, char *arg2)
 	len1 = bcTruelen(arg1);
 	len2 = bcTruelen(arg2);
 
-	cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
+	cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
 	if (0 == cmp)
 		return (bool) (len1 <= len2 ? 1 : 0);
 	else
@@ -275,7 +275,7 @@ bpchargt(char *arg1, char *arg2)
 	len1 = bcTruelen(arg1);
 	len2 = bcTruelen(arg2);
 
-	cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
+	cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
 	if (cmp == 0)
 		return (len1 > len2);
 	else
@@ -294,7 +294,7 @@ bpcharge(char *arg1, char *arg2)
 	len1 = bcTruelen(arg1);
 	len2 = bcTruelen(arg2);
 
-	cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
+	cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
 	if (0 == cmp)
 		return (bool) (len1 >= len2 ? 1 : 0);
 	else
@@ -311,7 +311,7 @@ bpcharcmp(char *arg1, char *arg2)
 	len1 = bcTruelen(arg1);
 	len2 = bcTruelen(arg2);
 
-	cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
+	cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
 	if ((0 == cmp) && (len1 != len2))
 		return (int32) (len1 < len2 ? -1 : 1);
 	else
@@ -325,11 +325,11 @@ bpcharcmp(char *arg1, char *arg2)
 static int
 vcTruelen(char *arg)
 {
-	char	   *s = arg + 4;
+	char	   *s = arg + VARHDRSZ;
 	int			i;
 	int			len;
 
-	len = *(int32 *) arg - 4;
+	len = *(int32 *) arg - VARHDRSZ;
 	for (i = 0; i < len; i++)
 	{
 		if (*s++ == '\0')
@@ -352,7 +352,7 @@ varchareq(char *arg1, char *arg2)
 	if (len1 != len2)
 		return 0;
 
-	return (strncmp(arg1 + 4, arg2 + 4, len1) == 0);
+	return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) == 0);
 }
 
 bool
@@ -369,7 +369,7 @@ varcharne(char *arg1, char *arg2)
 	if (len1 != len2)
 		return 1;
 
-	return (strncmp(arg1 + 4, arg2 + 4, len1) != 0);
+	return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) != 0);
 }
 
 bool
@@ -384,7 +384,7 @@ varcharlt(char *arg1, char *arg2)
 	len1 = vcTruelen(arg1);
 	len2 = vcTruelen(arg2);
 
-	cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
+	cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
 	if (cmp == 0)
 		return (len1 < len2);
 	else
@@ -403,7 +403,7 @@ varcharle(char *arg1, char *arg2)
 	len1 = vcTruelen(arg1);
 	len2 = vcTruelen(arg2);
 
-	cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
+	cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
 	if (0 == cmp)
 		return (bool) (len1 <= len2 ? 1 : 0);
 	else
@@ -422,7 +422,7 @@ varchargt(char *arg1, char *arg2)
 	len1 = vcTruelen(arg1);
 	len2 = vcTruelen(arg2);
 
-	cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
+	cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
 	if (cmp == 0)
 		return (len1 > len2);
 	else
@@ -441,7 +441,7 @@ varcharge(char *arg1, char *arg2)
 	len1 = vcTruelen(arg1);
 	len2 = vcTruelen(arg2);
 
-	cmp = strncmp(arg1 + 4, arg2 + 4, Min(len1, len2));
+	cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
 	if (0 == cmp)
 		return (bool) (len1 >= len2 ? 1 : 0);
 	else
@@ -458,7 +458,7 @@ varcharcmp(char *arg1, char *arg2)
 
 	len1 = vcTruelen(arg1);
 	len2 = vcTruelen(arg2);
-	cmp = (strncmp(arg1 + 4, arg2 + 4, Min(len1, len2)));
+	cmp = (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2)));
 	if ((0 == cmp) && (len1 != len2))
 		return (int32) (len1 < len2 ? -1 : 1);
 	else
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 4c4aa5b3630..4e97f148fb4 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.22 1997/11/23 21:39:12 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.23 1997/12/06 22:57:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -132,7 +132,7 @@ byteaout(struct varlena * vlena)
 		else if (isascii(*vp) && isprint(*vp))
 			len++;
 		else
-			len += 4;
+			len += VARHDRSZ;
 	rp = result = (char *) palloc(len);
 	vp = vlena->vl_dat;
 	for (i = vlena->vl_len - sizeof(int32); i != 0; i--)		/* varlena? */
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index c047b73ea99..53755af0991 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -21,7 +21,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.57 1997/12/05 01:04:25 scrappy Exp $
+ *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.58 1997/12/06 22:57:28 momjian Exp $
  *
  * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
  *
@@ -1671,7 +1671,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
 			tblinfo[i].typnames[j] = strdup(PQgetvalue(res, j, i_typname));
 			tblinfo[i].attlen[j] = atoi(PQgetvalue(res, j, i_attlen));
 			if (tblinfo[i].attlen[j] > 0)
-				tblinfo[i].attlen[j] = tblinfo[i].attlen[j] - 4;
+				tblinfo[i].attlen[j] = tblinfo[i].attlen[j] - VARHDRSZ;
 			tblinfo[i].inhAttrs[j] = 0; /* this flag is set in
 										 * flagInhAttrs() */
 			tblinfo[i].notnull[j] = (PQgetvalue(res, j, i_attnotnull)[0] == 't') ? true : false;
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index 2232cf72e9b..9ab9f78b4ab 100644
--- a/src/bin/psql/psql.c
+++ b/src/bin/psql/psql.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.119 1997/12/05 01:13:11 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.120 1997/12/06 22:57:36 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -616,12 +616,12 @@ tableDesc(PsqlSettings *pset, char *table, FILE *fout)
 			else if (strcmp(rtype, "bpchar") == 0)
 			{
 				fprintf(fout,"%-32.32s |", "(bp)char");
-				fprintf(fout,"%6i |", rsize > 0 ? rsize - 4 : 0);
+				fprintf(fout,"%6i |", rsize > 0 ? rsize - VARHDRSZ : 0);
 			}
 			else if (strcmp(rtype, "varchar") == 0)
 			{
 				fprintf(fout,"%-32.32s |", rtype);
-				fprintf(fout,"%6i |", rsize > 0 ? rsize - 4 : 0);
+				fprintf(fout,"%6i |", rsize > 0 ? rsize - VARHDRSZ: 0);
 			}
 			else
 			{
-- 
GitLab